OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2006 The Android Open Source Project | 2 * Copyright 2006 The Android Open Source Project |
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 "SkTypes.h" // Keep this before any #ifdef ... | 8 #include "SkTypes.h" // Keep this before any #ifdef ... |
9 #if defined(SK_BUILD_FOR_MAC) || defined(SK_BUILD_FOR_IOS) | 9 #if defined(SK_BUILD_FOR_MAC) || defined(SK_BUILD_FOR_IOS) |
10 | 10 |
(...skipping 457 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
468 | 468 |
469 protected: | 469 protected: |
470 int onGetUPEM() const override; | 470 int onGetUPEM() const override; |
471 SkStreamAsset* onOpenStream(int* ttcIndex) const override; | 471 SkStreamAsset* onOpenStream(int* ttcIndex) const override; |
472 SkFontData* onCreateFontData() const override; | 472 SkFontData* onCreateFontData() const override; |
473 void onGetFamilyName(SkString* familyName) const override; | 473 void onGetFamilyName(SkString* familyName) const override; |
474 SkTypeface::LocalizedStrings* onCreateFamilyNameIterator() const override; | 474 SkTypeface::LocalizedStrings* onCreateFamilyNameIterator() const override; |
475 int onGetTableTags(SkFontTableTag tags[]) const override; | 475 int onGetTableTags(SkFontTableTag tags[]) const override; |
476 virtual size_t onGetTableData(SkFontTableTag, size_t offset, | 476 virtual size_t onGetTableData(SkFontTableTag, size_t offset, |
477 size_t length, void* data) const override; | 477 size_t length, void* data) const override; |
478 SkScalerContext* onCreateScalerContext(const SkDescriptor*) const override; | 478 SkScalerContext* onCreateScalerContext(const SkScalerContextEffects&, |
| 479 const SkDescriptor*) const override; |
479 void onFilterRec(SkScalerContextRec*) const override; | 480 void onFilterRec(SkScalerContextRec*) const override; |
480 void onGetFontDescriptor(SkFontDescriptor*, bool*) const override; | 481 void onGetFontDescriptor(SkFontDescriptor*, bool*) const override; |
481 virtual SkAdvancedTypefaceMetrics* onGetAdvancedTypefaceMetrics( | 482 virtual SkAdvancedTypefaceMetrics* onGetAdvancedTypefaceMetrics( |
482 PerGlyphInfo, | 483 PerGlyphInfo, |
483 const uint32_t*, uint32_t) const override; | 484 const uint32_t*, uint32_t) const override; |
484 virtual int onCharsToGlyphs(const void* chars, Encoding, uint16_t glyphs[], | 485 virtual int onCharsToGlyphs(const void* chars, Encoding, uint16_t glyphs[], |
485 int glyphCount) const override; | 486 int glyphCount) const override; |
486 int onCountGlyphs() const override; | 487 int onCountGlyphs() const override; |
487 | 488 |
488 private: | 489 private: |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
638 /** GlyphRect is in FUnits (em space, y up). */ | 639 /** GlyphRect is in FUnits (em space, y up). */ |
639 struct GlyphRect { | 640 struct GlyphRect { |
640 int16_t fMinX; | 641 int16_t fMinX; |
641 int16_t fMinY; | 642 int16_t fMinY; |
642 int16_t fMaxX; | 643 int16_t fMaxX; |
643 int16_t fMaxY; | 644 int16_t fMaxY; |
644 }; | 645 }; |
645 | 646 |
646 class SkScalerContext_Mac : public SkScalerContext { | 647 class SkScalerContext_Mac : public SkScalerContext { |
647 public: | 648 public: |
648 SkScalerContext_Mac(SkTypeface_Mac*, const SkDescriptor*); | 649 SkScalerContext_Mac(SkTypeface_Mac*, const SkScalerContextEffects&, const Sk
Descriptor*); |
649 | 650 |
650 protected: | 651 protected: |
651 unsigned generateGlyphCount(void) override; | 652 unsigned generateGlyphCount(void) override; |
652 uint16_t generateCharToGlyph(SkUnichar uni) override; | 653 uint16_t generateCharToGlyph(SkUnichar uni) override; |
653 void generateAdvance(SkGlyph* glyph) override; | 654 void generateAdvance(SkGlyph* glyph) override; |
654 void generateMetrics(SkGlyph* glyph) override; | 655 void generateMetrics(SkGlyph* glyph) override; |
655 void generateImage(const SkGlyph& glyph) override; | 656 void generateImage(const SkGlyph& glyph) override; |
656 void generatePath(const SkGlyph& glyph, SkPath* path) override; | 657 void generatePath(const SkGlyph& glyph, SkPath* path) override; |
657 void generateFontMetrics(SkPaint::FontMetrics*) override; | 658 void generateFontMetrics(SkPaint::FontMetrics*) override; |
658 | 659 |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
747 // CGFontVariationFromDictCallback when it assumes kCGFontVariationAxisName
is CFNumberRef | 748 // CGFontVariationFromDictCallback when it assumes kCGFontVariationAxisName
is CFNumberRef |
748 // which it quite obviously is not. | 749 // which it quite obviously is not. |
749 | 750 |
750 // Because we cannot setup the CTFont descriptor to match, the same restrict
ion applies here | 751 // Because we cannot setup the CTFont descriptor to match, the same restrict
ion applies here |
751 // as other uses of CTFontCreateWithGraphicsFont which is that such CTFonts
should not escape | 752 // as other uses of CTFontCreateWithGraphicsFont which is that such CTFonts
should not escape |
752 // the scaler context, since they aren't 'normal'. | 753 // the scaler context, since they aren't 'normal'. |
753 return CTFontCreateWithGraphicsFont(baseCGFont, textSize, transform, nullptr
); | 754 return CTFontCreateWithGraphicsFont(baseCGFont, textSize, transform, nullptr
); |
754 } | 755 } |
755 | 756 |
756 SkScalerContext_Mac::SkScalerContext_Mac(SkTypeface_Mac* typeface, | 757 SkScalerContext_Mac::SkScalerContext_Mac(SkTypeface_Mac* typeface, |
| 758 const SkScalerContextEffects& effects, |
757 const SkDescriptor* desc) | 759 const SkDescriptor* desc) |
758 : INHERITED(typeface, desc) | 760 : INHERITED(typeface, effects, desc) |
759 , fFBoundingBoxes() | 761 , fFBoundingBoxes() |
760 , fFBoundingBoxesGlyphOffset(0) | 762 , fFBoundingBoxesGlyphOffset(0) |
761 , fGeneratedFBoundingBoxes(false) | 763 , fGeneratedFBoundingBoxes(false) |
762 , fDoSubPosition(SkToBool(fRec.fFlags & kSubpixelPositioning_Flag)) | 764 , fDoSubPosition(SkToBool(fRec.fFlags & kSubpixelPositioning_Flag)) |
763 , fVertical(SkToBool(fRec.fFlags & kVertical_Flag)) | 765 , fVertical(SkToBool(fRec.fFlags & kVertical_Flag)) |
764 | 766 |
765 { | 767 { |
766 AUTO_CG_LOCK(); | 768 AUTO_CG_LOCK(); |
767 | 769 |
768 CTFontRef ctFont = typeface->fFontRef.get(); | 770 CTFontRef ctFont = typeface->fFontRef.get(); |
(...skipping 1177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1946 } | 1948 } |
1947 if (length > srcSize - offset) { | 1949 if (length > srcSize - offset) { |
1948 length = srcSize - offset; | 1950 length = srcSize - offset; |
1949 } | 1951 } |
1950 if (dstData) { | 1952 if (dstData) { |
1951 memcpy(dstData, CFDataGetBytePtr(srcData) + offset, length); | 1953 memcpy(dstData, CFDataGetBytePtr(srcData) + offset, length); |
1952 } | 1954 } |
1953 return length; | 1955 return length; |
1954 } | 1956 } |
1955 | 1957 |
1956 SkScalerContext* SkTypeface_Mac::onCreateScalerContext(const SkDescriptor* desc)
const { | 1958 SkScalerContext* SkTypeface_Mac::onCreateScalerContext(const SkScalerContextEffe
cts& effects, |
1957 return new SkScalerContext_Mac(const_cast<SkTypeface_Mac*>(this), desc); | 1959 const SkDescriptor* desc)
const { |
| 1960 return new SkScalerContext_Mac(const_cast<SkTypeface_Mac*>(this), effects, d
esc); |
1958 } | 1961 } |
1959 | 1962 |
1960 void SkTypeface_Mac::onFilterRec(SkScalerContextRec* rec) const { | 1963 void SkTypeface_Mac::onFilterRec(SkScalerContextRec* rec) const { |
1961 if (rec->fFlags & SkScalerContext::kLCD_BGROrder_Flag || | 1964 if (rec->fFlags & SkScalerContext::kLCD_BGROrder_Flag || |
1962 rec->fFlags & SkScalerContext::kLCD_Vertical_Flag) | 1965 rec->fFlags & SkScalerContext::kLCD_Vertical_Flag) |
1963 { | 1966 { |
1964 rec->fMaskFormat = SkMask::kA8_Format; | 1967 rec->fMaskFormat = SkMask::kA8_Format; |
1965 // Render the glyphs as close as possible to what was requested. | 1968 // Render the glyphs as close as possible to what was requested. |
1966 // The above turns off subpixel rendering, but the user requested it. | 1969 // The above turns off subpixel rendering, but the user requested it. |
1967 // Normal hinting will cause the A8 masks to be generated from CoreGraph
ics subpixel masks. | 1970 // Normal hinting will cause the A8 masks to be generated from CoreGraph
ics subpixel masks. |
(...skipping 656 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2624 } | 2627 } |
2625 return face; | 2628 return face; |
2626 } | 2629 } |
2627 }; | 2630 }; |
2628 | 2631 |
2629 /////////////////////////////////////////////////////////////////////////////// | 2632 /////////////////////////////////////////////////////////////////////////////// |
2630 | 2633 |
2631 SkFontMgr* SkFontMgr::Factory() { return new SkFontMgr_Mac; } | 2634 SkFontMgr* SkFontMgr::Factory() { return new SkFontMgr_Mac; } |
2632 | 2635 |
2633 #endif//defined(SK_BUILD_FOR_MAC) || defined(SK_BUILD_FOR_IOS) | 2636 #endif//defined(SK_BUILD_FOR_MAC) || defined(SK_BUILD_FOR_IOS) |
OLD | NEW |