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

Side by Side Diff: gm/ovals.cpp

Issue 1793303002: Reland of "more shader-->sp conversions (patchset #5 id:80001 of https://codereview.chromium… (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: make pictureRef a value, so its clearer what's going on Created 4 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 | « gm/modecolorfilters.cpp ('k') | gm/patch.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 2013 Google Inc. 3 * Copyright 2013 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 8
9 #include "gm.h" 9 #include "gm.h"
10 #include "SkTArray.h" 10 #include "SkTArray.h"
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 fPaints[i].setColor(color); 239 fPaints[i].setColor(color);
240 240
241 canvas->drawOval(oval, fPaints[i]); 241 canvas->drawOval(oval, fPaints[i]);
242 canvas->restore(); 242 canvas->restore();
243 } 243 }
244 244
245 // radial gradient 245 // radial gradient
246 SkPoint center = SkPoint::Make(SkIntToScalar(0), SkIntToScalar(0)); 246 SkPoint center = SkPoint::Make(SkIntToScalar(0), SkIntToScalar(0));
247 SkColor colors[] = { SK_ColorBLUE, SK_ColorRED, SK_ColorGREEN }; 247 SkColor colors[] = { SK_ColorBLUE, SK_ColorRED, SK_ColorGREEN };
248 SkScalar pos[] = { 0, SK_ScalarHalf, SK_Scalar1 }; 248 SkScalar pos[] = { 0, SK_ScalarHalf, SK_Scalar1 };
249 SkAutoTUnref<SkShader> shader(SkGradientShader::CreateRadial(center, 249 auto shader = SkGradientShader::MakeRadial(center, 20, colors, pos, SK_A RRAY_COUNT(colors),
250 SkIntToScalar(20), 250 SkShader::kClamp_TileMode);
251 colors,
252 pos,
253 SK_ARRAY_COUNT(colors),
254 SkShader::kClamp_TileMode)) ;
255 251
256 for (int i = 0; i < fPaints.count(); ++i) { 252 for (int i = 0; i < fPaints.count(); ++i) {
257 canvas->save(); 253 canvas->save();
258 // position the path, and make it at off-integer coords. 254 // position the path, and make it at off-integer coords.
259 canvas->translate(kXStart + SK_Scalar1 * kXStep * 0 + SK_Scalar1 / 4 , 255 canvas->translate(kXStart + SK_Scalar1 * kXStep * 0 + SK_Scalar1 / 4 ,
260 kYStart + SK_Scalar1 * kYStep * i + 3 * SK_Scalar1 / 4 + 256 kYStart + SK_Scalar1 * kYStep * i + 3 * SK_Scalar1 / 4 +
261 SK_ScalarHalf * kYStep); 257 SK_ScalarHalf * kYStep);
262 258
263 SkColor color = genColor(&rand); 259 SkColor color = genColor(&rand);
264 fPaints[i].setColor(color); 260 fPaints[i].setColor(color);
(...skipping 14 matching lines...) Expand all
279 275
280 typedef GM INHERITED; 276 typedef GM INHERITED;
281 }; 277 };
282 278
283 ////////////////////////////////////////////////////////////////////////////// 279 //////////////////////////////////////////////////////////////////////////////
284 280
285 static GM* MyFactory(void*) { return new OvalGM; } 281 static GM* MyFactory(void*) { return new OvalGM; }
286 static GMRegistry reg(MyFactory); 282 static GMRegistry reg(MyFactory);
287 283
288 } 284 }
OLDNEW
« no previous file with comments | « gm/modecolorfilters.cpp ('k') | gm/patch.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698