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

Side by Side Diff: src/ports/SkFontMgr_android.cpp

Issue 491733003: HACK NOT FOR COMMIT time font init Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fix gyp Created 6 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 | « gyp/ports.gyp ('k') | no next file » | 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 2014 Google Inc. 2 * Copyright 2014 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 "SkFontConfigParser_android.h" 8 #include "SkFontConfigParser_android.h"
9 #include "SkFontDescriptor.h" 9 #include "SkFontDescriptor.h"
10 #include "SkFontHost_FreeType_common.h" 10 #include "SkFontHost_FreeType_common.h"
(...skipping 21 matching lines...) Expand all
32 # define DEBUG_FONT(args) SkDebugf args 32 # define DEBUG_FONT(args) SkDebugf args
33 #else 33 #else
34 # define DEBUG_FONT(args) 34 # define DEBUG_FONT(args)
35 #endif 35 #endif
36 36
37 // For test only. 37 // For test only.
38 static const char* gTestMainConfigFile = NULL; 38 static const char* gTestMainConfigFile = NULL;
39 static const char* gTestFallbackConfigFile = NULL; 39 static const char* gTestFallbackConfigFile = NULL;
40 static const char* gTestFontFilePrefix = NULL; 40 static const char* gTestFontFilePrefix = NULL;
41 41
42 // HACK
43 #include "../../tools/timer/Timer.h"
44 static Timer gTimer;
45 static double gTime = 0.0;
46
42 class SkTypeface_Android : public SkTypeface_FreeType { 47 class SkTypeface_Android : public SkTypeface_FreeType {
43 public: 48 public:
44 SkTypeface_Android(int index, 49 SkTypeface_Android(int index,
45 Style style, 50 Style style,
46 bool isFixedPitch, 51 bool isFixedPitch,
47 const SkString familyName) 52 const SkString familyName)
48 : INHERITED(style, SkTypefaceCache::NewFontID(), isFixedPitch) 53 : INHERITED(style, SkTypefaceCache::NewFontID(), isFixedPitch)
49 , fIndex(index) 54 , fIndex(index)
50 , fFamilyName(familyName) { } 55 , fFamilyName(familyName) { }
51 56
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 } 139 }
135 140
136 class SkFontStyleSet_Android : public SkFontStyleSet { 141 class SkFontStyleSet_Android : public SkFontStyleSet {
137 public: 142 public:
138 explicit SkFontStyleSet_Android(const FontFamily& family, const char* basePa th) { 143 explicit SkFontStyleSet_Android(const FontFamily& family, const char* basePa th) {
139 const SkString* cannonicalFamilyName = NULL; 144 const SkString* cannonicalFamilyName = NULL;
140 if (family.fNames.count() > 0) { 145 if (family.fNames.count() > 0) {
141 cannonicalFamilyName = &family.fNames[0]; 146 cannonicalFamilyName = &family.fNames[0];
142 } 147 }
143 // TODO? make this lazy 148 // TODO? make this lazy
149 gTimer.start();
144 for (int i = 0; i < family.fFonts.count(); ++i) { 150 for (int i = 0; i < family.fFonts.count(); ++i) {
145 const FontFileInfo& fontFile = family.fFonts[i]; 151 const FontFileInfo& fontFile = family.fFonts[i];
146 152
147 SkString pathName; 153 SkString pathName;
148 get_path_for_sys_fonts(basePath, fontFile.fFileName, &pathName); 154 get_path_for_sys_fonts(basePath, fontFile.fFileName, &pathName);
149 155
150 SkAutoTUnref<SkStream> stream(SkStream::NewFromFile(pathName.c_str() )); 156 SkAutoTUnref<SkStream> stream(SkStream::NewFromFile(pathName.c_str() ));
151 if (!stream.get()) { 157 if (!stream.get()) {
152 DEBUG_FONT(("---- SystemFonts[%d] file=%s (NOT EXIST)", i, pathN ame.c_str())); 158 DEBUG_FONT(("---- SystemFonts[%d] file=%s (NOT EXIST)", i, pathN ame.c_str()));
153 continue; 159 continue;
(...skipping 20 matching lines...) Expand all
174 // all of the specified family names in addition to the names found in the font. 180 // all of the specified family names in addition to the names found in the font.
175 if (cannonicalFamilyName != NULL) { 181 if (cannonicalFamilyName != NULL) {
176 familyName = *cannonicalFamilyName; 182 familyName = *cannonicalFamilyName;
177 } 183 }
178 184
179 fStyles.push_back().reset(SkNEW_ARGS(SkTypeface_AndroidSystem, 185 fStyles.push_back().reset(SkNEW_ARGS(SkTypeface_AndroidSystem,
180 (pathName, ttcIndex, 186 (pathName, ttcIndex,
181 style, isFixedWidth, familyNam e, 187 style, isFixedWidth, familyNam e,
182 lang, variant))); 188 lang, variant)));
183 } 189 }
190 gTimer.end();
191 gTime += gTimer.fCpu;
184 } 192 }
185 193
186 virtual int count() SK_OVERRIDE { 194 virtual int count() SK_OVERRIDE {
187 return fStyles.count(); 195 return fStyles.count();
188 } 196 }
189 virtual void getStyle(int index, SkFontStyle* style, SkString* name) SK_OVER RIDE { 197 virtual void getStyle(int index, SkFontStyle* style, SkString* name) SK_OVER RIDE {
190 if (index < 0 || fStyles.count() <= index) { 198 if (index < 0 || fStyles.count() <= index) {
191 return; 199 return;
192 } 200 }
193 if (style) { 201 if (style) {
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
264 SkFontStyleSet_Android* styleSet; 272 SkFontStyleSet_Android* styleSet;
265 }; 273 };
266 274
267 class SkFontMgr_Android : public SkFontMgr { 275 class SkFontMgr_Android : public SkFontMgr {
268 public: 276 public:
269 SkFontMgr_Android() { 277 SkFontMgr_Android() {
270 SkTDArray<FontFamily*> fontFamilies; 278 SkTDArray<FontFamily*> fontFamilies;
271 SkFontConfigParser::GetFontFamilies(fontFamilies); 279 SkFontConfigParser::GetFontFamilies(fontFamilies);
272 this->buildNameToFamilyMap(fontFamilies, NULL); 280 this->buildNameToFamilyMap(fontFamilies, NULL);
273 this->findDefaultFont(); 281 this->findDefaultFont();
282 SkDebugf("Elapsed CPU time building font families: %g ms\n", gTime);
274 } 283 }
275 SkFontMgr_Android(const char* mainConfigFile, const char* fallbackConfigFile , 284 SkFontMgr_Android(const char* mainConfigFile, const char* fallbackConfigFile ,
276 const char* basePath) 285 const char* basePath)
277 { 286 {
278 SkTDArray<FontFamily*> fontFamilies; 287 SkTDArray<FontFamily*> fontFamilies;
279 SkFontConfigParser::GetTestFontFamilies(fontFamilies, mainConfigFile, fa llbackConfigFile); 288 SkFontConfigParser::GetTestFontFamilies(fontFamilies, mainConfigFile, fa llbackConfigFile);
280 this->buildNameToFamilyMap(fontFamilies, basePath); 289 this->buildNameToFamilyMap(fontFamilies, basePath);
281 this->findDefaultFont(); 290 this->findDefaultFont();
282 } 291 }
283 292
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after
527 SkDEBUGF(("Use Test Config File Main %s, Fallback %s, Font Dir %s", 536 SkDEBUGF(("Use Test Config File Main %s, Fallback %s, Font Dir %s",
528 gTestMainConfigFile, gTestFallbackConfigFile, gTestFontFilePrefix) ); 537 gTestMainConfigFile, gTestFallbackConfigFile, gTestFontFilePrefix) );
529 } 538 }
530 539
531 void SkGetTestFontConfiguration(const char** mainconf, const char** fallbackconf , 540 void SkGetTestFontConfiguration(const char** mainconf, const char** fallbackconf ,
532 const char** fontsdir) { 541 const char** fontsdir) {
533 *mainconf = gTestMainConfigFile; 542 *mainconf = gTestMainConfigFile;
534 *fallbackconf = gTestFallbackConfigFile; 543 *fallbackconf = gTestFallbackConfigFile;
535 *fontsdir = gTestFontFilePrefix; 544 *fontsdir = gTestFontFilePrefix;
536 } 545 }
OLDNEW
« no previous file with comments | « gyp/ports.gyp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698