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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 | 45 |
46 SkString onShortName() override { | 46 SkString onShortName() override { |
47 return fName; | 47 return fName; |
48 } | 48 } |
49 | 49 |
50 SkISize onISize() 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) override { | 54 void onDraw(SkCanvas* canvas) override { |
55 const SkColor colors[] = { 0xFF555555, 0xFF444444 }; | 55 const SkColor colors[] = { sk_tool_utils::color_to_565(0xFF555555), |
| 56 sk_tool_utils::color_to_565(0xFF444444) }; |
56 const int colorCount = SK_ARRAY_COUNT(colors); | 57 const int colorCount = SK_ARRAY_COUNT(colors); |
57 | 58 |
58 SkRect r = { 0, 0, this->width(), this->height() }; | 59 SkRect r = { 0, 0, this->width(), this->height() }; |
59 SkSize size = SkSize::Make(r.width(), r.height()); | 60 SkSize size = SkSize::Make(r.width(), r.height()); |
60 | 61 |
61 SkPaint paint; | 62 SkPaint paint; |
62 paint.setShader(fProc(colors, colorCount, size))->unref(); | 63 paint.setShader(fProc(colors, colorCount, size))->unref(); |
63 canvas->drawRect(r, paint); | 64 canvas->drawRect(r, paint); |
64 } | 65 } |
65 | 66 |
66 private: | 67 private: |
67 MakeShaderProc fProc; | 68 MakeShaderProc fProc; |
68 SkString fName; | 69 SkString fName; |
69 | 70 |
70 typedef skiagm::GM INHERITED; | 71 typedef skiagm::GM INHERITED; |
71 }; | 72 }; |
72 | 73 |
73 /////////////////////////////////////////////////////////////////////////////// | 74 /////////////////////////////////////////////////////////////////////////////// |
74 | 75 |
75 DEF_GM( return new ShallowGradientGM(shader_linear, "linear"); ) | 76 DEF_GM( return new ShallowGradientGM(shader_linear, "linear"); ) |
76 DEF_GM( return new ShallowGradientGM(shader_radial, "radial"); ) | 77 DEF_GM( return new ShallowGradientGM(shader_radial, "radial"); ) |
77 DEF_GM( return new ShallowGradientGM(shader_conical, "conical"); ) | 78 DEF_GM( return new ShallowGradientGM(shader_conical, "conical"); ) |
78 DEF_GM( return new ShallowGradientGM(shader_sweep, "sweep"); ) | 79 DEF_GM( return new ShallowGradientGM(shader_sweep, "sweep"); ) |
OLD | NEW |