Revert "Reland c91b178b07b0d - Delete dead signin code (SigninGlobalError)"
[chromium-blink-merge.git] / media / renderers / mock_gpu_video_accelerator_factories.cc
blob5230cdde6d8df0aa199ff485d54e44194725fb2b
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
3 // found in the LICENSE file.
5 #include "media/renderers/mock_gpu_video_accelerator_factories.h"
7 #include "ui/gfx/gpu_memory_buffer.h"
9 namespace media {
11 namespace {
13 class GpuMemoryBufferImpl : public gfx::GpuMemoryBuffer {
14 public:
15 GpuMemoryBufferImpl(const gfx::Size& size, gfx::BufferFormat format)
16 : format_(format), size_(size) {
17 DCHECK(gfx::BufferFormat::R_8 == format_ ||
18 gfx::BufferFormat::UYVY_422 == format_);
19 bytes_.resize(size_.GetArea() *
20 (format_ == gfx::BufferFormat::UYVY_422 ? 2 : 1));
23 // Overridden from gfx::GpuMemoryBuffer:
24 bool Map(void** data) override {
25 data[0] = &bytes_[0];
26 return true;
28 void Unmap() override{};
29 bool IsMapped() const override {
30 NOTREACHED();
31 return false;
33 gfx::BufferFormat GetFormat() const override {
34 NOTREACHED();
35 return gfx::BufferFormat::R_8;
37 void GetStride(int* stride) const override {
38 stride[0] =
39 size_.width() * (format_ == gfx::BufferFormat::UYVY_422 ? 2 : 1);
41 gfx::GpuMemoryBufferId GetId() const override {
42 NOTREACHED();
43 return gfx::GpuMemoryBufferId(0);
45 gfx::GpuMemoryBufferHandle GetHandle() const override {
46 NOTREACHED();
47 return gfx::GpuMemoryBufferHandle();
49 ClientBuffer AsClientBuffer() override {
50 return reinterpret_cast<ClientBuffer>(this);
53 private:
54 gfx::BufferFormat format_;
55 std::vector<unsigned char> bytes_;
56 const gfx::Size size_;
59 } // unnamed namespace
61 MockGpuVideoAcceleratorFactories::MockGpuVideoAcceleratorFactories() {}
63 MockGpuVideoAcceleratorFactories::~MockGpuVideoAcceleratorFactories() {}
65 bool MockGpuVideoAcceleratorFactories::IsGpuVideoAcceleratorEnabled() {
66 return true;
69 scoped_ptr<gfx::GpuMemoryBuffer>
70 MockGpuVideoAcceleratorFactories::AllocateGpuMemoryBuffer(
71 const gfx::Size& size,
72 gfx::BufferFormat format,
73 gfx::BufferUsage usage) {
74 return make_scoped_ptr<gfx::GpuMemoryBuffer>(
75 new GpuMemoryBufferImpl(size, format));
78 scoped_ptr<base::SharedMemory>
79 MockGpuVideoAcceleratorFactories::CreateSharedMemory(size_t size) {
80 return nullptr;
83 scoped_ptr<VideoDecodeAccelerator>
84 MockGpuVideoAcceleratorFactories::CreateVideoDecodeAccelerator() {
85 return scoped_ptr<VideoDecodeAccelerator>(DoCreateVideoDecodeAccelerator());
88 scoped_ptr<VideoEncodeAccelerator>
89 MockGpuVideoAcceleratorFactories::CreateVideoEncodeAccelerator() {
90 return scoped_ptr<VideoEncodeAccelerator>(DoCreateVideoEncodeAccelerator());
93 bool MockGpuVideoAcceleratorFactories::ShouldUseGpuMemoryBuffersForVideoFrames()
94 const {
95 return false;
98 unsigned MockGpuVideoAcceleratorFactories::ImageTextureTarget() {
99 return GL_TEXTURE_2D;
102 } // namespace media