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

Side by Side Diff: samplecode/SampleSlides.cpp

Issue 283273002: remove unused (by clients) SkUnitMapper (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: fix legacy call Created 6 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « samplecode/SampleShaderText.cpp ('k') | samplecode/SampleTiling.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 "SkBlurMask.h" 9 #include "SkBlurMask.h"
10 #include "SkBlurMaskFilter.h" 10 #include "SkBlurMaskFilter.h"
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 }; 171 };
172 172
173 static const GradData gGradData[] = { 173 static const GradData gGradData[] = {
174 { 2, gColors, NULL }, 174 { 2, gColors, NULL },
175 { 2, gColors, gPos0 }, 175 { 2, gColors, gPos0 },
176 { 2, gColors, gPos1 }, 176 { 2, gColors, gPos1 },
177 { 5, gColors, NULL }, 177 { 5, gColors, NULL },
178 { 5, gColors, gPos2 } 178 { 5, gColors, gPos2 }
179 }; 179 };
180 180
181 static SkShader* MakeLinear(const SkPoint pts[2], const GradData& data, 181 static SkShader* MakeLinear(const SkPoint pts[2], const GradData& data, SkShader ::TileMode tm) {
182 SkShader::TileMode tm, SkUnitMapper* mapper) { 182 return SkGradientShader::CreateLinear(pts, data.fColors, data.fPos, data.fCo unt, tm);
183 return SkGradientShader::CreateLinear(pts, data.fColors, data.fPos,
184 data.fCount, tm, mapper);
185 } 183 }
186 184
187 static SkShader* MakeRadial(const SkPoint pts[2], const GradData& data, 185 static SkShader* MakeRadial(const SkPoint pts[2], const GradData& data, SkShader ::TileMode tm) {
188 SkShader::TileMode tm, SkUnitMapper* mapper) {
189 SkPoint center; 186 SkPoint center;
190 center.set(SkScalarAve(pts[0].fX, pts[1].fX), 187 center.set(SkScalarAve(pts[0].fX, pts[1].fX),
191 SkScalarAve(pts[0].fY, pts[1].fY)); 188 SkScalarAve(pts[0].fY, pts[1].fY));
192 return SkGradientShader::CreateRadial(center, center.fX, data.fColors, 189 return SkGradientShader::CreateRadial(center, center.fX, data.fColors,
193 data.fPos, data.fCount, tm, mapper); 190 data.fPos, data.fCount, tm);
194 } 191 }
195 192
196 static SkShader* MakeSweep(const SkPoint pts[2], const GradData& data, 193 static SkShader* MakeSweep(const SkPoint pts[2], const GradData& data, SkShader: :TileMode tm) {
197 SkShader::TileMode tm, SkUnitMapper* mapper) {
198 SkPoint center; 194 SkPoint center;
199 center.set(SkScalarAve(pts[0].fX, pts[1].fX), 195 center.set(SkScalarAve(pts[0].fX, pts[1].fX),
200 SkScalarAve(pts[0].fY, pts[1].fY)); 196 SkScalarAve(pts[0].fY, pts[1].fY));
201 return SkGradientShader::CreateSweep(center.fX, center.fY, data.fColors, 197 return SkGradientShader::CreateSweep(center.fX, center.fY, data.fColors, dat a.fPos, data.fCount);
202 data.fPos, data.fCount, mapper);
203 } 198 }
204 199
205 static SkShader* Make2Radial(const SkPoint pts[2], const GradData& data, 200 static SkShader* Make2Radial(const SkPoint pts[2], const GradData& data, SkShade r::TileMode tm) {
206 SkShader::TileMode tm, SkUnitMapper* mapper) {
207 SkPoint center0, center1; 201 SkPoint center0, center1;
208 center0.set(SkScalarAve(pts[0].fX, pts[1].fX), 202 center0.set(SkScalarAve(pts[0].fX, pts[1].fX),
209 SkScalarAve(pts[0].fY, pts[1].fY)); 203 SkScalarAve(pts[0].fY, pts[1].fY));
210 center1.set(SkScalarInterp(pts[0].fX, pts[1].fX, SkIntToScalar(3)/5), 204 center1.set(SkScalarInterp(pts[0].fX, pts[1].fX, SkIntToScalar(3)/5),
211 SkScalarInterp(pts[0].fY, pts[1].fY, SkIntToScalar(1)/4)); 205 SkScalarInterp(pts[0].fY, pts[1].fY, SkIntToScalar(1)/4));
212 return SkGradientShader::CreateTwoPointRadial( 206 return SkGradientShader::CreateTwoPointRadial(
213 center1, (pts[1].fX - pts[0].f X) / 7, 207 center1, (pts[1].fX - pts[0].f X) / 7,
214 center0, (pts[1].fX - pts[0].f X) / 2, 208 center0, (pts[1].fX - pts[0].f X) / 2,
215 data.fColors, data.fPos, data. fCount, tm, mapper); 209 data.fColors, data.fPos, data. fCount, tm);
216 } 210 }
217 211
218 typedef SkShader* (*GradMaker)(const SkPoint pts[2], const GradData& data, 212 typedef SkShader* (*GradMaker)(const SkPoint pts[2], const GradData& data, SkSha der::TileMode tm);
219 SkShader::TileMode tm, SkUnitMapper* mapper);
220 static const GradMaker gGradMakers[] = { 213 static const GradMaker gGradMakers[] = {
221 MakeLinear, MakeRadial, MakeSweep, Make2Radial 214 MakeLinear, MakeRadial, MakeSweep, Make2Radial
222 }; 215 };
223 216
224 static void gradient_slide(SkCanvas* canvas) { 217 static void gradient_slide(SkCanvas* canvas) {
225 SkPoint pts[2] = { 218 SkPoint pts[2] = {
226 { 0, 0 }, 219 { 0, 0 },
227 { SkIntToScalar(100), SkIntToScalar(100) } 220 { SkIntToScalar(100), SkIntToScalar(100) }
228 }; 221 };
229 SkShader::TileMode tm = SkShader::kClamp_TileMode; 222 SkShader::TileMode tm = SkShader::kClamp_TileMode;
230 SkRect r = { 0, 0, SkIntToScalar(100), SkIntToScalar(100) }; 223 SkRect r = { 0, 0, SkIntToScalar(100), SkIntToScalar(100) };
231 SkPaint paint; 224 SkPaint paint;
232 paint.setAntiAlias(true); 225 paint.setAntiAlias(true);
233 paint.setDither(true); 226 paint.setDither(true);
234 227
235 canvas->translate(SkIntToScalar(20), SkIntToScalar(10)); 228 canvas->translate(SkIntToScalar(20), SkIntToScalar(10));
236 for (size_t i = 0; i < SK_ARRAY_COUNT(gGradData); i++) { 229 for (size_t i = 0; i < SK_ARRAY_COUNT(gGradData); i++) {
237 canvas->save(); 230 canvas->save();
238 for (size_t j = 0; j < SK_ARRAY_COUNT(gGradMakers); j++) { 231 for (size_t j = 0; j < SK_ARRAY_COUNT(gGradMakers); j++) {
239 SkShader* shader = gGradMakers[j](pts, gGradData[i], tm, NULL); 232 SkShader* shader = gGradMakers[j](pts, gGradData[i], tm);
240 paint.setShader(shader); 233 paint.setShader(shader);
241 canvas->drawRect(r, paint); 234 canvas->drawRect(r, paint);
242 shader->unref(); 235 shader->unref();
243 canvas->translate(0, SkIntToScalar(120)); 236 canvas->translate(0, SkIntToScalar(120));
244 } 237 }
245 canvas->restore(); 238 canvas->restore();
246 canvas->translate(SkIntToScalar(120), 0); 239 canvas->translate(SkIntToScalar(120), 0);
247 } 240 }
248 } 241 }
249 242
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
328 size->set(bm.width(), bm.height()); 321 size->set(bm.width(), bm.height());
329 return SkShader::CreateBitmapShader(bm, SkShader::kClamp_TileMode, 322 return SkShader::CreateBitmapShader(bm, SkShader::kClamp_TileMode,
330 SkShader::kClamp_TileMode); 323 SkShader::kClamp_TileMode);
331 } 324 }
332 325
333 static SkShader* make_shader1(const SkIPoint& size) { 326 static SkShader* make_shader1(const SkIPoint& size) {
334 SkPoint pts[] = { { 0, 0 }, 327 SkPoint pts[] = { { 0, 0 },
335 { SkIntToScalar(size.fX), SkIntToScalar(size.fY) } }; 328 { SkIntToScalar(size.fX), SkIntToScalar(size.fY) } };
336 SkColor colors[] = { SK_ColorRED, SK_ColorGREEN, SK_ColorBLUE, SK_ColorRED } ; 329 SkColor colors[] = { SK_ColorRED, SK_ColorGREEN, SK_ColorBLUE, SK_ColorRED } ;
337 return SkGradientShader::CreateLinear(pts, colors, NULL, 330 return SkGradientShader::CreateLinear(pts, colors, NULL,
338 SK_ARRAY_COUNT(colors), SkShader::kMir ror_TileMode, NULL); 331 SK_ARRAY_COUNT(colors), SkShader::kMir ror_TileMode);
339 } 332 }
340 333
341 class Rec { 334 class Rec {
342 public: 335 public:
343 SkCanvas::VertexMode fMode; 336 SkCanvas::VertexMode fMode;
344 int fCount; 337 int fCount;
345 SkPoint* fVerts; 338 SkPoint* fVerts;
346 SkPoint* fTexs; 339 SkPoint* fTexs;
347 340
348 Rec() : fCount(0), fVerts(NULL), fTexs(NULL) {} 341 Rec() : fCount(0), fVerts(NULL), fTexs(NULL) {}
(...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after
725 } 718 }
726 719
727 private: 720 private:
728 typedef SampleView INHERITED; 721 typedef SampleView INHERITED;
729 }; 722 };
730 723
731 ////////////////////////////////////////////////////////////////////////////// 724 //////////////////////////////////////////////////////////////////////////////
732 725
733 static SkView* MyFactory() { return new SlideView; } 726 static SkView* MyFactory() { return new SlideView; }
734 static SkViewRegister reg(MyFactory); 727 static SkViewRegister reg(MyFactory);
OLDNEW
« no previous file with comments | « samplecode/SampleShaderText.cpp ('k') | samplecode/SampleTiling.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698