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
, 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
{
28 void Unmap() override
{};
29 bool IsMapped() const override
{
33 gfx::BufferFormat
GetFormat() const override
{
35 return gfx::BufferFormat::R_8
;
37 void GetStride(int* stride
) const override
{
39 size_
.width() * (format_
== gfx::BufferFormat::UYVY_422
? 2 : 1);
41 gfx::GpuMemoryBufferId
GetId() const override
{
43 return gfx::GpuMemoryBufferId(0);
45 gfx::GpuMemoryBufferHandle
GetHandle() const override
{
47 return gfx::GpuMemoryBufferHandle();
49 ClientBuffer
AsClientBuffer() override
{
50 return reinterpret_cast<ClientBuffer
>(this);
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() {
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
) {
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()
98 unsigned MockGpuVideoAcceleratorFactories::ImageTextureTarget() {