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

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

Issue 12593013: remove SkFontHost::CreateScalerContext (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Created 7 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « src/ports/SkFontHost_linux.cpp ('k') | src/ports/SkFontHost_none.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 <vector> 9 #include <vector>
10 #ifdef SK_BUILD_FOR_MAC 10 #ifdef SK_BUILD_FOR_MAC
(...skipping 592 matching lines...) Expand 10 before | Expand all | Expand 10 after
603 603
604 struct GlyphRect { 604 struct GlyphRect {
605 int16_t fMinX; 605 int16_t fMinX;
606 int16_t fMinY; 606 int16_t fMinY;
607 int16_t fMaxX; 607 int16_t fMaxX;
608 int16_t fMaxY; 608 int16_t fMaxY;
609 }; 609 };
610 610
611 class SkScalerContext_Mac : public SkScalerContext { 611 class SkScalerContext_Mac : public SkScalerContext {
612 public: 612 public:
613 SkScalerContext_Mac(const SkDescriptor* desc); 613 SkScalerContext_Mac(SkTypeface_Mac*, const SkDescriptor*);
614 virtual ~SkScalerContext_Mac(void); 614 virtual ~SkScalerContext_Mac();
615 615
616 616
617 protected: 617 protected:
618 unsigned generateGlyphCount(void) SK_OVERRIDE; 618 unsigned generateGlyphCount(void) SK_OVERRIDE;
619 uint16_t generateCharToGlyph(SkUnichar uni) SK_OVERRIDE; 619 uint16_t generateCharToGlyph(SkUnichar uni) SK_OVERRIDE;
620 void generateAdvance(SkGlyph* glyph) SK_OVERRIDE; 620 void generateAdvance(SkGlyph* glyph) SK_OVERRIDE;
621 void generateMetrics(SkGlyph* glyph) SK_OVERRIDE; 621 void generateMetrics(SkGlyph* glyph) SK_OVERRIDE;
622 void generateImage(const SkGlyph& glyph) SK_OVERRIDE; 622 void generateImage(const SkGlyph& glyph) SK_OVERRIDE;
623 void generatePath(const SkGlyph& glyph, SkPath* path) SK_OVERRIDE; 623 void generatePath(const SkGlyph& glyph, SkPath* path) SK_OVERRIDE;
624 void generateFontMetrics(SkPaint::FontMetrics* mX, SkPaint::FontMetrics* mY) SK_OVERRIDE; 624 void generateFontMetrics(SkPaint::FontMetrics* mX, SkPaint::FontMetrics* mY) SK_OVERRIDE;
(...skipping 14 matching lines...) Expand all
639 AutoCFRelease<CTFontRef> fCTVerticalFont; // for vertical advance 639 AutoCFRelease<CTFontRef> fCTVerticalFont; // for vertical advance
640 AutoCFRelease<CGFontRef> fCGFont; 640 AutoCFRelease<CGFontRef> fCGFont;
641 GlyphRect* fFBoundingBoxes; 641 GlyphRect* fFBoundingBoxes;
642 uint16_t fFBoundingBoxesGlyphOffset; 642 uint16_t fFBoundingBoxesGlyphOffset;
643 uint16_t fGlyphCount; 643 uint16_t fGlyphCount;
644 bool fGeneratedFBoundingBoxes; 644 bool fGeneratedFBoundingBoxes;
645 bool fDoSubPosition; 645 bool fDoSubPosition;
646 bool fVertical; 646 bool fVertical;
647 647
648 friend class Offscreen; 648 friend class Offscreen;
649
650 typedef SkScalerContext INHERITED;
649 }; 651 };
650 652
651 SkScalerContext_Mac::SkScalerContext_Mac(const SkDescriptor* desc) 653 SkScalerContext_Mac::SkScalerContext_Mac(SkTypeface_Mac* typeface,
652 : SkScalerContext(desc) 654 const SkDescriptor* desc)
655 : INHERITED(typeface, desc)
653 , fFBoundingBoxes(NULL) 656 , fFBoundingBoxes(NULL)
654 , fFBoundingBoxesGlyphOffset(0) 657 , fFBoundingBoxesGlyphOffset(0)
655 , fGeneratedFBoundingBoxes(false) 658 , fGeneratedFBoundingBoxes(false)
656 { 659 {
657 CTFontRef ctFont = GetFontRefFromFontID(fRec.fFontID); 660 CTFontRef ctFont = GetFontRefFromFontID(fRec.fFontID);
658 CFIndex numGlyphs = CTFontGetGlyphCount(ctFont); 661 CFIndex numGlyphs = CTFontGetGlyphCount(ctFont);
659 662
660 // Get the state we need 663 // Get the state we need
661 fRec.getSingleMatrix(&fMatrix); 664 fRec.getSingleMatrix(&fMatrix);
662 fUnitMatrix = fMatrix; 665 fUnitMatrix = fMatrix;
(...skipping 1043 matching lines...) Expand 10 before | Expand all | Expand 10 after
1706 // for now, we just want to skip it. 1709 // for now, we just want to skip it.
1707 size_t size = stream->readPackedUInt(); 1710 size_t size = stream->readPackedUInt();
1708 stream->skip(size); 1711 stream->skip(size);
1709 1712
1710 return SkFontHost::CreateTypeface(NULL, desc.getFamilyName(), desc.getStyle( )); 1713 return SkFontHost::CreateTypeface(NULL, desc.getFamilyName(), desc.getStyle( ));
1711 } 1714 }
1712 1715
1713 /////////////////////////////////////////////////////////////////////////////// 1716 ///////////////////////////////////////////////////////////////////////////////
1714 1717
1715 // DEPRECATED 1718 // DEPRECATED
1716 SkScalerContext* SkFontHost::CreateScalerContext(const SkDescriptor* desc) { 1719 SkTypeface* SkFontHost::NextLogicalTypeface(SkFontID currFontID, SkFontID origFo ntID) {
1717 return new SkScalerContext_Mac(desc);
1718 }
1719
1720 // DEPRECATED
1721 SkFontID SkFontHost::NextLogicalFont(SkFontID currFontID, SkFontID origFontID) {
1722 SkFontID nextFontID = 0;
1723 SkTypeface* face = GetDefaultFace(); 1720 SkTypeface* face = GetDefaultFace();
1724 if (face->uniqueID() != currFontID) { 1721 if (face->uniqueID() == currFontID) {
1725 nextFontID = face->uniqueID(); 1722 face = NULL;
1726 } 1723 }
1727 return nextFontID; 1724 return SkSafeRef(face);
1728 }
1729
1730 // DEPRECATED
1731 void SkFontHost::FilterRec(SkScalerContext::Rec* rec, SkTypeface* face) {
1732 face->onFilterRec(rec);
1733 } 1725 }
1734 1726
1735 // DEPRECATED 1727 // DEPRECATED
1736 int SkFontHost::CountTables(SkFontID fontID) { 1728 int SkFontHost::CountTables(SkFontID fontID) {
1737 SkTypeface* face = SkTypefaceCache::FindByID(fontID); 1729 SkTypeface* face = SkTypefaceCache::FindByID(fontID);
1738 return face ? face->onGetTableTags(NULL) : 0; 1730 return face ? face->onGetTableTags(NULL) : 0;
1739 } 1731 }
1740 1732
1741 // DEPRECATED 1733 // DEPRECATED
1742 int SkFontHost::GetTableTags(SkFontID fontID, SkFontTableTag tags[]) { 1734 int SkFontHost::GetTableTags(SkFontID fontID, SkFontTableTag tags[]) {
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
1808 if (length > srcSize - offset) { 1800 if (length > srcSize - offset) {
1809 length = srcSize - offset; 1801 length = srcSize - offset;
1810 } 1802 }
1811 if (dstData) { 1803 if (dstData) {
1812 memcpy(dstData, CFDataGetBytePtr(srcData) + offset, length); 1804 memcpy(dstData, CFDataGetBytePtr(srcData) + offset, length);
1813 } 1805 }
1814 return length; 1806 return length;
1815 } 1807 }
1816 1808
1817 SkScalerContext* SkTypeface_Mac::onCreateScalerContext(const SkDescriptor* desc) const { 1809 SkScalerContext* SkTypeface_Mac::onCreateScalerContext(const SkDescriptor* desc) const {
1818 return new SkScalerContext_Mac(desc); 1810 return new SkScalerContext_Mac(const_cast<SkTypeface_Mac*>(this), desc);
1819 } 1811 }
1820 1812
1821 void SkTypeface_Mac::onFilterRec(SkScalerContextRec* rec) const { 1813 void SkTypeface_Mac::onFilterRec(SkScalerContextRec* rec) const {
1822 unsigned flagsWeDontSupport = SkScalerContext::kDevKernText_Flag | 1814 unsigned flagsWeDontSupport = SkScalerContext::kDevKernText_Flag |
1823 SkScalerContext::kAutohinting_Flag; 1815 SkScalerContext::kAutohinting_Flag;
1824 1816
1825 rec->fFlags &= ~flagsWeDontSupport; 1817 rec->fFlags &= ~flagsWeDontSupport;
1826 1818
1827 bool lcdSupport = supports_LCD(); 1819 bool lcdSupport = supports_LCD();
1828 1820
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
1887 } 1879 }
1888 1880
1889 void SkTypeface_Mac::onGetFontDescriptor(SkFontDescriptor* desc) const { 1881 void SkTypeface_Mac::onGetFontDescriptor(SkFontDescriptor* desc) const {
1890 this->INHERITED::onGetFontDescriptor(desc); 1882 this->INHERITED::onGetFontDescriptor(desc);
1891 SkString tmpStr; 1883 SkString tmpStr;
1892 1884
1893 desc->setFamilyName(get_str(CTFontCopyFamilyName(fFontRef), &tmpStr)); 1885 desc->setFamilyName(get_str(CTFontCopyFamilyName(fFontRef), &tmpStr));
1894 desc->setFullName(get_str(CTFontCopyFullName(fFontRef), &tmpStr)); 1886 desc->setFullName(get_str(CTFontCopyFullName(fFontRef), &tmpStr));
1895 desc->setPostscriptName(get_str(CTFontCopyPostScriptName(fFontRef), &tmpStr) ); 1887 desc->setPostscriptName(get_str(CTFontCopyPostScriptName(fFontRef), &tmpStr) );
1896 } 1888 }
OLDNEW
« no previous file with comments | « src/ports/SkFontHost_linux.cpp ('k') | src/ports/SkFontHost_none.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698