Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(53)

Side by Side Diff: samplecode/ClockFaceView.cpp

Issue 395603002: Simplify flattening to just write enough to call the factory (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: simplify xfermodes, fix SkLayerDrawLooper Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 1
2 /* 2 /*
3 * Copyright 2011 Google Inc. 3 * Copyright 2011 Google Inc.
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 #include "SampleCode.h" 8 #include "SampleCode.h"
9 #include "SkView.h" 9 #include "SkView.h"
10 #include "SkCanvas.h" 10 #include "SkCanvas.h"
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 } 83 }
84 84
85 virtual void next(const SkPoint& loc, int u, int v, 85 virtual void next(const SkPoint& loc, int u, int v,
86 SkPath* dst) const SK_OVERRIDE { 86 SkPath* dst) const SK_OVERRIDE {
87 if (fPts) { 87 if (fPts) {
88 *fPts->append() = loc; 88 *fPts->append() = loc;
89 } 89 }
90 dst->addCircle(loc.fX, loc.fY, fRadius); 90 dst->addCircle(loc.fX, loc.fY, fRadius);
91 } 91 }
92 92
93 #ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING
93 Dot2DPathEffect(SkReadBuffer& buffer) : INHERITED(buffer) { 94 Dot2DPathEffect(SkReadBuffer& buffer) : INHERITED(buffer) {
94 fRadius = buffer.readScalar(); 95 fRadius = buffer.readScalar();
95 fPts = NULL; 96 fPts = NULL;
96 } 97 }
98 #endif
97 99
98 virtual void flatten(SkWriteBuffer& buffer) const SK_OVERRIDE { 100 virtual void flatten(SkWriteBuffer& buffer) const SK_OVERRIDE {
99 this->INHERITED::flatten(buffer); 101 buffer.writeMatrix(this->getMatrix());
100 buffer.writeScalar(fRadius); 102 buffer.writeScalar(fRadius);
101 } 103 }
102 104
103 private: 105 private:
104 SkScalar fRadius; 106 SkScalar fRadius;
105 SkTDArray<SkPoint>* fPts; 107 SkTDArray<SkPoint>* fPts;
106 108
107 typedef Sk2DPathEffect INHERITED; 109 typedef Sk2DPathEffect INHERITED;
108 }; 110 };
109 111
112 SkFlattenable* Dot2DPathEffect::CreateProc(SkReadBuffer& buffer) {
113 SkMatrix matrix;
114 buffer.readMatrix(&matrix);
115 return SkNEW_ARGS(Dot2DPathEffect, (buffer.readScalar(), matrix, NULL));
116 }
117
110 class InverseFillPE : public SkPathEffect { 118 class InverseFillPE : public SkPathEffect {
111 public: 119 public:
112 InverseFillPE() {} 120 InverseFillPE() {}
113 virtual bool filterPath(SkPath* dst, const SkPath& src, 121 virtual bool filterPath(SkPath* dst, const SkPath& src,
114 SkStrokeRec*, const SkRect*) const SK_OVERRIDE { 122 SkStrokeRec*, const SkRect*) const SK_OVERRIDE {
115 *dst = src; 123 *dst = src;
116 dst->setFillType(SkPath::kInverseWinding_FillType); 124 dst->setFillType(SkPath::kInverseWinding_FillType);
117 return true; 125 return true;
118 } 126 }
119 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(InverseFillPE) 127 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(InverseFillPE)
120 128
121 protected: 129 protected:
130 #ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING
122 InverseFillPE(SkReadBuffer& buffer) : INHERITED(buffer) {} 131 InverseFillPE(SkReadBuffer& buffer) : INHERITED(buffer) {}
132 #endif
133
123 private: 134 private:
124 135
125 typedef SkPathEffect INHERITED; 136 typedef SkPathEffect INHERITED;
126 }; 137 };
127 138
139 SkFlattenable* InverseFillPE::CreateProc(SkReadBuffer& buffer) {
140 return SkNEW(InverseFillPE);
141 }
142
128 static SkPathEffect* makepe(float interp, SkTDArray<SkPoint>* pts) { 143 static SkPathEffect* makepe(float interp, SkTDArray<SkPoint>* pts) {
129 SkMatrix lattice; 144 SkMatrix lattice;
130 SkScalar rad = 3 + SkIntToScalar(4) * (1 - interp); 145 SkScalar rad = 3 + SkIntToScalar(4) * (1 - interp);
131 lattice.setScale(rad*2, rad*2, 0, 0); 146 lattice.setScale(rad*2, rad*2, 0, 0);
132 lattice.postSkew(SK_Scalar1/3, 0, 0, 0); 147 lattice.postSkew(SK_Scalar1/3, 0, 0, 0);
133 return new Dot2DPathEffect(rad, lattice, pts); 148 return new Dot2DPathEffect(rad, lattice, pts);
134 } 149 }
135 150
136 static void r7(SkLayerRasterizer::Builder* rastBuilder, SkPaint& p, SkScalar int erp) { 151 static void r7(SkLayerRasterizer::Builder* rastBuilder, SkPaint& p, SkScalar int erp) {
137 p.setPathEffect(makepe(SkScalarToFloat(interp), NULL))->unref(); 152 p.setPathEffect(makepe(SkScalarToFloat(interp), NULL))->unref();
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 } 259 }
245 260
246 private: 261 private:
247 typedef SkView INHERITED; 262 typedef SkView INHERITED;
248 }; 263 };
249 264
250 ////////////////////////////////////////////////////////////////////////////// 265 //////////////////////////////////////////////////////////////////////////////
251 266
252 static SkView* MyFactory() { return new ClockFaceView; } 267 static SkView* MyFactory() { return new ClockFaceView; }
253 static SkViewRegister reg(MyFactory); 268 static SkViewRegister reg(MyFactory);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698