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-shared.h" | 8 #include "cc/ipc/shared_quad_state.mojom-shared.h" |
9 #include "cc/quads/shared_quad_state.h" | 9 #include "cc/quads/shared_quad_state.h" |
10 | 10 |
(...skipping 29 matching lines...) Expand all Loading... |
40 | 40 |
41 static bool is_clipped(const OptSharedQuadState& input) { | 41 static bool is_clipped(const OptSharedQuadState& input) { |
42 return input.sqs->is_clipped; | 42 return input.sqs->is_clipped; |
43 } | 43 } |
44 | 44 |
45 static float opacity(const OptSharedQuadState& input) { | 45 static float opacity(const OptSharedQuadState& input) { |
46 return input.sqs->opacity; | 46 return input.sqs->opacity; |
47 } | 47 } |
48 | 48 |
49 static uint32_t blend_mode(const OptSharedQuadState& input) { | 49 static uint32_t blend_mode(const OptSharedQuadState& input) { |
50 return input.sqs->blend_mode; | 50 return static_cast<uint32_t>(input.sqs->blend_mode); |
51 } | 51 } |
52 | 52 |
53 static int32_t sorting_context_id(const OptSharedQuadState& input) { | 53 static int32_t sorting_context_id(const OptSharedQuadState& input) { |
54 return input.sqs->sorting_context_id; | 54 return input.sqs->sorting_context_id; |
55 } | 55 } |
56 }; | 56 }; |
57 | 57 |
58 template <> | 58 template <> |
59 struct StructTraits<cc::mojom::SharedQuadStateDataView, cc::SharedQuadState> { | 59 struct StructTraits<cc::mojom::SharedQuadStateDataView, cc::SharedQuadState> { |
60 static const gfx::Transform& quad_to_target_transform( | 60 static const gfx::Transform& quad_to_target_transform( |
(...skipping 14 matching lines...) Expand all Loading... |
75 return sqs.clip_rect; | 75 return sqs.clip_rect; |
76 } | 76 } |
77 | 77 |
78 static bool is_clipped(const cc::SharedQuadState& sqs) { | 78 static bool is_clipped(const cc::SharedQuadState& sqs) { |
79 return sqs.is_clipped; | 79 return sqs.is_clipped; |
80 } | 80 } |
81 | 81 |
82 static float opacity(const cc::SharedQuadState& sqs) { return sqs.opacity; } | 82 static float opacity(const cc::SharedQuadState& sqs) { return sqs.opacity; } |
83 | 83 |
84 static uint32_t blend_mode(const cc::SharedQuadState& sqs) { | 84 static uint32_t blend_mode(const cc::SharedQuadState& sqs) { |
85 return sqs.blend_mode; | 85 return static_cast<uint32_t>(sqs.blend_mode); |
86 } | 86 } |
87 | 87 |
88 static int32_t sorting_context_id(const cc::SharedQuadState& sqs) { | 88 static int32_t sorting_context_id(const cc::SharedQuadState& sqs) { |
89 return sqs.sorting_context_id; | 89 return sqs.sorting_context_id; |
90 } | 90 } |
91 | 91 |
92 static bool Read(cc::mojom::SharedQuadStateDataView data, | 92 static bool Read(cc::mojom::SharedQuadStateDataView data, |
93 cc::SharedQuadState* out) { | 93 cc::SharedQuadState* out) { |
94 if (!data.ReadQuadToTargetTransform(&out->quad_to_target_transform) || | 94 if (!data.ReadQuadToTargetTransform(&out->quad_to_target_transform) || |
95 !data.ReadQuadLayerBounds(&out->quad_layer_bounds) || | 95 !data.ReadQuadLayerBounds(&out->quad_layer_bounds) || |
96 !data.ReadVisibleQuadLayerRect(&out->visible_quad_layer_rect) || | 96 !data.ReadVisibleQuadLayerRect(&out->visible_quad_layer_rect) || |
97 !data.ReadClipRect(&out->clip_rect)) { | 97 !data.ReadClipRect(&out->clip_rect)) { |
98 return false; | 98 return false; |
99 } | 99 } |
100 | 100 |
101 out->is_clipped = data.is_clipped(); | 101 out->is_clipped = data.is_clipped(); |
102 out->opacity = data.opacity(); | 102 out->opacity = data.opacity(); |
103 if (data.blend_mode() > SkXfermode::kLastMode) | 103 if (data.blend_mode() > static_cast<int>(SkBlendMode::kLastMode)) |
104 return false; | 104 return false; |
105 out->blend_mode = static_cast<SkXfermode::Mode>(data.blend_mode()); | 105 out->blend_mode = static_cast<SkBlendMode>(data.blend_mode()); |
106 out->sorting_context_id = data.sorting_context_id(); | 106 out->sorting_context_id = data.sorting_context_id(); |
107 return true; | 107 return true; |
108 } | 108 } |
109 }; | 109 }; |
110 | 110 |
111 } // namespace mojo | 111 } // namespace mojo |
112 | 112 |
113 #endif // CC_IPC_SHARED_QUAD_STATE_STRUCT_TRAITS_H_ | 113 #endif // CC_IPC_SHARED_QUAD_STATE_STRUCT_TRAITS_H_ |
OLD | NEW |