Bug 1325320 - change SVGGeometryElement::GetOrBuildPath to take DrawTarget as a pointer since all its callers have drawTarget as a pointer themselves.
authorRobert Longson <longsonr@gmail.com>
Fri, 09 Mar 2018 07:36:13 +0000
changeset 462343 2bd1e128872221c9d8ffedf5c04ddbd0f7ded051
parent 462342 2e0412dd3fc90ac56d86f2c1846f004d3477e22b
child 462344 14ef02ecc3033a4fa1a28d23897acc5239b620ea
push id1683
push usersfraser@mozilla.com
push dateThu, 26 Apr 2018 16:43:40 +0000
treeherdermozilla-release@5af6cb21869d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1325320
milestone60.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 1325320 - change SVGGeometryElement::GetOrBuildPath to take DrawTarget as a pointer since all its callers have drawTarget as a pointer themselves. This is consistent with most other methods that take a drawTarget parameter r=dholbert
dom/svg/SVGGeometryElement.cpp
dom/svg/SVGGeometryElement.h
layout/svg/SVGGeometryFrame.cpp
layout/svg/nsSVGClipPathFrame.cpp
--- a/dom/svg/SVGGeometryElement.cpp
+++ b/dom/svg/SVGGeometryElement.cpp
@@ -93,33 +93,33 @@ SVGGeometryElement::IsMarkable()
 }
 
 void
 SVGGeometryElement::GetMarkPoints(nsTArray<nsSVGMark> *aMarks)
 {
 }
 
 already_AddRefed<Path>
-SVGGeometryElement::GetOrBuildPath(const DrawTarget& aDrawTarget,
+SVGGeometryElement::GetOrBuildPath(const DrawTarget* aDrawTarget,
                                    FillRule aFillRule)
 {
   // We only cache the path if it matches the backend used for screen painting:
-  bool cacheable  = aDrawTarget.GetBackendType() ==
+  bool cacheable  = aDrawTarget->GetBackendType() ==
                     gfxPlatform::GetPlatform()->GetDefaultContentBackend();
 
   // Checking for and returning mCachedPath before checking the pref means
   // that the pref is only live on page reload (or app restart for SVG in
   // chrome). The benefit is that we avoid causing a CPU memory cache miss by
   // looking at the global variable that the pref's stored in.
   if (cacheable && mCachedPath && mCachedPath->GetFillRule() == aFillRule &&
-      aDrawTarget.GetBackendType() == mCachedPath->GetBackendType()) {
+      aDrawTarget->GetBackendType() == mCachedPath->GetBackendType()) {
     RefPtr<Path> path(mCachedPath);
     return path.forget();
   }
-  RefPtr<PathBuilder> builder = aDrawTarget.CreatePathBuilder(aFillRule);
+  RefPtr<PathBuilder> builder = aDrawTarget->CreatePathBuilder(aFillRule);
   RefPtr<Path> path = BuildPath(builder);
   if (cacheable && NS_SVGPathCachingEnabled()) {
     mCachedPath = path;
   }
   return path.forget();
 }
 
 already_AddRefed<Path>
--- a/dom/svg/SVGGeometryElement.h
+++ b/dom/svg/SVGGeometryElement.h
@@ -169,17 +169,17 @@ public:
     aSimplePath->Reset();
   }
 
   /**
    * Returns a Path that can be used to paint, hit-test or calculate bounds for
    * this element. May return nullptr if there is no [valid] path. The path
    * that is created may be cached and returned on subsequent calls.
    */
