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

Side by Side Diff: gm/fontcache.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/dftext.cpp ('k') | gm/fontmgr.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 2013 Google Inc. 2 * Copyright 2013 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 "SkGraphics.h" 10 #include "SkGraphics.h"
11 #include "SkTypeface.h" 11 #include "SkTypeface.h"
12 12
13 // GM to stress the GPU font cache 13 // GM to stress the GPU font cache
14 14
15 static SkScalar draw_string(SkCanvas* canvas, const SkString& text, SkScalar x, 15 static SkScalar draw_string(SkCanvas* canvas, const SkString& text, SkScalar x,
16 SkScalar y, const SkPaint& paint) { 16 SkScalar y, const SkPaint& paint) {
17 canvas->drawText(text.c_str(), text.size(), x, y, paint); 17 canvas->drawText(text.c_str(), text.size(), x, y, paint);
18 return x + paint.measureText(text.c_str(), text.size()); 18 return x + paint.measureText(text.c_str(), text.size());
19 } 19 }
20 20
21 class FontCacheGM : public skiagm::GM { 21 class FontCacheGM : public skiagm::GM {
22 public: 22 public:
23 FontCacheGM() { 23 FontCacheGM() {}
24 fTypefaces[0] = nullptr;
25 fTypefaces[1] = nullptr;
26 }
27
28 virtual ~FontCacheGM() {
29 SkSafeUnref(fTypefaces[0]);
30 SkSafeUnref(fTypefaces[1]);
31 }
32 24
33 protected: 25 protected:
34 SkString onShortName() override { 26 SkString onShortName() override {
35 return SkString("fontcache"); 27 return SkString("fontcache");
36 } 28 }
37 29
38 SkISize onISize() override { 30 SkISize onISize() override {
39 return SkISize::Make(1280, 640); 31 return SkISize::Make(1280, 640);
40 } 32 }
41 33
(...skipping 27 matching lines...) Expand all
69 paint.setTypeface(fTypefaces[1]); 61 paint.setTypeface(fTypefaces[1]);
70 draw_string(canvas, text, x, y, paint); 62 draw_string(canvas, text, x, y, paint);
71 y += 100; 63 y += 100;
72 draw_string(canvas, text2, x, y, paint); 64 draw_string(canvas, text2, x, y, paint);
73 y += 100; 65 y += 100;
74 draw_string(canvas, text3, x, y, paint); 66 draw_string(canvas, text3, x, y, paint);
75 y += 100; 67 y += 100;
76 } 68 }
77 69
78 private: 70 private:
79 SkTypeface* fTypefaces[2]; 71 sk_sp<SkTypeface> fTypefaces[2];
80 typedef GM INHERITED; 72 typedef GM INHERITED;
81 }; 73 };
82 74
83 75
84 ////////////////////////////////////////////////////////////////////////////// 76 //////////////////////////////////////////////////////////////////////////////
85 77
86 DEF_GM(return new FontCacheGM;) 78 DEF_GM(return new FontCacheGM;)
OLDNEW
« no previous file with comments | « gm/dftext.cpp ('k') | gm/fontmgr.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698