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"
13 class GpuMemoryBufferImpl
: public gfx::GpuMemoryBuffer
{
15 GpuMemoryBufferImpl(const gfx::Size
& size
) : size_(size
) {
16 bytes_
.resize(size_
.GetArea());
19 // Overridden from gfx::GpuMemoryBuffer:
20 bool Map(void** data
) override
{
24 void Unmap() override
{};
25 bool IsMapped() const override
{
29 gfx::BufferFormat
GetFormat() const override
{
30 return gfx::BufferFormat::R_8
;
32 void GetStride(int* stride
) const override
{ stride
[0] = size_
.width(); }
33 gfx::GpuMemoryBufferId
GetId() const override
{
37 gfx::GpuMemoryBufferHandle
GetHandle() const override
{
39 return gfx::GpuMemoryBufferHandle();
41 ClientBuffer
AsClientBuffer() override
{
42 return reinterpret_cast<ClientBuffer
>(this);
46 std::vector
<unsigned char> bytes_
;
47 const gfx::Size size_
;
50 } // unnamed namespace
52 MockGpuVideoAcceleratorFactories::MockGpuVideoAcceleratorFactories() {}
54 MockGpuVideoAcceleratorFactories::~MockGpuVideoAcceleratorFactories() {}
56 bool MockGpuVideoAcceleratorFactories::IsGpuVideoAcceleratorEnabled() {
60 scoped_ptr
<gfx::GpuMemoryBuffer
>
61 MockGpuVideoAcceleratorFactories::AllocateGpuMemoryBuffer(
62 const gfx::Size
& size
,
63 gfx::BufferFormat format
,
64 gfx::BufferUsage usage
) {
65 DCHECK(gfx::BufferFormat::R_8
== format
);
66 return make_scoped_ptr
<gfx::GpuMemoryBuffer
>(new GpuMemoryBufferImpl(size
));
69 scoped_ptr
<base::SharedMemory
>
70 MockGpuVideoAcceleratorFactories::CreateSharedMemory(size_t size
) {
74 scoped_ptr
<VideoDecodeAccelerator
>
75 MockGpuVideoAcceleratorFactories::CreateVideoDecodeAccelerator() {
76 return scoped_ptr
<VideoDecodeAccelerator
>(DoCreateVideoDecodeAccelerator());
79 scoped_ptr
<VideoEncodeAccelerator
>
80 MockGpuVideoAcceleratorFactories::CreateVideoEncodeAccelerator() {
81 return scoped_ptr
<VideoEncodeAccelerator
>(DoCreateVideoEncodeAccelerator());
84 unsigned MockGpuVideoAcceleratorFactories::ImageTextureTarget() {