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

Unified Diff: src/core/SkFlattenableSerialization.cpp

Issue 22591002: Adding 2 functions to the Skia API (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Back to generic SkFlattenable version Created 7 years, 4 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 | « include/core/SkFlattenableSerialization.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkFlattenableSerialization.cpp
diff --git a/src/core/SkFlattenableSerialization.cpp b/src/core/SkFlattenableSerialization.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..b74c82f051648f77dce5da97b26e21ba53b12e4b
--- /dev/null
+++ b/src/core/SkFlattenableSerialization.cpp
@@ -0,0 +1,28 @@
+/*
+ * Copyright 2013 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "SkFlattenableSerialization.h"
+
+#include "SkData.h"
+#include "SkFlattenable.h"
+#include "SkOrderedReadBuffer.h"
+#include "SkOrderedWriteBuffer.h"
+
+SkData* SkSerializeFlattenable(SkFlattenable* flattenable) {
+ SkOrderedWriteBuffer writer(1024);
+ writer.setFlags(SkOrderedWriteBuffer::kCrossProcess_Flag);
+ writer.writeFlattenable(flattenable);
+ uint32_t size = writer.bytesWritten();
+ void* data = sk_malloc_throw(size);
+ writer.writeToMemory(data);
+ return SkData::NewFromMalloc(data, size);
+}
+
+SkFlattenable* SkDeserializeFlattenable(const void* data, size_t size) {
+ SkOrderedReadBuffer buffer(data, size);
+ return buffer.readFlattenable();
+}
« no previous file with comments | « include/core/SkFlattenableSerialization.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698