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

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: 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
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 "cc/output/compositor_frame.h" 7 #include "cc/output/compositor_frame.h"
8 #include "cc/output/filter_operations.h" 8 #include "cc/output/filter_operations.h"
9 #include "content/public/common/common_param_traits.h" 9 #include "content/public/common/common_param_traits.h"
10 #include "third_party/skia/src/core/SkOrderedReadBuffer.h"
11 #include "third_party/skia/src/core/SkOrderedWriteBuffer.h"
10 #include "ui/gfx/transform.h" 12 #include "ui/gfx/transform.h"
11 13
12 namespace IPC { 14 namespace IPC {
13 15
14 void ParamTraits<cc::FilterOperation>::Write( 16 void ParamTraits<cc::FilterOperation>::Write(
15 Message* m, const param_type& p) { 17 Message* m, const param_type& p) {
16 WriteParam(m, p.type()); 18 WriteParam(m, p.type());
17 switch (p.type()) { 19 switch (p.type()) {
18 case cc::FilterOperation::GRAYSCALE: 20 case cc::FilterOperation::GRAYSCALE:
19 case cc::FilterOperation::SEPIA: 21 case cc::FilterOperation::SEPIA:
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 const param_type& p, std::string* l) { 180 const param_type& p, std::string* l) {
179 l->append("("); 181 l->append("(");
180 for (std::size_t i = 0; i < p.size(); ++i) { 182 for (std::size_t i = 0; i < p.size(); ++i) {
181 if (i) 183 if (i)
182 l->append(", "); 184 l->append(", ");
183 LogParam(p.at(i), l); 185 LogParam(p.at(i), l);
184 } 186 }
185 l->append(")"); 187 l->append(")");
186 } 188 }
187 189
190 void ParamTraits<skia::RefPtr<SkImageFilter> >::Write(
191 Message* m, const param_type& p) {
192 SkImageFilter* filter = p.get();
193 if (filter) {
194 SkOrderedWriteBuffer buffer(1024);
195 buffer.setFlags(SkOrderedWriteBuffer::kCrossProcess_Flag);
196 buffer.writeFlattenable(filter);
197 buffer.writeToMemory(m->BeginWriteData(buffer.bytesWritten()));
198 } else {
199 m->WriteData(0, 0);
200 }
201 }
202
203 bool ParamTraits<skia::RefPtr<SkImageFilter> >::Read(
204 const Message* m, PickleIterator* iter, param_type* r) {
205 const char* data = 0;
206 int length = 0;
207 if (!m->ReadData(iter, &data, &length))
208 return false;
209 if (length > 0) {
210 SkOrderedReadBuffer buffer(data, length);
211 *r = skia::AdoptRef(buffer.readFlattenableT<SkImageFilter>());
piman 2013/07/30 19:57:35 Yes, obviously we can't land this until we know it
sugoi1 2013/07/30 20:08:21 All right, if putting it behind a flag is an accep
212 } else {
213 r->clear();
214 }
215 return true;
216 }
217
218 void ParamTraits<skia::RefPtr<SkImageFilter> >::Log(
219 const param_type& p, std::string* l) {
220 l->append("(");
221 LogParam(p.get() ? p->countInputs() : 0, l);
222 l->append(")");
223 }
224
188 void ParamTraits<gfx::Transform>::Write( 225 void ParamTraits<gfx::Transform>::Write(
189 Message* m, const param_type& p) { 226 Message* m, const param_type& p) {
190 WriteParam(m, p.matrix().getDouble(0, 0)); 227 WriteParam(m, p.matrix().getDouble(0, 0));
191 WriteParam(m, p.matrix().getDouble(1, 0)); 228 WriteParam(m, p.matrix().getDouble(1, 0));
192 WriteParam(m, p.matrix().getDouble(2, 0)); 229 WriteParam(m, p.matrix().getDouble(2, 0));
193 WriteParam(m, p.matrix().getDouble(3, 0)); 230 WriteParam(m, p.matrix().getDouble(3, 0));
194 WriteParam(m, p.matrix().getDouble(0, 1)); 231 WriteParam(m, p.matrix().getDouble(0, 1));
195 WriteParam(m, p.matrix().getDouble(1, 1)); 232 WriteParam(m, p.matrix().getDouble(1, 1));
196 WriteParam(m, p.matrix().getDouble(2, 1)); 233 WriteParam(m, p.matrix().getDouble(2, 1));
197 WriteParam(m, p.matrix().getDouble(3, 1)); 234 WriteParam(m, p.matrix().getDouble(3, 1));
(...skipping 509 matching lines...) Expand 10 before | Expand all | Expand 10 after
707 l->append(", ["); 744 l->append(", [");
708 for (size_t i = 0; i < p.render_pass_list.size(); ++i) { 745 for (size_t i = 0; i < p.render_pass_list.size(); ++i) {
709 if (i) 746 if (i)
710 l->append(", "); 747 l->append(", ");
711 LogParam(*p.render_pass_list[i], l); 748 LogParam(*p.render_pass_list[i], l);
712 } 749 }
713 l->append("])"); 750 l->append("])");
714 } 751 }
715 752
716 } // namespace IPC 753 } // namespace IPC
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698