| 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_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 |
| 11 namespace mojo { | 11 namespace mojo { |
| 12 | 12 |
| 13 struct OptSharedQuadState { |
| 14 const cc::SharedQuadState* sqs; |
| 15 }; |
| 16 |
| 17 template <> |
| 18 struct StructTraits<cc::mojom::SharedQuadState, OptSharedQuadState> { |
| 19 static bool IsNull(const OptSharedQuadState& input) { return !input.sqs; } |
| 20 |
| 21 static void SetToNull(OptSharedQuadState* output) { output->sqs = nullptr; } |
| 22 |
| 23 static const gfx::Transform& quad_to_target_transform( |
| 24 const OptSharedQuadState& input) { |
| 25 return input.sqs->quad_to_target_transform; |
| 26 } |
| 27 |
| 28 static const gfx::Size& quad_layer_bounds(const OptSharedQuadState& input) { |
| 29 return input.sqs->quad_layer_bounds; |
| 30 } |
| 31 |
| 32 static const gfx::Rect& visible_quad_layer_rect( |
| 33 const OptSharedQuadState& input) { |
| 34 return input.sqs->visible_quad_layer_rect; |
| 35 } |
| 36 |
| 37 static const gfx::Rect& clip_rect(const OptSharedQuadState& input) { |
| 38 return input.sqs->clip_rect; |
| 39 } |
| 40 |
| 41 static bool is_clipped(const OptSharedQuadState& input) { |
| 42 return input.sqs->is_clipped; |
| 43 } |
| 44 |
| 45 static float opacity(const OptSharedQuadState& input) { |
| 46 return input.sqs->opacity; |
| 47 } |
| 48 |
| 49 static uint32_t blend_mode(const OptSharedQuadState& input) { |
| 50 return input.sqs->blend_mode; |
| 51 } |
| 52 |
| 53 static int32_t sorting_context_id(const OptSharedQuadState& input) { |
| 54 return input.sqs->sorting_context_id; |
| 55 } |
| 56 }; |
| 57 |
| 13 template <> | 58 template <> |
| 14 struct StructTraits<cc::mojom::SharedQuadState, cc::SharedQuadState> { | 59 struct StructTraits<cc::mojom::SharedQuadState, cc::SharedQuadState> { |
| 15 static const gfx::Transform& quad_to_target_transform( | 60 static const gfx::Transform& quad_to_target_transform( |
| 16 const cc::SharedQuadState& sqs) { | 61 const cc::SharedQuadState& sqs) { |
| 17 return sqs.quad_to_target_transform; | 62 return sqs.quad_to_target_transform; |
| 18 } | 63 } |
| 19 | 64 |
| 20 static const gfx::Size& quad_layer_bounds(const cc::SharedQuadState& sqs) { | 65 static const gfx::Size& quad_layer_bounds(const cc::SharedQuadState& sqs) { |
| 21 return sqs.quad_layer_bounds; | 66 return sqs.quad_layer_bounds; |
| 22 } | 67 } |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 out->is_clipped = data.is_clipped(); | 101 out->is_clipped = data.is_clipped(); |
| 57 out->opacity = data.opacity(); | 102 out->opacity = data.opacity(); |
| 58 if (data.blend_mode() > SkXfermode::kLastMode) | 103 if (data.blend_mode() > SkXfermode::kLastMode) |
| 59 return false; | 104 return false; |
| 60 out->blend_mode = static_cast<SkXfermode::Mode>(data.blend_mode()); | 105 out->blend_mode = static_cast<SkXfermode::Mode>(data.blend_mode()); |
| 61 out->sorting_context_id = data.sorting_context_id(); | 106 out->sorting_context_id = data.sorting_context_id(); |
| 62 return true; | 107 return true; |
| 63 } | 108 } |
| 64 }; | 109 }; |
| 65 | 110 |
| 66 struct SharedQuadStateListArray { | |
| 67 cc::SharedQuadStateList* list; | |
| 68 }; | |
| 69 | |
| 70 template <> | |
| 71 struct ArrayTraits<SharedQuadStateListArray> { | |
| 72 using Element = cc::SharedQuadState; | |
| 73 using Iterator = cc::SharedQuadStateList::Iterator; | |
| 74 using ConstIterator = cc::SharedQuadStateList::ConstIterator; | |
| 75 | |
| 76 static ConstIterator GetBegin(const SharedQuadStateListArray& input) { | |
| 77 return input.list->begin(); | |
| 78 } | |
| 79 static Iterator GetBegin(SharedQuadStateListArray& input) { | |
| 80 return input.list->begin(); | |
| 81 } | |
| 82 static void AdvanceIterator(ConstIterator& iterator) { ++iterator; } | |
| 83 static void AdvanceIterator(Iterator& iterator) { ++iterator; } | |
| 84 static const Element& GetValue(ConstIterator& iterator) { return **iterator; } | |
| 85 static Element& GetValue(Iterator& iterator) { return **iterator; } | |
| 86 static size_t GetSize(const SharedQuadStateListArray& input) { | |
| 87 return input.list->size(); | |
| 88 } | |
| 89 static bool Resize(SharedQuadStateListArray& input, size_t size) { | |
| 90 if (input.list->size() == size) | |
| 91 return true; | |
| 92 input.list->clear(); | |
| 93 for (size_t i = 0; i < size; ++i) | |
| 94 input.list->AllocateAndConstruct<cc::SharedQuadState>(); | |
| 95 return true; | |
| 96 } | |
| 97 }; | |
| 98 | |
| 99 template <> | |
| 100 struct StructTraits<cc::mojom::SharedQuadStateList, cc::SharedQuadStateList> { | |
| 101 static SharedQuadStateListArray shared_quad_states( | |
| 102 const cc::SharedQuadStateList& list) { | |
| 103 return {const_cast<cc::SharedQuadStateList*>(&list)}; | |
| 104 } | |
| 105 | |
| 106 static bool Read(cc::mojom::SharedQuadStateListDataView data, | |
| 107 cc::SharedQuadStateList* out) { | |
| 108 SharedQuadStateListArray sqs_array = {out}; | |
| 109 return data.ReadSharedQuadStates(&sqs_array); | |
| 110 } | |
| 111 }; | |
| 112 | |
| 113 } // namespace mojo | 111 } // namespace mojo |
| 114 | 112 |
| 115 #endif // CC_IPC_SHARED_QUAD_STATE_STRUCT_TRAITS_H_ | 113 #endif // CC_IPC_SHARED_QUAD_STATE_STRUCT_TRAITS_H_ |
| OLD | NEW |