| 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 #include "cc/ipc/render_pass_struct_traits.h" | 5 #include "cc/ipc/render_pass_struct_traits.h" |
| 6 | 6 |
| 7 #include "base/numerics/safe_conversions.h" | 7 #include "base/numerics/safe_conversions.h" |
| 8 #include "cc/ipc/shared_quad_state_struct_traits.h" | 8 #include "cc/ipc/shared_quad_state_struct_traits.h" |
| 9 | 9 |
| 10 namespace mojo { | 10 namespace mojo { |
| 11 | 11 |
| 12 // static | 12 // static |
| 13 bool StructTraits<cc::mojom::RenderPass, std::unique_ptr<cc::RenderPass>>::Read( | 13 bool StructTraits<cc::mojom::RenderPass, std::unique_ptr<cc::RenderPass>>::Read( |
| 14 cc::mojom::RenderPassDataView data, | 14 cc::mojom::RenderPassDataView data, |
| 15 std::unique_ptr<cc::RenderPass>* out) { | 15 std::unique_ptr<cc::RenderPass>* out) { |
| 16 *out = cc::RenderPass::Create(); | 16 *out = cc::RenderPass::Create(); |
| 17 if (!data.ReadId(&(*out)->id) || !data.ReadOutputRect(&(*out)->output_rect) || | 17 if (!data.ReadId(&(*out)->id) || !data.ReadOutputRect(&(*out)->output_rect) || |
| 18 !data.ReadDamageRect(&(*out)->damage_rect) || | 18 !data.ReadDamageRect(&(*out)->damage_rect) || |
| 19 !data.ReadTransformToRootTarget(&(*out)->transform_to_root_target)) { | 19 !data.ReadTransformToRootTarget(&(*out)->transform_to_root_target)) { |
| 20 return false; | 20 return false; |
| 21 } | 21 } |
| 22 (*out)->has_transparent_background = data.has_transparent_background(); | 22 (*out)->has_transparent_background = data.has_transparent_background(); |
| 23 | 23 |
| 24 mojo::ArrayDataView<cc::mojom::DrawQuadDataView> quads; | 24 mojo::ArrayDataView<cc::mojom::DrawQuadDataView> quads; |
| 25 data.GetQuadListDataView(&quads); | 25 data.GetQuadListDataView(&quads); |
| 26 cc::SharedQuadState* last_sqs = nullptr; | 26 cc::SharedQuadState* last_sqs = nullptr; |
| 27 for (size_t i = 0; i < quads.size(); ++i) { | 27 for (size_t i = 0; i < quads.size(); ++i) { |
| 28 cc::mojom::DrawQuadDataView quad_data_view; | 28 cc::mojom::DrawQuadDataView quad_data_view; |
| 29 quads.GetDataView(i, &quad_data_view); | 29 quads.GetDataView(i, &quad_data_view); |
| 30 cc::mojom::DrawQuadStateDataView quad_state_data_view; |
| 31 quad_data_view.GetDrawQuadStateDataView(&quad_state_data_view); |
| 32 |
| 30 cc::DrawQuad* quad = | 33 cc::DrawQuad* quad = |
| 31 AllocateAndConstruct(quad_data_view.material(), &(*out)->quad_list); | 34 AllocateAndConstruct(quad_state_data_view.tag(), &(*out)->quad_list); |
| 32 if (!quad) | 35 if (!quad) |
| 33 return false; | 36 return false; |
| 34 if (!quads.Read(i, quad)) | 37 if (!quads.Read(i, quad)) |
| 35 return false; | 38 return false; |
| 36 | 39 |
| 37 // Read the SharedQuadState. | 40 // Read the SharedQuadState. |
| 38 cc::mojom::SharedQuadStateDataView sqs_data_view; | 41 cc::mojom::SharedQuadStateDataView sqs_data_view; |
| 39 quad_data_view.GetSqsDataView(&sqs_data_view); | 42 quad_data_view.GetSqsDataView(&sqs_data_view); |
| 40 // If there is no seralized SharedQuadState then used the last deseriaized | 43 // If there is no seralized SharedQuadState then used the last deseriaized |
| 41 // one. | 44 // one. |
| 42 if (!sqs_data_view.is_null()) { | 45 if (!sqs_data_view.is_null()) { |
| 43 last_sqs = (*out)->CreateAndAppendSharedQuadState(); | 46 last_sqs = (*out)->CreateAndAppendSharedQuadState(); |
| 44 if (!quad_data_view.ReadSqs(last_sqs)) | 47 if (!quad_data_view.ReadSqs(last_sqs)) |
| 45 return false; | 48 return false; |
| 46 } | 49 } |
| 47 quad->shared_quad_state = last_sqs; | 50 quad->shared_quad_state = last_sqs; |
| 48 if (!quad->shared_quad_state) | 51 if (!quad->shared_quad_state) |
| 49 return false; | 52 return false; |
| 50 } | 53 } |
| 51 return true; | 54 return true; |
| 52 } | 55 } |
| 53 | 56 |
| 54 } // namespace mojo | 57 } // namespace mojo |
| OLD | NEW |