OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 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 "SkCanvas.h" | 9 #include "SkCanvas.h" |
10 #include "SkGradientShader.h" | 10 #include "SkGradientShader.h" |
11 #include "SkPath.h" | 11 #include "SkPath.h" |
12 #include "SkSurface.h" | 12 #include "SkSurface.h" |
13 | 13 |
14 #if SK_SUPPORT_GPU | 14 #if SK_SUPPORT_GPU |
15 #include "SkGpuDevice.h" | 15 #include "SkGpuDevice.h" |
16 #endif | 16 #endif |
17 | 17 |
18 #define W SkIntToScalar(80) | 18 #define W SkIntToScalar(80) |
19 #define H SkIntToScalar(60) | 19 #define H SkIntToScalar(60) |
20 | 20 |
21 typedef void (*PaintProc)(SkPaint*); | 21 typedef void (*PaintProc)(SkPaint*); |
22 | 22 |
23 static void identity_paintproc(SkPaint* paint) { | 23 static void identity_paintproc(SkPaint* paint) { |
24 paint->setShader(nullptr); | 24 paint->setShader(nullptr); |
25 } | 25 } |
26 | 26 |
27 static void gradient_paintproc(SkPaint* paint) { | 27 static void gradient_paintproc(SkPaint* paint) { |
28 const SkColor colors[] = { SK_ColorGREEN, SK_ColorBLUE }; | 28 const SkColor colors[] = { SK_ColorGREEN, SK_ColorBLUE }; |
29 const SkPoint pts[] = { { 0, 0 }, { W, H } }; | 29 const SkPoint pts[] = { { 0, 0 }, { W, H } }; |
30 paint->setShader(SkGradientShader::MakeLinear(pts, colors, nullptr, SK_ARRAY
_COUNT(colors), | 30 SkShader* s = SkGradientShader::CreateLinear(pts, colors, nullptr, |
31 SkShader::kClamp_TileMode)); | 31 SK_ARRAY_COUNT(colors), |
| 32 SkShader::kClamp_TileMode); |
| 33 paint->setShader(s)->unref(); |
32 } | 34 } |
33 | 35 |
34 typedef void (*Proc)(SkCanvas*, const SkPaint&); | 36 typedef void (*Proc)(SkCanvas*, const SkPaint&); |
35 | 37 |
36 static void draw_hair(SkCanvas* canvas, const SkPaint& paint) { | 38 static void draw_hair(SkCanvas* canvas, const SkPaint& paint) { |
37 SkPaint p(paint); | 39 SkPaint p(paint); |
38 p.setStrokeWidth(0); | 40 p.setStrokeWidth(0); |
39 canvas->drawLine(0, 0, W, H, p); | 41 canvas->drawLine(0, 0, W, H, p); |
40 } | 42 } |
41 | 43 |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 surf->draw(canvas, 0, 0, nullptr); | 142 surf->draw(canvas, 0, 0, nullptr); |
141 } | 143 } |
142 | 144 |
143 private: | 145 private: |
144 typedef skiagm::GM INHERITED; | 146 typedef skiagm::GM INHERITED; |
145 }; | 147 }; |
146 | 148 |
147 /////////////////////////////////////////////////////////////////////////////// | 149 /////////////////////////////////////////////////////////////////////////////// |
148 | 150 |
149 DEF_GM(return new SrcModeGM;) | 151 DEF_GM(return new SrcModeGM;) |
OLD | NEW |