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

Side by Side Diff: gm/typeface.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/textblobrandomfont.cpp ('k') | gm/variedtext.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 2012 Google Inc. 2 * Copyright 2012 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 "SkString.h" 10 #include "SkString.h"
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 { "serif", SkTypeface::kBoldItalic }, 83 { "serif", SkTypeface::kBoldItalic },
84 { "monospace", SkTypeface::kNormal }, 84 { "monospace", SkTypeface::kNormal },
85 { "monospace", SkTypeface::kBold }, 85 { "monospace", SkTypeface::kBold },
86 { "monospace", SkTypeface::kItalic }, 86 { "monospace", SkTypeface::kItalic },
87 { "monospace", SkTypeface::kBoldItalic }, 87 { "monospace", SkTypeface::kBoldItalic },
88 }; 88 };
89 89
90 static const int gFaceStylesCount = SK_ARRAY_COUNT(gFaceStyles); 90 static const int gFaceStylesCount = SK_ARRAY_COUNT(gFaceStyles);
91 91
92 class TypefaceStylesGM : public skiagm::GM { 92 class TypefaceStylesGM : public skiagm::GM {
93 SkTypeface* fFaces[gFaceStylesCount]; 93 sk_sp<SkTypeface> fFaces[gFaceStylesCount];
94 bool fApplyKerning; 94 bool fApplyKerning;
95 95
96 public: 96 public:
97 TypefaceStylesGM(bool applyKerning) 97 TypefaceStylesGM(bool applyKerning)
98 : fApplyKerning(applyKerning) { 98 : fApplyKerning(applyKerning) {
99 memset(fFaces, 0, sizeof(fFaces)); 99 memset(fFaces, 0, sizeof(fFaces));
100 } 100 }
101 101
102 virtual ~TypefaceStylesGM() {
103 for (int i = 0; i < gFaceStylesCount; i++) {
104 SkSafeUnref(fFaces[i]);
105 }
106 }
107
108 protected: 102 protected:
109 void onOnceBeforeDraw() override { 103 void onOnceBeforeDraw() override {
110 for (int i = 0; i < gFaceStylesCount; i++) { 104 for (int i = 0; i < gFaceStylesCount; i++) {
111 fFaces[i] = SkTypeface::CreateFromName( 105 fFaces[i] = SkTypeface::MakeFromName(
112 sk_tool_utils::platform_font_name(gFaceStyles[i].fName), gFa ceStyles[i].fStyle); 106 sk_tool_utils::platform_font_name(gFaceStyles[i].fName), gFa ceStyles[i].fStyle);
113 } 107 }
114 } 108 }
115 109
116 SkString onShortName() override { 110 SkString onShortName() override {
117 SkString name("typefacestyles"); 111 SkString name("typefacestyles");
118 if (fApplyKerning) { 112 if (fApplyKerning) {
119 name.append("_kerning"); 113 name.append("_kerning");
120 } 114 }
121 name.append(sk_tool_utils::major_platform_os_name()); 115 name.append(sk_tool_utils::major_platform_os_name());
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 } 148 }
155 149
156 private: 150 private:
157 typedef skiagm::GM INHERITED; 151 typedef skiagm::GM INHERITED;
158 }; 152 };
159 153
160 /////////////////////////////////////////////////////////////////////////////// 154 ///////////////////////////////////////////////////////////////////////////////
161 155
162 DEF_GM( return new TypefaceStylesGM(false); ) 156 DEF_GM( return new TypefaceStylesGM(false); )
163 DEF_GM( return new TypefaceStylesGM(true); ) 157 DEF_GM( return new TypefaceStylesGM(true); )
OLDNEW
« no previous file with comments | « gm/textblobrandomfont.cpp ('k') | gm/variedtext.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698