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

Side by Side Diff: gm/gradients.cpp

Issue 1269723002: add radial gradient hard stop test (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 4 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 | « 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 * 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 442 matching lines...) Expand 10 before | Expand all | Expand 10 after
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:
459 typedef GM INHERITED; 459 typedef GM INHERITED;
460 }; 460 };
461 DEF_GM( return new RadialGradient3GM; ) 461 DEF_GM( return new RadialGradient3GM; )
462 462
463 class RadialGradient4GM : public GM {
464 SkAutoTUnref<SkShader> fShader;
465
466 protected:
467 SkString onShortName() override { return SkString("radial_gradient4"); }
468
469 SkISize onISize() override { return SkISize::Make(500, 500); }
470
471 void onOnceBeforeDraw() override {
472 const SkPoint center = { 250, 250 };
473 const SkScalar kRadius = 250;
474 const SkColor colors[] = { SK_ColorRED, SK_ColorRED, SK_ColorWHITE, SK_C olorWHITE,
475 SK_ColorRED };
476 const SkScalar pos[] = { 0, .4f, .4f, .8f, .8f, 1 };
477 fShader.reset(SkGradientShader::CreateRadial(center, kRadius, colors, po s,
478 SK_ARRAY_COUNT(gColors), SkShader::kClamp_TileMode));
479 }
480
481 void onDraw(SkCanvas* canvas) override {
482 SkPaint paint;
483 paint.setAntiAlias(true);
484 paint.setShader(fShader);
485 canvas->drawRect(SkRect::MakeWH(500, 500), paint);
486 }
487
488 private:
489 typedef GM INHERITED;
490 };
491 DEF_GM( return new RadialGradient4GM; )
492
463 } 493 }
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