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 "cc/output/filter_operations.h"
9 #include "content/public/common/common_param_traits.h"
10 #include "third_party/skia/include/core/SkData.h"
11 #include "third_party/skia/include/core/SkFlattenableSerialization.h"
12 #include "ui/gfx/transform.h"
16 void ParamTraits
<cc::FilterOperation
>::Write(
17 Message
* m
, const param_type
& p
) {
18 WriteParam(m
, p
.type());
20 case cc::FilterOperation::GRAYSCALE
:
21 case cc::FilterOperation::SEPIA
:
22 case cc::FilterOperation::SATURATE
:
23 case cc::FilterOperation::HUE_ROTATE
:
24 case cc::FilterOperation::INVERT
:
25 case cc::FilterOperation::BRIGHTNESS
:
26 case cc::FilterOperation::SATURATING_BRIGHTNESS
:
27 case cc::FilterOperation::CONTRAST
:
28 case cc::FilterOperation::OPACITY
:
29 case cc::FilterOperation::BLUR
:
30 WriteParam(m
, p
.amount());
32 case cc::FilterOperation::DROP_SHADOW
:
33 WriteParam(m
, p
.drop_shadow_offset());
34 WriteParam(m
, p
.amount());
35 WriteParam(m
, p
.drop_shadow_color());
37 case cc::FilterOperation::COLOR_MATRIX
:
38 for (int i
= 0; i
< 20; ++i
)
39 WriteParam(m
, p
.matrix()[i
]);
41 case cc::FilterOperation::ZOOM
:
42 WriteParam(m
, p
.amount());
43 WriteParam(m
, p
.zoom_inset());
45 case cc::FilterOperation::REFERENCE
:
46 WriteParam(m
, p
.image_filter());
48 case cc::FilterOperation::ALPHA_THRESHOLD
:
54 bool ParamTraits
<cc::FilterOperation
>::Read(
55 const Message
* m
, PickleIterator
* iter
, param_type
* r
) {
56 cc::FilterOperation::FilterType type
;
58 gfx::Point drop_shadow_offset
;
59 SkColor drop_shadow_color
;
63 if (!ReadParam(m
, iter
, &type
))
69 case cc::FilterOperation::GRAYSCALE
:
70 case cc::FilterOperation::SEPIA
:
71 case cc::FilterOperation::SATURATE
:
72 case cc::FilterOperation::HUE_ROTATE
:
73 case cc::FilterOperation::INVERT
:
74 case cc::FilterOperation::BRIGHTNESS
:
75 case cc::FilterOperation::SATURATING_BRIGHTNESS
:
76 case cc::FilterOperation::CONTRAST
:
77 case cc::FilterOperation::OPACITY
:
78 case cc::FilterOperation::BLUR
:
79 if (ReadParam(m
, iter
, &amount
)) {
80 r
->set_amount(amount
);
84 case cc::FilterOperation::DROP_SHADOW
:
85 if (ReadParam(m
, iter
, &drop_shadow_offset
) &&
86 ReadParam(m
, iter
, &amount
) &&
87 ReadParam(m
, iter
, &drop_shadow_color
)) {
88 r
->set_drop_shadow_offset(drop_shadow_offset
);
89 r
->set_amount(amount
);
90 r
->set_drop_shadow_color(drop_shadow_color
);
94 case cc::FilterOperation::COLOR_MATRIX
: {
96 for (i
= 0; i
< 20; ++i
) {
97 if (!ReadParam(m
, iter
, &matrix
[i
]))
101 r
->set_matrix(matrix
);
106 case cc::FilterOperation::ZOOM
:
107 if (ReadParam(m
, iter
, &amount
) &&
108 ReadParam(m
, iter
, &zoom_inset
) &&
111 r
->set_amount(amount
);
112 r
->set_zoom_inset(zoom_inset
);
116 case cc::FilterOperation::REFERENCE
: {
117 skia::RefPtr
<SkImageFilter
> filter
;
118 if (!ReadParam(m
, iter
, &filter
)) {
122 r
->set_image_filter(filter
);
126 case cc::FilterOperation::ALPHA_THRESHOLD
:
132 void ParamTraits
<cc::FilterOperation
>::Log(
133 const param_type
& p
, std::string
* l
) {
135 LogParam(static_cast<unsigned>(p
.type()), l
);
139 case cc::FilterOperation::GRAYSCALE
:
140 case cc::FilterOperation::SEPIA
:
141 case cc::FilterOperation::SATURATE
:
142 case cc::FilterOperation::HUE_ROTATE
:
143 case cc::FilterOperation::INVERT
:
144 case cc::FilterOperation::BRIGHTNESS
:
145 case cc::FilterOperation::SATURATING_BRIGHTNESS
:
146 case cc::FilterOperation::CONTRAST
:
147 case cc::FilterOperation::OPACITY
:
148 case cc::FilterOperation::BLUR
:
149 LogParam(p
.amount(), l
);
151 case cc::FilterOperation::DROP_SHADOW
:
152 LogParam(p
.drop_shadow_offset(), l
);
154 LogParam(p
.amount(), l
);
156 LogParam(p
.drop_shadow_color(), l
);
158 case cc::FilterOperation::COLOR_MATRIX
:
159 for (int i
= 0; i
< 20; ++i
) {
162 LogParam(p
.matrix()[i
], l
);
165 case cc::FilterOperation::ZOOM
:
166 LogParam(p
.amount(), l
);
168 LogParam(p
.zoom_inset(), l
);
170 case cc::FilterOperation::REFERENCE
:
171 LogParam(p
.image_filter(), l
);
173 case cc::FilterOperation::ALPHA_THRESHOLD
:
180 void ParamTraits
<cc::FilterOperations
>::Write(
181 Message
* m
, const param_type
& p
) {
182 WriteParam(m
, p
.size());
183 for (std::size_t i
= 0; i
< p
.size(); ++i
) {
184 WriteParam(m
, p
.at(i
));
188 bool ParamTraits
<cc::FilterOperations
>::Read(
189 const Message
* m
, PickleIterator
* iter
, param_type
* r
) {
191 if (!ReadParam(m
, iter
, &count
))
194 for (std::size_t i
= 0; i
< count
; ++i
) {
195 cc::FilterOperation op
= cc::FilterOperation::CreateEmptyFilter();
196 if (!ReadParam(m
, iter
, &op
))
203 void ParamTraits
<cc::FilterOperations
>::Log(
204 const param_type
& p
, std::string
* l
) {
206 for (std::size_t i
= 0; i
< p
.size(); ++i
) {
209 LogParam(p
.at(i
), l
);
214 void ParamTraits
<skia::RefPtr
<SkImageFilter
> >::Write(
215 Message
* m
, const param_type
& p
) {
216 SkImageFilter
* filter
= p
.get();
218 skia::RefPtr
<SkData
> data
=
219 skia::AdoptRef(SkValidatingSerializeFlattenable(filter
));
220 m
->WriteData(static_cast<const char*>(data
->data()), data
->size());
226 bool ParamTraits
<skia::RefPtr
<SkImageFilter
> >::Read(
227 const Message
* m
, PickleIterator
* iter
, param_type
* r
) {
228 const char* data
= 0;
230 if (!m
->ReadData(iter
, &data
, &length
))
233 SkFlattenable
* flattenable
= SkValidatingDeserializeFlattenable(
234 data
, length
, SkImageFilter::GetFlattenableType());
235 *r
= skia::AdoptRef(static_cast<SkImageFilter
*>(flattenable
));
242 void ParamTraits
<skia::RefPtr
<SkImageFilter
> >::Log(
243 const param_type
& p
, std::string
* l
) {
245 LogParam(p
.get() ? p
->countInputs() : 0, l
);
249 void ParamTraits
<gfx::Transform
>::Write(
250 Message
* m
, const param_type
& p
) {
251 #ifdef SK_MSCALAR_IS_FLOAT
252 float column_major_data
[16];
253 p
.matrix().asColMajorf(column_major_data
);
255 double column_major_data
[16];
256 p
.matrix().asColMajord(column_major_data
);
258 m
->WriteBytes(&column_major_data
, sizeof(SkMScalar
) * 16);
261 bool ParamTraits
<gfx::Transform
>::Read(
262 const Message
* m
, PickleIterator
* iter
, param_type
* r
) {
263 const char* column_major_data
;
264 if (!m
->ReadBytes(iter
, &column_major_data
, sizeof(SkMScalar
) * 16))
266 r
->matrix().setColMajor(
267 reinterpret_cast<const SkMScalar
*>(column_major_data
));
271 void ParamTraits
<gfx::Transform
>::Log(
272 const param_type
& p
, std::string
* l
) {
273 #ifdef SK_MSCALAR_IS_FLOAT
274 float row_major_data
[16];
275 p
.matrix().asRowMajorf(row_major_data
);
277 double row_major_data
[16];
278 p
.matrix().asRowMajord(row_major_data
);
281 for (int i
= 0; i
< 16; ++i
) {
284 LogParam(row_major_data
[i
], l
);
289 void ParamTraits
<cc::RenderPass
>::Write(
290 Message
* m
, const param_type
& p
) {
292 WriteParam(m
, p
.output_rect
);
293 WriteParam(m
, p
.damage_rect
);
294 WriteParam(m
, p
.transform_to_root_target
);
295 WriteParam(m
, p
.has_transparent_background
);
296 WriteParam(m
, p
.shared_quad_state_list
.size());
297 WriteParam(m
, p
.quad_list
.size());
299 size_t shared_quad_state_index
= 0;
300 size_t last_shared_quad_state_index
= kuint32max
;
301 for (size_t i
= 0; i
< p
.quad_list
.size(); ++i
) {
302 const cc::DrawQuad
* quad
= p
.quad_list
[i
];
303 DCHECK(quad
->rect
.Contains(quad
->visible_rect
))
304 << quad
->material
<< " rect: " << quad
->rect
.ToString()
305 << " visible_rect: " << quad
->visible_rect
.ToString();
306 DCHECK(quad
->opaque_rect
.IsEmpty() ||
307 quad
->rect
.Contains(quad
->opaque_rect
))
308 << quad
->material
<< " rect: " << quad
->rect
.ToString()
309 << " opaque_rect: " << quad
->opaque_rect
.ToString();
311 switch (quad
->material
) {
312 case cc::DrawQuad::CHECKERBOARD
:
313 WriteParam(m
, *cc::CheckerboardDrawQuad::MaterialCast(quad
));
315 case cc::DrawQuad::DEBUG_BORDER
:
316 WriteParam(m
, *cc::DebugBorderDrawQuad::MaterialCast(quad
));
318 case cc::DrawQuad::IO_SURFACE_CONTENT
:
319 WriteParam(m
, *cc::IOSurfaceDrawQuad::MaterialCast(quad
));
321 case cc::DrawQuad::PICTURE_CONTENT
:
324 case cc::DrawQuad::TEXTURE_CONTENT
:
325 WriteParam(m
, *cc::TextureDrawQuad::MaterialCast(quad
));
327 case cc::DrawQuad::RENDER_PASS
:
328 WriteParam(m
, *cc::RenderPassDrawQuad::MaterialCast(quad
));
330 case cc::DrawQuad::SOLID_COLOR
:
331 WriteParam(m
, *cc::SolidColorDrawQuad::MaterialCast(quad
));
333 case cc::DrawQuad::SURFACE_CONTENT
:
334 WriteParam(m
, *cc::SurfaceDrawQuad::MaterialCast(quad
));
336 case cc::DrawQuad::TILED_CONTENT
:
337 WriteParam(m
, *cc::TileDrawQuad::MaterialCast(quad
));
339 case cc::DrawQuad::STREAM_VIDEO_CONTENT
:
340 WriteParam(m
, *cc::StreamVideoDrawQuad::MaterialCast(quad
));
342 case cc::DrawQuad::YUV_VIDEO_CONTENT
:
343 WriteParam(m
, *cc::YUVVideoDrawQuad::MaterialCast(quad
));
345 case cc::DrawQuad::INVALID
:
349 const cc::ScopedPtrVector
<cc::SharedQuadState
>& sqs_list
=
350 p
.shared_quad_state_list
;
352 // This is an invalid index.
353 size_t bad_index
= sqs_list
.size();
355 // Null shared quad states should not occur.
356 DCHECK(quad
->shared_quad_state
);
357 if (!quad
->shared_quad_state
) {
358 WriteParam(m
, bad_index
);
362 // SharedQuadStates should appear in the order they are used by DrawQuads.
363 // Find the SharedQuadState for this DrawQuad.
364 while (shared_quad_state_index
< sqs_list
.size() &&
365 quad
->shared_quad_state
!= sqs_list
[shared_quad_state_index
])
366 ++shared_quad_state_index
;
368 DCHECK_LT(shared_quad_state_index
, sqs_list
.size());
369 if (shared_quad_state_index
>= sqs_list
.size()) {
370 WriteParam(m
, bad_index
);
374 WriteParam(m
, shared_quad_state_index
);
375 if (shared_quad_state_index
!= last_shared_quad_state_index
) {
376 WriteParam(m
, *sqs_list
[shared_quad_state_index
]);
377 last_shared_quad_state_index
= shared_quad_state_index
;
382 static size_t ReserveSizeForRenderPassWrite(const cc::RenderPass
& p
) {
383 size_t to_reserve
= sizeof(cc::RenderPass
);
385 to_reserve
+= p
.shared_quad_state_list
.size() * sizeof(cc::SharedQuadState
);
387 // The shared_quad_state_index for each quad.
388 to_reserve
+= p
.quad_list
.size() * sizeof(size_t);
390 // The largest quad type, verified by a unit test.
391 to_reserve
+= p
.quad_list
.size() * sizeof(cc::RenderPassDrawQuad
);
395 template<typename QuadType
>
396 static scoped_ptr
<cc::DrawQuad
> ReadDrawQuad(const Message
* m
,
397 PickleIterator
* iter
) {
398 scoped_ptr
<QuadType
> quad(new QuadType
);
399 if (!ReadParam(m
, iter
, quad
.get()))
400 return scoped_ptr
<QuadType
>().template PassAs
<cc::DrawQuad
>();
401 return quad
.template PassAs
<cc::DrawQuad
>();
404 bool ParamTraits
<cc::RenderPass
>::Read(
405 const Message
* m
, PickleIterator
* iter
, param_type
* p
) {
406 cc::RenderPass::Id
id(-1, -1);
407 gfx::Rect output_rect
;
408 gfx::Rect damage_rect
;
409 gfx::Transform transform_to_root_target
;
410 bool has_transparent_background
;
411 size_t shared_quad_state_list_size
;
412 size_t quad_list_size
;
414 if (!ReadParam(m
, iter
, &id
) ||
415 !ReadParam(m
, iter
, &output_rect
) ||
416 !ReadParam(m
, iter
, &damage_rect
) ||
417 !ReadParam(m
, iter
, &transform_to_root_target
) ||
418 !ReadParam(m
, iter
, &has_transparent_background
) ||
419 !ReadParam(m
, iter
, &shared_quad_state_list_size
) ||
420 !ReadParam(m
, iter
, &quad_list_size
))
426 transform_to_root_target
,
427 has_transparent_background
);
429 size_t last_shared_quad_state_index
= kuint32max
;
430 for (size_t i
= 0; i
< quad_list_size
; ++i
) {
431 cc::DrawQuad::Material material
;
432 PickleIterator temp_iter
= *iter
;
433 if (!ReadParam(m
, &temp_iter
, &material
))
436 scoped_ptr
<cc::DrawQuad
> draw_quad
;
438 case cc::DrawQuad::CHECKERBOARD
:
439 draw_quad
= ReadDrawQuad
<cc::CheckerboardDrawQuad
>(m
, iter
);
441 case cc::DrawQuad::DEBUG_BORDER
:
442 draw_quad
= ReadDrawQuad
<cc::DebugBorderDrawQuad
>(m
, iter
);
444 case cc::DrawQuad::IO_SURFACE_CONTENT
:
445 draw_quad
= ReadDrawQuad
<cc::IOSurfaceDrawQuad
>(m
, iter
);
447 case cc::DrawQuad::PICTURE_CONTENT
:
450 case cc::DrawQuad::SURFACE_CONTENT
:
451 draw_quad
= ReadDrawQuad
<cc::SurfaceDrawQuad
>(m
, iter
);
453 case cc::DrawQuad::TEXTURE_CONTENT
:
454 draw_quad
= ReadDrawQuad
<cc::TextureDrawQuad
>(m
, iter
);
456 case cc::DrawQuad::RENDER_PASS
:
457 draw_quad
= ReadDrawQuad
<cc::RenderPassDrawQuad
>(m
, iter
);
459 case cc::DrawQuad::SOLID_COLOR
:
460 draw_quad
= ReadDrawQuad
<cc::SolidColorDrawQuad
>(m
, iter
);
462 case cc::DrawQuad::TILED_CONTENT
:
463 draw_quad
= ReadDrawQuad
<cc::TileDrawQuad
>(m
, iter
);
465 case cc::DrawQuad::STREAM_VIDEO_CONTENT
:
466 draw_quad
= ReadDrawQuad
<cc::StreamVideoDrawQuad
>(m
, iter
);
468 case cc::DrawQuad::YUV_VIDEO_CONTENT
:
469 draw_quad
= ReadDrawQuad
<cc::YUVVideoDrawQuad
>(m
, iter
);
471 case cc::DrawQuad::INVALID
:
476 if (!draw_quad
->rect
.Contains(draw_quad
->visible_rect
)) {
477 LOG(ERROR
) << "Quad with invalid visible rect " << draw_quad
->material
478 << " rect: " << draw_quad
->rect
.ToString()
479 << " visible_rect: " << draw_quad
->visible_rect
.ToString();
482 if (!draw_quad
->opaque_rect
.IsEmpty() &&
483 !draw_quad
->rect
.Contains(draw_quad
->opaque_rect
)) {
484 LOG(ERROR
) << "Quad with invalid opaque rect " << draw_quad
->material
485 << " rect: " << draw_quad
->rect
.ToString()
486 << " opaque_rect: " << draw_quad
->opaque_rect
.ToString();
490 size_t shared_quad_state_index
;
491 if (!ReadParam(m
, iter
, &shared_quad_state_index
))
493 if (shared_quad_state_index
>= shared_quad_state_list_size
)
495 // SharedQuadState indexes should be in ascending order.
496 if (last_shared_quad_state_index
!= kuint32max
&&
497 shared_quad_state_index
< last_shared_quad_state_index
)
500 // If the quad has a new shared quad state, read it in.
501 if (last_shared_quad_state_index
!= shared_quad_state_index
) {
502 cc::SharedQuadState
* state
= p
->CreateAndAppendSharedQuadState();
503 if (!ReadParam(m
, iter
, state
))
505 last_shared_quad_state_index
= shared_quad_state_index
;
508 draw_quad
->shared_quad_state
= p
->shared_quad_state_list
.back();
509 p
->quad_list
.push_back(draw_quad
.Pass());
515 void ParamTraits
<cc::RenderPass
>::Log(
516 const param_type
& p
, std::string
* l
) {
517 l
->append("RenderPass((");
520 LogParam(p
.output_rect
, l
);
522 LogParam(p
.damage_rect
, l
);
524 LogParam(p
.transform_to_root_target
, l
);
526 LogParam(p
.has_transparent_background
, l
);
530 for (size_t i
= 0; i
< p
.shared_quad_state_list
.size(); ++i
) {
533 LogParam(*p
.shared_quad_state_list
[i
], l
);
536 for (size_t i
= 0; i
< p
.quad_list
.size(); ++i
) {
539 const cc::DrawQuad
* quad
= p
.quad_list
[i
];
540 switch (quad
->material
) {
541 case cc::DrawQuad::CHECKERBOARD
:
542 LogParam(*cc::CheckerboardDrawQuad::MaterialCast(quad
), l
);
544 case cc::DrawQuad::DEBUG_BORDER
:
545 LogParam(*cc::DebugBorderDrawQuad::MaterialCast(quad
), l
);
547 case cc::DrawQuad::IO_SURFACE_CONTENT
:
548 LogParam(*cc::IOSurfaceDrawQuad::MaterialCast(quad
), l
);
550 case cc::DrawQuad::PICTURE_CONTENT
:
553 case cc::DrawQuad::TEXTURE_CONTENT
:
554 LogParam(*cc::TextureDrawQuad::MaterialCast(quad
), l
);
556 case cc::DrawQuad::RENDER_PASS
:
557 LogParam(*cc::RenderPassDrawQuad::MaterialCast(quad
), l
);
559 case cc::DrawQuad::SOLID_COLOR
:
560 LogParam(*cc::SolidColorDrawQuad::MaterialCast(quad
), l
);
562 case cc::DrawQuad::SURFACE_CONTENT
:
563 LogParam(*cc::SurfaceDrawQuad::MaterialCast(quad
), l
);
565 case cc::DrawQuad::TILED_CONTENT
:
566 LogParam(*cc::TileDrawQuad::MaterialCast(quad
), l
);
568 case cc::DrawQuad::STREAM_VIDEO_CONTENT
:
569 LogParam(*cc::StreamVideoDrawQuad::MaterialCast(quad
), l
);
571 case cc::DrawQuad::YUV_VIDEO_CONTENT
:
572 LogParam(*cc::YUVVideoDrawQuad::MaterialCast(quad
), l
);
574 case cc::DrawQuad::INVALID
:
582 enum CompositorFrameType
{
590 void ParamTraits
<cc::CompositorFrame
>::Write(Message
* m
,
591 const param_type
& p
) {
592 WriteParam(m
, p
.metadata
);
593 if (p
.delegated_frame_data
) {
594 DCHECK(!p
.gl_frame_data
);
595 DCHECK(!p
.software_frame_data
);
596 WriteParam(m
, static_cast<int>(DELEGATED_FRAME
));
597 WriteParam(m
, *p
.delegated_frame_data
);
598 } else if (p
.gl_frame_data
) {
599 DCHECK(!p
.software_frame_data
);
600 WriteParam(m
, static_cast<int>(GL_FRAME
));
601 WriteParam(m
, *p
.gl_frame_data
);
602 } else if (p
.software_frame_data
) {
603 WriteParam(m
, static_cast<int>(SOFTWARE_FRAME
));
604 WriteParam(m
, *p
.software_frame_data
);
606 WriteParam(m
, static_cast<int>(NO_FRAME
));
610 bool ParamTraits
<cc::CompositorFrame
>::Read(const Message
* m
,
611 PickleIterator
* iter
,
613 if (!ReadParam(m
, iter
, &p
->metadata
))
616 int compositor_frame_type
;
617 if (!ReadParam(m
, iter
, &compositor_frame_type
))
620 switch (compositor_frame_type
) {
621 case DELEGATED_FRAME
:
622 p
->delegated_frame_data
.reset(new cc::DelegatedFrameData());
623 if (!ReadParam(m
, iter
, p
->delegated_frame_data
.get()))
627 p
->gl_frame_data
.reset(new cc::GLFrameData());
628 if (!ReadParam(m
, iter
, p
->gl_frame_data
.get()))
632 p
->software_frame_data
.reset(new cc::SoftwareFrameData());
633 if (!ReadParam(m
, iter
, p
->software_frame_data
.get()))
644 void ParamTraits
<cc::CompositorFrame
>::Log(const param_type
& p
,
646 l
->append("CompositorFrame(");
647 LogParam(p
.metadata
, l
);
649 if (p
.delegated_frame_data
)
650 LogParam(*p
.delegated_frame_data
, l
);
651 else if (p
.gl_frame_data
)
652 LogParam(*p
.gl_frame_data
, l
);
653 else if (p
.software_frame_data
)
654 LogParam(*p
.software_frame_data
, l
);
658 void ParamTraits
<cc::CompositorFrameAck
>::Write(Message
* m
,
659 const param_type
& p
) {
660 WriteParam(m
, p
.resources
);
661 WriteParam(m
, p
.last_software_frame_id
);
662 if (p
.gl_frame_data
) {
663 WriteParam(m
, static_cast<int>(GL_FRAME
));
664 WriteParam(m
, *p
.gl_frame_data
);
666 WriteParam(m
, static_cast<int>(NO_FRAME
));
670 bool ParamTraits
<cc::CompositorFrameAck
>::Read(const Message
* m
,
671 PickleIterator
* iter
,
673 if (!ReadParam(m
, iter
, &p
->resources
))
676 if (!ReadParam(m
, iter
, &p
->last_software_frame_id
))
679 int compositor_frame_type
;
680 if (!ReadParam(m
, iter
, &compositor_frame_type
))
683 switch (compositor_frame_type
) {
687 p
->gl_frame_data
.reset(new cc::GLFrameData());
688 if (!ReadParam(m
, iter
, p
->gl_frame_data
.get()))
697 void ParamTraits
<cc::CompositorFrameAck
>::Log(const param_type
& p
,
699 l
->append("CompositorFrameAck(");
700 LogParam(p
.resources
, l
);
702 LogParam(p
.last_software_frame_id
, l
);
705 LogParam(*p
.gl_frame_data
, l
);
709 void ParamTraits
<cc::DelegatedFrameData
>::Write(Message
* m
,
710 const param_type
& p
) {
711 DCHECK_NE(0u, p
.render_pass_list
.size());
713 size_t to_reserve
= sizeof(p
.device_scale_factor
);
714 to_reserve
+= p
.resource_list
.size() * sizeof(cc::TransferableResource
);
715 for (size_t i
= 0; i
< p
.render_pass_list
.size(); ++i
) {
716 const cc::RenderPass
* pass
= p
.render_pass_list
[i
];
717 to_reserve
+= ReserveSizeForRenderPassWrite(*pass
);
719 m
->Reserve(to_reserve
);
721 WriteParam(m
, p
.device_scale_factor
);
722 WriteParam(m
, p
.resource_list
);
723 WriteParam(m
, p
.render_pass_list
.size());
724 for (size_t i
= 0; i
< p
.render_pass_list
.size(); ++i
)
725 WriteParam(m
, *p
.render_pass_list
[i
]);
728 bool ParamTraits
<cc::DelegatedFrameData
>::Read(const Message
* m
,
729 PickleIterator
* iter
,
731 if (!ReadParam(m
, iter
, &p
->device_scale_factor
))
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
.device_scale_factor
, l
);
754 LogParam(p
.resource_list
, l
);
756 for (size_t i
= 0; i
< p
.render_pass_list
.size(); ++i
) {
759 LogParam(*p
.render_pass_list
[i
], l
);
764 void ParamTraits
<cc::SoftwareFrameData
>::Write(Message
* m
,
765 const param_type
& p
) {
766 DCHECK(cc::SharedBitmap::VerifySizeInBytes(p
.size
));
768 m
->Reserve(sizeof(cc::SoftwareFrameData
));
770 WriteParam(m
, p
.size
);
771 WriteParam(m
, p
.damage_rect
);
772 WriteParam(m
, p
.bitmap_id
);
775 bool ParamTraits
<cc::SoftwareFrameData
>::Read(const Message
* m
,
776 PickleIterator
* iter
,
778 if (!ReadParam(m
, iter
, &p
->id
))
780 if (!ReadParam(m
, iter
, &p
->size
) ||
781 !cc::SharedBitmap::VerifySizeInBytes(p
->size
))
783 if (!ReadParam(m
, iter
, &p
->damage_rect
))
785 if (!ReadParam(m
, iter
, &p
->bitmap_id
))
790 void ParamTraits
<cc::SoftwareFrameData
>::Log(const param_type
& p
,
792 l
->append("SoftwareFrameData(");
797 LogParam(p
.damage_rect
, l
);
799 LogParam(p
.bitmap_id
, l
);