OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 #ifndef CC_IPC_QUADS_STRUCT_TRAITS_H_ | 5 #ifndef CC_IPC_QUADS_STRUCT_TRAITS_H_ |
6 #define CC_IPC_QUADS_STRUCT_TRAITS_H_ | 6 #define CC_IPC_QUADS_STRUCT_TRAITS_H_ |
7 | 7 |
8 #include "cc/ipc/filter_operation_struct_traits.h" | 8 #include "cc/ipc/filter_operation_struct_traits.h" |
9 #include "cc/ipc/filter_operations_struct_traits.h" | 9 #include "cc/ipc/filter_operations_struct_traits.h" |
10 #include "cc/ipc/quads.mojom.h" | 10 #include "cc/ipc/quads.mojom.h" |
11 #include "cc/ipc/render_pass_id_struct_traits.h" | 11 #include "cc/ipc/render_pass_id_struct_traits.h" |
12 #include "cc/ipc/surface_id_struct_traits.h" | 12 #include "cc/ipc/surface_id_struct_traits.h" |
13 #include "cc/quads/debug_border_draw_quad.h" | 13 #include "cc/quads/debug_border_draw_quad.h" |
14 #include "cc/quads/picture_draw_quad.h" | 14 #include "cc/quads/picture_draw_quad.h" |
15 #include "cc/quads/render_pass_draw_quad.h" | 15 #include "cc/quads/render_pass_draw_quad.h" |
16 #include "cc/quads/solid_color_draw_quad.h" | 16 #include "cc/quads/solid_color_draw_quad.h" |
17 #include "cc/quads/stream_video_draw_quad.h" | 17 #include "cc/quads/stream_video_draw_quad.h" |
18 #include "cc/quads/surface_draw_quad.h" | 18 #include "cc/quads/surface_draw_quad.h" |
19 #include "cc/quads/texture_draw_quad.h" | 19 #include "cc/quads/texture_draw_quad.h" |
20 #include "cc/quads/tile_draw_quad.h" | 20 #include "cc/quads/tile_draw_quad.h" |
| 21 #include "cc/quads/y_video_draw_quad.h" |
21 #include "cc/quads/yuv_video_draw_quad.h" | 22 #include "cc/quads/yuv_video_draw_quad.h" |
22 #include "ui/gfx/geometry/mojo/geometry_struct_traits.h" | 23 #include "ui/gfx/geometry/mojo/geometry_struct_traits.h" |
23 | 24 |
24 namespace mojo { | 25 namespace mojo { |
25 | 26 |
26 template <> | 27 template <> |
27 struct EnumTraits<cc::mojom::Material, cc::DrawQuad::Material> { | 28 struct EnumTraits<cc::mojom::Material, cc::DrawQuad::Material> { |
28 static cc::mojom::Material ToMojom(cc::DrawQuad::Material material); | 29 static cc::mojom::Material ToMojom(cc::DrawQuad::Material material); |
29 static bool FromMojom(cc::mojom::Material input, cc::DrawQuad::Material* out); | 30 static bool FromMojom(cc::mojom::Material input, cc::DrawQuad::Material* out); |
30 }; | 31 }; |
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
349 const cc::YUVVideoDrawQuad* quad = | 350 const cc::YUVVideoDrawQuad* quad = |
350 cc::YUVVideoDrawQuad::MaterialCast(&input); | 351 cc::YUVVideoDrawQuad::MaterialCast(&input); |
351 return quad->resource_multiplier; | 352 return quad->resource_multiplier; |
352 } | 353 } |
353 | 354 |
354 static bool Read(cc::mojom::YUVVideoQuadStateDataView data, | 355 static bool Read(cc::mojom::YUVVideoQuadStateDataView data, |
355 cc::DrawQuad* out); | 356 cc::DrawQuad* out); |
356 }; | 357 }; |
357 | 358 |
358 template <> | 359 template <> |
| 360 struct StructTraits<cc::mojom::YVideoQuadState, cc::DrawQuad> { |
| 361 static bool IsNull(const cc::DrawQuad& input) { |
| 362 return input.material != cc::DrawQuad::Y_VIDEO_CONTENT; |
| 363 } |
| 364 |
| 365 static void SetToNull(cc::DrawQuad* output) { |
| 366 // There is nothing to deserialize here if the DrawQuad is not a |
| 367 // YVideoContentDrawQuad. If it is, then this should not be called. |
| 368 DCHECK_NE(cc::DrawQuad::Y_VIDEO_CONTENT, output->material); |
| 369 } |
| 370 |
| 371 static uint32_t resource_id(const cc::DrawQuad& input) { |
| 372 const cc::YVideoDrawQuad* quad = cc::YVideoDrawQuad::MaterialCast(&input); |
| 373 return quad->resource_id(); |
| 374 } |
| 375 |
| 376 static const gfx::PointF& uv_top_left(const cc::DrawQuad& input) { |
| 377 const cc::YVideoDrawQuad* quad = cc::YVideoDrawQuad::MaterialCast(&input); |
| 378 return quad->uv_top_left; |
| 379 } |
| 380 |
| 381 static const gfx::PointF& uv_bottom_right(const cc::DrawQuad& input) { |
| 382 const cc::YVideoDrawQuad* quad = cc::YVideoDrawQuad::MaterialCast(&input); |
| 383 return quad->uv_bottom_right; |
| 384 } |
| 385 |
| 386 static bool Read(cc::mojom::YVideoQuadStateDataView data, cc::DrawQuad* out); |
| 387 }; |
| 388 |
| 389 |
| 390 template <> |
359 struct StructTraits<cc::mojom::DrawQuad, cc::DrawQuad> { | 391 struct StructTraits<cc::mojom::DrawQuad, cc::DrawQuad> { |
360 static cc::DrawQuad::Material material(const cc::DrawQuad& quad) { | 392 static cc::DrawQuad::Material material(const cc::DrawQuad& quad) { |
361 return quad.material; | 393 return quad.material; |
362 } | 394 } |
363 | 395 |
364 static const gfx::Rect& rect(const cc::DrawQuad& quad) { return quad.rect; } | 396 static const gfx::Rect& rect(const cc::DrawQuad& quad) { return quad.rect; } |
365 | 397 |
366 static const gfx::Rect& opaque_rect(const cc::DrawQuad& quad) { | 398 static const gfx::Rect& opaque_rect(const cc::DrawQuad& quad) { |
367 return quad.opaque_rect; | 399 return quad.opaque_rect; |
368 } | 400 } |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
453 void* context); | 485 void* context); |
454 static QuadListArray quads(const cc::QuadList& quad_list) { | 486 static QuadListArray quads(const cc::QuadList& quad_list) { |
455 return {quad_list.size(), const_cast<cc::QuadList*>(&quad_list)}; | 487 return {quad_list.size(), const_cast<cc::QuadList*>(&quad_list)}; |
456 } | 488 } |
457 static bool Read(cc::mojom::QuadListDataView data, cc::QuadList* out); | 489 static bool Read(cc::mojom::QuadListDataView data, cc::QuadList* out); |
458 }; | 490 }; |
459 | 491 |
460 } // namespace mojo | 492 } // namespace mojo |
461 | 493 |
462 #endif // CC_IPC_QUADS_STRUCT_TRAITS_H_ | 494 #endif // CC_IPC_QUADS_STRUCT_TRAITS_H_ |
OLD | NEW |