aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-03-22 13:23:45 +0000
committerGravatar reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-03-22 13:23:45 +0000
commit1361d78e88acd6a0865a4c08c58e7504ed094655 (patch)
tree5790cec437c1e37499345655dcbe1d47a576c020 /src
parenta72aef8a21c095d7502385f965ad510c775a9377 (diff)
override SkTypeface::onOpenStream for android
git-svn-id: http://skia.googlecode.com/svn/trunk@8331 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src')
-rw-r--r--src/ports/SkFontHost_android.cpp39
1 files changed, 19 insertions, 20 deletions
diff --git a/src/ports/SkFontHost_android.cpp b/src/ports/SkFontHost_android.cpp
index 5d3b583892..1c1db12f07 100644
--- a/src/ports/SkFontHost_android.cpp
+++ b/src/ports/SkFontHost_android.cpp
@@ -313,7 +313,6 @@ public:
bool isSysFont() const { return fIsSysFont; }
- virtual SkStream* openStream() = 0;
virtual const char* getUniqueString() const = 0;
virtual const char* getFilePath() const = 0;
@@ -338,17 +337,22 @@ public:
fStream->unref();
}
- // overrides
- virtual SkStream* openStream() {
+ virtual const char* getUniqueString() const SK_OVERRIDE { return NULL; }
+ virtual const char* getFilePath() const SK_OVERRIDE { return NULL; }
+
+protected:
+ virtual SkStream* openStream(int* ttcIndex) const SK_OVERRIDE {
+ // TODO: we should be given this when we were created
+ *ttcIndex = 0;
+
// we just ref our existing stream, since the caller will call unref()
// when they are through
+ // TODO: replace with shallow-copy when we have that for streams
fStream->ref();
// must rewind each time, since the caller assumes a "new" stream
fStream->rewind();
return fStream;
}
- virtual const char* getUniqueString() const { return NULL; }
- virtual const char* getFilePath() const { return NULL; }
private:
SkStream* fStream;
@@ -370,10 +374,6 @@ public:
fPath.set(path);
}
- virtual SkStream* openStream() SK_OVERRIDE {
- return SkStream::NewFromFile(fPath.c_str());
- }
-
virtual const char* getUniqueString() const SK_OVERRIDE {
const char* str = strrchr(fPath.c_str(), '/');
if (str) {
@@ -386,6 +386,14 @@ public:
return fPath.c_str();
}
+protected:
+ virtual SkStream* openStream(int* ttcIndex) const SK_OVERRIDE {
+ // TODO: we should be given this when we were created
+ *ttcIndex = 0;
+
+ return SkStream::NewFromFile(fPath.c_str());
+ }
+
private:
SkString fPath;
@@ -749,7 +757,7 @@ void SkFontHost::Serialize(const SkTypeface* face, SkWStream* stream) {
const bool isCustomFont = !((FamilyTypeface*)face)->isSysFont();
if (isCustomFont) {
// store the entire font in the fontData
- SkStream* fontStream = ((FamilyTypeface*)face)->openStream();
+ SkStream* fontStream = face->openStream(NULL);
const uint32_t length = fontStream->getLength();
stream->writePackedUInt(length);
@@ -834,16 +842,7 @@ SkTypeface* SkFontHost::CreateTypeface(const SkTypeface* familyFace,
}
SkStream* SkFontHost::OpenStream(uint32_t fontID) {
- SkAutoMutexAcquire ac(gFamilyHeadAndNameListMutex);
-
- FamilyTypeface* tf = (FamilyTypeface*)find_from_uniqueID(fontID);
- SkStream* stream = tf ? tf->openStream() : NULL;
-
- if (stream && stream->getLength() == 0) {
- stream->unref();
- stream = NULL;
- }
- return stream;
+ return NULL;
}
SkTypeface* SkFontHost::NextLogicalTypeface(SkFontID currFontID, SkFontID origFontID) {