Bug 935008 - Partial backout of effddcf29fa7 (bug 922942) for SVG perf regressions.
authorJonathan Watt <jwatt@jwatt.org>
Fri, 06 Dec 2013 09:59:36 +0000
changeset 174833 d4ca041c97b45fbe983d70b9e3eea10a51638ad8
parent 174832 c491f36ee82c554d3d17dd398072a0be89dbbeee
child 174834 20a6f6176960b5cdf2f346f6dba9100fc7a94ccb
push id445
push userffxbld
push dateMon, 10 Mar 2014 22:05:19 +0000
treeherdermozilla-release@dc38b741b04e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs935008, 922942
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 935008 - Partial backout of effddcf29fa7 (bug 922942) for SVG perf regressions.
layout/svg/nsSVGImageFrame.cpp
layout/svg/nsSVGPathGeometryFrame.cpp
--- a/layout/svg/nsSVGImageFrame.cpp
+++ b/layout/svg/nsSVGImageFrame.cpp
@@ -464,17 +464,17 @@ nsSVGImageFrame::ReflowSVG()
 
   NS_ABORT_IF_FALSE(!(GetStateBits() & NS_FRAME_IS_NONDISPLAY),
                     "ReflowSVG mechanism not designed for this");
 
   if (!nsSVGUtils::NeedsReflowSVG(this)) {
     return;
   }
 
-  nsRefPtr<gfxContext> tmpCtx = new gfxContext(gfxPlatform::GetPlatform()->ScreenReferenceDrawTarget());
+  gfxContext tmpCtx(gfxPlatform::GetPlatform()->ScreenReferenceSurface());
 
   // We'd like to just pass the identity matrix to GeneratePath, but if
   // this frame's user space size is _very_ large/small then the extents we
   // obtain below might have overflowed or otherwise be broken. This would
   // cause us to end up with a broken mRect and visual overflow rect and break
   // painting of this frame. This is particularly noticeable if the transforms
   // between us and our nsSVGOuterSVGFrame scale this frame to a reasonable
   // size. To avoid this we sadly have to do extra work to account for the
@@ -483,20 +483,20 @@ nsSVGImageFrame::ReflowSVG()
   // XXX Will Azure eventually save us from having to do this?
   gfxSize scaleFactors = GetCanvasTM(FOR_OUTERSVG_TM).ScaleFactors(true);
   bool applyScaling = fabs(scaleFactors.width) >= 1e-6 &&
                       fabs(scaleFactors.height) >= 1e-6;
   gfxMatrix scaling;
   if (applyScaling) {
     scaling.Scale(scaleFactors.width, scaleFactors.height);
   }
-  tmpCtx->Save();
-  GeneratePath(tmpCtx, scaling);
-  tmpCtx->Restore();
-  gfxRect extent = tmpCtx->GetUserPathExtent();
+  tmpCtx.Save();
+  GeneratePath(&tmpCtx, scaling);
+  tmpCtx.Restore();
+  gfxRect extent = tmpCtx.GetUserPathExtent();
   if (applyScaling) {
     extent.Scale(1 / scaleFactors.width, 1 / scaleFactors.height);
   }
 
   if (!extent.IsEmpty()) {
     mRect = nsLayoutUtils::RoundGfxRectToAppRect(extent, 
               PresContext()->AppUnitsPerCSSPixel());
   } else {
--- a/layout/svg/nsSVGPathGeometryFrame.cpp
+++ b/layout/svg/nsSVGPathGeometryFrame.cpp
@@ -240,17 +240,18 @@ nsSVGPathGeometryFrame::GetFrameForPoint
     if (!hitTestFlags || ((hitTestFlags & SVG_HIT_TEST_CHECK_MRECT) &&
                           !mRect.Contains(point)))
       return nullptr;
     fillRule = StyleSVG()->mFillRule;
   }
 
   bool isHit = false;
 
-  nsRefPtr<gfxContext> tmpCtx = new gfxContext(gfxPlatform::GetPlatform()->ScreenReferenceDrawTarget());
+  nsRefPtr<gfxContext> tmpCtx =
+    new gfxContext(gfxPlatform::GetPlatform()->ScreenReferenceSurface());
 
   GeneratePath(tmpCtx, canvasTM);
   gfxPoint userSpacePoint =
     tmpCtx->DeviceToUser(gfxPoint(PresContext()->AppUnitsToGfxUnits(aPoint.x),
                                   PresContext()->AppUnitsToGfxUnits(aPoint.y)));
 
   if (fillRule == NS_STYLE_FILL_RULE_EVENODD)
     tmpCtx->SetFillRule(gfxContext::FILL_RULE_EVEN_ODD);
@@ -402,17 +403,18 @@ nsSVGPathGeometryFrame::GetBBoxContribut
 {
   SVGBBox bbox;
 
   if (aToBBoxUserspace.IsSingular()) {
     // XXX ReportToConsole
     return bbox;
   }
 
-  nsRefPtr<gfxContext> tmpCtx = new gfxContext(gfxPlatform::GetPlatform()->ScreenReferenceDrawTarget());
+  nsRefPtr<gfxContext> tmpCtx =
+    new gfxContext(gfxPlatform::GetPlatform()->ScreenReferenceSurface());
 
   GeneratePath(tmpCtx, aToBBoxUserspace);
   tmpCtx->IdentityMatrix();
 
   // Be careful when replacing the following logic to get the fill and stroke
   // extents independently (instead of computing the stroke extents from the
   // path extents). You may think that you can just use the stroke extents if
   // there is both a fill and a stroke. In reality it's necessary to calculate