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

Side by Side Diff: gm/gradients.cpp

Issue 1316233002: Style Change: NULL->nullptr (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 2015-08-27 (Thursday) 10:25:06 EDT Created 5 years, 3 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/gradient_matrix.cpp ('k') | gm/gradients_no_texture.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 * Copyright 2011 Google Inc. 2 * Copyright 2011 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "gm.h" 8 #include "gm.h"
9 #include "SkGradientShader.h" 9 #include "SkGradientShader.h"
10 10
(...skipping 13 matching lines...) Expand all
24 static const SkScalar gPos2[] = { 24 static const SkScalar gPos2[] = {
25 0, SK_Scalar1/8, SK_Scalar1/2, SK_Scalar1*7/8, SK_Scalar1 25 0, SK_Scalar1/8, SK_Scalar1/2, SK_Scalar1*7/8, SK_Scalar1
26 }; 26 };
27 27
28 static const SkScalar gPosClamp[] = {0.0f, 0.0f, 1.0f, 1.0f}; 28 static const SkScalar gPosClamp[] = {0.0f, 0.0f, 1.0f, 1.0f};
29 static const SkColor gColorClamp[] = { 29 static const SkColor gColorClamp[] = {
30 SK_ColorRED, SK_ColorGREEN, SK_ColorGREEN, SK_ColorBLUE 30 SK_ColorRED, SK_ColorGREEN, SK_ColorGREEN, SK_ColorBLUE
31 }; 31 };
32 32
33 static const GradData gGradData[] = { 33 static const GradData gGradData[] = {
34 { 2, gColors, NULL }, 34 { 2, gColors, nullptr },
35 { 2, gColors, gPos0 }, 35 { 2, gColors, gPos0 },
36 { 2, gColors, gPos1 }, 36 { 2, gColors, gPos1 },
37 { 5, gColors, NULL }, 37 { 5, gColors, nullptr },
38 { 5, gColors, gPos2 }, 38 { 5, gColors, gPos2 },
39 { 4, gColorClamp, gPosClamp } 39 { 4, gColorClamp, gPosClamp }
40 }; 40 };
41 41
42 static SkShader* MakeLinear(const SkPoint pts[2], const GradData& data, 42 static SkShader* MakeLinear(const SkPoint pts[2], const GradData& data,
43 SkShader::TileMode tm, const SkMatrix& localMatrix) { 43 SkShader::TileMode tm, const SkMatrix& localMatrix) {
44 return SkGradientShader::CreateLinear(pts, data.fColors, data.fPos, 44 return SkGradientShader::CreateLinear(pts, data.fColors, data.fPos,
45 data.fCount, tm, 0, &localMatrix); 45 data.fCount, tm, 0, &localMatrix);
46 } 46 }
47 47
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after
304 304
305 SkRect r = { 0, 0, SkIntToScalar(100), SkIntToScalar(300) }; 305 SkRect r = { 0, 0, SkIntToScalar(100), SkIntToScalar(300) };
306 SkPaint paint; 306 SkPaint paint;
307 paint.setAntiAlias(true); 307 paint.setAntiAlias(true);
308 308
309 SkPoint center; 309 SkPoint center;
310 center.iset(0, 300); 310 center.iset(0, 300);
311 canvas->translate(SkIntToScalar(20), SkIntToScalar(20)); 311 canvas->translate(SkIntToScalar(20), SkIntToScalar(20));
312 SkShader* shader = SkGradientShader::CreateRadial( 312 SkShader* shader = SkGradientShader::CreateRadial(
313 SkPoint(center), 313 SkPoint(center),
314 SkIntToScalar(200), gColors, NULL, 5, 314 SkIntToScalar(200), gColors, nullptr, 5,
315 SkShader::kClamp_TileMode); 315 SkShader::kClamp_TileMode);
316 paint.setShader(shader); 316 paint.setShader(shader);
317 canvas->drawRect(r, paint); 317 canvas->drawRect(r, paint);
318 shader->unref(); 318 shader->unref();
319 } 319 }
320 320
321 private: 321 private:
322 typedef GM INHERITED; 322 typedef GM INHERITED;
323 }; 323 };
324 DEF_GM( return new ClampedGradientsGM; ) 324 DEF_GM( return new ClampedGradientsGM; )
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
394 SkPoint center; 394 SkPoint center;
395 center.set(cx, cy); 395 center.set(cx, cy);
396 396
397 // We can either interpolate endpoints and premultiply each point (defau lt, more precision), 397 // We can either interpolate endpoints and premultiply each point (defau lt, more precision),
398 // or premultiply the endpoints first, avoiding the need to premultiply each point (cheap). 398 // or premultiply the endpoints first, avoiding the need to premultiply each point (cheap).
399 const uint32_t flags[] = { 0, SkGradientShader::kInterpolateColorsInPrem ul_Flag }; 399 const uint32_t flags[] = { 0, SkGradientShader::kInterpolateColorsInPrem ul_Flag };
400 400
401 for (size_t i = 0; i < SK_ARRAY_COUNT(flags); i++) { 401 for (size_t i = 0; i < SK_ARRAY_COUNT(flags); i++) {
402 SkAutoTUnref<SkShader> sweep( 402 SkAutoTUnref<SkShader> sweep(
403 SkGradientShader::CreateSweep(cx, cy, sweep_colors, 403 SkGradientShader::CreateSweep(cx, cy, sweep_colors,
404 NULL, SK_ARRAY_COUNT(sweep_col ors), 404 nullptr, SK_ARRAY_COUNT(sweep_ colors),
405 flags[i], NULL)); 405 flags[i], nullptr));
406 SkAutoTUnref<SkShader> radial1( 406 SkAutoTUnref<SkShader> radial1(
407 SkGradientShader::CreateRadial(center, radius, colors1, 407 SkGradientShader::CreateRadial(center, radius, colors1,
408 NULL, SK_ARRAY_COUNT(colors1) , 408 nullptr, SK_ARRAY_COUNT(color s1),
409 SkShader::kClamp_TileMode, 409 SkShader::kClamp_TileMode,
410 flags[i], NULL)); 410 flags[i], nullptr));
411 SkAutoTUnref<SkShader> radial2( 411 SkAutoTUnref<SkShader> radial2(
412 SkGradientShader::CreateRadial(center, radius, colors2, 412 SkGradientShader::CreateRadial(center, radius, colors2,
413 NULL, SK_ARRAY_COUNT(colors2) , 413 nullptr, SK_ARRAY_COUNT(color s2),
414 SkShader::kClamp_TileMode, 414 SkShader::kClamp_TileMode,
415 flags[i], NULL)); 415 flags[i], nullptr));
416 paint1.setShader(sweep); 416 paint1.setShader(sweep);
417 paint2.setShader(radial1); 417 paint2.setShader(radial1);
418 paint3.setShader(radial2); 418 paint3.setShader(radial2);
419 419
420 canvas->drawCircle(cx, cy, radius, paint1); 420 canvas->drawCircle(cx, cy, radius, paint1);
421 canvas->drawCircle(cx, cy, radius, paint3); 421 canvas->drawCircle(cx, cy, radius, paint3);
422 canvas->drawCircle(cx, cy, radius, paint2); 422 canvas->drawCircle(cx, cy, radius, paint2);
423 423
424 canvas->translate(400, 0); 424 canvas->translate(400, 0);
425 } 425 }
(...skipping 12 matching lines...) Expand all
438 SkString onShortName() override { return SkString("radial_gradient3"); } 438 SkString onShortName() override { return SkString("radial_gradient3"); }
439 439
440 SkISize onISize() override { return SkISize::Make(500, 500); } 440 SkISize onISize() override { return SkISize::Make(500, 500); }
441 441
442 bool runAsBench() const override { return true; } 442 bool runAsBench() const override { return true; }
443 443
444 void onOnceBeforeDraw() override { 444 void onOnceBeforeDraw() override {
445 const SkPoint center = { 0, 0 }; 445 const SkPoint center = { 0, 0 };
446 const SkScalar kRadius = 3000; 446 const SkScalar kRadius = 3000;
447 const SkColor gColors[] = { 0xFFFFFFFF, 0xFF000000 }; 447 const SkColor gColors[] = { 0xFFFFFFFF, 0xFF000000 };
448 fShader.reset(SkGradientShader::CreateRadial(center, kRadius, gColors, N ULL, 2, 448 fShader.reset(SkGradientShader::CreateRadial(center, kRadius, gColors, n ullptr, 2,
449 SkShader::kClamp_TileMode)) ; 449 SkShader::kClamp_TileMode)) ;
450 } 450 }
451 451
452 void onDraw(SkCanvas* canvas) override { 452 void onDraw(SkCanvas* canvas) override {
453 SkPaint paint; 453 SkPaint paint;
454 paint.setShader(fShader); 454 paint.setShader(fShader);
455 canvas->drawRect(SkRect::MakeWH(500, 500), paint); 455 canvas->drawRect(SkRect::MakeWH(500, 500), paint);
456 } 456 }
457 457
458 private: 458 private:
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
527 (index + 1) * kHeight), paint); 527 (index + 1) * kHeight), paint);
528 } 528 }
529 } 529 }
530 530
531 private: 531 private:
532 typedef GM INHERITED; 532 typedef GM INHERITED;
533 }; 533 };
534 DEF_GM( return new LinearGradientGM; ) 534 DEF_GM( return new LinearGradientGM; )
535 535
536 } 536 }
OLDNEW
« no previous file with comments | « gm/gradient_matrix.cpp ('k') | gm/gradients_no_texture.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698