OLD | NEW |
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 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 private: | 97 private: |
98 SkScalar fRadius; | 98 SkScalar fRadius; |
99 SkTDArray<SkPoint>* fPts; | 99 SkTDArray<SkPoint>* fPts; |
100 | 100 |
101 typedef Sk2DPathEffect INHERITED; | 101 typedef Sk2DPathEffect INHERITED; |
102 }; | 102 }; |
103 | 103 |
104 SkFlattenable* Dot2DPathEffect::CreateProc(SkReadBuffer& buffer) { | 104 SkFlattenable* Dot2DPathEffect::CreateProc(SkReadBuffer& buffer) { |
105 SkMatrix matrix; | 105 SkMatrix matrix; |
106 buffer.readMatrix(&matrix); | 106 buffer.readMatrix(&matrix); |
107 return new Dot2DPathEffect(buffer.readScalar(), matrix, NULL); | 107 return new Dot2DPathEffect(buffer.readScalar(), matrix, nullptr); |
108 } | 108 } |
109 | 109 |
110 class InverseFillPE : public SkPathEffect { | 110 class InverseFillPE : public SkPathEffect { |
111 public: | 111 public: |
112 InverseFillPE() {} | 112 InverseFillPE() {} |
113 virtual bool filterPath(SkPath* dst, const SkPath& src, | 113 virtual bool filterPath(SkPath* dst, const SkPath& src, |
114 SkStrokeRec*, const SkRect*) const override { | 114 SkStrokeRec*, const SkRect*) const override { |
115 *dst = src; | 115 *dst = src; |
116 dst->setFillType(SkPath::kInverseWinding_FillType); | 116 dst->setFillType(SkPath::kInverseWinding_FillType); |
117 return true; | 117 return true; |
(...skipping 15 matching lines...) Expand all Loading... |
133 | 133 |
134 static SkPathEffect* makepe(float interp, SkTDArray<SkPoint>* pts) { | 134 static SkPathEffect* makepe(float interp, SkTDArray<SkPoint>* pts) { |
135 SkMatrix lattice; | 135 SkMatrix lattice; |
136 SkScalar rad = 3 + SkIntToScalar(4) * (1 - interp); | 136 SkScalar rad = 3 + SkIntToScalar(4) * (1 - interp); |
137 lattice.setScale(rad*2, rad*2, 0, 0); | 137 lattice.setScale(rad*2, rad*2, 0, 0); |
138 lattice.postSkew(SK_Scalar1/3, 0, 0, 0); | 138 lattice.postSkew(SK_Scalar1/3, 0, 0, 0); |
139 return new Dot2DPathEffect(rad, lattice, pts); | 139 return new Dot2DPathEffect(rad, lattice, pts); |
140 } | 140 } |
141 | 141 |
142 static void r7(SkLayerRasterizer::Builder* rastBuilder, SkPaint& p, SkScalar int
erp) { | 142 static void r7(SkLayerRasterizer::Builder* rastBuilder, SkPaint& p, SkScalar int
erp) { |
143 p.setPathEffect(makepe(SkScalarToFloat(interp), NULL))->unref(); | 143 p.setPathEffect(makepe(SkScalarToFloat(interp), nullptr))->unref(); |
144 rastBuilder->addLayer(p); | 144 rastBuilder->addLayer(p); |
145 #if 0 | 145 #if 0 |
146 p.setPathEffect(new InverseFillPE())->unref(); | 146 p.setPathEffect(new InverseFillPE())->unref(); |
147 p.setXfermodeMode(SkXfermode::kSrcIn_Mode); | 147 p.setXfermodeMode(SkXfermode::kSrcIn_Mode); |
148 p.setXfermodeMode(SkXfermode::kClear_Mode); | 148 p.setXfermodeMode(SkXfermode::kClear_Mode); |
149 p.setAlpha((1 - interp) * 255); | 149 p.setAlpha((1 - interp) * 255); |
150 rastBuilder->addLayer(p); | 150 rastBuilder->addLayer(p); |
151 #endif | 151 #endif |
152 } | 152 } |
153 | 153 |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
198 canvas->drawColor(SK_ColorWHITE); | 198 canvas->drawColor(SK_ColorWHITE); |
199 } | 199 } |
200 | 200 |
201 static void drawdots(SkCanvas* canvas, const SkPaint& orig) { | 201 static void drawdots(SkCanvas* canvas, const SkPaint& orig) { |
202 SkTDArray<SkPoint> pts; | 202 SkTDArray<SkPoint> pts; |
203 SkPathEffect* pe = makepe(0, &pts); | 203 SkPathEffect* pe = makepe(0, &pts); |
204 | 204 |
205 SkStrokeRec rec(SkStrokeRec::kFill_InitStyle); | 205 SkStrokeRec rec(SkStrokeRec::kFill_InitStyle); |
206 SkPath path, dstPath; | 206 SkPath path, dstPath; |
207 orig.getTextPath("9", 1, 0, 0, &path); | 207 orig.getTextPath("9", 1, 0, 0, &path); |
208 pe->filterPath(&dstPath, path, &rec, NULL); | 208 pe->filterPath(&dstPath, path, &rec, nullptr); |
209 | 209 |
210 SkPaint p; | 210 SkPaint p; |
211 p.setAntiAlias(true); | 211 p.setAntiAlias(true); |
212 p.setStrokeWidth(10); | 212 p.setStrokeWidth(10); |
213 p.setColor(SK_ColorRED); | 213 p.setColor(SK_ColorRED); |
214 canvas->drawPoints(SkCanvas::kPoints_PointMode, pts.count(), pts.begin()
, | 214 canvas->drawPoints(SkCanvas::kPoints_PointMode, pts.count(), pts.begin()
, |
215 p); | 215 p); |
216 } | 216 } |
217 | 217 |
218 virtual void onDraw(SkCanvas* canvas) { | 218 virtual void onDraw(SkCanvas* canvas) { |
(...skipping 19 matching lines...) Expand all Loading... |
238 | 238 |
239 if (false) { | 239 if (false) { |
240 fInterp += fDx; | 240 fInterp += fDx; |
241 if (fInterp > 1) { | 241 if (fInterp > 1) { |
242 fInterp = 1; | 242 fInterp = 1; |
243 fDx = -fDx; | 243 fDx = -fDx; |
244 } else if (fInterp < 0) { | 244 } else if (fInterp < 0) { |
245 fInterp = 0; | 245 fInterp = 0; |
246 fDx = -fDx; | 246 fDx = -fDx; |
247 } | 247 } |
248 this->inval(NULL); | 248 this->inval(nullptr); |
249 } | 249 } |
250 } | 250 } |
251 | 251 |
252 private: | 252 private: |
253 typedef SkView INHERITED; | 253 typedef SkView INHERITED; |
254 }; | 254 }; |
255 | 255 |
256 ////////////////////////////////////////////////////////////////////////////// | 256 ////////////////////////////////////////////////////////////////////////////// |
257 | 257 |
258 static SkView* MyFactory() { return new ClockFaceView; } | 258 static SkView* MyFactory() { return new ClockFaceView; } |
259 static SkViewRegister reg(MyFactory); | 259 static SkViewRegister reg(MyFactory); |
OLD | NEW |