Bug 1073972 - Get rid of gfxContext's FillRule enum in favor of Moz2D's. r=Bas
authorJonathan Watt <jwatt@jwatt.org>
Mon, 29 Sep 2014 14:15:19 +0100
changeset 207691 621ac0d4d8c91d0d4992c0ecd7e8821c411cc7ad
parent 207690 ece627b5e46a3b66e6af9df6017921789209a7d3
child 207692 22acc74cf08d65d9199b511842a1981e4c960aa7
push id27564
push userryanvm@gmail.com
push dateMon, 29 Sep 2014 18:57:04 +0000
treeherdermozilla-central@ce9a0b34225e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersBas
bugs1073972
milestone35.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 1073972 - Get rid of gfxContext's FillRule enum in favor of Moz2D's. r=Bas
content/svg/content/src/SVGEllipseElement.cpp
gfx/thebes/gfxContext.cpp
gfx/thebes/gfxContext.h
layout/base/nsCSSRendering.cpp
layout/svg/SVGTextFrame.cpp
layout/svg/nsSVGPathGeometryFrame.cpp
layout/svg/nsSVGUtils.h
--- a/content/svg/content/src/SVGEllipseElement.cpp
+++ b/content/svg/content/src/SVGEllipseElement.cpp
@@ -92,20 +92,17 @@ SVGEllipseElement::GetLengthInfo()
 
 //----------------------------------------------------------------------
 // nsSVGPathGeometryElement methods
 
 void
 SVGEllipseElement::ConstructPath(gfxContext *aCtx)
 {
   RefPtr<DrawTarget> dt = aCtx->GetDrawTarget();
-  FillRule fillRule =
-    aCtx->CurrentFillRule() == gfxContext::FILL_RULE_WINDING ?
-      FillRule::FILL_WINDING : FillRule::FILL_EVEN_ODD;
-  RefPtr<PathBuilder> builder = dt->CreatePathBuilder(fillRule);
+  RefPtr<PathBuilder> builder = dt->CreatePathBuilder(aCtx->CurrentFillRule());
   RefPtr<Path> path = BuildPath(builder);
   if (path) {
     aCtx->SetPath(path);
   }
 }
 
 TemporaryRef<Path>
 SVGEllipseElement::BuildPath(PathBuilder* aBuilder)
--- a/gfx/thebes/gfxContext.cpp
+++ b/gfx/thebes/gfxContext.cpp
@@ -718,23 +718,23 @@ gfxFloat
 gfxContext::CurrentMiterLimit() const
 {
   return CurrentState().strokeOptions.mMiterLimit;
 }
 
 void
 gfxContext::SetFillRule(FillRule rule)
 {
-  CurrentState().fillRule = rule == FILL_RULE_WINDING ? gfx::FillRule::FILL_WINDING : gfx::FillRule::FILL_EVEN_ODD;
+  CurrentState().fillRule = rule;
 }
 
