diff --git a/gfx/thebes/gfxUtils.cpp b/gfx/thebes/gfxUtils.cpp index 86f120f54d33..78637a85940a 100644 --- a/gfx/thebes/gfxUtils.cpp +++ b/gfx/thebes/gfxUtils.cpp @@ -4,6 +4,8 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "gfxUtils.h" + +#include "cairo.h" #include "gfxContext.h" #include "gfxImageSurface.h" #include "gfxPlatform.h" @@ -993,6 +995,21 @@ gfxUtils::ConvertYCbCrToRGB(const PlanarYCbCrData& aData, } } +/* static */ void gfxUtils::ClearThebesSurface(gfxASurface* aSurface) +{ + if (aSurface->CairoStatus()) { + return; + } + cairo_surface_t* surf = aSurface->CairoSurface(); + if (cairo_surface_status(surf)) { + return; + } + cairo_t* ctx = cairo_create(surf); + cairo_set_operator(ctx, CAIRO_OPERATOR_CLEAR); + cairo_paint_with_alpha(ctx, 1.0); + cairo_destroy(ctx); +} + /* static */ TemporaryRef gfxUtils::CopySurfaceToDataSourceSurfaceWithFormat(SourceSurface* aSurface, SurfaceFormat aFormat) diff --git a/gfx/thebes/gfxUtils.h b/gfx/thebes/gfxUtils.h index 92f15ec40110..222347121e7e 100644 --- a/gfx/thebes/gfxUtils.h +++ b/gfx/thebes/gfxUtils.h @@ -13,6 +13,7 @@ #include "mozilla/RefPtr.h" #include "nsPrintfCString.h" +class gfxASurface; class gfxDrawable; class nsIntRegion; struct nsIntRect; @@ -166,6 +167,11 @@ public: unsigned char* aDestBuffer, int32_t aStride); + /** + * Clears surface to transparent black. + */ + static void ClearThebesSurface(gfxASurface* aSurface); + /** * Creates a copy of aSurface, but having the SurfaceFormat aFormat. *