Bug 1208365 (part 3) - Change gfxPattern::mExtend from a GraphicsExtend to a gfx::ExtendMode. r=bas.
authorNicholas Nethercote <nnethercote@mozilla.com>
Fri, 25 Sep 2015 00:58:23 -0700
changeset 301401 85a6a4c077c8d304484c3316cc010664ea9fed2c
parent 301400 8389ef616e7ee5ca135715bd11b3de7978f4255d
child 301402 240ceb947a2beea0461a71fdf76bd54f0c24c694
push id1001
push userraliiev@mozilla.com
push dateMon, 18 Jan 2016 19:06:03 +0000
treeherdermozilla-release@8b89261f3ac4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbas
bugs1208365
milestone44.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 1208365 (part 3) - Change gfxPattern::mExtend from a GraphicsExtend to a gfx::ExtendMode. r=bas. At this point, the relationship between GraphicsExtend and gfx::ExtendMode is as follows. - EXTEND_REPEAT matches up with REPEAT. - EXTEND_REFLECT matches up with REFLECT. - EXTEND_PAD matches up with CLAMP. - EXTEND_NONE has no matching value in gfx::ExtendMode. The only use of EXTEND_NONE is with nsSVGGradientFrame::mExtend. That field gets assigned EXTEND_NONE in the various constructors, and other values via SetExtend(). And all uses of that field go immediately into ToExtend() calls, which convert EXTEND_NONE to CLAMP. So it's safe to change this field to gfx::ExtendMode and initialize it to CLAMP.
gfx/thebes/gfxPattern.cpp
gfx/thebes/gfxPattern.h
gfx/thebes/gfxWindowsNativeDrawing.cpp
layout/svg/nsSVGGradientFrame.cpp
layout/svg/nsSVGGradientFrame.h
layout/svg/nsSVGPatternFrame.cpp
--- a/gfx/thebes/gfxPattern.cpp
+++ b/gfx/thebes/gfxPattern.cpp
@@ -15,43 +15,43 @@
 
 #include "cairo.h"
 
 #include <vector>
 
 using namespace mozilla::gfx;
 
 gfxPattern::gfxPattern(const Color& aColor)
-  : mExtend(EXTEND_NONE)
+  : mExtend(ExtendMode::CLAMP)
 {
   mGfxPattern.InitColorPattern(ToDeviceColor(aColor));
 }
 
 // linear
 gfxPattern::gfxPattern(gfxFloat x0, gfxFloat y0, gfxFloat x1, gfxFloat y1)
-  : mExtend(EXTEND_NONE)
+  : mExtend(ExtendMode::CLAMP)
 {
   mGfxPattern.InitLinearGradientPattern(Point(x0, y0), Point(x1, y1), nullptr);
 }
 
 // radial
 gfxPattern::gfxPattern(gfxFloat cx0, gfxFloat cy0, gfxFloat radius0,
                        gfxFloat cx1, gfxFloat cy1, gfxFloat radius1)
-  : mExtend(EXTEND_NONE)
+  : mExtend(ExtendMode::CLAMP)
 {
   mGfxPattern.InitRadialGradientPattern(Point(cx0, cy0), Point(cx1, cy1),
                                         radius0, radius1, nullptr);
 }
 
 // Azure
 gfxPattern::gfxPattern(SourceSurface *aSurface, const Matrix &aPatternToUserSpace)
   : mPatternToUserSpace(aPatternToUserSpace)
