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

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: Enable it on Mac 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/gl/gl_bindings.h" 10 #include "ui/gl/gl_bindings.h"
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 case gfx::BufferFormat::RGBA_4444: 90 case gfx::BufferFormat::RGBA_4444:
91 case gfx::BufferFormat::RGBA_8888: 91 case gfx::BufferFormat::RGBA_8888:
92 case gfx::BufferFormat::RGBX_8888: 92 case gfx::BufferFormat::RGBX_8888:
93 case gfx::BufferFormat::BGRA_8888: 93 case gfx::BufferFormat::BGRA_8888:
94 return 1; 94 return 1;
95 case gfx::BufferFormat::YUV_420: { 95 case gfx::BufferFormat::YUV_420: {
96 static size_t factor[] = {1, 2, 2}; 96 static size_t factor[] = {1, 2, 2};
97 DCHECK_LT(static_cast<size_t>(plane), arraysize(factor)); 97 DCHECK_LT(static_cast<size_t>(plane), arraysize(factor));
98 return factor[plane]; 98 return factor[plane];
99 } 99 }
100 case gfx::BufferFormat::YUV_420_BIPLANAR: {
101 static size_t factor[] = {1, 2};
102 DCHECK_LT(static_cast<size_t>(plane), arraysize(factor));
103 return factor[plane];
104 }
100 } 105 }
101 NOTREACHED(); 106 NOTREACHED();
102 return 0; 107 return 0;
103 } 108 }
104 109
105 // static 110 // static
106 bool GpuMemoryBufferImpl::RowSizeInBytes(size_t width, 111 bool GpuMemoryBufferImpl::RowSizeInBytes(size_t width,
107 gfx::BufferFormat format, 112 gfx::BufferFormat format,
108 int plane, 113 int plane,
109 size_t* size_in_bytes) { 114 size_t* size_in_bytes) {
(...skipping 27 matching lines...) Expand all
137 case gfx::BufferFormat::BGRA_8888: 142 case gfx::BufferFormat::BGRA_8888:
138 checked_size *= 4; 143 checked_size *= 4;
139 if (!checked_size.IsValid()) 144 if (!checked_size.IsValid())
140 return false; 145 return false;
141 *size_in_bytes = checked_size.ValueOrDie(); 146 *size_in_bytes = checked_size.ValueOrDie();
142 return true; 147 return true;
143 case gfx::BufferFormat::YUV_420: 148 case gfx::BufferFormat::YUV_420:
144 DCHECK_EQ(width % 2, 0u); 149 DCHECK_EQ(width % 2, 0u);
145 *size_in_bytes = width / SubsamplingFactor(format, plane); 150 *size_in_bytes = width / SubsamplingFactor(format, plane);
146 return true; 151 return true;
152 case gfx::BufferFormat::YUV_420_BIPLANAR:
153 DCHECK_EQ(width % 2, 0u);
154 *size_in_bytes = width;
155 return true;
147 } 156 }
148 NOTREACHED(); 157 NOTREACHED();
149 return false; 158 return false;
150 } 159 }
151 160
152 // static 161 // static
153 bool GpuMemoryBufferImpl::BufferSizeInBytes(const gfx::Size& size, 162 bool GpuMemoryBufferImpl::BufferSizeInBytes(const gfx::Size& size,
154 gfx::BufferFormat format, 163 gfx::BufferFormat format,
155 size_t* size_in_bytes) { 164 size_t* size_in_bytes) {
156 base::CheckedNumeric<size_t> checked_size = 0; 165 base::CheckedNumeric<size_t> checked_size = 0;
(...skipping 24 matching lines...) Expand all
181 190
182 gfx::GpuMemoryBufferId GpuMemoryBufferImpl::GetId() const { 191 gfx::GpuMemoryBufferId GpuMemoryBufferImpl::GetId() const {
183 return id_; 192 return id_;
184 } 193 }
185 194
186 ClientBuffer GpuMemoryBufferImpl::AsClientBuffer() { 195 ClientBuffer GpuMemoryBufferImpl::AsClientBuffer() {
187 return reinterpret_cast<ClientBuffer>(this); 196 return reinterpret_cast<ClientBuffer>(this);
188 } 197 }
189 198
190 } // namespace content 199 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698