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 "SkPath.h" | 10 #include "SkPath.h" |
11 #include "SkGradientShader.h" | 11 #include "SkGradientShader.h" |
12 #include "SkTypeface.h" | 12 #include "SkTypeface.h" |
13 | 13 |
14 static sk_sp<SkShader> make_heatGradient(const SkPoint pts[2]) { | 14 static sk_sp<SkShader> make_heatGradient(const SkPoint pts[2]) { |
15 const SkColor bw[] = { SK_ColorBLACK, SK_ColorWHITE }; | 15 const SkColor bw[] = { SK_ColorBLACK, SK_ColorWHITE }; |
16 | 16 |
17 return SkGradientShader::MakeLinear(pts, bw, nullptr, SK_ARRAY_COUNT(bw), | 17 return SkGradientShader::MakeLinear(pts, bw, nullptr, SK_ARRAY_COUNT(bw), |
18 SkShader::kClamp_TileMode); | 18 SkShader::kClamp_TileMode); |
19 } | 19 } |
20 | 20 |
21 static bool setFont(SkPaint* paint, const char name[]) { | 21 static bool setFont(SkPaint* paint, const char name[]) { |
22 paint->setTypeface(SkTypeface::MakeFromName(name, SkTypeface::kNormal)); | 22 paint->setTypeface(SkTypeface::MakeFromName(name, SkFontStyle())); |
23 return SkToBool(paint->getTypeface()); | 23 return SkToBool(paint->getTypeface()); |
24 } | 24 } |
25 | 25 |
26 /** | 26 /** |
27 Test a set of clipping problems discovered while writing blitAntiRect, | 27 Test a set of clipping problems discovered while writing blitAntiRect, |
28 and test all the code paths through the clipping blitters. | 28 and test all the code paths through the clipping blitters. |
29 Each region should show as a blue center surrounded by a 2px green | 29 Each region should show as a blue center surrounded by a 2px green |
30 border, with no red. | 30 border, with no red. |
31 */ | 31 */ |
32 | 32 |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 | 97 |
98 static sk_sp<SkShader> make_gradient(SkColor c) { | 98 static sk_sp<SkShader> make_gradient(SkColor c) { |
99 const SkPoint pts[] = { { 0, 0 }, { 240, 0 } }; | 99 const SkPoint pts[] = { { 0, 0 }, { 240, 0 } }; |
100 SkColor colors[2]; | 100 SkColor colors[2]; |
101 colors[0] = c; | 101 colors[0] = c; |
102 colors[1] = SkColorSetA(c, 0); | 102 colors[1] = SkColorSetA(c, 0); |
103 return SkGradientShader::MakeLinear(pts, colors, nullptr, 2, SkShader::kClam
p_TileMode); | 103 return SkGradientShader::MakeLinear(pts, colors, nullptr, 2, SkShader::kClam
p_TileMode); |
104 } | 104 } |
105 | 105 |
106 static void set_face(SkPaint* paint) { | 106 static void set_face(SkPaint* paint) { |
107 paint->setTypeface(SkTypeface::MakeFromName("serif", SkTypeface::kItalic)); | 107 paint->setTypeface(SkTypeface::MakeFromName("serif", |
| 108 SkFontStyle::FromOldStyle(SkTypeface::kItalic))); |
108 } | 109 } |
109 | 110 |
110 static void draw_pair(SkCanvas* canvas, SkPaint* paint, const sk_sp<SkShader>& s
hader) { | 111 static void draw_pair(SkCanvas* canvas, SkPaint* paint, const sk_sp<SkShader>& s
hader) { |
111 const char text[] = "Now is the time for all good"; | 112 const char text[] = "Now is the time for all good"; |
112 const size_t len = strlen(text); | 113 const size_t len = strlen(text); |
113 | 114 |
114 paint->setShader(nullptr); | 115 paint->setShader(nullptr); |
115 canvas->drawText(text, len, 10, 20, *paint); | 116 canvas->drawText(text, len, 10, 20, *paint); |
116 paint->setShader(SkShader::MakeColorShader(paint->getColor())); | 117 paint->setShader(SkShader::MakeColorShader(paint->getColor())); |
117 canvas->drawText(text, len, 10, 40, *paint); | 118 canvas->drawText(text, len, 10, 40, *paint); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
158 draw_pair(canvas, &paint, fShaders[i]); | 159 draw_pair(canvas, &paint, fShaders[i]); |
159 canvas->translate(0, 80); | 160 canvas->translate(0, 80); |
160 } | 161 } |
161 } | 162 } |
162 | 163 |
163 private: | 164 private: |
164 typedef skiagm::GM INHERITED; | 165 typedef skiagm::GM INHERITED; |
165 }; | 166 }; |
166 | 167 |
167 DEF_GM( return new GammaShaderTextGM; ) | 168 DEF_GM( return new GammaShaderTextGM; ) |
OLD | NEW |