Chromium Code Reviews| 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 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | |
| 195 if (!command_line.HasSwitch(switches::kAllowFiltersOverIPC)) | |
| 196 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.
| |
| 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)) { | |
| 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 Loading... | |
| 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 |
| OLD | NEW |