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

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

Issue 1037793002: C++11 override should now be supported by all of {bots,Chrome,Android,Mozilla} (Closed) Base URL: https://skia.googlesource.com/skia@master
Patch Set: git cl web Created 5 years, 8 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 | « src/ports/SkFontHost_linux.cpp ('k') | src/ports/SkFontHost_win.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 /* 2 /*
3 * Copyright 2006 The Android Open Source Project 3 * Copyright 2006 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 "SkTypes.h" // Keep this before any #ifdef ... 9 #include "SkTypes.h" // Keep this before any #ifdef ...
10 10
(...skipping 445 matching lines...) Expand 10 before | Expand all | Expand 10 after
456 , fIsLocalStream(isLocalStream) 456 , fIsLocalStream(isLocalStream)
457 , fHasColorGlyphs(CTFontGetSymbolicTraits(fFontRef) & SkCTFontColorGlyph sTrait) 457 , fHasColorGlyphs(CTFontGetSymbolicTraits(fFontRef) & SkCTFontColorGlyph sTrait)
458 { 458 {
459 SkASSERT(fontRef); 459 SkASSERT(fontRef);
460 } 460 }
461 461
462 SkString fRequestedName; 462 SkString fRequestedName;
463 AutoCFRelease<CTFontRef> fFontRef; 463 AutoCFRelease<CTFontRef> fFontRef;
464 464
465 protected: 465 protected:
466 int onGetUPEM() const SK_OVERRIDE; 466 int onGetUPEM() const override;
467 SkStreamAsset* onOpenStream(int* ttcIndex) const SK_OVERRIDE; 467 SkStreamAsset* onOpenStream(int* ttcIndex) const override;
468 void onGetFamilyName(SkString* familyName) const SK_OVERRIDE; 468 void onGetFamilyName(SkString* familyName) const override;
469 SkTypeface::LocalizedStrings* onCreateFamilyNameIterator() const SK_OVERRIDE ; 469 SkTypeface::LocalizedStrings* onCreateFamilyNameIterator() const override;
470 int onGetTableTags(SkFontTableTag tags[]) const SK_OVERRIDE; 470 int onGetTableTags(SkFontTableTag tags[]) const override;
471 virtual size_t onGetTableData(SkFontTableTag, size_t offset, 471 virtual size_t onGetTableData(SkFontTableTag, size_t offset,
472 size_t length, void* data) const SK_OVERRIDE; 472 size_t length, void* data) const override;
473 SkScalerContext* onCreateScalerContext(const SkDescriptor*) const SK_OVERRID E; 473 SkScalerContext* onCreateScalerContext(const SkDescriptor*) const override;
474 void onFilterRec(SkScalerContextRec*) const SK_OVERRIDE; 474 void onFilterRec(SkScalerContextRec*) const override;
475 void onGetFontDescriptor(SkFontDescriptor*, bool*) const SK_OVERRIDE; 475 void onGetFontDescriptor(SkFontDescriptor*, bool*) const override;
476 virtual SkAdvancedTypefaceMetrics* onGetAdvancedTypefaceMetrics( 476 virtual SkAdvancedTypefaceMetrics* onGetAdvancedTypefaceMetrics(
477 SkAdvancedTypefaceMetrics::PerGlyphInfo, 477 SkAdvancedTypefaceMetrics::PerGlyphInfo,
478 const uint32_t*, uint32_t) const SK_OVERRIDE; 478 const uint32_t*, uint32_t) const override;
479 virtual int onCharsToGlyphs(const void* chars, Encoding, uint16_t glyphs[], 479 virtual int onCharsToGlyphs(const void* chars, Encoding, uint16_t glyphs[],
480 int glyphCount) const SK_OVERRIDE; 480 int glyphCount) const override;
481 int onCountGlyphs() const SK_OVERRIDE; 481 int onCountGlyphs() const override;
482 482
483 private: 483 private:
484 bool fIsLocalStream; 484 bool fIsLocalStream;
485 bool fHasColorGlyphs; 485 bool fHasColorGlyphs;
486 486
487 typedef SkTypeface INHERITED; 487 typedef SkTypeface INHERITED;
488 }; 488 };
489 489
490 static SkTypeface* NewFromFontRef(CTFontRef fontRef, const char name[], bool isL ocalStream) { 490 static SkTypeface* NewFromFontRef(CTFontRef fontRef, const char name[], bool isL ocalStream) {
491 SkASSERT(fontRef); 491 SkASSERT(fontRef);
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
623 int16_t fMinY; 623 int16_t fMinY;
624 int16_t fMaxX; 624 int16_t fMaxX;
625 int16_t fMaxY; 625 int16_t fMaxY;
626 }; 626 };
627 627
628 class SkScalerContext_Mac : public SkScalerContext { 628 class SkScalerContext_Mac : public SkScalerContext {
629 public: 629 public:
630 SkScalerContext_Mac(SkTypeface_Mac*, const SkDescriptor*); 630 SkScalerContext_Mac(SkTypeface_Mac*, const SkDescriptor*);
631 631
632 protected: 632 protected:
633 unsigned generateGlyphCount(void) SK_OVERRIDE; 633 unsigned generateGlyphCount(void) override;
634 uint16_t generateCharToGlyph(SkUnichar uni) SK_OVERRIDE; 634 uint16_t generateCharToGlyph(SkUnichar uni) override;
635 void generateAdvance(SkGlyph* glyph) SK_OVERRIDE; 635 void generateAdvance(SkGlyph* glyph) override;
636 void generateMetrics(SkGlyph* glyph) SK_OVERRIDE; 636 void generateMetrics(SkGlyph* glyph) override;
637 void generateImage(const SkGlyph& glyph) SK_OVERRIDE; 637 void generateImage(const SkGlyph& glyph) override;
638 void generatePath(const SkGlyph& glyph, SkPath* path) SK_OVERRIDE; 638 void generatePath(const SkGlyph& glyph, SkPath* path) override;
639 void generateFontMetrics(SkPaint::FontMetrics*) SK_OVERRIDE; 639 void generateFontMetrics(SkPaint::FontMetrics*) override;
640 640
641 private: 641 private:
642 static void CTPathElement(void *info, const CGPathElement *element); 642 static void CTPathElement(void *info, const CGPathElement *element);
643 643
644 /** Returns the offset from the horizontal origin to the vertical origin in SkGlyph units. */ 644 /** Returns the offset from the horizontal origin to the vertical origin in SkGlyph units. */
645 void getVerticalOffset(CGGlyph glyphID, SkPoint* offset) const; 645 void getVerticalOffset(CGGlyph glyphID, SkPoint* offset) const;
646 646
647 /** Initializes and returns the value of fFBoundingBoxesGlyphOffset. 647 /** Initializes and returns the value of fFBoundingBoxesGlyphOffset.
648 * 648 *
649 * For use with (and must be called before) generateBBoxes. 649 * For use with (and must be called before) generateBBoxes.
(...skipping 1451 matching lines...) Expand 10 before | Expand all | Expand 10 after
2101 fArray = CFArrayCreate(NULL, NULL, 0, NULL); 2101 fArray = CFArrayCreate(NULL, NULL, 0, NULL);
2102 } 2102 }
2103 fCount = SkToInt(CFArrayGetCount(fArray)); 2103 fCount = SkToInt(CFArrayGetCount(fArray));
2104 } 2104 }
2105 2105
2106 virtual ~SkFontStyleSet_Mac() { 2106 virtual ~SkFontStyleSet_Mac() {
2107 CFRelease(fArray); 2107 CFRelease(fArray);
2108 CFRelease(fFamilyName); 2108 CFRelease(fFamilyName);
2109 } 2109 }
2110 2110
2111 int count() SK_OVERRIDE { 2111 int count() override {
2112 return fCount; 2112 return fCount;
2113 } 2113 }
2114 2114
2115 void getStyle(int index, SkFontStyle* style, SkString* name) SK_OVERRIDE { 2115 void getStyle(int index, SkFontStyle* style, SkString* name) override {
2116 SkASSERT((unsigned)index < (unsigned)fCount); 2116 SkASSERT((unsigned)index < (unsigned)fCount);
2117 CTFontDescriptorRef desc = (CTFontDescriptorRef)CFArrayGetValueAtIndex(f Array, index); 2117 CTFontDescriptorRef desc = (CTFontDescriptorRef)CFArrayGetValueAtIndex(f Array, index);
2118 if (style) { 2118 if (style) {
2119 *style = fontstyle_from_descriptor(desc); 2119 *style = fontstyle_from_descriptor(desc);
2120 } 2120 }
2121 if (name) { 2121 if (name) {
2122 if (!find_desc_str(desc, kCTFontStyleNameAttribute, name)) { 2122 if (!find_desc_str(desc, kCTFontStyleNameAttribute, name)) {
2123 name->reset(); 2123 name->reset();
2124 } 2124 }
2125 } 2125 }
2126 } 2126 }
2127 2127
2128 SkTypeface* createTypeface(int index) SK_OVERRIDE { 2128 SkTypeface* createTypeface(int index) override {
2129 SkASSERT((unsigned)index < (unsigned)CFArrayGetCount(fArray)); 2129 SkASSERT((unsigned)index < (unsigned)CFArrayGetCount(fArray));
2130 CTFontDescriptorRef desc = (CTFontDescriptorRef)CFArrayGetValueAtIndex(f Array, index); 2130 CTFontDescriptorRef desc = (CTFontDescriptorRef)CFArrayGetValueAtIndex(f Array, index);
2131 2131
2132 return createFromDesc(fFamilyName, desc); 2132 return createFromDesc(fFamilyName, desc);
2133 } 2133 }
2134 2134
2135 SkTypeface* matchStyle(const SkFontStyle& pattern) SK_OVERRIDE { 2135 SkTypeface* matchStyle(const SkFontStyle& pattern) override {
2136 if (0 == fCount) { 2136 if (0 == fCount) {
2137 return NULL; 2137 return NULL;
2138 } 2138 }
2139 return createFromDesc(fFamilyName, findMatchingDesc(pattern)); 2139 return createFromDesc(fFamilyName, findMatchingDesc(pattern));
2140 } 2140 }
2141 2141
2142 private: 2142 private:
2143 CFArrayRef fArray; 2143 CFArrayRef fArray;
2144 CFStringRef fFamilyName; 2144 CFStringRef fFamilyName;
2145 int fCount; 2145 int fCount;
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
2189 public: 2189 public:
2190 SkFontMgr_Mac() 2190 SkFontMgr_Mac()
2191 : fNames(SkCTFontManagerCopyAvailableFontFamilyNames()) 2191 : fNames(SkCTFontManagerCopyAvailableFontFamilyNames())
2192 , fCount(fNames ? SkToInt(CFArrayGetCount(fNames)) : 0) {} 2192 , fCount(fNames ? SkToInt(CFArrayGetCount(fNames)) : 0) {}
2193 2193
2194 virtual ~SkFontMgr_Mac() { 2194 virtual ~SkFontMgr_Mac() {
2195 CFSafeRelease(fNames); 2195 CFSafeRelease(fNames);
2196 } 2196 }
2197 2197
2198 protected: 2198 protected:
2199 int onCountFamilies() const SK_OVERRIDE { 2199 int onCountFamilies() const override {
2200 return fCount; 2200 return fCount;
2201 } 2201 }
2202 2202
2203 void onGetFamilyName(int index, SkString* familyName) const SK_OVERRIDE { 2203 void onGetFamilyName(int index, SkString* familyName) const override {
2204 if ((unsigned)index < (unsigned)fCount) { 2204 if ((unsigned)index < (unsigned)fCount) {
2205 CFStringToSkString(this->stringAt(index), familyName); 2205 CFStringToSkString(this->stringAt(index), familyName);
2206 } else { 2206 } else {
2207 familyName->reset(); 2207 familyName->reset();
2208 } 2208 }
2209 } 2209 }
2210 2210
2211 SkFontStyleSet* onCreateStyleSet(int index) const SK_OVERRIDE { 2211 SkFontStyleSet* onCreateStyleSet(int index) const override {
2212 if ((unsigned)index >= (unsigned)fCount) { 2212 if ((unsigned)index >= (unsigned)fCount) {
2213 return NULL; 2213 return NULL;
2214 } 2214 }
2215 return CreateSet(this->stringAt(index)); 2215 return CreateSet(this->stringAt(index));
2216 } 2216 }
2217 2217
2218 SkFontStyleSet* onMatchFamily(const char familyName[]) const SK_OVERRIDE { 2218 SkFontStyleSet* onMatchFamily(const char familyName[]) const override {
2219 AutoCFRelease<CFStringRef> cfName(make_CFString(familyName)); 2219 AutoCFRelease<CFStringRef> cfName(make_CFString(familyName));
2220 return CreateSet(cfName); 2220 return CreateSet(cfName);
2221 } 2221 }
2222 2222
2223 virtual SkTypeface* onMatchFamilyStyle(const char familyName[], 2223 virtual SkTypeface* onMatchFamilyStyle(const char familyName[],
2224 const SkFontStyle&) const SK_OVERRIDE { 2224 const SkFontStyle&) const override {
2225 return NULL; 2225 return NULL;
2226 } 2226 }
2227 2227
2228 virtual SkTypeface* onMatchFamilyStyleCharacter(const char familyName[], con st SkFontStyle&, 2228 virtual SkTypeface* onMatchFamilyStyleCharacter(const char familyName[], con st SkFontStyle&,
2229 const char* bcp47[], int bcp 47Count, 2229 const char* bcp47[], int bcp 47Count,
2230 SkUnichar character) const S K_OVERRIDE { 2230 SkUnichar character) const o verride {
2231 return NULL; 2231 return NULL;
2232 } 2232 }
2233 2233
2234 virtual SkTypeface* onMatchFaceStyle(const SkTypeface* familyMember, 2234 virtual SkTypeface* onMatchFaceStyle(const SkTypeface* familyMember,
2235 const SkFontStyle&) const SK_OVERRIDE { 2235 const SkFontStyle&) const override {
2236 return NULL; 2236 return NULL;
2237 } 2237 }
2238 2238
2239 SkTypeface* onCreateFromData(SkData* data, int ttcIndex) const SK_OVERRIDE { 2239 SkTypeface* onCreateFromData(SkData* data, int ttcIndex) const override {
2240 AutoCFRelease<CGDataProviderRef> pr(SkCreateDataProviderFromData(data)); 2240 AutoCFRelease<CGDataProviderRef> pr(SkCreateDataProviderFromData(data));
2241 if (NULL == pr) { 2241 if (NULL == pr) {
2242 return NULL; 2242 return NULL;
2243 } 2243 }
2244 return create_from_dataProvider(pr); 2244 return create_from_dataProvider(pr);
2245 } 2245 }
2246 2246
2247 SkTypeface* onCreateFromStream(SkStreamAsset* stream, int ttcIndex) const SK _OVERRIDE { 2247 SkTypeface* onCreateFromStream(SkStreamAsset* stream, int ttcIndex) const ov erride {
2248 AutoCFRelease<CGDataProviderRef> pr(SkCreateDataProviderFromStream(strea m)); 2248 AutoCFRelease<CGDataProviderRef> pr(SkCreateDataProviderFromStream(strea m));
2249 if (NULL == pr) { 2249 if (NULL == pr) {
2250 return NULL; 2250 return NULL;
2251 } 2251 }
2252 return create_from_dataProvider(pr); 2252 return create_from_dataProvider(pr);
2253 } 2253 }
2254 2254
2255 SkTypeface* onCreateFromFile(const char path[], int ttcIndex) const SK_OVERR IDE { 2255 SkTypeface* onCreateFromFile(const char path[], int ttcIndex) const override {
2256 AutoCFRelease<CGDataProviderRef> pr(CGDataProviderCreateWithFilename(pat h)); 2256 AutoCFRelease<CGDataProviderRef> pr(CGDataProviderCreateWithFilename(pat h));
2257 if (NULL == pr) { 2257 if (NULL == pr) {
2258 return NULL; 2258 return NULL;
2259 } 2259 }
2260 return create_from_dataProvider(pr); 2260 return create_from_dataProvider(pr);
2261 } 2261 }
2262 2262
2263 virtual SkTypeface* onLegacyCreateTypeface(const char familyName[], 2263 virtual SkTypeface* onLegacyCreateTypeface(const char familyName[],
2264 unsigned styleBits) const SK_OVER RIDE { 2264 unsigned styleBits) const overrid e {
2265 2265
2266 SkFontStyle style = SkFontStyle((SkTypeface::Style)styleBits); 2266 SkFontStyle style = SkFontStyle((SkTypeface::Style)styleBits);
2267 if (familyName) { 2267 if (familyName) {
2268 familyName = map_css_names(familyName); 2268 familyName = map_css_names(familyName);
2269 } 2269 }
2270 2270
2271 if (!familyName || !*familyName) { 2271 if (!familyName || !*familyName) {
2272 familyName = FONT_DEFAULT_NAME; 2272 familyName = FONT_DEFAULT_NAME;
2273 } 2273 }
2274 2274
(...skipping 11 matching lines...) Expand all
2286 } 2286 }
2287 return face; 2287 return face;
2288 } 2288 }
2289 }; 2289 };
2290 2290
2291 /////////////////////////////////////////////////////////////////////////////// 2291 ///////////////////////////////////////////////////////////////////////////////
2292 2292
2293 SkFontMgr* SkFontMgr::Factory() { 2293 SkFontMgr* SkFontMgr::Factory() {
2294 return SkNEW(SkFontMgr_Mac); 2294 return SkNEW(SkFontMgr_Mac);
2295 } 2295 }
OLDNEW
« no previous file with comments | « src/ports/SkFontHost_linux.cpp ('k') | src/ports/SkFontHost_win.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698