Bug 703472. Retain the DataSourceSurface. r=bas

The Quartz Azure backend has the data owned by the DataSourceSurface so we
can't drop the DataSourceSurface after creating an image surface around it.
This patch keeps the DataSourceSurface around for the lifetime of the
gfxASurface.

--HG--
extra : rebase_source : d758646bab85d827c09af390d11e5e30ad33a6c9
This commit is contained in:
Jeff Muizelaar 2011-11-15 11:44:21 +13:00
parent 2bcb0f0c44
commit 3dc2412d44

View File

@ -515,6 +515,13 @@ gfxPlatform::GetScaledFontForFont(gfxFont *aFont)
return NULL; return NULL;
} }
cairo_user_data_key_t kDrawSourceSurface;
static void
DataSourceSurfaceDestroy(void *dataSourceSurface)
{
static_cast<DataSourceSurface*>(dataSourceSurface)->Release();
}
already_AddRefed<gfxASurface> already_AddRefed<gfxASurface>
gfxPlatform::GetThebesSurfaceForDrawTarget(DrawTarget *aTarget) gfxPlatform::GetThebesSurfaceForDrawTarget(DrawTarget *aTarget)
{ {
@ -531,6 +538,8 @@ gfxPlatform::GetThebesSurfaceForDrawTarget(DrawTarget *aTarget)
nsRefPtr<gfxImageSurface> image = nsRefPtr<gfxImageSurface> image =
new gfxImageSurface(data->GetData(), gfxIntSize(size.width, size.height), new gfxImageSurface(data->GetData(), gfxIntSize(size.width, size.height),
data->Stride(), format); data->Stride(), format);
image->SetData(&kDrawSourceSurface, data.forget().drop(), DataSourceSurfaceDestroy);
return image.forget(); return image.forget();
} }