aboutsummaryrefslogtreecommitdiffhomepage
path: root/samplecode
diff options
context:
space:
mode:
authorGravatar scroggo@google.com <scroggo@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-09-12 18:53:49 +0000
committerGravatar scroggo@google.com <scroggo@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-09-12 18:53:49 +0000
commitd8a6cc814f1a0a8faaddad05ae765ad2f6b11aac (patch)
tree3230571e4fab68583d802ea1f4a217d538695bc7 /samplecode
parentbfe1572f2484cb928a17b4c45ed2d094e3e57e17 (diff)
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
Diffstat (limited to 'samplecode')
-rw-r--r--samplecode/SampleAll.cpp49
-rw-r--r--samplecode/SampleSlides.cpp50
2 files changed, 2 insertions, 97 deletions
diff --git a/samplecode/SampleAll.cpp b/samplecode/SampleAll.cpp
index b85064265a..acdb148abe 100644
--- a/samplecode/SampleAll.cpp
+++ b/samplecode/SampleAll.cpp
@@ -206,60 +206,13 @@ static void r8(SkLayerRasterizer* rast, SkPaint& p) {
rast->addLayer(p);
}
-class Line2DPathEffect : public Sk2DPathEffect {
-public:
- Line2DPathEffect(SkScalar width, const SkMatrix& matrix)
- : Sk2DPathEffect(matrix), fWidth(width) {}
-
- virtual bool filterPath(SkPath* dst, const SkPath& src, SkStrokeRec* rec) SK_OVERRIDE {
- if (this->INHERITED::filterPath(dst, src, rec)) {
- rec->setStrokeStyle(fWidth);
- return true;
- }
- return false;
- }
-
- SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(Line2DPathEffect)
-
-protected:
- virtual void 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]);
- }
- }
-
- Line2DPathEffect(SkFlattenableReadBuffer& buffer) : INHERITED(buffer) {
- fWidth = buffer.readScalar();
- }
- virtual void flatten(SkFlattenableWriteBuffer& buffer) const SK_OVERRIDE {
- this->INHERITED::flatten(buffer);
- buffer.writeScalar(fWidth);
- }
-
-private:
- SkScalar fWidth;
-
- typedef Sk2DPathEffect INHERITED;
-};
-
-SK_DEFINE_FLATTENABLE_REGISTRAR(Line2DPathEffect)
-
static void r9(SkLayerRasterizer* rast, SkPaint& p) {
rast->addLayer(p);
SkMatrix lattice;
lattice.setScale(SK_Scalar1, SK_Scalar1*6, 0, 0);
lattice.postRotate(SkIntToScalar(30), 0, 0);
- p.setPathEffect(new Line2DPathEffect(SK_Scalar1*2, lattice))->unref();
+ p.setPathEffect(new SkLine2DPathEffect(SK_Scalar1*2, lattice))->unref();
p.setXfermodeMode(SkXfermode::kClear_Mode);
rast->addLayer(p);
diff --git a/samplecode/SampleSlides.cpp b/samplecode/SampleSlides.cpp
index 574564fe73..b200473708 100644
--- a/samplecode/SampleSlides.cpp
+++ b/samplecode/SampleSlides.cpp
@@ -598,54 +598,6 @@ static void r8(SkLayerRasterizer* rast, SkPaint& p)
rast->addLayer(p);
}
-class Line2DPathEffect : public Sk2DPathEffect {
-public:
- Line2DPathEffect(SkScalar width, const SkMatrix& matrix)
- : Sk2DPathEffect(matrix), fWidth(width) {}
-
- virtual bool filterPath(SkPath* dst, const SkPath& src, SkStrokeRec* rec) SK_OVERRIDE {
- if (this->INHERITED::filterPath(dst, src, rec)) {
- rec->setStrokeStyle(fWidth);
- return true;
- }
- return false;
- }
-
- SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(Line2DPathEffect)
-protected:
- virtual void 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]);
- }
- }
-
- Line2DPathEffect(SkFlattenableReadBuffer& buffer) : INHERITED(buffer)
- {
- fWidth = buffer.readScalar();
- }
- virtual void flatten(SkFlattenableWriteBuffer& buffer) const SK_OVERRIDE
- {
- this->INHERITED::flatten(buffer);
- buffer.writeScalar(fWidth);
- }
-
-private:
- SkScalar fWidth;
-
- typedef Sk2DPathEffect INHERITED;
-};
-
static void r9(SkLayerRasterizer* rast, SkPaint& p)
{
rast->addLayer(p);
@@ -653,7 +605,7 @@ static void r9(SkLayerRasterizer* rast, SkPaint& p)
SkMatrix lattice;
lattice.setScale(SK_Scalar1, SK_Scalar1*6, 0, 0);
lattice.postRotate(SkIntToScalar(30), 0, 0);
- p.setPathEffect(new Line2DPathEffect(SK_Scalar1*2, lattice))->unref();
+ p.setPathEffect(new SkLine2DPathEffect(SK_Scalar1*2, lattice))->unref();
p.setXfermodeMode(SkXfermode::kClear_Mode);
rast->addLayer(p);