Bug 695406 - Reset IPC double buffers if the ContentType has changed. r=cjones

This commit is contained in:
Oleg Romashin ext:(%2C%20Matt%20Woodrow%20%3Cmwoodrow%40mozilla.com%3E) 2011-10-21 14:29:09 +13:00
Родитель cc836abae5
Коммит 888c49fd78
3 изменённых файлов: 36 добавлений и 10 удалений

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

@ -2389,7 +2389,8 @@ class BasicShadowableImageLayer : public BasicImageLayer,
{
public:
BasicShadowableImageLayer(BasicShadowLayerManager* aManager) :
BasicImageLayer(aManager)
BasicImageLayer(aManager),
mBufferIsOpaque(false)
{
MOZ_COUNT_CTOR(BasicShadowableImageLayer);
}
@ -2451,6 +2452,7 @@ private:
// For YUV Images these are the 3 planes (Y, Cb and Cr),
// for RGB images only mBackSurface is used.
SurfaceDescriptor mBackBuffer;
bool mBufferIsOpaque;
nsRefPtr<gfxSharedImageSurface> mBackBufferY;
nsRefPtr<gfxSharedImageSurface> mBackBufferU;
nsRefPtr<gfxSharedImageSurface> mBackBufferV;
@ -2518,12 +2520,16 @@ BasicShadowableImageLayer::Paint(gfxContext* aContext)
if (!pat || !HasShadow())
return;
if (oldSize != mSize || !IsSurfaceDescriptorValid(mBackBuffer)) {
bool isOpaque = (GetContentFlags() & CONTENT_OPAQUE);
if (oldSize != mSize ||
!IsSurfaceDescriptorValid(mBackBuffer) ||
isOpaque != mBufferIsOpaque) {
DestroyBackBuffer();
mBufferIsOpaque = isOpaque;
if (!BasicManager()->AllocBuffer(
mSize,
(GetContentFlags() & CONTENT_OPAQUE) ?
isOpaque ?
gfxASurface::CONTENT_COLOR : gfxASurface::CONTENT_COLOR_ALPHA,
&mBackBuffer))
NS_RUNTIMEABORT("creating ImageLayer 'front buffer' failed!");
@ -2575,7 +2581,8 @@ class BasicShadowableCanvasLayer : public BasicCanvasLayer,
{
public:
BasicShadowableCanvasLayer(BasicShadowLayerManager* aManager) :
BasicCanvasLayer(aManager)
BasicCanvasLayer(aManager),
mBufferIsOpaque(false)
{
MOZ_COUNT_CTOR(BasicShadowableCanvasLayer);
}
@ -2622,6 +2629,7 @@ private:
}
SurfaceDescriptor mBackBuffer;
bool mBufferIsOpaque;
};
void
@ -2651,10 +2659,14 @@ BasicShadowableCanvasLayer::Paint(gfxContext* aContext)
return;
}
if (!IsSurfaceDescriptorValid(mBackBuffer)) {
bool isOpaque = (GetContentFlags() & CONTENT_OPAQUE);
if (!IsSurfaceDescriptorValid(mBackBuffer) ||
isOpaque != mBufferIsOpaque) {
DestroyBackBuffer();
mBufferIsOpaque = isOpaque;
if (!BasicManager()->AllocBuffer(
gfxIntSize(mBounds.width, mBounds.height),
(GetContentFlags() & CONTENT_OPAQUE) ?
isOpaque ?
gfxASurface::CONTENT_COLOR : gfxASurface::CONTENT_COLOR_ALPHA,
&mBackBuffer))
NS_RUNTIMEABORT("creating CanvasLayer back buffer failed!");
@ -2943,7 +2955,13 @@ BasicShadowImageLayer::Swap(const SharedImage& aNewFront,
nsRefPtr<gfxASurface> surface =
BasicManager()->OpenDescriptor(aNewFront);
// Destroy mFrontBuffer if size different
if (surface->GetSize() != mSize) {
bool needDrop = false;
if (IsSurfaceDescriptorValid(mFrontBuffer)) {
nsRefPtr<gfxASurface> front = BasicManager()->OpenDescriptor(mFrontBuffer);
needDrop = surface->GetSize() != mSize ||
surface->GetContentType() != front->GetContentType();
}
if (needDrop) {
DestroyFrontBuffer();
mSize = surface->GetSize();
}
@ -3059,7 +3077,13 @@ BasicShadowCanvasLayer::Swap(const CanvasSurface& aNewFront, bool needYFlip,
BasicManager()->OpenDescriptor(aNewFront);
// Destroy mFrontBuffer if size different
gfxIntSize sz = surface->GetSize();
if (sz != gfxIntSize(mBounds.width, mBounds.height)) {
bool needDrop = false;
if (IsSurfaceDescriptorValid(mFrontSurface)) {
nsRefPtr<gfxASurface> front = BasicManager()->OpenDescriptor(mFrontSurface);
needDrop = sz != gfxIntSize(mBounds.width, mBounds.height) ||
surface->GetContentType() != front->GetContentType();
}
if (needDrop) {
DestroyFrontBuffer();
mBounds.SetRect(0, 0, sz.width, sz.height);
}

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

@ -324,7 +324,8 @@ ShadowCanvasLayerOGL::Swap(const CanvasSurface& aNewFront,
if (!mDestroyed) {
nsRefPtr<gfxASurface> surf = ShadowLayerForwarder::OpenDescriptor(aNewFront);
gfxIntSize sz = surf->GetSize();
if (!mTexImage || mTexImage->GetSize() != sz) {
if (!mTexImage || mTexImage->GetSize() != sz ||
mTexImage->GetContentType() != surf->GetContentType()) {
Init(aNewFront, needYFlip);
}
nsIntRegion updateRegion(nsIntRect(0, 0, sz.width, sz.height));

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

@ -885,7 +885,8 @@ ShadowImageLayerOGL::Swap(const SharedImage& aNewFront,
nsRefPtr<gfxASurface> surf =
ShadowLayerForwarder::OpenDescriptor(aNewFront.get_SurfaceDescriptor());
gfxIntSize size = surf->GetSize();
if (mSize != size || !mTexImage) {
if (mSize != size || !mTexImage ||
mTexImage->GetContentType() != surf->GetContentType()) {
Init(aNewFront);
}
// XXX this is always just ridiculously slow