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

Side by Side Diff: samplecode/ClockFaceView.cpp

Issue 176873004: Builder class for SkLayerRasterizer. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Make ReadLayers private Created 6 years, 9 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
« no previous file with comments | « include/effects/SkLayerRasterizer.h ('k') | samplecode/SampleAll.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 }; 126 };
127 127
128 static SkPathEffect* makepe(float interp, SkTDArray<SkPoint>* pts) { 128 static SkPathEffect* makepe(float interp, SkTDArray<SkPoint>* pts) {
129 SkMatrix lattice; 129 SkMatrix lattice;
130 SkScalar rad = 3 + SkIntToScalar(4) * (1 - interp); 130 SkScalar rad = 3 + SkIntToScalar(4) * (1 - interp);
131 lattice.setScale(rad*2, rad*2, 0, 0); 131 lattice.setScale(rad*2, rad*2, 0, 0);
132 lattice.postSkew(SK_Scalar1/3, 0, 0, 0); 132 lattice.postSkew(SK_Scalar1/3, 0, 0, 0);
133 return new Dot2DPathEffect(rad, lattice, pts); 133 return new Dot2DPathEffect(rad, lattice, pts);
134 } 134 }
135 135
136 static void r7(SkLayerRasterizer* rast, SkPaint& p, SkScalar interp) { 136 static void r7(SkLayerRasterizer::Builder* rastBuilder, SkPaint& p, SkScalar int erp) {
137 p.setPathEffect(makepe(SkScalarToFloat(interp), NULL))->unref(); 137 p.setPathEffect(makepe(SkScalarToFloat(interp), NULL))->unref();
138 rast->addLayer(p); 138 rastBuilder->addLayer(p);
139 #if 0 139 #if 0
140 p.setPathEffect(new InverseFillPE())->unref(); 140 p.setPathEffect(new InverseFillPE())->unref();
141 p.setXfermodeMode(SkXfermode::kSrcIn_Mode); 141 p.setXfermodeMode(SkXfermode::kSrcIn_Mode);
142 p.setXfermodeMode(SkXfermode::kClear_Mode); 142 p.setXfermodeMode(SkXfermode::kClear_Mode);
143 p.setAlpha((1 - interp) * 255); 143 p.setAlpha((1 - interp) * 255);
144 rast->addLayer(p); 144 rastBuilder->addLayer(p);
145 #endif 145 #endif
146 } 146 }
147 147
148 typedef void (*raster_proc)(SkLayerRasterizer*, SkPaint&); 148 typedef void (*raster_proc)(SkLayerRasterizer*, SkPaint&);
149 149
150 #include "SkXfermode.h" 150 #include "SkXfermode.h"
151 151
152 static void apply_shader(SkPaint* paint, float scale) 152 static void apply_shader(SkPaint* paint, float scale)
153 { 153 {
154 SkPaint p; 154 SkPaint p;
155 SkLayerRasterizer* rast = new SkLayerRasterizer; 155 SkLayerRasterizer::Builder rastBuilder;
156 156
157 p.setAntiAlias(true); 157 p.setAntiAlias(true);
158 r7(rast, p, scale); 158 r7(&rastBuilder, p, scale);
159 paint->setRasterizer(rast)->unref(); 159 paint->setRasterizer(rastBuilder.detachRasterizer())->unref();
160 160
161 paint->setColor(SK_ColorBLUE); 161 paint->setColor(SK_ColorBLUE);
162 } 162 }
163 163
164 class ClockFaceView : public SkView { 164 class ClockFaceView : public SkView {
165 SkTypeface* fFace; 165 SkTypeface* fFace;
166 SkScalar fInterp; 166 SkScalar fInterp;
167 SkScalar fDx; 167 SkScalar fDx;
168 168
169 public: 169 public:
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 } 244 }
245 245
246 private: 246 private:
247 typedef SkView INHERITED; 247 typedef SkView INHERITED;
248 }; 248 };
249 249
250 ////////////////////////////////////////////////////////////////////////////// 250 //////////////////////////////////////////////////////////////////////////////
251 251
252 static SkView* MyFactory() { return new ClockFaceView; } 252 static SkView* MyFactory() { return new ClockFaceView; }
253 static SkViewRegister reg(MyFactory); 253 static SkViewRegister reg(MyFactory);
OLDNEW
« no previous file with comments | « include/effects/SkLayerRasterizer.h ('k') | samplecode/SampleAll.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698