diff --git a/include/core/SkPathEffect.h b/include/core/SkPathEffect.h index 736ea9895d..f9495cdc73 100644 --- a/include/core/SkPathEffect.h +++ b/include/core/SkPathEffect.h @@ -48,13 +48,14 @@ public: * 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 @@ public: 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 @@ public: 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 6624b4be13..0ceadc1bb9 100644 --- a/include/effects/Sk1DPathEffect.h +++ b/include/effects/Sk1DPathEffect.h @@ -16,19 +16,20 @@ class SkPathMeasure; // 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 @@ public: */ 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 @@ protected: 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 feb0da605c..3f774ae7b9 100644 --- a/include/effects/Sk2DPathEffect.h +++ b/include/effects/Sk2DPathEffect.h @@ -16,8 +16,8 @@ class SK_API Sk2DPathEffect : public SkPathEffect { 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 @@ protected: 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 @@ public: 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 @@ protected: 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 88afea3a83..ee89219f85 100644 --- a/include/effects/SkCornerPathEffect.h +++ b/include/effects/SkCornerPathEffect.h @@ -23,9 +23,8 @@ public: 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 5e8f14df80..cc9ad75321 100644 --- a/include/effects/SkDashPathEffect.h +++ b/include/effects/SkDashPathEffect.h @@ -36,17 +36,18 @@ public: 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 67057485ed..029ebfd35c 100644 --- a/include/effects/SkDiscretePathEffect.h +++ b/include/effects/SkDiscretePathEffect.h @@ -22,7 +22,8 @@ public: */ 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 a719608cad..f99a6a1c71 100644 --- a/samplecode/ClockFaceView.cpp +++ b/samplecode/ClockFaceView.cpp @@ -74,26 +74,26 @@ public: 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 @@ private: 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 ef6ef2847e..8cfde25804 100644 --- a/src/animator/SkDrawExtraPathEffect.cpp +++ b/src/animator/SkDrawExtraPathEffect.cpp @@ -94,8 +94,7 @@ public: 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 @@ protected: 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 8fbe5bfa87..ebbfd6dc51 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 @@ SkPairPathEffect::SkPairPathEffect(SkFlattenableReadBuffer& buffer) { /////////////////////////////////////////////////////////////////////////////// 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 SkComposePathEffect::filterPath(SkPath* dst, const SkPath& src, /////////////////////////////////////////////////////////////////////////////// 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 98345d0f09..3ef050cb88 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 @@ SkPath1DPathEffect::SkPath1DPathEffect(const SkPath& path, SkScalar advance, } 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 @@ SkPath1DPathEffect::SkPath1DPathEffect(SkFlattenableReadBuffer& buffer) { } } -SkScalar SkPath1DPathEffect::begin(SkScalar contourLength) { +SkScalar SkPath1DPathEffect::begin(SkScalar contourLength) const { return fInitialOffset; } @@ -174,7 +175,7 @@ void SkPath1DPathEffect::flatten(SkFlattenableWriteBuffer& buffer) const { } 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 e4d782173a..a4ebe7454f 100644 --- a/src/effects/Sk2DPathEffect.cpp +++ b/src/effects/Sk2DPathEffect.cpp @@ -16,7 +16,8 @@ Sk2DPathEffect::Sk2DPathEffect(const SkMatrix& mat) : fMatrix(mat) { 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 @@ bool Sk2DPathEffect::filterPath(SkPath* dst, const SkPath& src, SkStrokeRec*) { 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 @@ void Sk2DPathEffect::nextSpan(int x, int y, int count, SkPath* path) { } 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 @@ Sk2DPathEffect::Sk2DPathEffect(SkFlattenableReadBuffer& buffer) { /////////////////////////////////////////////////////////////////////////////// -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 @@ bool SkLine2DPathEffect::filterPath(SkPath *dst, const SkPath &src, SkStrokeRec 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 @@ void SkPath2DPathEffect::flatten(SkFlattenableWriteBuffer& buffer) const { 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 1ce62ecc03..b63045ddf9 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 @@ static bool ComputeStep(const SkPoint& a, const SkPoint& b, SkScalar radius, } 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 f2059775b0..58d746b3b9 100644 --- a/src/effects/SkDashPathEffect.cpp +++ b/src/effects/SkDashPathEffect.cpp @@ -156,7 +156,7 @@ private: }; 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 8a7c307965..a936be9a50 100644 --- a/src/effects/SkDiscretePathEffect.cpp +++ b/src/effects/SkDiscretePathEffect.cpp @@ -26,7 +26,7 @@ SkDiscretePathEffect::SkDiscretePathEffect(SkScalar segLength, SkScalar deviatio } bool SkDiscretePathEffect::filterPath(SkPath* dst, const SkPath& src, - SkStrokeRec* rec) { + SkStrokeRec* rec) const { bool doFill = rec->isFillStyle(); SkPathMeasure meas(src, doFill);