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_COMPOSITOR_FRAME_METADATA_STRUCT_TRAITS_H_ | |
| 6 #define CC_IPC_COMPOSITOR_FRAME_METADATA_STRUCT_TRAITS_H_ | |
| 7 | |
| 8 #include "cc/ipc/compositor_frame_metadata.mojom.h" | |
| 9 #include "cc/output/compositor_frame_metadata.h" | |
| 10 | |
| 11 namespace mojo { | |
| 12 | |
| 13 template <> | |
| 14 struct StructTraits<cc::mojom::CompositorFrameMetadata, | |
| 15 cc::CompositorFrameMetadata> { | |
| 16 static float device_scale_factor( | |
| 17 const cc::CompositorFrameMetadata& metadata) { | |
| 18 return metadata.device_scale_factor; | |
| 19 } | |
| 20 | |
| 21 static gfx::Vector2dF root_scroll_offset( | |
|
yzshen1
2016/06/06 16:22:04
Does it make sense to return a ref instead?
Fady Samuel
2016/06/06 20:00:11
I'll stick to return by value because Vector2dF is
| |
| 22 const cc::CompositorFrameMetadata& metadata) { | |
| 23 return metadata.root_scroll_offset; | |
| 24 } | |
| 25 | |
| 26 static float page_scale_factor(const cc::CompositorFrameMetadata& metadata) { | |
| 27 return metadata.page_scale_factor; | |
| 28 } | |
| 29 | |
| 30 static gfx::SizeF scrollable_viewport_size( | |
| 31 const cc::CompositorFrameMetadata& metadata) { | |
| 32 return metadata.scrollable_viewport_size; | |
| 33 } | |
| 34 | |
| 35 static gfx::SizeF root_layer_size( | |
| 36 const cc::CompositorFrameMetadata& metadata) { | |
| 37 return metadata.root_layer_size; | |
| 38 } | |
| 39 | |
| 40 static float min_page_scale_factor( | |
| 41 const cc::CompositorFrameMetadata& metadata) { | |
| 42 return metadata.min_page_scale_factor; | |
| 43 } | |
| 44 | |
| 45 static float max_page_scale_factor( | |
| 46 const cc::CompositorFrameMetadata& metadata) { | |
| 47 return metadata.max_page_scale_factor; | |
| 48 } | |
| 49 | |
| 50 static bool root_overflow_x_hidden( | |
| 51 const cc::CompositorFrameMetadata& metadata) { | |
| 52 return metadata.root_overflow_x_hidden; | |
| 53 } | |
| 54 | |
| 55 static bool root_overflow_y_hidden( | |
| 56 const cc::CompositorFrameMetadata& metadata) { | |
| 57 return metadata.root_overflow_y_hidden; | |
| 58 } | |
| 59 | |
| 60 static gfx::Vector2dF location_bar_offset( | |
| 61 const cc::CompositorFrameMetadata& metadata) { | |
| 62 return metadata.location_bar_offset; | |
| 63 } | |
| 64 | |
| 65 static gfx::Vector2dF location_bar_content_translation( | |
| 66 const cc::CompositorFrameMetadata& metadata) { | |
| 67 return metadata.location_bar_content_translation; | |
| 68 } | |
| 69 | |
| 70 static uint32_t root_background_color( | |
| 71 const cc::CompositorFrameMetadata& metadata) { | |
| 72 return metadata.root_background_color; | |
| 73 } | |
| 74 | |
| 75 static const cc::Selection<gfx::SelectionBound>& selection( | |
| 76 const cc::CompositorFrameMetadata& metadata) { | |
| 77 return metadata.selection; | |
| 78 } | |
| 79 | |
| 80 static const std::vector<ui::LatencyInfo>& latency_info( | |
| 81 const cc::CompositorFrameMetadata& metadata) { | |
| 82 return metadata.latency_info; | |
| 83 } | |
| 84 | |
| 85 static const std::vector<uint32_t>& satisfies_sequences( | |
| 86 const cc::CompositorFrameMetadata& metadata) { | |
| 87 return metadata.satisfies_sequences; | |
| 88 } | |
| 89 | |
| 90 static const std::vector<cc::SurfaceId>& referenced_surfaces( | |
| 91 const cc::CompositorFrameMetadata& metadata) { | |
| 92 return metadata.referenced_surfaces; | |
| 93 } | |
| 94 | |
| 95 static bool Read(cc::mojom::CompositorFrameMetadataDataView data, | |
| 96 cc::CompositorFrameMetadata* out) { | |
| 97 out->device_scale_factor = data.device_scale_factor(); | |
| 98 if (!data.ReadRootScrollOffset(&out->root_scroll_offset)) | |
| 99 return false; | |
| 100 | |
| 101 out->page_scale_factor = data.page_scale_factor(); | |
| 102 if (!data.ReadScrollableViewportSize(&out->scrollable_viewport_size) || | |
| 103 !data.ReadRootLayerSize(&out->root_layer_size)) { | |
| 104 return false; | |
| 105 } | |
| 106 | |
| 107 out->min_page_scale_factor = data.min_page_scale_factor(); | |
| 108 out->max_page_scale_factor = data.max_page_scale_factor(); | |
| 109 out->root_overflow_x_hidden = data.root_overflow_x_hidden(); | |
| 110 out->root_overflow_y_hidden = data.root_overflow_y_hidden(); | |
| 111 if (!data.ReadLocationBarOffset(&out->location_bar_offset) || | |
| 112 !data.ReadLocationBarContentTranslation( | |
| 113 &out->location_bar_content_translation)) { | |
| 114 return false; | |
| 115 } | |
| 116 | |
| 117 out->root_background_color = data.root_background_color(); | |
| 118 if (!data.ReadSelection(&out->selection) || | |
| 119 !data.ReadLatencyInfo(&out->latency_info) || | |
| 120 !data.ReadSatisfiesSequences(&out->satisfies_sequences) || | |
| 121 !data.ReadReferencedSurfaces(&out->referenced_surfaces)) { | |
| 122 return false; | |
| 123 } | |
| 124 return true; | |
| 125 } | |
| 126 }; | |
| 127 | |
| 128 } // namespace mojo | |
| 129 | |
| 130 #endif // CC_IPC_COMPOSITOR_FRAME_METADATA_STRUCT_TRAITS_H_ | |
| OLD | NEW |