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

Unified Diff: src/ports/SkFontHost_fontconfig.cpp

Issue 869763002: SkTypeface to use SkStreamAsset. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/ports/SkFontConfigTypeface.h ('k') | src/ports/SkFontHost_linux.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/ports/SkFontHost_fontconfig.cpp
diff --git a/src/ports/SkFontHost_fontconfig.cpp b/src/ports/SkFontHost_fontconfig.cpp
index 4c577d8c279b4293ed868ea9aa7227ffcba7c53c..591e9d5aed682fb851255d6f45082df856ad62da 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 {
« no previous file with comments | « src/ports/SkFontConfigTypeface.h ('k') | src/ports/SkFontHost_linux.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698