OLD | NEW |
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 "SkCanvas.h" | 9 #include "SkCanvas.h" |
10 #include "SkColorPriv.h" | 10 #include "SkColorPriv.h" |
11 #include "SkShader.h" | 11 #include "SkShader.h" |
12 | 12 |
13 #include "SkArithmeticMode.h" | 13 #include "SkArithmeticMode.h" |
14 #include "SkGradientShader.h" | 14 #include "SkGradientShader.h" |
15 #define WW 100 | 15 #define WW 100 |
16 #define HH 32 | 16 #define HH 32 |
17 | 17 |
18 static SkBitmap make_bm() { | 18 static SkBitmap make_bm() { |
19 SkBitmap bm; | 19 SkBitmap bm; |
20 bm.allocN32Pixels(WW, HH); | 20 bm.allocN32Pixels(WW, HH); |
21 bm.eraseColor(SK_ColorTRANSPARENT); | 21 bm.eraseColor(SK_ColorTRANSPARENT); |
22 return bm; | 22 return skstd::move(bm); |
23 } | 23 } |
24 | 24 |
25 static SkBitmap make_src() { | 25 static SkBitmap make_src() { |
26 SkBitmap bm = make_bm(); | 26 SkBitmap bm = make_bm(); |
27 SkCanvas canvas(bm); | 27 SkCanvas canvas(bm); |
28 SkPaint paint; | 28 SkPaint paint; |
29 SkPoint pts[] = { {0, 0}, {SkIntToScalar(WW), SkIntToScalar(HH)} }; | 29 SkPoint pts[] = { {0, 0}, {SkIntToScalar(WW), SkIntToScalar(HH)} }; |
30 SkColor colors[] = { | 30 SkColor colors[] = { |
31 SK_ColorTRANSPARENT, SK_ColorGREEN, SK_ColorCYAN, | 31 SK_ColorTRANSPARENT, SK_ColorGREEN, SK_ColorCYAN, |
32 SK_ColorRED, SK_ColorMAGENTA, SK_ColorWHITE, | 32 SK_ColorRED, SK_ColorMAGENTA, SK_ColorWHITE, |
33 }; | 33 }; |
34 SkShader* s = SkGradientShader::CreateLinear(pts, colors, nullptr, SK_ARRAY_
COUNT(colors), | 34 SkShader* s = SkGradientShader::CreateLinear(pts, colors, nullptr, SK_ARRAY_
COUNT(colors), |
35 SkShader::kClamp_TileMode); | 35 SkShader::kClamp_TileMode); |
36 paint.setShader(s)->unref(); | 36 paint.setShader(s)->unref(); |
37 canvas.drawPaint(paint); | 37 canvas.drawPaint(paint); |
38 return bm; | 38 return skstd::move(bm); |
39 } | 39 } |
40 | 40 |
41 static SkBitmap make_dst() { | 41 static SkBitmap make_dst() { |
42 SkBitmap bm = make_bm(); | 42 SkBitmap bm = make_bm(); |
43 SkCanvas canvas(bm); | 43 SkCanvas canvas(bm); |
44 SkPaint paint; | 44 SkPaint paint; |
45 SkPoint pts[] = { {0, SkIntToScalar(HH)}, {SkIntToScalar(WW), 0} }; | 45 SkPoint pts[] = { {0, SkIntToScalar(HH)}, {SkIntToScalar(WW), 0} }; |
46 SkColor colors[] = { | 46 SkColor colors[] = { |
47 SK_ColorBLUE, SK_ColorYELLOW, SK_ColorBLACK, SK_ColorGREEN, | 47 SK_ColorBLUE, SK_ColorYELLOW, SK_ColorBLACK, SK_ColorGREEN, |
48 sk_tool_utils::color_to_565(SK_ColorGRAY) | 48 sk_tool_utils::color_to_565(SK_ColorGRAY) |
49 }; | 49 }; |
50 SkShader* s = SkGradientShader::CreateLinear(pts, colors, nullptr, SK_ARRAY_
COUNT(colors), | 50 SkShader* s = SkGradientShader::CreateLinear(pts, colors, nullptr, SK_ARRAY_
COUNT(colors), |
51 SkShader::kClamp_TileMode); | 51 SkShader::kClamp_TileMode); |
52 paint.setShader(s)->unref(); | 52 paint.setShader(s)->unref(); |
53 canvas.drawPaint(paint); | 53 canvas.drawPaint(paint); |
54 return bm; | 54 return skstd::move(bm); |
55 } | 55 } |
56 | 56 |
57 static void show_k_text(SkCanvas* canvas, SkScalar x, SkScalar y, const SkScalar
k[]) { | 57 static void show_k_text(SkCanvas* canvas, SkScalar x, SkScalar y, const SkScalar
k[]) { |
58 SkPaint paint; | 58 SkPaint paint; |
59 paint.setTextSize(SkIntToScalar(24)); | 59 paint.setTextSize(SkIntToScalar(24)); |
60 paint.setAntiAlias(true); | 60 paint.setAntiAlias(true); |
61 sk_tool_utils::set_portable_typeface(&paint); | 61 sk_tool_utils::set_portable_typeface(&paint); |
62 for (int i = 0; i < 4; ++i) { | 62 for (int i = 0; i < 4; ++i) { |
63 SkString str; | 63 SkString str; |
64 str.appendScalar(k[i]); | 64 str.appendScalar(k[i]); |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
158 } | 158 } |
159 } | 159 } |
160 | 160 |
161 private: | 161 private: |
162 typedef GM INHERITED; | 162 typedef GM INHERITED; |
163 }; | 163 }; |
164 | 164 |
165 /////////////////////////////////////////////////////////////////////////////// | 165 /////////////////////////////////////////////////////////////////////////////// |
166 | 166 |
167 DEF_GM( return new ArithmodeGM; ) | 167 DEF_GM( return new ArithmodeGM; ) |
OLD | NEW |