Bug 862064; use PCompositable for tiled layers and add TiledContentClient. r=nical

--HG--
extra : rebase_source : b0055e13b661f78bc0e7168c0df8c6082cfdb34e
This commit is contained in:
Nicholas Cameron 2013-04-17 09:36:06 +12:00
parent 89e6b263d4
commit 35cf82d17b
23 changed files with 207 additions and 136 deletions

View File

@ -74,7 +74,7 @@ enum TextureHostFlags
{ {
TEXTURE_HOST_DEFAULT = 0, // The default texture host for the given TEXTURE_HOST_DEFAULT = 0, // The default texture host for the given
// SurfaceDescriptor // SurfaceDescriptor
TEXTURE_HOST_TILED = 1 << 0, // A texture host that supports tiling TEXTURE_HOST_TILED = 1 << 0 // A texture host that supports tiling
}; };
/** /**

View File

@ -15,11 +15,9 @@ namespace layers {
BasicTiledThebesLayer::BasicTiledThebesLayer(BasicShadowLayerManager* const aManager) BasicTiledThebesLayer::BasicTiledThebesLayer(BasicShadowLayerManager* const aManager)
: ThebesLayer(aManager, static_cast<BasicImplData*>(this)) : ThebesLayer(aManager, static_cast<BasicImplData*>(this))
, mTiledBuffer(this, aManager) , mContentClient()
, mLowPrecisionTiledBuffer(this, aManager)
{ {
MOZ_COUNT_CTOR(BasicTiledThebesLayer); MOZ_COUNT_CTOR(BasicTiledThebesLayer);
mLowPrecisionTiledBuffer.SetResolution(gfxPlatform::GetLowPrecisionResolution());
mPaintData.mLastScrollOffset = gfx::Point(0, 0); mPaintData.mLastScrollOffset = gfx::Point(0, 0);
mPaintData.mFirstPaint = true; mPaintData.mFirstPaint = true;
} }
@ -126,7 +124,15 @@ BasicTiledThebesLayer::PaintThebes(gfxContext* aContext,
return; 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(); mValidRegion = nsIntRegion();
} }
@ -151,9 +157,11 @@ BasicTiledThebesLayer::PaintThebes(gfxContext* aContext,
NS_ASSERTION(!BasicManager()->IsRepeatTransaction(), "Didn't paint our mask layer"); 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; return;
} }
@ -199,33 +207,35 @@ BasicTiledThebesLayer::PaintThebes(gfxContext* aContext,
// Only draw progressively when the resolution is unchanged. // Only draw progressively when the resolution is unchanged.
if (gfxPlatform::UseProgressiveTilePainting() && if (gfxPlatform::UseProgressiveTilePainting() &&
!BasicManager()->HasShadowTarget() && !BasicManager()->HasShadowTarget() &&
mTiledBuffer.GetFrameResolution() == mPaintData.mResolution) { mContentClient->mTiledBuffer.GetFrameResolution() == mPaintData.mResolution) {
// Store the old valid region, then clear it before painting. // Store the old valid region, then clear it before painting.
// We clip the old valid region to the visible region, as it only gets // We clip the old valid region to the visible region, as it only gets
// used to decide stale content (currently valid and previously visible) // used to decide stale content (currently valid and previously visible)
nsIntRegion oldValidRegion = mTiledBuffer.GetValidRegion(); nsIntRegion oldValidRegion = mContentClient->mTiledBuffer.GetValidRegion();
oldValidRegion.And(oldValidRegion, mVisibleRegion); oldValidRegion.And(oldValidRegion, mVisibleRegion);
if (!mPaintData.mLayerCriticalDisplayPort.IsEmpty()) { if (!mPaintData.mLayerCriticalDisplayPort.IsEmpty()) {
oldValidRegion.And(oldValidRegion, mPaintData.mLayerCriticalDisplayPort); oldValidRegion.And(oldValidRegion, mPaintData.mLayerCriticalDisplayPort);
} }
updatedBuffer = updatedBuffer =
mTiledBuffer.ProgressiveUpdate(mValidRegion, invalidRegion, mContentClient->mTiledBuffer.ProgressiveUpdate(mValidRegion, invalidRegion,
oldValidRegion, &mPaintData, aCallback, oldValidRegion, &mPaintData,
aCallbackData); aCallback, aCallbackData);
} else { } else {
updatedBuffer = true; updatedBuffer = true;
mValidRegion = mVisibleRegion; mValidRegion = mVisibleRegion;
if (!mPaintData.mLayerCriticalDisplayPort.IsEmpty()) { if (!mPaintData.mLayerCriticalDisplayPort.IsEmpty()) {
mValidRegion.And(mValidRegion, mPaintData.mLayerCriticalDisplayPort); mValidRegion.And(mValidRegion, mPaintData.mLayerCriticalDisplayPort);
} }
mTiledBuffer.SetFrameResolution(mPaintData.mResolution); mContentClient->mTiledBuffer.SetFrameResolution(mPaintData.mResolution);
mTiledBuffer.PaintThebes(mValidRegion, invalidRegion, aCallback, aCallbackData); mContentClient->mTiledBuffer.PaintThebes(mValidRegion, invalidRegion,
aCallback, aCallbackData);
} }
if (updatedBuffer) { if (updatedBuffer) {
mPaintData.mFirstPaint = false; 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 // If there are low precision updates, mark the paint as unfinished and
// request a repeat transaction. // request a repeat transaction.
@ -247,18 +257,19 @@ BasicTiledThebesLayer::PaintThebes(gfxContext* aContext,
bool updatedLowPrecision = false; bool updatedLowPrecision = false;
if (!lowPrecisionInvalidRegion.IsEmpty() && if (!lowPrecisionInvalidRegion.IsEmpty() &&
!nsIntRegion(mPaintData.mLayerCriticalDisplayPort).Contains(mVisibleRegion)) { !nsIntRegion(mPaintData.mLayerCriticalDisplayPort).Contains(mVisibleRegion)) {
nsIntRegion oldValidRegion = mLowPrecisionTiledBuffer.GetValidRegion(); nsIntRegion oldValidRegion =
mContentClient->mLowPrecisionTiledBuffer.GetValidRegion();
oldValidRegion.And(oldValidRegion, mVisibleRegion); oldValidRegion.And(oldValidRegion, mVisibleRegion);
// If the frame resolution or format have changed, invalidate the buffer // If the frame resolution or format have changed, invalidate the buffer
if (mLowPrecisionTiledBuffer.GetFrameResolution() != mPaintData.mResolution || if (mContentClient->mLowPrecisionTiledBuffer.GetFrameResolution() != mPaintData.mResolution ||
mLowPrecisionTiledBuffer.HasFormatChanged()) { mContentClient->mLowPrecisionTiledBuffer.HasFormatChanged()) {
if (!mLowPrecisionValidRegion.IsEmpty()) { if (!mLowPrecisionValidRegion.IsEmpty()) {
updatedLowPrecision = true; updatedLowPrecision = true;
} }
oldValidRegion.SetEmpty(); oldValidRegion.SetEmpty();
mLowPrecisionValidRegion.SetEmpty(); mLowPrecisionValidRegion.SetEmpty();
mLowPrecisionTiledBuffer.SetFrameResolution(mPaintData.mResolution); mContentClient->mLowPrecisionTiledBuffer.SetFrameResolution(mPaintData.mResolution);
lowPrecisionInvalidRegion = mVisibleRegion; lowPrecisionInvalidRegion = mVisibleRegion;
} }
@ -273,25 +284,27 @@ BasicTiledThebesLayer::PaintThebes(gfxContext* aContext,
lowPrecisionInvalidRegion.Sub(lowPrecisionInvalidRegion, mValidRegion); lowPrecisionInvalidRegion.Sub(lowPrecisionInvalidRegion, mValidRegion);
if (!lowPrecisionInvalidRegion.IsEmpty()) { if (!lowPrecisionInvalidRegion.IsEmpty()) {
updatedLowPrecision = updatedLowPrecision = mContentClient->mLowPrecisionTiledBuffer
mLowPrecisionTiledBuffer.ProgressiveUpdate(mLowPrecisionValidRegion, .ProgressiveUpdate(mLowPrecisionValidRegion,
lowPrecisionInvalidRegion, oldValidRegion, lowPrecisionInvalidRegion,
&mPaintData, aCallback, aCallbackData); oldValidRegion, &mPaintData,
aCallback, aCallbackData);
} }
} else if (!mLowPrecisionValidRegion.IsEmpty()) { } else if (!mLowPrecisionValidRegion.IsEmpty()) {
// Clear the low precision tiled buffer // Clear the low precision tiled buffer
updatedLowPrecision = true; updatedLowPrecision = true;
mLowPrecisionValidRegion.SetEmpty(); mLowPrecisionValidRegion.SetEmpty();
mLowPrecisionTiledBuffer.PaintThebes(mLowPrecisionValidRegion, mContentClient->mLowPrecisionTiledBuffer.PaintThebes(mLowPrecisionValidRegion,
mLowPrecisionValidRegion, aCallback, mLowPrecisionValidRegion,
aCallbackData); aCallback, aCallbackData);
} }
// We send a Painted callback if we clear the valid region of the low // 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 // precision buffer, so that the shadow buffer's valid region can be updated
// and the associated resources can be freed. // and the associated resources can be freed.
if (updatedLowPrecision) { if (updatedLowPrecision) {
mLowPrecisionTiledBuffer.LockCopyAndWrite(); BasicManager()->Hold(this);
mContentClient->LockCopyAndWrite(TiledContentClient::LOW_PRECISION_TILED_BUFFER);
} }
EndPaint(false); EndPaint(false);

View File

@ -94,8 +94,7 @@ private:
*/ */
void EndPaint(bool aFinish); void EndPaint(bool aFinish);
BasicTiledLayerBuffer mTiledBuffer; RefPtr<TiledContentClient> mContentClient;
BasicTiledLayerBuffer mLowPrecisionTiledBuffer;
nsIntRegion mLowPrecisionValidRegion; nsIntRegion mLowPrecisionValidRegion;
BasicTiledLayerPaintData mPaintData; BasicTiledLayerPaintData mPaintData;
}; };

