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 "cc/quads/largest_draw_quad.h"
10 #include "content/public/common/common_param_traits.h"
11 #include "third_party/skia/include/core/SkData.h"
12 #include "third_party/skia/include/core/SkFlattenableSerialization.h"
13 #include "ui/gfx/transform.h"
17 void ParamTraits
<cc::FilterOperation
>::Write(
18 Message
* m
, const param_type
& p
) {
19 WriteParam(m
, p
.type());
21 case cc::FilterOperation::GRAYSCALE
:
22 case cc::FilterOperation::SEPIA
:
23 case cc::FilterOperation::SATURATE
:
24 case cc::FilterOperation::HUE_ROTATE
:
25 case cc::FilterOperation::INVERT
:
26 case cc::FilterOperation::BRIGHTNESS
:
27 case cc::FilterOperation::SATURATING_BRIGHTNESS
:
28 case cc::FilterOperation::CONTRAST
:
29 case cc::FilterOperation::OPACITY
:
30 case cc::FilterOperation::BLUR
:
31 WriteParam(m
, p
.amount());
33 case cc::FilterOperation::DROP_SHADOW
:
34 WriteParam(m
, p
.drop_shadow_offset());
35 WriteParam(m
, p
.amount());
36 WriteParam(m
, p
.drop_shadow_color());
38 case cc::FilterOperation::COLOR_MATRIX
:
39 for (int i
= 0; i
< 20; ++i
)
40 WriteParam(m
, p
.matrix()[i
]);
42 case cc::FilterOperation::ZOOM
:
43 WriteParam(m
, p
.amount());
44 WriteParam(m
, p
.zoom_inset());
46 case cc::FilterOperation::REFERENCE
:
47 WriteParam(m
, p
.image_filter());
49 case cc::FilterOperation::ALPHA_THRESHOLD
:
55 bool ParamTraits
<cc::FilterOperation
>::Read(
56 const Message
* m
, PickleIterator
* iter
, param_type
* r
) {
57 cc::FilterOperation::FilterType type
;
59 gfx::Point drop_shadow_offset
;
60 SkColor drop_shadow_color
;
64 if (!ReadParam(m
, iter
, &type
))
70 case cc::FilterOperation::GRAYSCALE
:
71 case cc::FilterOperation::SEPIA
:
72 case cc::FilterOperation::SATURATE
:
73 case cc::FilterOperation::HUE_ROTATE
:
74 case cc::FilterOperation::INVERT
:
75 case cc::FilterOperation::BRIGHTNESS
:
76 case cc::FilterOperation::SATURATING_BRIGHTNESS
:
77 case cc::FilterOperation::CONTRAST
:
78 case cc::FilterOperation::OPACITY
:
79 case cc::FilterOperation::BLUR
:
80 if (ReadParam(m
, iter
, &amount
)) {
81 r
->set_amount(amount
);
85 case cc::FilterOperation::DROP_SHADOW
:
86 if (ReadParam(m
, iter
, &drop_shadow_offset
) &&
87 ReadParam(m
, iter
, &amount
) &&
88 ReadParam(m
, iter
, &drop_shadow_color
)) {
89 r
->set_drop_shadow_offset(drop_shadow_offset
);
90 r
->set_amount(amount
);
91 r
->set_drop_shadow_color(drop_shadow_color
);
95 case cc::FilterOperation::COLOR_MATRIX
: {
97 for (i
= 0; i
< 20; ++i
) {
98 if (!ReadParam(m
, iter
, &matrix
[i
]))
102 r
->set_matrix(matrix
);
107 case cc::FilterOperation::ZOOM
:
108 if (ReadParam(m
, iter
, &amount
) &&
109 ReadParam(m
, iter
, &zoom_inset
) &&
112 r
->set_amount(amount
);
113 r
->set_zoom_inset(zoom_inset
);
117 case cc::FilterOperation::REFERENCE
: {
118 skia::RefPtr
<SkImageFilter
> filter
;
119 if (!ReadParam(m
, iter
, &filter
)) {
123 r
->set_image_filter(filter
);
127 case cc::FilterOperation::ALPHA_THRESHOLD
:
133 void ParamTraits
<cc::FilterOperation
>::Log(
134 const param_type
& p
, std::string
* l
) {
136 LogParam(static_cast<unsigned>(p
.type()), l
);
140 case cc::FilterOperation::GRAYSCALE
:
141 case cc::FilterOperation::SEPIA
:
142 case cc::FilterOperation::SATURATE
:
143 case cc::FilterOperation::HUE_ROTATE
:
144 case cc::FilterOperation::INVERT
:
145 case cc::FilterOperation::BRIGHTNESS
:
146 case cc::FilterOperation::SATURATING_BRIGHTNESS
:
147 case cc::FilterOperation::CONTRAST
:
148 case cc::FilterOperation::OPACITY
:
149 case cc::FilterOperation::BLUR
:
150 LogParam(p
.amount(), l
);
152 case cc::FilterOperation::DROP_SHADOW
:
153 LogParam(p
.drop_shadow_offset(), l
);
155 LogParam(p
.amount(), l
);
157 LogParam(p
.drop_shadow_color(), l
);
159 case cc::FilterOperation::COLOR_MATRIX
:
160 for (int i
= 0; i
< 20; ++i
) {
163 LogParam(p
.matrix()[i
], l
);
166 case cc::FilterOperation::ZOOM
:
167 LogParam(p
.amount(), l
);
169 LogParam(p
.zoom_inset(), l
);
171 case cc::FilterOperation::REFERENCE
:
172 LogParam(p
.image_filter(), l
);
174 case cc::FilterOperation::ALPHA_THRESHOLD
:
181 void ParamTraits
<cc::FilterOperations
>::Write(
182 Message
* m
, const param_type
& p
) {
183 WriteParam(m
, p
.size());
184 for (std::size_t i
= 0; i
< p
.size(); ++i
) {
185 WriteParam(m
, p
.at(i
));
189 bool ParamTraits
<cc::FilterOperations
>::Read(
190 const Message
* m
, PickleIterator
* iter
, param_type
* r
) {
192 if (!ReadParam(m
, iter
, &count
))
195 for (std::size_t i
= 0; i
< count
; ++i
) {
196 cc::FilterOperation op
= cc::FilterOperation::CreateEmptyFilter();
197 if (!ReadParam(m
, iter
, &op
))
204 void ParamTraits
<cc::FilterOperations
>::Log(
205 const param_type
& p
, std::string
* l
) {
207 for (std::size_t i
= 0; i
< p
.size(); ++i
) {
210 LogParam(p
.at(i
), l
);
215 void ParamTraits
<skia::RefPtr
<SkImageFilter
> >::Write(
216 Message
* m
, const param_type
& p
) {
217 SkImageFilter
* filter
= p
.get();
219 skia::RefPtr
<SkData
> data
=
220 skia::AdoptRef(SkValidatingSerializeFlattenable(filter
));
221 m
->WriteData(static_cast<const char*>(data
->data()), data
->size());
227 bool ParamTraits
<skia::RefPtr
<SkImageFilter
> >::Read(
228 const Message
* m
, PickleIterator
* iter
, param_type
* r
) {
229 const char* data
= 0;
231 if (!m
->ReadData(iter
, &data
, &length
))
234 SkFlattenable
* flattenable
= SkValidatingDeserializeFlattenable(
235 data
, length
, SkImageFilter::GetFlattenableType());
236 *r
= skia::AdoptRef(static_cast<SkImageFilter
*>(flattenable
));
243 void ParamTraits
<skia::RefPtr
<SkImageFilter
> >::Log(
244 const param_type
& p
, std::string
* l
) {
246 LogParam(p
.get() ? p
->countInputs() : 0, l
);
250 void ParamTraits
<gfx::Transform
>::Write(
251 Message
* m
, const param_type
& p
) {
252 #ifdef SK_MSCALAR_IS_FLOAT
253 float column_major_data
[16];
254 p
.matrix().asColMajorf(column_major_data
);
256 double column_major_data
[16];
257 p
.matrix().asColMajord(column_major_data
);
259 m
->WriteBytes(&column_major_data
, sizeof(SkMScalar
) * 16);
262 bool ParamTraits
<gfx::Transform
>::Read(
263 const Message
* m
, PickleIterator
* iter
, param_type
* r
) {
264 const char* column_major_data
;
265 if (!m
->ReadBytes(iter
, &column_major_data
, sizeof(SkMScalar
) * 16))
267 r
->matrix().setColMajor(
268 reinterpret_cast<const SkMScalar
*>(column_major_data
));
272 void ParamTraits
<gfx::Transform
>::Log(
273 const param_type
& p
, std::string
* l
) {
274 #ifdef SK_MSCALAR_IS_FLOAT
275 float row_major_data
[16];
276 p
.matrix().asRowMajorf(row_major_data
);
278 double row_major_data
[16];
279 p
.matrix().asRowMajord(row_major_data
);
282 for (int i
= 0; i
< 16; ++i
) {
285 LogParam(row_major_data
[i
], l
);
290 void ParamTraits
<cc::RenderPass
>::Write(
291 Message
* m
, const param_type
& p
) {
293 WriteParam(m
, p
.output_rect
);
294 WriteParam(m
, p
.damage_rect
);
295 WriteParam(m
, p
.transform_to_root_target
);
296 WriteParam(m
, p
.has_transparent_background
);
297 WriteParam(m
, p
.quad_list
.size());
299 cc::SharedQuadStateList::ConstIterator shared_quad_state_iter
=
300 p
.shared_quad_state_list
.begin();
301 cc::SharedQuadStateList::ConstIterator last_shared_quad_state_iter
=
302 p
.shared_quad_state_list
.end();
303 for (const auto& quad
: p
.quad_list
) {
304 DCHECK(quad
.rect
.Contains(quad
.visible_rect
))
305 << quad
.material
<< " rect: " << quad
.rect
.ToString()
306 << " visible_rect: " << quad
.visible_rect
.ToString();
307 DCHECK(quad
.opaque_rect
.IsEmpty() || 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 // Null shared quad states should not occur.
350 DCHECK(quad
.shared_quad_state
);
352 // SharedQuadStates should appear in the order they are used by DrawQuads.
353 // Find the SharedQuadState for this DrawQuad.
354 while (shared_quad_state_iter
!= p
.shared_quad_state_list
.end() &&
355 quad
.shared_quad_state
!= &*shared_quad_state_iter
)
356 ++shared_quad_state_iter
;
358 DCHECK(shared_quad_state_iter
!= p
.shared_quad_state_list
.end());
360 if (shared_quad_state_iter
!= last_shared_quad_state_iter
) {
362 WriteParam(m
, *shared_quad_state_iter
);
363 last_shared_quad_state_iter
= shared_quad_state_iter
;
365 WriteParam(m
, false);
370 static size_t ReserveSizeForRenderPassWrite(const cc::RenderPass
& p
) {
371 size_t to_reserve
= sizeof(cc::RenderPass
);
373 // Whether the quad points to a new shared quad state for each quad.
374 to_reserve
+= p
.quad_list
.size() * sizeof(bool);
376 // Shared quad state is only written when a quad contains a shared quad state
377 // that has not been written.
378 to_reserve
+= p
.shared_quad_state_list
.size() * sizeof(cc::SharedQuadState
);
380 // The largest quad type, verified by a unit test.
381 to_reserve
+= p
.quad_list
.size() * sizeof(cc::kLargestDrawQuad
);
385 template <typename QuadType
>
386 static cc::DrawQuad
* ReadDrawQuad(const Message
* m
,
387 PickleIterator
* iter
,
388 cc::RenderPass
* render_pass
) {
389 QuadType
* quad
= render_pass
->CreateAndAppendDrawQuad
<QuadType
>();
390 if (!ReadParam(m
, iter
, quad
))
395 bool ParamTraits
<cc::RenderPass
>::Read(
396 const Message
* m
, PickleIterator
* iter
, param_type
* p
) {
397 cc::RenderPassId
id(-1, -1);
398 gfx::Rect output_rect
;
399 gfx::Rect damage_rect
;
400 gfx::Transform transform_to_root_target
;
401 bool has_transparent_background
;
402 size_t quad_list_size
;
404 if (!ReadParam(m
, iter
, &id
) ||
405 !ReadParam(m
, iter
, &output_rect
) ||
406 !ReadParam(m
, iter
, &damage_rect
) ||
407 !ReadParam(m
, iter
, &transform_to_root_target
) ||
408 !ReadParam(m
, iter
, &has_transparent_background
) ||
409 !ReadParam(m
, iter
, &quad_list_size
))
415 transform_to_root_target
,
416 has_transparent_background
);
418 for (size_t i
= 0; i
< quad_list_size
; ++i
) {
419 cc::DrawQuad::Material material
;
420 PickleIterator temp_iter
= *iter
;
421 if (!ReadParam(m
, &temp_iter
, &material
))
424 cc::DrawQuad
* draw_quad
= NULL
;
426 case cc::DrawQuad::CHECKERBOARD
:
427 draw_quad
= ReadDrawQuad
<cc::CheckerboardDrawQuad
>(m
, iter
, p
);
429 case cc::DrawQuad::DEBUG_BORDER
:
430 draw_quad
= ReadDrawQuad
<cc::DebugBorderDrawQuad
>(m
, iter
, p
);
432 case cc::DrawQuad::IO_SURFACE_CONTENT
:
433 draw_quad
= ReadDrawQuad
<cc::IOSurfaceDrawQuad
>(m
, iter
, p
);
435 case cc::DrawQuad::PICTURE_CONTENT
:
438 case cc::DrawQuad::SURFACE_CONTENT
:
439 draw_quad
= ReadDrawQuad
<cc::SurfaceDrawQuad
>(m
, iter
, p
);
441 case cc::DrawQuad::TEXTURE_CONTENT
:
442 draw_quad
= ReadDrawQuad
<cc::TextureDrawQuad
>(m
, iter
, p
);
444 case cc::DrawQuad::RENDER_PASS
:
445 draw_quad
= ReadDrawQuad
<cc::RenderPassDrawQuad
>(m
, iter
, p
);
447 case cc::DrawQuad::SOLID_COLOR
:
448 draw_quad
= ReadDrawQuad
<cc::SolidColorDrawQuad
>(m
, iter
, p
);
450 case cc::DrawQuad::TILED_CONTENT
:
451 draw_quad
= ReadDrawQuad
<cc::TileDrawQuad
>(m
, iter
, p
);
453 case cc::DrawQuad::STREAM_VIDEO_CONTENT
:
454 draw_quad
= ReadDrawQuad
<cc::StreamVideoDrawQuad
>(m
, iter
, p
);
456 case cc::DrawQuad::YUV_VIDEO_CONTENT
:
457 draw_quad
= ReadDrawQuad
<cc::YUVVideoDrawQuad
>(m
, iter
, p
);
459 case cc::DrawQuad::INVALID
:
464 if (!draw_quad
->rect
.Contains(draw_quad
->visible_rect
)) {
465 LOG(ERROR
) << "Quad with invalid visible rect " << draw_quad
->material
466 << " rect: " << draw_quad
->rect
.ToString()
467 << " visible_rect: " << draw_quad
->visible_rect
.ToString();
470 if (!draw_quad
->opaque_rect
.IsEmpty() &&
471 !draw_quad
->rect
.Contains(draw_quad
->opaque_rect
)) {
472 LOG(ERROR
) << "Quad with invalid opaque rect " << draw_quad
->material
473 << " rect: " << draw_quad
->rect
.ToString()
474 << " opaque_rect: " << draw_quad
->opaque_rect
.ToString();
478 bool has_new_shared_quad_state
;
479 if (!ReadParam(m
, iter
, &has_new_shared_quad_state
))
482 // If the quad has a new shared quad state, read it in.
483 if (has_new_shared_quad_state
) {
484 cc::SharedQuadState
* state
= p
->CreateAndAppendSharedQuadState();
485 if (!ReadParam(m
, iter
, state
))
489 draw_quad
->shared_quad_state
= p
->shared_quad_state_list
.back();
495 void ParamTraits
<cc::RenderPass
>::Log(
496 const param_type
& p
, std::string
* l
) {
497 l
->append("RenderPass((");
500 LogParam(p
.output_rect
, l
);
502 LogParam(p
.damage_rect
, l
);
504 LogParam(p
.transform_to_root_target
, l
);
506 LogParam(p
.has_transparent_background
, l
);
510 for (const auto& shared_quad_state
: p
.shared_quad_state_list
) {
511 if (&shared_quad_state
!= p
.shared_quad_state_list
.front())
513 LogParam(shared_quad_state
, l
);
516 for (const auto& quad
: p
.quad_list
) {
517 if (&quad
!= p
.quad_list
.front())
519 switch (quad
.material
) {
520 case cc::DrawQuad::CHECKERBOARD
:
521 LogParam(*cc::CheckerboardDrawQuad::MaterialCast(&quad
), l
);
523 case cc::DrawQuad::DEBUG_BORDER
:
524 LogParam(*cc::DebugBorderDrawQuad::MaterialCast(&quad
), l
);
526 case cc::DrawQuad::IO_SURFACE_CONTENT
:
527 LogParam(*cc::IOSurfaceDrawQuad::MaterialCast(&quad
), l
);
529 case cc::DrawQuad::PICTURE_CONTENT
:
532 case cc::DrawQuad::TEXTURE_CONTENT
:
533 LogParam(*cc::TextureDrawQuad::MaterialCast(&quad
), l
);
535 case cc::DrawQuad::RENDER_PASS
:
536 LogParam(*cc::RenderPassDrawQuad::MaterialCast(&quad
), l
);
538 case cc::DrawQuad::SOLID_COLOR
:
539 LogParam(*cc::SolidColorDrawQuad::MaterialCast(&quad
), l
);
541 case cc::DrawQuad::SURFACE_CONTENT
:
542 LogParam(*cc::SurfaceDrawQuad::MaterialCast(&quad
), l
);
544 case cc::DrawQuad::TILED_CONTENT
:
545 LogParam(*cc::TileDrawQuad::MaterialCast(&quad
), l
);
547 case cc::DrawQuad::STREAM_VIDEO_CONTENT
:
548 LogParam(*cc::StreamVideoDrawQuad::MaterialCast(&quad
), l
);
550 case cc::DrawQuad::YUV_VIDEO_CONTENT
:
551 LogParam(*cc::YUVVideoDrawQuad::MaterialCast(&quad
), l
);
553 case cc::DrawQuad::INVALID
:
561 enum CompositorFrameType
{
569 void ParamTraits
<cc::CompositorFrame
>::Write(Message
* m
,
570 const param_type
& p
) {
571 WriteParam(m
, p
.metadata
);
572 if (p
.delegated_frame_data
) {
573 DCHECK(!p
.gl_frame_data
);
574 DCHECK(!p
.software_frame_data
);
575 WriteParam(m
, static_cast<int>(DELEGATED_FRAME
));
576 WriteParam(m
, *p
.delegated_frame_data
);
577 } else if (p
.gl_frame_data
) {
578 DCHECK(!p
.software_frame_data
);
579 WriteParam(m
, static_cast<int>(GL_FRAME
));
580 WriteParam(m
, *p
.gl_frame_data
);
581 } else if (p
.software_frame_data
) {
582 WriteParam(m
, static_cast<int>(SOFTWARE_FRAME
));
583 WriteParam(m
, *p
.software_frame_data
);
585 WriteParam(m
, static_cast<int>(NO_FRAME
));
589 bool ParamTraits
<cc::CompositorFrame
>::Read(const Message
* m
,
590 PickleIterator
* iter
,
592 if (!ReadParam(m
, iter
, &p
->metadata
))
595 int compositor_frame_type
;
596 if (!ReadParam(m
, iter
, &compositor_frame_type
))
599 switch (compositor_frame_type
) {
600 case DELEGATED_FRAME
:
601 p
->delegated_frame_data
.reset(new cc::DelegatedFrameData());
602 if (!ReadParam(m
, iter
, p
->delegated_frame_data
.get()))
606 p
->gl_frame_data
.reset(new cc::GLFrameData());
607 if (!ReadParam(m
, iter
, p
->gl_frame_data
.get()))
611 p
->software_frame_data
.reset(new cc::SoftwareFrameData());
612 if (!ReadParam(m
, iter
, p
->software_frame_data
.get()))
623 void ParamTraits
<cc::CompositorFrame
>::Log(const param_type
& p
,
625 l
->append("CompositorFrame(");
626 LogParam(p
.metadata
, l
);
628 if (p
.delegated_frame_data
)
629 LogParam(*p
.delegated_frame_data
, l
);
630 else if (p
.gl_frame_data
)
631 LogParam(*p
.gl_frame_data
, l
);
632 else if (p
.software_frame_data
)
633 LogParam(*p
.software_frame_data
, l
);
637 void ParamTraits
<cc::CompositorFrameAck
>::Write(Message
* m
,
638 const param_type
& p
) {
639 WriteParam(m
, p
.resources
);
640 WriteParam(m
, p
.last_software_frame_id
);
641 if (p
.gl_frame_data
) {
642 WriteParam(m
, static_cast<int>(GL_FRAME
));
643 WriteParam(m
, *p
.gl_frame_data
);
645 WriteParam(m
, static_cast<int>(NO_FRAME
));
649 bool ParamTraits
<cc::CompositorFrameAck
>::Read(const Message
* m
,
650 PickleIterator
* iter
,
652 if (!ReadParam(m
, iter
, &p
->resources
))
655 if (!ReadParam(m
, iter
, &p
->last_software_frame_id
))
658 int compositor_frame_type
;
659 if (!ReadParam(m
, iter
, &compositor_frame_type
))
662 switch (compositor_frame_type
) {
666 p
->gl_frame_data
.reset(new cc::GLFrameData());
667 if (!ReadParam(m
, iter
, p
->gl_frame_data
.get()))
676 void ParamTraits
<cc::CompositorFrameAck
>::Log(const param_type
& p
,
678 l
->append("CompositorFrameAck(");
679 LogParam(p
.resources
, l
);
681 LogParam(p
.last_software_frame_id
, l
);
684 LogParam(*p
.gl_frame_data
, l
);
688 void ParamTraits
<cc::DelegatedFrameData
>::Write(Message
* m
,
689 const param_type
& p
) {
690 DCHECK_NE(0u, p
.render_pass_list
.size());
692 size_t to_reserve
= sizeof(p
.device_scale_factor
);
693 to_reserve
+= p
.resource_list
.size() * sizeof(cc::TransferableResource
);
694 for (size_t i
= 0; i
< p
.render_pass_list
.size(); ++i
) {
695 const cc::RenderPass
* pass
= p
.render_pass_list
[i
];
696 to_reserve
+= sizeof(size_t) * 2;
697 to_reserve
+= ReserveSizeForRenderPassWrite(*pass
);
699 m
->Reserve(to_reserve
);
701 WriteParam(m
, p
.device_scale_factor
);
702 WriteParam(m
, p
.resource_list
);
703 WriteParam(m
, p
.render_pass_list
.size());
704 for (size_t i
= 0; i
< p
.render_pass_list
.size(); ++i
) {
705 WriteParam(m
, p
.render_pass_list
[i
]->quad_list
.size());
706 WriteParam(m
, p
.render_pass_list
[i
]->shared_quad_state_list
.size());
707 WriteParam(m
, *p
.render_pass_list
[i
]);
711 bool ParamTraits
<cc::DelegatedFrameData
>::Read(const Message
* m
,
712 PickleIterator
* iter
,
714 if (!ReadParam(m
, iter
, &p
->device_scale_factor
))
717 const static size_t kMaxRenderPasses
= 10000;
718 const static size_t kMaxSharedQuadStateListSize
= 100000;
719 const static size_t kMaxQuadListSize
= 1000000;
721 size_t num_render_passes
;
722 if (!ReadParam(m
, iter
, &p
->resource_list
) ||
723 !ReadParam(m
, iter
, &num_render_passes
) ||
724 num_render_passes
> kMaxRenderPasses
|| num_render_passes
== 0)
726 for (size_t i
= 0; i
< num_render_passes
; ++i
) {
727 size_t quad_list_size
;
728 size_t shared_quad_state_list_size
;
729 if (!ReadParam(m
, iter
, &quad_list_size
) ||
730 !ReadParam(m
, iter
, &shared_quad_state_list_size
) ||
731 quad_list_size
> kMaxQuadListSize
||
732 shared_quad_state_list_size
> kMaxSharedQuadStateListSize
)
734 scoped_ptr
<cc::RenderPass
> render_pass
=
735 cc::RenderPass::Create(shared_quad_state_list_size
, quad_list_size
);
736 if (!ReadParam(m
, iter
, render_pass
.get()))
738 p
->render_pass_list
.push_back(render_pass
.Pass());
743 void ParamTraits
<cc::DelegatedFrameData
>::Log(const param_type
& p
,
745 l
->append("DelegatedFrameData(");
746 LogParam(p
.device_scale_factor
, l
);
747 LogParam(p
.resource_list
, l
);
749 for (size_t i
= 0; i
< p
.render_pass_list
.size(); ++i
) {
752 LogParam(*p
.render_pass_list
[i
], l
);
757 void ParamTraits
<cc::SoftwareFrameData
>::Write(Message
* m
,
758 const param_type
& p
) {
759 DCHECK(cc::SharedBitmap::VerifySizeInBytes(p
.size
));
761 m
->Reserve(sizeof(cc::SoftwareFrameData
));
763 WriteParam(m
, p
.size
);
764 WriteParam(m
, p
.damage_rect
);
765 WriteParam(m
, p
.bitmap_id
);
768 bool ParamTraits
<cc::SoftwareFrameData
>::Read(const Message
* m
,
769 PickleIterator
* iter
,
771 if (!ReadParam(m
, iter
, &p
->id
))
773 if (!ReadParam(m
, iter
, &p
->size
) ||
774 !cc::SharedBitmap::VerifySizeInBytes(p
->size
))
776 if (!ReadParam(m
, iter
, &p
->damage_rect
))
778 if (!ReadParam(m
, iter
, &p
->bitmap_id
))
783 void ParamTraits
<cc::SoftwareFrameData
>::Log(const param_type
& p
,
785 l
->append("SoftwareFrameData(");
790 LogParam(p
.damage_rect
, l
);
792 LogParam(p
.bitmap_id
, l
);