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