| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 "content/browser/renderer_host/media/video_capture_buffer_pool.h" | 5 #include "content/browser/renderer_host/media/video_capture_buffer_pool.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 | 105 |
| 106 bool Init(const gfx::Size& dimensions, | 106 bool Init(const gfx::Size& dimensions, |
| 107 media::VideoPixelFormat format, | 107 media::VideoPixelFormat format, |
| 108 media::VideoPixelStorage storage_type, | 108 media::VideoPixelStorage storage_type, |
| 109 base::Lock* lock) override { | 109 base::Lock* lock) override { |
| 110 DVLOG(2) << "allocating GMB for " << dimensions.ToString(); | 110 DVLOG(2) << "allocating GMB for " << dimensions.ToString(); |
| 111 // BrowserGpuMemoryBufferManager::current() may not be accessed on IO | 111 // BrowserGpuMemoryBufferManager::current() may not be accessed on IO |
| 112 // Thread. | 112 // Thread. |
| 113 DCHECK(!BrowserThread::CurrentlyOn(BrowserThread::IO)); | 113 DCHECK(!BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 114 DCHECK(BrowserGpuMemoryBufferManager::current()); | 114 DCHECK(BrowserGpuMemoryBufferManager::current()); |
| 115 // This class is only expected to be called with I420 buffer requests at | 115 // This class is only expected to be called with I420, Y8 or Y16 buffer |
| 116 // this point. | 116 // requests at this point. |
| 117 DCHECK_EQ(format, media::PIXEL_FORMAT_I420); | 117 DCHECK(media::PIXEL_FORMAT_I420 == format || |
| 118 media::PIXEL_FORMAT_Y8 == format || |
| 119 media::PIXEL_FORMAT_Y16 == format); |
| 118 set_dimensions(dimensions); | 120 set_dimensions(dimensions); |
| 119 set_max_pixel_count(dimensions.GetArea()); | 121 set_max_pixel_count(dimensions.GetArea()); |
| 120 set_pixel_format(format); | 122 set_pixel_format(format); |
| 121 set_storage_type(storage_type); | 123 set_storage_type(storage_type); |
| 122 // |dimensions| can be 0x0 for trackers that do not require memory backing. | 124 // |dimensions| can be 0x0 for trackers that do not require memory backing. |
| 123 if (dimensions.GetArea() == 0u) | 125 if (dimensions.GetArea() == 0u) |
| 124 return true; | 126 return true; |
| 125 | 127 |
| 126 base::AutoUnlock auto_unlock(*lock); | 128 base::AutoUnlock auto_unlock(*lock); |
| 127 const size_t num_planes = media::VideoFrame::NumPlanes(pixel_format()); | 129 const size_t num_planes = media::VideoFrame::NumPlanes(pixel_format()); |
| (...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 474 return buffer_id; | 476 return buffer_id; |
| 475 } | 477 } |
| 476 | 478 |
| 477 VideoCaptureBufferPool::Tracker* VideoCaptureBufferPool::GetTracker( | 479 VideoCaptureBufferPool::Tracker* VideoCaptureBufferPool::GetTracker( |
| 478 int buffer_id) { | 480 int buffer_id) { |
| 479 TrackerMap::const_iterator it = trackers_.find(buffer_id); | 481 TrackerMap::const_iterator it = trackers_.find(buffer_id); |
| 480 return (it == trackers_.end()) ? NULL : it->second; | 482 return (it == trackers_.end()) ? NULL : it->second; |
| 481 } | 483 } |
| 482 | 484 |
| 483 } // namespace content | 485 } // namespace content |
| OLD | NEW |