change all patheffect methods to const, in preparation for marking its
subclasses as immutable/re-entrant safe.
Review URL: https://codereview.appspot.com/6949071

git-svn-id: http://skia.googlecode.com/svn/trunk@6877 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/include/core/SkPathEffect.h b/include/core/SkPathEffect.h
index 736ea98..f9495cd 100644
--- a/include/core/SkPathEffect.h
+++ b/include/core/SkPathEffect.h
@@ -48,13 +48,14 @@
      *  If this method returns true, the caller will apply (as needed) the
      *  resulting stroke-rec to dst and then draw.
      */
-    virtual bool filterPath(SkPath* dst, const SkPath& src, SkStrokeRec*) = 0;
+    virtual bool filterPath(SkPath* dst, const SkPath& src,
+                            SkStrokeRec*) const = 0;
 
     /**
      *  Compute a conservative bounds for its effect, given the src bounds.
      *  The baseline implementation just assigns src to dst.
      */
-    virtual void computeFastBounds(SkRect* dst, const SkRect& src);
+    virtual void computeFastBounds(SkRect* dst, const SkRect& src) const;
 
     /** \class PointData
 
@@ -152,7 +153,8 @@
     SkComposePathEffect(SkPathEffect* outer, SkPathEffect* inner)
         : INHERITED(outer, inner) {}
 
-    virtual bool filterPath(SkPath* dst, const SkPath& src, SkStrokeRec*) SK_OVERRIDE;
+    virtual bool filterPath(SkPath* dst, const SkPath& src,
+                            SkStrokeRec*) const SK_OVERRIDE;
 
     SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkComposePathEffect)
 
@@ -182,7 +184,8 @@
     SkSumPathEffect(SkPathEffect* first, SkPathEffect* second)
         : INHERITED(first, second) {}
 
-    virtual bool filterPath(SkPath* dst, const SkPath& src, SkStrokeRec*) SK_OVERRIDE;
+    virtual bool filterPath(SkPath* dst, const SkPath& src,
+                            SkStrokeRec*) const SK_OVERRIDE;
 
     SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkSumPathEffect)
 
diff --git a/include/effects/Sk1DPathEffect.h b/include/effects/Sk1DPathEffect.h
index 6624b4b..0ceadc1 100644
--- a/include/effects/Sk1DPathEffect.h
+++ b/include/effects/Sk1DPathEffect.h
@@ -16,19 +16,20 @@
 // This class is not exported to java.
 class SK_API Sk1DPathEffect : public SkPathEffect {
 public:
-    virtual bool filterPath(SkPath* dst, const SkPath& src, SkStrokeRec*) SK_OVERRIDE;
+    virtual bool filterPath(SkPath* dst, const SkPath& src,
+                            SkStrokeRec*) const SK_OVERRIDE;
 
 protected:
     /** Called at the start of each contour, returns the initial offset
         into that contour.
     */
-    virtual SkScalar begin(SkScalar contourLength) = 0;
+    virtual SkScalar begin(SkScalar contourLength) const = 0;
     /** Called with the current distance along the path, with the current matrix
         for the point/tangent at the specified distance.
         Return the distance to travel for the next call. If return <= 0, then that
         contour is done.
     */
-    virtual SkScalar next(SkPath* dst, SkScalar distance, SkPathMeasure&) = 0;
+    virtual SkScalar next(SkPath* dst, SkScalar dist, SkPathMeasure&) const = 0;
 
 private:
     typedef SkPathEffect INHERITED;
@@ -53,7 +54,8 @@
     */
     SkPath1DPathEffect(const SkPath& path, SkScalar advance, SkScalar phase, Style);
 
-    virtual bool filterPath(SkPath*, const SkPath&, SkStrokeRec*) SK_OVERRIDE;
+    virtual bool filterPath(SkPath*, const SkPath&,
+                            SkStrokeRec*) const SK_OVERRIDE;
 
     SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkPath1DPathEffect)
 
@@ -62,8 +64,8 @@
     virtual void flatten(SkFlattenableWriteBuffer&) const SK_OVERRIDE;
 
     // overrides from Sk1DPathEffect
-    virtual SkScalar begin(SkScalar contourLength) SK_OVERRIDE;
-    virtual SkScalar next(SkPath*, SkScalar distance, SkPathMeasure&) SK_OVERRIDE;
+    virtual SkScalar begin(SkScalar contourLength) const SK_OVERRIDE;
+    virtual SkScalar next(SkPath*, SkScalar, SkPathMeasure&) const SK_OVERRIDE;
 
 private:
     SkPath      fPath;          // copied from constructor
