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

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

Issue 12683003: override SkTypeface::onOpenStream for DW (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 | « no previous file | no next file » | 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 * Copyright 2011 Google Inc. 2 * Copyright 2011 Google Inc.
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" 8 #include "SkTypes.h"
9 #undef GetGlyphIndices 9 #undef GetGlyphIndices
10 10
(...skipping 461 matching lines...) Expand 10 before | Expand all | Expand 10 after
472 ~DWriteFontTypeface() { 472 ~DWriteFontTypeface() {
473 if (fDWriteFontCollectionLoader.get() == NULL) return; 473 if (fDWriteFontCollectionLoader.get() == NULL) return;
474 474
475 IDWriteFactory* factory; 475 IDWriteFactory* factory;
476 HRVM(get_dwrite_factory(&factory), "Could not get factory."); 476 HRVM(get_dwrite_factory(&factory), "Could not get factory.");
477 HRV(factory->UnregisterFontCollectionLoader(fDWriteFontCollectionLoader. get())); 477 HRV(factory->UnregisterFontCollectionLoader(fDWriteFontCollectionLoader. get()));
478 HRV(factory->UnregisterFontFileLoader(fDWriteFontFileLoader.get())); 478 HRV(factory->UnregisterFontFileLoader(fDWriteFontFileLoader.get()));
479 } 479 }
480 480
481 protected: 481 protected:
482 virtual SkStream* onOpenStream(int* ttcIndex) const SK_OVERRIDE;
482 virtual SkScalerContext* onCreateScalerContext(const SkDescriptor*) const SK _OVERRIDE; 483 virtual SkScalerContext* onCreateScalerContext(const SkDescriptor*) const SK _OVERRIDE;
483 virtual void onFilterRec(SkScalerContextRec*) const SK_OVERRIDE; 484 virtual void onFilterRec(SkScalerContextRec*) const SK_OVERRIDE;
484 virtual SkAdvancedTypefaceMetrics* onGetAdvancedTypefaceMetrics( 485 virtual SkAdvancedTypefaceMetrics* onGetAdvancedTypefaceMetrics(
485 SkAdvancedTypefaceMetrics::PerGlyphInfo, 486 SkAdvancedTypefaceMetrics::PerGlyphInfo,
486 const uint32_t*, uint32_t) const SK_OVERRIDE; 487 const uint32_t*, uint32_t) const SK_OVERRIDE;
487 }; 488 };
488 489
489 class SkScalerContext_Windows : public SkScalerContext { 490 class SkScalerContext_Windows : public SkScalerContext {
490 public: 491 public:
491 SkScalerContext_Windows(DWriteFontTypeface*, const SkDescriptor* desc); 492 SkScalerContext_Windows(DWriteFontTypeface*, const SkDescriptor* desc);
(...skipping 493 matching lines...) Expand 10 before | Expand all | Expand 10 after
985 const bool isAA = !isLCD(fRec); 986 const bool isAA = !isLCD(fRec);
986 987
987 //Create the mask. 988 //Create the mask.
988 const void* bits = fOffscreen.draw(glyph, isBW); 989 const void* bits = fOffscreen.draw(glyph, isBW);
989 if (!bits) { 990 if (!bits) {
990 sk_bzero(glyph.fImage, glyph.computeImageSize()); 991 sk_bzero(glyph.fImage, glyph.computeImageSize());
991 return; 992 return;
992 } 993 }
993 994
994 //Copy the mask into the glyph. 995 //Copy the mask into the glyph.
995 int width = glyph.fWidth;
996 size_t dstRB = glyph.rowBytes();
997 const uint8_t* src = (const uint8_t*)bits; 996 const uint8_t* src = (const uint8_t*)bits;
998 if (isBW) { 997 if (isBW) {
999 bilevel_to_bw(src, glyph); 998 bilevel_to_bw(src, glyph);
1000 } else if (isAA) { 999 } else if (isAA) {
1001 if (fPreBlend.isApplicable()) { 1000 if (fPreBlend.isApplicable()) {
1002 rgb_to_a8<true>(src, glyph, fPreBlend.fG); 1001 rgb_to_a8<true>(src, glyph, fPreBlend.fG);
1003 } else { 1002 } else {
1004 rgb_to_a8<false>(src, glyph, fPreBlend.fG); 1003 rgb_to_a8<false>(src, glyph, fPreBlend.fG);
1005 } 1004 }
1006 } else if (SkMask::kLCD16_Format == glyph.fMaskFormat) { 1005 } else if (SkMask::kLCD16_Format == glyph.fMaskFormat) {
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
1127 1126
1128 SkTScopedComPtr<IDWriteFontFace> fontFace; 1127 SkTScopedComPtr<IDWriteFontFace> fontFace;
1129 HRN(font->CreateFontFace(&fontFace)); 1128 HRN(font->CreateFontFace(&fontFace));
1130 1129
1131 return SkCreateTypefaceFromDWriteFont(fontFace.get(), font.get(), fontFamily .get(), 1130 return SkCreateTypefaceFromDWriteFont(fontFace.get(), font.get(), fontFamily .get(),
1132 fontFileLoader.get(), streamFontCollec tionLoader.get()); 1131 fontFileLoader.get(), streamFontCollec tionLoader.get());
1133 } 1132 }
1134 1133
1135 SkStream* SkFontHost::OpenStream(SkFontID uniqueID) { 1134 SkStream* SkFontHost::OpenStream(SkFontID uniqueID) {
1136 DWriteFontTypeface* typeface = GetDWriteFontByID(uniqueID); 1135 DWriteFontTypeface* typeface = GetDWriteFontByID(uniqueID);
1137 if (NULL == typeface) { 1136 return typeface ? typeface->openStream(NULL) : NULL;
1138 return NULL; 1137 }
1139 } 1138
1139 SkStream* DWriteFontTypeface::onOpenStream(int* ttcIndex) const {
1140 *ttcIndex = 0;
1140 1141
1141 UINT32 numFiles; 1142 UINT32 numFiles;
1142 HRNM(typeface->fDWriteFontFace->GetFiles(&numFiles, NULL), 1143 HRNM(fDWriteFontFace->GetFiles(&numFiles, NULL),
1143 "Could not get number of font files."); 1144 "Could not get number of font files.");
1144 if (numFiles != 1) { 1145 if (numFiles != 1) {
1145 return NULL; 1146 return NULL;
1146 } 1147 }
1147 1148
1148 SkTScopedComPtr<IDWriteFontFile> fontFile; 1149 SkTScopedComPtr<IDWriteFontFile> fontFile;
1149 HRNM(typeface->fDWriteFontFace->GetFiles(&numFiles, &fontFile), "Could not g et font files."); 1150 HRNM(fDWriteFontFace->GetFiles(&numFiles, &fontFile), "Could not get font fi les.");
1150 1151
1151 const void* fontFileKey; 1152 const void* fontFileKey;
1152 UINT32 fontFileKeySize; 1153 UINT32 fontFileKeySize;
1153 HRNM(fontFile->GetReferenceKey(&fontFileKey, &fontFileKeySize), 1154 HRNM(fontFile->GetReferenceKey(&fontFileKey, &fontFileKeySize),
1154 "Could not get font file reference key."); 1155 "Could not get font file reference key.");
1155 1156
1156 SkTScopedComPtr<IDWriteFontFileLoader> fontFileLoader; 1157 SkTScopedComPtr<IDWriteFontFileLoader> fontFileLoader;
1157 HRNM(fontFile->GetLoader(&fontFileLoader), "Could not get font file loader." ); 1158 HRNM(fontFile->GetLoader(&fontFileLoader), "Could not get font file loader." );
1158 1159
1159 SkTScopedComPtr<IDWriteFontFileStream> fontFileStream; 1160 SkTScopedComPtr<IDWriteFontFileStream> fontFileStream;
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
1374 public: 1375 public:
1375 AutoDWriteTable(IDWriteFontFace* fontFace) 1376 AutoDWriteTable(IDWriteFontFace* fontFace)
1376 : fFontFace(fontFace) 1377 : fFontFace(fontFace)
1377 , fExists(FALSE) { 1378 , fExists(FALSE) {
1378 1379
1379 //fontFace->AddRef(); 1380 //fontFace->AddRef();
1380 const UINT32 tag = DWRITE_MAKE_OPENTYPE_TAG(T::TAG0, 1381 const UINT32 tag = DWRITE_MAKE_OPENTYPE_TAG(T::TAG0,
1381 T::TAG1, 1382 T::TAG1,
1382 T::TAG2, 1383 T::TAG2,
1383 T::TAG3); 1384 T::TAG3);
1384 HRESULT hr = fontFace->TryGetFontTable(tag, 1385 // TODO: need to check for failure
1386 /*HRESULT hr =*/ fontFace->TryGetFontTable(tag,
1385 reinterpret_cast<const void **>(&fData), &fSize, &fLock, &fExists); 1387 reinterpret_cast<const void **>(&fData), &fSize, &fLock, &fExists);
1386 } 1388 }
1387 ~AutoDWriteTable() { 1389 ~AutoDWriteTable() {
1388 if (fExists) { 1390 if (fExists) {
1389 fFontFace->ReleaseFontTable(fLock); 1391 fFontFace->ReleaseFontTable(fLock);
1390 } 1392 }
1391 } 1393 }
1392 const T* operator->() const { return fData; } 1394 const T* operator->() const { return fData; }
1393 1395
1394 const T* fData; 1396 const T* fData;
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
1554 getAdvanceData(fDWriteFontFace.get(), 1556 getAdvanceData(fDWriteFontFace.get(),
1555 glyphCount, 1557 glyphCount,
1556 glyphIDs, 1558 glyphIDs,
1557 glyphIDsCount, 1559 glyphIDsCount,
1558 getWidthAdvance)); 1560 getWidthAdvance));
1559 } 1561 }
1560 } 1562 }
1561 1563
1562 return info; 1564 return info;
1563 } 1565 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698