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

Unified Diff: src/ports/SkFontHost_FreeType.cpp

Issue 882763002: SkFontHost_FreeType takes advantage of 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/ports/SkFontHost_FreeType.cpp
diff --git a/src/ports/SkFontHost_FreeType.cpp b/src/ports/SkFontHost_FreeType.cpp
index 72fe8f67db15dc67e217f2290b99c518a87d7fee..828d74a78268cedbb81f9506af67dd2fd5c5441d 100644
--- a/src/ports/SkFontHost_FreeType.cpp
+++ b/src/ports/SkFontHost_FreeType.cpp
@@ -233,35 +233,30 @@ private:
///////////////////////////////////////////////////////////////////////////
struct SkFaceRec {
- SkFaceRec* fNext;
- FT_Face fFace;
- FT_StreamRec fFTStream;
- SkAutoTDelete<SkStream> fSkStream;
- uint32_t fRefCnt;
- uint32_t fFontID;
+ SkFaceRec* fNext;
+ FT_Face fFace;
+ FT_StreamRec fFTStream;
+ SkAutoTDelete<SkStreamAsset> fSkStream;
+ uint32_t fRefCnt;
+ uint32_t fFontID;
// assumes ownership of the stream, will delete when its done
- SkFaceRec(SkStream* strm, uint32_t fontID);
+ SkFaceRec(SkStreamAsset* strm, uint32_t fontID);
};
extern "C" {
- static unsigned long sk_ft_stream_io(FT_Stream stream,
+ static unsigned long sk_ft_stream_io(FT_Stream ftStream,
unsigned long offset,
unsigned char* buffer,
unsigned long count)
{
- SkStream* str = (SkStream*)stream->descriptor.pointer;
+ SkStreamAsset* stream = static_cast<SkStreamAsset*>(ftStream->descriptor.pointer);
if (count) {
- if (!str->rewind()) {
+ if (!stream->seek(offset)) {
return 0;
}
- if (offset) {
- if (str->skip(offset) != offset) {
- return 0;
- }
- }
- count = str->read(buffer, count);
+ count = stream->read(buffer, count);
}
return count;
}
@@ -269,10 +264,9 @@ extern "C" {
static void sk_ft_stream_close(FT_Stream) {}
}
-SkFaceRec::SkFaceRec(SkStream* strm, uint32_t fontID)
- : fNext(NULL), fSkStream(strm), fRefCnt(1), fFontID(fontID) {
-// SkDEBUGF(("SkFaceRec: opening %s (%p)\n", key.c_str(), strm));
-
+SkFaceRec::SkFaceRec(SkStreamAsset* stream, uint32_t fontID)
+ : fNext(NULL), fSkStream(stream), fRefCnt(1), fFontID(fontID)
+{
sk_bzero(&fFTStream, sizeof(fFTStream));
fFTStream.size = fSkStream->getLength();
fFTStream.descriptor.pointer = fSkStream;
@@ -297,22 +291,21 @@ static SkFaceRec* ref_ft_face(const SkTypeface* typeface) {
}
int face_index;
- SkStream* strm = typeface->openStream(&face_index);
- if (NULL == strm) {
+ SkStreamAsset* stream = typeface->openStream(&face_index);
+ if (NULL == stream) {
return NULL;
}
- // this passes ownership of strm to the rec
- rec = SkNEW_ARGS(SkFaceRec, (strm, fontID));
+ // this passes ownership of stream to the rec
+ rec = SkNEW_ARGS(SkFaceRec, (stream, fontID));
FT_Open_Args args;
memset(&args, 0, sizeof(args));
- const void* memoryBase = strm->getMemoryBase();
-
+ const void* memoryBase = stream->getMemoryBase();
if (memoryBase) {
args.flags = FT_OPEN_MEMORY;
args.memory_base = (const FT_Byte*)memoryBase;
- args.memory_size = strm->getLength();
+ args.memory_size = stream->getLength();
} else {
args.flags = FT_OPEN_STREAM;
args.stream = &rec->fFTStream;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698