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

Side by Side Diff: gm/poly2poly.cpp

Issue 1257773002: rename portable_typeface_always to portable_typeface (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: remove unncessary change to path test Created 5 years, 4 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/pixelsnap.cpp ('k') | gm/samplerstress.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 "Resources.h"
10 #include "SkTypeface.h"
9 11
10 class SkJSCanvas { 12 class SkJSCanvas {
11 public: 13 public:
12 SkJSCanvas(SkCanvas* target); 14 SkJSCanvas(SkCanvas* target);
13 ~SkJSCanvas(); 15 ~SkJSCanvas();
14 16
15 void save(); 17 void save();
16 void restore(); 18 void restore();
17 19
18 double lineWidth; 20 double lineWidth;
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 canvas->drawRectCoords(0, 0, D, D, *paint); 210 canvas->drawRectCoords(0, 0, D, D, *paint);
209 canvas->drawLine(0, 0, D, D, *paint); 211 canvas->drawLine(0, 0, D, D, *paint);
210 canvas->drawLine(0, D, D, 0, *paint); 212 canvas->drawLine(0, D, D, 0, *paint);
211 213
212 SkPaint::FontMetrics fm; 214 SkPaint::FontMetrics fm;
213 paint->getFontMetrics(&fm); 215 paint->getFontMetrics(&fm);
214 paint->setColor(SK_ColorRED); 216 paint->setColor(SK_ColorRED);
215 paint->setStyle(SkPaint::kFill_Style); 217 paint->setStyle(SkPaint::kFill_Style);
216 SkScalar x = D/2; 218 SkScalar x = D/2;
217 SkScalar y = D/2 - (fm.fAscent + fm.fDescent)/2; 219 SkScalar y = D/2 - (fm.fAscent + fm.fDescent)/2;
218 SkString str; 220 uint16_t glyphID = 3; // X
219 str.appendS32(count); 221 canvas->drawText((void*) &glyphID, sizeof(glyphID), x, y, *paint);
220 canvas->drawText(str.c_str(), str.size(), x, y, *paint); 222 canvas->restore();
223 }
221 224
222 canvas->restore(); 225 void onOnceBeforeDraw() override {
226 fEmFace.reset(GetResourceAsTypeface("/fonts/Em.ttf"));
223 } 227 }
224 228
225 void onDraw(SkCanvas* canvas) override { 229 void onDraw(SkCanvas* canvas) override {
226 if (false) { test_stroke(canvas); return; } 230 if (false) { test_stroke(canvas); return; }
227 231
228 SkPaint paint; 232 SkPaint paint;
229 paint.setAntiAlias(true); 233 paint.setAntiAlias(true);
230 sk_tool_utils::set_portable_typeface(&paint); 234 paint.setTypeface(fEmFace);
235 paint.setTextEncoding(SkPaint::kGlyphID_TextEncoding);
231 paint.setStrokeWidth(SkIntToScalar(4)); 236 paint.setStrokeWidth(SkIntToScalar(4));
232 paint.setTextSize(SkIntToScalar(40)); 237 paint.setTextSize(SkIntToScalar(40));
233 paint.setTextAlign(SkPaint::kCenter_Align); 238 paint.setTextAlign(SkPaint::kCenter_Align);
234 239
235 canvas->save(); 240 canvas->save();
236 canvas->translate(SkIntToScalar(10), SkIntToScalar(10)); 241 canvas->translate(SkIntToScalar(10), SkIntToScalar(10));
237 // translate (1 point) 242 // translate (1 point)
238 const int src1[] = { 0, 0 }; 243 const int src1[] = { 0, 0 };
239 const int dst1[] = { 5, 5 }; 244 const int dst1[] = { 5, 5 };
240 doDraw(canvas, &paint, src1, dst1, 1); 245 doDraw(canvas, &paint, src1, dst1, 1);
(...skipping 19 matching lines...) Expand all
260 canvas->translate(SkIntToScalar(160), SkIntToScalar(110)); 265 canvas->translate(SkIntToScalar(160), SkIntToScalar(110));
261 // perspective (4 points) 266 // perspective (4 points)
262 const int src4[] = { 0, 0, 64, 0, 64, 64, 0, 64 }; 267 const int src4[] = { 0, 0, 64, 0, 64, 64, 0, 64 };
263 const int dst4[] = { 0, 0, 96, 0, 64, 96, 0, 64 }; 268 const int dst4[] = { 0, 0, 96, 0, 64, 96, 0, 64 };
264 doDraw(canvas, &paint, src4, dst4, 4); 269 doDraw(canvas, &paint, src4, dst4, 4);
265 canvas->restore(); 270 canvas->restore();
266 } 271 }
267 272
268 private: 273 private:
269 typedef skiagm::GM INHERITED; 274 typedef skiagm::GM INHERITED;
275 SkAutoTUnref<SkTypeface> fEmFace;
270 }; 276 };
271 277
272 ////////////////////////////////////////////////////////////////////////////// 278 //////////////////////////////////////////////////////////////////////////////
273 279
274 DEF_GM( return new Poly2PolyGM; ) 280 DEF_GM( return new Poly2PolyGM; )
OLDNEW
« no previous file with comments | « gm/pixelsnap.cpp ('k') | gm/samplerstress.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698