Add patheffects to debugger printout

TBR=bsalomon@google.com

Review URL: https://codereview.chromium.org/872043002
This commit is contained in:
robertphillips 2015-01-26 06:08:52 -08:00 committed by Commit bot
parent b644e9afde
commit 42dbfa8651
19 changed files with 147 additions and 5 deletions

View 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;
};

View 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

View 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:

View 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:

View 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:

View 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:

View 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:

View 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:

View 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:

View 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:

View 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)) {

View 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>");
}

View 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

View 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

View 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

View 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

View 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

View 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

View 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