Bug 709490 - Part 6: Add frame ID to CanvasClient so compositor could update frame correctly. r=roc

--HG--
extra : rebase_source : 6bd6f11189fc431f24d5bdd1381ea5adc7ffcebe
This commit is contained in:
Morris Tseng 2015-10-12 11:21:03 +08:00
Родитель c3d37560cc
Коммит 83252e218f
3 изменённых файлов: 43 добавлений и 2 удалений

Просмотреть файл

@ -384,7 +384,7 @@ struct ColorLayerProperties : public LayerPropertiesBase
IntRect mBounds;
};
static ImageHost* GetImageHost(ImageLayer* aLayer)
static ImageHost* GetImageHost(Layer* aLayer)
{
LayerComposite* composite = aLayer->AsLayerComposite();
if (composite) {
@ -464,6 +464,34 @@ struct ImageLayerProperties : public LayerPropertiesBase
bool mIsMask;
};
struct CanvasLayerProperties : public LayerPropertiesBase
{
explicit CanvasLayerProperties(CanvasLayer* aCanvas)
: LayerPropertiesBase(aCanvas)
, mImageHost(GetImageHost(aCanvas))
{
mFrameID = mImageHost ? mImageHost->GetFrameID() : -1;
}
virtual nsIntRegion ComputeChangeInternal(NotifySubDocInvalidationFunc aCallback,
bool& aGeometryChanged)
{
CanvasLayer* canvasLayer = static_cast<CanvasLayer*>(mLayer.get());
ImageHost* host = GetImageHost(canvasLayer);
if (host && host->GetFrameID() != mFrameID) {
aGeometryChanged = true;
return NewTransformedBounds();
}
return IntRect();
}
nsRefPtr<ImageHost> mImageHost;
int32_t mFrameID;
};
UniquePtr<LayerPropertiesBase>
CloneLayerTreePropertiesInternal(Layer* aRoot, bool aIsMask /* = false */)
{
@ -482,6 +510,7 @@ CloneLayerTreePropertiesInternal(Layer* aRoot, bool aIsMask /* = false */)
case Layer::TYPE_IMAGE:
return MakeUnique<ImageLayerProperties>(static_cast<ImageLayer*>(aRoot), aIsMask);
case Layer::TYPE_CANVAS:
return MakeUnique<CanvasLayerProperties>(static_cast<CanvasLayer*>(aRoot));
case Layer::TYPE_READBACK:
case Layer::TYPE_SHADOW:
case Layer::TYPE_PAINTED:

Просмотреть файл

@ -125,6 +125,7 @@ CanvasClient2D::Update(gfx::IntSize aSize, ClientCanvasLayer* aLayer)
CompositableForwarder::TimedTextureClient* t = textures.AppendElement();
t->mTextureClient = mBuffer;
t->mPictureRect = nsIntRect(nsIntPoint(0, 0), mBuffer->GetSize());
t->mFrameID = mFrameID;
GetForwarder()->UseTextures(this, textures);
mBuffer->SyncWithObject(GetForwarder()->GetSyncObject());
}
@ -460,6 +461,7 @@ CanvasClientSharedSurface::Updated()
CompositableForwarder::TimedTextureClient* t = textures.AppendElement();
t->mTextureClient = mFront;
t->mPictureRect = nsIntRect(nsIntPoint(0, 0), mFront->GetSize());
t->mFrameID = mFrameID;
forwarder->UseTextures(this, textures);
}

Просмотреть файл

@ -57,6 +57,7 @@ public:
CanvasClient(CompositableForwarder* aFwd, TextureFlags aFlags)
: CompositableClient(aFwd, aFlags)
, mFrameID(0)
{
mTextureFlags = aFlags;
}
@ -67,9 +68,18 @@ public:
virtual void Update(gfx::IntSize aSize, ClientCanvasLayer* aLayer) = 0;
virtual bool AddTextureClient(TextureClient* aTexture) override
{
++mFrameID;
return CompositableClient::AddTextureClient(aTexture);
}
virtual void UpdateAsync(AsyncCanvasRenderer* aRenderer) {}
virtual void Updated() { }
protected:
int32_t mFrameID;
};
// Used for 2D canvases and WebGL canvas on non-GL systems where readback is requried.
@ -97,7 +107,7 @@ public:
virtual bool AddTextureClient(TextureClient* aTexture) override
{
MOZ_ASSERT((mTextureFlags & aTexture->GetFlags()) == mTextureFlags);
return CompositableClient::AddTextureClient(aTexture);
return CanvasClient::AddTextureClient(aTexture);
}
virtual void OnDetach() override