From 38717ce0a581b535cd4bca227240a64af34bc856 Mon Sep 17 00:00:00 2001 From: sotaro Date: Tue, 9 May 2017 01:19:48 -0700 Subject: [PATCH] Bug 1360717 - Make WebRenderCompositableHolder could generate WrImageKey r=nical --- gfx/layers/ipc/CompositorBridgeParent.cpp | 3 ++- gfx/layers/wr/WebRenderBridgeParent.cpp | 2 +- gfx/layers/wr/WebRenderBridgeParent.h | 4 ++++ gfx/layers/wr/WebRenderCompositableHolder.cpp | 4 +++- gfx/layers/wr/WebRenderCompositableHolder.h | 14 +++++++++++++- 5 files changed, 23 insertions(+), 4 deletions(-) diff --git a/gfx/layers/ipc/CompositorBridgeParent.cpp b/gfx/layers/ipc/CompositorBridgeParent.cpp index de0c9120eefb..e57287bb32e9 100644 --- a/gfx/layers/ipc/CompositorBridgeParent.cpp +++ b/gfx/layers/ipc/CompositorBridgeParent.cpp @@ -1612,7 +1612,8 @@ CompositorBridgeParent::AllocPWebRenderBridgeParent(const wr::PipelineId& aPipel RefPtr widget = mWidget; RefPtr api = wr::WebRenderAPI::Create( gfxPrefs::WebRenderProfilerEnabled(), this, Move(widget), aSize); - RefPtr holder = new WebRenderCompositableHolder(); + RefPtr holder = + new WebRenderCompositableHolder(WebRenderBridgeParent::AllocIdNameSpace()); MOZ_ASSERT(api); // TODO have a fallback api->SetRootPipeline(aPipelineId); mWrBridge = new WebRenderBridgeParent(this, aPipelineId, mWidget, nullptr, Move(api), Move(holder)); diff --git a/gfx/layers/wr/WebRenderBridgeParent.cpp b/gfx/layers/wr/WebRenderBridgeParent.cpp index 1fcab91fd4c9..31778680fb26 100644 --- a/gfx/layers/wr/WebRenderBridgeParent.cpp +++ b/gfx/layers/wr/WebRenderBridgeParent.cpp @@ -119,7 +119,7 @@ WebRenderBridgeParent::WebRenderBridgeParent(CompositorBridgeParentBase* aCompos , mChildLayerObserverEpoch(0) , mParentLayerObserverEpoch(0) , mWrEpoch(0) - , mIdNameSpace(++sIdNameSpace) + , mIdNameSpace(AllocIdNameSpace()) , mPaused(false) , mDestroyed(false) { diff --git a/gfx/layers/wr/WebRenderBridgeParent.h b/gfx/layers/wr/WebRenderBridgeParent.h index 1f390e71c984..cc2e036bd025 100644 --- a/gfx/layers/wr/WebRenderBridgeParent.h +++ b/gfx/layers/wr/WebRenderBridgeParent.h @@ -165,6 +165,10 @@ public: void UpdateAPZ(); const WebRenderScrollData& GetScrollData() const; + static uint32_t AllocIdNameSpace() { + return ++sIdNameSpace; + } + private: virtual ~WebRenderBridgeParent(); diff --git a/gfx/layers/wr/WebRenderCompositableHolder.cpp b/gfx/layers/wr/WebRenderCompositableHolder.cpp index 5a0cd453fa75..59807772ba47 100644 --- a/gfx/layers/wr/WebRenderCompositableHolder.cpp +++ b/gfx/layers/wr/WebRenderCompositableHolder.cpp @@ -15,7 +15,9 @@ using namespace gfx; namespace layers { -WebRenderCompositableHolder::WebRenderCompositableHolder() +WebRenderCompositableHolder::WebRenderCompositableHolder(uint32_t aIdNamespace) + : mIdNamespace(aIdNamespace) + , mResourceId(0) { MOZ_COUNT_CTOR(WebRenderCompositableHolder); } diff --git a/gfx/layers/wr/WebRenderCompositableHolder.h b/gfx/layers/wr/WebRenderCompositableHolder.h index 36502fbd4774..98fac30001f1 100644 --- a/gfx/layers/wr/WebRenderCompositableHolder.h +++ b/gfx/layers/wr/WebRenderCompositableHolder.h @@ -28,7 +28,7 @@ class WebRenderCompositableHolder final public: NS_INLINE_DECL_THREADSAFE_REFCOUNTING(WebRenderCompositableHolder) - explicit WebRenderCompositableHolder(); + explicit WebRenderCompositableHolder(uint32_t aIdNamespace); protected: ~WebRenderCompositableHolder(); @@ -59,6 +59,16 @@ public: return mCompositeUntilTime; } + uint32_t GetNextResourceId() { return ++mResourceId; } + uint32_t GetNamespace() { return mIdNamespace; } + WrImageKey GetImageKey() + { + WrImageKey key; + key.mNamespace = GetNamespace(); + key.mHandle = GetNextResourceId(); + return key; + } + private: struct ForwardingTextureHost { @@ -75,6 +85,8 @@ private: std::queue mTextureHosts; }; + uint32_t mIdNamespace; + uint32_t mResourceId; nsClassHashtable mPipelineTexturesHolders; // Render time for the current composition.