diff --git a/include/effects/Sk2DPathEffect.h b/include/effects/Sk2DPathEffect.h
index feb0da6..3f774ae 100644
--- a/include/effects/Sk2DPathEffect.h
+++ b/include/effects/Sk2DPathEffect.h
@@ -16,8 +16,8 @@
 public:
     Sk2DPathEffect(const SkMatrix& mat);
 
-    // overrides
-    virtual bool filterPath(SkPath*, const SkPath&, SkStrokeRec*) SK_OVERRIDE;
+    virtual bool filterPath(SkPath*, const SkPath&,
+                            SkStrokeRec*) const SK_OVERRIDE;
 
     SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(Sk2DPathEffect)
 
@@ -28,15 +28,15 @@
         next() will receive u and v values within these bounds,
         and then a call to end() will signal the end of processing.
     */
-    virtual void begin(const SkIRect& uvBounds, SkPath* dst);
-    virtual void next(const SkPoint& loc, int u, int v, SkPath* dst);
-    virtual void end(SkPath* dst);
+    virtual void begin(const SkIRect& uvBounds, SkPath* dst) const;
+    virtual void next(const SkPoint& loc, int u, int v, SkPath* dst) const;
+    virtual void end(SkPath* dst) const;
 
     /** Low-level virtual called per span of locations in the u-direction.
         The default implementation calls next() repeatedly with each
         location.
     */
-    virtual void nextSpan(int u, int v, int ucount, SkPath* dst);
+    virtual void nextSpan(int u, int v, int ucount, SkPath* dst) const;
 
     const SkMatrix& getMatrix() const { return fMatrix; }
 
@@ -61,12 +61,13 @@
     SkLine2DPathEffect(SkScalar width, const SkMatrix& matrix)
     : Sk2DPathEffect(matrix), fWidth(width) {}
 
-    virtual bool filterPath(SkPath* dst, const SkPath& src, SkStrokeRec* rec) SK_OVERRIDE;
+    virtual bool filterPath(SkPath* dst, const SkPath& src,
+                            SkStrokeRec*) const SK_OVERRIDE;
 
     SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkLine2DPathEffect)
 
 protected:
-    virtual void nextSpan(int u, int v, int ucount, SkPath* dst) SK_OVERRIDE;
+    virtual void nextSpan(int u, int v, int ucount, SkPath*) const SK_OVERRIDE;
 
     SkLine2DPathEffect(SkFlattenableReadBuffer&);
 
@@ -92,7 +93,7 @@
     SkPath2DPathEffect(SkFlattenableReadBuffer& buffer);
     virtual void flatten(SkFlattenableWriteBuffer&) const SK_OVERRIDE;
 
-    virtual void next(const SkPoint&, int u, int v, SkPath* dst) SK_OVERRIDE;
+    virtual void next(const SkPoint&, int u, int v, SkPath*) const SK_OVERRIDE;
 
 private:
     SkPath  fPath;
diff --git a/include/effects/SkCornerPathEffect.h b/include/effects/SkCornerPathEffect.h
index 88afea3..ee89219 100644
--- a/include/effects/SkCornerPathEffect.h
+++ b/include/effects/SkCornerPathEffect.h
@@ -23,9 +23,8 @@
     SkCornerPathEffect(SkScalar radius);
     virtual ~SkCornerPathEffect();
 
-    // overrides for SkPathEffect
-    //  This method is not exported to java.
-    virtual bool filterPath(SkPath* dst, const SkPath& src, SkStrokeRec*) SK_OVERRIDE;
+    virtual bool filterPath(SkPath* dst, const SkPath& src,
+                            SkStrokeRec*) const SK_OVERRIDE;
 
     SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkCornerPathEffect)
 
diff --git a/include/effects/SkDashPathEffect.h b/include/effects/SkDashPathEffect.h
index 5e8f14d..cc9ad75 100644
--- a/include/effects/SkDashPathEffect.h
+++ b/include/effects/SkDashPathEffect.h
@@ -36,17 +36,18 @@
 
         Note: only affects stroked paths.
     */
-    SkDashPathEffect(const SkScalar intervals[], int count, SkScalar phase, bool scaleToFit = false);
+    SkDashPathEffect(const SkScalar intervals[], int count, SkScalar phase,
+                     bool scaleToFit = false);
     virtual ~SkDashPathEffect();
 
