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

Side by Side Diff: gm/gammatext.cpp

Issue 1818043002: SkTypeface::MakeFromName to take SkFontStyle. (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: Android fix + nit fix Created 4 years, 6 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 | « gm/fontcache.cpp ('k') | gm/textblob.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 "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
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
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; )
OLDNEW
« no previous file with comments | « gm/fontcache.cpp ('k') | gm/textblob.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698