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 "SkGradientShader.h" | 10 #include "SkGradientShader.h" |
(...skipping 29 matching lines...) Expand all Loading... |
40 // Replicate chrome layout test - clipped pathed gradient-shaded text | 40 // Replicate chrome layout test - clipped pathed gradient-shaded text |
41 class ChromeGradTextGM1 : public GM { | 41 class ChromeGradTextGM1 : public GM { |
42 public: | 42 public: |
43 ChromeGradTextGM1() { } | 43 ChromeGradTextGM1() { } |
44 protected: | 44 protected: |
45 | 45 |
46 virtual SkString onShortName() { return SkString("chrome_gradtext1"); } | 46 virtual SkString onShortName() { return SkString("chrome_gradtext1"); } |
47 virtual SkISize onISize() { return SkISize::Make(500, 480); } | 47 virtual SkISize onISize() { return SkISize::Make(500, 480); } |
48 virtual void onDraw(SkCanvas* canvas) { | 48 virtual void onDraw(SkCanvas* canvas) { |
49 SkPaint paint; | 49 SkPaint paint; |
| 50 sk_tool_utils::set_portable_typeface(&paint); |
50 SkRect r = SkRect::MakeWH(SkIntToScalar(100), SkIntToScalar(100)); | 51 SkRect r = SkRect::MakeWH(SkIntToScalar(100), SkIntToScalar(100)); |
51 | 52 |
52 canvas->clipRect(r); | 53 canvas->clipRect(r); |
53 | 54 |
54 paint.setColor(SK_ColorRED); | 55 paint.setColor(SK_ColorRED); |
55 canvas->drawRect(r, paint); | 56 canvas->drawRect(r, paint); |
56 | 57 |
57 // Minimal repro doesn't require AA, LCD, or a nondefault typeface | 58 // Minimal repro doesn't require AA, LCD, or a nondefault typeface |
58 paint.setShader(make_chrome_solid())->unref(); | 59 paint.setShader(make_chrome_solid())->unref(); |
59 paint.setTextSize(SkIntToScalar(500)); | 60 paint.setTextSize(SkIntToScalar(500)); |
60 | 61 |
61 canvas->drawText("I", 1, 0, 100, paint); | 62 canvas->drawText("I", 1, 0, 100, paint); |
62 } | 63 } |
63 private: | 64 private: |
64 typedef GM INHERITED; | 65 typedef GM INHERITED; |
65 }; | 66 }; |
66 | 67 |
67 | 68 |
68 // Replicate chrome layout test - switching between solid & gadient text | 69 // Replicate chrome layout test - switching between solid & gadient text |
69 class ChromeGradTextGM2 : public GM { | 70 class ChromeGradTextGM2 : public GM { |
70 public: | 71 public: |
71 ChromeGradTextGM2() { } | 72 ChromeGradTextGM2() { } |
72 protected: | 73 protected: |
73 | 74 |
74 virtual SkString onShortName() { return SkString("chrome_gradtext2"); } | 75 virtual SkString onShortName() { return SkString("chrome_gradtext2"); } |
75 virtual SkISize onISize() { return SkISize::Make(500, 480); } | 76 virtual SkISize onISize() { return SkISize::Make(500, 480); } |
76 virtual void onDraw(SkCanvas* canvas) { | 77 virtual void onDraw(SkCanvas* canvas) { |
77 SkPaint paint; | 78 SkPaint paint; |
| 79 sk_tool_utils::set_portable_typeface(&paint); |
78 | 80 |
79 paint.setStyle(SkPaint::kFill_Style); | 81 paint.setStyle(SkPaint::kFill_Style); |
80 canvas->drawText("Normal Fill Text", 16, 0, 50, paint); | 82 canvas->drawText("Normal Fill Text", 16, 0, 50, paint); |
81 paint.setStyle(SkPaint::kStroke_Style); | 83 paint.setStyle(SkPaint::kStroke_Style); |
82 canvas->drawText("Normal Stroke Text", 18, 0, 100, paint); | 84 canvas->drawText("Normal Stroke Text", 18, 0, 100, paint); |
83 | 85 |
84 // Minimal repro doesn't require AA, LCD, or a nondefault typeface | 86 // Minimal repro doesn't require AA, LCD, or a nondefault typeface |
85 paint.setShader(make_chrome_solid())->unref(); | 87 paint.setShader(make_chrome_solid())->unref(); |
86 | 88 |
87 paint.setStyle(SkPaint::kFill_Style); | 89 paint.setStyle(SkPaint::kFill_Style); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 p.setAntiAlias(true); | 122 p.setAntiAlias(true); |
121 canvas->translate(0, paint.getTextSize() * 4/3); | 123 canvas->translate(0, paint.getTextSize() * 4/3); |
122 draw_text(canvas, p); | 124 draw_text(canvas, p); |
123 p.setLCDRenderText(true); | 125 p.setLCDRenderText(true); |
124 canvas->translate(0, paint.getTextSize() * 4/3); | 126 canvas->translate(0, paint.getTextSize() * 4/3); |
125 draw_text(canvas, p); | 127 draw_text(canvas, p); |
126 } | 128 } |
127 | 129 |
128 virtual void onDraw(SkCanvas* canvas) { | 130 virtual void onDraw(SkCanvas* canvas) { |
129 SkPaint paint; | 131 SkPaint paint; |
| 132 sk_tool_utils::set_portable_typeface(&paint); |
130 paint.setTextSize(SkIntToScalar(26)); | 133 paint.setTextSize(SkIntToScalar(26)); |
131 | 134 |
132 const SkISize& size = this->getISize(); | 135 const SkISize& size = this->getISize(); |
133 SkRect r = SkRect::MakeWH(SkIntToScalar(size.width()), | 136 SkRect r = SkRect::MakeWH(SkIntToScalar(size.width()), |
134 SkIntToScalar(size.height()) / 2); | 137 SkIntToScalar(size.height()) / 2); |
135 canvas->drawRect(r, paint); | 138 canvas->drawRect(r, paint); |
136 | 139 |
137 canvas->translate(SkIntToScalar(20), paint.getTextSize()); | 140 canvas->translate(SkIntToScalar(20), paint.getTextSize()); |
138 | 141 |
139 for (int i = 0; i < 2; ++i) { | 142 for (int i = 0; i < 2; ++i) { |
(...skipping 16 matching lines...) Expand all Loading... |
156 ////////////////////////////////////////////////////////////////////////////// | 159 ////////////////////////////////////////////////////////////////////////////// |
157 | 160 |
158 static GM* MyFactory(void*) { return new GradTextGM; } | 161 static GM* MyFactory(void*) { return new GradTextGM; } |
159 static GM* CMyFactory(void*) { return new ChromeGradTextGM1; } | 162 static GM* CMyFactory(void*) { return new ChromeGradTextGM1; } |
160 static GM* CMyFactory2(void*) { return new ChromeGradTextGM2; } | 163 static GM* CMyFactory2(void*) { return new ChromeGradTextGM2; } |
161 | 164 |
162 static GMRegistry reg(MyFactory); | 165 static GMRegistry reg(MyFactory); |
163 static GMRegistry Creg(CMyFactory); | 166 static GMRegistry Creg(CMyFactory); |
164 static GMRegistry Creg2(CMyFactory2); | 167 static GMRegistry Creg2(CMyFactory2); |
165 } | 168 } |
OLD | NEW |