Bug 611433 - Add gfxQuartzImage constructor for data pointers. r=jrmuizel a=blocking2.0

This commit is contained in:
Joe Drew 2010-12-16 23:34:54 -08:00
parent 233f393c74
commit 63935bac8b
2 changed files with 24 additions and 0 deletions

View File

@ -87,6 +87,29 @@ gfxQuartzSurface::gfxQuartzSurface(cairo_surface_t *csurf,
Init(csurf, PR_TRUE);
}
gfxQuartzSurface::gfxQuartzSurface(unsigned char *data,
const gfxSize& size,
long stride,
gfxImageFormat format,
PRBool aForPrinting)
: mCGContext(nsnull), mSize(size), mForPrinting(aForPrinting)
{
unsigned int width = (unsigned int) floor(size.width);
unsigned int height = (unsigned int) floor(size.height);
if (!CheckSurfaceSize(gfxIntSize(width, height)))
return;
cairo_surface_t *surf = cairo_quartz_surface_create_for_data
(data, (cairo_format_t) format, width, height, stride);
mCGContext = cairo_quartz_surface_get_cg_context (surf);
CGContextRetain(mCGContext);
Init(surf);
}
already_AddRefed<gfxASurface>
gfxQuartzSurface::CreateSimilarSurface(gfxContentType aType,
const gfxIntSize& aSize)

View File

@ -51,6 +51,7 @@ public:
gfxQuartzSurface(const gfxSize& size, gfxImageFormat format, PRBool aForPrinting = PR_FALSE);
gfxQuartzSurface(CGContextRef context, const gfxSize& size, PRBool aForPrinting = PR_FALSE);
gfxQuartzSurface(cairo_surface_t *csurf, PRBool aForPrinting = PR_FALSE);
gfxQuartzSurface(unsigned char *data, const gfxSize& size, long stride, gfxImageFormat format, PRBool aForPrinting = PR_FALSE);
virtual ~gfxQuartzSurface();