Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(73)

Side by Side Diff: media/renderers/mock_gpu_video_accelerator_factories.cc

Issue 1316493004: Add support for converting I420 software frames into NV12 hardware frames (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@snapshot
Patch Set: Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « media/base/video_frame.cc ('k') | media/video/gpu_memory_buffer_video_frame_pool.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "media/renderers/mock_gpu_video_accelerator_factories.h" 5 #include "media/renderers/mock_gpu_video_accelerator_factories.h"
6 6
7 #include "ui/gfx/buffer_format_util.h"
7 #include "ui/gfx/gpu_memory_buffer.h" 8 #include "ui/gfx/gpu_memory_buffer.h"
8 9
9 namespace media { 10 namespace media {
10 11
11 namespace { 12 namespace {
12 13
13 class GpuMemoryBufferImpl : public gfx::GpuMemoryBuffer { 14 class GpuMemoryBufferImpl : public gfx::GpuMemoryBuffer {
14 public: 15 public:
15 GpuMemoryBufferImpl(const gfx::Size& size, gfx::BufferFormat format) 16 GpuMemoryBufferImpl(const gfx::Size& size, gfx::BufferFormat format)
16 : format_(format), size_(size) { 17 : format_(format), size_(size) {
17 DCHECK(gfx::BufferFormat::R_8 == format_ || 18 DCHECK(gfx::BufferFormat::R_8 == format_ ||
19 gfx::BufferFormat::YUV_420_BIPLANAR == format_ ||
18 gfx::BufferFormat::UYVY_422 == format_); 20 gfx::BufferFormat::UYVY_422 == format_);
19 bytes_.resize(size_.GetArea() * 21 DCHECK(NumPlanes() <= kMaxPlanes);
20 (format_ == gfx::BufferFormat::UYVY_422 ? 2 : 1)); 22 for (size_t plane = 0; plane < NumPlanes(); ++plane)
23 bytes_[plane].resize(size_.GetArea() * BytesPerElement());
21 } 24 }
22 25
23 // Overridden from gfx::GpuMemoryBuffer: 26 // Overridden from gfx::GpuMemoryBuffer:
24 bool Map(void** data) override { 27 bool Map(void** data) override {
25 data[0] = &bytes_[0]; 28 for (size_t plane = 0; plane < NumPlanes(); ++plane)
29 data[plane] = &bytes_[plane][0];
26 return true; 30 return true;
27 } 31 }
28 void Unmap() override{}; 32 void Unmap() override{};
29 bool IsMapped() const override { 33 bool IsMapped() const override {
30 NOTREACHED(); 34 NOTREACHED();
31 return false; 35 return false;
32 } 36 }
33 gfx::BufferFormat GetFormat() const override { 37 gfx::BufferFormat GetFormat() const override {
34 NOTREACHED(); 38 return format_;
35 return gfx::BufferFormat::R_8;
36 } 39 }
37 void GetStride(int* stride) const override { 40 void GetStride(int* strides) const override {
38 stride[0] = 41 for (size_t plane = 0; plane < NumPlanes(); ++plane)
39 size_.width() * (format_ == gfx::BufferFormat::UYVY_422 ? 2 : 1); 42 strides[plane] = size_.width() * BytesPerElement();
40 } 43 }
41 gfx::GpuMemoryBufferId GetId() const override { 44 gfx::GpuMemoryBufferId GetId() const override {
42 NOTREACHED(); 45 NOTREACHED();
43 return gfx::GpuMemoryBufferId(0); 46 return gfx::GpuMemoryBufferId(0);
44 } 47 }
45 gfx::GpuMemoryBufferHandle GetHandle() const override { 48 gfx::GpuMemoryBufferHandle GetHandle() const override {
46 NOTREACHED(); 49 NOTREACHED();
47 return gfx::GpuMemoryBufferHandle(); 50 return gfx::GpuMemoryBufferHandle();
48 } 51 }
49 ClientBuffer AsClientBuffer() override { 52 ClientBuffer AsClientBuffer() override {
50 return reinterpret_cast<ClientBuffer>(this); 53 return reinterpret_cast<ClientBuffer>(this);
51 } 54 }
52 55
53 private: 56 private:
57 size_t NumPlanes() const {
58 return gfx::NumberOfPlanesForBufferFormat(format_);
59 }
60 int BytesPerElement() const {
61 return format_ == gfx::BufferFormat::UYVY_422 ? 2 : 1;
62 }
63
64 static const size_t kMaxPlanes = 3;
65
54 gfx::BufferFormat format_; 66 gfx::BufferFormat format_;
55 std::vector<unsigned char> bytes_; 67 std::vector<uint8> bytes_[kMaxPlanes];
56 const gfx::Size size_; 68 const gfx::Size size_;
57 }; 69 };
58 70
59 } // unnamed namespace 71 } // unnamed namespace
60 72
61 MockGpuVideoAcceleratorFactories::MockGpuVideoAcceleratorFactories() {} 73 MockGpuVideoAcceleratorFactories::MockGpuVideoAcceleratorFactories() {}
62 74
63 MockGpuVideoAcceleratorFactories::~MockGpuVideoAcceleratorFactories() {} 75 MockGpuVideoAcceleratorFactories::~MockGpuVideoAcceleratorFactories() {}
64 76
65 bool MockGpuVideoAcceleratorFactories::IsGpuVideoAcceleratorEnabled() { 77 bool MockGpuVideoAcceleratorFactories::IsGpuVideoAcceleratorEnabled() {
(...skipping 27 matching lines...) Expand all
93 bool MockGpuVideoAcceleratorFactories::ShouldUseGpuMemoryBuffersForVideoFrames() 105 bool MockGpuVideoAcceleratorFactories::ShouldUseGpuMemoryBuffersForVideoFrames()
94 const { 106 const {
95 return false; 107 return false;
96 } 108 }
97 109
98 unsigned MockGpuVideoAcceleratorFactories::ImageTextureTarget() { 110 unsigned MockGpuVideoAcceleratorFactories::ImageTextureTarget() {
99 return GL_TEXTURE_2D; 111 return GL_TEXTURE_2D;
100 } 112 }
101 113
102 } // namespace media 114 } // namespace media
OLDNEW
« no previous file with comments | « media/base/video_frame.cc ('k') | media/video/gpu_memory_buffer_video_frame_pool.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698