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

Side by Side Diff: gm/poly2poly.cpp

Issue 1933393002: Move SkTypeface to sk_sp. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Restore deleted Android code. Created 4 years, 7 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/pdf_never_embed.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 "Resources.h" 9 #include "Resources.h"
10 #include "SkPath.h" 10 #include "SkPath.h"
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 paint->setColor(SK_ColorRED); 217 paint->setColor(SK_ColorRED);
218 paint->setStyle(SkPaint::kFill_Style); 218 paint->setStyle(SkPaint::kFill_Style);
219 SkScalar x = D/2; 219 SkScalar x = D/2;
220 SkScalar y = D/2 - (fm.fAscent + fm.fDescent)/2; 220 SkScalar y = D/2 - (fm.fAscent + fm.fDescent)/2;
221 uint16_t glyphID = 3; // X 221 uint16_t glyphID = 3; // X
222 canvas->drawText((void*) &glyphID, sizeof(glyphID), x, y, *paint); 222 canvas->drawText((void*) &glyphID, sizeof(glyphID), x, y, *paint);
223 canvas->restore(); 223 canvas->restore();
224 } 224 }
225 225
226 void onOnceBeforeDraw() override { 226 void onOnceBeforeDraw() override {
227 fEmFace.reset(GetResourceAsTypeface("/fonts/Em.ttf")); 227 fEmFace = MakeResourceAsTypeface("/fonts/Em.ttf");
228 } 228 }
229 229
230 void onDraw(SkCanvas* canvas) override { 230 void onDraw(SkCanvas* canvas) override {
231 if (false) { test_stroke(canvas); return; } 231 if (false) { test_stroke(canvas); return; }
232 232
233 SkPaint paint; 233 SkPaint paint;
234 paint.setAntiAlias(true); 234 paint.setAntiAlias(true);
235 paint.setTypeface(fEmFace); 235 paint.setTypeface(fEmFace);
236 paint.setTextEncoding(SkPaint::kGlyphID_TextEncoding); 236 paint.setTextEncoding(SkPaint::kGlyphID_TextEncoding);
237 paint.setStrokeWidth(SkIntToScalar(4)); 237 paint.setStrokeWidth(SkIntToScalar(4));
(...skipping 28 matching lines...) Expand all
266 canvas->translate(SkIntToScalar(160), SkIntToScalar(110)); 266 canvas->translate(SkIntToScalar(160), SkIntToScalar(110));
267 // perspective (4 points) 267 // perspective (4 points)
268 const int src4[] = { 0, 0, 64, 0, 64, 64, 0, 64 }; 268 const int src4[] = { 0, 0, 64, 0, 64, 64, 0, 64 };
269 const int dst4[] = { 0, 0, 96, 0, 64, 96, 0, 64 }; 269 const int dst4[] = { 0, 0, 96, 0, 64, 96, 0, 64 };
270 doDraw(canvas, &paint, src4, dst4, 4); 270 doDraw(canvas, &paint, src4, dst4, 4);
271 canvas->restore(); 271 canvas->restore();
272 } 272 }
273 273
274 private: 274 private:
275 typedef skiagm::GM INHERITED; 275 typedef skiagm::GM INHERITED;
276 SkAutoTUnref<SkTypeface> fEmFace; 276 sk_sp<SkTypeface> fEmFace;
277 }; 277 };
278 278
279 ////////////////////////////////////////////////////////////////////////////// 279 //////////////////////////////////////////////////////////////////////////////
280 280
281 DEF_GM( return new Poly2PolyGM; ) 281 DEF_GM( return new Poly2PolyGM; )
OLDNEW
« no previous file with comments | « gm/pdf_never_embed.cpp ('k') | gm/textblob.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698