-gfxContext::FillRule
+FillRule
 gfxContext::CurrentFillRule() const
 {
-  return FILL_RULE_WINDING;
+  return CurrentState().fillRule;
 }
 
 // clipping
 void
 gfxContext::Clip(const gfxRect& rect)
 {
   AzureState::PushedClip clip = { nullptr, ToRect(rect), mTransform };
   CurrentState().pushedClips.AppendElement(clip);
--- a/gfx/thebes/gfxContext.h
+++ b/gfx/thebes/gfxContext.h
@@ -32,16 +32,17 @@ template <typename T> class FallibleTArr
  * The functions like Rectangle and Arc do not do any drawing themselves.
  * When a path is drawn (stroked or filled), it is filled/stroked with a
  * pattern set by SetPattern, SetColor or SetSource.
  *
  * Note that the gfxContext takes coordinates in device pixels,
  * as opposed to app units.
  */
 class gfxContext MOZ_FINAL {
+    typedef mozilla::gfx::FillRule FillRule;
     typedef mozilla::gfx::Path Path;
 
     NS_INLINE_DECL_REFCOUNTING(gfxContext)
 
 public:
 
     /**
      * Initialize this context from a DrawTarget.
@@ -464,20 +465,16 @@ public:
 
     void SetMiterLimit(gfxFloat limit);
     gfxFloat CurrentMiterLimit() const;
 
     /**
      ** Fill Properties
      **/
 
-    enum FillRule {
-        FILL_RULE_WINDING,
-        FILL_RULE_EVEN_ODD
-    };
     void SetFillRule(FillRule rule);
     FillRule CurrentFillRule() const;
 
     /**
      ** Operators and Rendering control
      **/
 
     // define enum for operators (clear, src, dst, etc)
--- a/layout/base/nsCSSRendering.cpp
+++ b/layout/base/nsCSSRendering.cpp
@@ -1332,17 +1332,17 @@ nsCSSRendering::PaintBoxShadowOuter(nsPr
       renderContext->NewPath();
       renderContext->Rectangle(shadowGfxRectPlusBlur);
       if (hasBorderRadius) {
         renderContext->RoundedRectangle(frameGfxRect, borderRadii);
       } else {
         renderContext->Rectangle(frameGfxRect);
       }
 
-      renderContext->SetFillRule(gfxContext::FILL_RULE_EVEN_ODD);
+      renderContext->SetFillRule(FillRule::FILL_EVEN_ODD);
       renderContext->Clip();
 
       // Clip the shadow so that we only get the part that applies to aForFrame.
       nsRect fragmentClip = shadowRectPlusBlur;
       if (!skipSides.IsEmpty()) {
         if (skipSides.Left()) {
           nscoord xmost = fragmentClip.XMost();
           fragmentClip.x = aFrameArea.x;
@@ -1555,17 +1555,17 @@ nsCSSRendering::PaintBoxShadowInner(nsPr
       nsLayoutUtils::RectToGfxRect(shadowClipRect, twipsPerPixel);
     shadowClipGfxRect.Round();
     shadowContext->NewPath();
     shadowContext->Rectangle(shadowPaintGfxRect);
     if (hasBorderRadius)
       shadowContext->RoundedRectangle(shadowClipGfxRect, clipRectRadii, false);
     else
       shadowContext->Rectangle(shadowClipGfxRect);
-    shadowContext->SetFillRule(gfxContext::FILL_RULE_EVEN_ODD);
+    shadowContext->SetFillRule(FillRule::FILL_EVEN_ODD);
     shadowContext->Fill();
 
     blurringArea.DoPaint();
     renderContext->Restore();
   }
 }
 
 void
--- a/layout/svg/SVGTextFrame.cpp
+++ b/layout/svg/SVGTextFrame.cpp
@@ -2823,17 +2823,17 @@ SVGTextDrawPathCallbacks::NotifySelectio
   if (mRenderMode != SVGAutoRenderState::NORMAL) {
     // Don't paint selection backgrounds when in a clip path.
     return;
   }
 
   nsRefPtr<gfxPattern> fillPattern = MakeFillPattern();
   if (fillPattern) {
     gfx->SetPattern(fillPattern);
-    gfx->SetFillRule(nsSVGUtils::ThebesFillRule(mFrame->StyleSVG()->mFillRule));
+    gfx->SetFillRule(nsSVGUtils::ToFillRule(mFrame->StyleSVG()->mFillRule));
     gfx->FillWithOpacity(mColor == NS_40PERCENT_FOREGROUND_COLOR ? 0.4 : 1.0);
   }
   gfx->Restore();
 }
 
 void
 SVGTextDrawPathCallbacks::NotifyBeforeDecorationLine(nscolor aColor)
 {
@@ -2961,17 +2961,17 @@ SVGTextDrawPathCallbacks::FillAndStrokeG
 }
 
 void
 SVGTextDrawPathCallbacks::FillGeometry()
 {
   nsRefPtr<gfxPattern> fillPattern = MakeFillPattern();
   if (fillPattern) {
     gfx->SetPattern(fillPattern);
-    gfx->SetFillRule(nsSVGUtils::ThebesFillRule(mFrame->StyleSVG()->mFillRule));
+    gfx->SetFillRule(nsSVGUtils::ToFillRule(mFrame->StyleSVG()->mFillRule));
     gfx->Fill();
   }
 }
 
 void
 SVGTextDrawPathCallbacks::StrokeGeometry()
 {
   // We don't paint the stroke when we are filling with a selection color.
--- a/layout/svg/nsSVGPathGeometryFrame.cpp
+++ b/layout/svg/nsSVGPathGeometryFrame.cpp
@@ -655,22 +655,22 @@ nsSVGPathGeometryFrame::Render(nsRenderi
     // We used to call gfx->Restore() here, since for the
     // SVGAutoRenderState::CLIP case it is important to leave the fill rule
     // that we set below untouched so that the value is still set when return
     // to gfxContext::Clip() further up the call stack. Since we no longer
     // call gfx->Save() in the SVGAutoRenderState::CLIP case we don't need to
     // worry that autoSaveRestore will delay the Restore() call for the
     // CLIP_MASK case until we exit this function.
 
-    gfxContext::FillRule oldFillRull = gfx->CurrentFillRule();
+    FillRule oldFillRull = gfx->CurrentFillRule();
 
     if (StyleSVG()->mClipRule == NS_STYLE_FILL_RULE_EVENODD)
-      gfx->SetFillRule(gfxContext::FILL_RULE_EVEN_ODD);
+      gfx->SetFillRule(FillRule::FILL_EVEN_ODD);
     else
-      gfx->SetFillRule(gfxContext::FILL_RULE_WINDING);
+      gfx->SetFillRule(FillRule::FILL_WINDING);
 
     if (renderMode == SVGAutoRenderState::CLIP_MASK) {
       gfx->SetColor(gfxRGBA(1.0f, 1.0f, 1.0f, 1.0f));
       gfx->Fill();
       gfx->SetFillRule(oldFillRull); // restore, but only for CLIP_MASK
       gfx->NewPath();
     }
 
@@ -684,17 +684,17 @@ nsSVGPathGeometryFrame::Render(nsRenderi
   gfxTextContextPaint *contextPaint =
     (gfxTextContextPaint*)aContext->GetDrawTarget()->GetUserData(&gfxTextContextPaint::sUserDataKey);
 
   if ((aRenderComponents & eRenderFill)) {
     nsRefPtr<gfxPattern> fillPattern =
       nsSVGUtils::MakeFillPatternFor(this, gfx, contextPaint);
     if (fillPattern) {
       gfx->SetPattern(fillPattern);
-      gfx->SetFillRule(nsSVGUtils::ThebesFillRule(StyleSVG()->mFillRule));
+      gfx->SetFillRule(nsSVGUtils::ToFillRule(StyleSVG()->mFillRule));
       gfx->Fill();
     }
   }
 
   if ((aRenderComponents & eRenderStroke) &&
       nsSVGUtils::HasStroke(this, contextPaint)) {
     nsRefPtr<gfxPattern> strokePattern =
       nsSVGUtils::MakeStrokePatternFor(this, gfx, contextPaint);
--- a/layout/svg/nsSVGUtils.h
+++ b/layout/svg/nsSVGUtils.h
@@ -200,16 +200,17 @@ NS_DEFINE_STATIC_IID_ACCESSOR(nsISVGFilt
  * General functions used by all of SVG layout and possibly content code.
  * If a method is used by content and depends only on other content methods
  * it should go in SVGContentUtils instead.
  */
 class nsSVGUtils
 {
 public:
   typedef mozilla::dom::Element Element;
+  typedef mozilla::gfx::FillRule FillRule;
 
   static void Init();
 
   /**
    * Gets the nearest nsSVGInnerSVGFrame or nsSVGOuterSVGFrame frame. aFrame
    * must be an SVG frame. If aFrame is of type nsGkAtoms::svgOuterSVGFrame,
    * returns nullptr.
    */
@@ -539,19 +540,19 @@ public:
   /**
    * This function returns a set of bit flags indicating which parts of the
    * element (fill, stroke, bounds) should intercept pointer events. It takes
    * into account the type of element and the value of the 'pointer-events'
    * property on the element.
    */
   static uint16_t GetGeometryHitTestFlags(nsIFrame* aFrame);
 
-  static gfxContext::FillRule ThebesFillRule(uint8_t aFillRule) {
+  static FillRule ToFillRule(uint8_t aFillRule) {
     return aFillRule == NS_STYLE_FILL_RULE_EVENODD ?
-             gfxContext::FILL_RULE_EVEN_ODD : gfxContext::FILL_RULE_WINDING;
+             FillRule::FILL_EVEN_ODD : FillRule::FILL_WINDING;
   }
 
   /**
    * Render a SVG glyph.
    * @param aElement the SVG glyph element to render
    * @param aContext the thebes aContext to draw to
    * @param aDrawMode fill or stroke or both (see DrawMode)
    * @return true if rendering succeeded