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

Side by Side Diff: chrome/gpu/gpu_arc_video_service.cc

Issue 2505733003: arc: enable use_new_wrapper_types for video_accelerator.mojom (Closed)
Patch Set: Created 4 years, 1 month 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
« no previous file with comments | « chrome/gpu/gpu_arc_video_service.h ('k') | components/arc/BUILD.gn » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #include "chrome/gpu/gpu_arc_video_service.h" 5 #include "chrome/gpu/gpu_arc_video_service.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 chromeos::arc::ArcVideoAccelerator::Config result; 104 chromeos::arc::ArcVideoAccelerator::Config result;
105 result.device_type = 105 result.device_type =
106 static_cast<chromeos::arc::ArcVideoAccelerator::Config::DeviceType>( 106 static_cast<chromeos::arc::ArcVideoAccelerator::Config::DeviceType>(
107 input->device_type); 107 input->device_type);
108 result.num_input_buffers = input->num_input_buffers; 108 result.num_input_buffers = input->num_input_buffers;
109 result.input_pixel_format = input->input_pixel_format; 109 result.input_pixel_format = input->input_pixel_format;
110 return result; 110 return result;
111 } 111 }
112 }; 112 };
113 113
114 template <>
115 struct TypeConverter<chromeos::arc::ArcVideoAccelerator::DmabufPlane,
116 arc::mojom::ArcVideoAcceleratorDmabufPlanePtr> {
117 static chromeos::arc::ArcVideoAccelerator::DmabufPlane Convert(
118 const arc::mojom::ArcVideoAcceleratorDmabufPlanePtr& input) {
119 chromeos::arc::ArcVideoAccelerator::DmabufPlane result = {0};
120 if (input->offset < 0 || input->stride < 0) {
121 DVLOG(1) << "Invalid offset/stride: " << input->offset << "/"
122 << input->stride;
123 return result;
124 }
125
126 result.offset = input->offset;
127 result.stride = input->stride;
128 return result;
129 }
130 };
131
132 } // namespace mojo 114 } // namespace mojo
133 115
134 namespace chromeos { 116 namespace chromeos {
135 namespace arc { 117 namespace arc {
136 118
137 GpuArcVideoService::GpuArcVideoService( 119 GpuArcVideoService::GpuArcVideoService(
138 const gpu::GpuPreferences& gpu_preferences) 120 const gpu::GpuPreferences& gpu_preferences)
139 : gpu_preferences_(gpu_preferences), 121 : gpu_preferences_(gpu_preferences),
140 accelerator_(new ArcGpuVideoDecodeAccelerator(gpu_preferences_)) {} 122 accelerator_(new ArcGpuVideoDecodeAccelerator(gpu_preferences_)) {}
141 123
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
256 if (!fd.is_valid()) 238 if (!fd.is_valid())
257 return; 239 return;
258 accelerator_->BindSharedMemory(static_cast<PortType>(port), index, 240 accelerator_->BindSharedMemory(static_cast<PortType>(port), index,
259 std::move(fd), offset, length); 241 std::move(fd), offset, length);
260 } 242 }
261 243
262 void GpuArcVideoService::DeprecatedBindDmabuf(::arc::mojom::PortType port, 244 void GpuArcVideoService::DeprecatedBindDmabuf(::arc::mojom::PortType port,
263 uint32_t index, 245 uint32_t index,
264 mojo::ScopedHandle dmabuf_handle, 246 mojo::ScopedHandle dmabuf_handle,
265 int32_t stride) { 247 int32_t stride) {
266 mojo::Array<::arc::mojom::ArcVideoAcceleratorDmabufPlanePtr> planes(1); 248 std::vector<::arc::mojom::ArcVideoAcceleratorDmabufPlanePtr> planes(1);
267 planes[0]->offset = 0; 249 planes[0]->offset = 0;
268 planes[0]->stride = stride; 250 planes[0]->stride = stride;
269 251
270 BindDmabuf(port, index, std::move(dmabuf_handle), std::move(planes)); 252 BindDmabuf(port, index, std::move(dmabuf_handle), std::move(planes));
271 } 253 }
272 254
273 void GpuArcVideoService::BindDmabuf( 255 void GpuArcVideoService::BindDmabuf(
274 ::arc::mojom::PortType port, 256 ::arc::mojom::PortType port,
275 uint32_t index, 257 uint32_t index,
276 mojo::ScopedHandle dmabuf_handle, 258 mojo::ScopedHandle dmabuf_handle,
277 mojo::Array<::arc::mojom::ArcVideoAcceleratorDmabufPlanePtr> 259 std::vector<::arc::mojom::ArcVideoAcceleratorDmabufPlanePtr>
278 dmabuf_planes) { 260 dmabuf_planes) {
279 DVLOG(2) << "BindDmabuf port=" << port << ", index=" << index; 261 DVLOG(2) << "BindDmabuf port=" << port << ", index=" << index;
280 262
281 base::ScopedFD fd = UnwrapFdFromMojoHandle(std::move(dmabuf_handle)); 263 base::ScopedFD fd = UnwrapFdFromMojoHandle(std::move(dmabuf_handle));
282 if (!fd.is_valid()) 264 if (!fd.is_valid())
283 return; 265 return;
284 266
285 std::vector<ArcVideoAccelerator::DmabufPlane> converted_planes = 267 std::vector<ArcVideoAccelerator::DmabufPlane> converted_planes;
Luis Héctor Chávez 2016/11/16 03:04:57 It's maybe better to create a typemapping for the
Yusuke Sato 2016/11/16 06:17:49 Let me do it in a different CL. Added TODO and fil
286 dmabuf_planes.To<std::vector<ArcVideoAccelerator::DmabufPlane>>(); 268 for (const auto& input : dmabuf_planes) {
269 if (input->offset < 0 || input->stride < 0) {
270 DVLOG(1) << "Invalid offset/stride: " << input->offset << "/"
271 << input->stride;
272 converted_planes.emplace_back(0, 0);
273 } else {
274 converted_planes.emplace_back(input->offset, input->stride);
275 }
276 }
287 277
288 accelerator_->BindDmabuf(static_cast<PortType>(port), index, std::move(fd), 278 accelerator_->BindDmabuf(static_cast<PortType>(port), index, std::move(fd),
289 std::move(converted_planes)); 279 std::move(converted_planes));
290 } 280 }
291 281
292 void GpuArcVideoService::UseBuffer(::arc::mojom::PortType port, 282 void GpuArcVideoService::UseBuffer(::arc::mojom::PortType port,
293 uint32_t index, 283 uint32_t index,
294 ::arc::mojom::BufferMetadataPtr metadata) { 284 ::arc::mojom::BufferMetadataPtr metadata) {
295 DVLOG(2) << "UseBuffer port=" << port << ", index=" << index; 285 DVLOG(2) << "UseBuffer port=" << port << ", index=" << index;
296 accelerator_->UseBuffer(static_cast<PortType>(port), index, 286 accelerator_->UseBuffer(static_cast<PortType>(port), index,
(...skipping 10 matching lines...) Expand all
307 accelerator_->Reset(); 297 accelerator_->Reset();
308 } 298 }
309 299
310 void GpuArcVideoService::Flush() { 300 void GpuArcVideoService::Flush() {
311 DVLOG(2) << "Flush"; 301 DVLOG(2) << "Flush";
312 accelerator_->Flush(); 302 accelerator_->Flush();
313 } 303 }
314 304
315 } // namespace arc 305 } // namespace arc
316 } // namespace chromeos 306 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/gpu/gpu_arc_video_service.h ('k') | components/arc/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698