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