View File

@ -58,6 +58,43 @@ using namespace gfx;
namespace layers { 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 bool
BasicTiledLayerBuffer::HasFormatChanged() const 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 void
BasicTiledLayerBuffer::PaintThebes(const nsIntRegion& aNewValidRegion, BasicTiledLayerBuffer::PaintThebes(const nsIntRegion& aNewValidRegion,

View File

@ -100,16 +100,12 @@ class BasicTiledLayerBuffer
public: public:
BasicTiledLayerBuffer(BasicTiledThebesLayer* aThebesLayer, BasicTiledLayerBuffer(BasicTiledThebesLayer* aThebesLayer,
BasicShadowLayerManager* aManager) BasicShadowLayerManager* aManager);
: mThebesLayer(aThebesLayer) BasicTiledLayerBuffer()
, mManager(aManager)
, mLastPaintOpaque(false)
{}
BasicTiledLayerBuffer()
: mThebesLayer(nullptr) : mThebesLayer(nullptr)
, mManager(nullptr) , mManager(nullptr)
, mLastPaintOpaque(false) , mLastPaintOpaque(false)
{} {}
void PaintThebes(const nsIntRegion& aNewValidRegion, void PaintThebes(const nsIntRegion& aNewValidRegion,
const nsIntRegion& aPaintRegion, const nsIntRegion& aPaintRegion,
@ -135,8 +131,6 @@ public:
bool HasFormatChanged() const; bool HasFormatChanged() const;
void LockCopyAndWrite();
/** /**
* Performs a progressive update of a given tiled buffer. * Performs a progressive update of a given tiled buffer.
* See ComputeProgressiveUpdateRegion above for parameter documentation. * See ComputeProgressiveUpdateRegion above for parameter documentation.
@ -175,6 +169,7 @@ protected:
} }
BasicTiledLayerTile GetPlaceholderTile() const { return BasicTiledLayerTile(); } BasicTiledLayerTile GetPlaceholderTile() const { return BasicTiledLayerTile(); }
private: private:
gfxASurface::gfxContentType GetContentType() const; gfxASurface::gfxContentType GetContentType() const;
BasicTiledThebesLayer* mThebesLayer; BasicTiledThebesLayer* mThebesLayer;
@ -189,8 +184,8 @@ private:
nsIntPoint mSinglePaintBufferOffset; nsIntPoint mSinglePaintBufferOffset;
BasicTiledLayerTile ValidateTileInternal(BasicTiledLayerTile aTile, BasicTiledLayerTile ValidateTileInternal(BasicTiledLayerTile aTile,
const nsIntPoint& aTileOrigin, const nsIntPoint& aTileOrigin,
const nsIntRect& aDirtyRect); const nsIntRect& aDirtyRect);
/** /**
* Calculates the region to update in a single progressive update transaction. * Calculates the region to update in a single progressive update transaction.
@ -220,6 +215,39 @@ private:
bool aIsRepeated); 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;
};
} }
} }

View File

@ -43,24 +43,24 @@ CompositableHost::AddMaskEffect(EffectChain& aEffects,
} }
/* static */ TemporaryRef<CompositableHost> /* static */ TemporaryRef<CompositableHost>
CompositableHost::Create(const TextureInfo& aTextureInfo, Compositor* aCompositor) CompositableHost::Create(const TextureInfo& aTextureInfo)
{ {
RefPtr<CompositableHost> result; RefPtr<CompositableHost> result;
switch (aTextureInfo.mCompositableType) { switch (aTextureInfo.mCompositableType) {
case BUFFER_IMAGE_BUFFERED: case BUFFER_IMAGE_BUFFERED:
result = new ImageHostBuffered(aTextureInfo, aCompositor); result = new ImageHostBuffered(aTextureInfo);
return result; return result;
case BUFFER_IMAGE_SINGLE: case BUFFER_IMAGE_SINGLE:
result = new ImageHostSingle(aTextureInfo, aCompositor); result = new ImageHostSingle(aTextureInfo);
return result; return result;
case BUFFER_TILED: case BUFFER_TILED:
result = new TiledContentHost(aTextureInfo, aCompositor); result = new TiledContentHost(aTextureInfo);
return result; return result;
case BUFFER_CONTENT: case BUFFER_CONTENT:
result = new ContentHostSingleBuffered(aTextureInfo, aCompositor); result = new ContentHostSingleBuffered(aTextureInfo);
return result; return result;
case BUFFER_CONTENT_DIRECT: case BUFFER_CONTENT_DIRECT:
result = new ContentHostDoubleBuffered(aTextureInfo, aCompositor); result = new ContentHostDoubleBuffered(aTextureInfo);
return result; return result;
default: default:
MOZ_NOT_REACHED("Unknown CompositableType"); MOZ_NOT_REACHED("Unknown CompositableType");

View File

@ -48,10 +48,9 @@ class SurfaceDescriptor;
class CompositableHost : public RefCounted<CompositableHost> class CompositableHost : public RefCounted<CompositableHost>
{ {
public: public:
CompositableHost(const TextureInfo& aTextureInfo, CompositableHost(const TextureInfo& aTextureInfo)
Compositor* aCompositor = nullptr)
: mTextureInfo(aTextureInfo) : mTextureInfo(aTextureInfo)
, mCompositor(aCompositor) , mCompositor(nullptr)
, mLayer(nullptr) , mLayer(nullptr)
{ {
MOZ_COUNT_CTOR(CompositableHost); MOZ_COUNT_CTOR(CompositableHost);
@ -62,8 +61,7 @@ public:
MOZ_COUNT_DTOR(CompositableHost); MOZ_COUNT_DTOR(CompositableHost);
} }
static TemporaryRef<CompositableHost> Create(const TextureInfo& aTextureInfo, static TemporaryRef<CompositableHost> Create(const TextureInfo& aTextureInfo);
Compositor* aCompositor = nullptr);
virtual CompositableType GetType() = 0; virtual CompositableType GetType() = 0;
@ -146,7 +144,9 @@ public:
Layer* GetLayer() const { return mLayer; } Layer* GetLayer() const { return mLayer; }
void SetLayer(Layer* aLayer) { mLayer = aLayer; } 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); SetCompositor(aCompositor);
SetLayer(aLayer); SetLayer(aLayer);

View File

@ -11,9 +11,8 @@ namespace mozilla {
using namespace gfx; using namespace gfx;
namespace layers { namespace layers {
ContentHostBase::ContentHostBase(const TextureInfo& aTextureInfo, ContentHostBase::ContentHostBase(const TextureInfo& aTextureInfo)
Compositor* aCompositor) : ContentHost(aTextureInfo)
: ContentHost(aTextureInfo, aCompositor)
, mPaintWillResample(false) , mPaintWillResample(false)
, mInitialised(false) , mInitialised(false)
{} {}

View File

@ -39,8 +39,8 @@ public:
#endif #endif
protected: protected:
ContentHost(const TextureInfo& aTextureInfo, Compositor* aCompositor) ContentHost(const TextureInfo& aTextureInfo)
: CompositableHost(aTextureInfo, aCompositor) : CompositableHost(aTextureInfo)
{} {}
}; };
@ -61,7 +61,7 @@ public:
typedef ThebesLayerBuffer::ContentType ContentType; typedef ThebesLayerBuffer::ContentType ContentType;
typedef ThebesLayerBuffer::PaintState PaintState; typedef ThebesLayerBuffer::PaintState PaintState;
ContentHostBase(const TextureInfo& aTextureInfo, Compositor* aCompositor); ContentHostBase(const TextureInfo& aTextureInfo);
~ContentHostBase(); ~ContentHostBase();
virtual void Composite(EffectChain& aEffectChain, virtual void Composite(EffectChain& aEffectChain,
@ -135,9 +135,8 @@ protected:
class ContentHostDoubleBuffered : public ContentHostBase class ContentHostDoubleBuffered : public ContentHostBase
{ {
public: public:
ContentHostDoubleBuffered(const TextureInfo& aTextureInfo, ContentHostDoubleBuffered(const TextureInfo& aTextureInfo)
Compositor* aCompositor) : ContentHostBase(aTextureInfo)
: ContentHostBase(aTextureInfo, aCompositor)
{} {}
~ContentHostDoubleBuffered(); ~ContentHostDoubleBuffered();
@ -173,9 +172,8 @@ protected:
class ContentHostSingleBuffered : public ContentHostBase class ContentHostSingleBuffered : public ContentHostBase
{ {
public: public:
ContentHostSingleBuffered(const TextureInfo& aTextureInfo, ContentHostSingleBuffered(const TextureInfo& aTextureInfo)
Compositor* aCompositor) : ContentHostBase(aTextureInfo)
: ContentHostBase(aTextureInfo, aCompositor)
{} {}
virtual ~ContentHostSingleBuffered(); virtual ~ContentHostSingleBuffered();

View File

@ -24,8 +24,8 @@ public:
TextureHost* GetTextureHost() MOZ_OVERRIDE { return nullptr; } TextureHost* GetTextureHost() MOZ_OVERRIDE { return nullptr; }
protected: protected:
ImageHost(const TextureInfo& aTextureInfo, Compositor* aCompositor) ImageHost(const TextureInfo& aTextureInfo)
: CompositableHost(aTextureInfo, aCompositor) : CompositableHost(aTextureInfo)
{ {
MOZ_COUNT_CTOR(ImageHost); MOZ_COUNT_CTOR(ImageHost);
} }
@ -40,8 +40,8 @@ protected:
class ImageHostSingle : public ImageHost class ImageHostSingle : public ImageHost
{ {
public: public:
ImageHostSingle(const TextureInfo& aTextureInfo, Compositor* aCompositor) ImageHostSingle(const TextureInfo& aTextureInfo)
: ImageHost(aTextureInfo, aCompositor) : ImageHost(aTextureInfo)
, mTextureHost(nullptr) , mTextureHost(nullptr)
, mHasPictureRect(false) , mHasPictureRect(false)
{} {}
@ -99,8 +99,8 @@ protected:
class ImageHostBuffered : public ImageHostSingle class ImageHostBuffered : public ImageHostSingle
{ {
public: public:
ImageHostBuffered(const TextureInfo& aTextureInfo, Compositor* aCompositor) ImageHostBuffered(const TextureInfo& aTextureInfo)
: ImageHostSingle(aTextureInfo, aCompositor) : ImageHostSingle(aTextureInfo)
{} {}
virtual bool Update(const SurfaceDescriptor& aImage, virtual bool Update(const SurfaceDescriptor& aImage,

View File

@ -389,7 +389,7 @@ LayerManagerComposite::ComputeRenderIntegrityInternal(Layer* aLayer,
TiledLayerComposer* composer = nullptr; TiledLayerComposer* composer = nullptr;
LayerComposite* shadow = aLayer->AsLayerComposite(); LayerComposite* shadow = aLayer->AsLayerComposite();
if (shadow) { if (shadow) {
composer = shadow->AsTiledLayerComposer(); composer = shadow->GetTiledLayerComposer();
if (composer) { if (composer) {
incompleteRegion.Sub(incompleteRegion, composer->GetValidLowPrecisionRegion()); incompleteRegion.Sub(incompleteRegion, composer->GetValidLowPrecisionRegion());
if (!incompleteRegion.IsEmpty()) { if (!incompleteRegion.IsEmpty()) {

View File

@ -287,12 +287,7 @@ public:
virtual void CleanupResources() = 0; virtual void CleanupResources() = 0;
virtual TiledLayerComposer* AsTiledLayerComposer() { return NULL; } virtual TiledLayerComposer* GetTiledLayerComposer() { return nullptr; }
virtual void EnsureBuffer(CompositableType aType)
{
MOZ_ASSERT(false, "Should not be called unless overriden.");
}
protected: protected:
LayerManagerComposite* mCompositeManager; LayerManagerComposite* mCompositeManager;

View File

@ -47,21 +47,6 @@ ThebesLayerComposite::SetCompositableHost(CompositableHost* aHost)
mBuffer= static_cast<ContentHost*>(aHost); mBuffer= static_cast<ContentHost*>(aHost);
} }
void
ThebesLayerComposite::EnsureBuffer(CompositableType aType)
{
MOZ_ASSERT(aType == BUFFER_TILED,
"Should only be called for tiled layers.");
if (!mBuffer ||
mBuffer->GetType() != aType) {
RefPtr<CompositableHost> bufferHost
= CompositableHost::Create(TextureInfo(aType), mCompositeManager->GetCompositor());
NS_ASSERTION(bufferHost->GetType() == BUFFER_TILED, "bad buffer type");
mBuffer = static_cast<ContentHost*>(bufferHost.get());
mRequiresTiledProperties = true;
}
}
void void
ThebesLayerComposite::Disconnect() ThebesLayerComposite::Disconnect()
{ {
@ -87,7 +72,7 @@ ThebesLayerComposite::GetLayer()
} }
TiledLayerComposer* TiledLayerComposer*
ThebesLayerComposite::AsTiledLayerComposer() ThebesLayerComposite::GetTiledLayerComposer()
{ {
return mBuffer->AsTiledLayerComposer(); return mBuffer->AsTiledLayerComposer();
} }

View File

@ -47,7 +47,7 @@ public:
virtual Layer* GetLayer() MOZ_OVERRIDE; virtual Layer* GetLayer() MOZ_OVERRIDE;
virtual TiledLayerComposer* AsTiledLayerComposer() MOZ_OVERRIDE; virtual TiledLayerComposer* GetTiledLayerComposer() MOZ_OVERRIDE;
virtual void RenderLayer(const nsIntPoint& aOffset, virtual void RenderLayer(const nsIntPoint& aOffset,
const nsIntRect& aClipRect) MOZ_OVERRIDE; const nsIntRect& aClipRect) MOZ_OVERRIDE;
@ -58,7 +58,7 @@ public:
virtual LayerComposite* AsLayerComposite() MOZ_OVERRIDE { return this; } virtual LayerComposite* AsLayerComposite() MOZ_OVERRIDE { return this; }
virtual void EnsureBuffer(CompositableType aType) MOZ_OVERRIDE; void EnsureTiled() { mRequiresTiledProperties = true; }
#ifdef MOZ_LAYERS_HAVE_LOG #ifdef MOZ_LAYERS_HAVE_LOG
virtual const char* Name() const MOZ_OVERRIDE { return "ThebesLayerComposite"; } virtual const char* Name() const MOZ_OVERRIDE { return "ThebesLayerComposite"; }

View File

@ -6,6 +6,7 @@
#include "TiledContentHost.h" #include "TiledContentHost.h"
#include "mozilla/layers/Effects.h" #include "mozilla/layers/Effects.h"
#include "nsPrintfCString.h" #include "nsPrintfCString.h"
#include "ThebesLayerComposite.h"
namespace mozilla { namespace mozilla {
using namespace gfx; using namespace gfx;
@ -59,6 +60,13 @@ TiledContentHost::~TiledContentHost()
mLowPrecisionMainMemoryTiledBuffer.ReadUnlock(); mLowPrecisionMainMemoryTiledBuffer.ReadUnlock();
} }
void
TiledContentHost::Attach(Layer* aLayer, Compositor* aCompositor)
{
CompositableHost::Attach(aLayer, aCompositor);
static_cast<ThebesLayerComposite*>(aLayer)->EnsureTiled();
}
void void
TiledContentHost::PaintedTiledLayerBuffer(const BasicTiledLayerBuffer* mTiledBuffer) TiledContentHost::PaintedTiledLayerBuffer(const BasicTiledLayerBuffer* mTiledBuffer)
{ {

View File

@ -66,8 +66,8 @@ class TiledLayerBufferComposite
friend class TiledLayerBuffer<TiledLayerBufferComposite, TiledTexture>; friend class TiledLayerBuffer<TiledLayerBufferComposite, TiledTexture>;
public: public:
TiledLayerBufferComposite(Compositor* aCompositor) TiledLayerBufferComposite()
: mCompositor(aCompositor) : mCompositor(nullptr)
{} {}
void Upload(const BasicTiledLayerBuffer* aMainMemoryTiledBuffer, void Upload(const BasicTiledLayerBuffer* aMainMemoryTiledBuffer,
@ -81,6 +81,11 @@ public:
// by the sum of the resolutions of all parent layers' FrameMetrics. // by the sum of the resolutions of all parent layers' FrameMetrics.
const gfxSize& GetFrameResolution() { return mFrameResolution; } const gfxSize& GetFrameResolution() { return mFrameResolution; }
void SetCompositor(Compositor* aCompositor)
{
mCompositor = aCompositor;
}
protected: protected:
TiledTexture ValidateTile(TiledTexture aTile, TiledTexture ValidateTile(TiledTexture aTile,
const nsIntPoint& aTileRect, const nsIntPoint& aTileRect,
@ -126,10 +131,8 @@ class TiledContentHost : public ContentHost,
public TiledLayerComposer public TiledLayerComposer
{ {
public: public:
TiledContentHost(const TextureInfo& aTextureInfo, Compositor* aCompositor) TiledContentHost(const TextureInfo& aTextureInfo)
: ContentHost(aTextureInfo, aCompositor) : ContentHost(aTextureInfo)
, mVideoMemoryTiledBuffer(aCompositor)
, mLowPrecisionVideoMemoryTiledBuffer(aCompositor)
, mPendingUpload(false) , mPendingUpload(false)
, mPendingLowPrecisionUpload(false) , mPendingLowPrecisionUpload(false)
{} {}
@ -179,7 +182,7 @@ public:
virtual CompositableType GetType() { return BUFFER_TILED; } virtual CompositableType GetType() { return BUFFER_TILED; }
virtual TiledLayerComposer* AsTiledLayerComposer() { return this; } virtual TiledLayerComposer* AsTiledLayerComposer() MOZ_OVERRIDE { return this; }
virtual bool EnsureTextureHost(TextureIdentifier aTextureId, virtual bool EnsureTextureHost(TextureIdentifier aTextureId,
const SurfaceDescriptor& aSurface, const SurfaceDescriptor& aSurface,
@ -190,6 +193,15 @@ public:
return false; 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 #ifdef MOZ_LAYERS_HAVE_LOG
virtual void PrintInfo(nsACString& aTo, const char* aPrefix); virtual void PrintInfo(nsACString& aTo, const char* aPrefix);
#endif #endif

View File

@ -20,6 +20,7 @@ class TextureFactoryIdentifier;
class SurfaceDescriptor; class SurfaceDescriptor;
class ThebesBufferData; class ThebesBufferData;
class TextureClient; class TextureClient;
class BasicTiledLayerBuffer;
/** /**
* A transaction is a set of changes that happenned on the content side, that * 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 DestroyThebesBuffer(CompositableClient* aCompositable) = 0;
virtual void PaintedTiledLayerBuffer(CompositableClient* aCompositable,
BasicTiledLayerBuffer* aTiledLayerBuffer) = 0;
/** /**
* Communicate to the compositor that the texture identified by aCompositable * Communicate to the compositor that the texture identified by aCompositable
* and aTextureId has been updated to aImage. * and aTextureId has been updated to aImage.

View File

@ -132,6 +132,20 @@ CompositableParentManager::ReceiveCompositableUpdate(const CompositableOperation
compositable->SetPictureRect(op.picture()); compositable->SetPictureRect(op.picture());
break; break;
} }
case CompositableOperation::TOpPaintTiledLayerBuffer: {
MOZ_LAYERS_LOG(("[ParentSide] Paint TiledLayerBuffer"));
const OpPaintTiledLayerBuffer& op = aEdit.get_OpPaintTiledLayerBuffer();
CompositableParent* compositableParent = static_cast<CompositableParent*>(op.compositableParent());
CompositableHost* compositable =
compositableParent->GetCompositableHost();
TiledLayerComposer* tileComposer = compositable->AsTiledLayerComposer();
NS_ASSERTION(tileComposer, "compositable is not a tile composer");
BasicTiledLayerBuffer* p = reinterpret_cast<BasicTiledLayerBuffer*>(op.tiledLayerBuffer());
tileComposer->PaintedTiledLayerBuffer(p);
break;
}
default: { default: {
MOZ_ASSERT(false, "bad type"); MOZ_ASSERT(false, "bad type");
} }

View File

@ -230,6 +230,12 @@ public:
virtual void Connect(CompositableClient* aCompositable) MOZ_OVERRIDE; 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 * Communicate to the compositor that the texture identified by aCompositable
* and aTextureId has been updated to aDescriptor. * and aTextureId has been updated to aDescriptor.

View File

@ -235,7 +235,7 @@ struct OpRaiseToTopChild { PLayer container; PLayer childLayer; };
// Paint (buffer update) // Paint (buffer update)
struct OpPaintTiledLayerBuffer { struct OpPaintTiledLayerBuffer {
PLayer layer; PCompositable compositable;
// Bug 747811 // Bug 747811
// FIXME: We need to support sharing tile across process. // FIXME: We need to support sharing tile across process.
uintptr_t tiledLayerBuffer; uintptr_t tiledLayerBuffer;
@ -277,6 +277,8 @@ union CompositableOperation {
OpPaintTexture; OpPaintTexture;
OpPaintTextureRegion; OpPaintTextureRegion;
OpPaintTiledLayerBuffer;
}; };
// A unit of a changeset; a set of these comprise a changeset // A unit of a changeset; a set of these comprise a changeset
@ -300,7 +302,6 @@ union Edit {
OpAttachCompositable; OpAttachCompositable;
OpAttachAsyncCompositable; OpAttachAsyncCompositable;
OpPaintTiledLayerBuffer;
CompositableOperation; CompositableOperation;
}; };

View File

@ -290,12 +290,12 @@ ShadowLayerForwarder::RepositionChild(ShadowableLayer* aContainer,
} }
void void
ShadowLayerForwarder::PaintedTiledLayerBuffer(ShadowableLayer* aLayer, ShadowLayerForwarder::PaintedTiledLayerBuffer(CompositableClient* aCompositable,
BasicTiledLayerBuffer* aTiledLayerBuffer) BasicTiledLayerBuffer* aTiledLayerBuffer)
{ {
if (XRE_GetProcessType() != GeckoProcessType_Default) if (XRE_GetProcessType() != GeckoProcessType_Default)
NS_RUNTIMEABORT("PaintedTiledLayerBuffer must be made IPC safe (not share pointers)"); 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))); uintptr_t(aTiledLayerBuffer)));
} }

View File

@ -50,7 +50,6 @@ class TiledLayerComposer;
class Transaction; class Transaction;
class SurfaceDescriptor; class SurfaceDescriptor;
class CanvasSurface; class CanvasSurface;
class BasicTiledLayerBuffer;
class TextureClientShmem; class TextureClientShmem;
class ContentClientRemote; class ContentClientRemote;
class CompositableChild; class CompositableChild;
@ -258,8 +257,8 @@ public:
* and is free to choose it's own internal representation (double buffering, * and is free to choose it's own internal representation (double buffering,
* copy on write, tiling). * copy on write, tiling).
*/ */
void PaintedTiledLayerBuffer(ShadowableLayer* aThebes, virtual void PaintedTiledLayerBuffer(CompositableClient* aCompositable,
BasicTiledLayerBuffer* aTiledLayerBuffer); BasicTiledLayerBuffer* aTiledLayerBuffer) MOZ_OVERRIDE;
/** /**
* Notify the compositor that a compositable will be updated asynchronously * Notify the compositor that a compositable will be updated asynchronously

View File

@ -389,21 +389,6 @@ ShadowLayersParent::RecvUpdate(const InfallibleTArray<Edit>& cset,
compositableParent->SetCompositorID(mLayerManager->GetCompositor()->GetCompositorID()); compositableParent->SetCompositorID(mLayerManager->GetCompositor()->GetCompositorID());
break; 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<BasicTiledLayerBuffer*>(op.tiledLayerBuffer());
tileComposer->PaintedTiledLayerBuffer(p);
break;
}
default: default:
NS_RUNTIMEABORT("not reached"); NS_RUNTIMEABORT("not reached");
} }