Bug 938528 - Check if data in the layer is still valid. r=gw280, r=snorp

This commit is contained in:
Morris 2013-12-04 17:46:20 -05:00
parent e53321c213
commit 19a48551b0
4 changed files with 17 additions and 2 deletions

View File

@ -3999,7 +3999,10 @@ CanvasRenderingContext2D::GetCanvasLayer(nsDisplayListBuilder* aBuilder,
CanvasRenderingContext2DUserData* userData =
static_cast<CanvasRenderingContext2DUserData*>(
aOldLayer->GetUserData(&g2DContextLayerUserData));
if (userData && userData->IsForContext(this)) {
CanvasLayer::Data data;
data.mGLContext = static_cast<GLContext*>(mTarget->GetGLContext());
if (userData && userData->IsForContext(this) && aOldLayer->IsDataValid(data)) {
nsRefPtr<CanvasLayer> ret = aOldLayer;
return ret.forget();
}

View File

@ -69,6 +69,12 @@ CopyableCanvasLayer::Initialize(const Data& aData)
mBounds.SetRect(0, 0, aData.mSize.width, aData.mSize.height);
}
bool
CopyableCanvasLayer::IsDataValid(const Data& aData)
{
return mGLContext == aData.mGLContext;
}
void
CopyableCanvasLayer::UpdateSurface(gfxASurface* aDestSurface, Layer* aMaskLayer)
{

View File

@ -40,7 +40,8 @@ public:
virtual ~CopyableCanvasLayer();
virtual void Initialize(const Data& aData);
virtual bool IsDataValid(const Data& aData);
protected:
void PaintWithOpacity(gfxContext* aContext,

View File

@ -1733,6 +1733,11 @@ public:
*/
virtual void Initialize(const Data& aData) = 0;
/**
* Check the data is owned by this layer is still valid for rendering
*/
virtual bool IsDataValid(const Data& aData) { return true; }
/**
* Notify this CanvasLayer that the canvas surface contents have
* changed (or will change) before the next transaction.