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

Side by Side Diff: content/common/cc_messages.cc

Issue 21271002: Added SkImageFilter serialization (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Unit test is back and enables the flag 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « content/common/cc_messages.h ('k') | content/common/cc_messages_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/common/cc_messages.h" 5 #include "content/common/cc_messages.h"
6 6
7 #include "base/command_line.h"
7 #include "cc/output/compositor_frame.h" 8 #include "cc/output/compositor_frame.h"
8 #include "cc/output/filter_operations.h" 9 #include "cc/output/filter_operations.h"
9 #include "content/public/common/common_param_traits.h" 10 #include "content/public/common/common_param_traits.h"
11 #include "content/public/common/content_switches.h"
12 #include "third_party/skia/src/core/SkOrderedReadBuffer.h"
13 #include "third_party/skia/src/core/SkOrderedWriteBuffer.h"
10 #include "ui/gfx/transform.h" 14 #include "ui/gfx/transform.h"
11 15
12 namespace IPC { 16 namespace IPC {
13 17
14 void ParamTraits<cc::FilterOperation>::Write( 18 void ParamTraits<cc::FilterOperation>::Write(
15 Message* m, const param_type& p) { 19 Message* m, const param_type& p) {
16 WriteParam(m, p.type()); 20 WriteParam(m, p.type());
17 switch (p.type()) { 21 switch (p.type()) {
18 case cc::FilterOperation::GRAYSCALE: 22 case cc::FilterOperation::GRAYSCALE:
19 case cc::FilterOperation::SEPIA: 23 case cc::FilterOperation::SEPIA:
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 const param_type& p, std::string* l) { 182 const param_type& p, std::string* l) {
179 l->append("("); 183 l->append("(");
180 for (std::size_t i = 0; i < p.size(); ++i) { 184 for (std::size_t i = 0; i < p.size(); ++i) {
181 if (i) 185 if (i)
182 l->append(", "); 186 l->append(", ");
183 LogParam(p.at(i), l); 187 LogParam(p.at(i), l);
184 } 188 }
185 l->append(")"); 189 l->append(")");
186 } 190 }
187 191
192 void ParamTraits<skia::RefPtr<SkImageFilter> >::Write(
193 Message* m, const param_type& p) {
194 const CommandLine& command_line = *CommandLine::ForCurrentProcess();
195 if (!command_line.HasSwitch(switches::kAllowFiltersOverIPC))
palmer 2013/08/01 20:26:27 For security purposes, this check should be done i
piman 2013/08/01 21:25:28 See my comments, I think it's ok, and preferable t
196 return;
197 SkImageFilter* filter = p.get();
198 if (filter) {
199 SkOrderedWriteBuffer buffer(1024);
200 buffer.setFlags(SkOrderedWriteBuffer::kCrossProcess_Flag);
201 buffer.writeFlattenable(filter);
202 buffer.writeToMemory(m->BeginWriteData(buffer.bytesWritten()));
203 } else {
204 m->WriteData(0, 0);
205 }
206 }
207
208 bool ParamTraits<skia::RefPtr<SkImageFilter> >::Read(
209 const Message* m, PickleIterator* iter, param_type* r) {
210 const CommandLine& command_line = *CommandLine::ForCurrentProcess();
211 if (!command_line.HasSwitch(switches::kAllowFiltersOverIPC)) {
palmer 2013/08/01 20:26:27 Same thing here.
piman 2013/08/01 21:25:28 FYI, that side is the one that runs in the browser
palmer 2013/08/06 17:48:31 As I (think I) understand it now: in Write, the un
212 r->clear();
213 return true;
214 }
215 const char* data = 0;
216 int length = 0;
217 if (!m->ReadData(iter, &data, &length))
218 return false;
219 if (length > 0) {
220 SkOrderedReadBuffer buffer(data, length);
221 *r = skia::AdoptRef(buffer.readFlattenableT<SkImageFilter>());
222 } else {
223 r->clear();
224 }
225 return true;
226 }
227
228 void ParamTraits<skia::RefPtr<SkImageFilter> >::Log(
229 const param_type& p, std::string* l) {
230 l->append("(");
231 LogParam(p.get() ? p->countInputs() : 0, l);
232 l->append(")");
233 }
234
188 void ParamTraits<gfx::Transform>::Write( 235 void ParamTraits<gfx::Transform>::Write(
189 Message* m, const param_type& p) { 236 Message* m, const param_type& p) {
190 WriteParam(m, p.matrix().getDouble(0, 0)); 237 WriteParam(m, p.matrix().getDouble(0, 0));
191 WriteParam(m, p.matrix().getDouble(1, 0)); 238 WriteParam(m, p.matrix().getDouble(1, 0));
192 WriteParam(m, p.matrix().getDouble(2, 0)); 239 WriteParam(m, p.matrix().getDouble(2, 0));
193 WriteParam(m, p.matrix().getDouble(3, 0)); 240 WriteParam(m, p.matrix().getDouble(3, 0));
194 WriteParam(m, p.matrix().getDouble(0, 1)); 241 WriteParam(m, p.matrix().getDouble(0, 1));
195 WriteParam(m, p.matrix().getDouble(1, 1)); 242 WriteParam(m, p.matrix().getDouble(1, 1));
196 WriteParam(m, p.matrix().getDouble(2, 1)); 243 WriteParam(m, p.matrix().getDouble(2, 1));
197 WriteParam(m, p.matrix().getDouble(3, 1)); 244 WriteParam(m, p.matrix().getDouble(3, 1));
(...skipping 509 matching lines...) Expand 10 before | Expand all | Expand 10 after
707 l->append(", ["); 754 l->append(", [");
708 for (size_t i = 0; i < p.render_pass_list.size(); ++i) { 755 for (size_t i = 0; i < p.render_pass_list.size(); ++i) {
709 if (i) 756 if (i)
710 l->append(", "); 757 l->append(", ");
711 LogParam(*p.render_pass_list[i], l); 758 LogParam(*p.render_pass_list[i], l);
712 } 759 }
713 l->append("])"); 760 l->append("])");
714 } 761 }
715 762
716 } // namespace IPC 763 } // namespace IPC
OLDNEW
« no previous file with comments | « content/common/cc_messages.h ('k') | content/common/cc_messages_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698