Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "cc/ipc/render_pass_struct_traits.h" | |
| 6 #include "cc/ipc/shared_quad_state_struct_traits.h" | |
| 7 | |
| 8 namespace mojo { | |
| 9 | |
| 10 // static | |
| 11 void* StructTraits<cc::mojom::RenderPass, std::unique_ptr<cc::RenderPass>>:: | |
| 12 SetUpContext(const std::unique_ptr<cc::RenderPass>& input) { | |
| 13 DCHECK_GT(input->quad_list.size(), 0u); | |
| 14 mojo::Array<uint32_t>* sqs_references = | |
| 15 new mojo::Array<uint32_t>(input->quad_list.size()); | |
| 16 cc::SharedQuadStateList::ConstIterator sqs_iter = | |
| 17 input->shared_quad_state_list.begin(); | |
| 18 for (auto it = input->quad_list.begin(); it != input->quad_list.end(); ++it) { | |
| 19 if ((*it)->shared_quad_state != *sqs_iter) | |
| 20 ++sqs_iter; | |
| 21 (*sqs_references)[it.index()] = sqs_iter.index(); | |
| 22 DCHECK_EQ(*sqs_iter, (*it)->shared_quad_state); | |
| 23 } | |
| 24 DCHECK_EQ(input->shared_quad_state_list.size() - 1, sqs_iter.index()); | |
| 25 return sqs_references; | |
| 26 } | |
| 27 | |
| 28 // static | |
| 29 void StructTraits<cc::mojom::RenderPass, std::unique_ptr<cc::RenderPass>>:: | |
| 30 TearDownContext(const std::unique_ptr<cc::RenderPass>& input, | |
| 31 void* context) { | |
| 32 // static_cast to ensure the destructor is called. | |
| 33 delete static_cast<mojo::Array<uint32_t>*>(context); | |
| 34 } | |
| 35 | |
| 36 // static | |
| 37 bool StructTraits<cc::mojom::RenderPass, std::unique_ptr<cc::RenderPass>>::Read( | |
|
danakj
2016/06/22 00:05:09
Where does the writer live?
Fady Samuel
2016/06/22 20:08:14
All the accessors in render_pass_struct_traits.h.
| |
| 38 cc::mojom::RenderPassDataView data, | |
| 39 std::unique_ptr<cc::RenderPass>* out) { | |
| 40 *out = cc::RenderPass::Create(); | |
| 41 if (!data.ReadId(&(*out)->id) || !data.ReadOutputRect(&(*out)->output_rect) || | |
| 42 !data.ReadDamageRect(&(*out)->damage_rect) || | |
| 43 !data.ReadTransformToRootTarget(&(*out)->transform_to_root_target)) { | |
| 44 return false; | |
| 45 } | |
| 46 (*out)->has_transparent_background = data.has_transparent_background(); | |
| 47 if (!data.ReadQuadList(&(*out)->quad_list) || | |
| 48 !data.ReadSharedQuadStateList(&(*out)->shared_quad_state_list)) | |
| 49 return false; | |
| 50 | |
| 51 mojo::Array<uint32_t> shared_quad_state_references; | |
| 52 if (!data.ReadSharedQuadStateReferences(&shared_quad_state_references)) | |
| 53 return false; | |
| 54 | |
| 55 if ((*out)->quad_list.size() != shared_quad_state_references.size()) | |
| 56 return false; | |
| 57 | |
| 58 cc::SharedQuadStateList::ConstIterator sqs_iter = | |
| 59 (*out)->shared_quad_state_list.begin(); | |
| 60 for (auto it = (*out)->quad_list.begin(); it != (*out)->quad_list.end(); | |
| 61 ++it) { | |
| 62 if (sqs_iter.index() != shared_quad_state_references[it.index()]) | |
| 63 ++sqs_iter; | |
| 64 DCHECK_EQ(shared_quad_state_references[it.index()], sqs_iter.index()); | |
|
yzshen1
2016/06/21 23:51:21
(I am not familiar with this data structure...)
Ar
danakj
2016/06/22 00:05:09
1On 2016/06/21 23:51:21, yzshen1 wrote:
Fady Samuel
2016/06/22 20:08:14
Done.
Fady Samuel
2016/06/22 20:08:14
Good point. I changed them to return false if the
| |
| 65 (*it)->shared_quad_state = *sqs_iter; | |
| 66 DCHECK_NE(nullptr, (*it)->shared_quad_state); | |
| 67 } | |
| 68 DCHECK_EQ((*out)->shared_quad_state_list.size() - 1, sqs_iter.index()); | |
| 69 return true; | |
| 70 } | |
| 71 | |
| 72 } // namespace mojo | |
| OLD | NEW |