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 #ifndef CC_IPC_SHARED_QUAD_STATE_STRUCT_TRAITS_H_ |
| 6 #define CC_IPC_SHARED_QUAD_STATE_STRUCT_TRAITS_H_ |
| 7 |
| 8 #include "cc/ipc/shared_quad_state.mojom.h" |
| 9 #include "cc/quads/shared_quad_state.h" |
| 10 |
| 11 namespace mojo { |
| 12 |
| 13 template <> |
| 14 struct StructTraits<cc::mojom::SharedQuadState, |
| 15 std::unique_ptr<cc::SharedQuadState>> { |
| 16 static gfx::Transform quad_to_target_transform( |
| 17 const std::unique_ptr<cc::SharedQuadState>& sqs) { |
| 18 return sqs->quad_to_target_transform; |
| 19 } |
| 20 |
| 21 static gfx::Size quad_layer_bounds( |
| 22 const std::unique_ptr<cc::SharedQuadState>& sqs) { |
| 23 return sqs->quad_layer_bounds; |
| 24 } |
| 25 |
| 26 static gfx::Rect visible_quad_layer_rect( |
| 27 const std::unique_ptr<cc::SharedQuadState>& sqs) { |
| 28 return sqs->visible_quad_layer_rect; |
| 29 } |
| 30 |
| 31 static gfx::Rect clip_rect(const std::unique_ptr<cc::SharedQuadState>& sqs) { |
| 32 return sqs->clip_rect; |
| 33 } |
| 34 |
| 35 static bool is_clipped(const std::unique_ptr<cc::SharedQuadState>& sqs) { |
| 36 return sqs->is_clipped; |
| 37 } |
| 38 |
| 39 static float opacity(const std::unique_ptr<cc::SharedQuadState>& sqs) { |
| 40 return sqs->opacity; |
| 41 } |
| 42 |
| 43 static cc::mojom::SkXfermode blend_mode( |
| 44 const std::unique_ptr<cc::SharedQuadState>& sqs) { |
| 45 return static_cast<cc::mojom::SkXfermode>(sqs->blend_mode); |
| 46 } |
| 47 |
| 48 static int32_t sorting_context_id( |
| 49 const std::unique_ptr<cc::SharedQuadState>& sqs) { |
| 50 return sqs->sorting_context_id; |
| 51 } |
| 52 |
| 53 static bool Read(cc::mojom::SharedQuadStateDataView data, |
| 54 std::unique_ptr<cc::SharedQuadState>* out) { |
| 55 std::unique_ptr<cc::SharedQuadState> sqs(new cc::SharedQuadState()); |
| 56 if (!data.ReadQuadToTargetTransform(&sqs->quad_to_target_transform) || |
| 57 !data.ReadQuadLayerBounds(&sqs->quad_layer_bounds) || |
| 58 !data.ReadVisibleQuadLayerRect(&sqs->visible_quad_layer_rect) || |
| 59 !data.ReadClipRect(&sqs->clip_rect)) { |
| 60 return false; |
| 61 } |
| 62 |
| 63 sqs->is_clipped = data.is_clipped(); |
| 64 sqs->opacity = data.opacity(); |
| 65 sqs->blend_mode = static_cast<SkXfermode::Mode>(data.blend_mode()); |
| 66 sqs->sorting_context_id = data.sorting_context_id(); |
| 67 *out = std::move(sqs); |
| 68 return true; |
| 69 } |
| 70 }; |
| 71 |
| 72 } // namespace mojo |
| 73 |
| 74 #endif // CC_IPC_SHARED_QUAD_STATE_STRUCT_TRAITS_H_ |
OLD | NEW |