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

Unified Diff: content/common/cc_messages.cc

Issue 21271002: Added SkImageFilter serialization (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Hid new ipc code behind flag and removed test changes Created 7 years, 5 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 | « content/common/cc_messages.h ('k') | content/public/common/content_switches.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/common/cc_messages.cc
diff --git a/content/common/cc_messages.cc b/content/common/cc_messages.cc
index 9065a946ad3bc5ff857e30610170e469a4998575..42ce0f6ff8f26e44588f4058948de867c5c7b635 100644
--- a/content/common/cc_messages.cc
+++ b/content/common/cc_messages.cc
@@ -4,9 +4,13 @@
#include "content/common/cc_messages.h"
+#include "base/command_line.h"
#include "cc/output/compositor_frame.h"
#include "cc/output/filter_operations.h"
#include "content/public/common/common_param_traits.h"
+#include "content/public/common/content_switches.h"
+#include "third_party/skia/src/core/SkOrderedReadBuffer.h"
+#include "third_party/skia/src/core/SkOrderedWriteBuffer.h"
#include "ui/gfx/transform.h"
namespace IPC {
@@ -185,6 +189,49 @@ void ParamTraits<cc::FilterOperations>::Log(
l->append(")");
}
+void ParamTraits<skia::RefPtr<SkImageFilter> >::Write(
+ Message* m, const param_type& p) {
+ const CommandLine& command_line = *CommandLine::ForCurrentProcess();
+ if (!command_line.HasSwitch(switches::kAllowFiltersOverIPC))
+ return;
piman 2013/08/01 19:53:22 As it is, this relies on the flag being identical
sugoi1 2013/08/01 20:23:28 Done.
+ SkImageFilter* filter = p.get();
+ if (filter) {
+ SkOrderedWriteBuffer buffer(1024);
+ buffer.setFlags(SkOrderedWriteBuffer::kCrossProcess_Flag);
+ buffer.writeFlattenable(filter);
+ buffer.writeToMemory(m->BeginWriteData(buffer.bytesWritten()));
+ } else {
+ m->WriteData(0, 0);
+ }
+}
+
+bool ParamTraits<skia::RefPtr<SkImageFilter> >::Read(
+ const Message* m, PickleIterator* iter, param_type* r) {
+ const CommandLine& command_line = *CommandLine::ForCurrentProcess();
+ if (!command_line.HasSwitch(switches::kAllowFiltersOverIPC)) {
+ r->clear();
+ return true;
+ }
+ const char* data = 0;
+ int length = 0;
+ if (!m->ReadData(iter, &data, &length))
+ return false;
+ if (length > 0) {
+ SkOrderedReadBuffer buffer(data, length);
+ *r = skia::AdoptRef(buffer.readFlattenableT<SkImageFilter>());
+ } else {
+ r->clear();
+ }
+ return true;
+}
+
+void ParamTraits<skia::RefPtr<SkImageFilter> >::Log(
+ const param_type& p, std::string* l) {
+ l->append("(");
+ LogParam(p.get() ? p->countInputs() : 0, l);
+ l->append(")");
+}
+
void ParamTraits<gfx::Transform>::Write(
Message* m, const param_type& p) {
WriteParam(m, p.matrix().getDouble(0, 0));
« no previous file with comments | « content/common/cc_messages.h ('k') | content/public/common/content_switches.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698