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

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

Issue 1327243002: Revert of Add support for converting I420 software frames into NV12 hardware frames (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@biplanar
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
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"
8 #include "ui/gfx/gpu_memory_buffer.h" 7 #include "ui/gfx/gpu_memory_buffer.h"
9 8
10 namespace media { 9 namespace media {
11 10
12 namespace { 11 namespace {
13 12
14 class GpuMemoryBufferImpl : public gfx::GpuMemoryBuffer { 13 class GpuMemoryBufferImpl : public gfx::GpuMemoryBuffer {
15 public: 14 public:
16 GpuMemoryBufferImpl(const gfx::Size& size, gfx::BufferFormat format) 15 GpuMemoryBufferImpl(const gfx::Size& size, gfx::BufferFormat format)
17 : format_(format), size_(size), 16 : format_(format), size_(size) {
18 num_planes_(gfx::NumberOfPlanesForBufferFormat(format)) {
19 DCHECK(gfx::BufferFormat::R_8 == format_ || 17 DCHECK(gfx::BufferFormat::R_8 == format_ ||
20 gfx::BufferFormat::YUV_420_BIPLANAR == format_ ||
21 gfx::BufferFormat::UYVY_422 == format_); 18 gfx::BufferFormat::UYVY_422 == format_);
22 DCHECK(num_planes_ <= kMaxPlanes); 19 bytes_.resize(size_.GetArea() *
23 for (int i = 0; i < static_cast<int>(num_planes_); ++i) { 20 (format_ == gfx::BufferFormat::UYVY_422 ? 2 : 1));
24 bytes_[i].resize(
25 gfx::RowSizeForBufferFormat(size_.width(), format_, i) *
26 size_.height() / gfx::SubsamplingFactorForBufferFormat(format_, i));
27 }
28 } 21 }
29 22
30 // Overridden from gfx::GpuMemoryBuffer: 23 // Overridden from gfx::GpuMemoryBuffer:
31 bool Map(void** data) override { 24 bool Map(void** data) override {
32 for (size_t plane = 0; plane < num_planes_; ++plane) 25 data[0] = &bytes_[0];
33 data[plane] = &bytes_[plane][0];
34 return true; 26 return true;
35 } 27 }
36 void Unmap() override{}; 28 void Unmap() override{};
37 bool IsMapped() const override { 29 bool IsMapped() const override {
38 NOTREACHED(); 30 NOTREACHED();
39 return false; 31 return false;
40 } 32 }
41 gfx::BufferFormat GetFormat() const override { 33 gfx::BufferFormat GetFormat() const override {
42 return format_; 34 NOTREACHED();
35 return gfx::BufferFormat::R_8;
43 } 36 }
44 void GetStride(int* strides) const override { 37 void GetStride(int* stride) const override {
45 for (int plane = 0; plane < static_cast<int>(num_planes_); ++plane) { 38 stride[0] =
46 strides[plane] = static_cast<int>( 39 size_.width() * (format_ == gfx::BufferFormat::UYVY_422 ? 2 : 1);
47 gfx::RowSizeForBufferFormat(size_.width(), format_, plane));
48 }
49 } 40 }
50 gfx::GpuMemoryBufferId GetId() const override { 41 gfx::GpuMemoryBufferId GetId() const override {
51 NOTREACHED(); 42 NOTREACHED();
52 return gfx::GpuMemoryBufferId(0); 43 return gfx::GpuMemoryBufferId(0);
53 } 44 }
54 gfx::GpuMemoryBufferHandle GetHandle() const override { 45 gfx::GpuMemoryBufferHandle GetHandle() const override {
55 NOTREACHED(); 46 NOTREACHED();
56 return gfx::GpuMemoryBufferHandle(); 47 return gfx::GpuMemoryBufferHandle();
57 } 48 }
58 ClientBuffer AsClientBuffer() override { 49 ClientBuffer AsClientBuffer() override {
59 return reinterpret_cast<ClientBuffer>(this); 50 return reinterpret_cast<ClientBuffer>(this);
60 } 51 }
61 52
62 private: 53 private:
63 static const size_t kMaxPlanes = 3;
64
65 gfx::BufferFormat format_; 54 gfx::BufferFormat format_;
55 std::vector<unsigned char> bytes_;
66 const gfx::Size size_; 56 const gfx::Size size_;
67 size_t num_planes_;
68 std::vector<uint8> bytes_[kMaxPlanes];
69 }; 57 };
70 58
71 } // unnamed namespace 59 } // unnamed namespace
72 60
73 MockGpuVideoAcceleratorFactories::MockGpuVideoAcceleratorFactories() {} 61 MockGpuVideoAcceleratorFactories::MockGpuVideoAcceleratorFactories() {}
74 62
75 MockGpuVideoAcceleratorFactories::~MockGpuVideoAcceleratorFactories() {} 63 MockGpuVideoAcceleratorFactories::~MockGpuVideoAcceleratorFactories() {}
76 64
77 bool MockGpuVideoAcceleratorFactories::IsGpuVideoAcceleratorEnabled() { 65 bool MockGpuVideoAcceleratorFactories::IsGpuVideoAcceleratorEnabled() {
78 return true; 66 return true;
(...skipping 26 matching lines...) Expand all
105 bool MockGpuVideoAcceleratorFactories::ShouldUseGpuMemoryBuffersForVideoFrames() 93 bool MockGpuVideoAcceleratorFactories::ShouldUseGpuMemoryBuffersForVideoFrames()
106 const { 94 const {
107 return false; 95 return false;
108 } 96 }
109 97
110 unsigned MockGpuVideoAcceleratorFactories::ImageTextureTarget() { 98 unsigned MockGpuVideoAcceleratorFactories::ImageTextureTarget() {
111 return GL_TEXTURE_2D; 99 return GL_TEXTURE_2D;
112 } 100 }
113 101
114 } // namespace media 102 } // namespace media
OLDNEW
« no previous file with comments | « media/blink/skcanvas_video_renderer.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