Make texteffects gm work through serialization and pipe.
Move Line2DPathEffect (now Sk_) into a separate header file so it can
be shared and initialized.
Switch to the shared version in SampleAll and SampleSlides.
Remove the skip pipe flag from texteffects, since it can now be serialized.
I have a separate change to turn serialization on by default at https://codereview.appspot.com/6498121/
Review URL: https://codereview.appspot.com/6503106
git-svn-id: http://skia.googlecode.com/svn/trunk@5512 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/src/effects/Sk2DPathEffect.cpp b/src/effects/Sk2DPathEffect.cpp
index a9a239f..1f1dce4 100644
--- a/src/effects/Sk2DPathEffect.cpp
+++ b/src/effects/Sk2DPathEffect.cpp
@@ -76,7 +76,42 @@
fMatrixIsInvertible = fMatrix.invert(&fInverse);
}
+SK_DEFINE_FLATTENABLE_REGISTRAR(Sk2DPathEffect)
+
///////////////////////////////////////////////////////////////////////////////
+
+bool SkLine2DPathEffect::filterPath(SkPath *dst, const SkPath &src, SkStrokeRec *rec) {
+ if (this->INHERITED::filterPath(dst, src, rec)) {
+ rec->setStrokeStyle(fWidth);
+ return true;
+ }
+ return false;
+}
+
+void SkLine2DPathEffect::nextSpan(int u, int v, int ucount, SkPath *dst) {
+ if (ucount > 1) {
+ SkPoint src[2], dstP[2];
+
+ src[0].set(SkIntToScalar(u) + SK_ScalarHalf, SkIntToScalar(v) + SK_ScalarHalf);
+ src[1].set(SkIntToScalar(u+ucount) + SK_ScalarHalf, SkIntToScalar(v) + SK_ScalarHalf);
+ this->getMatrix().mapPoints(dstP, src, 2);
+
+ dst->moveTo(dstP[0]);
+ dst->lineTo(dstP[1]);
+ }
+}
+
+SkLine2DPathEffect::SkLine2DPathEffect(SkFlattenableReadBuffer& buffer) : INHERITED(buffer) {
+ fWidth = buffer.readScalar();
+}
+
+void SkLine2DPathEffect::flatten(SkFlattenableWriteBuffer &buffer) const {
+ this->INHERITED::flatten(buffer);
+ buffer.writeScalar(fWidth);
+}
+
+SK_DEFINE_FLATTENABLE_REGISTRAR(SkLine2DPathEffect)
+
///////////////////////////////////////////////////////////////////////////////
SkPath2DPathEffect::SkPath2DPathEffect(const SkMatrix& m, const SkPath& p)