Bug 629866. Part 1: Create a DIB for a Win32 surface that's similar to a parent surface with alpha, even if the parent surface doesn't have a DIB. r=jrmuizel

--HG--
extra : rebase_source : 95240f4f4f2d7f7fa453a1eb3ca020c1839160c7
This commit is contained in:
Robert O'Callahan 2011-01-31 22:47:47 -05:00
parent 90c20af040
commit ac7b8cc9c4
2 changed files with 40 additions and 0 deletions

View File

@ -130,6 +130,43 @@ gfxWindowsSurface::InitWithDC(PRUint32 flags)
}
}
already_AddRefed<gfxASurface>
gfxWindowsSurface::CreateSimilarSurface(gfxContentType aContent,
const gfxIntSize& aSize)
{
if (!mSurface || !mSurfaceValid) {
return nsnull;
}
cairo_surface_t *surface;
if (GetContentType() == CONTENT_COLOR_ALPHA) {
// When creating a similar surface to a transparent surface, ensure
// the new surface uses a DIB. cairo_surface_create_similar won't
// use a DIB for a CONTENT_COLOR surface if this surface doesn't
// have a DIB (e.g. if we're a transparent window surface). But
// we need a DIB to perform well if the new surface is composited into
// a surface that's the result of create_similar(CONTENT_COLOR_ALPHA)
// (e.g. a backbuffer for the window) --- that new surface *would*
// have a DIB.
surface =
cairo_win32_surface_create_with_dib(cairo_format_t(gfxASurface::FormatFromContent(aContent)),
aSize.width, aSize.height);
} else {
surface =
cairo_surface_create_similar(mSurface, cairo_content_t(aContent),
aSize.width, aSize.height);
}
if (cairo_surface_status(surface)) {
cairo_surface_destroy(surface);
return nsnull;
}
nsRefPtr<gfxASurface> result = Wrap(surface);
cairo_surface_destroy(surface);
return result.forget();
}
gfxWindowsSurface::~gfxWindowsSurface()
{
if (mOwnsDC) {

View File

@ -67,6 +67,9 @@ public:
gfxWindowsSurface(cairo_surface_t *csurf);
virtual already_AddRefed<gfxASurface> CreateSimilarSurface(gfxContentType aType,
const gfxIntSize& aSize);
void InitWithDC(PRUint32 flags);
virtual ~gfxWindowsSurface();