OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 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 25 matching lines...) Expand all Loading... |
36 } | 36 } |
37 | 37 |
38 class ShallowGradientGM : public skiagm::GM { | 38 class ShallowGradientGM : public skiagm::GM { |
39 public: | 39 public: |
40 ShallowGradientGM(MakeShaderProc proc, const char name[]) : fProc(proc) { | 40 ShallowGradientGM(MakeShaderProc proc, const char name[]) : fProc(proc) { |
41 fName.printf("shallow_gradient_%s", name); | 41 fName.printf("shallow_gradient_%s", name); |
42 } | 42 } |
43 | 43 |
44 protected: | 44 protected: |
45 | 45 |
46 SkString onShortName() SK_OVERRIDE { | 46 SkString onShortName() override { |
47 return fName; | 47 return fName; |
48 } | 48 } |
49 | 49 |
50 SkISize onISize() SK_OVERRIDE { | 50 SkISize onISize() override { |
51 return SkISize::Make(800, 800); | 51 return SkISize::Make(800, 800); |
52 } | 52 } |
53 | 53 |
54 void onDraw(SkCanvas* canvas) SK_OVERRIDE { | 54 void onDraw(SkCanvas* canvas) override { |
55 const SkColor colors[] = { 0xFF555555, 0xFF444444 }; | 55 const SkColor colors[] = { 0xFF555555, 0xFF444444 }; |
56 const int colorCount = SK_ARRAY_COUNT(colors); | 56 const int colorCount = SK_ARRAY_COUNT(colors); |
57 | 57 |
58 SkRect r = { 0, 0, this->width(), this->height() }; | 58 SkRect r = { 0, 0, this->width(), this->height() }; |
59 SkSize size = SkSize::Make(r.width(), r.height()); | 59 SkSize size = SkSize::Make(r.width(), r.height()); |
60 | 60 |
61 SkPaint paint; | 61 SkPaint paint; |
62 paint.setShader(fProc(colors, colorCount, size))->unref(); | 62 paint.setShader(fProc(colors, colorCount, size))->unref(); |
63 canvas->drawRect(r, paint); | 63 canvas->drawRect(r, paint); |
64 } | 64 } |
65 | 65 |
66 private: | 66 private: |
67 MakeShaderProc fProc; | 67 MakeShaderProc fProc; |
68 SkString fName; | 68 SkString fName; |
69 | 69 |
70 typedef skiagm::GM INHERITED; | 70 typedef skiagm::GM INHERITED; |
71 }; | 71 }; |
72 | 72 |
73 /////////////////////////////////////////////////////////////////////////////// | 73 /////////////////////////////////////////////////////////////////////////////// |
74 | 74 |
75 DEF_GM( return new ShallowGradientGM(shader_linear, "linear"); ) | 75 DEF_GM( return new ShallowGradientGM(shader_linear, "linear"); ) |
76 DEF_GM( return new ShallowGradientGM(shader_radial, "radial"); ) | 76 DEF_GM( return new ShallowGradientGM(shader_radial, "radial"); ) |
77 DEF_GM( return new ShallowGradientGM(shader_conical, "conical"); ) | 77 DEF_GM( return new ShallowGradientGM(shader_conical, "conical"); ) |
78 DEF_GM( return new ShallowGradientGM(shader_sweep, "sweep"); ) | 78 DEF_GM( return new ShallowGradientGM(shader_sweep, "sweep"); ) |
OLD | NEW |