Add patheffects to debugger printout
authorrobertphillips <robertphillips@google.com>
Mon, 26 Jan 2015 14:08:52 +0000 (06:08 -0800)
committerCommit bot <commit-bot@chromium.org>
Mon, 26 Jan 2015 14:08:52 +0000 (06:08 -0800)
TBR=bsalomon@google.com

Review URL: https://codereview.chromium.org/872043002

19 files changed:
gm/dcshader.cpp
include/core/SkPathEffect.h
include/core/SkShader.h
include/effects/Sk1DPathEffect.h
include/effects/Sk2DPathEffect.h
include/effects/SkArcToPathEffect.h
include/effects/SkCornerPathEffect.h
include/effects/SkDashPathEffect.h
include/effects/SkDiscretePathEffect.h
samplecode/ClockFaceView.cpp
src/animator/SkDrawExtraPathEffect.cpp
src/core/SkPaint.cpp
src/core/SkPathEffect.cpp
src/effects/Sk1DPathEffect.cpp
src/effects/Sk2DPathEffect.cpp
src/effects/SkArcToPathEffect.cpp
src/effects/SkCornerPathEffect.cpp
src/effects/SkDashPathEffect.cpp
src/effects/SkDiscretePathEffect.cpp

index c08923f4c38780f0121c581e5659fdd53b0302e0..1f5969bd3c6eefee456ea3d09bd565e076d9b25e 100644 (file)
@@ -36,6 +36,13 @@ public:
     bool asFragmentProcessor(GrContext*, const SkPaint& paint, const SkMatrix& viewM,
                              const SkMatrix* localMatrix, GrColor* color,
                              GrFragmentProcessor** fp) const SK_OVERRIDE;
+
+#ifndef SK_IGNORE_TO_STRING
+    void toString(SkString* str) const SK_OVERRIDE {
+        str->appendf("DCShader: ()");
+    }
+#endif
+
 private:
     const SkMatrix fDeviceMatrix;
 };
index 0675e97058b2f99b1056e557d8514a0955d5ff91..c4d41839811da787f77bcab3ba8466f74681685d 100644 (file)
@@ -131,6 +131,7 @@ public:
 
     virtual DashType asADash(DashInfo* info) const;
 
+    SK_TO_STRING_PUREVIRT()
     SK_DEFINE_FLATTENABLE_TYPE(SkPathEffect)
 
 protected:
@@ -162,6 +163,8 @@ protected:
     // these are visible to our subclasses
     SkPathEffect* fPE0, *fPE1;
 
+    SK_TO_STRING_OVERRIDE()    
+
 private:
     typedef SkPathEffect INHERITED;
 };
@@ -185,11 +188,11 @@ public:
     virtual bool filterPath(SkPath* dst, const SkPath& src,
                             SkStrokeRec*, const SkRect*) const SK_OVERRIDE;
 
+    SK_TO_STRING_OVERRIDE()    
     SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkComposePathEffect)
 
 protected:
-    SkComposePathEffect(SkPathEffect* outer, SkPathEffect* inner)
-        : INHERITED(outer, inner) {}
+    SkComposePathEffect(SkPathEffect* outer, SkPathEffect* inner) : INHERITED(outer, inner) {}
 
 private:
     // illegal
@@ -218,11 +221,11 @@ public:
     virtual bool filterPath(SkPath* dst, const SkPath& src,
                             SkStrokeRec*, const SkRect*) const SK_OVERRIDE;
 
+    SK_TO_STRING_OVERRIDE()    
     SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkSumPathEffect)
 
 protected:
-    SkSumPathEffect(SkPathEffect* first, SkPathEffect* second)
-        : INHERITED(first, second) {}
+    SkSumPathEffect(SkPathEffect* first, SkPathEffect* second) : INHERITED(first, second) {}
 
 private:
     // illegal
index 1ae531e2e5d95294af98735a229a0e31fdfc9dc0..10f4afad0b3df3ffa6010d82db50cbbf2063fa0a 100644 (file)
@@ -480,7 +480,7 @@ public:
 
     void preroll() const { this->onPreroll(); }
 
-    SK_TO_STRING_VIRT()
+    SK_TO_STRING_PUREVIRT()
     SK_DEFINE_FLATTENABLE_TYPE(SkShader)
 
 protected:
