Bug 622072. Part 2: Add DidTransactionCallback to CanvasLayer. r=bas, sr=joe

This commit is contained in:
Robert O'Callahan 2011-03-28 12:59:46 +13:00
parent 6536947736
commit 333b8d0f05
5 changed files with 28 additions and 3 deletions

View File

@ -1181,6 +1181,16 @@ public:
*/
void Updated() { mDirty = PR_TRUE; }
/**
* Register a callback to be called at the end of each transaction.
*/
typedef void (* DidTransactionCallback)(void* aClosureData);
void SetDidTransactionCallback(DidTransactionCallback aCallback, void* aClosureData)
{
mCallback = aCallback;
mCallbackData = aClosureData;
}
/**
* CONSTRUCTION PHASE ONLY
* Set the filter used to resample this image (if necessary).
@ -1204,14 +1214,25 @@ public:
protected:
CanvasLayer(LayerManager* aManager, void* aImplData)
: Layer(aManager, aImplData), mFilter(gfxPattern::FILTER_GOOD), mDirty(PR_FALSE) {}
: Layer(aManager, aImplData),
mCallback(nsnull), mCallbackData(nsnull), mFilter(gfxPattern::FILTER_GOOD),
mDirty(PR_FALSE) {}
virtual nsACString& PrintInfo(nsACString& aTo, const char* aPrefix);
void FireDidTransactionCallback()
{
if (mCallback) {
mCallback(mCallbackData);
}
}
/**
* 0, 0, canvaswidth, canvasheight
*/
nsIntRect mBounds;
DidTransactionCallback mCallback;
void* mCallbackData;
gfxPattern::GraphicsFilter mFilter;
/**
* Set to true in Updated(), cleared during a transaction.

View File

@ -995,6 +995,7 @@ void
BasicCanvasLayer::Paint(gfxContext* aContext)
{
UpdateSurface();
FireDidTransactionCallback();
PaintWithOpacity(aContext, GetEffectiveOpacity());
}

View File

@ -228,10 +228,10 @@ void
CanvasLayerD3D10::RenderLayer()
{
UpdateSurface();
FireDidTransactionCallback();
if (!mTexture) {
if (!mTexture)
return;
}
nsIntRect visibleRect = mVisibleRegion.GetBounds();

View File

@ -209,6 +209,8 @@ void
CanvasLayerD3D9::RenderLayer()
{
UpdateSurface();
FireDidTransactionCallback();
if (!mTexture)
return;

View File

@ -184,6 +184,7 @@ CanvasLayerOGL::RenderLayer(int aPreviousDestination,
const nsIntPoint& aOffset)
{
UpdateSurface();
FireDidTransactionCallback();
mOGLManager->MakeCurrent();