OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2014 Google Inc. | 3 * Copyright 2014 Google Inc. |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 | 8 |
9 #include "gm.h" | 9 #include "gm.h" |
10 #if SK_SUPPORT_GPU | 10 #if SK_SUPPORT_GPU |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 const SkMatrix* localMatrix, GrColor* color, | 103 const SkMatrix* localMatrix, GrColor* color, |
104 GrFragmentProcessor** fp) const { | 104 GrFragmentProcessor** fp) const { |
105 *fp = SkNEW_ARGS(DCFP, (fDeviceMatrix)); | 105 *fp = SkNEW_ARGS(DCFP, (fDeviceMatrix)); |
106 *color = GrColorPackA4(paint.getAlpha()); | 106 *color = GrColorPackA4(paint.getAlpha()); |
107 return true; | 107 return true; |
108 } | 108 } |
109 | 109 |
110 class DCShaderGM : public GM { | 110 class DCShaderGM : public GM { |
111 public: | 111 public: |
112 DCShaderGM() { | 112 DCShaderGM() { |
113 this->setBGColor(0xFFAABBCC); | 113 this->setBGColor(sk_tool_utils::color_to_565(0xFFAABBCC)); |
114 } | 114 } |
115 | 115 |
116 ~DCShaderGM() override { | 116 ~DCShaderGM() override { |
117 for (int i = 0; i < fPrims.count(); ++i) { | 117 for (int i = 0; i < fPrims.count(); ++i) { |
118 SkDELETE(fPrims[i]); | 118 SkDELETE(fPrims[i]); |
119 } | 119 } |
120 } | 120 } |
121 | 121 |
122 protected: | 122 protected: |
123 | 123 |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
203 const char* text = this->text(); | 203 const char* text = this->text(); |
204 static const SkVector offset = SkVector::Make(10, 10); | 204 static const SkVector offset = SkVector::Make(10, 10); |
205 canvas->drawText(text, strlen(text), offset.fX, offset.fY, paint
); | 205 canvas->drawText(text, strlen(text), offset.fX, offset.fY, paint
); |
206 SkRect bounds; | 206 SkRect bounds; |
207 paint.measureText(text, strlen(text), &bounds); | 207 paint.measureText(text, strlen(text), &bounds); |
208 bounds.offset(offset); | 208 bounds.offset(offset); |
209 return bounds; | 209 return bounds; |
210 } | 210 } |
211 | 211 |
212 virtual void setFont(SkPaint* paint) { | 212 virtual void setFont(SkPaint* paint) { |
213 sk_tool_utils::set_portable_typeface(paint); | 213 sk_tool_utils::set_portable_typeface_always(paint); |
214 } | 214 } |
215 | 215 |
216 virtual const char* text() const { return "Hello, Skia!"; } | 216 virtual const char* text() const { return "Hello, Skia!"; } |
217 }; | 217 }; |
218 | 218 |
219 struct BmpText : public Text { | 219 struct BmpText : public Text { |
220 void setFont(SkPaint* paint) override { | 220 void setFont(SkPaint* paint) override { |
221 if (!fTypeface) { | 221 if (!fTypeface) { |
222 fTypeface.reset(GetResourceAsTypeface("/fonts/Funkster.ttf")
); | 222 fTypeface.reset(GetResourceAsTypeface("/fonts/Funkster.ttf")
); |
223 } | 223 } |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
304 }; | 304 }; |
305 | 305 |
306 SkTArray<Prim*> fPrims; | 306 SkTArray<Prim*> fPrims; |
307 | 307 |
308 typedef GM INHERITED; | 308 typedef GM INHERITED; |
309 }; | 309 }; |
310 | 310 |
311 DEF_GM( return SkNEW(DCShaderGM); ) | 311 DEF_GM( return SkNEW(DCShaderGM); ) |
312 } | 312 } |
313 #endif | 313 #endif |
OLD | NEW |