| 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 "content/browser/renderer_host/media/gpu_memory_buffer_tracker.h" | 5 #include "content/browser/renderer_host/media/gpu_memory_buffer_tracker.h" |
| 6 | 6 |
| 7 #include "base/memory/ptr_util.h" | 7 #include "base/memory/ptr_util.h" |
| 8 #include "content/browser/gpu/browser_gpu_memory_buffer_manager.h" | 8 #include "content/browser/gpu/browser_gpu_memory_buffer_manager.h" |
| 9 #include "content/browser/renderer_host/media/gpu_memory_buffer_handle.h" | 9 #include "content/browser/renderer_host/media/gpu_memory_buffer_handle.h" |
| 10 #include "content/public/browser/browser_thread.h" | 10 #include "content/public/browser/browser_thread.h" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 | 22 |
| 23 bool GpuMemoryBufferTracker::Init(const gfx::Size& dimensions, | 23 bool GpuMemoryBufferTracker::Init(const gfx::Size& dimensions, |
| 24 media::VideoPixelFormat format, | 24 media::VideoPixelFormat format, |
| 25 media::VideoPixelStorage storage_type, | 25 media::VideoPixelStorage storage_type, |
| 26 base::Lock* lock) { | 26 base::Lock* lock) { |
| 27 DVLOG(2) << "allocating GMB for " << dimensions.ToString(); | 27 DVLOG(2) << "allocating GMB for " << dimensions.ToString(); |
| 28 // BrowserGpuMemoryBufferManager::current() may not be accessed on IO | 28 // BrowserGpuMemoryBufferManager::current() may not be accessed on IO |
| 29 // Thread. | 29 // Thread. |
| 30 DCHECK(!BrowserThread::CurrentlyOn(BrowserThread::IO)); | 30 DCHECK(!BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 31 DCHECK(BrowserGpuMemoryBufferManager::current()); | 31 DCHECK(BrowserGpuMemoryBufferManager::current()); |
| 32 // This class is only expected to be called with I420 buffer requests at | 32 // This class is only expected to be called with I420 or Y16 buffer requests |
| 33 // this point. | 33 // at this point. |
| 34 DCHECK_EQ(format, media::PIXEL_FORMAT_I420); | 34 DCHECK(media::PIXEL_FORMAT_I420 == format || |
| 35 media::PIXEL_FORMAT_Y16 == format); |
| 35 set_dimensions(dimensions); | 36 set_dimensions(dimensions); |
| 36 set_max_pixel_count(dimensions.GetArea()); | 37 set_max_pixel_count(dimensions.GetArea()); |
| 37 set_pixel_format(format); | 38 set_pixel_format(format); |
| 38 set_storage_type(storage_type); | 39 set_storage_type(storage_type); |
| 39 // |dimensions| can be 0x0 for trackers that do not require memory backing. | 40 // |dimensions| can be 0x0 for trackers that do not require memory backing. |
| 40 if (dimensions.GetArea() == 0u) | 41 if (dimensions.GetArea() == 0u) |
| 41 return true; | 42 return true; |
| 42 | 43 |
| 43 base::AutoUnlock auto_unlock(*lock); | 44 base::AutoUnlock auto_unlock(*lock); |
| 44 const size_t num_planes = media::VideoFrame::NumPlanes(pixel_format()); | 45 const size_t num_planes = media::VideoFrame::NumPlanes(pixel_format()); |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 case gfx::IO_SURFACE_BUFFER: | 97 case gfx::IO_SURFACE_BUFFER: |
| 97 case gfx::OZONE_NATIVE_PIXMAP: | 98 case gfx::OZONE_NATIVE_PIXMAP: |
| 98 *new_handle = current_gmb_handle; | 99 *new_handle = current_gmb_handle; |
| 99 return true; | 100 return true; |
| 100 } | 101 } |
| 101 NOTREACHED(); | 102 NOTREACHED(); |
| 102 return true; | 103 return true; |
| 103 } | 104 } |
| 104 | 105 |
| 105 } // namespace content | 106 } // namespace content |
| OLD | NEW |