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
3 // found in the LICENSE file.
5 #include "content/common/cc_messages.h"
7 #include "cc/output/compositor_frame.h"
8 #include "content/public/common/common_param_traits.h"
9 #include "third_party/WebKit/Source/Platform/chromium/public/WebData.h"
10 #include "third_party/WebKit/Source/Platform/chromium/public/WebFilterOperations.h"
11 #include "ui/gfx/transform.h"
15 void ParamTraits
<WebKit::WebFilterOperation
>::Write(
16 Message
* m
, const param_type
& p
) {
17 WriteParam(m
, p
.type());
19 case WebKit::WebFilterOperation::FilterTypeGrayscale
:
20 case WebKit::WebFilterOperation::FilterTypeSepia
:
21 case WebKit::WebFilterOperation::FilterTypeSaturate
:
22 case WebKit::WebFilterOperation::FilterTypeHueRotate
:
23 case WebKit::WebFilterOperation::FilterTypeInvert
:
24 case WebKit::WebFilterOperation::FilterTypeBrightness
:
25 case WebKit::WebFilterOperation::FilterTypeSaturatingBrightness
:
26 case WebKit::WebFilterOperation::FilterTypeContrast
:
27 case WebKit::WebFilterOperation::FilterTypeOpacity
:
28 case WebKit::WebFilterOperation::FilterTypeBlur
:
29 WriteParam(m
, p
.amount());
31 case WebKit::WebFilterOperation::FilterTypeDropShadow
:
32 WriteParam(m
, p
.dropShadowOffset());
33 WriteParam(m
, p
.amount());
34 WriteParam(m
, p
.dropShadowColor());
36 case WebKit::WebFilterOperation::FilterTypeColorMatrix
:
37 for (int i
= 0; i
< 20; ++i
)
38 WriteParam(m
, p
.matrix()[i
]);
40 case WebKit::WebFilterOperation::FilterTypeZoom
:
41 WriteParam(m
, p
.amount());
42 WriteParam(m
, p
.zoomInset());
47 bool ParamTraits
<WebKit::WebFilterOperation
>::Read(
48 const Message
* m
, PickleIterator
* iter
, param_type
* r
) {
49 WebKit::WebFilterOperation::FilterType type
;
51 WebKit::WebPoint dropShadowOffset
;
52 WebKit::WebColor dropShadowColor
;
56 if (!ReadParam(m
, iter
, &type
))
62 case WebKit::WebFilterOperation::FilterTypeGrayscale
:
63 case WebKit::WebFilterOperation::FilterTypeSepia
:
64 case WebKit::WebFilterOperation::FilterTypeSaturate
:
65 case WebKit::WebFilterOperation::FilterTypeHueRotate
:
66 case WebKit::WebFilterOperation::FilterTypeInvert
:
67 case WebKit::WebFilterOperation::FilterTypeBrightness
:
68 case WebKit::WebFilterOperation::FilterTypeSaturatingBrightness
:
69 case WebKit::WebFilterOperation::FilterTypeContrast
:
70 case WebKit::WebFilterOperation::FilterTypeOpacity
:
71 case WebKit::WebFilterOperation::FilterTypeBlur
:
72 if (ReadParam(m
, iter
, &amount
)) {
77 case WebKit::WebFilterOperation::FilterTypeDropShadow
:
78 if (ReadParam(m
, iter
, &dropShadowOffset
) &&
79 ReadParam(m
, iter
, &amount
) &&
80 ReadParam(m
, iter
, &dropShadowColor
)) {
81 r
->setDropShadowOffset(dropShadowOffset
);
83 r
->setDropShadowColor(dropShadowColor
);
87 case WebKit::WebFilterOperation::FilterTypeColorMatrix
: {
89 for (i
= 0; i
< 20; ++i
) {
90 if (!ReadParam(m
, iter
, &matrix
[i
]))
99 case WebKit::WebFilterOperation::FilterTypeZoom
:
100 if (ReadParam(m
, iter
, &amount
) &&
101 ReadParam(m
, iter
, &zoom_inset
) &&
104 r
->setAmount(amount
);
105 r
->setZoomInset(zoom_inset
);
113 void ParamTraits
<WebKit::WebFilterOperation
>::Log(
114 const param_type
& p
, std::string
* l
) {
116 LogParam(static_cast<unsigned>(p
.type()), l
);
120 case WebKit::WebFilterOperation::FilterTypeGrayscale
:
121 case WebKit::WebFilterOperation::FilterTypeSepia
:
122 case WebKit::WebFilterOperation::FilterTypeSaturate
:
123 case WebKit::WebFilterOperation::FilterTypeHueRotate
:
124 case WebKit::WebFilterOperation::FilterTypeInvert
:
125 case WebKit::WebFilterOperation::FilterTypeBrightness
:
126 case WebKit::WebFilterOperation::FilterTypeSaturatingBrightness
:
127 case WebKit::WebFilterOperation::FilterTypeContrast
:
128 case WebKit::WebFilterOperation::FilterTypeOpacity
:
129 case WebKit::WebFilterOperation::FilterTypeBlur
:
130 LogParam(p
.amount(), l
);
132 case WebKit::WebFilterOperation::FilterTypeDropShadow
:
133 LogParam(p
.dropShadowOffset(), l
);
135 LogParam(p
.amount(), l
);
137 LogParam(p
.dropShadowColor(), l
);
139 case WebKit::WebFilterOperation::FilterTypeColorMatrix
:
140 for (int i
= 0; i
< 20; ++i
) {
143 LogParam(p
.matrix()[i
], l
);
146 case WebKit::WebFilterOperation::FilterTypeZoom
:
147 LogParam(p
.amount(), l
);
149 LogParam(p
.zoomInset(), l
);
155 void ParamTraits
<WebKit::WebFilterOperations
>::Write(
156 Message
* m
, const param_type
& p
) {
157 WriteParam(m
, p
.size());
158 for (std::size_t i
= 0; i
< p
.size(); ++i
) {
159 WriteParam(m
, p
.at(i
));
163 bool ParamTraits
<WebKit::WebFilterOperations
>::Read(
164 const Message
* m
, PickleIterator
* iter
, param_type
* r
) {
166 if (!ReadParam(m
, iter
, &count
))
169 for (std::size_t i
= 0; i
< count
; ++i
) {
170 WebKit::WebFilterOperation op
=
171 WebKit::WebFilterOperation::createEmptyFilter();
172 if (!ReadParam(m
, iter
, &op
))
179 void ParamTraits
<WebKit::WebFilterOperations
>::Log(
180 const param_type
& p
, std::string
* l
) {
182 for (std::size_t i
= 0; i
< p
.size(); ++i
) {
185 LogParam(p
.at(i
), l
);
190 void ParamTraits
<gfx::Transform
>::Write(
191 Message
* m
, const param_type
& p
) {
192 WriteParam(m
, p
.matrix().getDouble(0, 0));
193 WriteParam(m
, p
.matrix().getDouble(1, 0));
194 WriteParam(m
, p
.matrix().getDouble(2, 0));
195 WriteParam(m
, p
.matrix().getDouble(3, 0));
196 WriteParam(m
, p
.matrix().getDouble(0, 1));
197 WriteParam(m
, p
.matrix().getDouble(1, 1));
198 WriteParam(m
, p
.matrix().getDouble(2, 1));
199 WriteParam(m
, p
.matrix().getDouble(3, 1));
200 WriteParam(m
, p
.matrix().getDouble(0, 2));
201 WriteParam(m
, p
.matrix().getDouble(1, 2));
202 WriteParam(m
, p
.matrix().getDouble(2, 2));
203 WriteParam(m
, p
.matrix().getDouble(3, 2));
204 WriteParam(m
, p
.matrix().getDouble(0, 3));
205 WriteParam(m
, p
.matrix().getDouble(1, 3));
206 WriteParam(m
, p
.matrix().getDouble(2, 3));
207 WriteParam(m
, p
.matrix().getDouble(3, 3));
210 bool ParamTraits
<gfx::Transform
>::Read(
211 const Message
* m
, PickleIterator
* iter
, param_type
* r
) {
212 // Note: In this function, "m12" means 1st row, 2nd column of the matrix.
213 // This is consistent with Skia's row-column notation, but backwards from
214 // WebCore's column-row notation.
215 double m11
, m12
, m13
, m14
, m21
, m22
, m23
, m24
, m31
, m32
, m33
, m34
,
219 ReadParam(m
, iter
, &m11
) &&
220 ReadParam(m
, iter
, &m21
) &&
221 ReadParam(m
, iter
, &m31
) &&
222 ReadParam(m
, iter
, &m41
) &&
223 ReadParam(m
, iter
, &m12
) &&
224 ReadParam(m
, iter
, &m22
) &&
225 ReadParam(m
, iter
, &m32
) &&
226 ReadParam(m
, iter
, &m42
) &&
227 ReadParam(m
, iter
, &m13
) &&
228 ReadParam(m
, iter
, &m23
) &&
229 ReadParam(m
, iter
, &m33
) &&
230 ReadParam(m
, iter
, &m43
) &&
231 ReadParam(m
, iter
, &m14
) &&
232 ReadParam(m
, iter
, &m24
) &&
233 ReadParam(m
, iter
, &m34
) &&
234 ReadParam(m
, iter
, &m44
);
237 r
->matrix().setDouble(0, 0, m11
);
238 r
->matrix().setDouble(1, 0, m21
);
239 r
->matrix().setDouble(2, 0, m31
);
240 r
->matrix().setDouble(3, 0, m41
);
241 r
->matrix().setDouble(0, 1, m12
);
242 r
->matrix().setDouble(1, 1, m22
);
243 r
->matrix().setDouble(2, 1, m32
);
244 r
->matrix().setDouble(3, 1, m42
);
245 r
->matrix().setDouble(0, 2, m13
);
246 r
->matrix().setDouble(1, 2, m23
);
247 r
->matrix().setDouble(2, 2, m33
);
248 r
->matrix().setDouble(3, 2, m43
);
249 r
->matrix().setDouble(0, 3, m14
);
250 r
->matrix().setDouble(1, 3, m24
);
251 r
->matrix().setDouble(2, 3, m34
);
252 r
->matrix().setDouble(3, 3, m44
);
258 void ParamTraits
<gfx::Transform
>::Log(
259 const param_type
& p
, std::string
* l
) {
261 LogParam(p
.matrix().getDouble(0, 0), l
);
263 LogParam(p
.matrix().getDouble(1, 0), l
);
265 LogParam(p
.matrix().getDouble(2, 0), l
);
267 LogParam(p
.matrix().getDouble(3, 0), l
);
269 LogParam(p
.matrix().getDouble(0, 1), l
);
271 LogParam(p
.matrix().getDouble(1, 1), l
);
273 LogParam(p
.matrix().getDouble(2, 1), l
);
275 LogParam(p
.matrix().getDouble(3, 1), l
);
277 LogParam(p
.matrix().getDouble(0, 2), l
);
279 LogParam(p
.matrix().getDouble(1, 2), l
);
281 LogParam(p
.matrix().getDouble(2, 2), l
);
283 LogParam(p
.matrix().getDouble(3, 2), l
);
285 LogParam(p
.matrix().getDouble(0, 3), l
);
287 LogParam(p
.matrix().getDouble(1, 3), l
);
289 LogParam(p
.matrix().getDouble(2, 3), l
);
291 LogParam(p
.matrix().getDouble(3, 3), l
);
295 void ParamTraits
<cc::RenderPass
>::Write(
296 Message
* m
, const param_type
& p
) {
298 WriteParam(m
, p
.output_rect
);
299 WriteParam(m
, p
.damage_rect
);
300 WriteParam(m
, p
.transform_to_root_target
);
301 WriteParam(m
, p
.has_transparent_background
);
302 WriteParam(m
, p
.has_occlusion_from_outside_target_surface
);
303 WriteParam(m
, p
.shared_quad_state_list
.size());
304 WriteParam(m
, p
.quad_list
.size());
306 for (size_t i
= 0; i
< p
.shared_quad_state_list
.size(); ++i
)
307 WriteParam(m
, *p
.shared_quad_state_list
[i
]);
309 size_t shared_quad_state_index
= 0;
310 for (size_t i
= 0; i
< p
.quad_list
.size(); ++i
) {
311 const cc::DrawQuad
* quad
= p
.quad_list
[i
];
313 switch (quad
->material
) {
314 case cc::DrawQuad::CHECKERBOARD
:
315 WriteParam(m
, *cc::CheckerboardDrawQuad::MaterialCast(quad
));
317 case cc::DrawQuad::DEBUG_BORDER
:
318 WriteParam(m
, *cc::DebugBorderDrawQuad::MaterialCast(quad
));
320 case cc::DrawQuad::IO_SURFACE_CONTENT
:
321 WriteParam(m
, *cc::IOSurfaceDrawQuad::MaterialCast(quad
));
323 case cc::DrawQuad::PICTURE_CONTENT
:
326 case cc::DrawQuad::TEXTURE_CONTENT
:
327 WriteParam(m
, *cc::TextureDrawQuad::MaterialCast(quad
));
329 case cc::DrawQuad::RENDER_PASS
:
330 WriteParam(m
, *cc::RenderPassDrawQuad::MaterialCast(quad
));
332 case cc::DrawQuad::SOLID_COLOR
:
333 WriteParam(m
, *cc::SolidColorDrawQuad::MaterialCast(quad
));
335 case cc::DrawQuad::TILED_CONTENT
:
336 WriteParam(m
, *cc::TileDrawQuad::MaterialCast(quad
));
338 case cc::DrawQuad::STREAM_VIDEO_CONTENT
:
339 WriteParam(m
, *cc::StreamVideoDrawQuad::MaterialCast(quad
));
341 case cc::DrawQuad::YUV_VIDEO_CONTENT
:
342 WriteParam(m
, *cc::YUVVideoDrawQuad::MaterialCast(quad
));
344 case cc::DrawQuad::INVALID
:
348 const cc::ScopedPtrVector
<cc::SharedQuadState
>& sqs_list
=
349 p
.shared_quad_state_list
;
351 // This is an invalid index.
352 size_t bad_index
= sqs_list
.size();
354 // Null shared quad states should not occur.
355 DCHECK(quad
->shared_quad_state
);
356 if (!quad
->shared_quad_state
) {
357 WriteParam(m
, bad_index
);
361 // SharedQuadStates should appear in the order they are used by DrawQuads.
362 // Find the SharedQuadState for this DrawQuad.
363 while (shared_quad_state_index
< sqs_list
.size() &&
364 quad
->shared_quad_state
!= sqs_list
[shared_quad_state_index
])
365 ++shared_quad_state_index
;
367 DCHECK_LT(shared_quad_state_index
, sqs_list
.size());
368 if (shared_quad_state_index
>= sqs_list
.size()) {
369 WriteParam(m
, bad_index
);
373 DCHECK_LT(shared_quad_state_index
, p
.shared_quad_state_list
.size());
374 WriteParam(m
, shared_quad_state_index
);
378 template<typename QuadType
>
379 static scoped_ptr
<cc::DrawQuad
> ReadDrawQuad(const Message
* m
,
380 PickleIterator
* iter
) {
381 scoped_ptr
<QuadType
> quad
= QuadType::Create();
382 if (!ReadParam(m
, iter
, quad
.get()))
383 return scoped_ptr
<QuadType
>(NULL
).template PassAs
<cc::DrawQuad
>();
384 return quad
.template PassAs
<cc::DrawQuad
>();
387 bool ParamTraits
<cc::RenderPass
>::Read(
388 const Message
* m
, PickleIterator
* iter
, param_type
* p
) {
389 cc::RenderPass::Id
id(-1, -1);
390 gfx::Rect output_rect
;
391 gfx::RectF damage_rect
;
392 gfx::Transform transform_to_root_target
;
393 bool has_transparent_background
;
394 bool has_occlusion_from_outside_target_surface
;
395 size_t shared_quad_state_list_size
;
396 size_t quad_list_size
;
398 if (!ReadParam(m
, iter
, &id
) ||
399 !ReadParam(m
, iter
, &output_rect
) ||
400 !ReadParam(m
, iter
, &damage_rect
) ||
401 !ReadParam(m
, iter
, &transform_to_root_target
) ||
402 !ReadParam(m
, iter
, &has_transparent_background
) ||
403 !ReadParam(m
, iter
, &has_occlusion_from_outside_target_surface
) ||
404 !ReadParam(m
, iter
, &shared_quad_state_list_size
) ||
405 !ReadParam(m
, iter
, &quad_list_size
))
411 transform_to_root_target
,
412 has_transparent_background
,
413 has_occlusion_from_outside_target_surface
);
415 for (size_t i
= 0; i
< shared_quad_state_list_size
; ++i
) {
416 scoped_ptr
<cc::SharedQuadState
> state(cc::SharedQuadState::Create());
417 if (!ReadParam(m
, iter
, state
.get()))
419 p
->shared_quad_state_list
.push_back(state
.Pass());
422 size_t last_shared_quad_state_index
= 0;
423 for (size_t i
= 0; i
< quad_list_size
; ++i
) {
424 cc::DrawQuad::Material material
;
425 PickleIterator temp_iter
= *iter
;
426 if (!ReadParam(m
, &temp_iter
, &material
))
429 scoped_ptr
<cc::DrawQuad
> draw_quad
;
431 case cc::DrawQuad::CHECKERBOARD
:
432 draw_quad
= ReadDrawQuad
<cc::CheckerboardDrawQuad
>(m
, iter
);
434 case cc::DrawQuad::DEBUG_BORDER
:
435 draw_quad
= ReadDrawQuad
<cc::DebugBorderDrawQuad
>(m
, iter
);
437 case cc::DrawQuad::IO_SURFACE_CONTENT
:
438 draw_quad
= ReadDrawQuad
<cc::IOSurfaceDrawQuad
>(m
, iter
);
440 case cc::DrawQuad::PICTURE_CONTENT
:
443 case cc::DrawQuad::TEXTURE_CONTENT
:
444 draw_quad
= ReadDrawQuad
<cc::TextureDrawQuad
>(m
, iter
);
446 case cc::DrawQuad::RENDER_PASS
:
447 draw_quad
= ReadDrawQuad
<cc::RenderPassDrawQuad
>(m
, iter
);
449 case cc::DrawQuad::SOLID_COLOR
:
450 draw_quad
= ReadDrawQuad
<cc::SolidColorDrawQuad
>(m
, iter
);
452 case cc::DrawQuad::TILED_CONTENT
:
453 draw_quad
= ReadDrawQuad
<cc::TileDrawQuad
>(m
, iter
);
455 case cc::DrawQuad::STREAM_VIDEO_CONTENT
:
456 draw_quad
= ReadDrawQuad
<cc::StreamVideoDrawQuad
>(m
, iter
);
458 case cc::DrawQuad::YUV_VIDEO_CONTENT
:
459 draw_quad
= ReadDrawQuad
<cc::YUVVideoDrawQuad
>(m
, iter
);
461 case cc::DrawQuad::INVALID
:
467 size_t shared_quad_state_index
;
468 if (!ReadParam(m
, iter
, &shared_quad_state_index
) ||
469 shared_quad_state_index
>= p
->shared_quad_state_list
.size())
471 // SharedQuadState indexes should be in ascending order.
472 if (shared_quad_state_index
< last_shared_quad_state_index
)
474 last_shared_quad_state_index
= shared_quad_state_index
;
476 draw_quad
->shared_quad_state
=
477 p
->shared_quad_state_list
[shared_quad_state_index
];
479 p
->quad_list
.push_back(draw_quad
.Pass());
485 void ParamTraits
<cc::RenderPass
>::Log(
486 const param_type
& p
, std::string
* l
) {
487 l
->append("RenderPass((");
490 LogParam(p
.output_rect
, l
);
492 LogParam(p
.damage_rect
, l
);
494 LogParam(p
.transform_to_root_target
, l
);
496 LogParam(p
.has_transparent_background
, l
);
498 LogParam(p
.has_occlusion_from_outside_target_surface
, l
);
502 for (size_t i
= 0; i
< p
.shared_quad_state_list
.size(); ++i
) {
505 LogParam(*p
.shared_quad_state_list
[i
], l
);
508 for (size_t i
= 0; i
< p
.quad_list
.size(); ++i
) {
511 const cc::DrawQuad
* quad
= p
.quad_list
[i
];
512 switch (quad
->material
) {
513 case cc::DrawQuad::CHECKERBOARD
:
514 LogParam(*cc::CheckerboardDrawQuad::MaterialCast(quad
), l
);
516 case cc::DrawQuad::DEBUG_BORDER
:
517 LogParam(*cc::DebugBorderDrawQuad::MaterialCast(quad
), l
);
519 case cc::DrawQuad::IO_SURFACE_CONTENT
:
520 LogParam(*cc::IOSurfaceDrawQuad::MaterialCast(quad
), l
);
522 case cc::DrawQuad::PICTURE_CONTENT
:
525 case cc::DrawQuad::TEXTURE_CONTENT
:
526 LogParam(*cc::TextureDrawQuad::MaterialCast(quad
), l
);
528 case cc::DrawQuad::RENDER_PASS
:
529 LogParam(*cc::RenderPassDrawQuad::MaterialCast(quad
), l
);
531 case cc::DrawQuad::SOLID_COLOR
:
532 LogParam(*cc::SolidColorDrawQuad::MaterialCast(quad
), l
);
534 case cc::DrawQuad::TILED_CONTENT
:
535 LogParam(*cc::TileDrawQuad::MaterialCast(quad
), l
);
537 case cc::DrawQuad::STREAM_VIDEO_CONTENT
:
538 LogParam(*cc::StreamVideoDrawQuad::MaterialCast(quad
), l
);
540 case cc::DrawQuad::YUV_VIDEO_CONTENT
:
541 LogParam(*cc::YUVVideoDrawQuad::MaterialCast(quad
), l
);
543 case cc::DrawQuad::INVALID
:
551 enum CompositorFrameType
{
559 void ParamTraits
<cc::CompositorFrame
>::Write(Message
* m
,
560 const param_type
& p
) {
561 WriteParam(m
, p
.metadata
);
562 if (p
.delegated_frame_data
) {
563 DCHECK(!p
.gl_frame_data
);
564 DCHECK(!p
.software_frame_data
);
565 WriteParam(m
, static_cast<int>(DELEGATED_FRAME
));
566 WriteParam(m
, *p
.delegated_frame_data
);
567 } else if (p
.gl_frame_data
) {
568 DCHECK(!p
.software_frame_data
);
569 WriteParam(m
, static_cast<int>(GL_FRAME
));
570 WriteParam(m
, *p
.gl_frame_data
);
571 } else if (p
.software_frame_data
) {
572 WriteParam(m
, static_cast<int>(SOFTWARE_FRAME
));
573 WriteParam(m
, *p
.software_frame_data
);
575 WriteParam(m
, static_cast<int>(NO_FRAME
));
579 bool ParamTraits
<cc::CompositorFrame
>::Read(const Message
* m
,
580 PickleIterator
* iter
,
582 if (!ReadParam(m
, iter
, &p
->metadata
))
585 int compositor_frame_type
;
586 if (!ReadParam(m
, iter
, &compositor_frame_type
))
589 switch (compositor_frame_type
) {
590 case DELEGATED_FRAME
:
591 p
->delegated_frame_data
.reset(new cc::DelegatedFrameData());
592 if (!ReadParam(m
, iter
, p
->delegated_frame_data
.get()))
596 p
->gl_frame_data
.reset(new cc::GLFrameData());
597 if (!ReadParam(m
, iter
, p
->gl_frame_data
.get()))
601 p
->software_frame_data
.reset(new cc::SoftwareFrameData());
602 if (!ReadParam(m
, iter
, p
->software_frame_data
.get()))
613 void ParamTraits
<cc::CompositorFrame
>::Log(const param_type
& p
,
615 l
->append("CompositorFrame(");
616 LogParam(p
.metadata
, l
);
618 if (p
.delegated_frame_data
)
619 LogParam(*p
.delegated_frame_data
, l
);
620 else if (p
.gl_frame_data
)
621 LogParam(*p
.gl_frame_data
, l
);
622 else if (p
.software_frame_data
)
623 LogParam(*p
.software_frame_data
, l
);
627 void ParamTraits
<cc::CompositorFrameAck
>::Write(Message
* m
,
628 const param_type
& p
) {
629 WriteParam(m
, p
.resources
);
630 WriteParam(m
, p
.last_dib_id
);
631 if (p
.gl_frame_data
) {
632 WriteParam(m
, static_cast<int>(GL_FRAME
));
633 WriteParam(m
, *p
.gl_frame_data
);
635 WriteParam(m
, static_cast<int>(NO_FRAME
));
639 bool ParamTraits
<cc::CompositorFrameAck
>::Read(const Message
* m
,
640 PickleIterator
* iter
,
642 if (!ReadParam(m
, iter
, &p
->resources
))
645 if (!ReadParam(m
, iter
, &p
->last_dib_id
))
648 int compositor_frame_type
;
649 if (!ReadParam(m
, iter
, &compositor_frame_type
))
652 switch (compositor_frame_type
) {
656 p
->gl_frame_data
.reset(new cc::GLFrameData());
657 if (!ReadParam(m
, iter
, p
->gl_frame_data
.get()))
666 void ParamTraits
<cc::CompositorFrameAck
>::Log(const param_type
& p
,
668 l
->append("CompositorFrameAck(");
669 LogParam(p
.resources
, l
);
671 LogParam(p
.last_dib_id
, l
);
674 LogParam(*p
.gl_frame_data
, l
);
678 void ParamTraits
<cc::DelegatedFrameData
>::Write(Message
* m
,
679 const param_type
& p
) {
680 WriteParam(m
, p
.resource_list
);
681 WriteParam(m
, p
.render_pass_list
.size());
682 for (size_t i
= 0; i
< p
.render_pass_list
.size(); ++i
)
683 WriteParam(m
, *p
.render_pass_list
[i
]);
686 bool ParamTraits
<cc::DelegatedFrameData
>::Read(const Message
* m
,
687 PickleIterator
* iter
,
689 const static size_t kMaxRenderPasses
= 10000;
691 size_t num_render_passes
;
692 if (!ReadParam(m
, iter
, &p
->resource_list
) ||
693 !ReadParam(m
, iter
, &num_render_passes
) ||
694 num_render_passes
> kMaxRenderPasses
)
696 for (size_t i
= 0; i
< num_render_passes
; ++i
) {
697 scoped_ptr
<cc::RenderPass
> render_pass
= cc::RenderPass::Create();
698 if (!ReadParam(m
, iter
, render_pass
.get()))
700 p
->render_pass_list
.push_back(render_pass
.Pass());
705 void ParamTraits
<cc::DelegatedFrameData
>::Log(const param_type
& p
,
707 l
->append("DelegatedFrameData(");
708 LogParam(p
.resource_list
, l
);
710 for (size_t i
= 0; i
< p
.render_pass_list
.size(); ++i
) {
713 LogParam(*p
.render_pass_list
[i
], l
);