-  virtual already_AddRefed<Path> GetOrBuildPath(const DrawTarget& aDrawTarget,
+  virtual already_AddRefed<Path> GetOrBuildPath(const DrawTarget* aDrawTarget,
                                                 FillRule fillRule);
 
   /**
    * The same as GetOrBuildPath, but bypasses the cache (neither returns any
    * previously cached Path, nor caches the Path that in does return).
    * this element. May return nullptr if there is no [valid] path.
    */
   virtual already_AddRefed<Path> BuildPath(PathBuilder* aBuilder) = 0;
--- a/layout/svg/SVGGeometryFrame.cpp
+++ b/layout/svg/SVGGeometryFrame.cpp
@@ -335,17 +335,17 @@ SVGGeometryFrame::GetFrameForPoint(const
   SVGGeometryElement* content =
     static_cast<SVGGeometryElement*>(GetContent());
 
   // Using ScreenReferenceDrawTarget() opens us to Moz2D backend specific hit-
   // testing bugs. Maybe we should use a BackendType::CAIRO DT for hit-testing
   // so that we get more consistent/backwards compatible results?
   RefPtr<DrawTarget> drawTarget =
     gfxPlatform::GetPlatform()->ScreenReferenceDrawTarget();
-  RefPtr<Path> path = content->GetOrBuildPath(*drawTarget, fillRule);
+  RefPtr<Path> path = content->GetOrBuildPath(drawTarget, fillRule);
   if (!path) {
     return nullptr; // no path, so we don't paint anything that can be hit
   }
 
   if (hitTestFlags & SVG_HIT_TEST_FILL) {
     isHit = path->ContainsPoint(ToPoint(aPoint), Matrix());
   }
   if (!isHit && (hitTestFlags & SVG_HIT_TEST_STROKE)) {
@@ -542,17 +542,17 @@ SVGGeometryFrame::GetBBoxContribution(co
 #else
     tmpDT = gfxPlatform::GetPlatform()->ScreenReferenceDrawTarget();
 #endif
 
     FillRule fillRule = nsSVGUtils::ToFillRule(
         (GetStateBits() & NS_STATE_SVG_CLIPPATH_CHILD)
       ? StyleSVG()->mClipRule
       : StyleSVG()->mFillRule);
-    RefPtr<Path> pathInUserSpace = element->GetOrBuildPath(*tmpDT, fillRule);
+    RefPtr<Path> pathInUserSpace = element->GetOrBuildPath(tmpDT, fillRule);
     if (!pathInUserSpace) {
       return bbox;
     }
     RefPtr<Path> pathInBBoxSpace;
     if (aToBBoxUserspace.IsIdentity()) {
       pathInBBoxSpace = pathInUserSpace;
     } else {
       RefPtr<PathBuilder> builder =
@@ -767,31 +767,31 @@ SVGGeometryFrame::Render(gfxContext* aCo
   // set it unnecessarily if we return early (it's an expensive operation for
   // some backends).
   gfxContextMatrixAutoSaveRestore autoRestoreTransform(aContext);
   aContext->SetMatrixDouble(aNewTransform);
 
   if (GetStateBits() & NS_STATE_SVG_CLIPPATH_CHILD) {
     // We don't complicate this code with GetAsSimplePath since the cost of
     // masking will dwarf Path creation overhead anyway.
-    RefPtr<Path> path = element->GetOrBuildPath(*drawTarget, fillRule);
+    RefPtr<Path> path = element->GetOrBuildPath(drawTarget, fillRule);
     if (path) {
       ColorPattern white(ToDeviceColor(Color(1.0f, 1.0f, 1.0f, 1.0f)));
       drawTarget->Fill(path, white,
                        DrawOptions(1.0f, CompositionOp::OP_OVER, aaMode));
     }
     return;
   }
 
   SVGGeometryElement::SimplePath simplePath;
   RefPtr<Path> path;
 
   element->GetAsSimplePath(&simplePath);
   if (!simplePath.IsPath()) {
-    path = element->GetOrBuildPath(*drawTarget, fillRule);
+    path = element->GetOrBuildPath(drawTarget, fillRule);
     if (!path) {
       return;
     }
   }
 
   SVGContextPaint* contextPaint = SVGContextPaint::GetContextPaint(GetContent());
 
   if (aRenderComponents & eRenderFill) {
@@ -812,17 +812,17 @@ SVGGeometryFrame::Render(gfxContext* aCo
   if ((aRenderComponents & eRenderStroke) &&
       nsSVGUtils::HasStroke(this, contextPaint)) {
     // Account for vector-effect:non-scaling-stroke:
     gfxMatrix userToOuterSVG;
     if (nsSVGUtils::GetNonScalingStrokeTransform(this, &userToOuterSVG)) {
       // A simple Rect can't be transformed with rotate/skew, so let's switch
       // to using a real path:
       if (!path) {
-        path = element->GetOrBuildPath(*drawTarget, fillRule);
+        path = element->GetOrBuildPath(drawTarget, fillRule);
         if (!path) {
           return;
         }
         simplePath.Reset();
       }
       // We need to transform the path back into the appropriate ancestor
       // coordinate system, and paint it it that coordinate system, in order
       // for non-scaled stroke to paint correctly.
--- a/layout/svg/nsSVGClipPathFrame.cpp
+++ b/layout/svg/nsSVGClipPathFrame.cpp
@@ -36,17 +36,17 @@ NS_IMPL_FRAMEARENA_HELPERS(nsSVGClipPath
 
 void
 nsSVGClipPathFrame::ApplyClipPath(gfxContext& aContext,
                                   nsIFrame* aClippedFrame,
                                   const gfxMatrix& aMatrix)
 {
   MOZ_ASSERT(IsTrivial(), "Caller needs to use GetClipMask");
 
-  DrawTarget& aDrawTarget = *aContext.GetDrawTarget();
+  const DrawTarget* drawTarget = aContext.GetDrawTarget();
 
   // No need for AutoReferenceChainGuard since simple clip paths by definition
   // don't reference another clip path.
 
   // Restore current transform after applying clip path:
   gfxContextMatrixAutoSaveRestore autoRestore(&aContext);
 
   RefPtr<Path> clipPath;
@@ -63,17 +63,17 @@ nsSVGClipPathFrame::ApplyClipPath(gfxCon
         PrependLocalTransformsTo(GetClipPathTransform(aClippedFrame) * aMatrix,
                                  eUserSpaceToParent);
       gfxMatrix newMatrix =
         aContext.CurrentMatrixDouble().PreMultiply(toChildsUserSpace).NudgeToIntegers();
       if (!newMatrix.IsSingular()) {
         aContext.SetMatrixDouble(newMatrix);
         FillRule clipRule =
           nsSVGUtils::ToFillRule(pathFrame->StyleSVG()->mClipRule);
-        clipPath = pathElement->GetOrBuildPath(aDrawTarget, clipRule);
+        clipPath = pathElement->GetOrBuildPath(drawTarget, clipRule);
       }
     }
   }
 
   if (clipPath) {
     aContext.Clip(clipPath);
   } else {
     // The spec says clip away everything if we have no children or the