Bug 924194 - Make gfxQuartzNativeDrawing::BeginNativeDrawing able to handle DrawTargets with a different backend than BACKEND_COREGRAPHICS (e.g. BACKEND_CAIRO). r=jrmuizel
authorMarkus Stange <mstange@themasta.com>
Thu, 24 Oct 2013 17:53:39 +0200
changeset 165801 a1d74808c32581a42de1d51bf9bafbffb4552c94
parent 165800 4eaaad2e06f20b53c5229ddfb4d7f3e3a8a52c66
child 165802 17d130494887b4e0db3afc747eade2f1b3072b53
push id3066
push userakeybl@mozilla.com
push dateMon, 09 Dec 2013 19:58:46 +0000
treeherdermozilla-beta@a31a0dce83aa [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjrmuizel
bugs924194
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 924194 - Make gfxQuartzNativeDrawing::BeginNativeDrawing able to handle DrawTargets with a different backend than BACKEND_COREGRAPHICS (e.g. BACKEND_CAIRO). r=jrmuizel
gfx/thebes/gfxQuartzNativeDrawing.cpp
--- a/gfx/thebes/gfxQuartzNativeDrawing.cpp
+++ b/gfx/thebes/gfxQuartzNativeDrawing.cpp
@@ -30,42 +30,47 @@ gfxQuartzNativeDrawing::gfxQuartzNativeD
     mNativeRect.RoundOut();
 }
 
 CGContextRef
 gfxQuartzNativeDrawing::BeginNativeDrawing()
 {
     NS_ASSERTION(!mQuartzSurface, "BeginNativeDrawing called when drawing already in progress");
 
+    gfxPoint deviceOffset;
+    nsRefPtr<gfxASurface> surf;
+
     if (!mContext->IsCairo()) {
       DrawTarget *dt = mContext->GetDrawTarget();
-      if (mContext->GetDrawTarget()->IsDualDrawTarget()) {
-        IntSize backingSize(NSToIntFloor(mNativeRect.width * mBackingScale),
-                            NSToIntFloor(mNativeRect.height * mBackingScale));
+      if (dt->GetType() == BACKEND_COREGRAPHICS) {
+        if (dt->IsDualDrawTarget()) {
+          IntSize backingSize(NSToIntFloor(mNativeRect.width * mBackingScale),
+                              NSToIntFloor(mNativeRect.height * mBackingScale));
 
-       if (backingSize.IsEmpty())
-          return nullptr;
+         if (backingSize.IsEmpty())
+            return nullptr;
 
-        mDrawTarget = Factory::CreateDrawTarget(BACKEND_COREGRAPHICS, backingSize, FORMAT_B8G8R8A8);
+          mDrawTarget = Factory::CreateDrawTarget(BACKEND_COREGRAPHICS, backingSize, FORMAT_B8G8R8A8);
 
-        Matrix transform;
-        transform.Scale(mBackingScale, mBackingScale);
-        transform.Translate(-mNativeRect.x, -mNativeRect.y);
+          Matrix transform;
+          transform.Scale(mBackingScale, mBackingScale);
+          transform.Translate(-mNativeRect.x, -mNativeRect.y);
 
-        mDrawTarget->SetTransform(transform);
-        dt = mDrawTarget;
-      }
+          mDrawTarget->SetTransform(transform);
+          dt = mDrawTarget;
+        }
 
-      mCGContext = mBorrowedContext.Init(dt);
-      MOZ_ASSERT(mCGContext);
-      return mCGContext;
+        mCGContext = mBorrowedContext.Init(dt);
+        MOZ_ASSERT(mCGContext);
+        return mCGContext;
+      }
+      surf = gfxPlatform::GetPlatform()->GetThebesSurfaceForDrawTarget(dt);
+    } else {
+      surf = mContext->CurrentSurface(&deviceOffset.x, &deviceOffset.y);
     }
-
-    gfxPoint deviceOffset;
-    nsRefPtr<gfxASurface> surf = mContext->CurrentSurface(&deviceOffset.x, &deviceOffset.y);
     if (!surf || surf->CairoStatus())
         return nullptr;
 
     // if this is a native Quartz surface, we don't have to redirect
     // rendering to our own CGContextRef; in most cases, we are able to
     // use the CGContextRef from the surface directly.  we can extend
     // this to support offscreen drawing fairly easily in the future.
     if (surf->GetType() == gfxSurfaceTypeQuartz &&