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

Unified Diff: trunk/src/ports/SkFontHost_linux.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_freetype_mac.cpp ('k') | trunk/src/ports/SkFontHost_simple.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: trunk/src/ports/SkFontHost_linux.cpp
===================================================================
--- trunk/src/ports/SkFontHost_linux.cpp (revision 8197)
+++ trunk/src/ports/SkFontHost_linux.cpp (working copy)
@@ -10,7 +10,6 @@
#include "SkFontHost.h"
#include "SkFontDescriptor.h"
#include "SkDescriptor.h"
-#include "SkMMapStream.h"
#include "SkOSFile.h"
#include "SkPaint.h"
#include "SkString.h"
@@ -280,8 +279,8 @@
EmptyTypeface() : INHERITED(SkTypeface::kNormal, true, NULL, false) {}
// overrides
- virtual SkStream* openStream() { return NULL; }
- virtual const char* getUniqueString() const { return NULL; }
+ virtual SkStream* openStream() SK_OVERRIDE { return NULL; }
+ virtual const char* getUniqueString() SK_OVERRIDE const { return NULL; }
private:
typedef FamilyTypeface INHERITED;
@@ -299,14 +298,12 @@
fStream->unref();
}
- // overrides
- virtual SkStream* openStream()
- {
+ virtual SkStream* openStream() SK_OVERRIDE {
// openStream returns a refed stream.
fStream->ref();
return fStream;
}
- virtual const char* getUniqueString() const { return NULL; }
+ virtual const char* getUniqueString() const SK_OVERRIDE { return NULL; }
private:
SkStream* fStream;
@@ -322,25 +319,11 @@
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 '/'
@@ -359,19 +342,13 @@
static bool get_name_and_style(const char path[], SkString* name,
SkTypeface::Style* style, bool* isFixedWidth) {
- SkMMAPStream stream(path);
- if (stream.getLength() > 0) {
- return find_name_and_attributes(&stream, name, style, isFixedWidth);
+ SkAutoTUnref<SkStream> stream(SkStream::NewFromFile(path));
+ if (stream.get()) {
+ return find_name_and_attributes(stream, name, style, isFixedWidth);
+ } else {
+ SkDebugf("---- failed to open <%s> as a font\n", path);
+ return false;
}
- else {
- SkFILEStream stream(path);
- if (stream.getLength() > 0) {
- return find_name_and_attributes(&stream, name, style, isFixedWidth);
- }
- }
-
- SkDebugf("---- failed to open <%s> as a font\n", path);
- return false;
}
// these globals are assigned (once) by load_system_fonts()
« no previous file with comments | « trunk/src/ports/SkFontHost_freetype_mac.cpp ('k') | trunk/src/ports/SkFontHost_simple.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698