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

Side by Side Diff: components/view_manager/gles2/mojo_gpu_memory_buffer.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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "components/view_manager/gles2/mojo_gpu_memory_buffer.h" 5 #include "components/view_manager/gles2/mojo_gpu_memory_buffer.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/memory/shared_memory.h" 8 #include "base/memory/shared_memory.h"
9 #include "base/numerics/safe_conversions.h" 9 #include "base/numerics/safe_conversions.h"
10 #include "ui/gfx/buffer_format_util.h" 10 #include "ui/gfx/buffer_format_util.h"
(...skipping 14 matching lines...) Expand all
25 case gfx::BufferFormat::RGBA_8888: 25 case gfx::BufferFormat::RGBA_8888:
26 case gfx::BufferFormat::BGRX_8888: 26 case gfx::BufferFormat::BGRX_8888:
27 case gfx::BufferFormat::BGRA_8888: 27 case gfx::BufferFormat::BGRA_8888:
28 case gfx::BufferFormat::UYVY_422: 28 case gfx::BufferFormat::UYVY_422:
29 return 1; 29 return 1;
30 case gfx::BufferFormat::YUV_420: { 30 case gfx::BufferFormat::YUV_420: {
31 static size_t factor[] = {1, 2, 2}; 31 static size_t factor[] = {1, 2, 2};
32 DCHECK_LT(static_cast<size_t>(plane), arraysize(factor)); 32 DCHECK_LT(static_cast<size_t>(plane), arraysize(factor));
33 return factor[plane]; 33 return factor[plane];
34 } 34 }
35 case gfx::BufferFormat::YUV_420_BIPLANAR: {
36 static size_t factor[] = {1, 2};
37 DCHECK_LT(static_cast<size_t>(plane), arraysize(factor));
38 return factor[plane];
39 }
35 } 40 }
36 NOTREACHED(); 41 NOTREACHED();
37 return 0; 42 return 0;
38 } 43 }
39 44
40 size_t StrideInBytes(size_t width, gfx::BufferFormat format, int plane) { 45 size_t StrideInBytes(size_t width, gfx::BufferFormat format, int plane) {
41 switch (format) { 46 switch (format) {
42 case gfx::BufferFormat::ATCIA: 47 case gfx::BufferFormat::ATCIA:
43 case gfx::BufferFormat::DXT5: 48 case gfx::BufferFormat::DXT5:
44 DCHECK_EQ(plane, 0); 49 DCHECK_EQ(plane, 0);
(...skipping 10 matching lines...) Expand all
55 case gfx::BufferFormat::UYVY_422: 60 case gfx::BufferFormat::UYVY_422:
56 DCHECK_EQ(plane, 0); 61 DCHECK_EQ(plane, 0);
57 return width * 2; 62 return width * 2;
58 case gfx::BufferFormat::RGBA_8888: 63 case gfx::BufferFormat::RGBA_8888:
59 case gfx::BufferFormat::BGRX_8888: 64 case gfx::BufferFormat::BGRX_8888:
60 case gfx::BufferFormat::BGRA_8888: 65 case gfx::BufferFormat::BGRA_8888:
61 DCHECK_EQ(plane, 0); 66 DCHECK_EQ(plane, 0);
62 return width * 4; 67 return width * 4;
63 case gfx::BufferFormat::YUV_420: 68 case gfx::BufferFormat::YUV_420:
64 return width / SubsamplingFactor(format, plane); 69 return width / SubsamplingFactor(format, plane);
70 case gfx::BufferFormat::YUV_420_BIPLANAR:
71 return width;
65 } 72 }
66 NOTREACHED(); 73 NOTREACHED();
67 return 0; 74 return 0;
68 } 75 }
69 76
70 size_t BufferSizeInBytes(const gfx::Size& size, gfx::BufferFormat format) { 77 size_t BufferSizeInBytes(const gfx::Size& size, gfx::BufferFormat format) {
71 size_t size_in_bytes = 0; 78 size_t size_in_bytes = 0;
72 int num_planes = static_cast<int>(gfx::NumberOfPlanesForBufferFormat(format)); 79 int num_planes = static_cast<int>(gfx::NumberOfPlanesForBufferFormat(format));
73 for (int i = 0; i < num_planes; ++i) { 80 for (int i = 0; i < num_planes; ++i) {
74 size_in_bytes += StrideInBytes(size.width(), format, i) * 81 size_in_bytes += StrideInBytes(size.width(), format, i) *
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 handle.type = gfx::SHARED_MEMORY_BUFFER; 166 handle.type = gfx::SHARED_MEMORY_BUFFER;
160 handle.handle = shared_memory_->handle(); 167 handle.handle = shared_memory_->handle();
161 return handle; 168 return handle;
162 } 169 }
163 170
164 ClientBuffer MojoGpuMemoryBufferImpl::AsClientBuffer() { 171 ClientBuffer MojoGpuMemoryBufferImpl::AsClientBuffer() {
165 return reinterpret_cast<ClientBuffer>(this); 172 return reinterpret_cast<ClientBuffer>(this);
166 } 173 }
167 174
168 } // namespace gles2 175 } // namespace gles2
OLDNEW
« no previous file with comments | « cc/test/test_gpu_memory_buffer_manager.cc ('k') | content/browser/gpu/browser_gpu_memory_buffer_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698