aboutsummaryrefslogtreecommitdiffhomepage
path: root/gm
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 /gm
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 'gm')
-rw-r--r--gm/texteffects.cpp62
1 files changed, 1 insertions, 61 deletions
diff --git a/gm/texteffects.cpp b/gm/texteffects.cpp
index 18cae70155..3436018963 100644
--- a/gm/texteffects.cpp
+++ b/gm/texteffects.cpp
@@ -124,58 +124,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;
-};
-
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);
@@ -192,16 +147,6 @@ static const raster_proc gRastProcs[] = {
r0, r1, r2, r3, r4, r5, r6, r7, r8, r9
};
-static const struct {
- SkColor fMul, fAdd;
-} gLightingColors[] = {
- { 0x808080, 0x800000 }, // general case
- { 0x707070, 0x707070 }, // no-pin case
- { 0xFFFFFF, 0x800000 }, // just-add case
- { 0x808080, 0x000000 }, // just-mul case
- { 0xFFFFFF, 0x000000 } // identity case
-};
-
#include "SkXfermode.h"
static void apply_shader(SkPaint* paint, int index) {
@@ -262,11 +207,6 @@ protected:
canvas->restore();
}
- virtual uint32_t onGetFlags() const SK_OVERRIDE {
- // want to skip serialization due to custom effects only defined here
- return kSkipPipe_Flag;
- }
-
private:
typedef skiagm::GM INHERITED;
};