Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(222)

Side by Side Diff: cc/ipc/compositor_frame_metadata_struct_traits.h

Issue 2965103003: Test
Patch Set: c Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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_COMPOSITOR_FRAME_METADATA_STRUCT_TRAITS_H_ 5 #ifndef CC_IPC_COMPOSITOR_FRAME_METADATA_STRUCT_TRAITS_H_
6 #define CC_IPC_COMPOSITOR_FRAME_METADATA_STRUCT_TRAITS_H_ 6 #define CC_IPC_COMPOSITOR_FRAME_METADATA_STRUCT_TRAITS_H_
7 7
8 #include "cc/ipc/compositor_frame_metadata.mojom-shared.h" 8 #include "cc/ipc/compositor_frame_metadata.mojom.h"
9 #include "cc/output/compositor_frame_metadata.h" 9 #include "cc/output/compositor_frame_metadata.h"
10 #include "mojo/public/cpp/system/platform_handle.h"
10 11
11 namespace mojo { 12 namespace mojo {
12 13
13 template <> 14 template <>
14 struct StructTraits<cc::mojom::CompositorFrameMetadataDataView, 15 struct StructTraits<cc::mojom::CompositorFrameMetadataDataView,
15 cc::CompositorFrameMetadata> { 16 cc::CompositorFrameMetadata> {
16 static float device_scale_factor( 17 static float device_scale_factor(
17 const cc::CompositorFrameMetadata& metadata) { 18 const cc::CompositorFrameMetadata& metadata) {
18 return metadata.device_scale_factor; 19 return metadata.device_scale_factor;
19 } 20 }
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 124
124 static const cc::BeginFrameAck& begin_frame_ack( 125 static const cc::BeginFrameAck& begin_frame_ack(
125 const cc::CompositorFrameMetadata& metadata) { 126 const cc::CompositorFrameMetadata& metadata) {
126 return metadata.begin_frame_ack; 127 return metadata.begin_frame_ack;
127 } 128 }
128 129
129 static uint32_t frame_token(const cc::CompositorFrameMetadata& metadata) { 130 static uint32_t frame_token(const cc::CompositorFrameMetadata& metadata) {
130 return metadata.frame_token; 131 return metadata.frame_token;
131 } 132 }
132 133
134 static std::vector<cc::mojom::SharedBitmapInfoPtr>& shared_bitmaps_to_register (
135 const cc::CompositorFrameMetadata& metadata, void* context) {
136 static std::vector<cc::mojom::SharedBitmapInfoPtr> empty_vector;
137 if (!context)
138 return empty_vector;
139 return *static_cast<std::vector<cc::mojom::SharedBitmapInfoPtr>*>(context);
140 }
141
142 static void* SetUpContext(const cc::CompositorFrameMetadata& metadata) {
143 if (metadata.shared_bitmaps_to_register.empty())
144 return nullptr;
145 auto* result = new std::vector<cc::mojom::SharedBitmapInfoPtr>();
146 for (const auto& info : metadata.shared_bitmaps_to_register) {
147 mojo::ScopedSharedBufferHandle buffer_handle = mojo::WrapSharedMemoryHandl e(
148 info.handle, info.size, true /* read_only */);
149 DCHECK(buffer_handle.is_valid());
150 result->push_back(cc::mojom::SharedBitmapInfo::New(std::move(buffer_handle ), info.id));
151 }
152 return result;
153 }
154 static void TearDownContext(const cc::CompositorFrameMetadata& metadata,
155 void* context) {
156 if (context)
157 delete static_cast<std::vector<cc::mojom::SharedBitmapInfoPtr>*>(context);
158 }
159
133 static bool Read(cc::mojom::CompositorFrameMetadataDataView data, 160 static bool Read(cc::mojom::CompositorFrameMetadataDataView data,
134 cc::CompositorFrameMetadata* out); 161 cc::CompositorFrameMetadata* out);
135 }; 162 };
136 163
137 } // namespace mojo 164 } // namespace mojo
138 165
139 #endif // CC_IPC_COMPOSITOR_FRAME_METADATA_STRUCT_TRAITS_H_ 166 #endif // CC_IPC_COMPOSITOR_FRAME_METADATA_STRUCT_TRAITS_H_
OLDNEW
« no previous file with comments | « cc/ipc/compositor_frame_metadata.mojom ('k') | cc/ipc/compositor_frame_metadata_struct_traits.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698