OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 // Notes about usage of this object by VideoCaptureImplManager. | 5 // Notes about usage of this object by VideoCaptureImplManager. |
6 // | 6 // |
7 // VideoCaptureImplManager access this object by using a Unretained() | 7 // VideoCaptureImplManager access this object by using a Unretained() |
8 // binding and tasks on the IO thread. It is then important that | 8 // binding and tasks on the IO thread. It is then important that |
9 // VideoCaptureImpl never post task to itself. All operations must be | 9 // VideoCaptureImpl never post task to itself. All operations must be |
10 // synchronous. | 10 // synchronous. |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 for (size_t i = 0; i < handles_.size(); ++i) { | 72 for (size_t i = 0; i < handles_.size(); ++i) { |
73 const size_t width = media::VideoFrame::Columns(i, format, size_.width()); | 73 const size_t width = media::VideoFrame::Columns(i, format, size_.width()); |
74 const size_t height = media::VideoFrame::Rows(i, format, size_.height()); | 74 const size_t height = media::VideoFrame::Rows(i, format, size_.height()); |
75 buffers_.push_back(GpuMemoryBufferImpl::CreateFromHandle( | 75 buffers_.push_back(GpuMemoryBufferImpl::CreateFromHandle( |
76 handles_[i], | 76 handles_[i], |
77 gfx::Size(width, height), | 77 gfx::Size(width, height), |
78 gfx::BufferFormat::R_8, | 78 gfx::BufferFormat::R_8, |
79 gfx::BufferUsage::MAP, | 79 gfx::BufferUsage::MAP, |
80 base::Bind(&ClientBuffer2::DestroyGpuMemoryBuffer, | 80 base::Bind(&ClientBuffer2::DestroyGpuMemoryBuffer, |
81 base::Unretained(this)))); | 81 base::Unretained(this)))); |
82 void* data_ptr = nullptr; | 82 bool rv = buffers_[i]->Map(); |
83 buffers_[i]->Map(&data_ptr); | 83 DCHECK(rv); |
84 data_[i] = reinterpret_cast<uint8*>(data_ptr); | 84 data_[i] = reinterpret_cast<uint8*>(buffers_[i]->memory(0u)); |
85 strides_[i] = width; | 85 strides_[i] = width; |
86 } | 86 } |
87 } | 87 } |
88 | 88 |
89 uint8* data(int plane) const { return data_[plane]; } | 89 uint8* data(int plane) const { return data_[plane]; } |
90 int32 stride(int plane) const { return strides_[plane]; } | 90 int32 stride(int plane) const { return strides_[plane]; } |
91 std::vector<gfx::GpuMemoryBufferHandle> gpu_memory_buffer_handles() { | 91 std::vector<gfx::GpuMemoryBufferHandle> gpu_memory_buffer_handles() { |
92 return handles_; | 92 return handles_; |
93 } | 93 } |
94 | 94 |
(...skipping 471 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
566 double consumer_resource_utilization = -1.0; | 566 double consumer_resource_utilization = -1.0; |
567 if (!metadata->GetDouble(media::VideoFrameMetadata::RESOURCE_UTILIZATION, | 567 if (!metadata->GetDouble(media::VideoFrameMetadata::RESOURCE_UTILIZATION, |
568 &consumer_resource_utilization)) { | 568 &consumer_resource_utilization)) { |
569 consumer_resource_utilization = -1.0; | 569 consumer_resource_utilization = -1.0; |
570 } | 570 } |
571 | 571 |
572 callback_to_io_thread.Run(release_sync_point, consumer_resource_utilization); | 572 callback_to_io_thread.Run(release_sync_point, consumer_resource_utilization); |
573 } | 573 } |
574 | 574 |
575 } // namespace content | 575 } // namespace content |
OLD | NEW |