Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / media / renderers / mock_gpu_video_accelerator_factories.cc
blob1bbc7ac3f90eeb885fd1ce36f86715c903dd31be
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) : size_(size) {
16 bytes_.resize(size_.GetArea());
19 // Overridden from gfx::GpuMemoryBuffer:
20 bool Map(void** data) override {
21 data[0] = &bytes_[0];
22 return true;
24 void Unmap() override{};
25 bool IsMapped() const override {
26 NOTREACHED();
27 return false;
29 Format GetFormat() const override { return gfx::GpuMemoryBuffer::R_8; }
30 void GetStride(int* stride) const override { stride[0] = size_.width(); }
31 gfx::GpuMemoryBufferId GetId() const override {
32 NOTREACHED();
33 return 0;
35 gfx::GpuMemoryBufferHandle GetHandle() const override {
36 NOTREACHED();
37 return gfx::GpuMemoryBufferHandle();
39 ClientBuffer AsClientBuffer() override {
40 return reinterpret_cast<ClientBuffer>(this);
43 private:
44 std::vector<unsigned char> bytes_;
45 const gfx::Size size_;
48 } // unnamed namespace
50 MockGpuVideoAcceleratorFactories::MockGpuVideoAcceleratorFactories() {}
52 MockGpuVideoAcceleratorFactories::~MockGpuVideoAcceleratorFactories() {}
54 bool MockGpuVideoAcceleratorFactories::IsGpuVideoAcceleratorEnabled() {
55 return true;
58 scoped_ptr<gfx::GpuMemoryBuffer>
59 MockGpuVideoAcceleratorFactories::AllocateGpuMemoryBuffer(
60 const gfx::Size& size,
61 gfx::GpuMemoryBuffer::Format format,
62 gfx::GpuMemoryBuffer::Usage usage) {
63 DCHECK_EQ(gfx::GpuMemoryBuffer::R_8, format);
64 return make_scoped_ptr<gfx::GpuMemoryBuffer>(new GpuMemoryBufferImpl(size));
67 scoped_ptr<base::SharedMemory>
68 MockGpuVideoAcceleratorFactories::CreateSharedMemory(size_t size) {
69 return nullptr;
72 scoped_ptr<VideoDecodeAccelerator>
73 MockGpuVideoAcceleratorFactories::CreateVideoDecodeAccelerator() {
74 return scoped_ptr<VideoDecodeAccelerator>(DoCreateVideoDecodeAccelerator());
77 scoped_ptr<VideoEncodeAccelerator>
78 MockGpuVideoAcceleratorFactories::CreateVideoEncodeAccelerator() {
79 return scoped_ptr<VideoEncodeAccelerator>(DoCreateVideoEncodeAccelerator());
82 unsigned MockGpuVideoAcceleratorFactories::ImageTextureTarget() {
83 return GL_TEXTURE_2D;
86 } // namespace media