diff --git a/gfx/2d/DrawTargetCairo.cpp b/gfx/2d/DrawTargetCairo.cpp index 39d738c79ff7..db9d2cad3f5f 100644 --- a/gfx/2d/DrawTargetCairo.cpp +++ b/gfx/2d/DrawTargetCairo.cpp @@ -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) { diff --git a/gfx/2d/DrawTargetCairo.h b/gfx/2d/DrawTargetCairo.h index 867873f1e17b..0f4edd5af64f 100644 --- a/gfx/2d/DrawTargetCairo.h +++ b/gfx/2d/DrawTargetCairo.h @@ -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,