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 455 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
466 | 466 |
467 protected: | 467 protected: |
468 int onGetUPEM() const override; | 468 int onGetUPEM() const override; |
469 SkStreamAsset* onOpenStream(int* ttcIndex) const override; | 469 SkStreamAsset* onOpenStream(int* ttcIndex) const override; |
470 SkFontData* onCreateFontData() const override; | 470 SkFontData* onCreateFontData() const override; |
471 void onGetFamilyName(SkString* familyName) const override; | 471 void onGetFamilyName(SkString* familyName) const override; |
472 SkTypeface::LocalizedStrings* onCreateFamilyNameIterator() const override; | 472 SkTypeface::LocalizedStrings* onCreateFamilyNameIterator() const override; |
473 int onGetTableTags(SkFontTableTag tags[]) const override; | 473 int onGetTableTags(SkFontTableTag tags[]) const override; |
474 virtual size_t onGetTableData(SkFontTableTag, size_t offset, | 474 virtual size_t onGetTableData(SkFontTableTag, size_t offset, |
475 size_t length, void* data) const override; | 475 size_t length, void* data) const override; |
476 SkScalerContext* onCreateScalerContext(const SkDescriptor*) const override; | 476 SkScalerContext* onCreateScalerContext(const SkScalerContextEffects&, |
| 477 const SkDescriptor*) const override; |
477 void onFilterRec(SkScalerContextRec*) const override; | 478 void onFilterRec(SkScalerContextRec*) const override; |
478 void onGetFontDescriptor(SkFontDescriptor*, bool*) const override; | 479 void onGetFontDescriptor(SkFontDescriptor*, bool*) const override; |
479 virtual SkAdvancedTypefaceMetrics* onGetAdvancedTypefaceMetrics( | 480 virtual SkAdvancedTypefaceMetrics* onGetAdvancedTypefaceMetrics( |
480 PerGlyphInfo, | 481 PerGlyphInfo, |
481 const uint32_t*, uint32_t) const override; | 482 const uint32_t*, uint32_t) const override; |
482 virtual int onCharsToGlyphs(const void* chars, Encoding, uint16_t glyphs[], | 483 virtual int onCharsToGlyphs(const void* chars, Encoding, uint16_t glyphs[], |
483 int glyphCount) const override; | 484 int glyphCount) const override; |
484 int onCountGlyphs() const override; | 485 int onCountGlyphs() const override; |
485 | 486 |
486 private: | 487 private: |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
622 /** GlyphRect is in FUnits (em space, y up). */ | 623 /** GlyphRect is in FUnits (em space, y up). */ |
623 struct GlyphRect { | 624 struct GlyphRect { |
624 int16_t fMinX; | 625 int16_t fMinX; |
625 int16_t fMinY; | 626 int16_t fMinY; |
626 int16_t fMaxX; | 627 int16_t fMaxX; |
627 int16_t fMaxY; | 628 int16_t fMaxY; |
628 }; | 629 }; |
629 | 630 |
630 class SkScalerContext_Mac : public SkScalerContext { | 631 class SkScalerContext_Mac : public SkScalerContext { |
631 public: | 632 public: |
632 SkScalerContext_Mac(SkTypeface_Mac*, const SkDescriptor*); | 633 SkScalerContext_Mac(SkTypeface_Mac*, const SkScalerContextEffects&, const Sk
Descriptor*); |
633 | 634 |
634 protected: | 635 protected: |
635 unsigned generateGlyphCount(void) override; | 636 unsigned generateGlyphCount(void) override; |
636 uint16_t generateCharToGlyph(SkUnichar uni) override; | 637 uint16_t generateCharToGlyph(SkUnichar uni) override; |
637 void generateAdvance(SkGlyph* glyph) override; | 638 void generateAdvance(SkGlyph* glyph) override; |
638 void generateMetrics(SkGlyph* glyph) override; | 639 void generateMetrics(SkGlyph* glyph) override; |
639 void generateImage(const SkGlyph& glyph) override; | 640 void generateImage(const SkGlyph& glyph) override; |
640 void generatePath(const SkGlyph& glyph, SkPath* path) override; | 641 void generatePath(const SkGlyph& glyph, SkPath* path) override; |
641 void generateFontMetrics(SkPaint::FontMetrics*) override; | 642 void generateFontMetrics(SkPaint::FontMetrics*) override; |
642 | 643 |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
731 // CGFontVariationFromDictCallback when it assumes kCGFontVariationAxisName
is CFNumberRef | 732 // CGFontVariationFromDictCallback when it assumes kCGFontVariationAxisName
is CFNumberRef |
732 // which it quite obviously is not. | 733 // which it quite obviously is not. |
733 | 734 |
734 // Because we cannot setup the CTFont descriptor to match, the same restrict
ion applies here | 735 // Because we cannot setup the CTFont descriptor to match, the same restrict
ion applies here |
735 // as other uses of CTFontCreateWithGraphicsFont which is that such CTFonts
should not escape | 736 // as other uses of CTFontCreateWithGraphicsFont which is that such CTFonts
should not escape |
736 // the scaler context, since they aren't 'normal'. | 737 // the scaler context, since they aren't 'normal'. |
737 return CTFontCreateWithGraphicsFont(baseCGFont, textSize, transform, nullptr
); | 738 return CTFontCreateWithGraphicsFont(baseCGFont, textSize, transform, nullptr
); |
738 } | 739 } |
739 | 740 |
740 SkScalerContext_Mac::SkScalerContext_Mac(SkTypeface_Mac* typeface, | 741 SkScalerContext_Mac::SkScalerContext_Mac(SkTypeface_Mac* typeface, |
| 742 const SkScalerContextEffects& effects, |
741 const SkDescriptor* desc) | 743 const SkDescriptor* desc) |
742 : INHERITED(typeface, desc) | 744 : INHERITED(typeface, effects, desc) |
743 , fFBoundingBoxes() | 745 , fFBoundingBoxes() |
744 , fFBoundingBoxesGlyphOffset(0) | 746 , fFBoundingBoxesGlyphOffset(0) |
745 , fGeneratedFBoundingBoxes(false) | 747 , fGeneratedFBoundingBoxes(false) |
746 , fDoSubPosition(SkToBool(fRec.fFlags & kSubpixelPositioning_Flag)) | 748 , fDoSubPosition(SkToBool(fRec.fFlags & kSubpixelPositioning_Flag)) |
747 , fVertical(SkToBool(fRec.fFlags & kVertical_Flag)) | 749 , fVertical(SkToBool(fRec.fFlags & kVertical_Flag)) |
748 | 750 |
749 { | 751 { |
750 AUTO_CG_LOCK(); | 752 AUTO_CG_LOCK(); |
751 | 753 |
752 CTFontRef ctFont = typeface->fFontRef.get(); | 754 CTFontRef ctFont = typeface->fFontRef.get(); |
(...skipping 1177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1930 } | 1932 } |
1931 if (length > srcSize - offset) { | 1933 if (length > srcSize - offset) { |
1932 length = srcSize - offset; | 1934 length = srcSize - offset; |
1933 } | 1935 } |
1934 if (dstData) { | 1936 if (dstData) { |
1935 memcpy(dstData, CFDataGetBytePtr(srcData) + offset, length); | 1937 memcpy(dstData, CFDataGetBytePtr(srcData) + offset, length); |
1936 } | 1938 } |
1937 return length; | 1939 return length; |
1938 } | 1940 } |
1939 | 1941 |
1940 SkScalerContext* SkTypeface_Mac::onCreateScalerContext(const SkDescriptor* desc)
const { | 1942 SkScalerContext* SkTypeface_Mac::onCreateScalerContext(const SkScalerContextEffe
cts& effects, |
1941 return new SkScalerContext_Mac(const_cast<SkTypeface_Mac*>(this), desc); | 1943 const SkDescriptor* desc)
const { |
| 1944 return new SkScalerContext_Mac(const_cast<SkTypeface_Mac*>(this), effects, d
esc); |
1942 } | 1945 } |
1943 | 1946 |
1944 void SkTypeface_Mac::onFilterRec(SkScalerContextRec* rec) const { | 1947 void SkTypeface_Mac::onFilterRec(SkScalerContextRec* rec) const { |
1945 if (rec->fFlags & SkScalerContext::kLCD_BGROrder_Flag || | 1948 if (rec->fFlags & SkScalerContext::kLCD_BGROrder_Flag || |
1946 rec->fFlags & SkScalerContext::kLCD_Vertical_Flag) | 1949 rec->fFlags & SkScalerContext::kLCD_Vertical_Flag) |
1947 { | 1950 { |
1948 rec->fMaskFormat = SkMask::kA8_Format; | 1951 rec->fMaskFormat = SkMask::kA8_Format; |
1949 // Render the glyphs as close as possible to what was requested. | 1952 // Render the glyphs as close as possible to what was requested. |
1950 // The above turns off subpixel rendering, but the user requested it. | 1953 // The above turns off subpixel rendering, but the user requested it. |
1951 // Normal hinting will cause the A8 masks to be generated from CoreGraph
ics subpixel masks. | 1954 // Normal hinting will cause the A8 masks to be generated from CoreGraph
ics subpixel masks. |
(...skipping 636 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2588 | 2591 |
2589 return SkSafeRef(GetDefaultFace()); | 2592 return SkSafeRef(GetDefaultFace()); |
2590 } | 2593 } |
2591 }; | 2594 }; |
2592 | 2595 |
2593 /////////////////////////////////////////////////////////////////////////////// | 2596 /////////////////////////////////////////////////////////////////////////////// |
2594 | 2597 |
2595 SkFontMgr* SkFontMgr::Factory() { return new SkFontMgr_Mac; } | 2598 SkFontMgr* SkFontMgr::Factory() { return new SkFontMgr_Mac; } |
2596 | 2599 |
2597 #endif//defined(SK_BUILD_FOR_MAC) || defined(SK_BUILD_FOR_IOS) | 2600 #endif//defined(SK_BUILD_FOR_MAC) || defined(SK_BUILD_FOR_IOS) |
OLD | NEW |