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

Side by Side Diff: src/ports/SkFontHost_FreeType.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/core/SkTypeface.cpp ('k') | src/ports/SkFontHost_FreeType_common.h » ('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 "SkBitmap.h" 9 #include "SkBitmap.h"
10 #include "SkCanvas.h" 10 #include "SkCanvas.h"
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 if (!gLCDSupportValid) { 152 if (!gLCDSupportValid) {
153 InitFreetype(); 153 InitFreetype();
154 FT_Done_FreeType(gFTLibrary); 154 FT_Done_FreeType(gFTLibrary);
155 } 155 }
156 } 156 }
157 return gLCDSupport; 157 return gLCDSupport;
158 } 158 }
159 159
160 class SkScalerContext_FreeType : public SkScalerContext_FreeType_Base { 160 class SkScalerContext_FreeType : public SkScalerContext_FreeType_Base {
161 public: 161 public:
162 SkScalerContext_FreeType(const SkDescriptor* desc); 162 SkScalerContext_FreeType(SkTypeface*, const SkDescriptor* desc);
163 virtual ~SkScalerContext_FreeType(); 163 virtual ~SkScalerContext_FreeType();
164 164
165 bool success() const { 165 bool success() const {
166 return fFaceRec != NULL && 166 return fFaceRec != NULL &&
167 fFTSize != NULL && 167 fFTSize != NULL &&
168 fFace != NULL; 168 fFace != NULL;
169 } 169 }
170 170
171 protected: 171 protected:
172 virtual unsigned generateGlyphCount() SK_OVERRIDE; 172 virtual unsigned generateGlyphCount() SK_OVERRIDE;
(...skipping 470 matching lines...) Expand 10 before | Expand all | Expand 10 after
643 return 0 == a && 0 == b; 643 return 0 == a && 0 == b;
644 } 644 }
645 645
646 // returns false if there is any non-90-rotation or skew 646 // returns false if there is any non-90-rotation or skew
647 static bool isAxisAligned(const SkScalerContext::Rec& rec) { 647 static bool isAxisAligned(const SkScalerContext::Rec& rec) {
648 return 0 == rec.fPreSkewX && 648 return 0 == rec.fPreSkewX &&
649 (bothZero(rec.fPost2x2[0][1], rec.fPost2x2[1][0]) || 649 (bothZero(rec.fPost2x2[0][1], rec.fPost2x2[1][0]) ||
650 bothZero(rec.fPost2x2[0][0], rec.fPost2x2[1][1])); 650 bothZero(rec.fPost2x2[0][0], rec.fPost2x2[1][1]));
651 } 651 }
652 652
653 void SkFontHost::FilterRec(SkScalerContext::Rec* rec, SkTypeface*) { 653 SkScalerContext* SkTypeface_FreeType::onCreateScalerContext(
654 const SkDescriptor* desc) const {
655 SkScalerContext_FreeType* c = SkNEW_ARGS(SkScalerContext_FreeType,
656 (const_cast<SkTypeface_FreeType*>(this),
657 desc));
658 if (!c->success()) {
659 SkDELETE(c);
660 c = NULL;
661 }
662 return c;
663 }
664
665 void SkTypeface_FreeType::onFilterRec(SkScalerContextRec* rec) const {
654 //BOGUS: http://code.google.com/p/chromium/issues/detail?id=121119 666 //BOGUS: http://code.google.com/p/chromium/issues/detail?id=121119
655 //Cap the requested size as larger sizes give bogus values. 667 //Cap the requested size as larger sizes give bogus values.
656 //Remove when http://code.google.com/p/skia/issues/detail?id=554 is fixed. 668 //Remove when http://code.google.com/p/skia/issues/detail?id=554 is fixed.
657 if (rec->fTextSize > SkIntToScalar(1 << 14)) { 669 if (rec->fTextSize > SkIntToScalar(1 << 14)) {
658 rec->fTextSize = SkIntToScalar(1 << 14); 670 rec->fTextSize = SkIntToScalar(1 << 14);
659 } 671 }
660 672
661 if (!is_lcd_supported() && isLCD(*rec)) { 673 if (!is_lcd_supported() && isLCD(*rec)) {
662 // If the runtime Freetype library doesn't support LCD mode, we disable 674 // If the runtime Freetype library doesn't support LCD mode, we disable
663 // it here. 675 // it here.
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
703 715
704 if (rec != NULL && rec->fFace != NULL) { 716 if (rec != NULL && rec->fFace != NULL) {
705 unitsPerEm = rec->fFace->units_per_EM; 717 unitsPerEm = rec->fFace->units_per_EM;
706 unref_ft_face(rec->fFace); 718 unref_ft_face(rec->fFace);
707 } 719 }
708 720
709 return (uint32_t)unitsPerEm; 721 return (uint32_t)unitsPerEm;
710 } 722 }
711 #endif 723 #endif
712 724
713 SkScalerContext_FreeType::SkScalerContext_FreeType(const SkDescriptor* desc) 725 SkScalerContext_FreeType::SkScalerContext_FreeType(SkTypeface* typeface,
714 : SkScalerContext_FreeType_Base(desc) { 726 const SkDescriptor* desc)
727 : SkScalerContext_FreeType_Base(typeface, desc) {
715 SkAutoMutexAcquire ac(gFTMutex); 728 SkAutoMutexAcquire ac(gFTMutex);
716 729
717 if (gFTCount == 0) { 730 if (gFTCount == 0) {
718 if (!InitFreetype()) { 731 if (!InitFreetype()) {
719 sk_throw(); 732 sk_throw();
720 } 733 }
721 } 734 }
722 ++gFTCount; 735 ++gFTCount;
723 736
724 // load the font file 737 // load the font file
(...skipping 568 matching lines...) Expand 10 before | Expand all | Expand 10 after
1293 my->fAvgCharWidth = pts[5].fY; 1306 my->fAvgCharWidth = pts[5].fY;
1294 my->fXMin = xmin; 1307 my->fXMin = xmin;
1295 my->fXMax = xmax; 1308 my->fXMax = xmax;
1296 my->fXHeight = x_height; 1309 my->fXHeight = x_height;
1297 } 1310 }
1298 } 1311 }
1299 1312
1300 //////////////////////////////////////////////////////////////////////// 1313 ////////////////////////////////////////////////////////////////////////
1301 //////////////////////////////////////////////////////////////////////// 1314 ////////////////////////////////////////////////////////////////////////
1302 1315
1303 SkScalerContext* SkFontHost::CreateScalerContext(const SkDescriptor* desc) {
1304 SkScalerContext_FreeType* c = SkNEW_ARGS(SkScalerContext_FreeType, (desc));
1305 if (!c->success()) {
1306 SkDELETE(c);
1307 c = NULL;
1308 }
1309 return c;
1310 }
1311
1312 ///////////////////////////////////////////////////////////////////////////////
1313
1314 /* Export this so that other parts of our FonttHost port can make use of our 1316 /* Export this so that other parts of our FonttHost port can make use of our
1315 ability to extract the name+style from a stream, using FreeType's api. 1317 ability to extract the name+style from a stream, using FreeType's api.
1316 */ 1318 */
1317 bool find_name_and_attributes(SkStream* stream, SkString* name, 1319 bool find_name_and_attributes(SkStream* stream, SkString* name,
1318 SkTypeface::Style* style, bool* isFixedWidth) { 1320 SkTypeface::Style* style, bool* isFixedWidth) {
1319 FT_Library library; 1321 FT_Library library;
1320 if (FT_Init_FreeType(&library)) { 1322 if (FT_Init_FreeType(&library)) {
1321 return false; 1323 return false;
1322 } 1324 }
1323 1325
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
1363 *style = (SkTypeface::Style) tempStyle; 1365 *style = (SkTypeface::Style) tempStyle;
1364 } 1366 }
1365 if (isFixedWidth) { 1367 if (isFixedWidth) {
1366 *isFixedWidth = FT_IS_FIXED_WIDTH(face); 1368 *isFixedWidth = FT_IS_FIXED_WIDTH(face);
1367 } 1369 }
1368 1370
1369 FT_Done_Face(face); 1371 FT_Done_Face(face);
1370 FT_Done_FreeType(library); 1372 FT_Done_FreeType(library);
1371 return true; 1373 return true;
1372 } 1374 }
OLDNEW
« no previous file with comments | « src/core/SkTypeface.cpp ('k') | src/ports/SkFontHost_FreeType_common.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698