Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(425)

Side by Side Diff: gm/gradtext.cpp

Issue 1234233003: make gradtext quadpaths gm portable (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | gm/quadpaths.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 sk_tool_utils::set_portable_typeface_always(&paint);
51 SkRect r = SkRect::MakeWH(SkIntToScalar(100), SkIntToScalar(100)); 51 SkRect r = SkRect::MakeWH(SkIntToScalar(100), SkIntToScalar(100));
52 52
53 canvas->clipRect(r); 53 canvas->clipRect(r);
54 54
55 paint.setColor(SK_ColorRED); 55 paint.setColor(SK_ColorRED);
56 canvas->drawRect(r, paint); 56 canvas->drawRect(r, paint);
57 57
58 // Minimal repro doesn't require AA, LCD, or a nondefault typeface 58 // Minimal repro doesn't require AA, LCD, or a nondefault typeface
59 paint.setShader(make_chrome_solid())->unref(); 59 paint.setShader(make_chrome_solid())->unref();
60 paint.setTextSize(SkIntToScalar(500)); 60 paint.setTextSize(SkIntToScalar(500));
61 61
62 canvas->drawText("I", 1, 0, 100, paint); 62 canvas->drawText("I", 1, 0, 100, paint);
63 } 63 }
64 private: 64 private:
65 typedef GM INHERITED; 65 typedef GM INHERITED;
66 }; 66 };
67 67
68 68
69 // Replicate chrome layout test - switching between solid & gadient text 69 // Replicate chrome layout test - switching between solid & gradient text
70 class ChromeGradTextGM2 : public GM { 70 class ChromeGradTextGM2 : public GM {
71 public: 71 public:
72 ChromeGradTextGM2() { } 72 ChromeGradTextGM2() { }
73 protected: 73 protected:
74 74
75 virtual SkString onShortName() { return SkString("chrome_gradtext2"); } 75 virtual SkString onShortName() { return SkString("chrome_gradtext2"); }
76 virtual SkISize onISize() { return SkISize::Make(500, 480); } 76 virtual SkISize onISize() { return SkISize::Make(500, 480); }
77 virtual void onDraw(SkCanvas* canvas) { 77 virtual void onDraw(SkCanvas* canvas) {
78 SkPaint paint; 78 SkPaint paint;
79 sk_tool_utils::set_portable_typeface(&paint); 79 sk_tool_utils::set_portable_typeface_always(&paint);
80 80
81 paint.setStyle(SkPaint::kFill_Style); 81 paint.setStyle(SkPaint::kFill_Style);
82 canvas->drawText("Normal Fill Text", 16, 0, 50, paint); 82 canvas->drawText("Normal Fill Text", 16, 0, 50, paint);
83 paint.setStyle(SkPaint::kStroke_Style); 83 paint.setStyle(SkPaint::kStroke_Style);
84 canvas->drawText("Normal Stroke Text", 18, 0, 100, paint); 84 canvas->drawText("Normal Stroke Text", 18, 0, 100, paint);
85 85
86 // Minimal repro doesn't require AA, LCD, or a nondefault typeface 86 // Minimal repro doesn't require AA, LCD, or a nondefault typeface
87 paint.setShader(make_chrome_solid())->unref(); 87 paint.setShader(make_chrome_solid())->unref();
88 88
89 paint.setStyle(SkPaint::kFill_Style); 89 paint.setStyle(SkPaint::kFill_Style);
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 p.setAntiAlias(true); 122 p.setAntiAlias(true);
123 canvas->translate(0, paint.getTextSize() * 4/3); 123 canvas->translate(0, paint.getTextSize() * 4/3);
124 draw_text(canvas, p); 124 draw_text(canvas, p);
125 p.setLCDRenderText(true); 125 p.setLCDRenderText(true);
126 canvas->translate(0, paint.getTextSize() * 4/3); 126 canvas->translate(0, paint.getTextSize() * 4/3);
127 draw_text(canvas, p); 127 draw_text(canvas, p);
128 } 128 }
129 129
130 void onDraw(SkCanvas* canvas) override { 130 void onDraw(SkCanvas* canvas) override {
131 SkPaint paint; 131 SkPaint paint;
132 sk_tool_utils::set_portable_typeface(&paint); 132 sk_tool_utils::set_portable_typeface_always(&paint);
133 paint.setTextSize(SkIntToScalar(26)); 133 paint.setTextSize(SkIntToScalar(26));
134 134
135 const SkISize& size = this->getISize(); 135 const SkISize& size = this->getISize();
136 SkRect r = SkRect::MakeWH(SkIntToScalar(size.width()), 136 SkRect r = SkRect::MakeWH(SkIntToScalar(size.width()),
137 SkIntToScalar(size.height()) / 2); 137 SkIntToScalar(size.height()) / 2);
138 canvas->drawRect(r, paint); 138 canvas->drawRect(r, paint);
139 139
140 canvas->translate(SkIntToScalar(20), paint.getTextSize()); 140 canvas->translate(SkIntToScalar(20), paint.getTextSize());
141 141
142 for (int i = 0; i < 2; ++i) { 142 for (int i = 0; i < 2; ++i) {
(...skipping 16 matching lines...) Expand all
159 ////////////////////////////////////////////////////////////////////////////// 159 //////////////////////////////////////////////////////////////////////////////
160 160
161 static GM* MyFactory(void*) { return new GradTextGM; } 161 static GM* MyFactory(void*) { return new GradTextGM; }
162 static GM* CMyFactory(void*) { return new ChromeGradTextGM1; } 162 static GM* CMyFactory(void*) { return new ChromeGradTextGM1; }
163 static GM* CMyFactory2(void*) { return new ChromeGradTextGM2; } 163 static GM* CMyFactory2(void*) { return new ChromeGradTextGM2; }
164 164
165 static GMRegistry reg(MyFactory); 165 static GMRegistry reg(MyFactory);
166 static GMRegistry Creg(CMyFactory); 166 static GMRegistry Creg(CMyFactory);
167 static GMRegistry Creg2(CMyFactory2); 167 static GMRegistry Creg2(CMyFactory2);
168 } 168 }
OLDNEW
« no previous file with comments | « no previous file | gm/quadpaths.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698