Bug 781380 - Fix cairo surface memory leak in DrawTargetCairo::CreateSimilarDrawTarget(). r=roc

This commit is contained in:
Anthony Jones 2012-08-23 19:50:59 -04:00
parent 5fd5fe5bbc
commit f43050747b
2 changed files with 11 additions and 2 deletions

View File

@ -810,17 +810,23 @@ DrawTargetCairo::CreateSimilarDrawTarget(const IntSize &aSize, SurfaceFormat aFo
}
bool
DrawTargetCairo::Init(cairo_surface_t* aSurface, const IntSize& aSize)
DrawTargetCairo::InitAlreadyReferenced(cairo_surface_t* aSurface, const IntSize& aSize)
{
mContext = cairo_create(aSurface);
mSurface = aSurface;
cairo_surface_reference(mSurface);
mSize = aSize;
mFormat = CairoContentToGfxFormat(cairo_surface_get_content(aSurface));
return true;
}
bool
DrawTargetCairo::Init(cairo_surface_t* aSurface, const IntSize& aSize)
{
cairo_surface_reference(aSurface);
return InitAlreadyReferenced(aSurface, aSize);
}
void *
DrawTargetCairo::GetNativeSurface(NativeSurfaceType aType)
{

View File

@ -135,6 +135,9 @@ public:
void PrepareForDrawing(cairo_t* aContext, const Path* aPath = nullptr);
private: // methods
// Init cairo surface without doing a cairo_surface_reference() call.
bool InitAlreadyReferenced(cairo_surface_t* aSurface, const IntSize& aSize);
enum DrawPatternType { DRAW_FILL, DRAW_STROKE };
void DrawPattern(const Pattern& aPattern,
const StrokeOptions& aStrokeOptions,