Bug 627858: Use AutoSaveRestore objects in SVGDrawingCallback::operator(), rather than manually saving & restoring gfxContext state. r=jwatt a=roc
authorDaniel Holbert <dholbert@cs.stanford.edu>
Mon, 24 Jan 2011 10:32:34 -0800
changeset 61178 6128904992831ad1d9b65880417e6998e5eaed06
parent 61177 9ec42a4717062c495cc70fe6d7b10c23b3d79243
child 61179 3f19e5698520a8cd63e15719a8dce7f2bd90463c
child 61386 3a4e6a96823ac51cf9ce8b2eeb0ecf49d262dc42
push id18260
push userdholbert@mozilla.com
push dateMon, 24 Jan 2011 18:34:32 +0000
treeherdermozilla-central@612890499283 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjwatt, roc
bugs627858
milestone2.0b10pre
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 627858: Use AutoSaveRestore objects in SVGDrawingCallback::operator(), rather than manually saving & restoring gfxContext state. r=jwatt a=roc
modules/libpr0n/src/VectorImage.cpp
--- a/modules/libpr0n/src/VectorImage.cpp
+++ b/modules/libpr0n/src/VectorImage.cpp
@@ -158,24 +158,24 @@ SVGDrawingCallback::operator()(gfxContex
   // Get (& sanity-check) the helper-doc's presShell
   nsCOMPtr<nsIPresShell> presShell;
   if (NS_FAILED(mSVGDocumentWrapper->GetPresShell(getter_AddRefs(presShell)))) {
     NS_WARNING("Unable to draw -- presShell lookup failed");
     return NS_ERROR_FAILURE;
   }
   NS_ABORT_IF_FALSE(presShell, "GetPresShell succeeded but returned null");
 
-  aContext->Save();
+  gfxContextAutoSaveRestore contextRestorer(aContext);
 
   // Clip to aFillRect so that we don't paint outside.
   aContext->NewPath();
   aContext->Rectangle(aFillRect);
   aContext->Clip();
-  gfxMatrix savedMatrix(aContext->CurrentMatrix());
 
+  gfxContextMatrixAutoSaveRestore contextMatrixRestorer(aContext);
   aContext->Multiply(gfxMatrix(aTransform).Invert());
 
 
   nsPresContext* presContext = presShell->GetPresContext();
   NS_ABORT_IF_FALSE(presContext, "pres shell w/out pres context");
 
   nsRect svgRect(presContext->DevPixelsToAppUnits(mViewport.x),
                  presContext->DevPixelsToAppUnits(mViewport.y),
@@ -186,19 +186,16 @@ SVGDrawingCallback::operator()(gfxContex
   if (!(mImageFlags & imgIContainer::FLAG_SYNC_DECODE)) {
     renderDocFlags |= nsIPresShell::RENDER_ASYNC_DECODE_IMAGES;
   }
 
   presShell->RenderDocument(svgRect, renderDocFlags,
                             NS_RGBA(0, 0, 0, 0), // transparent
                             aContext);
 
-  aContext->SetMatrix(savedMatrix);
-  aContext->Restore();
-
   return PR_TRUE;
 }
 
 // Implement VectorImage's nsISupports-inherited methods
 NS_IMPL_ISUPPORTS3(VectorImage,
                    imgIContainer,
                    nsIStreamListener,
                    nsIRequestObserver)