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

Unified Diff: trunk/src/core/SkData.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/include/core/SkStream.h ('k') | trunk/src/core/SkMMapStream.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: trunk/src/core/SkData.cpp
===================================================================
--- trunk/src/core/SkData.cpp (revision 8197)
+++ trunk/src/core/SkData.cpp (working copy)
@@ -8,6 +8,13 @@
#include "SkData.h"
#include "SkFlattenableBuffers.h"
+#if SK_MMAP_SUPPORT
+ #include <unistd.h>
+ #include <sys/mman.h>
+ #include <fcntl.h>
+ #include <errno.h>
+#endif
+
SK_DEFINE_INST_COUNT(SkData)
SkData::SkData(const void* ptr, size_t size, ReleaseProc proc, void* context) {
@@ -120,6 +127,20 @@
return NewWithCopy(cstr, size);
}
+#if SK_MMAP_SUPPORT
+static void sk_munmap_releaseproc(const void* addr, size_t length, void*) {
+ munmap(const_cast<void*>(addr), length);
+}
+
+SkData* SkData::NewFromMMap(const void* addr, size_t length) {
+ return SkNEW_ARGS(SkData, (addr, length, sk_munmap_releaseproc, NULL));
+}
+#else
+SkData* SkData::NewFromMMap(const void* addr, size_t length) {
+ return NULL;
+}
+#endif
+
///////////////////////////////////////////////////////////////////////////////
void SkData::flatten(SkFlattenableWriteBuffer& buffer) const {
@@ -300,3 +321,4 @@
gEmptySet->ref();
return gEmptySet;
}
+
« no previous file with comments | « trunk/include/core/SkStream.h ('k') | trunk/src/core/SkMMapStream.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698