index 7a0ca2ec63bdae35196b00ab982fe4bf3d91038d..77f8ccc7cd7a53c1f5b4fb0632e377c82ffe2a5b 100644 (file)
@@ -60,6 +60,7 @@ public:
     virtual bool filterPath(SkPath*, const SkPath&,
                             SkStrokeRec*, const SkRect*) const SK_OVERRIDE;
 
+    SK_TO_STRING_OVERRIDE()
     SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkPath1DPathEffect)
 
 protected:
index bd905e1ba60e6379162655e34ec2fc8aad3433b8..7971ef431c719bfe15bdad8695d33a17305a149d 100644 (file)
@@ -39,6 +39,8 @@ protected:
     explicit Sk2DPathEffect(const SkMatrix& mat);
     void flatten(SkWriteBuffer&) const SK_OVERRIDE;
 
+    SK_TO_STRING_OVERRIDE()
+
 private:
     SkMatrix    fMatrix, fInverse;
     bool        fMatrixIsInvertible;
@@ -60,6 +62,7 @@ public:
     virtual bool filterPath(SkPath* dst, const SkPath& src,
                             SkStrokeRec*, const SkRect*) const SK_OVERRIDE;
 
+    SK_TO_STRING_OVERRIDE()
     SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkLine2DPathEffect)
 
 protected:
@@ -85,6 +88,7 @@ public:
         return SkNEW_ARGS(SkPath2DPathEffect, (matrix, path));
     }
 
+    SK_TO_STRING_OVERRIDE()
     SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkPath2DPathEffect)
 
 protected:
index ca8819c59f2052c79df43ae2b93a7b108aa3d234..7a96cd72ce2a7a4f5c0bfd68fae7058a750dc5ff 100644 (file)
@@ -24,6 +24,7 @@ public:
 
     bool filterPath(SkPath* dst, const SkPath& src, SkStrokeRec*, const SkRect*) const SK_OVERRIDE;
 
+    SK_TO_STRING_OVERRIDE()
     SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkArcToPathEffect)
 
 protected:
index c90aaec16bd14c75402fe845b7ccc5d3974c05ad..7223129c07ded3ba4d0ff822997f36f545eee625 100644 (file)
@@ -28,6 +28,7 @@ public:
     virtual bool filterPath(SkPath* dst, const SkPath& src,
                             SkStrokeRec*, const SkRect*) const SK_OVERRIDE;
 
+    SK_TO_STRING_OVERRIDE()
     SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkCornerPathEffect)
 
 protected:
index ee9c553b6c19a3c525c2a7c4bce6aadb20185af5..923777a8bb8b21719b4b7d42b6f2e56daf626363 100644 (file)
@@ -51,6 +51,7 @@ public:
 
     DashType asADash(DashInfo* info) const SK_OVERRIDE;
 
+    SK_TO_STRING_OVERRIDE()
     SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkDashPathEffect)
 
 protected:
index bbb09a80df55e45b05742ac0b47ba8d1efec3e1f..136d452ae7a24f6f941dadd2f6116e2983b1f2b9 100644 (file)
@@ -39,6 +39,7 @@ public:
     virtual bool filterPath(SkPath* dst, const SkPath& src,
                             SkStrokeRec*, const SkRect*) const SK_OVERRIDE;
 
+    SK_TO_STRING_OVERRIDE()
     SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkDiscretePathEffect)
 
 protected:
index 1e21bad753c9a0f521584e9bc9f5ca5871061aa1..12f16e092a7f63cb2871bccbd7a1f820d70e8274 100644 (file)
@@ -117,6 +117,13 @@ public:
         dst->setFillType(SkPath::kInverseWinding_FillType);
         return true;
     }
+
+#ifndef SK_IGNORE_TO_STRING
+    void toString(SkString* str) const SK_OVERRIDE {
+        str->appendf("InverseFillPE: ()");
+    }
+#endif
+
     SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(InverseFillPE)
 
 private:
index 0e4582b6ea957dea7ebd8cb28f53adfb349b7ef3..b13429e07fa2dc5e1d5466933ed7a51469cc7bf4 100644 (file)
@@ -139,6 +139,14 @@ protected:
         return result;
     }
 
