aboutsummaryrefslogtreecommitdiffhomepage
path: root/include/core
diff options
context:
space:
mode:
authorGravatar reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-03-18 20:49:28 +0000
committerGravatar reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-03-18 20:49:28 +0000
commit4f7e846cd8b577fc40f30cce6d982d853763a3eb (patch)
treed8b1d61d7b5221ee020a2cf786d23d1c1f454881 /include/core
parenta6c76db94c37df7449afe6406d5263b528fa7ccd (diff)
reland 8200 w/ fix for android (need fullpath instead of path)
git-svn-id: http://skia.googlecode.com/svn/trunk@8204 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'include/core')
-rw-r--r--include/core/SkData.h6
-rw-r--r--include/core/SkMMapStream.h30
-rw-r--r--include/core/SkPreConfig.h11
-rw-r--r--include/core/SkStream.h7
4 files changed, 24 insertions, 30 deletions
diff --git a/include/core/SkData.h b/include/core/SkData.h
index 9a0cb09b60..6b09119fc5 100644
--- a/include/core/SkData.h
+++ b/include/core/SkData.h
@@ -89,6 +89,12 @@ public:
static SkData* NewFromMalloc(const void* data, size_t length);
/**
+ * Create a new dataref from a pointer allocated by mmap. The Data object
+ * will handle calling munmap().
+ */
+ static SkData* NewFromMMap(const void* data, size_t length);
+
+ /**
* Create a new dataref using a subset of the data in the specified
* src dataref.
*/
diff --git a/include/core/SkMMapStream.h b/include/core/SkMMapStream.h
deleted file mode 100644
index a3b35f2df8..0000000000
--- a/include/core/SkMMapStream.h
+++ /dev/null
@@ -1,30 +0,0 @@
-
-/*
- * Copyright 2008 The Android Open Source Project
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-
-#ifndef SkMMapStream_DEFINED
-#define SkMMapStream_DEFINED
-
-#include "SkStream.h"
-
-class SkMMAPStream : public SkMemoryStream {
-public:
- SkMMAPStream(const char filename[]);
- virtual ~SkMMAPStream();
-
- virtual void setMemory(const void* data, size_t length, bool);
-private:
- void* fAddr;
- size_t fSize;
-
- void closeMMap();
-
- typedef SkMemoryStream INHERITED;
-};
-
-#endif
diff --git a/include/core/SkPreConfig.h b/include/core/SkPreConfig.h
index 2246b63f59..11cb2235a7 100644
--- a/include/core/SkPreConfig.h
+++ b/include/core/SkPreConfig.h
@@ -108,6 +108,17 @@
//////////////////////////////////////////////////////////////////////
+#ifndef SK_MMAP_SUPPORT
+ #ifdef SK_BUILD_FOR_WIN32
+ // by default, if we're windows, we assume we don't have mmap
+ #define SK_MMAP_SUPPORT 0
+ #else
+ #define SK_MMAP_SUPPORT 1
+ #endif
+#endif
+
+//////////////////////////////////////////////////////////////////////
+
/**
* SK_CPU_SSE_LEVEL
*
diff --git a/include/core/SkStream.h b/include/core/SkStream.h
index 7e3c1a370b..eb0cd4757f 100644
--- a/include/core/SkStream.h
+++ b/include/core/SkStream.h
@@ -17,6 +17,13 @@ class SkData;
class SK_API SkStream : public SkRefCnt {
public:
+ /**
+ * Attempts to open the specified file, and return a stream to it (using
+ * mmap if available). On success, the caller must call unref() on the
+ * returned object. On failure, returns NULL.
+ */
+ static SkStream* NewFromFile(const char path[]);
+
SK_DECLARE_INST_COUNT(SkStream)
/** Called to rewind to the beginning of the stream. If this cannot be