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

Unified Diff: src/core/SkSerializeDrawable.h

Issue 1837913003: Add support for serializing/deserializing of SkDrawable (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Improve testing Created 4 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
Index: src/core/SkSerializeDrawable.h
diff --git a/src/core/SkSerializeDrawable.h b/src/core/SkSerializeDrawable.h
new file mode 100644
index 0000000000000000000000000000000000000000..39f17a51f929b8f911f253f2fe36499202fc7377
--- /dev/null
+++ b/src/core/SkSerializeDrawable.h
@@ -0,0 +1,30 @@
+/*
+ * Copyright 2016 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "SkDrawable.h"
+#include "SkReadBuffer.h"
+#include "SkWriteBuffer.h"
+
+class SkSerializeDrawable {
+public:
+
+ /**
+ * Create an SkDrawable from serialized data.
+ */
+ static SkDrawable* NewFromSerialized(SkReadBuffer& buffer) {
+ return (SkDrawable*) buffer.readFlattenable(SkFlattenable::kSkDrawable_Type);
+ }
+
+ /**
+ * Serialize an SkDrawable.
+ */
+ static SkWriteBuffer* Serialize(const SkDrawable& drawable) {
+ SkWriteBuffer* buffer = new SkWriteBuffer();
+ buffer->writeFlattenable(&drawable);
+ return buffer;
+ }
+};

Powered by Google App Engine
This is Rietveld 408576698