diff --git a/gfx/layers/CompositorTypes.h b/gfx/layers/CompositorTypes.h index 9e2214a2f97..020b705a783 100644 --- a/gfx/layers/CompositorTypes.h +++ b/gfx/layers/CompositorTypes.h @@ -74,7 +74,7 @@ enum TextureHostFlags { TEXTURE_HOST_DEFAULT = 0, // The default texture host for the given // SurfaceDescriptor - TEXTURE_HOST_TILED = 1 << 0, // A texture host that supports tiling + TEXTURE_HOST_TILED = 1 << 0 // A texture host that supports tiling }; /** diff --git a/gfx/layers/basic/BasicTiledThebesLayer.cpp b/gfx/layers/basic/BasicTiledThebesLayer.cpp index 20dfe99629f..35d3743ef58 100644 --- a/gfx/layers/basic/BasicTiledThebesLayer.cpp +++ b/gfx/layers/basic/BasicTiledThebesLayer.cpp @@ -15,11 +15,9 @@ namespace layers { BasicTiledThebesLayer::BasicTiledThebesLayer(BasicShadowLayerManager* const aManager) : ThebesLayer(aManager, static_cast(this)) - , mTiledBuffer(this, aManager) - , mLowPrecisionTiledBuffer(this, aManager) + , mContentClient() { MOZ_COUNT_CTOR(BasicTiledThebesLayer); - mLowPrecisionTiledBuffer.SetResolution(gfxPlatform::GetLowPrecisionResolution()); mPaintData.mLastScrollOffset = gfx::Point(0, 0); mPaintData.mFirstPaint = true; } @@ -126,7 +124,15 @@ BasicTiledThebesLayer::PaintThebes(gfxContext* aContext, return; } - if (mTiledBuffer.HasFormatChanged()) { + if (!mContentClient) { + mContentClient = new TiledContentClient(this, BasicManager()); + + mContentClient->Connect(); + BasicManager()->Attach(mContentClient, this); + MOZ_ASSERT(mContentClient->GetForwarder()); + } + + if (mContentClient->mTiledBuffer.HasFormatChanged()) { mValidRegion = nsIntRegion(); } @@ -151,9 +157,11 @@ BasicTiledThebesLayer::PaintThebes(gfxContext* aContext, NS_ASSERTION(!BasicManager()->IsRepeatTransaction(), "Didn't paint our mask layer"); - mTiledBuffer.PaintThebes(mValidRegion, invalidRegion, aCallback, aCallbackData); + mContentClient->mTiledBuffer.PaintThebes(mValidRegion, invalidRegion, + aCallback, aCallbackData); - mTiledBuffer.LockCopyAndWrite(); + BasicManager()->Hold(this); + mContentClient->LockCopyAndWrite(TiledContentClient::TILED_BUFFER); return; } @@ -199,33 +207,35 @@ BasicTiledThebesLayer::PaintThebes(gfxContext* aContext, // Only draw progressively when the resolution is unchanged. if (gfxPlatform::UseProgressiveTilePainting() && !BasicManager()->HasShadowTarget() && - mTiledBuffer.GetFrameResolution() == mPaintData.mResolution) { + mContentClient->mTiledBuffer.GetFrameResolution() == mPaintData.mResolution) { // Store the old valid region, then clear it before painting. // We clip the old valid region to the visible region, as it only gets // used to decide stale content (currently valid and previously visible) - nsIntRegion oldValidRegion = mTiledBuffer.GetValidRegion(); + nsIntRegion oldValidRegion = mContentClient->mTiledBuffer.GetValidRegion(); oldValidRegion.And(oldValidRegion, mVisibleRegion); if (!mPaintData.mLayerCriticalDisplayPort.IsEmpty()) { oldValidRegion.And(oldValidRegion, mPaintData.mLayerCriticalDisplayPort); } updatedBuffer = - mTiledBuffer.ProgressiveUpdate(mValidRegion, invalidRegion, - oldValidRegion, &mPaintData, aCallback, - aCallbackData); + mContentClient->mTiledBuffer.ProgressiveUpdate(mValidRegion, invalidRegion, + oldValidRegion, &mPaintData, + aCallback, aCallbackData); } else { updatedBuffer = true; mValidRegion = mVisibleRegion; if (!mPaintData.mLayerCriticalDisplayPort.IsEmpty()) { mValidRegion.And(mValidRegion, mPaintData.mLayerCriticalDisplayPort); } - mTiledBuffer.SetFrameResolution(mPaintData.mResolution); - mTiledBuffer.PaintThebes(mValidRegion, invalidRegion, aCallback, aCallbackData); + mContentClient->mTiledBuffer.SetFrameResolution(mPaintData.mResolution); + mContentClient->mTiledBuffer.PaintThebes(mValidRegion, invalidRegion, + aCallback, aCallbackData); } if (updatedBuffer) { mPaintData.mFirstPaint = false; - mTiledBuffer.LockCopyAndWrite(); + BasicManager()->Hold(this); + mContentClient->LockCopyAndWrite(TiledContentClient::TILED_BUFFER); // If there are low precision updates, mark the paint as unfinished and // request a repeat transaction. @@ -247,18 +257,19 @@ BasicTiledThebesLayer::PaintThebes(gfxContext* aContext, bool updatedLowPrecision = false; if (!lowPrecisionInvalidRegion.IsEmpty() && !nsIntRegion(mPaintData.mLayerCriticalDisplayPort).Contains(mVisibleRegion)) { - nsIntRegion oldValidRegion = mLowPrecisionTiledBuffer.GetValidRegion(); + nsIntRegion oldValidRegion = + mContentClient->mLowPrecisionTiledBuffer.GetValidRegion(); oldValidRegion.And(oldValidRegion, mVisibleRegion); // If the frame resolution or format have changed, invalidate the buffer - if (mLowPrecisionTiledBuffer.GetFrameResolution() != mPaintData.mResolution || - mLowPrecisionTiledBuffer.HasFormatChanged()) { + if (mContentClient->mLowPrecisionTiledBuffer.GetFrameResolution() != mPaintData.mResolution || + mContentClient->mLowPrecisionTiledBuffer.HasFormatChanged()) { if (!mLowPrecisionValidRegion.IsEmpty()) { updatedLowPrecision = true; } oldValidRegion.SetEmpty(); mLowPrecisionValidRegion.SetEmpty(); - mLowPrecisionTiledBuffer.SetFrameResolution(mPaintData.mResolution); + mContentClient->mLowPrecisionTiledBuffer.SetFrameResolution(mPaintData.mResolution); lowPrecisionInvalidRegion = mVisibleRegion; } @@ -273,25 +284,27 @@ BasicTiledThebesLayer::PaintThebes(gfxContext* aContext, lowPrecisionInvalidRegion.Sub(lowPrecisionInvalidRegion, mValidRegion); if (!lowPrecisionInvalidRegion.IsEmpty()) { - updatedLowPrecision = - mLowPrecisionTiledBuffer.ProgressiveUpdate(mLowPrecisionValidRegion, - lowPrecisionInvalidRegion, oldValidRegion, - &mPaintData, aCallback, aCallbackData); + updatedLowPrecision = mContentClient->mLowPrecisionTiledBuffer + .ProgressiveUpdate(mLowPrecisionValidRegion, + lowPrecisionInvalidRegion, + oldValidRegion, &mPaintData, + aCallback, aCallbackData); } } else if (!mLowPrecisionValidRegion.IsEmpty()) { // Clear the low precision tiled buffer updatedLowPrecision = true; mLowPrecisionValidRegion.SetEmpty(); - mLowPrecisionTiledBuffer.PaintThebes(mLowPrecisionValidRegion, - mLowPrecisionValidRegion, aCallback, - aCallbackData); + mContentClient->mLowPrecisionTiledBuffer.PaintThebes(mLowPrecisionValidRegion, + mLowPrecisionValidRegion, + aCallback, aCallbackData); } // We send a Painted callback if we clear the valid region of the low // precision buffer, so that the shadow buffer's valid region can be updated // and the associated resources can be freed. if (updatedLowPrecision) { - mLowPrecisionTiledBuffer.LockCopyAndWrite(); + BasicManager()->Hold(this); + mContentClient->LockCopyAndWrite(TiledContentClient::LOW_PRECISION_TILED_BUFFER); } EndPaint(false); diff --git a/gfx/layers/basic/BasicTiledThebesLayer.h b/gfx/layers/basic/BasicTiledThebesLayer.h index 7eaa7deebaf..2ce44776cbb 100644 --- a/gfx/layers/basic/BasicTiledThebesLayer.h +++ b/gfx/layers/basic/BasicTiledThebesLayer.h @@ -94,8 +94,7 @@ private: */ void EndPaint(bool aFinish); - BasicTiledLayerBuffer mTiledBuffer; - BasicTiledLayerBuffer mLowPrecisionTiledBuffer; + RefPtr mContentClient; nsIntRegion mLowPrecisionValidRegion; BasicTiledLayerPaintData mPaintData; }; diff --git a/gfx/layers/client/TiledContentClient.cpp b/gfx/layers/client/TiledContentClient.cpp index 1f819962128..425257a1c1f 100644 --- a/gfx/layers/client/TiledContentClient.cpp +++ b/gfx/layers/client/TiledContentClient.cpp @@ -58,6 +58,43 @@ using namespace gfx; namespace layers { + +TiledContentClient::TiledContentClient(BasicTiledThebesLayer* aThebesLayer, + BasicShadowLayerManager* aManager) + : CompositableClient(aManager->AsShadowForwarder()) + , mTiledBuffer(aThebesLayer, aManager) + , mLowPrecisionTiledBuffer(aThebesLayer, aManager) +{ + MOZ_COUNT_CTOR(TiledContentClient); + + mLowPrecisionTiledBuffer.SetResolution(gfxPlatform::GetLowPrecisionResolution()); +} + +void +TiledContentClient::LockCopyAndWrite(TiledBufferType aType) +{ + // Create a heap copy owned and released by the compositor. This is needed + // since we're sending this over an async message and content needs to be + // be able to modify the tiled buffer in the next transaction. + // TODO: Remove me once Bug 747811 lands. + BasicTiledLayerBuffer* buffer = aType == LOW_PRECISION_TILED_BUFFER + ? &mLowPrecisionTiledBuffer + : &mTiledBuffer; + + BasicTiledLayerBuffer* heapCopy = new BasicTiledLayerBuffer(buffer->DeepCopy()); + buffer->ReadLock(); + mForwarder->PaintedTiledLayerBuffer(this, heapCopy); + buffer->ClearPaintedRegion(); +} + +BasicTiledLayerBuffer::BasicTiledLayerBuffer(BasicTiledThebesLayer* aThebesLayer, + BasicShadowLayerManager* aManager) + : mThebesLayer(aThebesLayer) + , mManager(aManager) + , mLastPaintOpaque(false) +{ +} + bool BasicTiledLayerBuffer::HasFormatChanged() const { @@ -75,18 +112,6 @@ BasicTiledLayerBuffer::GetContentType() const } } -void -BasicTiledLayerBuffer::LockCopyAndWrite() -{ - // Create a heap copy owned and released by the compositor. This is needed - // since we're sending this over an async message and content needs to be - // be able to modify the tiled buffer in the next transaction. - // TODO: Remove me once Bug 747811 lands. - BasicTiledLayerBuffer *heapCopy = new BasicTiledLayerBuffer(this->DeepCopy()); - ReadLock(); - mManager->PaintedTiledLayerBuffer(mManager->Hold(mThebesLayer), heapCopy); - ClearPaintedRegion(); -} void BasicTiledLayerBuffer::PaintThebes(const nsIntRegion& aNewValidRegion, diff --git a/gfx/layers/client/TiledContentClient.h b/gfx/layers/client/TiledContentClient.h index 69a50865362..a1f23c83a3d 100644 --- a/gfx/layers/client/TiledContentClient.h +++ b/gfx/layers/client/TiledContentClient.h @@ -100,16 +100,12 @@ class BasicTiledLayerBuffer public: BasicTiledLayerBuffer(BasicTiledThebesLayer* aThebesLayer, - BasicShadowLayerManager* aManager) - : mThebesLayer(aThebesLayer) - , mManager(aManager) - , mLastPaintOpaque(false) - {} - BasicTiledLayerBuffer() + BasicShadowLayerManager* aManager); + BasicTiledLayerBuffer() : mThebesLayer(nullptr) , mManager(nullptr) , mLastPaintOpaque(false) - {} + {} void PaintThebes(const nsIntRegion& aNewValidRegion, const nsIntRegion& aPaintRegion, @@ -135,8 +131,6 @@ public: bool HasFormatChanged() const; - void LockCopyAndWrite(); - /** * Performs a progressive update of a given tiled buffer. * See ComputeProgressiveUpdateRegion above for parameter documentation. @@ -175,6 +169,7 @@ protected: } BasicTiledLayerTile GetPlaceholderTile() const { return BasicTiledLayerTile(); } + private: gfxASurface::gfxContentType GetContentType() const; BasicTiledThebesLayer* mThebesLayer; @@ -189,8 +184,8 @@ private: nsIntPoint mSinglePaintBufferOffset; BasicTiledLayerTile ValidateTileInternal(BasicTiledLayerTile aTile, - const nsIntPoint& aTileOrigin, - const nsIntRect& aDirtyRect); + const nsIntPoint& aTileOrigin, + const nsIntRect& aDirtyRect); /** * Calculates the region to update in a single progressive update transaction. @@ -220,6 +215,39 @@ private: bool aIsRepeated); }; +class TiledContentClient : public CompositableClient +{ + // XXX: for now the layer which owns us interacts directly with our buffers. + // We should have a content client for each tiled buffer which manages its + // own valid region, resolution, etc. Then we could have a much cleaner + // interface and tidy up BasicTiledThebesLayer::PaintThebes (bug 862547). + friend class BasicTiledThebesLayer; + +public: + TiledContentClient(BasicTiledThebesLayer* aThebesLayer, + BasicShadowLayerManager* aManager); + + ~TiledContentClient() + { + MOZ_COUNT_DTOR(TiledContentClient); + } + + virtual TextureInfo GetTextureInfo() const MOZ_OVERRIDE + { + return TextureInfo(BUFFER_TILED); + } + + enum TiledBufferType { + TILED_BUFFER, + LOW_PRECISION_TILED_BUFFER + }; + void LockCopyAndWrite(TiledBufferType aType); + +private: + BasicTiledLayerBuffer mTiledBuffer; + BasicTiledLayerBuffer mLowPrecisionTiledBuffer; +}; + } } diff --git a/gfx/layers/composite/CompositableHost.cpp b/gfx/layers/composite/CompositableHost.cpp index 8cc7ebfdd64..6b126ae523d 100644 --- a/gfx/layers/composite/CompositableHost.cpp +++ b/gfx/layers/composite/CompositableHost.cpp @@ -43,24 +43,24 @@ CompositableHost::AddMaskEffect(EffectChain& aEffects, } /* static */ TemporaryRef -CompositableHost::Create(const TextureInfo& aTextureInfo, Compositor* aCompositor) +CompositableHost::Create(const TextureInfo& aTextureInfo) { RefPtr result; switch (aTextureInfo.mCompositableType) { case BUFFER_IMAGE_BUFFERED: - result = new ImageHostBuffered(aTextureInfo, aCompositor); + result = new ImageHostBuffered(aTextureInfo); return result; case BUFFER_IMAGE_SINGLE: - result = new ImageHostSingle(aTextureInfo, aCompositor); + result = new ImageHostSingle(aTextureInfo); return result; case BUFFER_TILED: - result = new TiledContentHost(aTextureInfo, aCompositor); + result = new TiledContentHost(aTextureInfo); return result; case BUFFER_CONTENT: - result = new ContentHostSingleBuffered(aTextureInfo, aCompositor); + result = new ContentHostSingleBuffered(aTextureInfo); return result; case BUFFER_CONTENT_DIRECT: - result = new ContentHostDoubleBuffered(aTextureInfo, aCompositor); + result = new ContentHostDoubleBuffered(aTextureInfo); return result; default: MOZ_NOT_REACHED("Unknown CompositableType"); diff --git a/gfx/layers/composite/CompositableHost.h b/gfx/layers/composite/CompositableHost.h index 1443a59e0a7..8f82209391e 100644 --- a/gfx/layers/composite/CompositableHost.h +++ b/gfx/layers/composite/CompositableHost.h @@ -48,10 +48,9 @@ class SurfaceDescriptor; class CompositableHost : public RefCounted { public: - CompositableHost(const TextureInfo& aTextureInfo, - Compositor* aCompositor = nullptr) + CompositableHost(const TextureInfo& aTextureInfo) : mTextureInfo(aTextureInfo) - , mCompositor(aCompositor) + , mCompositor(nullptr) , mLayer(nullptr) { MOZ_COUNT_CTOR(CompositableHost); @@ -62,8 +61,7 @@ public: MOZ_COUNT_DTOR(CompositableHost); } - static TemporaryRef Create(const TextureInfo& aTextureInfo, - Compositor* aCompositor = nullptr); + static TemporaryRef Create(const TextureInfo& aTextureInfo); virtual CompositableType GetType() = 0; @@ -146,7 +144,9 @@ public: Layer* GetLayer() const { return mLayer; } void SetLayer(Layer* aLayer) { mLayer = aLayer; } - void Attach(Layer* aLayer, Compositor* aCompositor) + virtual TiledLayerComposer* AsTiledLayerComposer() { return nullptr; } + + virtual void Attach(Layer* aLayer, Compositor* aCompositor) { SetCompositor(aCompositor); SetLayer(aLayer); diff --git a/gfx/layers/composite/ContentHost.cpp b/gfx/layers/composite/ContentHost.cpp index befda04a708..52773f23e8d 100644 --- a/gfx/layers/composite/ContentHost.cpp +++ b/gfx/layers/composite/ContentHost.cpp @@ -11,9 +11,8 @@ namespace mozilla { using namespace gfx; namespace layers { -ContentHostBase::ContentHostBase(const TextureInfo& aTextureInfo, - Compositor* aCompositor) - : ContentHost(aTextureInfo, aCompositor) +ContentHostBase::ContentHostBase(const TextureInfo& aTextureInfo) + : ContentHost(aTextureInfo) , mPaintWillResample(false) , mInitialised(false) {} diff --git a/gfx/layers/composite/ContentHost.h b/gfx/layers/composite/ContentHost.h index b80c51600a8..069e7500240 100644 --- a/gfx/layers/composite/ContentHost.h +++ b/gfx/layers/composite/ContentHost.h @@ -39,8 +39,8 @@ public: #endif protected: - ContentHost(const TextureInfo& aTextureInfo, Compositor* aCompositor) - : CompositableHost(aTextureInfo, aCompositor) + ContentHost(const TextureInfo& aTextureInfo) + : CompositableHost(aTextureInfo) {} }; @@ -61,7 +61,7 @@ public: typedef ThebesLayerBuffer::ContentType ContentType; typedef ThebesLayerBuffer::PaintState PaintState; - ContentHostBase(const TextureInfo& aTextureInfo, Compositor* aCompositor); + ContentHostBase(const TextureInfo& aTextureInfo); ~ContentHostBase(); virtual void Composite(EffectChain& aEffectChain, @@ -135,9 +135,8 @@ protected: class ContentHostDoubleBuffered : public ContentHostBase { public: - ContentHostDoubleBuffered(const TextureInfo& aTextureInfo, - Compositor* aCompositor) - : ContentHostBase(aTextureInfo, aCompositor) + ContentHostDoubleBuffered(const TextureInfo& aTextureInfo) + : ContentHostBase(aTextureInfo) {} ~ContentHostDoubleBuffered(); @@ -173,9 +172,8 @@ protected: class ContentHostSingleBuffered : public ContentHostBase { public: - ContentHostSingleBuffered(const TextureInfo& aTextureInfo, - Compositor* aCompositor) - : ContentHostBase(aTextureInfo, aCompositor) + ContentHostSingleBuffered(const TextureInfo& aTextureInfo) + : ContentHostBase(aTextureInfo) {} virtual ~ContentHostSingleBuffered(); diff --git a/gfx/layers/composite/ImageHost.h b/gfx/layers/composite/ImageHost.h index 6b01432a526..ff1f854ba37 100644 --- a/gfx/layers/composite/ImageHost.h +++ b/gfx/layers/composite/ImageHost.h @@ -24,8 +24,8 @@ public: TextureHost* GetTextureHost() MOZ_OVERRIDE { return nullptr; } protected: - ImageHost(const TextureInfo& aTextureInfo, Compositor* aCompositor) - : CompositableHost(aTextureInfo, aCompositor) + ImageHost(const TextureInfo& aTextureInfo) + : CompositableHost(aTextureInfo) { MOZ_COUNT_CTOR(ImageHost); } @@ -40,8 +40,8 @@ protected: class ImageHostSingle : public ImageHost { public: - ImageHostSingle(const TextureInfo& aTextureInfo, Compositor* aCompositor) - : ImageHost(aTextureInfo, aCompositor) + ImageHostSingle(const TextureInfo& aTextureInfo) + : ImageHost(aTextureInfo) , mTextureHost(nullptr) , mHasPictureRect(false) {} @@ -99,8 +99,8 @@ protected: class ImageHostBuffered : public ImageHostSingle { public: - ImageHostBuffered(const TextureInfo& aTextureInfo, Compositor* aCompositor) - : ImageHostSingle(aTextureInfo, aCompositor) + ImageHostBuffered(const TextureInfo& aTextureInfo) + : ImageHostSingle(aTextureInfo) {} virtual bool Update(const SurfaceDescriptor& aImage, diff --git a/gfx/layers/composite/LayerManagerComposite.cpp b/gfx/layers/composite/LayerManagerComposite.cpp index 8b1c623f09d..2ee0614f458 100644 --- a/gfx/layers/composite/LayerManagerComposite.cpp +++ b/gfx/layers/composite/LayerManagerComposite.cpp @@ -389,7 +389,7 @@ LayerManagerComposite::ComputeRenderIntegrityInternal(Layer* aLayer, TiledLayerComposer* composer = nullptr; LayerComposite* shadow = aLayer->AsLayerComposite(); if (shadow) { - composer = shadow->AsTiledLayerComposer(); + composer = shadow->GetTiledLayerComposer(); if (composer) { incompleteRegion.Sub(incompleteRegion, composer->GetValidLowPrecisionRegion()); if (!incompleteRegion.IsEmpty()) { diff --git a/gfx/layers/composite/LayerManagerComposite.h b/gfx/layers/composite/LayerManagerComposite.h index 54d849ccbea..c4af147865f 100644 --- a/gfx/layers/composite/LayerManagerComposite.h +++ b/gfx/layers/composite/LayerManagerComposite.h @@ -287,12 +287,7 @@ public: virtual void CleanupResources() = 0; - virtual TiledLayerComposer* AsTiledLayerComposer() { return NULL; } - - virtual void EnsureBuffer(CompositableType aType) - { - MOZ_ASSERT(false, "Should not be called unless overriden."); - } + virtual TiledLayerComposer* GetTiledLayerComposer() { return nullptr; } protected: LayerManagerComposite* mCompositeManager; diff --git a/gfx/layers/composite/ThebesLayerComposite.cpp b/gfx/layers/composite/ThebesLayerComposite.cpp index 5949a2551f3..c16487ce886 100644 --- a/gfx/layers/composite/ThebesLayerComposite.cpp +++ b/gfx/layers/composite/ThebesLayerComposite.cpp @@ -47,21 +47,6 @@ ThebesLayerComposite::SetCompositableHost(CompositableHost* aHost) mBuffer= static_cast(aHost); } -void -ThebesLayerComposite::EnsureBuffer(CompositableType aType) -{ - MOZ_ASSERT(aType == BUFFER_TILED, - "Should only be called for tiled layers."); - if (!mBuffer || - mBuffer->GetType() != aType) { - RefPtr bufferHost - = CompositableHost::Create(TextureInfo(aType), mCompositeManager->GetCompositor()); - NS_ASSERTION(bufferHost->GetType() == BUFFER_TILED, "bad buffer type"); - mBuffer = static_cast(bufferHost.get()); - mRequiresTiledProperties = true; - } -} - void ThebesLayerComposite::Disconnect() { @@ -87,7 +72,7 @@ ThebesLayerComposite::GetLayer() } TiledLayerComposer* -ThebesLayerComposite::AsTiledLayerComposer() +ThebesLayerComposite::GetTiledLayerComposer() { return mBuffer->AsTiledLayerComposer(); } diff --git a/gfx/layers/composite/ThebesLayerComposite.h b/gfx/layers/composite/ThebesLayerComposite.h index 15f4132032c..c524cc8ca15 100644 --- a/gfx/layers/composite/ThebesLayerComposite.h +++ b/gfx/layers/composite/ThebesLayerComposite.h @@ -47,7 +47,7 @@ public: virtual Layer* GetLayer() MOZ_OVERRIDE; - virtual TiledLayerComposer* AsTiledLayerComposer() MOZ_OVERRIDE; + virtual TiledLayerComposer* GetTiledLayerComposer() MOZ_OVERRIDE; virtual void RenderLayer(const nsIntPoint& aOffset, const nsIntRect& aClipRect) MOZ_OVERRIDE; @@ -58,7 +58,7 @@ public: virtual LayerComposite* AsLayerComposite() MOZ_OVERRIDE { return this; } - virtual void EnsureBuffer(CompositableType aType) MOZ_OVERRIDE; + void EnsureTiled() { mRequiresTiledProperties = true; } #ifdef MOZ_LAYERS_HAVE_LOG virtual const char* Name() const MOZ_OVERRIDE { return "ThebesLayerComposite"; } diff --git a/gfx/layers/composite/TiledContentHost.cpp b/gfx/layers/composite/TiledContentHost.cpp index 25399dc80a5..c6355aef8ea 100644 --- a/gfx/layers/composite/TiledContentHost.cpp +++ b/gfx/layers/composite/TiledContentHost.cpp @@ -6,6 +6,7 @@ #include "TiledContentHost.h" #include "mozilla/layers/Effects.h" #include "nsPrintfCString.h" +#include "ThebesLayerComposite.h" namespace mozilla { using namespace gfx; @@ -59,6 +60,13 @@ TiledContentHost::~TiledContentHost() mLowPrecisionMainMemoryTiledBuffer.ReadUnlock(); } +void +TiledContentHost::Attach(Layer* aLayer, Compositor* aCompositor) +{ + CompositableHost::Attach(aLayer, aCompositor); + static_cast(aLayer)->EnsureTiled(); +} + void TiledContentHost::PaintedTiledLayerBuffer(const BasicTiledLayerBuffer* mTiledBuffer) { diff --git a/gfx/layers/composite/TiledContentHost.h b/gfx/layers/composite/TiledContentHost.h index 01ddc45a2f5..9116f193e94 100644 --- a/gfx/layers/composite/TiledContentHost.h +++ b/gfx/layers/composite/TiledContentHost.h @@ -66,8 +66,8 @@ class TiledLayerBufferComposite friend class TiledLayerBuffer; public: - TiledLayerBufferComposite(Compositor* aCompositor) - : mCompositor(aCompositor) + TiledLayerBufferComposite() + : mCompositor(nullptr) {} void Upload(const BasicTiledLayerBuffer* aMainMemoryTiledBuffer, @@ -81,6 +81,11 @@ public: // by the sum of the resolutions of all parent layers' FrameMetrics. const gfxSize& GetFrameResolution() { return mFrameResolution; } + void SetCompositor(Compositor* aCompositor) + { + mCompositor = aCompositor; + } + protected: TiledTexture ValidateTile(TiledTexture aTile, const nsIntPoint& aTileRect, @@ -126,10 +131,8 @@ class TiledContentHost : public ContentHost, public TiledLayerComposer { public: - TiledContentHost(const TextureInfo& aTextureInfo, Compositor* aCompositor) - : ContentHost(aTextureInfo, aCompositor) - , mVideoMemoryTiledBuffer(aCompositor) - , mLowPrecisionVideoMemoryTiledBuffer(aCompositor) + TiledContentHost(const TextureInfo& aTextureInfo) + : ContentHost(aTextureInfo) , mPendingUpload(false) , mPendingLowPrecisionUpload(false) {} @@ -179,7 +182,7 @@ public: virtual CompositableType GetType() { return BUFFER_TILED; } - virtual TiledLayerComposer* AsTiledLayerComposer() { return this; } + virtual TiledLayerComposer* AsTiledLayerComposer() MOZ_OVERRIDE { return this; } virtual bool EnsureTextureHost(TextureIdentifier aTextureId, const SurfaceDescriptor& aSurface, @@ -190,6 +193,15 @@ public: return false; } + virtual void SetCompositor(Compositor* aCompositor) MOZ_OVERRIDE + { + CompositableHost::SetCompositor(aCompositor); + mVideoMemoryTiledBuffer.SetCompositor(aCompositor); + mLowPrecisionVideoMemoryTiledBuffer.SetCompositor(aCompositor); + } + + virtual void Attach(Layer* aLayer, Compositor* aCompositor) MOZ_OVERRIDE; + #ifdef MOZ_LAYERS_HAVE_LOG virtual void PrintInfo(nsACString& aTo, const char* aPrefix); #endif diff --git a/gfx/layers/ipc/CompositableForwarder.h b/gfx/layers/ipc/CompositableForwarder.h index 9167a7dc71c..b71ba7f032e 100644 --- a/gfx/layers/ipc/CompositableForwarder.h +++ b/gfx/layers/ipc/CompositableForwarder.h @@ -20,6 +20,7 @@ class TextureFactoryIdentifier; class SurfaceDescriptor; class ThebesBufferData; class TextureClient; +class BasicTiledLayerBuffer; /** * A transaction is a set of changes that happenned on the content side, that @@ -69,6 +70,9 @@ public: */ virtual void DestroyThebesBuffer(CompositableClient* aCompositable) = 0; + virtual void PaintedTiledLayerBuffer(CompositableClient* aCompositable, + BasicTiledLayerBuffer* aTiledLayerBuffer) = 0; + /** * Communicate to the compositor that the texture identified by aCompositable * and aTextureId has been updated to aImage. diff --git a/gfx/layers/ipc/CompositableTransactionParent.cpp b/gfx/layers/ipc/CompositableTransactionParent.cpp index 0daaf2e98da..303e049ffb1 100644 --- a/gfx/layers/ipc/CompositableTransactionParent.cpp +++ b/gfx/layers/ipc/CompositableTransactionParent.cpp @@ -132,6 +132,20 @@ CompositableParentManager::ReceiveCompositableUpdate(const CompositableOperation compositable->SetPictureRect(op.picture()); break; } + case CompositableOperation::TOpPaintTiledLayerBuffer: { + MOZ_LAYERS_LOG(("[ParentSide] Paint TiledLayerBuffer")); + const OpPaintTiledLayerBuffer& op = aEdit.get_OpPaintTiledLayerBuffer(); + CompositableParent* compositableParent = static_cast(op.compositableParent()); + CompositableHost* compositable = + compositableParent->GetCompositableHost(); + + TiledLayerComposer* tileComposer = compositable->AsTiledLayerComposer(); + NS_ASSERTION(tileComposer, "compositable is not a tile composer"); + + BasicTiledLayerBuffer* p = reinterpret_cast(op.tiledLayerBuffer()); + tileComposer->PaintedTiledLayerBuffer(p); + break; + } default: { MOZ_ASSERT(false, "bad type"); } diff --git a/gfx/layers/ipc/ImageBridgeChild.h b/gfx/layers/ipc/ImageBridgeChild.h index 7b241907196..d36fa8a4445 100644 --- a/gfx/layers/ipc/ImageBridgeChild.h +++ b/gfx/layers/ipc/ImageBridgeChild.h @@ -230,6 +230,12 @@ public: virtual void Connect(CompositableClient* aCompositable) MOZ_OVERRIDE; + virtual void PaintedTiledLayerBuffer(CompositableClient* aCompositable, + BasicTiledLayerBuffer* aTiledLayerBuffer) MOZ_OVERRIDE + { + NS_RUNTIMEABORT("should not be called"); + } + /** * Communicate to the compositor that the texture identified by aCompositable * and aTextureId has been updated to aDescriptor. diff --git a/gfx/layers/ipc/LayerTransaction.ipdlh b/gfx/layers/ipc/LayerTransaction.ipdlh index 57e0772e58f..fb988090e94 100644 --- a/gfx/layers/ipc/LayerTransaction.ipdlh +++ b/gfx/layers/ipc/LayerTransaction.ipdlh @@ -235,7 +235,7 @@ struct OpRaiseToTopChild { PLayer container; PLayer childLayer; }; // Paint (buffer update) struct OpPaintTiledLayerBuffer { - PLayer layer; + PCompositable compositable; // Bug 747811 // FIXME: We need to support sharing tile across process. uintptr_t tiledLayerBuffer; @@ -277,6 +277,8 @@ union CompositableOperation { OpPaintTexture; OpPaintTextureRegion; + + OpPaintTiledLayerBuffer; }; // A unit of a changeset; a set of these comprise a changeset @@ -300,7 +302,6 @@ union Edit { OpAttachCompositable; OpAttachAsyncCompositable; - OpPaintTiledLayerBuffer; CompositableOperation; }; diff --git a/gfx/layers/ipc/ShadowLayers.cpp b/gfx/layers/ipc/ShadowLayers.cpp index f9206e639f1..4be9b116408 100644 --- a/gfx/layers/ipc/ShadowLayers.cpp +++ b/gfx/layers/ipc/ShadowLayers.cpp @@ -290,12 +290,12 @@ ShadowLayerForwarder::RepositionChild(ShadowableLayer* aContainer, } void -ShadowLayerForwarder::PaintedTiledLayerBuffer(ShadowableLayer* aLayer, +ShadowLayerForwarder::PaintedTiledLayerBuffer(CompositableClient* aCompositable, BasicTiledLayerBuffer* aTiledLayerBuffer) { if (XRE_GetProcessType() != GeckoProcessType_Default) NS_RUNTIMEABORT("PaintedTiledLayerBuffer must be made IPC safe (not share pointers)"); - mTxn->AddNoSwapPaint(OpPaintTiledLayerBuffer(NULL, Shadow(aLayer), + mTxn->AddNoSwapPaint(OpPaintTiledLayerBuffer(NULL, aCompositable->GetIPDLActor(), uintptr_t(aTiledLayerBuffer))); } diff --git a/gfx/layers/ipc/ShadowLayers.h b/gfx/layers/ipc/ShadowLayers.h index 22da90d36d6..abc8a877822 100644 --- a/gfx/layers/ipc/ShadowLayers.h +++ b/gfx/layers/ipc/ShadowLayers.h @@ -50,7 +50,6 @@ class TiledLayerComposer; class Transaction; class SurfaceDescriptor; class CanvasSurface; -class BasicTiledLayerBuffer; class TextureClientShmem; class ContentClientRemote; class CompositableChild; @@ -258,8 +257,8 @@ public: * and is free to choose it's own internal representation (double buffering, * copy on write, tiling). */ - void PaintedTiledLayerBuffer(ShadowableLayer* aThebes, - BasicTiledLayerBuffer* aTiledLayerBuffer); + virtual void PaintedTiledLayerBuffer(CompositableClient* aCompositable, + BasicTiledLayerBuffer* aTiledLayerBuffer) MOZ_OVERRIDE; /** * Notify the compositor that a compositable will be updated asynchronously diff --git a/gfx/layers/ipc/ShadowLayersParent.cpp b/gfx/layers/ipc/ShadowLayersParent.cpp index 9389ddc4b5c..421a9426fb9 100644 --- a/gfx/layers/ipc/ShadowLayersParent.cpp +++ b/gfx/layers/ipc/ShadowLayersParent.cpp @@ -389,21 +389,6 @@ ShadowLayersParent::RecvUpdate(const InfallibleTArray& cset, compositableParent->SetCompositorID(mLayerManager->GetCompositor()->GetCompositorID()); break; } - case Edit::TOpPaintTiledLayerBuffer: { - MOZ_LAYERS_LOG(("[ParentSide] Paint TiledLayerBuffer")); - const OpPaintTiledLayerBuffer& op = edit.get_OpPaintTiledLayerBuffer(); - ShadowLayerParent* shadow = AsShadowLayer(op); - - LayerComposite* compositeLayer = shadow->AsLayer()->AsLayerComposite(); - compositeLayer->EnsureBuffer(BUFFER_TILED); - TiledLayerComposer* tileComposer = compositeLayer->AsTiledLayerComposer(); - - NS_ASSERTION(tileComposer, "compositeLayer is not a tile composer"); - - BasicTiledLayerBuffer* p = reinterpret_cast(op.tiledLayerBuffer()); - tileComposer->PaintedTiledLayerBuffer(p); - break; - } default: NS_RUNTIMEABORT("not reached"); }