+#ifndef SK_IGNORE_TO_STRING
+    void toString(SkString* str) const SK_OVERRIDE {
+        str->appendf("SkShape1DPathEffect: (");
+        // TODO: fill in
+        str->appendf(")");
+    }
+#endif
+
 private:
     static bool GetContourLength(const char* token, size_t len, void* clen, SkScriptValue* value) {
         if (SK_LITERAL_STR_EQUAL("contourLength", token, len)) {
index dd9611e9c6fcb3741a2ab839136d6662e047b3b6..7c6c8e0109d8f71778f218aec053cf3a16fa9540 100644 (file)
@@ -2113,6 +2113,7 @@ void SkPaint::toString(SkString* str) const {
     SkPathEffect* pathEffect = this->getPathEffect();
     if (pathEffect) {
         str->append("<dt>PathEffect:</dt><dd>");
+        pathEffect->toString(str);
         str->append("</dd>");
     }
 
index 7338789de2e873cb8d0461b58ae8729a8204280e..2403ffcb30c5f99511ebed3c6d7cf9b589231027 100644 (file)
@@ -49,6 +49,19 @@ void SkPairPathEffect::flatten(SkWriteBuffer& buffer) const {
     buffer.writeFlattenable(fPE1);
 }
 
+#ifndef SK_IGNORE_TO_STRING
+void SkPairPathEffect::toString(SkString* str) const {
+    str->appendf("first: ");
+    if (fPE0) {
+        fPE0->toString(str);
+    }
+    str->appendf(" second: ");
+    if (fPE1) {
+        fPE1->toString(str);
+    }
+}
+#endif
+
 ///////////////////////////////////////////////////////////////////////////////
 
 SkFlattenable* SkComposePathEffect::CreateProc(SkReadBuffer& buffer) {
@@ -73,6 +86,15 @@ bool SkComposePathEffect::filterPath(SkPath* dst, const SkPath& src,
     return fPE0->filterPath(dst, *ptr, rec, cullRect);
 }
 
+
+#ifndef SK_IGNORE_TO_STRING
+void SkComposePathEffect::toString(SkString* str) const {
+    str->appendf("SkComposePathEffect: (");
+    this->INHERITED::toString(str);
+    str->appendf(")");
+}
+#endif
+
 ///////////////////////////////////////////////////////////////////////////////
 
 SkFlattenable* SkSumPathEffect::CreateProc(SkReadBuffer& buffer) {
@@ -87,3 +109,12 @@ bool SkSumPathEffect::filterPath(SkPath* dst, const SkPath& src,
     return fPE0->filterPath(dst, src, rec, cullRect) |
            fPE1->filterPath(dst, src, rec, cullRect);
 }
+
+
+#ifndef SK_IGNORE_TO_STRING
+void SkSumPathEffect::toString(SkString* str) const {
+    str->appendf("SkSumPathEffect: (");
+    this->INHERITED::toString(str);
+    str->appendf(")");
+}
+#endif
index 83f684e2ca2bc29b901d1434a2062e37bc16f5ca..3af9887f9c66045b037a7a0da22807955236ae0b 100644 (file)
@@ -196,3 +196,13 @@ SkScalar SkPath1DPathEffect::next(SkPath* dst, SkScalar distance,
     }
     return fAdvance;
 }
+
+
+#ifndef SK_IGNORE_TO_STRING
+void SkPath1DPathEffect::toString(SkString* str) const {
+    str->appendf("SkPath1DPathEffect: (");
+    // TODO: add path and style
+    str->appendf("advance: %.2f phase %.2f", fAdvance, fInitialOffset);
+    str->appendf(")");
+}
+#endif
index 2ad202ae85d772acb875e1c9e579b6ebe26a8f18..1df69a51fc4b95fda7cb8d5e3c382524e6eee675 100644 (file)
@@ -73,6 +73,15 @@ void Sk2DPathEffect::flatten(SkWriteBuffer& buffer) const {
     buffer.writeMatrix(fMatrix);
 }
 
+#ifndef SK_IGNORE_TO_STRING
+void Sk2DPathEffect::toString(SkString* str) const {
+    str->appendf("(matrix: %.2f %.2f %.2f %.2f %.2f %.2f %.2f %.2f %.2f)",
+            fMatrix[SkMatrix::kMScaleX], fMatrix[SkMatrix::kMSkewX],  fMatrix[SkMatrix::kMTransX],
+            fMatrix[SkMatrix::kMSkewY],  fMatrix[SkMatrix::kMScaleY], fMatrix[SkMatrix::kMTransY],
+            fMatrix[SkMatrix::kMPersp0], fMatrix[SkMatrix::kMPersp1], fMatrix[SkMatrix::kMPersp2]);
+}
+#endif
+
 ///////////////////////////////////////////////////////////////////////////////
 
 bool SkLine2DPathEffect::filterPath(SkPath* dst, const SkPath& src,
@@ -109,6 +118,16 @@ void SkLine2DPathEffect::flatten(SkWriteBuffer &buffer) const {
     buffer.writeScalar(fWidth);
 }
 
+
+#ifndef SK_IGNORE_TO_STRING
+void SkLine2DPathEffect::toString(SkString* str) const {
+    str->appendf("SkLine2DPathEffect: (");
+    this->INHERITED::toString(str);
+    str->appendf("width: %f", fWidth);
+    str->appendf(")");
+}
+#endif
+
 ///////////////////////////////////////////////////////////////////////////////
 
 SkPath2DPathEffect::SkPath2DPathEffect(const SkMatrix& m, const SkPath& p)
@@ -132,3 +151,12 @@ void SkPath2DPathEffect::next(const SkPoint& loc, int u, int v,
                               SkPath* dst) const {
     dst->addPath(fPath, loc.fX, loc.fY);
 }
+
+#ifndef SK_IGNORE_TO_STRING
+void SkPath2DPathEffect::toString(SkString* str) const {
+    str->appendf("SkPath2DPathEffect: (");
+    this->INHERITED::toString(str);
+    // TODO: print out path information
+    str->appendf(")");
+}
+#endif
index 79398b3b82dd26ea8648e3abf9750fe0b9db23e6..06cba96109c637a0fd0454b75d51d174e5f3ad37 100644 (file)
@@ -68,3 +68,11 @@ SkFlattenable* SkArcToPathEffect::CreateProc(SkReadBuffer& buffer) {
 void SkArcToPathEffect::flatten(SkWriteBuffer& buffer) const {
     buffer.writeScalar(fRadius);
 }
+
+#ifndef SK_IGNORE_TO_STRING
+void SkArcToPathEffect::toString(SkString* str) const {
+    str->appendf("SkArcToPathEffect: (");
+    str->appendf("radius: %f", fRadius);
+    str->appendf(")");
+}
+#endif
index 31f55a3901e22b5502e843d78d5c709ccd484d04..79d4c4cbd3a1710d1bea4f3e56a10a5d1328d834 100644 (file)
@@ -146,3 +146,11 @@ SkFlattenable* SkCornerPathEffect::CreateProc(SkReadBuffer& buffer) {
 void SkCornerPathEffect::flatten(SkWriteBuffer& buffer) const {
     buffer.writeScalar(fRadius);
 }
+
+#ifndef SK_IGNORE_TO_STRING
+void SkCornerPathEffect::toString(SkString* str) const {
+    str->appendf("SkCornerPathEffect: (");
+    str->appendf("radius: %.2f", fRadius);
+    str->appendf(")");
+}
+#endif
index 8cd703f62fa16df323e8ad5daa70ae7372058300..5296f972d5cef104458b59755192e4378b72acfa 100644 (file)
@@ -369,3 +369,17 @@ SkFlattenable* SkDashPathEffect::CreateProc(SkReadBuffer& buffer) {
     }
     return NULL;
 }
+
+#ifndef SK_IGNORE_TO_STRING
+void SkDashPathEffect::toString(SkString* str) const {
+    str->appendf("SkDashPathEffect: (");
+    str->appendf("count: %d phase %.2f intervals: (", fCount, fPhase);
+    for (int i = 0; i < fCount; ++i) {
+        str->appendf("%.2f", fIntervals[i]);
+        if (i < fCount-1) {
+            str->appendf(", ");
+        }
+    }
+    str->appendf("))");
+}
+#endif
index 6765b296a54b9b6c7306860cb18c16ba1aad21a9..ac84a600e3ddb0726916a8bf16dafeac82dd6599 100644 (file)
@@ -128,3 +128,11 @@ void SkDiscretePathEffect::flatten(SkWriteBuffer& buffer) const {
     buffer.writeScalar(fPerterb);
     buffer.writeUInt(fSeedAssist);
 }
+
+#ifndef SK_IGNORE_TO_STRING
+void SkDiscretePathEffect::toString(SkString* str) const {
+    str->appendf("SkDiscretePathEffect: (");
+    str->appendf("segLength: %.2f deviation: %.2f seed %d", fSegLength, fPerterb, fSeedAssist);
+    str->append(")");
+}
+#endif