| OLD | NEW |
| 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 Loading... |
| 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 { |
| 249 planes[0]->offset = 0; | 249 {0, stride} |
| 250 planes[0]->stride = stride; | 250 }; |
| 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. | |
| 269 for (const auto& input : dmabuf_planes) { | |
| 270 if (input->offset < 0 || input->stride < 0) { | |
| 271 DVLOG(1) << "Invalid offset/stride: " << input->offset << "/" | |
| 272 << input->stride; | |
| 273 client_->OnError( | |
| 274 ::arc::mojom::VideoAcceleratorService::Result::INVALID_ARGUMENT); | |
| 275 return; | |
| 276 } | |
| 277 converted_planes.emplace_back(input->offset, input->stride); | |
| 278 } | |
| 279 | |
| 280 accelerator_->BindDmabuf(static_cast<PortType>(port), index, std::move(fd), | 266 accelerator_->BindDmabuf(static_cast<PortType>(port), index, std::move(fd), |
| 281 std::move(converted_planes)); | 267 std::move(dmabuf_planes)); |
| 282 } | 268 } |
| 283 | 269 |
| 284 void GpuArcVideoService::UseBuffer(::arc::mojom::PortType port, | 270 void GpuArcVideoService::UseBuffer(::arc::mojom::PortType port, |
| 285 uint32_t index, | 271 uint32_t index, |
| 286 ::arc::mojom::BufferMetadataPtr metadata) { | 272 ::arc::mojom::BufferMetadataPtr metadata) { |
| 287 DVLOG(2) << "UseBuffer port=" << port << ", index=" << index; | 273 DVLOG(2) << "UseBuffer port=" << port << ", index=" << index; |
| 288 accelerator_->UseBuffer(static_cast<PortType>(port), index, | 274 accelerator_->UseBuffer(static_cast<PortType>(port), index, |
| 289 metadata.To<BufferMetadata>()); | 275 metadata.To<BufferMetadata>()); |
| 290 } | 276 } |
| 291 | 277 |
| 292 void GpuArcVideoService::SetNumberOfOutputBuffers(uint32_t number) { | 278 void GpuArcVideoService::SetNumberOfOutputBuffers(uint32_t number) { |
| 293 DVLOG(2) << "SetNumberOfOutputBuffers number=" << number; | 279 DVLOG(2) << "SetNumberOfOutputBuffers number=" << number; |
| 294 accelerator_->SetNumberOfOutputBuffers(number); | 280 accelerator_->SetNumberOfOutputBuffers(number); |
| 295 } | 281 } |
| 296 | 282 |
| 297 void GpuArcVideoService::Reset() { | 283 void GpuArcVideoService::Reset() { |
| 298 DVLOG(2) << "Reset"; | 284 DVLOG(2) << "Reset"; |
| 299 accelerator_->Reset(); | 285 accelerator_->Reset(); |
| 300 } | 286 } |
| 301 | 287 |
| 302 void GpuArcVideoService::Flush() { | 288 void GpuArcVideoService::Flush() { |
| 303 DVLOG(2) << "Flush"; | 289 DVLOG(2) << "Flush"; |
| 304 accelerator_->Flush(); | 290 accelerator_->Flush(); |
| 305 } | 291 } |
| 306 | 292 |
| 307 } // namespace arc | 293 } // namespace arc |
| 308 } // namespace chromeos | 294 } // namespace chromeos |
| OLD | NEW |