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 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
{
35 gfx::GpuMemoryBufferHandle
GetHandle() const override
{
37 return gfx::GpuMemoryBufferHandle();
39 ClientBuffer
AsClientBuffer() override
{
40 return reinterpret_cast<ClientBuffer
>(this);
44 std::vector
<unsigned char> bytes_
;
45 const gfx::Size size_
;
48 } // unnamed namespace
50 MockGpuVideoAcceleratorFactories::MockGpuVideoAcceleratorFactories() {}
52 MockGpuVideoAcceleratorFactories::~MockGpuVideoAcceleratorFactories() {}
54 bool MockGpuVideoAcceleratorFactories::IsGpuVideoAcceleratorEnabled() {
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
) {
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() {