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 "base/command_line.h"
8 #include "cc/output/compositor_frame.h"
9 #include "cc/output/filter_operations.h"
10 #include "content/public/common/common_param_traits.h"
11 #include "content/public/common/content_switches.h"
12 #include "third_party/skia/include/core/SkData.h"
13 #include "third_party/skia/include/core/SkFlattenableSerialization.h"
14 #include "ui/gfx/transform.h"
18 void ParamTraits
<cc::FilterOperation
>::Write(
19 Message
* m
, const param_type
& p
) {
20 WriteParam(m
, p
.type());
22 case cc::FilterOperation::GRAYSCALE
:
23 case cc::FilterOperation::SEPIA
:
24 case cc::FilterOperation::SATURATE
:
25 case cc::FilterOperation::HUE_ROTATE
:
26 case cc::FilterOperation::INVERT
:
27 case cc::FilterOperation::BRIGHTNESS
:
28 case cc::FilterOperation::SATURATING_BRIGHTNESS
:
29 case cc::FilterOperation::CONTRAST
:
30 case cc::FilterOperation::OPACITY
:
31 case cc::FilterOperation::BLUR
:
32 WriteParam(m
, p
.amount());
34 case cc::FilterOperation::DROP_SHADOW
:
35 WriteParam(m
, p
.drop_shadow_offset());
36 WriteParam(m
, p
.amount());
37 WriteParam(m
, p
.drop_shadow_color());
39 case cc::FilterOperation::COLOR_MATRIX
:
40 for (int i
= 0; i
< 20; ++i
)
41 WriteParam(m
, p
.matrix()[i
]);
43 case cc::FilterOperation::ZOOM
:
44 WriteParam(m
, p
.amount());
45 WriteParam(m
, p
.zoom_inset());
47 case cc::FilterOperation::REFERENCE
:
48 WriteParam(m
, p
.image_filter());
50 case cc::FilterOperation::ALPHA_THRESHOLD
:
56 bool ParamTraits
<cc::FilterOperation
>::Read(
57 const Message
* m
, PickleIterator
* iter
, param_type
* r
) {
58 cc::FilterOperation::FilterType type
;
60 gfx::Point drop_shadow_offset
;
61 SkColor drop_shadow_color
;
65 if (!ReadParam(m
, iter
, &type
))
71 case cc::FilterOperation::GRAYSCALE
:
72 case cc::FilterOperation::SEPIA
:
73 case cc::FilterOperation::SATURATE
:
74 case cc::FilterOperation::HUE_ROTATE
:
75 case cc::FilterOperation::INVERT
:
76 case cc::FilterOperation::BRIGHTNESS
:
77 case cc::FilterOperation::SATURATING_BRIGHTNESS
:
78 case cc::FilterOperation::CONTRAST
:
79 case cc::FilterOperation::OPACITY
:
80 case cc::FilterOperation::BLUR
:
81 if (ReadParam(m
, iter
, &amount
)) {
82 r
->set_amount(amount
);
86 case cc::FilterOperation::DROP_SHADOW
:
87 if (ReadParam(m
, iter
, &drop_shadow_offset
) &&
88 ReadParam(m
, iter
, &amount
) &&
89 ReadParam(m
, iter
, &drop_shadow_color
)) {
90 r
->set_drop_shadow_offset(drop_shadow_offset
);
91 r
->set_amount(amount
);
92 r
->set_drop_shadow_color(drop_shadow_color
);
96 case cc::FilterOperation::COLOR_MATRIX
: {
98 for (i
= 0; i
< 20; ++i
) {
99 if (!ReadParam(m
, iter
, &matrix
[i
]))
103 r
->set_matrix(matrix
);
108 case cc::FilterOperation::ZOOM
:
109 if (ReadParam(m
, iter
, &amount
) &&
110 ReadParam(m
, iter
, &zoom_inset
) &&
113 r
->set_amount(amount
);
114 r
->set_zoom_inset(zoom_inset
);
118 case cc::FilterOperation::REFERENCE
: {
119 skia::RefPtr
<SkImageFilter
> filter
;
120 if (!ReadParam(m
, iter
, &filter
)) {
124 r
->set_image_filter(filter
);
128 case cc::FilterOperation::ALPHA_THRESHOLD
:
134 void ParamTraits
<cc::FilterOperation
>::Log(
135 const param_type
& p
, std::string
* l
) {
137 LogParam(static_cast<unsigned>(p
.type()), l
);
141 case cc::FilterOperation::GRAYSCALE
:
142 case cc::FilterOperation::SEPIA
:
143 case cc::FilterOperation::SATURATE
:
144 case cc::FilterOperation::HUE_ROTATE
:
145 case cc::FilterOperation::INVERT
:
146 case cc::FilterOperation::BRIGHTNESS
:
147 case cc::FilterOperation::SATURATING_BRIGHTNESS
:
148 case cc::FilterOperation::CONTRAST
:
149 case cc::FilterOperation::OPACITY
:
150 case cc::FilterOperation::BLUR
:
151 LogParam(p
.amount(), l
);
153 case cc::FilterOperation::DROP_SHADOW
:
154 LogParam(p
.drop_shadow_offset(), l
);
156 LogParam(p
.amount(), l
);
158 LogParam(p
.drop_shadow_color(), l
);
160 case cc::FilterOperation::COLOR_MATRIX
:
161 for (int i
= 0; i
< 20; ++i
) {
164 LogParam(p
.matrix()[i
], l
);
167 case cc::FilterOperation::ZOOM
:
168 LogParam(p
.amount(), l
);
170 LogParam(p
.zoom_inset(), l
);
172 case cc::FilterOperation::REFERENCE
:
173 LogParam(p
.image_filter(), l
);
175 case cc::FilterOperation::ALPHA_THRESHOLD
:
182 void ParamTraits
<cc::FilterOperations
>::Write(
183 Message
* m
, const param_type
& p
) {
184 WriteParam(m
, p
.size());
185 for (std::size_t i
= 0; i
< p
.size(); ++i
) {
186 WriteParam(m
, p
.at(i
));
190 bool ParamTraits
<cc::FilterOperations
>::Read(
191 const Message
* m
, PickleIterator
* iter
, param_type
* r
) {
193 if (!ReadParam(m
, iter
, &count
))
196 for (std::size_t i
= 0; i
< count
; ++i
) {
197 cc::FilterOperation op
= cc::FilterOperation::CreateEmptyFilter();
198 if (!ReadParam(m
, iter
, &op
))
205 void ParamTraits
<cc::FilterOperations
>::Log(
206 const param_type
& p
, std::string
* l
) {
208 for (std::size_t i
= 0; i
< p
.size(); ++i
) {
211 LogParam(p
.at(i
), l
);
216 void ParamTraits
<skia::RefPtr
<SkImageFilter
> >::Write(
217 Message
* m
, const param_type
& p
) {
218 SkImageFilter
* filter
= p
.get();
219 const CommandLine
& command_line
= *CommandLine::ForCurrentProcess();
220 if (filter
&& !command_line
.HasSwitch(switches::kDisableFiltersOverIPC
)) {
221 skia::RefPtr
<SkData
> data
=
222 skia::AdoptRef(SkValidatingSerializeFlattenable(filter
));
223 m
->WriteData(static_cast<const char*>(data
->data()), data
->size());
229 bool ParamTraits
<skia::RefPtr
<SkImageFilter
> >::Read(
230 const Message
* m
, PickleIterator
* iter
, param_type
* r
) {
231 const char* data
= 0;
233 if (!m
->ReadData(iter
, &data
, &length
))
235 const CommandLine
& command_line
= *CommandLine::ForCurrentProcess();
237 !command_line
.HasSwitch(switches::kDisableFiltersOverIPC
)) {
238 SkFlattenable
* flattenable
= SkValidatingDeserializeFlattenable(
239 data
, length
, SkImageFilter::GetFlattenableType());
240 *r
= skia::AdoptRef(static_cast<SkImageFilter
*>(flattenable
));
247 void ParamTraits
<skia::RefPtr
<SkImageFilter
> >::Log(
248 const param_type
& p
, std::string
* l
) {
250 LogParam(p
.get() ? p
->countInputs() : 0, l
);
254 void ParamTraits
<gfx::Transform
>::Write(
255 Message
* m
, const param_type
& p
) {
256 #ifdef SK_MSCALAR_IS_FLOAT
257 float column_major_data
[16];
258 p
.matrix().asColMajorf(column_major_data
);
260 double column_major_data
[16];
261 p
.matrix().asColMajord(column_major_data
);
263 m
->WriteBytes(&column_major_data
, sizeof(SkMScalar
) * 16);
266 bool ParamTraits
<gfx::Transform
>::Read(
267 const Message
* m
, PickleIterator
* iter
, param_type
* r
) {
268 const char* column_major_data
;
269 if (!m
->ReadBytes(iter
, &column_major_data
, sizeof(SkMScalar
) * 16))
271 r
->matrix().setColMajor(
272 reinterpret_cast<const SkMScalar
*>(column_major_data
));
276 void ParamTraits
<gfx::Transform
>::Log(
277 const param_type
& p
, std::string
* l
) {
278 #ifdef SK_MSCALAR_IS_FLOAT
279 float row_major_data
[16];
280 p
.matrix().asRowMajorf(row_major_data
);
282 double row_major_data
[16];
283 p
.matrix().asRowMajord(row_major_data
);
286 for (int i
= 0; i
< 16; ++i
) {
289 LogParam(row_major_data
[i
], l
);
294 void ParamTraits
<cc::RenderPass
>::Write(
295 Message
* m
, const param_type
& p
) {
297 WriteParam(m
, p
.output_rect
);
298 WriteParam(m
, p
.damage_rect
);
299 WriteParam(m
, p
.transform_to_root_target
);
300 WriteParam(m
, p
.has_transparent_background
);
301 WriteParam(m
, p
.shared_quad_state_list
.size());
302 WriteParam(m
, p
.quad_list
.size());
304 size_t shared_quad_state_index
= 0;
305 size_t last_shared_quad_state_index
= kuint32max
;
306 for (size_t i
= 0; i
< p
.quad_list
.size(); ++i
) {
307 const cc::DrawQuad
* quad
= p
.quad_list
[i
];
308 DCHECK(quad
->rect
.Contains(quad
->visible_rect
))
309 << quad
->material
<< " rect: " << quad
->rect
.ToString()
310 << " visible_rect: " << quad
->visible_rect
.ToString();
311 DCHECK(quad
->opaque_rect
.IsEmpty() ||
312 quad
->rect
.Contains(quad
->opaque_rect
))
313 << quad
->material
<< " rect: " << quad
->rect
.ToString()
314 << " opaque_rect: " << quad
->opaque_rect
.ToString();
316 switch (quad
->material
) {
317 case cc::DrawQuad::CHECKERBOARD
:
318 WriteParam(m
, *cc::CheckerboardDrawQuad::MaterialCast(quad
));
320 case cc::DrawQuad::DEBUG_BORDER
:
321 WriteParam(m
, *cc::DebugBorderDrawQuad::MaterialCast(quad
));
323 case cc::DrawQuad::IO_SURFACE_CONTENT
:
324 WriteParam(m
, *cc::IOSurfaceDrawQuad::MaterialCast(quad
));
326 case cc::DrawQuad::PICTURE_CONTENT
:
329 case cc::DrawQuad::TEXTURE_CONTENT
:
330 WriteParam(m
, *cc::TextureDrawQuad::MaterialCast(quad
));
332 case cc::DrawQuad::RENDER_PASS
:
333 WriteParam(m
, *cc::RenderPassDrawQuad::MaterialCast(quad
));
335 case cc::DrawQuad::SOLID_COLOR
:
336 WriteParam(m
, *cc::SolidColorDrawQuad::MaterialCast(quad
));
338 case cc::DrawQuad::SURFACE_CONTENT
:
339 WriteParam(m
, *cc::SurfaceDrawQuad::MaterialCast(quad
));
341 case cc::DrawQuad::TILED_CONTENT
:
342 WriteParam(m
, *cc::TileDrawQuad::MaterialCast(quad
));
344 case cc::DrawQuad::STREAM_VIDEO_CONTENT
:
345 WriteParam(m
, *cc::StreamVideoDrawQuad::MaterialCast(quad
));
347 case cc::DrawQuad::YUV_VIDEO_CONTENT
:
348 WriteParam(m
, *cc::YUVVideoDrawQuad::MaterialCast(quad
));
350 case cc::DrawQuad::INVALID
:
354 const cc::ScopedPtrVector
<cc::SharedQuadState
>& sqs_list
=
355 p
.shared_quad_state_list
;
357 // This is an invalid index.
358 size_t bad_index
= sqs_list
.size();
360 // Null shared quad states should not occur.
361 DCHECK(quad
->shared_quad_state
);
362 if (!quad
->shared_quad_state
) {
363 WriteParam(m
, bad_index
);
367 // SharedQuadStates should appear in the order they are used by DrawQuads.
368 // Find the SharedQuadState for this DrawQuad.
369 while (shared_quad_state_index
< sqs_list
.size() &&
370 quad
->shared_quad_state
!= sqs_list
[shared_quad_state_index
])
371 ++shared_quad_state_index
;
373 DCHECK_LT(shared_quad_state_index
, sqs_list
.size());
374 if (shared_quad_state_index
>= sqs_list
.size()) {
375 WriteParam(m
, bad_index
);
379 WriteParam(m
, shared_quad_state_index
);
380 if (shared_quad_state_index
!= last_shared_quad_state_index
) {
381 WriteParam(m
, *sqs_list
[shared_quad_state_index
]);
382 last_shared_quad_state_index
= shared_quad_state_index
;
387 static size_t ReserveSizeForRenderPassWrite(const cc::RenderPass
& p
) {
388 size_t to_reserve
= sizeof(cc::RenderPass
);
390 to_reserve
+= p
.shared_quad_state_list
.size() * sizeof(cc::SharedQuadState
);
392 // The shared_quad_state_index for each quad.
393 to_reserve
+= p
.quad_list
.size() * sizeof(size_t);
395 // The largest quad type, verified by a unit test.
396 to_reserve
+= p
.quad_list
.size() * sizeof(cc::RenderPassDrawQuad
);
400 template<typename QuadType
>
401 static scoped_ptr
<cc::DrawQuad
> ReadDrawQuad(const Message
* m
,
402 PickleIterator
* iter
) {
403 scoped_ptr
<QuadType
> quad
= QuadType::Create();
404 if (!ReadParam(m
, iter
, quad
.get()))
405 return scoped_ptr
<QuadType
>().template PassAs
<cc::DrawQuad
>();
406 return quad
.template PassAs
<cc::DrawQuad
>();
409 bool ParamTraits
<cc::RenderPass
>::Read(
410 const Message
* m
, PickleIterator
* iter
, param_type
* p
) {
411 cc::RenderPass::Id
id(-1, -1);
412 gfx::Rect output_rect
;
413 gfx::Rect damage_rect
;
414 gfx::Transform transform_to_root_target
;
415 bool has_transparent_background
;
416 size_t shared_quad_state_list_size
;
417 size_t quad_list_size
;
419 if (!ReadParam(m
, iter
, &id
) ||
420 !ReadParam(m
, iter
, &output_rect
) ||
421 !ReadParam(m
, iter
, &damage_rect
) ||
422 !ReadParam(m
, iter
, &transform_to_root_target
) ||
423 !ReadParam(m
, iter
, &has_transparent_background
) ||
424 !ReadParam(m
, iter
, &shared_quad_state_list_size
) ||
425 !ReadParam(m
, iter
, &quad_list_size
))
431 transform_to_root_target
,
432 has_transparent_background
);
434 size_t last_shared_quad_state_index
= kuint32max
;
435 for (size_t i
= 0; i
< quad_list_size
; ++i
) {
436 cc::DrawQuad::Material material
;
437 PickleIterator temp_iter
= *iter
;
438 if (!ReadParam(m
, &temp_iter
, &material
))
441 scoped_ptr
<cc::DrawQuad
> draw_quad
;
443 case cc::DrawQuad::CHECKERBOARD
:
444 draw_quad
= ReadDrawQuad
<cc::CheckerboardDrawQuad
>(m
, iter
);
446 case cc::DrawQuad::DEBUG_BORDER
:
447 draw_quad
= ReadDrawQuad
<cc::DebugBorderDrawQuad
>(m
, iter
);
449 case cc::DrawQuad::IO_SURFACE_CONTENT
:
450 draw_quad
= ReadDrawQuad
<cc::IOSurfaceDrawQuad
>(m
, iter
);
452 case cc::DrawQuad::PICTURE_CONTENT
:
455 case cc::DrawQuad::SURFACE_CONTENT
:
456 draw_quad
= ReadDrawQuad
<cc::SurfaceDrawQuad
>(m
, iter
);
458 case cc::DrawQuad::TEXTURE_CONTENT
:
459 draw_quad
= ReadDrawQuad
<cc::TextureDrawQuad
>(m
, iter
);
461 case cc::DrawQuad::RENDER_PASS
:
462 draw_quad
= ReadDrawQuad
<cc::RenderPassDrawQuad
>(m
, iter
);
464 case cc::DrawQuad::SOLID_COLOR
:
465 draw_quad
= ReadDrawQuad
<cc::SolidColorDrawQuad
>(m
, iter
);
467 case cc::DrawQuad::TILED_CONTENT
:
468 draw_quad
= ReadDrawQuad
<cc::TileDrawQuad
>(m
, iter
);
470 case cc::DrawQuad::STREAM_VIDEO_CONTENT
:
471 draw_quad
= ReadDrawQuad
<cc::StreamVideoDrawQuad
>(m
, iter
);
473 case cc::DrawQuad::YUV_VIDEO_CONTENT
:
474 draw_quad
= ReadDrawQuad
<cc::YUVVideoDrawQuad
>(m
, iter
);
476 case cc::DrawQuad::INVALID
:
481 if (!draw_quad
->rect
.Contains(draw_quad
->visible_rect
)) {
482 LOG(ERROR
) << "Quad with invalid visible rect " << draw_quad
->material
483 << " rect: " << draw_quad
->rect
.ToString()
484 << " visible_rect: " << draw_quad
->visible_rect
.ToString();
487 if (!draw_quad
->opaque_rect
.IsEmpty() &&
488 !draw_quad
->rect
.Contains(draw_quad
->opaque_rect
)) {
489 LOG(ERROR
) << "Quad with invalid opaque rect " << draw_quad
->material
490 << " rect: " << draw_quad
->rect
.ToString()
491 << " opaque_rect: " << draw_quad
->opaque_rect
.ToString();
495 size_t shared_quad_state_index
;
496 if (!ReadParam(m
, iter
, &shared_quad_state_index
))
498 if (shared_quad_state_index
>= shared_quad_state_list_size
)
500 // SharedQuadState indexes should be in ascending order.
501 if (last_shared_quad_state_index
!= kuint32max
&&
502 shared_quad_state_index
< last_shared_quad_state_index
)
505 // If the quad has a new shared quad state, read it in.
506 if (last_shared_quad_state_index
!= shared_quad_state_index
) {
507 cc::SharedQuadState
* state
= p
->CreateAndAppendSharedQuadState();
508 if (!ReadParam(m
, iter
, state
))
510 last_shared_quad_state_index
= shared_quad_state_index
;
513 draw_quad
->shared_quad_state
= p
->shared_quad_state_list
.back();
514 p
->quad_list
.push_back(draw_quad
.Pass());
520 void ParamTraits
<cc::RenderPass
>::Log(
521 const param_type
& p
, std::string
* l
) {
522 l
->append("RenderPass((");
525 LogParam(p
.output_rect
, l
);
527 LogParam(p
.damage_rect
, l
);
529 LogParam(p
.transform_to_root_target
, l
);
531 LogParam(p
.has_transparent_background
, l
);
535 for (size_t i
= 0; i
< p
.shared_quad_state_list
.size(); ++i
) {
538 LogParam(*p
.shared_quad_state_list
[i
], l
);
541 for (size_t i
= 0; i
< p
.quad_list
.size(); ++i
) {
544 const cc::DrawQuad
* quad
= p
.quad_list
[i
];
545 switch (quad
->material
) {
546 case cc::DrawQuad::CHECKERBOARD
:
547 LogParam(*cc::CheckerboardDrawQuad::MaterialCast(quad
), l
);
549 case cc::DrawQuad::DEBUG_BORDER
:
550 LogParam(*cc::DebugBorderDrawQuad::MaterialCast(quad
), l
);
552 case cc::DrawQuad::IO_SURFACE_CONTENT
:
553 LogParam(*cc::IOSurfaceDrawQuad::MaterialCast(quad
), l
);
555 case cc::DrawQuad::PICTURE_CONTENT
:
558 case cc::DrawQuad::TEXTURE_CONTENT
:
559 LogParam(*cc::TextureDrawQuad::MaterialCast(quad
), l
);
561 case cc::DrawQuad::RENDER_PASS
:
562 LogParam(*cc::RenderPassDrawQuad::MaterialCast(quad
), l
);
564 case cc::DrawQuad::SOLID_COLOR
:
565 LogParam(*cc::SolidColorDrawQuad::MaterialCast(quad
), l
);
567 case cc::DrawQuad::SURFACE_CONTENT
:
568 LogParam(*cc::SurfaceDrawQuad::MaterialCast(quad
), l
);
570 case cc::DrawQuad::TILED_CONTENT
:
571 LogParam(*cc::TileDrawQuad::MaterialCast(quad
), l
);
573 case cc::DrawQuad::STREAM_VIDEO_CONTENT
:
574 LogParam(*cc::StreamVideoDrawQuad::MaterialCast(quad
), l
);
576 case cc::DrawQuad::YUV_VIDEO_CONTENT
:
577 LogParam(*cc::YUVVideoDrawQuad::MaterialCast(quad
), l
);
579 case cc::DrawQuad::INVALID
:
587 enum CompositorFrameType
{
595 void ParamTraits
<cc::CompositorFrame
>::Write(Message
* m
,
596 const param_type
& p
) {
597 WriteParam(m
, p
.metadata
);
598 if (p
.delegated_frame_data
) {
599 DCHECK(!p
.gl_frame_data
);
600 DCHECK(!p
.software_frame_data
);
601 WriteParam(m
, static_cast<int>(DELEGATED_FRAME
));
602 WriteParam(m
, *p
.delegated_frame_data
);
603 } else if (p
.gl_frame_data
) {
604 DCHECK(!p
.software_frame_data
);
605 WriteParam(m
, static_cast<int>(GL_FRAME
));
606 WriteParam(m
, *p
.gl_frame_data
);
607 } else if (p
.software_frame_data
) {
608 WriteParam(m
, static_cast<int>(SOFTWARE_FRAME
));
609 WriteParam(m
, *p
.software_frame_data
);
611 WriteParam(m
, static_cast<int>(NO_FRAME
));
615 bool ParamTraits
<cc::CompositorFrame
>::Read(const Message
* m
,
616 PickleIterator
* iter
,
618 if (!ReadParam(m
, iter
, &p
->metadata
))
621 int compositor_frame_type
;
622 if (!ReadParam(m
, iter
, &compositor_frame_type
))
625 switch (compositor_frame_type
) {
626 case DELEGATED_FRAME
:
627 p
->delegated_frame_data
.reset(new cc::DelegatedFrameData());
628 if (!ReadParam(m
, iter
, p
->delegated_frame_data
.get()))
632 p
->gl_frame_data
.reset(new cc::GLFrameData());
633 if (!ReadParam(m
, iter
, p
->gl_frame_data
.get()))
637 p
->software_frame_data
.reset(new cc::SoftwareFrameData());
638 if (!ReadParam(m
, iter
, p
->software_frame_data
.get()))
649 void ParamTraits
<cc::CompositorFrame
>::Log(const param_type
& p
,
651 l
->append("CompositorFrame(");
652 LogParam(p
.metadata
, l
);
654 if (p
.delegated_frame_data
)
655 LogParam(*p
.delegated_frame_data
, l
);
656 else if (p
.gl_frame_data
)
657 LogParam(*p
.gl_frame_data
, l
);
658 else if (p
.software_frame_data
)
659 LogParam(*p
.software_frame_data
, l
);
663 void ParamTraits
<cc::CompositorFrameAck
>::Write(Message
* m
,
664 const param_type
& p
) {
665 WriteParam(m
, p
.resources
);
666 WriteParam(m
, p
.last_software_frame_id
);
667 if (p
.gl_frame_data
) {
668 WriteParam(m
, static_cast<int>(GL_FRAME
));
669 WriteParam(m
, *p
.gl_frame_data
);
671 WriteParam(m
, static_cast<int>(NO_FRAME
));
675 bool ParamTraits
<cc::CompositorFrameAck
>::Read(const Message
* m
,
676 PickleIterator
* iter
,
678 if (!ReadParam(m
, iter
, &p
->resources
))
681 if (!ReadParam(m
, iter
, &p
->last_software_frame_id
))
684 int compositor_frame_type
;
685 if (!ReadParam(m
, iter
, &compositor_frame_type
))
688 switch (compositor_frame_type
) {
692 p
->gl_frame_data
.reset(new cc::GLFrameData());
693 if (!ReadParam(m
, iter
, p
->gl_frame_data
.get()))
702 void ParamTraits
<cc::CompositorFrameAck
>::Log(const param_type
& p
,
704 l
->append("CompositorFrameAck(");
705 LogParam(p
.resources
, l
);
707 LogParam(p
.last_software_frame_id
, l
);
710 LogParam(*p
.gl_frame_data
, l
);
714 void ParamTraits
<cc::DelegatedFrameData
>::Write(Message
* m
,
715 const param_type
& p
) {
716 DCHECK_NE(0u, p
.render_pass_list
.size());
718 size_t to_reserve
= p
.resource_list
.size() * sizeof(cc::TransferableResource
);
719 for (size_t i
= 0; i
< p
.render_pass_list
.size(); ++i
) {
720 const cc::RenderPass
* pass
= p
.render_pass_list
[i
];
721 to_reserve
+= ReserveSizeForRenderPassWrite(*pass
);
723 m
->Reserve(to_reserve
);
725 WriteParam(m
, p
.resource_list
);
726 WriteParam(m
, p
.render_pass_list
.size());
727 for (size_t i
= 0; i
< p
.render_pass_list
.size(); ++i
)
728 WriteParam(m
, *p
.render_pass_list
[i
]);
731 bool ParamTraits
<cc::DelegatedFrameData
>::Read(const Message
* m
,
732 PickleIterator
* iter
,
734 const static size_t kMaxRenderPasses
= 10000;
736 size_t num_render_passes
;
737 if (!ReadParam(m
, iter
, &p
->resource_list
) ||
738 !ReadParam(m
, iter
, &num_render_passes
) ||
739 num_render_passes
> kMaxRenderPasses
|| num_render_passes
== 0)
741 for (size_t i
= 0; i
< num_render_passes
; ++i
) {
742 scoped_ptr
<cc::RenderPass
> render_pass
= cc::RenderPass::Create();
743 if (!ReadParam(m
, iter
, render_pass
.get()))
745 p
->render_pass_list
.push_back(render_pass
.Pass());
750 void ParamTraits
<cc::DelegatedFrameData
>::Log(const param_type
& p
,
752 l
->append("DelegatedFrameData(");
753 LogParam(p
.resource_list
, l
);
755 for (size_t i
= 0; i
< p
.render_pass_list
.size(); ++i
) {
758 LogParam(*p
.render_pass_list
[i
], l
);
763 void ParamTraits
<cc::SoftwareFrameData
>::Write(Message
* m
,
764 const param_type
& p
) {
765 DCHECK(cc::SharedBitmap::VerifySizeInBytes(p
.size
));
767 m
->Reserve(sizeof(cc::SoftwareFrameData
));
769 WriteParam(m
, p
.size
);
770 WriteParam(m
, p
.damage_rect
);
771 WriteParam(m
, p
.bitmap_id
);
774 bool ParamTraits
<cc::SoftwareFrameData
>::Read(const Message
* m
,
775 PickleIterator
* iter
,
777 if (!ReadParam(m
, iter
, &p
->id
))
779 if (!ReadParam(m
, iter
, &p
->size
) ||
780 !cc::SharedBitmap::VerifySizeInBytes(p
->size
))
782 if (!ReadParam(m
, iter
, &p
->damage_rect
))
784 if (!ReadParam(m
, iter
, &p
->bitmap_id
))
789 void ParamTraits
<cc::SoftwareFrameData
>::Log(const param_type
& p
,
791 l
->append("SoftwareFrameData(");
796 LogParam(p
.damage_rect
, l
);
798 LogParam(p
.bitmap_id
, l
);