cygprofile: increase timeouts to allow showing web contents
[chromium-blink-merge.git] / media / renderers / mock_gpu_video_accelerator_factories.cc
blob5f2d64d6a484f9634ea66a886aed143256dace28
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/buffer_format_util.h"
8 #include "ui/gfx/gpu_memory_buffer.h"
10 namespace media {
12 namespace {
14 class GpuMemoryBufferImpl : public gfx::GpuMemoryBuffer {
15 public:
16 GpuMemoryBufferImpl(const gfx::Size& size, gfx::BufferFormat format)
17 : format_(format), size_(size),
18 num_planes_(gfx::NumberOfPlanesForBufferFormat(format)) {
19 DCHECK(gfx::BufferFormat::R_8 == format_ ||
20 gfx::BufferFormat::YUV_420_BIPLANAR == format_ ||
21 gfx::BufferFormat::UYVY_422 == format_);
22 DCHECK(num_planes_ <= kMaxPlanes);
23 for (int i = 0; i < static_cast<int>(num_planes_); ++i) {
24 bytes_[i].resize(
25 gfx::RowSizeForBufferFormat(size_.width(), format_, i) *
26 size_.height() / gfx::SubsamplingFactorForBufferFormat(format_, i));
30 // Overridden from gfx::GpuMemoryBuffer:
31 bool Map(void** data) override {
32 for (size_t plane = 0; plane < num_planes_; ++plane)
33 data[plane] = &bytes_[plane][0];
34 return true;
36 void Unmap() override{};
37 bool IsMapped() const override {
38 NOTREACHED();
39 return false;
41 gfx::BufferFormat GetFormat() const override {
42 return format_;
44 void GetStride(int* strides) const override {
45 for (int plane = 0; plane < static_cast<int>(num_planes_); ++plane) {
46 strides[plane] = static_cast<int>(
47 gfx::RowSizeForBufferFormat(size_.width(), format_, plane));
50 gfx::GpuMemoryBufferId GetId() const override {
51 NOTREACHED();
52 return gfx::GpuMemoryBufferId(0);
54 gfx::GpuMemoryBufferHandle GetHandle() const override {
55 NOTREACHED();
56 return gfx::GpuMemoryBufferHandle();
58 ClientBuffer AsClientBuffer() override {
59 return reinterpret_cast<ClientBuffer>(this);
62 private:
63 static const size_t kMaxPlanes = 3;
65 gfx::BufferFormat format_;
66 const gfx::Size size_;
67 size_t num_planes_;
68 std::vector<uint8> bytes_[kMaxPlanes];
71 } // unnamed namespace
73 MockGpuVideoAcceleratorFactories::MockGpuVideoAcceleratorFactories() {}
75 MockGpuVideoAcceleratorFactories::~MockGpuVideoAcceleratorFactories() {}
77 bool MockGpuVideoAcceleratorFactories::IsGpuVideoAcceleratorEnabled() {
78 return true;
81 scoped_ptr<gfx::GpuMemoryBuffer>
82 MockGpuVideoAcceleratorFactories::AllocateGpuMemoryBuffer(
83 const gfx::Size& size,
84 gfx::BufferFormat format,
85 gfx::BufferUsage usage) {
86 return make_scoped_ptr<gfx::GpuMemoryBuffer>(
87 new GpuMemoryBufferImpl(size, format));
90 scoped_ptr<base::SharedMemory>
91 MockGpuVideoAcceleratorFactories::CreateSharedMemory(size_t size) {
92 return nullptr;
95 scoped_ptr<VideoDecodeAccelerator>
96 MockGpuVideoAcceleratorFactories::CreateVideoDecodeAccelerator() {
97 return scoped_ptr<VideoDecodeAccelerator>(DoCreateVideoDecodeAccelerator());
100 scoped_ptr<VideoEncodeAccelerator>
101 MockGpuVideoAcceleratorFactories::CreateVideoEncodeAccelerator() {
102 return scoped_ptr<VideoEncodeAccelerator>(DoCreateVideoEncodeAccelerator());
105 bool MockGpuVideoAcceleratorFactories::ShouldUseGpuMemoryBuffersForVideoFrames()
106 const {
107 return false;
110 unsigned MockGpuVideoAcceleratorFactories::ImageTextureTarget() {
111 return GL_TEXTURE_2D;
114 } // namespace media