From 626f89e156a3102785a215fcaf09c132d7d820d4 Mon Sep 17 00:00:00 2001 From: Matt Woodrow Date: Wed, 16 Oct 2013 14:00:31 +1300 Subject: [PATCH] Bug 922942 - Implement gfxASurface::CopyToARGB32ImageSurface using azure. r=seth --- gfx/thebes/gfxASurface.cpp | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/gfx/thebes/gfxASurface.cpp b/gfx/thebes/gfxASurface.cpp index 1e96a9e907bb..c8b869b2b297 100644 --- a/gfx/thebes/gfxASurface.cpp +++ b/gfx/thebes/gfxASurface.cpp @@ -10,6 +10,7 @@ #include "mozilla/Attributes.h" #include "mozilla/MemoryReporting.h" #include "nsTraceRefcnt.h" +#include "mozilla/gfx/2D.h" #include "gfxASurface.h" #include "gfxContext.h" @@ -52,6 +53,7 @@ #include "nsIClipboardHelper.h" using namespace mozilla; +using namespace mozilla::gfx; static cairo_user_data_key_t gfxasurface_pointer_key; @@ -359,10 +361,17 @@ gfxASurface::CopyToARGB32ImageSurface() nsRefPtr imgSurface = new gfxImageSurface(size, gfxImageFormatARGB32); - gfxContext ctx(imgSurface); - ctx.SetOperator(gfxContext::OPERATOR_SOURCE); - ctx.SetSource(this); - ctx.Paint(); + if (gfxPlatform::GetPlatform()->SupportsAzureContent()) { + RefPtr dt = gfxPlatform::GetPlatform()->CreateDrawTargetForSurface(imgSurface, IntSize(size.width, size.height)); + RefPtr source = gfxPlatform::GetPlatform()->GetSourceSurfaceForSurface(dt, this); + + dt->CopySurface(source, IntRect(0, 0, size.width, size.height), IntPoint()); + } else { + gfxContext ctx(imgSurface); + ctx.SetOperator(gfxContext::OPERATOR_SOURCE); + ctx.SetSource(this); + ctx.Paint(); + } return imgSurface.forget(); }