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

Side by Side Diff: gm/gradients.cpp

Issue 23637008: Split radial_gradients2 GM into two to reproduce its bug. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: one gm, side by side Created 7 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | 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 "gm.h" 8 #include "gm.h"
9 #include "SkGradientShader.h" 9 #include "SkGradientShader.h"
10 10
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after
360 typedef GM INHERITED; 360 typedef GM INHERITED;
361 }; 361 };
362 362
363 363
364 class RadialGradient2GM : public GM { 364 class RadialGradient2GM : public GM {
365 public: 365 public:
366 RadialGradient2GM() {} 366 RadialGradient2GM() {}
367 367
368 protected: 368 protected:
369 SkString onShortName() { return SkString("radial_gradient2"); } 369 SkString onShortName() { return SkString("radial_gradient2"); }
370 virtual SkISize onISize() { return make_isize(400, 400); } 370 virtual SkISize onISize() { return make_isize(800, 400); }
371 void drawBG(SkCanvas* canvas) { 371 void drawBG(SkCanvas* canvas) {
372 canvas->drawColor(0xFF000000); 372 canvas->drawColor(0xFF000000);
373 } 373 }
374 374
375 // Reproduces the example given in bug 7671058. 375 // Reproduces the example given in bug 7671058.
376 virtual void onDraw(SkCanvas* canvas) { 376 virtual void onDraw(SkCanvas* canvas) {
377 SkPaint paint1, paint2, paint3; 377 SkPaint paint1, paint2, paint3;
378 paint1.setStyle(SkPaint::kFill_Style); 378 paint1.setStyle(SkPaint::kFill_Style);
379 paint2.setStyle(SkPaint::kFill_Style); 379 paint2.setStyle(SkPaint::kFill_Style);
380 paint3.setStyle(SkPaint::kFill_Style); 380 paint3.setStyle(SkPaint::kFill_Style);
381 381
382 const SkColor sweep_colors[] = 382 const SkColor sweep_colors[] =
383 { 0xFFFF0000, 0xFFFFFF00, 0xFF00FF00, 0xFF00FFFF, 0xFF0000FF, 0xFFFF 00FF, 0xFFFF0000 }; 383 { 0xFFFF0000, 0xFFFFFF00, 0xFF00FF00, 0xFF00FFFF, 0xFF0000FF, 0xFFFF 00FF, 0xFFFF0000 };
384 const SkColor colors1[] = { 0xFFFFFFFF, 0x00000000 }; 384 const SkColor colors1[] = { 0xFFFFFFFF, 0x00000000 };
385 const SkColor colors2[] = { 0xFF000000, 0x00000000 }; 385 const SkColor colors2[] = { 0xFF000000, 0x00000000 };
386 386
387 const SkScalar cx = 200, cy = 200, radius = 150; 387 const SkScalar cx = 200, cy = 200, radius = 150;
388 SkPoint center; 388 SkPoint center;
389 center.set(cx, cy); 389 center.set(cx, cy);
390 390
391 SkAutoTUnref<SkShader> sweep( 391 // We can either interpolate endpoints and premultiply each point (defau lt, more precision),
392 SkGradientShader::CreateSweep(cx, cy, sweep_colors, 392 // or premultiply the endpoints first, avoiding the need to premultiply each point (cheap).
393 NULL, SK_ARRAY_COUNT(sweep_colors) )); 393 const uint32_t flags[] = { 0, SkGradientShader::kInterpolateColorsInPrem ul_Flag };
394 SkAutoTUnref<SkShader> radial1(
395 SkGradientShader::CreateRadial(center, radius, colors1,
396 NULL, SK_ARRAY_COUNT(colors1),
397 SkShader::kClamp_TileMode));
398 SkAutoTUnref<SkShader> radial2(
399 SkGradientShader::CreateRadial(center, radius, colors2,
400 NULL, SK_ARRAY_COUNT(colors2),
401 SkShader::kClamp_TileMode));
402 paint1.setShader(sweep);
403 paint2.setShader(radial1);
404 paint3.setShader(radial2);
405 394
406 canvas->drawCircle(cx, cy, radius, paint1); 395 for (size_t i = 0; i < SK_ARRAY_COUNT(flags); i++) {
407 canvas->drawCircle(cx, cy, radius, paint3); 396 SkAutoTUnref<SkShader> sweep(
408 canvas->drawCircle(cx, cy, radius, paint2); 397 SkGradientShader::CreateSweep(cx, cy, sweep_colors,
398 NULL, SK_ARRAY_COUNT(sweep_col ors),
399 NULL, flags[i]));
400 SkAutoTUnref<SkShader> radial1(
401 SkGradientShader::CreateRadial(center, radius, colors1,
402 NULL, SK_ARRAY_COUNT(colors1) ,
403 SkShader::kClamp_TileMode,
404 NULL, flags[i]));
405 SkAutoTUnref<SkShader> radial2(
406 SkGradientShader::CreateRadial(center, radius, colors2,
407 NULL, SK_ARRAY_COUNT(colors2) ,
408 SkShader::kClamp_TileMode,
409 NULL, flags[i]));
410 paint1.setShader(sweep);
411 paint2.setShader(radial1);
412 paint3.setShader(radial2);
413
414 canvas->drawCircle(cx, cy, radius, paint1);
415 canvas->drawCircle(cx, cy, radius, paint3);
416 canvas->drawCircle(cx, cy, radius, paint2);
417
418 canvas->translate(400, 0);
419 }
409 } 420 }
410 421
411 private: 422 private:
412 typedef GM INHERITED; 423 typedef GM INHERITED;
413 }; 424 };
414 425
415 /////////////////////////////////////////////////////////////////////////////// 426 ///////////////////////////////////////////////////////////////////////////////
416 427
417 static GM* MyFactory(void*) { return new GradientsGM; } 428 static GM* MyFactory(void*) { return new GradientsGM; }
418 static GMRegistry reg(MyFactory); 429 static GMRegistry reg(MyFactory);
419 430
420 static GM* MyFactory2(void*) { return new GradientsDegenrate2PointGM; } 431 static GM* MyFactory2(void*) { return new GradientsDegenrate2PointGM; }
421 static GMRegistry reg2(MyFactory2); 432 static GMRegistry reg2(MyFactory2);
422 433
423 static GM* MyFactory3(void*) { return new ClampedGradientsGM; } 434 static GM* MyFactory3(void*) { return new ClampedGradientsGM; }
424 static GMRegistry reg3(MyFactory3); 435 static GMRegistry reg3(MyFactory3);
425 436
426 static GM* MyFactory4(void*) { return new RadialGradientGM; } 437 static GM* MyFactory4(void*) { return new RadialGradientGM; }
427 static GMRegistry reg4(MyFactory4); 438 static GMRegistry reg4(MyFactory4);
428 439
429 static GM* MyFactory5(void*) { return new GradientsLocalPerspectiveGM; } 440 static GM* MyFactory5(void*) { return new GradientsLocalPerspectiveGM; }
430 static GMRegistry reg5(MyFactory5); 441 static GMRegistry reg5(MyFactory5);
431 442
432 static GM* MyFactory6(void*) { return new GradientsViewPerspectiveGM; } 443 static GM* MyFactory6(void*) { return new GradientsViewPerspectiveGM; }
433 static GMRegistry reg6(MyFactory6); 444 static GMRegistry reg6(MyFactory6);
434 445
435 static GM* MyFactory7(void*) { return new RadialGradient2GM; } 446 static GM* MyFactory7(void*) { return new RadialGradient2GM; }
436 static GMRegistry reg7(MyFactory7); 447 static GMRegistry reg7(MyFactory7);
437 } 448 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698