summaryrefslogtreecommitdiffstats
path: root/skia
diff options
context:
space:
mode:
authoragl@chromium.org <agl@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-08-28 21:43:06 +0000
committeragl@chromium.org <agl@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-08-28 21:43:06 +0000
commitcb4d9831a1c23b22a97523d4cd8fe5592601a64e (patch)
treef51bc648de831b593b9fd617a45169396b090129 /skia
parent4768c65bc656d4352632a6fc718c8eb6d5046c84 (diff)
downloadchromium_src-cb4d9831a1c23b22a97523d4cd8fe5592601a64e.zip
chromium_src-cb4d9831a1c23b22a97523d4cd8fe5592601a64e.tar.gz
chromium_src-cb4d9831a1c23b22a97523d4cd8fe5592601a64e.tar.bz2
Revert "Linux: use mmap fonts."
This reverts commit r24790. page_cycler_intl2 went red, although it's not clear why. This is a speculative revert. git-svn-id: svn://svn.chromium.org/chrome/trunk/src@24802 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'skia')
-rw-r--r--skia/ext/SkFontHost_fontconfig.cpp61
1 files changed, 24 insertions, 37 deletions
diff --git a/skia/ext/SkFontHost_fontconfig.cpp b/skia/ext/SkFontHost_fontconfig.cpp
index d4726d7..46d8d45 100644
--- a/skia/ext/SkFontHost_fontconfig.cpp
+++ b/skia/ext/SkFontHost_fontconfig.cpp
@@ -27,9 +27,8 @@
#include <map>
#include <string>
-#include <sys/mman.h>
-#include <sys/stat.h>
#include <unistd.h>
+#include <sys/stat.h>
#include "SkFontHost.h"
#include "SkStream.h"
@@ -236,28 +235,17 @@ uint32_t SkFontHost::NextLogicalFont(SkFontID fontID) {
class SkFileDescriptorStream : public SkStream {
public:
- SkFileDescriptorStream(int fd) {
- memory_ = NULL;
- offset_ = 0;
-
- struct stat st;
- if (fstat(fd, &st))
- return;
-
- void* memory = mmap(NULL, st.st_size, PROT_READ, MAP_SHARED, fd, 0);
- if (memory == MAP_FAILED)
- return;
-
- memory_ = reinterpret_cast<uint8_t*>(memory);
- length_ = st.st_size;
+ SkFileDescriptorStream(int fd)
+ : fd_(fd) {
}
~SkFileDescriptorStream() {
- munmap(const_cast<uint8_t*>(memory_), length_);
+ close(fd_);
}
virtual bool rewind() {
- offset_ = 0;
+ if (lseek(fd_, 0, SEEK_SET) == -1)
+ return false;
return true;
}
@@ -265,34 +253,33 @@ class SkFileDescriptorStream : public SkStream {
virtual size_t read(void* buffer, size_t size) {
if (!buffer && !size) {
// This is request for the length of the stream.
- return length_;
+ struct stat st;
+ if (fstat(fd_, &st) == -1)
+ return 0;
+ return st.st_size;
}
if (!buffer) {
// This is a request to skip bytes.
- if (offset_ + size < offset_)
- return offset_;
- offset_ += size;
- if (offset_ > length_)
- offset_ = length_;
- return offset_;
+ const off_t current_position = lseek(fd_, 0, SEEK_CUR);
+ if (current_position == -1)
+ return 0;
+ const off_t new_position = lseek(fd_, size, SEEK_CUR);
+ if (new_position == -1)
+ return 0;
+ if (new_position < current_position) {
+ lseek(fd_, current_position, SEEK_SET);
+ return 0;
+ }
+ return new_position;
}
- size_t remaining = length_ - offset_;
- if (size > remaining)
- size = remaining;
- memcpy(buffer, memory_ + offset_, size);
- offset_ += size;
- return size;
- }
-
- virtual const void* getMemoryBase() {
- return memory_;
+ // This is a request to read bytes.
+ return ::read(fd_, buffer, size);
}
private:
- const uint8_t* memory_;
- size_t offset_, length_;
+ const int fd_;
};
///////////////////////////////////////////////////////////////////////////////