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

Unified Diff: content/common/gpu/client/gpu_memory_buffer_impl.cc

Issue 1062853002: Add gfx::GpuMemoryBuffer::YUV_420 and GpuMemoryBufferImplSharedMemory support (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 8 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 side-by-side diff with in-line comments
Download patch
Index: content/common/gpu/client/gpu_memory_buffer_impl.cc
diff --git a/content/common/gpu/client/gpu_memory_buffer_impl.cc b/content/common/gpu/client/gpu_memory_buffer_impl.cc
index 208261dd0831e940f8f858b63a4169888c706db8..b8284ecb6048510ffb5ea3fb83e22a7d2ebd1ee3 100644
--- a/content/common/gpu/client/gpu_memory_buffer_impl.cc
+++ b/content/common/gpu/client/gpu_memory_buffer_impl.cc
@@ -77,57 +77,86 @@ GpuMemoryBufferImpl* GpuMemoryBufferImpl::FromClientBuffer(
}
// static
+size_t GpuMemoryBufferImpl::NumberOfPlanesForGpuMemoryBufferFormat(
+ Format format) {
+ switch (format) {
+ case ATC:
+ case ATCIA:
+ case DXT1:
+ case DXT5:
+ case ETC1:
+ case RGBA_8888:
+ case RGBX_8888:
+ case BGRA_8888:
+ return 1;
+ case YUV_420:
+ return 3;
+ }
+ NOTREACHED();
+ return 0;
+}
+
+// static
bool GpuMemoryBufferImpl::StrideInBytes(size_t width,
Format format,
+ int plane,
size_t* stride_in_bytes) {
- base::CheckedNumeric<size_t> s = width;
switch (format) {
case ATCIA:
case DXT5:
+ DCHECK_EQ(plane, 0);
*stride_in_bytes = width;
return true;
case ATC:
case DXT1:
case ETC1:
+ DCHECK_EQ(plane, 0);
DCHECK_EQ(width % 2, 0U);
- s /= 2;
- if (!s.IsValid())
- return false;
-
- *stride_in_bytes = s.ValueOrDie();
+ *stride_in_bytes = width / 2;
return true;
case RGBA_8888:
case RGBX_8888:
- case BGRA_8888:
+ case BGRA_8888: {
+ base::CheckedNumeric<size_t> s = width;
+ DCHECK_EQ(plane, 0);
s *= 4;
if (!s.IsValid())
return false;
-
*stride_in_bytes = s.ValueOrDie();
return true;
+ }
+ case YUV_420: {
+ DCHECK_EQ(width % 2, 0u);
+ *stride_in_bytes = width / SubsamplingFactor(format, plane);
+ return true;
+ }
}
-
NOTREACHED();
return false;
}
// static
-size_t GpuMemoryBufferImpl::NumberOfPlanesForGpuMemoryBufferFormat(
- gfx::GpuMemoryBuffer::Format format) {
+size_t GpuMemoryBufferImpl::SubsamplingFactor(
+ Format format,
+ int plane) {
switch (format) {
- case gfx::GpuMemoryBuffer::Format::ATC:
- case gfx::GpuMemoryBuffer::Format::ATCIA:
- case gfx::GpuMemoryBuffer::Format::DXT1:
- case gfx::GpuMemoryBuffer::Format::DXT5:
- case gfx::GpuMemoryBuffer::Format::ETC1:
- case gfx::GpuMemoryBuffer::Format::RGBA_8888:
- case gfx::GpuMemoryBuffer::Format::RGBX_8888:
- case gfx::GpuMemoryBuffer::Format::BGRA_8888:
+ case ATC:
+ case ATCIA:
+ case DXT1:
+ case DXT5:
+ case ETC1:
+ case RGBA_8888:
+ case RGBX_8888:
+ case BGRA_8888:
return 1;
- default:
- NOTREACHED();
- return 0;
+ case YUV_420: {
+ static size_t factor[] = {1, 2, 2};
+ DCHECK_LT(static_cast<size_t>(plane), arraysize(factor));
+ return factor[plane];
+ }
}
+ NOTREACHED();
+ return 0;
}
gfx::GpuMemoryBuffer::Format GpuMemoryBufferImpl::GetFormat() const {

Powered by Google App Engine
This is Rietveld 408576698