OLD | NEW |
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 Loading... |
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 SkImageFilter* filter = p.get(); |
| 195 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
| 196 if (filter && command_line.HasSwitch(switches::kAllowFiltersOverIPC)) { |
| 197 SkOrderedWriteBuffer buffer(1024); |
| 198 buffer.setFlags(SkOrderedWriteBuffer::kCrossProcess_Flag); |
| 199 buffer.writeFlattenable(filter); |
| 200 buffer.writeToMemory(m->BeginWriteData(buffer.bytesWritten())); |
| 201 } else { |
| 202 m->WriteData(0, 0); |
| 203 } |
| 204 } |
| 205 |
| 206 bool ParamTraits<skia::RefPtr<SkImageFilter> >::Read( |
| 207 const Message* m, PickleIterator* iter, param_type* r) { |
| 208 const char* data = 0; |
| 209 int length = 0; |
| 210 if (!m->ReadData(iter, &data, &length)) |
| 211 return false; |
| 212 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
| 213 if ((length > 0) && command_line.HasSwitch(switches::kAllowFiltersOverIPC)) { |
| 214 SkOrderedReadBuffer buffer(data, length); |
| 215 *r = skia::AdoptRef(buffer.readFlattenableT<SkImageFilter>()); |
| 216 } else { |
| 217 r->clear(); |
| 218 } |
| 219 return true; |
| 220 } |
| 221 |
| 222 void ParamTraits<skia::RefPtr<SkImageFilter> >::Log( |
| 223 const param_type& p, std::string* l) { |
| 224 l->append("("); |
| 225 LogParam(p.get() ? p->countInputs() : 0, l); |
| 226 l->append(")"); |
| 227 } |
| 228 |
188 void ParamTraits<gfx::Transform>::Write( | 229 void ParamTraits<gfx::Transform>::Write( |
189 Message* m, const param_type& p) { | 230 Message* m, const param_type& p) { |
190 WriteParam(m, p.matrix().getDouble(0, 0)); | 231 WriteParam(m, p.matrix().getDouble(0, 0)); |
191 WriteParam(m, p.matrix().getDouble(1, 0)); | 232 WriteParam(m, p.matrix().getDouble(1, 0)); |
192 WriteParam(m, p.matrix().getDouble(2, 0)); | 233 WriteParam(m, p.matrix().getDouble(2, 0)); |
193 WriteParam(m, p.matrix().getDouble(3, 0)); | 234 WriteParam(m, p.matrix().getDouble(3, 0)); |
194 WriteParam(m, p.matrix().getDouble(0, 1)); | 235 WriteParam(m, p.matrix().getDouble(0, 1)); |
195 WriteParam(m, p.matrix().getDouble(1, 1)); | 236 WriteParam(m, p.matrix().getDouble(1, 1)); |
196 WriteParam(m, p.matrix().getDouble(2, 1)); | 237 WriteParam(m, p.matrix().getDouble(2, 1)); |
197 WriteParam(m, p.matrix().getDouble(3, 1)); | 238 WriteParam(m, p.matrix().getDouble(3, 1)); |
(...skipping 509 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
707 l->append(", ["); | 748 l->append(", ["); |
708 for (size_t i = 0; i < p.render_pass_list.size(); ++i) { | 749 for (size_t i = 0; i < p.render_pass_list.size(); ++i) { |
709 if (i) | 750 if (i) |
710 l->append(", "); | 751 l->append(", "); |
711 LogParam(*p.render_pass_list[i], l); | 752 LogParam(*p.render_pass_list[i], l); |
712 } | 753 } |
713 l->append("])"); | 754 l->append("])"); |
714 } | 755 } |
715 | 756 |
716 } // namespace IPC | 757 } // namespace IPC |
OLD | NEW |