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
Родитель d294ee3873
Коммит ab6a6b6eb2
2 изменённых файлов: 40 добавлений и 0 удалений

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

@ -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) {

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

@ -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();