Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(769)

Side by Side Diff: cc/ipc/render_pass_struct_traits.cc

Issue 2088603002: Implement RenderPass StructTraits (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Updated Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cc/ipc/render_pass_struct_traits.h ('k') | cc/ipc/shared_quad_state_struct_traits.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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
7 #include "base/numerics/safe_conversions.h"
8 #include "cc/ipc/shared_quad_state_struct_traits.h"
9
10 namespace mojo {
11
12 // static
13 void* StructTraits<cc::mojom::RenderPass, std::unique_ptr<cc::RenderPass>>::
14 SetUpContext(const std::unique_ptr<cc::RenderPass>& input) {
15 DCHECK_GT(input->quad_list.size(), 0u);
16 mojo::Array<uint32_t>* sqs_references =
dcheng 2016/06/24 09:12:20 Nit: std::unique_ptr and release at the end.
Fady Samuel 2016/06/24 13:33:21 Done.
17 new mojo::Array<uint32_t>(input->quad_list.size());
18 cc::SharedQuadStateList::ConstIterator sqs_iter =
19 input->shared_quad_state_list.begin();
20 for (auto it = input->quad_list.begin(); it != input->quad_list.end(); ++it) {
21 if ((*it)->shared_quad_state != *sqs_iter)
22 ++sqs_iter;
23 (*sqs_references)[it.index()] =
24 base::checked_cast<uint32_t>(sqs_iter.index());
25 DCHECK_EQ(*sqs_iter, (*it)->shared_quad_state);
dcheng 2016/06/24 09:12:20 For clarity, it might help to DCHECK() that the in
Fady Samuel 2016/06/24 13:33:21 Done.
26 }
27 DCHECK_EQ(input->shared_quad_state_list.size() - 1, sqs_iter.index());
28 return sqs_references;
29 }
30
31 // static
32 void StructTraits<cc::mojom::RenderPass, std::unique_ptr<cc::RenderPass>>::
33 TearDownContext(const std::unique_ptr<cc::RenderPass>& input,
34 void* context) {
35 // static_cast to ensure the destructor is called.
36 delete static_cast<mojo::Array<uint32_t>*>(context);
37 }
38
39 // static
40 bool StructTraits<cc::mojom::RenderPass, std::unique_ptr<cc::RenderPass>>::Read(
41 cc::mojom::RenderPassDataView data,
42 std::unique_ptr<cc::RenderPass>* out) {
43 *out = cc::RenderPass::Create();
44 if (!data.ReadId(&(*out)->id) || !data.ReadOutputRect(&(*out)->output_rect) ||
45 !data.ReadDamageRect(&(*out)->damage_rect) ||
46 !data.ReadTransformToRootTarget(&(*out)->transform_to_root_target)) {
47 return false;
48 }
49 (*out)->has_transparent_background = data.has_transparent_background();
50 if (!data.ReadQuadList(&(*out)->quad_list) ||
51 !data.ReadSharedQuadStateList(&(*out)->shared_quad_state_list))
52 return false;
53
54 mojo::Array<uint32_t> shared_quad_state_references;
55 if (!data.ReadSharedQuadStateReferences(&shared_quad_state_references))
56 return false;
57
58 if ((*out)->quad_list.size() != shared_quad_state_references.size())
59 return false;
60
61 cc::SharedQuadStateList::ConstIterator sqs_iter =
62 (*out)->shared_quad_state_list.begin();
63 for (auto it = (*out)->quad_list.begin(); it != (*out)->quad_list.end();
64 ++it) {
65 if (sqs_iter.index() != shared_quad_state_references[it.index()])
66 ++sqs_iter;
67 if (shared_quad_state_references[it.index()] != sqs_iter.index())
68 return false;
69 (*it)->shared_quad_state = *sqs_iter;
70 if (!(*it)->shared_quad_state)
71 return false;
72 }
73 return sqs_iter.index() == (*out)->shared_quad_state_list.size() - 1;
74 }
75
76 } // namespace mojo
OLDNEW
« no previous file with comments | « cc/ipc/render_pass_struct_traits.h ('k') | cc/ipc/shared_quad_state_struct_traits.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698