Bug 1475139 part 9 - Use DrawDependentSurface in nsDisplayRemote when painting to a temp layer manager with a recording. r=mattwoodrow

Differential Revision: https://phabricator.services.mozilla.com/D6788

--HG--
extra : rebase_source : be90e03c9db768ecbc1b7f419f5ab9eda36e9ae4
This commit is contained in:
Ryan Hunt 2018-09-24 21:45:54 -05:00
parent 0548fffa40
commit f1dc235e14
3 changed files with 55 additions and 25 deletions

View File

@ -367,7 +367,16 @@ nsSubDocumentFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
}
if (rfp) {
rfp->BuildDisplayList(aBuilder, this, aLists);
// We're the subdoc for <browser remote="true"> and it has
// painted content. Display its shadow layer tree.
DisplayListClipState::AutoSaveRestore clipState(aBuilder);
nsPoint offset = aBuilder->ToReferenceFrame(this);
nsRect bounds = this->EnsureInnerView()->GetBounds() + offset;
clipState.ClipContentDescendants(bounds);
aLists.Content()->AppendToTop(
MakeDisplayItem<nsDisplayRemote>(aBuilder, this));
return;
}

View File

@ -274,23 +274,6 @@ RenderFrameParent::TriggerRepaint()
docFrame->InvalidateLayer(DisplayItemType::TYPE_REMOTE);
}
void
RenderFrameParent::BuildDisplayList(nsDisplayListBuilder* aBuilder,
nsSubDocumentFrame* aFrame,
const nsDisplayListSet& aLists)
{
// We're the subdoc for <browser remote="true"> and it has
// painted content. Display its shadow layer tree.
DisplayListClipState::AutoSaveRestore clipState(aBuilder);
nsPoint offset = aBuilder->ToReferenceFrame(aFrame);
nsRect bounds = aFrame->EnsureInnerView()->GetBounds() + offset;
clipState.ClipContentDescendants(bounds);
aLists.Content()->AppendToTop(
MakeDisplayItem<nsDisplayRemote>(aBuilder, aFrame));
}
void
RenderFrameParent::GetTextureFactoryIdentifier(TextureFactoryIdentifier* aTextureFactoryIdentifier)
{
@ -341,6 +324,7 @@ RenderFrameParent::EnsureLayersConnected(CompositorOptions* aCompositorOptions)
nsDisplayRemote::nsDisplayRemote(nsDisplayListBuilder* aBuilder,
nsSubDocumentFrame* aFrame)
: nsDisplayItem(aBuilder, aFrame)
, mTabId{0}
, mEventRegionsOverride(EventRegionsOverride::NoOverride)
{
bool frameIsPointerEventsNone =
@ -352,6 +336,25 @@ nsDisplayRemote::nsDisplayRemote(nsDisplayListBuilder* aBuilder,
if (nsLayoutUtils::HasDocumentLevelListenersForApzAwareEvents(aFrame->PresShell())) {
mEventRegionsOverride |= EventRegionsOverride::ForceDispatchToContent;
}
nsFrameLoader* frameLoader = GetRenderFrameParent()->FrameLoader();
if (frameLoader) {
TabParent* browser = TabParent::GetFrom(frameLoader);
if (browser) {
mTabId = browser->GetTabId();
}
}
}
mozilla::LayerState
nsDisplayRemote::GetLayerState(nsDisplayListBuilder* aBuilder,
LayerManager* aManager,
const ContainerLayerParameters& aParameters)
{
if (mozilla::layout::IsTempLayerManager(aManager)) {
return mozilla::LAYER_NONE;
}
return mozilla::LAYER_ACTIVE_FORCE;
}
bool
@ -378,6 +381,21 @@ nsDisplayRemote::BuildLayer(nsDisplayListBuilder* aBuilder,
return layer.forget();
}
void
nsDisplayRemote::Paint(nsDisplayListBuilder* aBuilder, gfxContext* aCtx)
{
DrawTarget* target = aCtx->GetDrawTarget();
if (!target->IsRecording() || mTabId == 0) {
NS_WARNING("Remote iframe not rendered");
return;
}
int32_t appUnitsPerDevPixel = mFrame->PresContext()->AppUnitsPerDevPixel();
Rect destRect =
mozilla::NSRectToSnappedRect(GetContentRect(), appUnitsPerDevPixel, *target);
target->DrawDependentSurface(mTabId, destRect);
}
bool
nsDisplayRemote::CreateWebRenderCommands(mozilla::wr::DisplayListBuilder& aBuilder,
mozilla::wr::IpcResourceUpdateQueue& aResources,

View File

@ -10,6 +10,7 @@
#include "mozilla/Attributes.h"
#include <map>
#include "mozilla/dom/ipc/IdType.h"
#include "mozilla/layers/APZUtils.h"
#include "mozilla/layers/CompositorOptions.h"
#include "mozilla/layers/LayersTypes.h"
@ -64,9 +65,6 @@ public:
bool IsInitted();
void Destroy();
void BuildDisplayList(nsDisplayListBuilder* aBuilder,
nsSubDocumentFrame* aFrame,
const nsDisplayListSet& aLists);
already_AddRefed<Layer> BuildLayer(nsDisplayListBuilder* aBuilder,
nsIFrame* aFrame,
@ -90,6 +88,11 @@ public:
LayerManager* AttachLayerManager();
nsFrameLoader* FrameLoader() const
{
return mFrameLoader;
}
protected:
void ActorDestroy(ActorDestroyReason why) override;
@ -155,15 +158,14 @@ public:
LayerState GetLayerState(nsDisplayListBuilder* aBuilder,
LayerManager* aManager,
const ContainerLayerParameters& aParameters) override
{
return mozilla::LAYER_ACTIVE_FORCE;
}
const ContainerLayerParameters& aParameters) override;
already_AddRefed<Layer>
BuildLayer(nsDisplayListBuilder* aBuilder, LayerManager* aManager,
const ContainerLayerParameters& aContainerParameters) override;
void Paint(nsDisplayListBuilder* aBuilder, gfxContext* aCtx) override;
bool CreateWebRenderCommands(mozilla::wr::DisplayListBuilder& aBuilder,
mozilla::wr::IpcResourceUpdateQueue& aResources,
const StackingContextHelper& aSc,
@ -178,6 +180,7 @@ private:
mozilla::layers::LayersId GetRemoteLayersId() const;
RenderFrameParent* GetRenderFrameParent() const;
mozilla::dom::TabId mTabId;
mozilla::LayoutDeviceIntPoint mOffset;
mozilla::layers::EventRegionsOverride mEventRegionsOverride;
};