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

Side by Side Diff: content/common/gpu/client/gpu_memory_buffer_impl.cc

Issue 1282313002: Add YUV_420_BIPLANAR to gfx::BufferFormat. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@gmb-planes
Patch Set: Rebase 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 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 "content/common/gpu/client/gpu_memory_buffer_impl.h" 5 #include "content/common/gpu/client/gpu_memory_buffer_impl.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/numerics/safe_math.h" 8 #include "base/numerics/safe_math.h"
9 #include "content/common/gpu/client/gpu_memory_buffer_impl_shared_memory.h" 9 #include "content/common/gpu/client/gpu_memory_buffer_impl_shared_memory.h"
10 #include "ui/gfx/buffer_format_util.h" 10 #include "ui/gfx/buffer_format_util.h"
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 case gfx::BufferFormat::RGBA_4444: 91 case gfx::BufferFormat::RGBA_4444:
92 case gfx::BufferFormat::RGBA_8888: 92 case gfx::BufferFormat::RGBA_8888:
93 case gfx::BufferFormat::RGBX_8888: 93 case gfx::BufferFormat::RGBX_8888:
94 case gfx::BufferFormat::BGRA_8888: 94 case gfx::BufferFormat::BGRA_8888:
95 return 1; 95 return 1;
96 case gfx::BufferFormat::YUV_420: { 96 case gfx::BufferFormat::YUV_420: {
97 static size_t factor[] = {1, 2, 2}; 97 static size_t factor[] = {1, 2, 2};
98 DCHECK_LT(static_cast<size_t>(plane), arraysize(factor)); 98 DCHECK_LT(static_cast<size_t>(plane), arraysize(factor));
99 return factor[plane]; 99 return factor[plane];
100 } 100 }
101 case gfx::BufferFormat::YUV_420_BIPLANAR: {
102 static size_t factor[] = {1, 2};
103 DCHECK_LT(static_cast<size_t>(plane), arraysize(factor));
104 return factor[plane];
105 }
101 } 106 }
102 NOTREACHED(); 107 NOTREACHED();
103 return 0; 108 return 0;
104 } 109 }
105 110
106 // static 111 // static
107 bool GpuMemoryBufferImpl::RowSizeInBytes(size_t width, 112 bool GpuMemoryBufferImpl::RowSizeInBytes(size_t width,
108 gfx::BufferFormat format, 113 gfx::BufferFormat format,
109 int plane, 114 int plane,
110 size_t* size_in_bytes) { 115 size_t* size_in_bytes) {
(...skipping 27 matching lines...) Expand all
138 case gfx::BufferFormat::BGRA_8888: 143 case gfx::BufferFormat::BGRA_8888:
139 checked_size *= 4; 144 checked_size *= 4;
140 if (!checked_size.IsValid()) 145 if (!checked_size.IsValid())
141 return false; 146 return false;
142 *size_in_bytes = checked_size.ValueOrDie(); 147 *size_in_bytes = checked_size.ValueOrDie();
143 return true; 148 return true;
144 case gfx::BufferFormat::YUV_420: 149 case gfx::BufferFormat::YUV_420:
145 DCHECK_EQ(width % 2, 0u); 150 DCHECK_EQ(width % 2, 0u);
146 *size_in_bytes = width / SubsamplingFactor(format, plane); 151 *size_in_bytes = width / SubsamplingFactor(format, plane);
147 return true; 152 return true;
153 case gfx::BufferFormat::YUV_420_BIPLANAR:
154 DCHECK_EQ(width % 2, 0u);
155 *size_in_bytes = width;
156 return true;
148 } 157 }
149 NOTREACHED(); 158 NOTREACHED();
150 return false; 159 return false;
151 } 160 }
152 161
153 // static 162 // static
154 bool GpuMemoryBufferImpl::BufferSizeInBytes(const gfx::Size& size, 163 bool GpuMemoryBufferImpl::BufferSizeInBytes(const gfx::Size& size,
155 gfx::BufferFormat format, 164 gfx::BufferFormat format,
156 size_t* size_in_bytes) { 165 size_t* size_in_bytes) {
157 base::CheckedNumeric<size_t> checked_size = 0; 166 base::CheckedNumeric<size_t> checked_size = 0;
(...skipping 24 matching lines...) Expand all
182 191
183 gfx::GpuMemoryBufferId GpuMemoryBufferImpl::GetId() const { 192 gfx::GpuMemoryBufferId GpuMemoryBufferImpl::GetId() const {
184 return id_; 193 return id_;
185 } 194 }
186 195
187 ClientBuffer GpuMemoryBufferImpl::AsClientBuffer() { 196 ClientBuffer GpuMemoryBufferImpl::AsClientBuffer() {
188 return reinterpret_cast<ClientBuffer>(this); 197 return reinterpret_cast<ClientBuffer>(this);
189 } 198 }
190 199
191 } // namespace content 200 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698