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

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

Issue 433163002: Remove references to __system_property_get from Skia (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: comments 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 | « no previous file | src/ports/SkFontConfigParser_android.h » ('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 /* 2 /*
3 * Copyright 2013 The Android Open Source Project 3 * Copyright 2013 The Android Open Source Project
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 #include "SkFontConfigInterface.h" 9 #include "SkFontConfigInterface.h"
10 #include "SkTypeface_android.h" 10 #include "SkTypeface_android.h"
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 */ 103 */
104 SkTypeface* nextLogicalTypeface(SkFontID currFontID, SkFontID origFontID, 104 SkTypeface* nextLogicalTypeface(SkFontID currFontID, SkFontID origFontID,
105 const SkPaintOptionsAndroid& options); 105 const SkPaintOptionsAndroid& options);
106 SkTypeface* getTypefaceForGlyphID(uint16_t glyphID, const SkTypeface* origTy peface, 106 SkTypeface* getTypefaceForGlyphID(uint16_t glyphID, const SkTypeface* origTy peface,
107 const SkPaintOptionsAndroid& options, 107 const SkPaintOptionsAndroid& options,
108 int* lowerBounds, int* upperBounds); 108 int* lowerBounds, int* upperBounds);
109 109
110 private: 110 private:
111 void addFallbackFamily(FamilyRecID fontRecID); 111 void addFallbackFamily(FamilyRecID fontRecID);
112 SkTypeface* getTypefaceForFontRec(FontRecID fontRecID); 112 SkTypeface* getTypefaceForFontRec(FontRecID fontRecID);
113 FallbackFontList* getCurrentLocaleFallbackFontList();
114 FallbackFontList* findFallbackFontList(const SkLanguage& lang, bool isOrigin al = true); 113 FallbackFontList* findFallbackFontList(const SkLanguage& lang, bool isOrigin al = true);
115 114
116 SkTArray<FontRec, true> fFonts; 115 SkTArray<FontRec, true> fFonts;
117 SkTArray<FamilyRec, true> fFontFamilies; 116 SkTArray<FamilyRec, true> fFontFamilies;
118 SkTDict<FamilyRecID> fFamilyNameDict; 117 SkTDict<FamilyRecID> fFamilyNameDict;
119 FamilyRecID fDefaultFamilyRecID; 118 FamilyRecID fDefaultFamilyRecID;
120 119
121 // (SkLanguage)<->(fallback chain index) translation 120 // (SkLanguage)<->(fallback chain index) translation
122 SkTDict<FallbackFontList*> fFallbackFontDict; 121 SkTDict<FallbackFontList*> fFallbackFontDict;
123 SkTDict<FallbackFontList*> fFallbackFontAliasDict; 122 SkTDict<FallbackFontList*> fFallbackFontAliasDict;
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 // defer initializing the familyRec until we can be sure that at least 211 // defer initializing the familyRec until we can be sure that at least
213 // one of it's children contains a valid font file 212 // one of it's children contains a valid font file
214 FamilyRec* familyRec = NULL; 213 FamilyRec* familyRec = NULL;
215 FamilyRecID familyRecID = INVALID_FAMILY_REC_ID; 214 FamilyRecID familyRecID = INVALID_FAMILY_REC_ID;
216 215
217 for (int j = 0; j < family->fFontFiles.count(); ++j) { 216 for (int j = 0; j < family->fFontFiles.count(); ++j) {
218 SkString filename; 217 SkString filename;
219 get_path_for_sys_fonts(&filename, family->fFontFiles[j].fFileName); 218 get_path_for_sys_fonts(&filename, family->fFontFiles[j].fFileName);
220 219
221 if (has_font(fFonts, filename)) { 220 if (has_font(fFonts, filename)) {
222 SkDebugf("---- system font and fallback font files specify a dup licate " 221 DEBUG_FONT(("---- system font and fallback font files specify a duplicate "
223 "font %s, skipping the second occurrence", filename.c_st r()); 222 "font %s, skipping the second occurrence", filename.c_st r()));
224 continue;
225 } 223 }
226 224
227 FontRec& fontRec = fFonts.push_back(); 225 FontRec& fontRec = fFonts.push_back();
228 fontRec.fFileName = filename; 226 fontRec.fFileName = filename;
229 fontRec.fStyle = SkTypeface::kNormal; 227 fontRec.fStyle = SkTypeface::kNormal;
230 fontRec.fIsValid = false; 228 fontRec.fIsValid = false;
231 fontRec.fFamilyRecID = familyRecID; 229 fontRec.fFamilyRecID = familyRecID;
232 230
233 const FontRecID fontRecID = fFonts.count() - 1; 231 const FontRecID fontRecID = fFonts.count() - 1;
234 232
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after
503 // store the result for subsequent lookups 501 // store the result for subsequent lookups
504 fontRec.fTypeface.reset(face); 502 fontRec.fTypeface.reset(face);
505 } 503 }
506 SkASSERT(face); 504 SkASSERT(face);
507 return face; 505 return face;
508 } 506 }
509 507
510 bool SkFontConfigInterfaceAndroid::getFallbackFamilyNameForChar(SkUnichar uni, 508 bool SkFontConfigInterfaceAndroid::getFallbackFamilyNameForChar(SkUnichar uni,
511 const char* lang , 509 const char* lang ,
512 SkString* name) { 510 SkString* name) {
513 FallbackFontList* fallbackFontList = NULL; 511 const SkString locale(lang);
514 const SkString langTag(lang); 512 if (NULL == fLocaleFallbackFontList || locale != fCachedLocale) {
515 if (langTag.isEmpty()) { 513 fCachedLocale = locale;
516 fallbackFontList = this->getCurrentLocaleFallbackFontList(); 514 fLocaleFallbackFontList = this->findFallbackFontList(locale);
bungeman-skia 2014/08/04 14:52:45 Now that this is cleaner, it sets of my spider sen
tomhudson 2014/08/04 15:26:37 So the error case is that two different threads ar
517 } else {
518 fallbackFontList = this->findFallbackFontList(langTag);
519 } 515 }
520 516
521 for (int i = 0; i < fallbackFontList->count(); i++) { 517 for (int i = 0; i < fLocaleFallbackFontList->count(); i++) {
522 FamilyRecID familyRecID = fallbackFontList->getAt(i); 518 FamilyRecID familyRecID = fLocaleFallbackFontList->getAt(i);
523 519
524 // if it is not one of the accepted variants then move to the next famil y 520 // if it is not one of the accepted variants then move to the next famil y
525 int32_t acceptedVariants = SkPaintOptionsAndroid::kDefault_Variant | 521 int32_t acceptedVariants = SkPaintOptionsAndroid::kDefault_Variant |
526 SkPaintOptionsAndroid::kElegant_Variant; 522 SkPaintOptionsAndroid::kElegant_Variant;
527 if (!(fFontFamilies[familyRecID].fPaintOptions.getFontVariant() & accept edVariants)) { 523 if (!(fFontFamilies[familyRecID].fPaintOptions.getFontVariant() & accept edVariants)) {
528 continue; 524 continue;
529 } 525 }
530 526
531 FontRecID fontRecID = find_best_style(fFontFamilies[familyRecID], SkType face::kNormal); 527 FontRecID fontRecID = find_best_style(fFontFamilies[familyRecID], SkType face::kNormal);
532 SkTypeface* face = this->getTypefaceForFontRec(fontRecID); 528 SkTypeface* face = this->getTypefaceForFontRec(fontRecID);
533 529
534 SkPaint paint; 530 SkPaint paint;
535 paint.setTypeface(face); 531 paint.setTypeface(face);
536 paint.setTextEncoding(SkPaint::kUTF32_TextEncoding); 532 paint.setTextEncoding(SkPaint::kUTF32_TextEncoding);
537 533
538 uint16_t glyphID; 534 uint16_t glyphID;
539 paint.textToGlyphs(&uni, sizeof(uni), &glyphID); 535 paint.textToGlyphs(&uni, sizeof(uni), &glyphID);
540 if (glyphID != 0) { 536 if (glyphID != 0) {
541 name->set(fFontFamilies[familyRecID].fFallbackName); 537 name->set(fFontFamilies[familyRecID].fFallbackName);
542 return true; 538 return true;
543 } 539 }
544 } 540 }
545 return false; 541 return false;
546 } 542 }
547 543
548 FallbackFontList* SkFontConfigInterfaceAndroid::getCurrentLocaleFallbackFontList () {
549 SkString locale = SkFontConfigParser::GetLocale();
550 if (NULL == fLocaleFallbackFontList || locale != fCachedLocale) {
551 fCachedLocale = locale;
552 fLocaleFallbackFontList = this->findFallbackFontList(locale);
553 }
554 return fLocaleFallbackFontList;
555 }
556
557 FallbackFontList* SkFontConfigInterfaceAndroid::findFallbackFontList(const SkLan guage& lang, 544 FallbackFontList* SkFontConfigInterfaceAndroid::findFallbackFontList(const SkLan guage& lang,
558 bool isOrig inal) { 545 bool isOrig inal) {
559 const SkString& langTag = lang.getTag(); 546 const SkString& langTag = lang.getTag();
560 if (langTag.isEmpty()) { 547 if (langTag.isEmpty()) {
561 return &fDefaultFallbackList; 548 return &fDefaultFallbackList;
562 } 549 }
563 550
564 FallbackFontList* fallbackFontList; 551 FallbackFontList* fallbackFontList;
565 if (fFallbackFontDict.find(langTag.c_str(), langTag.size(), &fallbackFontLis t) || 552 if (fFallbackFontDict.find(langTag.c_str(), langTag.size(), &fallbackFontLis t) ||
566 fFallbackFontAliasDict.find(langTag.c_str(), langTag.size(), &fallbackFo ntList)) { 553 fFallbackFontAliasDict.find(langTag.c_str(), langTag.size(), &fallbackFo ntList)) {
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
734 721
735 } 722 }
736 723
737 SkTypeface* SkGetTypefaceForGlyphID(uint16_t glyphID, const SkTypeface* origType face, 724 SkTypeface* SkGetTypefaceForGlyphID(uint16_t glyphID, const SkTypeface* origType face,
738 const SkPaintOptionsAndroid& options, 725 const SkPaintOptionsAndroid& options,
739 int* lowerBounds, int* upperBounds) { 726 int* lowerBounds, int* upperBounds) {
740 SkFontConfigInterfaceAndroid* fontConfig = getSingletonInterface(); 727 SkFontConfigInterfaceAndroid* fontConfig = getSingletonInterface();
741 return fontConfig->getTypefaceForGlyphID(glyphID, origTypeface, options, 728 return fontConfig->getTypefaceForGlyphID(glyphID, origTypeface, options,
742 lowerBounds, upperBounds); 729 lowerBounds, upperBounds);
743 } 730 }
OLDNEW
« no previous file with comments | « no previous file | src/ports/SkFontConfigParser_android.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698