-  , mExtend(EXTEND_NONE)
+  , mExtend(ExtendMode::CLAMP)
 {
-  mGfxPattern.InitSurfacePattern(aSurface, ToExtendMode(mExtend), Matrix(), // matrix is overridden in GetPattern()
+  mGfxPattern.InitSurfacePattern(aSurface, mExtend, Matrix(), // matrix is overridden in GetPattern()
                                  mozilla::gfx::Filter::GOOD);
 }
 
 void
 gfxPattern::AddColorStop(gfxFloat offset, const Color& c)
 {
   if (mGfxPattern.GetPattern()->GetType() != PatternType::LINEAR_GRADIENT &&
       mGfxPattern.GetPattern()->GetType() != PatternType::RADIAL_GRADIENT) {
@@ -70,18 +70,17 @@ void
 gfxPattern::SetColorStops(GradientStops* aStops)
 {
   mStops = aStops;
 }
 
 void
 gfxPattern::CacheColorStops(const DrawTarget *aDT)
 {
-  mStops = gfxGradientCache::GetOrCreateGradientStops(aDT, mStopsList,
-                                                      ToExtendMode(mExtend));
+  mStops = gfxGradientCache::GetOrCreateGradientStops(aDT, mStopsList, mExtend);
 }
 
 void
 gfxPattern::SetMatrix(const gfxMatrix& aPatternToUserSpace)
 {
   mPatternToUserSpace = ToMatrix(aPatternToUserSpace);
   // Cairo-pattern matrices specify the conversion from DrawTarget to pattern
   // space. Azure pattern matrices specify the conversion from pattern to
@@ -127,25 +126,24 @@ gfxPattern::GetPattern(const DrawTarget 
 
     patternToUser = patternToUser * *aOriginalUserToDevice * deviceToCurrentUser;
   }
   patternToUser.NudgeToIntegers();
 
   if (!mStops &&
       !mStopsList.IsEmpty()) {
     mStops = aTarget->CreateGradientStops(mStopsList.Elements(),
-                                          mStopsList.Length(),
-                                          ToExtendMode(mExtend));
+                                          mStopsList.Length(), mExtend);
   }
 
   switch (mGfxPattern.GetPattern()->GetType()) {
   case PatternType::SURFACE: {
     SurfacePattern* surfacePattern = static_cast<SurfacePattern*>(mGfxPattern.GetPattern());
     surfacePattern->mMatrix = patternToUser;
-    surfacePattern->mExtendMode = ToExtendMode(mExtend);
+    surfacePattern->mExtendMode = mExtend;
     break;
   }
   case PatternType::LINEAR_GRADIENT: {
     LinearGradientPattern* linearGradientPattern = static_cast<LinearGradientPattern*>(mGfxPattern.GetPattern());
     linearGradientPattern->mMatrix = patternToUser;
     linearGradientPattern->mStops = mStops;
     break;
   }
@@ -159,19 +157,19 @@ gfxPattern::GetPattern(const DrawTarget 
     /* Reassure the compiler we are handling all the enum values.  */
     break;
   }
 
   return mGfxPattern.GetPattern();
 }
 
 void
-gfxPattern::SetExtend(GraphicsExtend extend)
+gfxPattern::SetExtend(ExtendMode aExtend)
 {
-  mExtend = extend;
+  mExtend = aExtend;
   mStops = nullptr;
 }
 
 bool
 gfxPattern::IsOpaque()
 {
   if (mGfxPattern.GetPattern()->GetType() != PatternType::SURFACE) {
     return false;
--- a/gfx/thebes/gfxPattern.h
+++ b/gfx/thebes/gfxPattern.h
@@ -55,18 +55,18 @@ public:
 
     enum GraphicsExtend {
         EXTEND_NONE,
         EXTEND_REPEAT,
         EXTEND_REFLECT,
         EXTEND_PAD
     };
 
-    // none, repeat, reflect
-    void SetExtend(GraphicsExtend extend);
+    // clamp, repeat, reflect
+    void SetExtend(mozilla::gfx::ExtendMode aExtend);
 
     int CairoStatus();
 
     void SetFilter(GraphicsFilter filter);
     GraphicsFilter Filter() const;
 
     /* returns TRUE if it succeeded */
     bool GetSolidColor(mozilla::gfx::Color& aColorOut);
@@ -75,12 +75,12 @@ private:
     // Private destructor, to discourage deletion outside of Release():
     ~gfxPattern() {}
 
     mozilla::gfx::GeneralPattern mGfxPattern;
     mozilla::RefPtr<mozilla::gfx::SourceSurface> mSourceSurface;
     mozilla::gfx::Matrix mPatternToUserSpace;
     mozilla::RefPtr<mozilla::gfx::GradientStops> mStops;
     nsTArray<mozilla::gfx::GradientStop> mStopsList;
-    GraphicsExtend mExtend;
+    mozilla::gfx::ExtendMode mExtend;
 };
 
 #endif /* GFX_PATTERN_H */
--- a/gfx/thebes/gfxWindowsNativeDrawing.cpp
+++ b/gfx/thebes/gfxWindowsNativeDrawing.cpp
@@ -285,17 +285,17 @@ gfxWindowsNativeDrawing::PaintToContext(
 
         gfxMatrix m;
         m.Scale(mScale.width, mScale.height);
         pat->SetMatrix(m);
 
         if (mNativeDrawFlags & DO_NEAREST_NEIGHBOR_FILTERING)
             pat->SetFilter(GraphicsFilter::FILTER_FAST);
 
-        pat->SetExtend(gfxPattern::EXTEND_PAD);
+        pat->SetExtend(ExtendMode::CLAMP);
         mContext->SetPattern(pat);
         mContext->Fill();
         mContext->Restore();
 
         mRenderState = RENDER_STATE_DONE;
     } else {
         NS_ERROR("Invalid RenderState in gfxWindowsNativeDrawing::PaintToContext");
     }
--- a/layout/svg/nsSVGGradientFrame.cpp
+++ b/layout/svg/nsSVGGradientFrame.cpp
@@ -273,21 +273,21 @@ nsSVGGradientFrame::GetPaintServerPatter
   }
 
   nsRefPtr<gfxPattern> gradient = CreateGradient();
   if (!gradient || gradient->CairoStatus())
     return nullptr;
 
   uint16_t aSpread = GetSpreadMethod();
   if (aSpread == SVG_SPREADMETHOD_PAD)
-    gradient->SetExtend(gfxPattern::EXTEND_PAD);
+    gradient->SetExtend(ExtendMode::CLAMP);
   else if (aSpread == SVG_SPREADMETHOD_REFLECT)
-    gradient->SetExtend(gfxPattern::EXTEND_REFLECT);
+    gradient->SetExtend(ExtendMode::REFLECT);
   else if (aSpread == SVG_SPREADMETHOD_REPEAT)
-    gradient->SetExtend(gfxPattern::EXTEND_REPEAT);
+    gradient->SetExtend(ExtendMode::REPEAT);
 
   gradient->SetMatrix(patternMatrix);
 
   // setup stops
   float lastOffset = 0.0f;
 
   for (uint32_t i = 0; i < nStops; i++) {
     float offset, stopOpacity;
--- a/layout/svg/nsSVGGradientFrame.h
+++ b/layout/svg/nsSVGGradientFrame.h
@@ -34,16 +34,18 @@ class SVGRadialGradientElement;
 typedef nsSVGPaintServerFrame nsSVGGradientFrameBase;
 
 /**
  * Gradients can refer to other gradients. We create an nsSVGPaintingProperty
  * with property type nsGkAtoms::href to track the referenced gradient.
  */
 class nsSVGGradientFrame : public nsSVGGradientFrameBase
 {
+  typedef mozilla::gfx::ExtendMode ExtendMode;
+
 protected:
   explicit nsSVGGradientFrame(nsStyleContext* aContext);
 
 public:
   NS_DECL_FRAMEARENA_HELPERS
 
   // nsSVGPaintServerFrame methods:
   virtual already_AddRefed<gfxPattern>
--- a/layout/svg/nsSVGPatternFrame.cpp
+++ b/layout/svg/nsSVGPatternFrame.cpp
@@ -718,17 +718,17 @@ nsSVGPatternFrame::GetPaintServerPattern
     return nullptr;
   }
 
   nsRefPtr<gfxPattern> pattern = new gfxPattern(surface, pMatrix);
 
   if (!pattern || pattern->CairoStatus())
     return nullptr;
 
-  pattern->SetExtend(gfxPattern::EXTEND_REPEAT);
+  pattern->SetExtend(ExtendMode::REPEAT);
   return pattern.forget();
 }
 
 // -------------------------------------------------------------------------
 // Public functions
 // -------------------------------------------------------------------------
 
 nsIFrame* NS_NewSVGPatternFrame(nsIPresShell*   aPresShell,