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

Side by Side Diff: src/ports/SkFontHost_win.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_simple.cpp ('k') | src/ports/SkFontHost_win_dw.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 "SkAdvancedTypefaceMetrics.h" 9 #include "SkAdvancedTypefaceMetrics.h"
10 #include "SkBase64.h" 10 #include "SkBase64.h"
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 183
184 LOGFONT fLogFont; 184 LOGFONT fLogFont;
185 bool fSerializeAsStream; 185 bool fSerializeAsStream;
186 bool fCanBeLCD; 186 bool fCanBeLCD;
187 187
188 static LogFontTypeface* Create(const LOGFONT& lf) { 188 static LogFontTypeface* Create(const LOGFONT& lf) {
189 SkTypeface::Style style = get_style(lf); 189 SkTypeface::Style style = get_style(lf);
190 SkFontID fontID = SkTypefaceCache::NewFontID(); 190 SkFontID fontID = SkTypefaceCache::NewFontID();
191 return new LogFontTypeface(style, fontID, lf); 191 return new LogFontTypeface(style, fontID, lf);
192 } 192 }
193
194 protected:
195 virtual SkScalerContext* onCreateScalerContext(const SkDescriptor*) const SK _OVERRIDE;
196 virtual void onFilterRec(SkScalerContextRec*) const SK_OVERRIDE;
193 }; 197 };
194 198
195 class FontMemResourceTypeface : public LogFontTypeface { 199 class FontMemResourceTypeface : public LogFontTypeface {
196 public: 200 public:
197 /** 201 /**
198 * Takes ownership of fontMemResource. 202 * Takes ownership of fontMemResource.
199 */ 203 */
200 FontMemResourceTypeface(SkTypeface::Style style, SkFontID fontID, const LOGF ONT& lf, HANDLE fontMemResource) : 204 FontMemResourceTypeface(SkTypeface::Style style, SkFontID fontID, const LOGF ONT& lf, HANDLE fontMemResource) :
201 LogFontTypeface(style, fontID, lf, true), fFontMemResource(fontMemResour ce) { 205 LogFontTypeface(style, fontID, lf, true), fFontMemResource(fontMemResour ce) {
202 } 206 }
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 * This guy is public 271 * This guy is public
268 */ 272 */
269 void SkLOGFONTFromTypeface(const SkTypeface* face, LOGFONT* lf) { 273 void SkLOGFONTFromTypeface(const SkTypeface* face, LOGFONT* lf) {
270 if (NULL == face) { 274 if (NULL == face) {
271 *lf = get_default_font(); 275 *lf = get_default_font();
272 } else { 276 } else {
273 *lf = static_cast<const LogFontTypeface*>(face)->fLogFont; 277 *lf = static_cast<const LogFontTypeface*>(face)->fLogFont;
274 } 278 }
275 } 279 }
276 280
277 SkFontID SkFontHost::NextLogicalFont(SkFontID currFontID, SkFontID origFontID) { 281 SkTypeface* SkFontHost::NextLogicalTypeface(SkFontID currFontID, SkFontID origFo ntID) {
278 // Zero means that we don't have any fallback fonts for this fontID. 282 // Zero means that we don't have any fallback fonts for this fontID.
279 // This function is implemented on Android, but doesn't have much 283 // This function is implemented on Android, but doesn't have much
280 // meaning here. 284 // meaning here.
281 return 0; 285 return NULL;
282 } 286 }
283 287
284 static void ensure_typeface_accessible(SkFontID fontID) { 288 static void ensure_typeface_accessible(SkFontID fontID) {
285 LogFontTypeface* face = static_cast<LogFontTypeface*>(SkTypefaceCache::FindB yID(fontID)); 289 LogFontTypeface* face = static_cast<LogFontTypeface*>(SkTypefaceCache::FindB yID(fontID));
286 if (face) { 290 if (face) {
287 SkFontHost::EnsureTypefaceAccessible(*face); 291 SkFontHost::EnsureTypefaceAccessible(*face);
288 } 292 }
289 } 293 }
290 294
291 static void GetLogFontByID(SkFontID fontID, LOGFONT* lf) { 295 static void GetLogFontByID(SkFontID fontID, LOGFONT* lf) {
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
474 } 478 }
475 *srcRBPtr = srcRB; 479 *srcRBPtr = srcRB;
476 // offset to the start of the image 480 // offset to the start of the image
477 return (const char*)fBits + (fHeight - glyph.fHeight) * srcRB; 481 return (const char*)fBits + (fHeight - glyph.fHeight) * srcRB;
478 } 482 }
479 483
480 ////////////////////////////////////////////////////////////////////////////// 484 //////////////////////////////////////////////////////////////////////////////
481 485
482 class SkScalerContext_Windows : public SkScalerContext { 486 class SkScalerContext_Windows : public SkScalerContext {
483 public: 487 public:
484 SkScalerContext_Windows(const SkDescriptor* desc); 488 SkScalerContext_Windows(SkTypeface*, const SkDescriptor* desc);
485 virtual ~SkScalerContext_Windows(); 489 virtual ~SkScalerContext_Windows();
486 490
487 protected: 491 protected:
488 virtual unsigned generateGlyphCount() SK_OVERRIDE; 492 virtual unsigned generateGlyphCount() SK_OVERRIDE;
489 virtual uint16_t generateCharToGlyph(SkUnichar uni) SK_OVERRIDE; 493 virtual uint16_t generateCharToGlyph(SkUnichar uni) SK_OVERRIDE;
490 virtual void generateAdvance(SkGlyph* glyph) SK_OVERRIDE; 494 virtual void generateAdvance(SkGlyph* glyph) SK_OVERRIDE;
491 virtual void generateMetrics(SkGlyph* glyph) SK_OVERRIDE; 495 virtual void generateMetrics(SkGlyph* glyph) SK_OVERRIDE;
492 virtual void generateImage(const SkGlyph& glyph) SK_OVERRIDE; 496 virtual void generateImage(const SkGlyph& glyph) SK_OVERRIDE;
493 virtual void generatePath(const SkGlyph& glyph, SkPath* path) SK_OVERRIDE; 497 virtual void generatePath(const SkGlyph& glyph, SkPath* path) SK_OVERRIDE;
494 virtual void generateFontMetrics(SkPaint::FontMetrics* mX, 498 virtual void generateFontMetrics(SkPaint::FontMetrics* mX,
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
542 return CLEARTYPE_QUALITY; 546 return CLEARTYPE_QUALITY;
543 default: 547 default:
544 if (rec.fFlags & SkScalerContext::kGenA8FromLCD_Flag) { 548 if (rec.fFlags & SkScalerContext::kGenA8FromLCD_Flag) {
545 return CLEARTYPE_QUALITY; 549 return CLEARTYPE_QUALITY;
546 } else { 550 } else {
547 return ANTIALIASED_QUALITY; 551 return ANTIALIASED_QUALITY;
548 } 552 }
549 } 553 }
550 } 554 }
551 555
552 SkScalerContext_Windows::SkScalerContext_Windows(const SkDescriptor* desc) 556 SkScalerContext_Windows::SkScalerContext_Windows(SkTypeface* typeface,
553 : SkScalerContext(desc), fDDC(0), fFont(0), fSavefont(0), fSC(0) 557 const SkDescriptor* desc)
558 : SkScalerContext(typeface, desc), fDDC(0), fFont(0), fSavefont(0), fSC( 0)
554 , fGlyphCount(-1) { 559 , fGlyphCount(-1) {
555 SkAutoMutexAcquire ac(gFTMutex); 560 SkAutoMutexAcquire ac(gFTMutex);
556 561
557 fDDC = ::CreateCompatibleDC(NULL); 562 fDDC = ::CreateCompatibleDC(NULL);
558 SetGraphicsMode(fDDC, GM_ADVANCED); 563 SetGraphicsMode(fDDC, GM_ADVANCED);
559 SetBkMode(fDDC, TRANSPARENT); 564 SetBkMode(fDDC, TRANSPARENT);
560 565
561 // Scaling by the DPI is inconsistent with how Skia draws elsewhere 566 // Scaling by the DPI is inconsistent with how Skia draws elsewhere
562 //SkScalar height = -(fRec.fTextSize * GetDeviceCaps(ddc, LOGPIXELSY) / 72); 567 //SkScalar height = -(fRec.fTextSize * GetDeviceCaps(ddc, LOGPIXELSY) / 72);
563 LOGFONT lf; 568 LOGFONT lf;
(...skipping 1037 matching lines...) Expand 10 before | Expand all | Expand 10 after
1601 DeleteObject(font); 1606 DeleteObject(font);
1602 DeleteDC(hdc); 1607 DeleteDC(hdc);
1603 1608
1604 return stream; 1609 return stream;
1605 } 1610 }
1606 1611
1607 size_t SkFontHost::GetFileName(SkFontID fontID, char path[], size_t length, int3 2_t* index) { 1612 size_t SkFontHost::GetFileName(SkFontID fontID, char path[], size_t length, int3 2_t* index) {
1608 return 0; 1613 return 0;
1609 } 1614 }
1610 1615
1611 SkScalerContext* SkFontHost::CreateScalerContext(const SkDescriptor* desc) { 1616 SkScalerContext* LogFontTypeface::onCreateScalerContext(const SkDescriptor* desc ) const {
1612 return SkNEW_ARGS(SkScalerContext_Windows, (desc)); 1617 return SkNEW_ARGS(SkScalerContext_Windows, (const_cast<LogFontTypeface*>(thi s), desc));
1613 } 1618 }
1614 1619
1615 /** Return the closest matching typeface given either an existing family 1620 /** Return the closest matching typeface given either an existing family
1616 (specified by a typeface in that family) or by a familyName, and a 1621 (specified by a typeface in that family) or by a familyName, and a
1617 requested style. 1622 requested style.
1618 1) If familyFace is null, use familyName. 1623 1) If familyFace is null, use familyName.
1619 2) If familyName is null, use familyFace. 1624 2) If familyName is null, use familyFace.
1620 3) If both are null, return the default font that best matches style 1625 3) If both are null, return the default font that best matches style
1621 This MUST not return NULL. 1626 This MUST not return NULL.
1622 */ 1627 */
(...skipping 12 matching lines...) Expand all
1635 } 1640 }
1636 setStyle(&lf, style); 1641 setStyle(&lf, style);
1637 return SkCreateTypefaceFromLOGFONT(lf); 1642 return SkCreateTypefaceFromLOGFONT(lf);
1638 } 1643 }
1639 1644
1640 SkTypeface* SkFontHost::CreateTypefaceFromFile(const char path[]) { 1645 SkTypeface* SkFontHost::CreateTypefaceFromFile(const char path[]) {
1641 SkAutoTUnref<SkStream> stream(SkStream::NewFromFile(path)); 1646 SkAutoTUnref<SkStream> stream(SkStream::NewFromFile(path));
1642 return stream.get() ? CreateTypefaceFromStream(stream) : NULL; 1647 return stream.get() ? CreateTypefaceFromStream(stream) : NULL;
1643 } 1648 }
1644 1649
1645 void SkFontHost::FilterRec(SkScalerContext::Rec* rec, SkTypeface* typeface) { 1650 void LogFontTypeface::onFilterRec(SkScalerContextRec* rec) const {
1646 unsigned flagsWeDontSupport = SkScalerContext::kDevKernText_Flag | 1651 unsigned flagsWeDontSupport = SkScalerContext::kDevKernText_Flag |
1647 SkScalerContext::kAutohinting_Flag | 1652 SkScalerContext::kAutohinting_Flag |
1648 SkScalerContext::kEmbeddedBitmapText_Flag | 1653 SkScalerContext::kEmbeddedBitmapText_Flag |
1649 SkScalerContext::kEmbolden_Flag | 1654 SkScalerContext::kEmbolden_Flag |
1650 SkScalerContext::kSubpixelPositioning_Flag | 1655 SkScalerContext::kSubpixelPositioning_Flag |
1651 SkScalerContext::kLCD_BGROrder_Flag | 1656 SkScalerContext::kLCD_BGROrder_Flag |
1652 SkScalerContext::kLCD_Vertical_Flag; 1657 SkScalerContext::kLCD_Vertical_Flag;
1653 rec->fFlags &= ~flagsWeDontSupport; 1658 rec->fFlags &= ~flagsWeDontSupport;
1654 1659
1655 SkPaint::Hinting h = rec->getHinting(); 1660 SkPaint::Hinting h = rec->getHinting();
(...skipping 19 matching lines...) Expand all
1675 rec->setHinting(h); 1680 rec->setHinting(h);
1676 1681
1677 // turn this off since GDI might turn A8 into BW! Need a bigger fix. 1682 // turn this off since GDI might turn A8 into BW! Need a bigger fix.
1678 #if 0 1683 #if 0
1679 // Disable LCD when rotated, since GDI's output is ugly 1684 // Disable LCD when rotated, since GDI's output is ugly
1680 if (isLCD(*rec) && !isAxisAligned(*rec)) { 1685 if (isLCD(*rec) && !isAxisAligned(*rec)) {
1681 rec->fMaskFormat = SkMask::kA8_Format; 1686 rec->fMaskFormat = SkMask::kA8_Format;
1682 } 1687 }
1683 #endif 1688 #endif
1684 1689
1685 LogFontTypeface* logfontTypeface = static_cast<LogFontTypeface*>(typeface); 1690 if (!fCanBeLCD && isLCD(*rec)) {
1686 if (!logfontTypeface->fCanBeLCD && isLCD(*rec)) {
1687 rec->fMaskFormat = SkMask::kA8_Format; 1691 rec->fMaskFormat = SkMask::kA8_Format;
1688 rec->fFlags &= ~SkScalerContext::kGenA8FromLCD_Flag; 1692 rec->fFlags &= ~SkScalerContext::kGenA8FromLCD_Flag;
1689 } 1693 }
1690 } 1694 }
OLDNEW
« no previous file with comments | « src/ports/SkFontHost_simple.cpp ('k') | src/ports/SkFontHost_win_dw.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698