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

Side by Side Diff: cc/ipc/shared_quad_state_struct_traits.h

Issue 2075853004: Implement SharedQuadStateList StructTraits (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed sky's comments 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/shared_quad_state.mojom ('k') | components/bitmap_uploader/bitmap_uploader.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_SHARED_QUAD_STATE_STRUCT_TRAITS_H_ 5 #ifndef CC_IPC_SHARED_QUAD_STATE_STRUCT_TRAITS_H_
6 #define CC_IPC_SHARED_QUAD_STATE_STRUCT_TRAITS_H_ 6 #define CC_IPC_SHARED_QUAD_STATE_STRUCT_TRAITS_H_
7 7
8 #include "cc/ipc/shared_quad_state.mojom.h" 8 #include "cc/ipc/shared_quad_state.mojom.h"
9 #include "cc/quads/shared_quad_state.h" 9 #include "cc/quads/shared_quad_state.h"
10 10
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 out->is_clipped = data.is_clipped(); 55 out->is_clipped = data.is_clipped();
56 out->opacity = data.opacity(); 56 out->opacity = data.opacity();
57 if (data.blend_mode() > SkXfermode::kLastMode) 57 if (data.blend_mode() > SkXfermode::kLastMode)
58 return false; 58 return false;
59 out->blend_mode = static_cast<SkXfermode::Mode>(data.blend_mode()); 59 out->blend_mode = static_cast<SkXfermode::Mode>(data.blend_mode());
60 out->sorting_context_id = data.sorting_context_id(); 60 out->sorting_context_id = data.sorting_context_id();
61 return true; 61 return true;
62 } 62 }
63 }; 63 };
64 64
65 struct SharedQuadStateListArray {
66 cc::SharedQuadStateList* list;
67 };
68
69 template <>
70 struct ArrayTraits<SharedQuadStateListArray> {
71 using Element = cc::SharedQuadState;
72 using Iterator = cc::SharedQuadStateList::Iterator;
73 using ConstIterator = cc::SharedQuadStateList::ConstIterator;
74
75 static ConstIterator GetBegin(const SharedQuadStateListArray& input) {
76 return input.list->begin();
77 }
78 static Iterator GetBegin(SharedQuadStateListArray& input) {
79 return input.list->begin();
80 }
81 static void AdvanceIterator(ConstIterator& iterator) { ++iterator; }
82 static void AdvanceIterator(Iterator& iterator) { ++iterator; }
83 static const Element& GetValue(ConstIterator& iterator) { return **iterator; }
84 static Element& GetValue(Iterator& iterator) { return **iterator; }
85 static size_t GetSize(const SharedQuadStateListArray& input) {
86 return input.list->size();
87 }
88 static bool Resize(SharedQuadStateListArray& input, size_t size) {
89 if (input.list->size() == size)
90 return true;
91 input.list->clear();
92 for (size_t i = 0; i < size; ++i)
93 input.list->AllocateAndConstruct<cc::SharedQuadState>();
94 return true;
95 }
96 };
97
98 template <>
99 struct StructTraits<cc::mojom::SharedQuadStateList, cc::SharedQuadStateList> {
100 static SharedQuadStateListArray shared_quad_states(
101 const cc::SharedQuadStateList& list) {
102 return {const_cast<cc::SharedQuadStateList*>(&list)};
103 }
104
105 static bool Read(cc::mojom::SharedQuadStateListDataView data,
106 cc::SharedQuadStateList* out) {
107 SharedQuadStateListArray sqs_array = {out};
108 return data.ReadSharedQuadStates(&sqs_array);
109 }
110 };
111
65 } // namespace mojo 112 } // namespace mojo
66 113
67 #endif // CC_IPC_SHARED_QUAD_STATE_STRUCT_TRAITS_H_ 114 #endif // CC_IPC_SHARED_QUAD_STATE_STRUCT_TRAITS_H_
OLDNEW
« no previous file with comments | « cc/ipc/shared_quad_state.mojom ('k') | components/bitmap_uploader/bitmap_uploader.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698