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 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 #endif | 125 #endif |
126 | 126 |
127 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(InverseFillPE) | 127 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(InverseFillPE) |
128 | 128 |
129 private: | 129 private: |
130 typedef SkPathEffect INHERITED; | 130 typedef SkPathEffect INHERITED; |
131 }; | 131 }; |
132 | 132 |
133 SkFlattenable* InverseFillPE::CreateProc(SkReadBuffer& buffer) { return new Inve
rseFillPE; } | 133 SkFlattenable* InverseFillPE::CreateProc(SkReadBuffer& buffer) { return new Inve
rseFillPE; } |
134 | 134 |
135 static SkPathEffect* makepe(float interp, SkTDArray<SkPoint>* pts) { | 135 static sk_sp<SkPathEffect> makepe(float interp, SkTDArray<SkPoint>* pts) { |
136 SkMatrix lattice; | 136 SkMatrix lattice; |
137 SkScalar rad = 3 + SkIntToScalar(4) * (1 - interp); | 137 SkScalar rad = 3 + SkIntToScalar(4) * (1 - interp); |
138 lattice.setScale(rad*2, rad*2, 0, 0); | 138 lattice.setScale(rad*2, rad*2, 0, 0); |
139 lattice.postSkew(SK_Scalar1/3, 0, 0, 0); | 139 lattice.postSkew(SK_Scalar1/3, 0, 0, 0); |
140 return new Dot2DPathEffect(rad, lattice, pts); | 140 return sk_make_sp<Dot2DPathEffect>(rad, lattice, pts); |
141 } | 141 } |
142 | 142 |
143 static void r7(SkLayerRasterizer::Builder* rastBuilder, SkPaint& p, SkScalar int
erp) { | 143 static void r7(SkLayerRasterizer::Builder* rastBuilder, SkPaint& p, SkScalar int
erp) { |
144 p.setPathEffect(makepe(SkScalarToFloat(interp), nullptr))->unref(); | 144 p.setPathEffect(makepe(SkScalarToFloat(interp), nullptr)); |
145 rastBuilder->addLayer(p); | 145 rastBuilder->addLayer(p); |
146 #if 0 | 146 #if 0 |
147 p.setPathEffect(new InverseFillPE())->unref(); | 147 p.setPathEffect(new InverseFillPE())->unref(); |
148 p.setXfermodeMode(SkXfermode::kSrcIn_Mode); | 148 p.setXfermodeMode(SkXfermode::kSrcIn_Mode); |
149 p.setXfermodeMode(SkXfermode::kClear_Mode); | 149 p.setXfermodeMode(SkXfermode::kClear_Mode); |
150 p.setAlpha((1 - interp) * 255); | 150 p.setAlpha((1 - interp) * 255); |
151 rastBuilder->addLayer(p); | 151 rastBuilder->addLayer(p); |
152 #endif | 152 #endif |
153 } | 153 } |
154 | 154 |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
194 return this->INHERITED::onQuery(evt); | 194 return this->INHERITED::onQuery(evt); |
195 } | 195 } |
196 | 196 |
197 void drawBG(SkCanvas* canvas) { | 197 void drawBG(SkCanvas* canvas) { |
198 // canvas->drawColor(0xFFDDDDDD); | 198 // canvas->drawColor(0xFFDDDDDD); |
199 canvas->drawColor(SK_ColorWHITE); | 199 canvas->drawColor(SK_ColorWHITE); |
200 } | 200 } |
201 | 201 |
202 static void drawdots(SkCanvas* canvas, const SkPaint& orig) { | 202 static void drawdots(SkCanvas* canvas, const SkPaint& orig) { |
203 SkTDArray<SkPoint> pts; | 203 SkTDArray<SkPoint> pts; |
204 SkPathEffect* pe = makepe(0, &pts); | 204 auto pe = makepe(0, &pts); |
205 | 205 |
206 SkStrokeRec rec(SkStrokeRec::kFill_InitStyle); | 206 SkStrokeRec rec(SkStrokeRec::kFill_InitStyle); |
207 SkPath path, dstPath; | 207 SkPath path, dstPath; |
208 orig.getTextPath("9", 1, 0, 0, &path); | 208 orig.getTextPath("9", 1, 0, 0, &path); |
209 pe->filterPath(&dstPath, path, &rec, nullptr); | 209 pe->filterPath(&dstPath, path, &rec, nullptr); |
210 | 210 |
211 SkPaint p; | 211 SkPaint p; |
212 p.setAntiAlias(true); | 212 p.setAntiAlias(true); |
213 p.setStrokeWidth(10); | 213 p.setStrokeWidth(10); |
214 p.setColor(SK_ColorRED); | 214 p.setColor(SK_ColorRED); |
215 canvas->drawPoints(SkCanvas::kPoints_PointMode, pts.count(), pts.begin()
, | 215 canvas->drawPoints(SkCanvas::kPoints_PointMode, pts.count(), pts.begin()
, p); |
216 p); | |
217 } | 216 } |
218 | 217 |
219 virtual void onDraw(SkCanvas* canvas) { | 218 virtual void onDraw(SkCanvas* canvas) { |
220 this->drawBG(canvas); | 219 this->drawBG(canvas); |
221 | 220 |
222 SkScalar x = SkIntToScalar(20); | 221 SkScalar x = SkIntToScalar(20); |
223 SkScalar y = SkIntToScalar(300); | 222 SkScalar y = SkIntToScalar(300); |
224 SkPaint paint; | 223 SkPaint paint; |
225 | 224 |
226 paint.setAntiAlias(true); | 225 paint.setAntiAlias(true); |
(...skipping 24 matching lines...) Expand all Loading... |
251 } | 250 } |
252 | 251 |
253 private: | 252 private: |
254 typedef SkView INHERITED; | 253 typedef SkView INHERITED; |
255 }; | 254 }; |
256 | 255 |
257 ////////////////////////////////////////////////////////////////////////////// | 256 ////////////////////////////////////////////////////////////////////////////// |
258 | 257 |
259 static SkView* MyFactory() { return new ClockFaceView; } | 258 static SkView* MyFactory() { return new ClockFaceView; } |
260 static SkViewRegister reg(MyFactory); | 259 static SkViewRegister reg(MyFactory); |
OLD | NEW |