aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-03-21 20:16:04 +0000
committerGravatar reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-03-21 20:16:04 +0000
commit0042b9c2a2e6fe954cdfbcd5a5b7449cdf41a4c3 (patch)
tree9648991542fb39acbb90e7e0ac583fbe053497a0
parentdd4400b5a169dc28e896fffa24f778ca1ead459a (diff)
override SkTypeface::onOpenStream()
note: getTables APIs are not overridden yet, causing them to take the slow openstream case each time. We should fix this, since openStream for windows itself is slow (not native). Review URL: https://codereview.chromium.org/12941006 git-svn-id: http://skia.googlecode.com/svn/trunk@8306 2bbb7eff-a529-9590-31e7-b0007b416f81
-rwxr-xr-xsrc/ports/SkFontHost_win.cpp27
1 files changed, 19 insertions, 8 deletions
diff --git a/src/ports/SkFontHost_win.cpp b/src/ports/SkFontHost_win.cpp
index 76edd76c27..7040f7cb8b 100755
--- a/src/ports/SkFontHost_win.cpp
+++ b/src/ports/SkFontHost_win.cpp
@@ -210,6 +210,7 @@ public:
}
protected:
+ virtual SkStream* onOpenStream(int* ttcIndex) const SK_OVERRIDE;
virtual SkScalerContext* onCreateScalerContext(const SkDescriptor*) const SK_OVERRIDE;
virtual void onFilterRec(SkScalerContextRec*) const SK_OVERRIDE;
virtual SkAdvancedTypefaceMetrics* onGetAdvancedTypefaceMetrics(
@@ -1321,11 +1322,14 @@ void SkFontHost::Serialize(const SkTypeface* rawFace, SkWStream* stream) {
if (face->fSerializeAsStream) {
// store the entire font in the fontData
- SkAutoTUnref<SkStream> fontStream(SkFontHost::OpenStream(face->uniqueID()));
- const uint32_t length = fontStream->getLength();
-
- stream->writePackedUInt(length);
- stream->writeStream(fontStream, length);
+ SkAutoTUnref<SkStream> fontStream(face->openStream(NULL));
+ if (fontStream.get()) {
+ const uint32_t length = fontStream->getLength();
+ stream->writePackedUInt(length);
+ stream->writeStream(fontStream, length);
+ } else {
+ stream->writePackedUInt(0);
+ }
} else {
stream->writePackedUInt(0);
}
@@ -1588,11 +1592,12 @@ SkTypeface* SkFontHost::CreateTypefaceFromStream(SkStream* stream) {
return SkCreateFontMemResourceTypefaceFromLOGFONT(lf, fontReference);
}
-SkStream* SkFontHost::OpenStream(SkFontID uniqueID) {
+SkStream* LogFontTypeface::onOpenStream(int* ttcIndex) const {
+ *ttcIndex = 0;
+
const DWORD kTTCTag =
SkEndian_SwapBE32(SkSetFourByteTag('t', 't', 'c', 'f'));
- LOGFONT lf;
- GetLogFontByID(uniqueID, &lf);
+ LOGFONT lf = fLogFont;
HDC hdc = ::CreateCompatibleDC(NULL);
HFONT font = CreateFontIndirect(&lf);
@@ -1625,7 +1630,13 @@ SkStream* SkFontHost::OpenStream(SkFontID uniqueID) {
return stream;
}
+SkStream* SkFontHost::OpenStream(SkFontID uniqueID) {
+ SkTypeface* typeface = SkTypefaceCache::FindByID(uniqueID);
+ return typeface ? typeface->openStream(NULL) : NULL;
+}
+
size_t SkFontHost::GetFileName(SkFontID fontID, char path[], size_t length, int32_t* index) {
+ SkASSERT(!"SkFontHost::GetFileName is DEPRECATED\n");
return 0;
}