-    virtual bool filterPath(SkPath* dst, const SkPath& src, SkStrokeRec*) SK_OVERRIDE;
+    virtual bool filterPath(SkPath* dst, const SkPath& src,
+                            SkStrokeRec*) const SK_OVERRIDE;
 
     virtual bool asPoints(PointData* results, const SkPath& src,
                           const SkStrokeRec&, const SkMatrix&) const SK_OVERRIDE;
 
-    // overrides for SkFlattenable
-    //  This method is not exported to java.
-    virtual Factory getFactory();
+    virtual Factory getFactory() SK_OVERRIDE;
+
     static SkFlattenable* CreateProc(SkFlattenableReadBuffer&);
 
 protected:
diff --git a/include/effects/SkDiscretePathEffect.h b/include/effects/SkDiscretePathEffect.h
index 6705748..029ebfd 100644
--- a/include/effects/SkDiscretePathEffect.h
+++ b/include/effects/SkDiscretePathEffect.h
@@ -22,7 +22,8 @@
     */
     SkDiscretePathEffect(SkScalar segLength, SkScalar deviation);
 
-    virtual bool filterPath(SkPath* dst, const SkPath& src, SkStrokeRec*) SK_OVERRIDE;
+    virtual bool filterPath(SkPath* dst, const SkPath& src,
+                            SkStrokeRec*) const SK_OVERRIDE;
 
     SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkDiscretePathEffect)
 
diff --git a/samplecode/ClockFaceView.cpp b/samplecode/ClockFaceView.cpp
index a719608..f99a6a1 100644
--- a/samplecode/ClockFaceView.cpp
+++ b/samplecode/ClockFaceView.cpp
@@ -74,26 +74,26 @@
     SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(Dot2DPathEffect)
 
 protected:
