Bug 1051592 - Clip DrawTargetCairo's context to the surface bound to prevent massive mask allocations within cairo. r=jrmuizel

This commit is contained in:
Matt Woodrow 2014-08-15 14:23:22 +12:00
parent e82f0c3fce
commit 903bd31201
2 changed files with 16 additions and 1 deletions

View File

@ -68,7 +68,14 @@ public:
MOZ_ASSERT(cairo_status(mCtx) || dt->GetTransform() == GetTransform());
}
~AutoPrepareForDrawing() { cairo_restore(mCtx); }
~AutoPrepareForDrawing()
{
cairo_restore(mCtx);
cairo_status_t status = cairo_status(mCtx);
if (status) {
gfxWarning() << "DrawTargetCairo context in error state: " << cairo_status_to_string(status) << "(" << status << ")";
}
}
private:
#ifdef DEBUG
@ -1290,6 +1297,13 @@ DrawTargetCairo::InitAlreadyReferenced(cairo_surface_t* aSurface, const IntSize&
mSize = aSize;
mFormat = aFormat ? *aFormat : CairoContentToGfxFormat(cairo_surface_get_content(aSurface));
// Cairo image surface have a bug where they will allocate a mask surface (for clipping)
// the size of the clip extents, and don't take the surface extents into account.
// Add a manual clip to the surface extents to prevent this.
cairo_new_path(mContext);
cairo_rectangle(mContext, 0, 0, mSize.width, mSize.height);
cairo_clip(mContext);
if (mFormat == SurfaceFormat::B8G8R8A8 ||
mFormat == SurfaceFormat::R8G8B8A8) {
SetPermitSubpixelAA(false);

View File

@ -439,6 +439,7 @@ _moz_cairo_set_source_rgba
_moz_cairo_set_source_surface
_moz_cairo_show_glyphs
_moz_cairo_status
_moz_cairo_status_to_string
_moz_cairo_stroke
_moz_cairo_stroke_extents
_moz_cairo_stroke_preserve