Bug 922942 - Implement gfxASurface::CopyToARGB32ImageSurface using azure. r=seth
authorMatt Woodrow <mwoodrow@mozilla.com>
Wed, 16 Oct 2013 14:00:31 +1300
changeset 165623 d1881913d9a676f2a6ef45a6da3bf20c0f33c8f6
parent 165622 c0e5db20b6556eed713a25e9ccd93489e5eb71ed
child 165624 349d02055f07ceaea5b2dfdf81be5b8b8a4de595
push id428
push userbbajaj@mozilla.com
push dateTue, 28 Jan 2014 00:16:25 +0000
treeherdermozilla-release@cd72a7ff3a75 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersseth
bugs922942
milestone27.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 922942 - Implement gfxASurface::CopyToARGB32ImageSurface using azure. r=seth
gfx/thebes/gfxASurface.cpp
--- a/gfx/thebes/gfxASurface.cpp
+++ b/gfx/thebes/gfxASurface.cpp
@@ -5,16 +5,17 @@
 
 #include "nsIMemoryReporter.h"
 #include "nsMemory.h"
 #include "mozilla/Base64.h"
 #include "mozilla/CheckedInt.h"
 #include "mozilla/Attributes.h"
 #include "mozilla/MemoryReporting.h"
 #include "nsTraceRefcnt.h"
+#include "mozilla/gfx/2D.h"
 
 #include "gfxASurface.h"
 #include "gfxContext.h"
 #include "gfxImageSurface.h"
 #include "gfxPlatform.h"
 #include "gfxRect.h"
 
 #include "cairo.h"
@@ -47,16 +48,17 @@
 #include "nsComponentManagerUtils.h"
 #include "nsISupportsUtils.h"
 #include "nsCOMPtr.h"
 #include "nsServiceManagerUtils.h"
 #include "nsString.h"
 #include "nsIClipboardHelper.h"
 
 using namespace mozilla;
+using namespace mozilla::gfx;
 
 static cairo_user_data_key_t gfxasurface_pointer_key;
 
 gfxASurface::gfxASurface()
  : mSurface(nullptr), mFloatingRefs(0), mBytesRecorded(0),
    mSurfaceValid(false), mAllowUseAsSource(true)
 {
     MOZ_COUNT_CTOR(gfxASurface);
@@ -354,20 +356,27 @@ gfxASurface::CopyToARGB32ImageSurface()
     if (!mSurface || !mSurfaceValid) {
       return nullptr;
     }
 
     const nsIntSize size = GetSize();
     nsRefPtr<gfxImageSurface> imgSurface =
         new gfxImageSurface(size, gfxImageFormatARGB32);
 
-    gfxContext ctx(imgSurface);
-    ctx.SetOperator(gfxContext::OPERATOR_SOURCE);
-    ctx.SetSource(this);
-    ctx.Paint();
+    if (gfxPlatform::GetPlatform()->SupportsAzureContent()) {
+        RefPtr<DrawTarget> dt = gfxPlatform::GetPlatform()->CreateDrawTargetForSurface(imgSurface, IntSize(size.width, size.height));
+        RefPtr<SourceSurface> 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();
 }
 
 int
 gfxASurface::CairoStatus()
 {
     if (!mSurfaceValid)