Bug 780260 - Add serial numbers to Images and use it to check if an image has been painted to its BasicShadowableImageLayer already. r=cjones

This commit is contained in:
Matt Woodrow 2012-08-03 17:09:13 -07:00
parent 072ab750db
commit c7942e6ad6
3 changed files with 19 additions and 2 deletions

View File

@ -32,6 +32,10 @@ using mozilla::gfx::SourceSurface;
namespace mozilla {
namespace layers {
uint64_t Image::sSerialCounter = 0;
mozilla::Mutex Image::sSerialMutex("mozilla.layers.Image.sSerialMutex");
already_AddRefed<Image>
ImageFactory::CreateImage(const Image::Format *aFormats,
PRUint32 aNumFormats,

View File

@ -143,16 +143,24 @@ public:
void SetBackendData(LayersBackend aBackend, ImageBackendData* aData)
{ mBackendData[aBackend] = aData; }
uint64_t GetSerial() { return mSerial; }
protected:
Image(void* aImplData, Format aFormat) :
mImplData(aImplData),
mFormat(aFormat)
{}
{
MutexAutoLock lock(sSerialMutex);
mSerial = ++sSerialCounter;
}
nsAutoPtr<ImageBackendData> mBackendData[mozilla::layers::LAYERS_LAST];
void* mImplData;
uint64_t mSerial;
Format mFormat;
static uint64_t sSerialCounter;
static mozilla::Mutex sSerialMutex;
};
/**

View File

@ -174,7 +174,8 @@ class BasicShadowableImageLayer : public BasicImageLayer,
public:
BasicShadowableImageLayer(BasicShadowLayerManager* aManager) :
BasicImageLayer(aManager),
mBufferIsOpaque(false)
mBufferIsOpaque(false),
mLastPaintedImageSerial(0)
{
MOZ_COUNT_CTOR(BasicShadowableImageLayer);
}
@ -243,6 +244,7 @@ private:
SurfaceDescriptor mBackBufferU;
SurfaceDescriptor mBackBufferV;
gfxIntSize mCbCrSize;
uint64_t mLastPaintedImageSerial;
};
void
@ -371,6 +373,8 @@ BasicShadowableImageLayer::Paint(gfxContext* aContext, Layer* aMaskLayer)
if (!BasicManager()->AllocBuffer(mSize, type, &mBackBuffer))
NS_RUNTIMEABORT("creating ImageLayer 'front buffer' failed!");
} else if (mLastPaintedImageSerial == image->GetSerial()) {
return;
}
AutoOpenSurface backSurface(OPEN_READ_WRITE, mBackBuffer);
@ -382,6 +386,7 @@ BasicShadowableImageLayer::Paint(gfxContext* aContext, Layer* aMaskLayer)
BasicManager()->PaintedImage(BasicManager()->Hold(this),
mBackBuffer);
mLastPaintedImageSerial = image->GetSerial();
}
class BasicShadowImageLayer : public ShadowImageLayer, public BasicImplData {