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

Unified Diff: trunk/src/ports/SkFontHost_simple.cpp

Issue 12919013: move SK_MMAP_SUPPORT into SkPreConfig, so we can know about its availability (Closed) Base URL: http://skia.googlecode.com/svn/
Patch Set: Created 7 years, 9 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 | « trunk/src/ports/SkFontHost_linux.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: trunk/src/ports/SkFontHost_simple.cpp
===================================================================
--- trunk/src/ports/SkFontHost_simple.cpp (revision 8197)
+++ trunk/src/ports/SkFontHost_simple.cpp (working copy)
@@ -9,7 +9,6 @@
#include "SkFontHost.h"
#include "SkDescriptor.h"
-#include "SkMMapStream.h"
#include "SkPaint.h"
#include "SkString.h"
#include "SkStream.h"
@@ -312,30 +311,18 @@
fPath.set(path);
}
- // overrides
- virtual SkStream* openStream() {
- SkStream* stream = SkNEW_ARGS(SkMMAPStream, (fPath.c_str()));
-
- // check for failure
- if (stream->getLength() <= 0) {
- SkDELETE(stream);
- // maybe MMAP isn't supported. try FILE
- stream = SkNEW_ARGS(SkFILEStream, (fPath.c_str()));
- if (stream->getLength() <= 0) {
- SkDELETE(stream);
- stream = NULL;
- }
- }
- return stream;
+ virtual SkStream* openStream() SK_OVERRIDE {
+ return SkStream::NewFromFile(fPath.c_str());
}
- virtual const char* getUniqueString() const {
+
+ virtual const char* getUniqueString() const SK_OVERRIDE {
const char* str = strrchr(fPath.c_str(), '/');
if (str) {
str += 1; // skip the '/'
}
return str;
}
- virtual const char* getFilePath() const {
+ virtual const char* getFilePath() const SK_OVERRIDE {
return fPath.c_str();
}
@@ -353,21 +340,15 @@
SkString fullpath;
GetFullPathForSysFonts(&fullpath, path);
- SkMMAPStream stream(fullpath.c_str());
- if (stream.getLength() > 0) {
+ SkAutoTUnref<SkStream> stream(SkStream::NewFromFile(path));
+ if (stream.get()) {
return find_name_and_attributes(&stream, name, style, NULL);
- }
- else {
- SkFILEStream stream(fullpath.c_str());
- if (stream.getLength() > 0) {
- return find_name_and_attributes(&stream, name, style, NULL);
+ } else {
+ if (isExpected) {
+ SkDebugf("---- failed to open <%s> as a font\n", fullpath.c_str());
}
+ return false;
}
-
- if (isExpected) {
- SkDebugf("---- failed to open <%s> as a font\n", fullpath.c_str());
- }
- return false;
}
// used to record our notion of the pre-existing fonts
@@ -636,9 +617,6 @@
}
SkTypeface* SkFontHost::CreateTypefaceFromFile(const char path[]) {
- SkStream* stream = SkNEW_ARGS(SkMMAPStream, (path));
- SkTypeface* face = SkFontHost::CreateTypefaceFromStream(stream);
- // since we created the stream, we let go of our ref() here
- stream->unref();
- return face;
+ SkAutoTUnref<SkStream> stream(SkStream::NewFromFile(path));
+ return stream.get() ? SkFontHost::CreateTypefaceFromStream(stream) : NULL;
}
« no previous file with comments | « trunk/src/ports/SkFontHost_linux.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698