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

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

Issue 2513973002: Use mojo typemap to simplify the code using DmabufPlane (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
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 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 if (!fd.is_valid()) 238 if (!fd.is_valid())
239 return; 239 return;
240 accelerator_->BindSharedMemory(static_cast<PortType>(port), index, 240 accelerator_->BindSharedMemory(static_cast<PortType>(port), index,
241 std::move(fd), offset, length); 241 std::move(fd), offset, length);
242 } 242 }
243 243
244 void GpuArcVideoService::DeprecatedBindDmabuf(::arc::mojom::PortType port, 244 void GpuArcVideoService::DeprecatedBindDmabuf(::arc::mojom::PortType port,
245 uint32_t index, 245 uint32_t index,
246 mojo::ScopedHandle dmabuf_handle, 246 mojo::ScopedHandle dmabuf_handle,
247 int32_t stride) { 247 int32_t stride) {
248 std::vector<::arc::mojom::ArcVideoAcceleratorDmabufPlanePtr> planes(1); 248 std::vector<::arc::ArcVideoAcceleratorDmabufPlane> planes(1);
Luis Héctor Chávez 2016/11/29 18:25:35 You can maybe directly initialize the plane with a
yoshiki 2016/11/30 17:25:44 Done.
249 planes[0]->offset = 0; 249 planes[0].offset = 0;
250 planes[0]->stride = stride; 250 planes[0].stride = stride;
251 251
252 BindDmabuf(port, index, std::move(dmabuf_handle), std::move(planes)); 252 BindDmabuf(port, index, std::move(dmabuf_handle), std::move(planes));
253 } 253 }
254 254
255 void GpuArcVideoService::BindDmabuf( 255 void GpuArcVideoService::BindDmabuf(
256 ::arc::mojom::PortType port, 256 ::arc::mojom::PortType port,
257 uint32_t index, 257 uint32_t index,
258 mojo::ScopedHandle dmabuf_handle, 258 mojo::ScopedHandle dmabuf_handle,
259 std::vector<::arc::mojom::ArcVideoAcceleratorDmabufPlanePtr> 259 std::vector<::arc::ArcVideoAcceleratorDmabufPlane> dmabuf_planes) {
260 dmabuf_planes) {
261 DVLOG(2) << "BindDmabuf port=" << port << ", index=" << index; 260 DVLOG(2) << "BindDmabuf port=" << port << ", index=" << index;
262 261
263 base::ScopedFD fd = UnwrapFdFromMojoHandle(std::move(dmabuf_handle)); 262 base::ScopedFD fd = UnwrapFdFromMojoHandle(std::move(dmabuf_handle));
264 if (!fd.is_valid()) 263 if (!fd.is_valid())
265 return; 264 return;
266 265
267 std::vector<ArcVideoAccelerator::DmabufPlane> converted_planes;
268 // TODO(yusukes): Use mojo typemaps to simplify the code. 266 // TODO(yusukes): Use mojo typemaps to simplify the code.
Luis Héctor Chávez 2016/11/29 18:25:35 you can now safely remove this, and the whole L267
yoshiki 2016/11/30 17:25:44 Done.
269 for (const auto& input : dmabuf_planes) { 267 for (const auto& input : dmabuf_planes) {
270 if (input->offset < 0 || input->stride < 0) { 268 if (input.offset < 0 || input.stride < 0) {
271 DVLOG(1) << "Invalid offset/stride: " << input->offset << "/" 269 DVLOG(1) << "Invalid offset/stride: " << input.offset << "/"
272 << input->stride; 270 << input.stride;
273 client_->OnError( 271 client_->OnError(
274 ::arc::mojom::VideoAcceleratorService::Result::INVALID_ARGUMENT); 272 ::arc::mojom::VideoAcceleratorService::Result::INVALID_ARGUMENT);
275 return; 273 return;
276 } 274 }
277 converted_planes.emplace_back(input->offset, input->stride);
278 } 275 }
279 276
280 accelerator_->BindDmabuf(static_cast<PortType>(port), index, std::move(fd), 277 accelerator_->BindDmabuf(static_cast<PortType>(port), index, std::move(fd),
281 std::move(converted_planes)); 278 std::move(dmabuf_planes));
282 } 279 }
283 280
284 void GpuArcVideoService::UseBuffer(::arc::mojom::PortType port, 281 void GpuArcVideoService::UseBuffer(::arc::mojom::PortType port,
285 uint32_t index, 282 uint32_t index,
286 ::arc::mojom::BufferMetadataPtr metadata) { 283 ::arc::mojom::BufferMetadataPtr metadata) {
287 DVLOG(2) << "UseBuffer port=" << port << ", index=" << index; 284 DVLOG(2) << "UseBuffer port=" << port << ", index=" << index;
288 accelerator_->UseBuffer(static_cast<PortType>(port), index, 285 accelerator_->UseBuffer(static_cast<PortType>(port), index,
289 metadata.To<BufferMetadata>()); 286 metadata.To<BufferMetadata>());
290 } 287 }
291 288
292 void GpuArcVideoService::SetNumberOfOutputBuffers(uint32_t number) { 289 void GpuArcVideoService::SetNumberOfOutputBuffers(uint32_t number) {
293 DVLOG(2) << "SetNumberOfOutputBuffers number=" << number; 290 DVLOG(2) << "SetNumberOfOutputBuffers number=" << number;
294 accelerator_->SetNumberOfOutputBuffers(number); 291 accelerator_->SetNumberOfOutputBuffers(number);
295 } 292 }
296 293
297 void GpuArcVideoService::Reset() { 294 void GpuArcVideoService::Reset() {
298 DVLOG(2) << "Reset"; 295 DVLOG(2) << "Reset";
299 accelerator_->Reset(); 296 accelerator_->Reset();
300 } 297 }
301 298
302 void GpuArcVideoService::Flush() { 299 void GpuArcVideoService::Flush() {
303 DVLOG(2) << "Flush"; 300 DVLOG(2) << "Flush";
304 accelerator_->Flush(); 301 accelerator_->Flush();
305 } 302 }
306 303
307 } // namespace arc 304 } // namespace arc
308 } // namespace chromeos 305 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698