mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-11 04:15:43 +00:00
Bug 846132 - (Part 1) Add gfxASurface methods to produce gfxImageSurfaces. r=jrmuizel
This commit is contained in:
parent
dfbea1ac80
commit
e391985aa5
@ -310,6 +310,35 @@ gfxASurface::CreateSimilarSurface(gfxContentType aContent,
|
||||
return result.forget();
|
||||
}
|
||||
|
||||
already_AddRefed<gfxImageSurface>
|
||||
gfxASurface::GetAsReadableARGB32ImageSurface()
|
||||
{
|
||||
nsRefPtr<gfxImageSurface> imgSurface = GetAsImageSurface();
|
||||
if (!imgSurface || imgSurface->Format() != gfxASurface::ImageFormatARGB32) {
|
||||
imgSurface = CopyToARGB32ImageSurface();
|
||||
}
|
||||
return imgSurface.forget();
|
||||
}
|
||||
|
||||
already_AddRefed<gfxImageSurface>
|
||||
gfxASurface::CopyToARGB32ImageSurface()
|
||||
{
|
||||
if (!mSurface || !mSurfaceValid) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const gfxIntSize size = GetSize();
|
||||
nsRefPtr<gfxImageSurface> imgSurface =
|
||||
new gfxImageSurface(size, gfxASurface::ImageFormatARGB32);
|
||||
|
||||
gfxContext ctx(imgSurface);
|
||||
ctx.SetOperator(gfxContext::OPERATOR_SOURCE);
|
||||
ctx.SetSource(this);
|
||||
ctx.Paint();
|
||||
|
||||
return imgSurface.forget();
|
||||
}
|
||||
|
||||
int
|
||||
gfxASurface::CairoStatus()
|
||||
{
|
||||
|
@ -155,6 +155,19 @@ public:
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a read-only ARGB32 image surface for this surface. If this is an
|
||||
* optimized surface this may require a copy.
|
||||
* Returns null on error.
|
||||
*/
|
||||
virtual already_AddRefed<gfxImageSurface> GetAsReadableARGB32ImageSurface();
|
||||
|
||||
/**
|
||||
* Creates a new ARGB32 image surface with the same contents as this surface.
|
||||
* Returns null on error.
|
||||
*/
|
||||
already_AddRefed<gfxImageSurface> CopyToARGB32ImageSurface();
|
||||
|
||||
int CairoStatus();
|
||||
|
||||
/* Make sure that the given dimensions don't overflow a 32-bit signed int
|
||||
|
Loading…
Reference in New Issue
Block a user