aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/ports
diff options
context:
space:
mode:
Diffstat (limited to 'src/ports')
-rw-r--r--src/ports/SkFontConfigInterface_direct.cpp4
-rw-r--r--src/ports/SkFontConfigTypeface.h10
-rw-r--r--src/ports/SkFontHost_fontconfig.cpp42
-rw-r--r--src/ports/SkFontHost_linux.cpp18
-rwxr-xr-xsrc/ports/SkFontHost_mac.cpp6
-rwxr-xr-xsrc/ports/SkFontHost_win.cpp10
-rw-r--r--src/ports/SkFontMgr_android.cpp16
-rw-r--r--src/ports/SkFontMgr_fontconfig.cpp8
-rw-r--r--src/ports/SkFontMgr_win_dw.cpp4
-rw-r--r--src/ports/SkTypeface_win_dw.cpp2
-rw-r--r--src/ports/SkTypeface_win_dw.h2
11 files changed, 51 insertions, 71 deletions
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(