зеркало из https://github.com/mozilla/gecko-dev.git
Bug 917703 - Mark gfxSubimageSurface as opaque if it is within the opaque rect of the parent surface. r=roc
This commit is contained in:
Родитель
86badaa8b5
Коммит
ea50fadeaf
|
@ -299,21 +299,30 @@ gfxImageSurface::GetSubimage(const gfxRect& aRect)
|
|||
r.Round();
|
||||
MOZ_ASSERT(gfxRect(0, 0, mSize.width, mSize.height).Contains(r));
|
||||
|
||||
gfxImageFormat format = Format();
|
||||
|
||||
unsigned char* subData = Data() +
|
||||
(Stride() * (int)r.Y()) +
|
||||
(int)r.X() * gfxASurface::BytePerPixelFromFormat(Format());
|
||||
|
||||
if (format == ImageFormatARGB32 &&
|
||||
GetOpaqueRect().Contains(aRect)) {
|
||||
format = ImageFormatRGB24;
|
||||
}
|
||||
|
||||
nsRefPtr<gfxSubimageSurface> image =
|
||||
new gfxSubimageSurface(this, subData,
|
||||
gfxIntSize((int)r.Width(), (int)r.Height()));
|
||||
gfxIntSize((int)r.Width(), (int)r.Height()),
|
||||
format);
|
||||
|
||||
return image.forget();
|
||||
}
|
||||
|
||||
gfxSubimageSurface::gfxSubimageSurface(gfxImageSurface* aParent,
|
||||
unsigned char* aData,
|
||||
const gfxIntSize& aSize)
|
||||
: gfxImageSurface(aData, aSize, aParent->Stride(), aParent->Format())
|
||||
const gfxIntSize& aSize,
|
||||
gfxImageFormat aFormat)
|
||||
: gfxImageSurface(aData, aSize, aParent->Stride(), aFormat)
|
||||
, mParent(aParent)
|
||||
{
|
||||
}
|
||||
|
|
|
@ -149,7 +149,8 @@ protected:
|
|||
friend class gfxImageSurface;
|
||||
gfxSubimageSurface(gfxImageSurface* aParent,
|
||||
unsigned char* aData,
|
||||
const gfxIntSize& aSize);
|
||||
const gfxIntSize& aSize,
|
||||
gfxImageFormat aFormat);
|
||||
private:
|
||||
nsRefPtr<gfxImageSurface> mParent;
|
||||
};
|
||||
|
|
|
@ -72,6 +72,7 @@ gfxQPainterSurface::GetAsImageSurface()
|
|||
assert(cairo_surface_get_type(isurf) == CAIRO_SURFACE_TYPE_IMAGE);
|
||||
|
||||
nsRefPtr<gfxImageSurface> asurf = new gfxImageSurface(isurf);
|
||||
asurf->SetOpaqueRect(GetOpaqueRect());
|
||||
return asurf.forget();
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -67,5 +67,8 @@ gfxQuartzImageSurface::GetAsImageSurface()
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
return gfxASurface::Wrap(isurf).downcast<gfxImageSurface>();
|
||||
nsRefPtr<gfxImageSurface> result = gfxASurface::Wrap(isurf).downcast<gfxImageSurface>();
|
||||
result->SetOpaqueRect(GetOpaqueRect());
|
||||
|
||||
return result.forget();
|
||||
}
|
||||
|
|
|
@ -194,6 +194,8 @@ already_AddRefed<gfxImageSurface> gfxQuartzSurface::GetAsImageSurface()
|
|||
// explicitly so we don't leak.
|
||||
img->Release();
|
||||
|
||||
img->SetOpaqueRect(GetOpaqueRect());
|
||||
|
||||
return img.forget().downcast<gfxImageSurface>();
|
||||
}
|
||||
|
||||
|
|
|
@ -193,7 +193,10 @@ gfxWindowsSurface::GetAsImageSurface()
|
|||
if (!isurf)
|
||||
return nullptr;
|
||||
|
||||
return gfxASurface::Wrap(isurf).downcast<gfxImageSurface>();
|
||||
nsRefPtr<gfxImageSurface> result = gfxASurface::Wrap(isurf).downcast<gfxImageSurface>();
|
||||
result->SetOpaqueRect(GetOpaqueRect());
|
||||
|
||||
return result.forget();
|
||||
}
|
||||
|
||||
already_AddRefed<gfxWindowsSurface>
|
||||
|
|
|
@ -814,6 +814,7 @@ void imgFrame::SetHasNoAlpha()
|
|||
if (mFormat == gfxASurface::ImageFormatARGB32) {
|
||||
mFormat = gfxASurface::ImageFormatRGB24;
|
||||
mFormatChanged = true;
|
||||
ThebesSurface()->SetOpaqueRect(gfxRect(0, 0, mSize.width, mSize.height));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче