Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(257)

Side by Side Diff: media/renderers/mock_gpu_video_accelerator_factories.cc

Issue 2006893002: Video Gmb Pool: Plumb GpuMemoryBufferId through to compositor (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add gmb ID support to unittests Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « media/base/video_frame.cc ('k') | media/video/gpu_memory_buffer_video_frame_pool.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 bool gpu_memory_buffers_in_use_by_window_server = false; 15 bool gpu_memory_buffers_in_use_by_window_server = false;
16 int g_next_gpu_memory_buffer_id = 1;
16 17
17 class GpuMemoryBufferImpl : public gfx::GpuMemoryBuffer { 18 class GpuMemoryBufferImpl : public gfx::GpuMemoryBuffer {
18 public: 19 public:
19 GpuMemoryBufferImpl(const gfx::Size& size, gfx::BufferFormat format) 20 GpuMemoryBufferImpl(const gfx::Size& size, gfx::BufferFormat format)
20 : mapped_(false), 21 : mapped_(false),
21 format_(format), 22 format_(format),
22 size_(size), 23 size_(size),
23 num_planes_(gfx::NumberOfPlanesForBufferFormat(format)) { 24 num_planes_(gfx::NumberOfPlanesForBufferFormat(format)),
25 id_(g_next_gpu_memory_buffer_id++) {
24 DCHECK(gfx::BufferFormat::R_8 == format_ || 26 DCHECK(gfx::BufferFormat::R_8 == format_ ||
25 gfx::BufferFormat::YUV_420_BIPLANAR == format_ || 27 gfx::BufferFormat::YUV_420_BIPLANAR == format_ ||
26 gfx::BufferFormat::UYVY_422 == format_); 28 gfx::BufferFormat::UYVY_422 == format_);
27 DCHECK(num_planes_ <= kMaxPlanes); 29 DCHECK(num_planes_ <= kMaxPlanes);
28 for (int i = 0; i < static_cast<int>(num_planes_); ++i) { 30 for (int i = 0; i < static_cast<int>(num_planes_); ++i) {
29 bytes_[i].resize( 31 bytes_[i].resize(
30 gfx::RowSizeForBufferFormat(size_.width(), format_, i) * 32 gfx::RowSizeForBufferFormat(size_.width(), format_, i) *
31 size_.height() / gfx::SubsamplingFactorForBufferFormat(format_, i)); 33 size_.height() / gfx::SubsamplingFactorForBufferFormat(format_, i));
32 } 34 }
33 } 35 }
(...skipping 18 matching lines...) Expand all
52 } 54 }
53 gfx::Size GetSize() const override { return size_; } 55 gfx::Size GetSize() const override { return size_; }
54 gfx::BufferFormat GetFormat() const override { 56 gfx::BufferFormat GetFormat() const override {
55 return format_; 57 return format_;
56 } 58 }
57 int stride(size_t plane) const override { 59 int stride(size_t plane) const override {
58 DCHECK_LT(plane, num_planes_); 60 DCHECK_LT(plane, num_planes_);
59 return static_cast<int>(gfx::RowSizeForBufferFormat( 61 return static_cast<int>(gfx::RowSizeForBufferFormat(
60 size_.width(), format_, static_cast<int>(plane))); 62 size_.width(), format_, static_cast<int>(plane)));
61 } 63 }
62 gfx::GpuMemoryBufferId GetId() const override { 64 gfx::GpuMemoryBufferId GetId() const override { return id_; }
63 NOTREACHED();
64 return gfx::GpuMemoryBufferId(0);
65 }
66 gfx::GpuMemoryBufferHandle GetHandle() const override { 65 gfx::GpuMemoryBufferHandle GetHandle() const override {
67 NOTREACHED(); 66 NOTREACHED();
68 return gfx::GpuMemoryBufferHandle(); 67 return gfx::GpuMemoryBufferHandle();
69 } 68 }
70 ClientBuffer AsClientBuffer() override { 69 ClientBuffer AsClientBuffer() override {
71 return reinterpret_cast<ClientBuffer>(this); 70 return reinterpret_cast<ClientBuffer>(this);
72 } 71 }
73 72
74 private: 73 private:
75 static const size_t kMaxPlanes = 3; 74 static const size_t kMaxPlanes = 3;
76 75
77 bool mapped_; 76 bool mapped_;
78 gfx::BufferFormat format_; 77 gfx::BufferFormat format_;
79 const gfx::Size size_; 78 const gfx::Size size_;
80 size_t num_planes_; 79 size_t num_planes_;
81 std::vector<uint8_t> bytes_[kMaxPlanes]; 80 std::vector<uint8_t> bytes_[kMaxPlanes];
81 gfx::GpuMemoryBufferId id_;
82 }; 82 };
83 83
84 } // unnamed namespace 84 } // unnamed namespace
85 85
86 MockGpuVideoAcceleratorFactories::MockGpuVideoAcceleratorFactories( 86 MockGpuVideoAcceleratorFactories::MockGpuVideoAcceleratorFactories(
87 gpu::gles2::GLES2Interface* gles2) 87 gpu::gles2::GLES2Interface* gles2)
88 : gles2_(gles2) {} 88 : gles2_(gles2) {}
89 89
90 MockGpuVideoAcceleratorFactories::~MockGpuVideoAcceleratorFactories() {} 90 MockGpuVideoAcceleratorFactories::~MockGpuVideoAcceleratorFactories() {}
91 91
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 }; 148 };
149 } // namespace 149 } // namespace
150 150
151 std::unique_ptr<GpuVideoAcceleratorFactories::ScopedGLContextLock> 151 std::unique_ptr<GpuVideoAcceleratorFactories::ScopedGLContextLock>
152 MockGpuVideoAcceleratorFactories::GetGLContextLock() { 152 MockGpuVideoAcceleratorFactories::GetGLContextLock() {
153 DCHECK(gles2_); 153 DCHECK(gles2_);
154 return base::WrapUnique(new ScopedGLContextLockImpl(this)); 154 return base::WrapUnique(new ScopedGLContextLockImpl(this));
155 } 155 }
156 156
157 } // namespace media 157 } // namespace media
OLDNEW
« no previous file with comments | « media/base/video_frame.cc ('k') | media/video/gpu_memory_buffer_video_frame_pool.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698