| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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 "media/renderers/mock_gpu_video_accelerator_factories.h" | 5 #include "media/renderers/mock_gpu_video_accelerator_factories.h" |
| 6 | 6 |
| 7 #include "base/memory/ptr_util.h" | 7 #include "base/memory/ptr_util.h" |
| 8 #include "ui/gfx/buffer_format_util.h" | 8 #include "ui/gfx/buffer_format_util.h" |
| 9 #include "ui/gfx/gpu_memory_buffer.h" | 9 #include "ui/gfx/gpu_memory_buffer.h" |
| 10 | 10 |
| 11 namespace media { | 11 namespace media { |
| 12 | 12 |
| 13 namespace { | 13 namespace { |
| 14 | 14 |
| 15 int g_next_gpu_memory_buffer_id = 1; | 15 int g_next_gpu_memory_buffer_id = 1; |
| 16 | 16 |
| 17 class GpuMemoryBufferImpl : public gfx::GpuMemoryBuffer { | 17 class GpuMemoryBufferImpl : public gfx::GpuMemoryBuffer { |
| 18 public: | 18 public: |
| 19 GpuMemoryBufferImpl(const gfx::Size& size, gfx::BufferFormat format) | 19 GpuMemoryBufferImpl(const gfx::Size& size, gfx::BufferFormat format) |
| 20 : mapped_(false), | 20 : mapped_(false), |
| 21 format_(format), | 21 format_(format), |
| 22 size_(size), | 22 size_(size), |
| 23 num_planes_(gfx::NumberOfPlanesForBufferFormat(format)), | 23 num_planes_(gfx::NumberOfPlanesForBufferFormat(format)), |
| 24 id_(g_next_gpu_memory_buffer_id++) { | 24 id_(g_next_gpu_memory_buffer_id++) { |
| 25 DCHECK(gfx::BufferFormat::R_8 == format_ || | 25 DCHECK(gfx::BufferFormat::R_8 == format_ || |
| 26 gfx::BufferFormat::RG_88 == format_ || | 26 gfx::BufferFormat::RG_88 == format_ || |
| 27 gfx::BufferFormat::YUV_420_BIPLANAR == format_ || | 27 gfx::BufferFormat::YUV_420_BIPLANAR == format_ || |
| 28 gfx::BufferFormat::UYVY_422 == format_); | 28 gfx::BufferFormat::UYVY_422 == format_ || |
| 29 gfx::BufferFormat::YUYV_422 == format_); |
| 29 DCHECK(num_planes_ <= kMaxPlanes); | 30 DCHECK(num_planes_ <= kMaxPlanes); |
| 30 for (int i = 0; i < static_cast<int>(num_planes_); ++i) { | 31 for (int i = 0; i < static_cast<int>(num_planes_); ++i) { |
| 31 bytes_[i].resize( | 32 bytes_[i].resize( |
| 32 gfx::RowSizeForBufferFormat(size_.width(), format_, i) * | 33 gfx::RowSizeForBufferFormat(size_.width(), format_, i) * |
| 33 size_.height() / gfx::SubsamplingFactorForBufferFormat(format_, i)); | 34 size_.height() / gfx::SubsamplingFactorForBufferFormat(format_, i)); |
| 34 } | 35 } |
| 35 } | 36 } |
| 36 | 37 |
| 37 // Overridden from gfx::GpuMemoryBuffer: | 38 // Overridden from gfx::GpuMemoryBuffer: |
| 38 bool Map() override { | 39 bool Map() override { |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 }; | 144 }; |
| 144 } // namespace | 145 } // namespace |
| 145 | 146 |
| 146 std::unique_ptr<GpuVideoAcceleratorFactories::ScopedGLContextLock> | 147 std::unique_ptr<GpuVideoAcceleratorFactories::ScopedGLContextLock> |
| 147 MockGpuVideoAcceleratorFactories::GetGLContextLock() { | 148 MockGpuVideoAcceleratorFactories::GetGLContextLock() { |
| 148 DCHECK(gles2_); | 149 DCHECK(gles2_); |
| 149 return base::MakeUnique<ScopedGLContextLockImpl>(this); | 150 return base::MakeUnique<ScopedGLContextLockImpl>(this); |
| 150 } | 151 } |
| 151 | 152 |
| 152 } // namespace media | 153 } // namespace media |
| OLD | NEW |