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

Side by Side Diff: components/view_manager/gles2/mojo_gpu_memory_buffer.cc

Issue 1282313002: Add YUV_420_BIPLANAR to gfx::BufferFormat. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@gmb-planes
Patch Set: Fix ozone build Created 5 years, 4 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 10
(...skipping 12 matching lines...) Expand all
23 case gfx::BufferFormat::RGBA_4444: 23 case gfx::BufferFormat::RGBA_4444:
24 case gfx::BufferFormat::RGBA_8888: 24 case gfx::BufferFormat::RGBA_8888:
25 case gfx::BufferFormat::RGBX_8888: 25 case gfx::BufferFormat::RGBX_8888:
26 case gfx::BufferFormat::BGRA_8888: 26 case gfx::BufferFormat::BGRA_8888:
27 return 1; 27 return 1;
28 case gfx::BufferFormat::YUV_420: { 28 case gfx::BufferFormat::YUV_420: {
29 static size_t factor[] = {1, 2, 2}; 29 static size_t factor[] = {1, 2, 2};
30 DCHECK_LT(static_cast<size_t>(plane), arraysize(factor)); 30 DCHECK_LT(static_cast<size_t>(plane), arraysize(factor));
31 return factor[plane]; 31 return factor[plane];
32 } 32 }
33 case gfx::BufferFormat::YUV_420_BIPLANAR: {
34 static size_t factor[] = {1, 2};
35 DCHECK_LT(static_cast<size_t>(plane), arraysize(factor));
36 return factor[plane];
37 }
33 } 38 }
34 NOTREACHED(); 39 NOTREACHED();
35 return 0; 40 return 0;
36 } 41 }
37 42
38 size_t StrideInBytes(size_t width, gfx::BufferFormat format, int plane) { 43 size_t StrideInBytes(size_t width, gfx::BufferFormat format, int plane) {
39 switch (format) { 44 switch (format) {
40 case gfx::BufferFormat::ATCIA: 45 case gfx::BufferFormat::ATCIA:
41 case gfx::BufferFormat::DXT5: 46 case gfx::BufferFormat::DXT5:
42 DCHECK_EQ(plane, 0); 47 DCHECK_EQ(plane, 0);
43 return width; 48 return width;
44 case gfx::BufferFormat::ATC: 49 case gfx::BufferFormat::ATC:
45 case gfx::BufferFormat::DXT1: 50 case gfx::BufferFormat::DXT1:
46 case gfx::BufferFormat::ETC1: 51 case gfx::BufferFormat::ETC1:
47 DCHECK_EQ(plane, 0); 52 DCHECK_EQ(plane, 0);
48 DCHECK_EQ(width % 2, 0u); 53 DCHECK_EQ(width % 2, 0u);
49 return width / 2; 54 return width / 2;
50 case gfx::BufferFormat::R_8: 55 case gfx::BufferFormat::R_8:
51 return (width + 3) & ~0x3; 56 return (width + 3) & ~0x3;
52 case gfx::BufferFormat::RGBA_4444: 57 case gfx::BufferFormat::RGBA_4444:
53 DCHECK_EQ(plane, 0); 58 DCHECK_EQ(plane, 0);
54 return width * 2; 59 return width * 2;
55 case gfx::BufferFormat::RGBA_8888: 60 case gfx::BufferFormat::RGBA_8888:
56 case gfx::BufferFormat::RGBX_8888: 61 case gfx::BufferFormat::RGBX_8888:
57 case gfx::BufferFormat::BGRA_8888: 62 case gfx::BufferFormat::BGRA_8888:
58 DCHECK_EQ(plane, 0); 63 DCHECK_EQ(plane, 0);
59 return width * 4; 64 return width * 4;
60 case gfx::BufferFormat::YUV_420: 65 case gfx::BufferFormat::YUV_420:
61 return width / SubsamplingFactor(format, plane); 66 return width / SubsamplingFactor(format, plane);
67 case gfx::BufferFormat::YUV_420_BIPLANAR:
68 return width;
62 } 69 }
63 NOTREACHED(); 70 NOTREACHED();
64 return 0; 71 return 0;
65 } 72 }
66 73
67 size_t BufferSizeInBytes(const gfx::Size& size, gfx::BufferFormat format) { 74 size_t BufferSizeInBytes(const gfx::Size& size, gfx::BufferFormat format) {
68 size_t size_in_bytes = 0; 75 size_t size_in_bytes = 0;
69 int num_planes = gfx::GpuMemoryBuffer::NumberOfPlanes(format); 76 int num_planes = gfx::GpuMemoryBuffer::NumberOfPlanes(format);
70 for (int i = 0; i < num_planes; ++i) { 77 for (int i = 0; i < num_planes; ++i) {
71 size_in_bytes += StrideInBytes(size.width(), format, i) * 78 size_in_bytes += StrideInBytes(size.width(), format, i) *
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 handle.type = gfx::SHARED_MEMORY_BUFFER; 157 handle.type = gfx::SHARED_MEMORY_BUFFER;
151 handle.handle = shared_memory_->handle(); 158 handle.handle = shared_memory_->handle();
152 return handle; 159 return handle;
153 } 160 }
154 161
155 ClientBuffer MojoGpuMemoryBufferImpl::AsClientBuffer() { 162 ClientBuffer MojoGpuMemoryBufferImpl::AsClientBuffer() {
156 return reinterpret_cast<ClientBuffer>(this); 163 return reinterpret_cast<ClientBuffer>(this);
157 } 164 }
158 165
159 } // namespace gles2 166 } // namespace gles2
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698