diff options
author | bungeman <bungeman@google.com> | 2015-01-27 05:39:10 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-01-27 05:39:10 -0800 |
commit | 5f213d9627d2eefa7da81cd97f36754f75eb4ae9 (patch) | |
tree | ab4712f955c73a4a8d97a9910176b12902dde642 /src | |
parent | dc14fa4ec7739465d9bb9dbf1f0e537c80ad867f (diff) |
SkTypeface to use SkStreamAsset.
SkTypeface already requires typeface streams to support SkStreamAsset
in practice, and in practice all users are already supplying them.
Review URL: https://codereview.chromium.org/869763002
Diffstat (limited to 'src')
-rw-r--r-- | src/core/SkFontDescriptor.h | 6 | ||||
-rw-r--r-- | src/core/SkFontMgr.cpp | 4 | ||||
-rw-r--r-- | src/core/SkTypeface.cpp | 8 | ||||
-rw-r--r-- | src/fonts/SkFontMgr_fontconfig.cpp | 8 | ||||
-rw-r--r-- | src/fonts/SkFontMgr_indirect.cpp | 4 | ||||
-rw-r--r-- | src/fonts/SkGScalerContext.cpp | 2 | ||||
-rw-r--r-- | src/fonts/SkGScalerContext.h | 2 | ||||
-rw-r--r-- | src/fonts/SkTestScalerContext.h | 2 | ||||
-rw-r--r-- | src/ports/SkFontConfigInterface_direct.cpp | 4 | ||||
-rw-r--r-- | src/ports/SkFontConfigTypeface.h | 10 | ||||
-rw-r--r-- | src/ports/SkFontHost_fontconfig.cpp | 42 | ||||
-rw-r--r-- | src/ports/SkFontHost_linux.cpp | 18 | ||||
-rwxr-xr-x | src/ports/SkFontHost_mac.cpp | 6 | ||||
-rwxr-xr-x | src/ports/SkFontHost_win.cpp | 10 | ||||
-rw-r--r-- | src/ports/SkFontMgr_android.cpp | 16 | ||||
-rw-r--r-- | src/ports/SkFontMgr_fontconfig.cpp | 8 | ||||
-rw-r--r-- | src/ports/SkFontMgr_win_dw.cpp | 4 | ||||
-rw-r--r-- | src/ports/SkTypeface_win_dw.cpp | 2 | ||||
-rw-r--r-- | src/ports/SkTypeface_win_dw.h | 2 | ||||
-rw-r--r-- | src/sfnt/SkOTUtils.cpp | 2 | ||||
-rw-r--r-- | src/sfnt/SkOTUtils.h | 2 |
21 files changed, 71 insertions, 91 deletions
diff --git a/src/core/SkFontDescriptor.h b/src/core/SkFontDescriptor.h index aafbe84dec..13f9cb7257 100644 --- a/src/core/SkFontDescriptor.h +++ b/src/core/SkFontDescriptor.h @@ -29,7 +29,7 @@ public: const char* getFontFileName() const { return fFontFileName.c_str(); } bool hasFontData() const { return fFontData.get() != NULL; } // Transfers ownership to the caller. - SkStream* transferFontData() { return fFontData.detach(); } + SkStreamAsset* transferFontData() { return fFontData.detach(); } int getFontIndex() const { return fFontIndex; } void setFamilyName(const char* name) { fFamilyName.set(name); } @@ -39,7 +39,7 @@ public: /** Set the font data only if it is necessary for serialization. * This method takes ownership of the stream (both reference and cursor). */ - void setFontData(SkStream* stream) { fFontData.reset(stream); } + void setFontData(SkStreamAsset* stream) { fFontData.reset(stream); } void setFontIndex(int index) { fFontIndex = index; } private: @@ -47,7 +47,7 @@ private: SkString fFullName; SkString fPostscriptName; SkString fFontFileName; - SkAutoTDelete<SkStream> fFontData; + SkAutoTDelete<SkStreamAsset> fFontData; int fFontIndex; SkTypeface::Style fStyle; diff --git a/src/core/SkFontMgr.cpp b/src/core/SkFontMgr.cpp index 71289a67a6..4e0f549896 100644 --- a/src/core/SkFontMgr.cpp +++ b/src/core/SkFontMgr.cpp @@ -68,7 +68,7 @@ protected: SkTypeface* onCreateFromData(SkData*, int) const SK_OVERRIDE { return NULL; } - SkTypeface* onCreateFromStream(SkStream* stream, int) const SK_OVERRIDE { + SkTypeface* onCreateFromStream(SkStreamAsset* stream, int) const SK_OVERRIDE { SkDELETE(stream); return NULL; } @@ -126,7 +126,7 @@ SkTypeface* SkFontMgr::createFromData(SkData* data, int ttcIndex) const { return this->onCreateFromData(data, ttcIndex); } -SkTypeface* SkFontMgr::createFromStream(SkStream* stream, int ttcIndex) const { +SkTypeface* SkFontMgr::createFromStream(SkStreamAsset* stream, int ttcIndex) const { if (NULL == stream) { return NULL; } diff --git a/src/core/SkTypeface.cpp b/src/core/SkTypeface.cpp index b86cfa7caf..84cab097e0 100644 --- a/src/core/SkTypeface.cpp +++ b/src/core/SkTypeface.cpp @@ -29,7 +29,7 @@ public: protected: SkEmptyTypeface() : SkTypeface(SkFontStyle(), 0, true) { } - SkStream* onOpenStream(int* ttcIndex) const SK_OVERRIDE { return NULL; } + SkStreamAsset* onOpenStream(int* ttcIndex) const SK_OVERRIDE { return NULL; } SkScalerContext* onCreateScalerContext(const SkDescriptor*) const SK_OVERRIDE { return NULL; } @@ -138,7 +138,7 @@ SkTypeface* SkTypeface::CreateFromTypeface(const SkTypeface* family, Style s) { return fm->matchFaceStyle(family, newStyle); } -SkTypeface* SkTypeface::CreateFromStream(SkStream* stream, int index) { +SkTypeface* SkTypeface::CreateFromStream(SkStreamAsset* stream, int index) { SkAutoTUnref<SkFontMgr> fm(SkFontMgr::RefDefault()); return fm->createFromStream(stream, index); } @@ -180,7 +180,7 @@ void SkTypeface::serializeForcingEmbedding(SkWStream* wstream) const { SkTypeface* SkTypeface::Deserialize(SkStream* stream) { SkFontDescriptor desc(stream); - SkStream* data = desc.transferFontData(); + SkStreamAsset* data = desc.transferFontData(); if (data) { SkTypeface* typeface = SkTypeface::CreateFromStream(data, desc.getFontIndex()); if (typeface) { @@ -209,7 +209,7 @@ size_t SkTypeface::getTableData(SkFontTableTag tag, size_t offset, size_t length return this->onGetTableData(tag, offset, length, data); } -SkStream* SkTypeface::openStream(int* ttcIndex) const { +SkStreamAsset* SkTypeface::openStream(int* ttcIndex) const { int ttcIndexStorage; if (NULL == ttcIndex) { // So our subclasses don't need to check for null param diff --git a/src/fonts/SkFontMgr_fontconfig.cpp b/src/fonts/SkFontMgr_fontconfig.cpp index c1d531d3f5..ba2dae8be3 100644 --- a/src/fonts/SkFontMgr_fontconfig.cpp +++ b/src/fonts/SkFontMgr_fontconfig.cpp @@ -295,8 +295,8 @@ protected: SkTypeface* onCreateFromData(SkData*, int ttcIndex) const SK_OVERRIDE { return NULL; } - SkTypeface* onCreateFromStream(SkStream* stream, int ttcIndex) const SK_OVERRIDE { - SkAutoTDelete<SkStream> streamDeleter(stream); + SkTypeface* onCreateFromStream(SkStreamAsset* bareStream, int ttcIndex) const SK_OVERRIDE { + SkAutoTDelete<SkStreamAsset> stream(bareStream); const size_t length = stream->getLength(); if (!length) { return NULL; @@ -312,12 +312,12 @@ protected: return NULL; } - SkTypeface* face = FontConfigTypeface::Create(style, isFixedWidth, streamDeleter.detach()); + SkTypeface* face = FontConfigTypeface::Create(style, isFixedWidth, stream.detach()); return face; } SkTypeface* onCreateFromFile(const char path[], int ttcIndex) const SK_OVERRIDE { - SkAutoTDelete<SkStream> stream(SkStream::NewFromFile(path)); + SkAutoTDelete<SkStreamAsset> stream(SkStream::NewFromFile(path)); return stream.get() ? this->createFromStream(stream.detach(), ttcIndex) : NULL; } diff --git a/src/fonts/SkFontMgr_indirect.cpp b/src/fonts/SkFontMgr_indirect.cpp index 6f94dfd367..5615a78c21 100644 --- a/src/fonts/SkFontMgr_indirect.cpp +++ b/src/fonts/SkFontMgr_indirect.cpp @@ -213,7 +213,7 @@ SkTypeface* SkFontMgr_Indirect::createTypefaceFromFontId(const SkFontIdentity& i // No exact match, but did find a data match. if (dataTypeface.get() != NULL) { - SkAutoTDelete<SkStream> stream(dataTypeface->openStream(NULL)); + SkAutoTDelete<SkStreamAsset> stream(dataTypeface->openStream(NULL)); if (stream.get() != NULL) { return fImpl->createFromStream(stream.detach(), dataTypefaceIndex); } @@ -262,7 +262,7 @@ SkTypeface* SkFontMgr_Indirect::onMatchFaceStyle(const SkTypeface* familyMember, return this->matchFamilyStyle(familyName.c_str(), fontStyle); } -SkTypeface* SkFontMgr_Indirect::onCreateFromStream(SkStream* stream, int ttcIndex) const { +SkTypeface* SkFontMgr_Indirect::onCreateFromStream(SkStreamAsset* stream, int ttcIndex) const { return fImpl->createFromStream(stream, ttcIndex); } diff --git a/src/fonts/SkGScalerContext.cpp b/src/fonts/SkGScalerContext.cpp index 7c447090e1..cd5db5f9f8 100644 --- a/src/fonts/SkGScalerContext.cpp +++ b/src/fonts/SkGScalerContext.cpp @@ -184,7 +184,7 @@ SkAdvancedTypefaceMetrics* SkGTypeface::onGetAdvancedTypefaceMetrics( return fProxy->getAdvancedTypefaceMetrics(info, glyphIDs, glyphIDsCount); } -SkStream* SkGTypeface::onOpenStream(int* ttcIndex) const { +SkStreamAsset* SkGTypeface::onOpenStream(int* ttcIndex) const { return fProxy->openStream(ttcIndex); } diff --git a/src/fonts/SkGScalerContext.h b/src/fonts/SkGScalerContext.h index 54af3c39d3..05dc483007 100644 --- a/src/fonts/SkGScalerContext.h +++ b/src/fonts/SkGScalerContext.h @@ -26,7 +26,7 @@ protected: SkAdvancedTypefaceMetrics::PerGlyphInfo, const uint32_t* glyphIDs, uint32_t glyphIDsCount) const SK_OVERRIDE; - SkStream* onOpenStream(int* ttcIndex) const SK_OVERRIDE; + SkStreamAsset* onOpenStream(int* ttcIndex) const SK_OVERRIDE; void onGetFontDescriptor(SkFontDescriptor*, bool* isLocal) const SK_OVERRIDE; virtual int onCharsToGlyphs(const void* chars, Encoding encoding, diff --git a/src/fonts/SkTestScalerContext.h b/src/fonts/SkTestScalerContext.h index 6a78e5a1b4..49e9b779a5 100644 --- a/src/fonts/SkTestScalerContext.h +++ b/src/fonts/SkTestScalerContext.h @@ -73,7 +73,7 @@ protected: const uint32_t* glyphIDs, uint32_t glyphIDsCount) const SK_OVERRIDE; - SkStream* onOpenStream(int* ttcIndex) const SK_OVERRIDE { + SkStreamAsset* onOpenStream(int* ttcIndex) const SK_OVERRIDE { SkASSERT(0); // don't expect to get here return NULL; } diff --git a/src/ports/SkFontConfigInterface_direct.cpp b/src/ports/SkFontConfigInterface_direct.cpp index 124ca2a907..0f2d882ca8 100644 --- a/src/ports/SkFontConfigInterface_direct.cpp +++ b/src/ports/SkFontConfigInterface_direct.cpp @@ -112,7 +112,7 @@ public: FontIdentity* outFontIdentifier, SkString* outFamilyName, SkTypeface::Style* outStyle) SK_OVERRIDE; - SkStream* openStream(const FontIdentity&) SK_OVERRIDE; + SkStreamAsset* openStream(const FontIdentity&) SK_OVERRIDE; // new APIs SkDataTable* getFamilyNames() SK_OVERRIDE; @@ -552,7 +552,7 @@ bool SkFontConfigInterfaceDirect::matchFamilyName(const char familyName[], return true; } -SkStream* SkFontConfigInterfaceDirect::openStream(const FontIdentity& identity) { +SkStreamAsset* SkFontConfigInterfaceDirect::openStream(const FontIdentity& identity) { return SkStream::NewFromFile(identity.fString.c_str()); } diff --git a/src/ports/SkFontConfigTypeface.h b/src/ports/SkFontConfigTypeface.h index 821f4908d5..83cd3ad218 100644 --- a/src/ports/SkFontConfigTypeface.h +++ b/src/ports/SkFontConfigTypeface.h @@ -15,7 +15,7 @@ class SkFontDescriptor; class FontConfigTypeface : public SkTypeface_FreeType { SkFontConfigInterface::FontIdentity fIdentity; SkString fFamilyName; - SkAutoTDelete<SkStream> fLocalStream; + SkAutoTDelete<SkStreamAsset> fLocalStream; public: static FontConfigTypeface* Create(const SkFontStyle& style, @@ -25,7 +25,7 @@ public: } static FontConfigTypeface* Create(const SkFontStyle& style, bool fixedWidth, - SkStream* localStream) { + SkStreamAsset* localStream) { return SkNEW_ARGS(FontConfigTypeface, (style, fixedWidth, localStream)); } @@ -34,7 +34,7 @@ public: } const char* getFamilyName() const { return fFamilyName.c_str(); } - SkStream* getLocalStream() const { return fLocalStream.get(); } + SkStreamAsset* getLocalStream() const { return fLocalStream.get(); } bool isFamilyName(const char* name) const { return fFamilyName.equals(name); @@ -55,7 +55,7 @@ protected: , fFamilyName(familyName) , fLocalStream(NULL) {} - FontConfigTypeface(const SkFontStyle& style, bool fixedWidth, SkStream* localStream) + FontConfigTypeface(const SkFontStyle& style, bool fixedWidth, SkStreamAsset* localStream) : INHERITED(style, SkTypefaceCache::NewFontID(), fixedWidth) , fLocalStream(localStream) { // we default to empty fFamilyName and fIdentity @@ -63,7 +63,7 @@ protected: void onGetFamilyName(SkString* familyName) const SK_OVERRIDE; void onGetFontDescriptor(SkFontDescriptor*, bool*) const SK_OVERRIDE; - SkStream* onOpenStream(int* ttcIndex) const SK_OVERRIDE; + SkStreamAsset* onOpenStream(int* ttcIndex) const SK_OVERRIDE; private: typedef SkTypeface_FreeType INHERITED; diff --git a/src/ports/SkFontHost_fontconfig.cpp b/src/ports/SkFontHost_fontconfig.cpp index 4c577d8c27..591e9d5aed 100644 --- a/src/ports/SkFontHost_fontconfig.cpp +++ b/src/ports/SkFontHost_fontconfig.cpp @@ -126,41 +126,21 @@ SkTypeface* FontConfigTypeface::LegacyCreateTypeface( /////////////////////////////////////////////////////////////////////////////// -SkStream* FontConfigTypeface::onOpenStream(int* ttcIndex) const { - SkStream* stream = this->getLocalStream(); +SkStreamAsset* FontConfigTypeface::onOpenStream(int* ttcIndex) const { + SkStreamAsset* stream = this->getLocalStream(); if (stream) { - // should have been provided by CreateFromStream() + // TODO: should have been provided by CreateFromStream() *ttcIndex = 0; + return stream->duplicate(); + } - SkAutoTDelete<SkStream> dupStream(stream->duplicate()); - if (dupStream) { - return dupStream.detach(); - } - - // TODO: update interface use, remove the following code in this block. - size_t length = stream->getLength(); - - const void* memory = stream->getMemoryBase(); - if (memory) { - return new SkMemoryStream(memory, length, true); - } - - SkAutoTMalloc<uint8_t> allocMemory(length); - stream->rewind(); - if (length == stream->read(allocMemory.get(), length)) { - SkAutoTDelete<SkMemoryStream> copyStream(new SkMemoryStream()); - copyStream->setMemoryOwned(allocMemory.detach(), length); - return copyStream.detach(); - } - } else { - SkAutoTUnref<SkFontConfigInterface> fci(RefFCI()); - if (NULL == fci.get()) { - return NULL; - } - stream = fci->openStream(this->getIdentity()); - *ttcIndex = this->getIdentity().fTTCIndex; + SkAutoTUnref<SkFontConfigInterface> fci(RefFCI()); + if (NULL == fci.get()) { + return NULL; } - return stream; + + *ttcIndex = this->getIdentity().fTTCIndex; + return fci->openStream(this->getIdentity()); } void FontConfigTypeface::onGetFamilyName(SkString* familyName) const { diff --git a/src/ports/SkFontHost_linux.cpp b/src/ports/SkFontHost_linux.cpp index 86d431dd41..c6f932fe6a 100644 --- a/src/ports/SkFontHost_linux.cpp +++ b/src/ports/SkFontHost_linux.cpp @@ -73,7 +73,7 @@ public: const char* getUniqueString() const SK_OVERRIDE { return NULL; } protected: - SkStream* onOpenStream(int*) const SK_OVERRIDE { return NULL; } + SkStreamAsset* onOpenStream(int*) const SK_OVERRIDE { return NULL; } private: typedef SkTypeface_Custom INHERITED; @@ -83,7 +83,7 @@ private: class SkTypeface_Stream : public SkTypeface_Custom { public: SkTypeface_Stream(const SkFontStyle& style, bool isFixedPitch, bool sysFont, - const SkString familyName, SkStream* stream, int index) + const SkString familyName, SkStreamAsset* stream, int index) : INHERITED(style, isFixedPitch, sysFont, familyName, index) , fStream(stream) { } @@ -91,13 +91,13 @@ public: const char* getUniqueString() const SK_OVERRIDE { return NULL; } protected: - SkStream* onOpenStream(int* ttcIndex) const SK_OVERRIDE { + SkStreamAsset* onOpenStream(int* ttcIndex) const SK_OVERRIDE { *ttcIndex = this->getIndex(); return fStream->duplicate(); } private: - const SkAutoTDelete<const SkStream> fStream; + const SkAutoTDelete<const SkStreamAsset> fStream; typedef SkTypeface_Custom INHERITED; }; @@ -128,7 +128,7 @@ public: } protected: - SkStream* onOpenStream(int* ttcIndex) const SK_OVERRIDE { + SkStreamAsset* onOpenStream(int* ttcIndex) const SK_OVERRIDE { *ttcIndex = this->getIndex(); if (fStream.get()) { return fStream->duplicate(); @@ -286,8 +286,8 @@ protected: return this->createFromStream(new SkMemoryStream(data), ttcIndex); } - SkTypeface* onCreateFromStream(SkStream* stream, int ttcIndex) const SK_OVERRIDE { - SkAutoTDelete<SkStream> streamDeleter(stream); + SkTypeface* onCreateFromStream(SkStreamAsset* bareStream, int ttcIndex) const SK_OVERRIDE { + SkAutoTDelete<SkStreamAsset> stream(bareStream); if (NULL == stream || stream->getLength() <= 0) { return NULL; } @@ -297,14 +297,14 @@ protected: SkString name; if (fScanner.scanFont(stream, ttcIndex, &name, &style, &isFixedPitch)) { return SkNEW_ARGS(SkTypeface_Stream, (style, isFixedPitch, false, name, - streamDeleter.detach(), ttcIndex)); + stream.detach(), ttcIndex)); } else { return NULL; } } SkTypeface* onCreateFromFile(const char path[], int ttcIndex) const SK_OVERRIDE { - SkAutoTDelete<SkStream> stream(SkStream::NewFromFile(path)); + SkAutoTDelete<SkStreamAsset> stream(SkStream::NewFromFile(path)); return stream.get() ? this->createFromStream(stream.detach(), ttcIndex) : NULL; } diff --git a/src/ports/SkFontHost_mac.cpp b/src/ports/SkFontHost_mac.cpp index f12785d106..4518708334 100755 --- a/src/ports/SkFontHost_mac.cpp +++ b/src/ports/SkFontHost_mac.cpp @@ -469,7 +469,7 @@ protected: friend class SkFontHost; // to access our protected members for deprecated methods int onGetUPEM() const SK_OVERRIDE; - SkStream* onOpenStream(int* ttcIndex) const SK_OVERRIDE; + SkStreamAsset* onOpenStream(int* ttcIndex) const SK_OVERRIDE; void onGetFamilyName(SkString* familyName) const SK_OVERRIDE; SkTypeface::LocalizedStrings* onCreateFamilyNameIterator() const SK_OVERRIDE; int onGetTableTags(SkFontTableTag tags[]) const SK_OVERRIDE; @@ -1685,7 +1685,7 @@ static SK_SFNT_ULONG get_font_type_tag(const SkTypeface_Mac* typeface) { } } -SkStream* SkTypeface_Mac::onOpenStream(int* ttcIndex) const { +SkStreamAsset* SkTypeface_Mac::onOpenStream(int* ttcIndex) const { SK_SFNT_ULONG fontType = get_font_type_tag(this); if (0 == fontType) { return NULL; @@ -2245,7 +2245,7 @@ protected: return create_from_dataProvider(pr); } - SkTypeface* onCreateFromStream(SkStream* stream, int ttcIndex) const SK_OVERRIDE { + SkTypeface* onCreateFromStream(SkStreamAsset* stream, int ttcIndex) const SK_OVERRIDE { AutoCFRelease<CGDataProviderRef> pr(SkCreateDataProviderFromStream(stream)); if (NULL == pr) { return NULL; diff --git a/src/ports/SkFontHost_win.cpp b/src/ports/SkFontHost_win.cpp index 70f3ddfdf8..a1d92fc216 100755 --- a/src/ports/SkFontHost_win.cpp +++ b/src/ports/SkFontHost_win.cpp @@ -255,7 +255,7 @@ public: } protected: - SkStream* onOpenStream(int* ttcIndex) const SK_OVERRIDE; + SkStreamAsset* onOpenStream(int* ttcIndex) const SK_OVERRIDE; SkScalerContext* onCreateScalerContext(const SkDescriptor*) const SK_OVERRIDE; void onFilterRec(SkScalerContextRec*) const SK_OVERRIDE; virtual SkAdvancedTypefaceMetrics* onGetAdvancedTypefaceMetrics( @@ -1925,7 +1925,7 @@ static HANDLE activate_font(SkData* fontData) { } // Does not affect ownership of stream. -static SkTypeface* create_from_stream(SkStream* stream) { +static SkTypeface* create_from_stream(SkStreamAsset* stream) { // Create a unique and unpredictable font name. // Avoids collisions and access from CSS. char familyName[BASE64_GUID_ID_LEN]; @@ -1953,7 +1953,7 @@ static SkTypeface* create_from_stream(SkStream* stream) { return SkCreateFontMemResourceTypefaceFromLOGFONT(lf, fontReference); } -SkStream* LogFontTypeface::onOpenStream(int* ttcIndex) const { +SkStreamAsset* LogFontTypeface::onOpenStream(int* ttcIndex) const { *ttcIndex = 0; const DWORD kTTCTag = @@ -2481,8 +2481,8 @@ protected: return this->matchFamilyStyle(familyName.c_str(), fontstyle); } - SkTypeface* onCreateFromStream(SkStream* stream, int ttcIndex) const SK_OVERRIDE { - SkAutoTDelete<SkStream> streamDeleter(stream); + SkTypeface* onCreateFromStream(SkStreamAsset* bareStream, int ttcIndex) const SK_OVERRIDE { + SkAutoTDelete<SkStreamAsset> stream(bareStream); return create_from_stream(stream); } diff --git a/src/ports/SkFontMgr_android.cpp b/src/ports/SkFontMgr_android.cpp index ce931941cd..523deca0e3 100644 --- a/src/ports/SkFontMgr_android.cpp +++ b/src/ports/SkFontMgr_android.cpp @@ -84,7 +84,7 @@ public: desc->setFontIndex(fIndex); *serialize = false; } - SkStream* onOpenStream(int* ttcIndex) const SK_OVERRIDE { + SkStreamAsset* onOpenStream(int* ttcIndex) const SK_OVERRIDE { *ttcIndex = fIndex; return SkStream::NewFromFile(fPathName.c_str()); } @@ -98,7 +98,7 @@ public: class SkTypeface_AndroidStream : public SkTypeface_Android { public: - SkTypeface_AndroidStream(SkStream* stream, + SkTypeface_AndroidStream(SkStreamAsset* stream, int index, const SkFontStyle& style, bool isFixedPitch, @@ -115,13 +115,13 @@ public: *serialize = true; } - SkStream* onOpenStream(int* ttcIndex) const SK_OVERRIDE { + SkStreamAsset* onOpenStream(int* ttcIndex) const SK_OVERRIDE { *ttcIndex = fIndex; return fStream->duplicate(); } private: - SkAutoTDelete<SkStream> fStream; + SkAutoTDelete<SkStreamAsset> fStream; typedef SkTypeface_Android INHERITED; }; @@ -413,19 +413,19 @@ protected: } SkTypeface* onCreateFromFile(const char path[], int ttcIndex) const SK_OVERRIDE { - SkAutoTDelete<SkStream> stream(SkStream::NewFromFile(path)); + SkAutoTDelete<SkStreamAsset> stream(SkStream::NewFromFile(path)); return stream.get() ? this->createFromStream(stream.detach(), ttcIndex) : NULL; } - SkTypeface* onCreateFromStream(SkStream* stream, int ttcIndex) const SK_OVERRIDE { - SkAutoTDelete<SkStream> streamDeleter(stream); + SkTypeface* onCreateFromStream(SkStreamAsset* bareStream, int ttcIndex) const SK_OVERRIDE { + SkAutoTDelete<SkStreamAsset> stream(bareStream); bool isFixedPitch; SkFontStyle style; SkString name; if (!fScanner.scanFont(stream, ttcIndex, &name, &style, &isFixedPitch)) { return NULL; } - return SkNEW_ARGS(SkTypeface_AndroidStream, (streamDeleter.detach(), ttcIndex, + return SkNEW_ARGS(SkTypeface_AndroidStream, (stream.detach(), ttcIndex, style, isFixedPitch, name)); } diff --git a/src/ports/SkFontMgr_fontconfig.cpp b/src/ports/SkFontMgr_fontconfig.cpp index 28df5d4790..a0e45facf6 100644 --- a/src/ports/SkFontMgr_fontconfig.cpp +++ b/src/ports/SkFontMgr_fontconfig.cpp @@ -391,7 +391,7 @@ public: *serialize = true; } - SkStream* onOpenStream(int* ttcIndex) const SK_OVERRIDE { + SkStreamAsset* onOpenStream(int* ttcIndex) const SK_OVERRIDE { *ttcIndex = fIndex; return fStream->duplicate(); } @@ -425,7 +425,7 @@ public: *serialize = false; } - SkStream* onOpenStream(int* ttcIndex) const SK_OVERRIDE { + SkStreamAsset* onOpenStream(int* ttcIndex) const SK_OVERRIDE { FCLocker lock; *ttcIndex = get_int(fPattern, FC_INDEX, 0); return SkStream::NewFromFile(get_string(fPattern, FC_FILE)); @@ -809,8 +809,8 @@ protected: return this->matchFamilyStyle(get_string(fcTypeface->fPattern, FC_FAMILY), style); } - SkTypeface* onCreateFromStream(SkStream* inputStream, int ttcIndex) const SK_OVERRIDE { - SkAutoTDelete<SkStream> stream(inputStream); + SkTypeface* onCreateFromStream(SkStreamAsset* bareStream, int ttcIndex) const SK_OVERRIDE { + SkAutoTDelete<SkStreamAsset> stream(bareStream); const size_t length = stream->getLength(); if (length <= 0 || (1u << 30) < length) { return NULL; diff --git a/src/ports/SkFontMgr_win_dw.cpp b/src/ports/SkFontMgr_win_dw.cpp index 31c1d3fef4..bb1e8f572f 100644 --- a/src/ports/SkFontMgr_win_dw.cpp +++ b/src/ports/SkFontMgr_win_dw.cpp @@ -276,7 +276,7 @@ protected: SkUnichar character) const SK_OVERRIDE; virtual SkTypeface* onMatchFaceStyle(const SkTypeface* familyMember, const SkFontStyle& fontstyle) const SK_OVERRIDE; - SkTypeface* onCreateFromStream(SkStream* stream, int ttcIndex) const SK_OVERRIDE; + SkTypeface* onCreateFromStream(SkStreamAsset* stream, int ttcIndex) const SK_OVERRIDE; SkTypeface* onCreateFromData(SkData* data, int ttcIndex) const SK_OVERRIDE; SkTypeface* onCreateFromFile(const char path[], int ttcIndex) const SK_OVERRIDE; virtual SkTypeface* onLegacyCreateTypeface(const char familyName[], @@ -534,7 +534,7 @@ private: T* fUnregister; }; -SkTypeface* SkFontMgr_DirectWrite::onCreateFromStream(SkStream* stream, int ttcIndex) const { +SkTypeface* SkFontMgr_DirectWrite::onCreateFromStream(SkStreamAsset* stream, int ttcIndex) const { SkTScopedComPtr<StreamFontFileLoader> fontFileLoader; // This transfers ownership of stream to the new object. HRN(StreamFontFileLoader::Create(stream, &fontFileLoader)); diff --git a/src/ports/SkTypeface_win_dw.cpp b/src/ports/SkTypeface_win_dw.cpp index b7778060f2..eb17201408 100644 --- a/src/ports/SkTypeface_win_dw.cpp +++ b/src/ports/SkTypeface_win_dw.cpp @@ -209,7 +209,7 @@ size_t DWriteFontTypeface::onGetTableData(SkFontTableTag tag, size_t offset, return size; } -SkStream* DWriteFontTypeface::onOpenStream(int* ttcIndex) const { +SkStreamAsset* DWriteFontTypeface::onOpenStream(int* ttcIndex) const { *ttcIndex = fDWriteFontFace->GetIndex(); UINT32 numFiles; diff --git a/src/ports/SkTypeface_win_dw.h b/src/ports/SkTypeface_win_dw.h index f25d709cb8..9e824e5948 100644 --- a/src/ports/SkTypeface_win_dw.h +++ b/src/ports/SkTypeface_win_dw.h @@ -96,7 +96,7 @@ protected: INHERITED::weak_dispose(); } - SkStream* onOpenStream(int* ttcIndex) const SK_OVERRIDE; + SkStreamAsset* onOpenStream(int* ttcIndex) const SK_OVERRIDE; SkScalerContext* onCreateScalerContext(const SkDescriptor*) const SK_OVERRIDE; void onFilterRec(SkScalerContextRec*) const SK_OVERRIDE; virtual SkAdvancedTypefaceMetrics* onGetAdvancedTypefaceMetrics( diff --git a/src/sfnt/SkOTUtils.cpp b/src/sfnt/SkOTUtils.cpp index 1d3843d061..fb82182130 100644 --- a/src/sfnt/SkOTUtils.cpp +++ b/src/sfnt/SkOTUtils.cpp @@ -33,7 +33,7 @@ uint32_t SkOTUtils::CalcTableChecksum(SK_OT_ULONG *data, size_t length) { return sum; } -SkData* SkOTUtils::RenameFont(SkStream* fontData, const char* fontName, int fontNameLen) { +SkData* SkOTUtils::RenameFont(SkStreamAsset* fontData, const char* fontName, int fontNameLen) { // Get the sfnt header. SkSFNTHeader sfntHeader; diff --git a/src/sfnt/SkOTUtils.h b/src/sfnt/SkOTUtils.h index 691bd76d51..cbaf31cf70 100644 --- a/src/sfnt/SkOTUtils.h +++ b/src/sfnt/SkOTUtils.h @@ -36,7 +36,7 @@ struct SkOTUtils { * * Does not affect fontData's ownership. */ - static SkData* RenameFont(SkStream* fontData, const char* fontName, int fontNameLen); + static SkData* RenameFont(SkStreamAsset* fontData, const char* fontName, int fontNameLen); /** An implementation of LocalizedStrings which obtains it's data from a 'name' table. */ class LocalizedStrings_NameTable : public SkTypeface::LocalizedStrings { |