Bug 575521 - Add gfxQuartzSurface::GetAsImageSurface. r=jrmuizel,vlad

This commit is contained in:
Joe Drew 2010-11-11 15:31:23 -05:00
parent 69ac8b8909
commit c001466571
2 changed files with 19 additions and 0 deletions

View File

@ -117,6 +117,23 @@ PRInt32 gfxQuartzSurface::GetDefaultContextFlags() const
return 0;
}
already_AddRefed<gfxImageSurface> gfxQuartzSurface::GetAsImageSurface()
{
cairo_surface_t *surface = cairo_quartz_surface_get_image(mSurface);
if (!surface)
return nsnull;
nsRefPtr<gfxASurface> img = Wrap(surface);
// cairo_quartz_surface_get_image returns a referenced image, and thebes
// shares the refcounts of Cairo surfaces. However, Wrap also adds a
// reference to the image. We need to remove one of these references
// explicitly so we don't leak.
img->Release();
return static_cast<gfxImageSurface*>(img.forget().get());
}
gfxQuartzSurface::~gfxQuartzSurface()
{
CGContextRelease(mCGContext);

View File

@ -73,6 +73,8 @@ public:
virtual PRInt32 GetDefaultContextFlags() const;
already_AddRefed<gfxImageSurface> GetAsImageSurface();
protected:
CGContextRef mCGContext;
gfxSize mSize;