Bug 923341 - Part 3: Use azure for CreateSamplingRestrictedDrawable. r=seth
authorMatt Woodrow <mwoodrow@mozilla.com>
Wed, 13 Nov 2013 17:32:48 +1300
changeset 155154 810c38bc0493006787b5cff6d05aab83098c3e76
parent 155153 79cfed9c9d1d67fd12b9b79ac819e5727282ab95
child 155155 99108bac6f2d57a1d110b6d1ac52bad1cdfd28e7
push id36260
push usermwoodrow@mozilla.com
push dateMon, 18 Nov 2013 08:30:44 +0000
treeherdermozilla-inbound@99108bac6f2d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersseth
bugs923341
milestone28.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 923341 - Part 3: Use azure for CreateSamplingRestrictedDrawable. r=seth
gfx/thebes/gfxUtils.cpp
--- a/gfx/thebes/gfxUtils.cpp
+++ b/gfx/thebes/gfxUtils.cpp
@@ -7,16 +7,17 @@
 #include "gfxContext.h"
 #include "gfxPlatform.h"
 #include "gfxDrawable.h"
 #include "nsRegion.h"
 #include "yuv_convert.h"
 #include "ycbcr_to_rgb565.h"
 #include "GeckoProfiler.h"
 #include "ImageContainer.h"
+#include "gfx2DGlue.h"
 
 #ifdef XP_WIN
 #include "gfxWindowsPlatform.h"
 #endif
 
 using namespace mozilla;
 using namespace mozilla::layers;
 using namespace mozilla::gfx;
@@ -241,36 +242,38 @@ CreateSamplingRestrictedDrawable(gfxDraw
 
     // if 'needed' is empty, nothing will be drawn since aFill
     // must be entirely outside the clip region, so it doesn't
     // matter what we do here, but we should avoid trying to
     // create a zero-size surface.
     if (needed.IsEmpty())
         return nullptr;
 
-    nsRefPtr<gfxASurface> temp;
+    nsRefPtr<gfxDrawable> drawable;
     gfxIntSize size(int32_t(needed.Width()), int32_t(needed.Height()));
 
     nsRefPtr<gfxImageSurface> image = aDrawable->GetAsImageSurface();
     if (image && gfxRect(0, 0, image->GetSize().width, image->GetSize().height).Contains(needed)) {
-      temp = image->GetSubimage(needed);
+      nsRefPtr<gfxASurface> temp = image->GetSubimage(needed);
+      drawable = new gfxSurfaceDrawable(temp, size, gfxMatrix().Translate(-needed.TopLeft()));
     } else {
-      temp =
-          gfxPlatform::GetPlatform()->CreateOffscreenSurface(size, gfxASurface::ContentFromFormat(aFormat));
-      if (!temp || temp->CairoStatus())
-          return nullptr;
+      mozilla::RefPtr<mozilla::gfx::DrawTarget> target =
+        gfxPlatform::GetPlatform()->CreateOffscreenContentDrawTarget(ToIntSize(size),
+                                                                     ImageFormatToSurfaceFormat(aFormat));
+      if (!target) {
+        return nullptr;
+      }
 
-      nsRefPtr<gfxContext> tmpCtx = new gfxContext(temp);
+      nsRefPtr<gfxContext> tmpCtx = new gfxContext(target);
       tmpCtx->SetOperator(OptimalFillOperator());
       aDrawable->Draw(tmpCtx, needed - needed.TopLeft(), true,
                       GraphicsFilter::FILTER_FAST, gfxMatrix().Translate(needed.TopLeft()));
+      drawable = new gfxSurfaceDrawable(target, size, gfxMatrix().Translate(-needed.TopLeft()));
     }
 
-    nsRefPtr<gfxDrawable> drawable = 
-        new gfxSurfaceDrawable(temp, size, gfxMatrix().Translate(-needed.TopLeft()));
     return drawable.forget();
 }
 #endif // !MOZ_GFX_OPTIMIZE_MOBILE
 
 // working around cairo/pixman bug (bug 364968)
 // Our device-space-to-image-space transform may not be acceptable to pixman.
 struct MOZ_STACK_CLASS AutoCairoPixmanBugWorkaround
 {