aboutsummaryrefslogtreecommitdiffstats
path: root/src/ports/SkImageRef_ashmem.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/ports/SkImageRef_ashmem.cpp')
-rw-r--r--src/ports/SkImageRef_ashmem.cpp34
1 files changed, 34 insertions, 0 deletions
diff --git a/src/ports/SkImageRef_ashmem.cpp b/src/ports/SkImageRef_ashmem.cpp
index a904bae..5dd3a59 100644
--- a/src/ports/SkImageRef_ashmem.cpp
+++ b/src/ports/SkImageRef_ashmem.cpp
@@ -1,5 +1,6 @@
#include "SkImageRef_ashmem.h"
#include "SkImageDecoder.h"
+#include "SkFlattenable.h"
#include "SkThread.h"
#include <sys/mman.h>
@@ -201,3 +202,36 @@ void SkImageRef_ashmem::onUnlockPixels() {
fBitmap.setPixels(NULL, NULL);
}
+void SkImageRef_ashmem::flatten(SkFlattenableWriteBuffer& buffer) const {
+ this->INHERITED::flatten(buffer);
+ const char* uri = getURI();
+ if (uri) {
+ size_t len = strlen(uri);
+ buffer.write32(len);
+ buffer.writePad(uri, len);
+ } else {
+ buffer.write32(0);
+ }
+}
+
+SkImageRef_ashmem::SkImageRef_ashmem(SkFlattenableReadBuffer& buffer)
+ : INHERITED(buffer) {
+ fRec.fFD = -1;
+ fRec.fAddr = NULL;
+ fRec.fSize = 0;
+ fRec.fPinned = false;
+ fCT = NULL;
+ size_t length = buffer.readU32();
+ if (length) {
+ char* buf = (char*) malloc(length);
+ buffer.read(buf, length);
+ setURI(buf, length);
+ }
+}
+
+SkPixelRef* SkImageRef_ashmem::Create(SkFlattenableReadBuffer& buffer) {
+ return SkNEW_ARGS(SkImageRef_ashmem, (buffer));
+}
+
+static SkPixelRef::Registrar reg("SkImageRef_ashmem",
+ SkImageRef_ashmem::Create);