Chromium Code Reviews| 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, cc::SharedQuadState> { | |
| 15 static gfx::Transform quad_to_target_transform( | |
| 16 const cc::SharedQuadState& sqs) { | |
| 17 return sqs.quad_to_target_transform; | |
| 18 } | |
| 19 | |
| 20 static gfx::Size quad_layer_bounds(const cc::SharedQuadState& sqs) { | |
| 21 return sqs.quad_layer_bounds; | |
| 22 } | |
| 23 | |
| 24 static gfx::Rect visible_quad_layer_rect(const cc::SharedQuadState& sqs) { | |
| 25 return sqs.visible_quad_layer_rect; | |
| 26 } | |
| 27 | |
| 28 static gfx::Rect clip_rect(const cc::SharedQuadState& sqs) { | |
| 29 return sqs.clip_rect; | |
| 30 } | |
| 31 | |
| 32 static bool is_clipped(const cc::SharedQuadState& sqs) { | |
| 33 return sqs.is_clipped; | |
| 34 } | |
| 35 | |
| 36 static float opacity(const cc::SharedQuadState& sqs) { return sqs.opacity; } | |
| 37 | |
| 38 static int32_t blend_mode(const cc::SharedQuadState& sqs) { | |
| 39 return sqs.blend_mode; | |
| 40 } | |
| 41 | |
| 42 static int32_t sorting_context_id(const cc::SharedQuadState& sqs) { | |
| 43 return sqs.sorting_context_id; | |
| 44 } | |
| 45 | |
| 46 static bool Read(cc::mojom::SharedQuadStateDataView data, | |
| 47 cc::SharedQuadState* out) { | |
| 48 if (!data.ReadQuadToTargetTransform(&out->quad_to_target_transform) || | |
| 49 !data.ReadQuadLayerBounds(&out->quad_layer_bounds) || | |
| 50 !data.ReadVisibleQuadLayerRect(&out->visible_quad_layer_rect) || | |
| 51 !data.ReadClipRect(&out->clip_rect)) { | |
| 52 return false; | |
| 53 } | |
| 54 | |
| 55 out->is_clipped = data.is_clipped(); | |
| 56 out->opacity = data.opacity(); | |
| 57 out->blend_mode = static_cast<SkXfermode::Mode>(data.blend_mode()); | |
|
Tom Sepez
2016/06/03 16:48:22
You need to manually validate that blend_mode is w
Fady Samuel
2016/06/03 18:01:55
Added DCHECK. Done.
Ken Rockot(use gerrit already)
2016/06/03 18:03:44
Drive-by comment: DCHECK is not validation. This s
| |
| 58 out->sorting_context_id = data.sorting_context_id(); | |
| 59 return true; | |
| 60 } | |
| 61 }; | |
| 62 | |
| 63 } // namespace mojo | |
| 64 | |
| 65 #endif // CC_IPC_SHARED_QUAD_STATE_STRUCT_TRAITS_H_ | |
| OLD | NEW |