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 627 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
638 /** GlyphRect is in FUnits (em space, y up). */ | 638 /** GlyphRect is in FUnits (em space, y up). */ |
639 struct GlyphRect { | 639 struct GlyphRect { |
640 int16_t fMinX; | 640 int16_t fMinX; |
641 int16_t fMinY; | 641 int16_t fMinY; |
642 int16_t fMaxX; | 642 int16_t fMaxX; |
643 int16_t fMaxY; | 643 int16_t fMaxY; |
644 }; | 644 }; |
645 | 645 |
646 class SkScalerContext_Mac : public SkScalerContext { | 646 class SkScalerContext_Mac : public SkScalerContext { |
647 public: | 647 public: |
648 SkScalerContext_Mac(SkTypeface_Mac*, const SkDescriptor*); | 648 SkScalerContext_Mac(const Effects&, const SkDescriptor*); |
bungeman-skia
2016/04/06 17:52:10
I'm assuming you mean SkScalerContextEffects here?
| |
649 | 649 |
650 protected: | 650 protected: |
651 unsigned generateGlyphCount(void) override; | 651 unsigned generateGlyphCount(void) override; |
652 uint16_t generateCharToGlyph(SkUnichar uni) override; | 652 uint16_t generateCharToGlyph(SkUnichar uni) override; |
653 void generateAdvance(SkGlyph* glyph) override; | 653 void generateAdvance(SkGlyph* glyph) override; |
654 void generateMetrics(SkGlyph* glyph) override; | 654 void generateMetrics(SkGlyph* glyph) override; |
655 void generateImage(const SkGlyph& glyph) override; | 655 void generateImage(const SkGlyph& glyph) override; |
656 void generatePath(const SkGlyph& glyph, SkPath* path) override; | 656 void generatePath(const SkGlyph& glyph, SkPath* path) override; |
657 void generateFontMetrics(SkPaint::FontMetrics*) override; | 657 void generateFontMetrics(SkPaint::FontMetrics*) override; |
658 | 658 |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
746 // If non-nullptr then with fonts with variation axes, the copy will fail in | 746 // If non-nullptr then with fonts with variation axes, the copy will fail in |
747 // CGFontVariationFromDictCallback when it assumes kCGFontVariationAxisName is CFNumberRef | 747 // CGFontVariationFromDictCallback when it assumes kCGFontVariationAxisName is CFNumberRef |
748 // which it quite obviously is not. | 748 // which it quite obviously is not. |
749 | 749 |
750 // Because we cannot setup the CTFont descriptor to match, the same restrict ion applies here | 750 // 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 | 751 // as other uses of CTFontCreateWithGraphicsFont which is that such CTFonts should not escape |
752 // the scaler context, since they aren't 'normal'. | 752 // the scaler context, since they aren't 'normal'. |
753 return CTFontCreateWithGraphicsFont(baseCGFont, textSize, transform, nullptr ); | 753 return CTFontCreateWithGraphicsFont(baseCGFont, textSize, transform, nullptr ); |
754 } | 754 } |
755 | 755 |
756 SkScalerContext_Mac::SkScalerContext_Mac(SkTypeface_Mac* typeface, | 756 SkScalerContext_Mac::SkScalerContext_Mac(const Effects& effects, const SkDescrip tor* desc) |
757 const SkDescriptor* desc) | 757 : INHERITED(effects, desc) |
758 : INHERITED(typeface, desc) | |
759 , fFBoundingBoxes() | 758 , fFBoundingBoxes() |
760 , fFBoundingBoxesGlyphOffset(0) | 759 , fFBoundingBoxesGlyphOffset(0) |
761 , fGeneratedFBoundingBoxes(false) | 760 , fGeneratedFBoundingBoxes(false) |
762 , fDoSubPosition(SkToBool(fRec.fFlags & kSubpixelPositioning_Flag)) | 761 , fDoSubPosition(SkToBool(fRec.fFlags & kSubpixelPositioning_Flag)) |
763 , fVertical(SkToBool(fRec.fFlags & kVertical_Flag)) | 762 , fVertical(SkToBool(fRec.fFlags & kVertical_Flag)) |
764 | 763 |
765 { | 764 { |
766 AUTO_CG_LOCK(); | 765 AUTO_CG_LOCK(); |
767 | 766 |
767 SkTypeface_Mac* typeface = (SkTypeface_Mac*)effects.fTypeface.get(); | |
768 CTFontRef ctFont = typeface->fFontRef.get(); | 768 CTFontRef ctFont = typeface->fFontRef.get(); |
769 CFIndex numGlyphs = CTFontGetGlyphCount(ctFont); | 769 CFIndex numGlyphs = CTFontGetGlyphCount(ctFont); |
770 SkASSERT(numGlyphs >= 1 && numGlyphs <= 0xFFFF); | 770 SkASSERT(numGlyphs >= 1 && numGlyphs <= 0xFFFF); |
771 fGlyphCount = SkToU16(numGlyphs); | 771 fGlyphCount = SkToU16(numGlyphs); |
772 | 772 |
773 // CT on (at least) 10.9 will size color glyphs down from the requested size , but not up. | 773 // CT on (at least) 10.9 will size color glyphs down from the requested size , but not up. |
774 // As a result, it is necessary to know the actual device size and request t hat. | 774 // As a result, it is necessary to know the actual device size and request t hat. |
775 SkVector scale; | 775 SkVector scale; |
776 SkMatrix skTransform; | 776 SkMatrix skTransform; |
777 fRec.computeMatrices(SkScalerContextRec::kVertical_PreMatrixScale, &scale, & skTransform, | 777 fRec.computeMatrices(SkScalerContextRec::kVertical_PreMatrixScale, &scale, & skTransform, |
(...skipping 1168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1946 } | 1946 } |
1947 if (length > srcSize - offset) { | 1947 if (length > srcSize - offset) { |
1948 length = srcSize - offset; | 1948 length = srcSize - offset; |
1949 } | 1949 } |
1950 if (dstData) { | 1950 if (dstData) { |
1951 memcpy(dstData, CFDataGetBytePtr(srcData) + offset, length); | 1951 memcpy(dstData, CFDataGetBytePtr(srcData) + offset, length); |
1952 } | 1952 } |
1953 return length; | 1953 return length; |
1954 } | 1954 } |
1955 | 1955 |
1956 SkScalerContext* SkTypeface_Mac::onCreateScalerContext(const SkDescriptor* desc) const { | 1956 SkScalerContext* SkTypeface_Mac::onCreateScalerContext(const SkDescriptor* desc) const { |
bungeman-skia
2016/04/06 17:52:10
And this would need updated? I rather like that th
| |
1957 return new SkScalerContext_Mac(const_cast<SkTypeface_Mac*>(this), desc); | 1957 return new SkScalerContext_Mac(const_cast<SkTypeface_Mac*>(this), desc); |
1958 } | 1958 } |
1959 | 1959 |
1960 void SkTypeface_Mac::onFilterRec(SkScalerContextRec* rec) const { | 1960 void SkTypeface_Mac::onFilterRec(SkScalerContextRec* rec) const { |
1961 if (rec->fFlags & SkScalerContext::kLCD_BGROrder_Flag || | 1961 if (rec->fFlags & SkScalerContext::kLCD_BGROrder_Flag || |
1962 rec->fFlags & SkScalerContext::kLCD_Vertical_Flag) | 1962 rec->fFlags & SkScalerContext::kLCD_Vertical_Flag) |
1963 { | 1963 { |
1964 rec->fMaskFormat = SkMask::kA8_Format; | 1964 rec->fMaskFormat = SkMask::kA8_Format; |
1965 // Render the glyphs as close as possible to what was requested. | 1965 // Render the glyphs as close as possible to what was requested. |
1966 // The above turns off subpixel rendering, but the user requested it. | 1966 // The above turns off subpixel rendering, but the user requested it. |
(...skipping 657 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2624 } | 2624 } |
2625 return face; | 2625 return face; |
2626 } | 2626 } |
2627 }; | 2627 }; |
2628 | 2628 |
2629 /////////////////////////////////////////////////////////////////////////////// | 2629 /////////////////////////////////////////////////////////////////////////////// |
2630 | 2630 |
2631 SkFontMgr* SkFontMgr::Factory() { return new SkFontMgr_Mac; } | 2631 SkFontMgr* SkFontMgr::Factory() { return new SkFontMgr_Mac; } |
2632 | 2632 |
2633 #endif//defined(SK_BUILD_FOR_MAC) || defined(SK_BUILD_FOR_IOS) | 2633 #endif//defined(SK_BUILD_FOR_MAC) || defined(SK_BUILD_FOR_IOS) |
OLD | NEW |