-    virtual void begin(const SkIRect& uvBounds, SkPath* dst) {
+    virtual void begin(const SkIRect& uvBounds, SkPath* dst) const SK_OVERRIDE {
         if (fPts) {
             fPts->reset();
         }
         this->INHERITED::begin(uvBounds, dst);
     }
-//    virtual void end(SkPath* dst) {}
-    virtual void next(const SkPoint& loc, int u, int v, SkPath* dst)
-    {
+
+    virtual void next(const SkPoint& loc, int u, int v,
+                      SkPath* dst) const SK_OVERRIDE {
         if (fPts) {
             *fPts->append() = loc;
         }
         dst->addCircle(loc.fX, loc.fY, fRadius);
     }
 
-    Dot2DPathEffect(SkFlattenableReadBuffer& buffer) : INHERITED(buffer)
-    {
+    Dot2DPathEffect(SkFlattenableReadBuffer& buffer) : INHERITED(buffer) {
         fRadius = buffer.readScalar();
         fPts = NULL;
     }
+
     virtual void flatten(SkFlattenableWriteBuffer& buffer) const SK_OVERRIDE {
         this->INHERITED::flatten(buffer);
         buffer.writeScalar(fRadius);
@@ -109,7 +109,8 @@
 class InverseFillPE : public SkPathEffect {
 public:
     InverseFillPE() {}
-    virtual bool filterPath(SkPath* dst, const SkPath& src, SkStrokeRec*) SK_OVERRIDE {
+    virtual bool filterPath(SkPath* dst, const SkPath& src,
+                            SkStrokeRec*) const SK_OVERRIDE {
         *dst = src;
         dst->setFillType(SkPath::kInverseWinding_FillType);
         return true;
diff --git a/src/animator/SkDrawExtraPathEffect.cpp b/src/animator/SkDrawExtraPathEffect.cpp
index ef6ef28..8cfde25 100644
--- a/src/animator/SkDrawExtraPathEffect.cpp
+++ b/src/animator/SkDrawExtraPathEffect.cpp
@@ -94,8 +94,7 @@
     SK_DECLARE_UNFLATTENABLE_OBJECT()
 
 protected:
-    virtual SkScalar begin(SkScalar contourLength)
-    {
+    virtual SkScalar begin(SkScalar contourLength) const {
         SkScriptValue value;
         SkAnimatorScript engine(*fMaker, NULL, SkType_Float);
         engine.propertyCallBack(GetContourLength, &contourLength);
@@ -104,8 +103,7 @@
         return value.fOperand.fScalar;
     }
 
-    virtual SkScalar next(SkPath* dst, SkScalar distance, SkPathMeasure& )
-    {
+    virtual SkScalar next(SkPath* dst, SkScalar distance, SkPathMeasure&) const {
         fMaker->setExtraPropertyCallBack(fDraw->fType, GetDistance, &distance);
         SkDrawPath* drawPath = NULL;
         if (fDraw->addPath->isPath()) {
diff --git a/src/core/SkPathEffect.cpp b/src/core/SkPathEffect.cpp
index 8fbe5bf..ebbfd6d 100644
--- a/src/core/SkPathEffect.cpp
+++ b/src/core/SkPathEffect.cpp
@@ -14,7 +14,7 @@
 
 SK_DEFINE_INST_COUNT(SkPathEffect)
 
-void SkPathEffect::computeFastBounds(SkRect* dst, const SkRect& src) {
+void SkPathEffect::computeFastBounds(SkRect* dst, const SkRect& src) const {
     *dst = src;
 }
 
@@ -56,7 +56,7 @@
 ///////////////////////////////////////////////////////////////////////////////
 
 bool SkComposePathEffect::filterPath(SkPath* dst, const SkPath& src,
-                                     SkStrokeRec* rec) {
+                                     SkStrokeRec* rec) const {
     // we may have failed to unflatten these, so we have to check
     if (!fPE0 || !fPE1) {
         return false;
@@ -74,7 +74,7 @@
 ///////////////////////////////////////////////////////////////////////////////
 
 bool SkSumPathEffect::filterPath(SkPath* dst, const SkPath& src,
-                                 SkStrokeRec* rec) {
+                                 SkStrokeRec* rec) const {
     // use bit-or so that we always call both, even if the first one succeeds
     return fPE0->filterPath(dst, src, rec) | fPE1->filterPath(dst, src, rec);
 }
diff --git a/src/effects/Sk1DPathEffect.cpp b/src/effects/Sk1DPathEffect.cpp
index 98345d0..3ef050c 100644
--- a/src/effects/Sk1DPathEffect.cpp
+++ b/src/effects/Sk1DPathEffect.cpp
@@ -11,7 +11,8 @@
 #include "SkFlattenableBuffers.h"
 #include "SkPathMeasure.h"
 
-bool Sk1DPathEffect::filterPath(SkPath* dst, const SkPath& src, SkStrokeRec*) {
+bool Sk1DPathEffect::filterPath(SkPath* dst, const SkPath& src,
+                                SkStrokeRec*) const {
     SkPathMeasure   meas(src, false);
     do {
         SkScalar    length = meas.getLength();
@@ -68,7 +69,7 @@
 }
 
 bool SkPath1DPathEffect::filterPath(SkPath* dst, const SkPath& src,
-                                    SkStrokeRec* rec) {
+                                    SkStrokeRec* rec) const {
     if (fAdvance > 0) {
         rec->setFillStyle();
         return this->INHERITED::filterPath(dst, src, rec);
@@ -159,7 +160,7 @@
     }
 }
 
-SkScalar SkPath1DPathEffect::begin(SkScalar contourLength) {
+SkScalar SkPath1DPathEffect::begin(SkScalar contourLength) const {
     return fInitialOffset;
 }
 
@@ -174,7 +175,7 @@
 }
 
 SkScalar SkPath1DPathEffect::next(SkPath* dst, SkScalar distance,
-                                  SkPathMeasure& meas) {
+                                  SkPathMeasure& meas) const {
     switch (fStyle) {
         case kTranslate_Style: {
             SkPoint pos;
diff --git a/src/effects/Sk2DPathEffect.cpp b/src/effects/Sk2DPathEffect.cpp
index e4d7821..a4ebe74 100644
--- a/src/effects/Sk2DPathEffect.cpp
+++ b/src/effects/Sk2DPathEffect.cpp
@@ -16,7 +16,8 @@
     fMatrixIsInvertible = mat.invert(&fInverse);
 }
 
-bool Sk2DPathEffect::filterPath(SkPath* dst, const SkPath& src, SkStrokeRec*) {
+bool Sk2DPathEffect::filterPath(SkPath* dst, const SkPath& src,
+                                SkStrokeRec*) const {
     if (!fMatrixIsInvertible) {
         return false;
     }
@@ -44,7 +45,7 @@
     return true;
 }
 
-void Sk2DPathEffect::nextSpan(int x, int y, int count, SkPath* path) {
+void Sk2DPathEffect::nextSpan(int x, int y, int count, SkPath* path) const {
     if (!fMatrixIsInvertible) {
         return;
     }
@@ -60,9 +61,9 @@
     } while (--count > 0);
 }
 
-void Sk2DPathEffect::begin(const SkIRect& uvBounds, SkPath* dst) {}
-void Sk2DPathEffect::next(const SkPoint& loc, int u, int v, SkPath* dst) {}
-void Sk2DPathEffect::end(SkPath* dst) {}
+void Sk2DPathEffect::begin(const SkIRect& uvBounds, SkPath* dst) const {}
+void Sk2DPathEffect::next(const SkPoint& loc, int u, int v, SkPath* dst) const {}
+void Sk2DPathEffect::end(SkPath* dst) const {}
 
 ///////////////////////////////////////////////////////////////////////////////
 
@@ -78,7 +79,8 @@
 
 ///////////////////////////////////////////////////////////////////////////////
 
-bool SkLine2DPathEffect::filterPath(SkPath *dst, const SkPath &src, SkStrokeRec *rec) {
+bool SkLine2DPathEffect::filterPath(SkPath* dst, const SkPath& src,
+                                    SkStrokeRec* rec) const {
     if (this->INHERITED::filterPath(dst, src, rec)) {
         rec->setStrokeStyle(fWidth);
         return true;
@@ -86,7 +88,7 @@
     return false;
 }
 
-void SkLine2DPathEffect::nextSpan(int u, int v, int ucount, SkPath *dst) {
+void SkLine2DPathEffect::nextSpan(int u, int v, int ucount, SkPath* dst) const {
     if (ucount > 1) {
         SkPoint    src[2], dstP[2];
 
@@ -124,6 +126,7 @@
     buffer.writePath(fPath);
 }
 
-void SkPath2DPathEffect::next(const SkPoint& loc, int u, int v, SkPath* dst) {
+void SkPath2DPathEffect::next(const SkPoint& loc, int u, int v,
+                              SkPath* dst) const {
     dst->addPath(fPath, loc.fX, loc.fY);
 }
diff --git a/src/effects/SkCornerPathEffect.cpp b/src/effects/SkCornerPathEffect.cpp
index 1ce62ec..b63045d 100644
--- a/src/effects/SkCornerPathEffect.cpp
+++ b/src/effects/SkCornerPathEffect.cpp
@@ -12,13 +12,8 @@
 #include "SkPoint.h"
 #include "SkFlattenableBuffers.h"
 
-SkCornerPathEffect::SkCornerPathEffect(SkScalar radius) : fRadius(radius)
-{
-}
-
-SkCornerPathEffect::~SkCornerPathEffect()
-{
-}
+SkCornerPathEffect::SkCornerPathEffect(SkScalar radius) : fRadius(radius) {}
+SkCornerPathEffect::~SkCornerPathEffect() {}
 
 static bool ComputeStep(const SkPoint& a, const SkPoint& b, SkScalar radius,
                         SkPoint* step) {
@@ -36,8 +31,8 @@
 }
 
 bool SkCornerPathEffect::filterPath(SkPath* dst, const SkPath& src,
-                                    SkStrokeRec*) {
-    if (fRadius == 0) {
+                                    SkStrokeRec*) const {
+    if (0 == fRadius) {
         return false;
     }
 
diff --git a/src/effects/SkDashPathEffect.cpp b/src/effects/SkDashPathEffect.cpp
index f205977..58d746b 100644
--- a/src/effects/SkDashPathEffect.cpp
+++ b/src/effects/SkDashPathEffect.cpp
@@ -156,7 +156,7 @@
 };
 
 bool SkDashPathEffect::filterPath(SkPath* dst, const SkPath& src,
-                                  SkStrokeRec* rec) {
+                                  SkStrokeRec* rec) const {
     // we do nothing if the src wants to be filled, or if our dashlength is 0
     if (rec->isFillStyle() || fInitialDashLength < 0) {
         return false;
diff --git a/src/effects/SkDiscretePathEffect.cpp b/src/effects/SkDiscretePathEffect.cpp
index 8a7c307..a936be9 100644
--- a/src/effects/SkDiscretePathEffect.cpp
+++ b/src/effects/SkDiscretePathEffect.cpp
@@ -26,7 +26,7 @@
 }
 
 bool SkDiscretePathEffect::filterPath(SkPath* dst, const SkPath& src,
-                                      SkStrokeRec* rec) {
+                                      SkStrokeRec* rec) const {
     bool doFill = rec->isFillStyle();
 
     SkPathMeasure   meas(src, doFill);