Bug 772726. Make nsCanvasRenderingContext2DAzure::DrawWindow use Azure content drawing if that's enabled. r=bas
authorRobert O'Callahan <robert@ocallahan.org>
Tue, 04 Sep 2012 16:24:09 +1200
changeset 107571 a5cb3eecff37b2569a1574adb051617baf1cdb68
parent 107570 74db71024d857293f3485afb69d3c3bf15fb40b2
child 107572 7c820213a4d1fa755eb8f3f0f98fc9cccfe15040
push id23490
push userMs2ger@gmail.com
push dateThu, 20 Sep 2012 11:22:06 +0000
treeherdermozilla-central@6a2d1a3556b9 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbas
bugs772726
milestone18.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 772726. Make nsCanvasRenderingContext2DAzure::DrawWindow use Azure content drawing if that's enabled. r=bas
content/canvas/src/nsCanvasRenderingContext2DAzure.cpp
--- a/content/canvas/src/nsCanvasRenderingContext2DAzure.cpp
+++ b/content/canvas/src/nsCanvasRenderingContext2DAzure.cpp
@@ -3899,42 +3899,34 @@ nsCanvasRenderingContext2DAzure::DrawWin
   // protect against too-large surfaces that will cause allocation
   // or overflow issues
   if (!gfxASurface::CheckSurfaceSize(gfxIntSize(int32_t(w), int32_t(h)),
                                      0xffff)) {
     error.Throw(NS_ERROR_FAILURE);
     return;
   }
 
-  nsRefPtr<gfxASurface> drawSurf;
-  GetThebesSurface(getter_AddRefs(drawSurf));
-
-  nsRefPtr<gfxContext> thebes = new gfxContext(drawSurf);
-
   EnsureTarget();
-  Matrix matrix = mTarget->GetTransform();
-  thebes->SetMatrix(gfxMatrix(matrix._11, matrix._12, matrix._21,
-                              matrix._22, matrix._31, matrix._32));
-
   // We can't allow web apps to call this until we fix at least the
   // following potential security issues:
   // -- rendering cross-domain IFRAMEs and then extracting the results
   // -- rendering the user's theme and then extracting the results
   // -- rendering native anonymous content (e.g., file input paths;
   // scrollbars should be allowed)
   if (!nsContentUtils::IsCallerTrustedForRead()) {
     // not permitted to use DrawWindow
     // XXX ERRMSG we need to report an error to developers here! (bug 329026)
     error.Throw(NS_ERROR_DOM_SECURITY_ERR);
     return;
   }
 
   // Flush layout updates
-  if (!(flags & nsIDOMCanvasRenderingContext2D::DRAWWINDOW_DO_NOT_FLUSH))
+  if (!(flags & nsIDOMCanvasRenderingContext2D::DRAWWINDOW_DO_NOT_FLUSH)) {
     nsContentUtils::FlushLayoutForTree(window);
+  }
 
   nsRefPtr<nsPresContext> presContext;
   nsCOMPtr<nsPIDOMWindow> win = do_QueryInterface(window);
   if (win) {
     nsIDocShell* docshell = win->GetDocShell();
     if (docshell) {
       docshell->GetPresContext(getter_AddRefs(presContext));
     }
@@ -3965,18 +3957,32 @@ nsCanvasRenderingContext2DAzure::DrawWin
   }
   if (flags & nsIDOMCanvasRenderingContext2D::DRAWWINDOW_USE_WIDGET_LAYERS) {
     renderDocFlags |= nsIPresShell::RENDER_USE_WIDGET_LAYERS;
   }
   if (flags & nsIDOMCanvasRenderingContext2D::DRAWWINDOW_ASYNC_DECODE_IMAGES) {
     renderDocFlags |= nsIPresShell::RENDER_ASYNC_DECODE_IMAGES;
   }
 
+  // gfxContext-over-Azure may modify the DrawTarget's transform, so
+  // save and restore it
+  Matrix matrix = mTarget->GetTransform();
+  nsRefPtr<gfxContext> thebes;
+  if (gfxPlatform::UseAzureContentDrawing()) {
+    thebes = new gfxContext(mTarget);
+  } else {
+    nsRefPtr<gfxASurface> drawSurf;
+    GetThebesSurface(getter_AddRefs(drawSurf));
+    thebes = new gfxContext(drawSurf);
+  }
+  thebes->SetMatrix(gfxMatrix(matrix._11, matrix._12, matrix._21,
+                              matrix._22, matrix._31, matrix._32));
   unused << presContext->PresShell()->
     RenderDocument(r, renderDocFlags, backgroundColor, thebes);
+  mTarget->SetTransform(matrix);
 
   // note that x and y are coordinates in the document that
   // we're drawing; x and y are drawn to 0,0 in current user
   // space.
   RedrawUser(gfxRect(0, 0, w, h));
 }
 
 NS_IMETHODIMP