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

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

Issue 1051503003: Add R_8 GPU memory buffers format. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Merged on master. 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 b8284ecb6048510ffb5ea3fb83e22a7d2ebd1ee3..53b9b2956c92d1efa44b4ae50550d2069756cdb9 100644
--- a/content/common/gpu/client/gpu_memory_buffer_impl.cc
+++ b/content/common/gpu/client/gpu_memory_buffer_impl.cc
@@ -85,6 +85,7 @@ size_t GpuMemoryBufferImpl::NumberOfPlanesForGpuMemoryBufferFormat(
case DXT1:
case DXT5:
case ETC1:
+ case R_8:
case RGBA_8888:
case RGBX_8888:
case BGRA_8888:
@@ -101,6 +102,7 @@ bool GpuMemoryBufferImpl::StrideInBytes(size_t width,
Format format,
int plane,
size_t* stride_in_bytes) {
+ base::CheckedNumeric<size_t> checked_stride = width;
switch (format) {
case ATCIA:
case DXT5:
@@ -111,26 +113,29 @@ bool GpuMemoryBufferImpl::StrideInBytes(size_t width,
case DXT1:
case ETC1:
DCHECK_EQ(plane, 0);
- DCHECK_EQ(width % 2, 0U);
+ DCHECK_EQ(width % 2, 0u);
*stride_in_bytes = width / 2;
return true;
- case RGBA_8888:
+ case R_8:
+ checked_stride += 3;
+ if (!checked_stride.IsValid())
+ return false;
+ *stride_in_bytes = checked_stride.ValueOrDie() & ~0x3;
+ return true;
case RGBX_8888:
- case BGRA_8888: {
- base::CheckedNumeric<size_t> s = width;
- DCHECK_EQ(plane, 0);
- s *= 4;
- if (!s.IsValid())
+ case RGBA_8888:
+ case BGRA_8888:
+ checked_stride *= 4;
+ if (!checked_stride.IsValid())
return false;
- *stride_in_bytes = s.ValueOrDie();
+ *stride_in_bytes = checked_stride.ValueOrDie();
return true;
- }
- case YUV_420: {
+ case YUV_420:
DCHECK_EQ(width % 2, 0u);
*stride_in_bytes = width / SubsamplingFactor(format, plane);
return true;
- }
}
+
NOTREACHED();
return false;
}
@@ -145,6 +150,7 @@ size_t GpuMemoryBufferImpl::SubsamplingFactor(
case DXT1:
case DXT5:
case ETC1:
+ case R_8:
case RGBA_8888:
case RGBX_8888:
case BGRA_8888:
« no previous file with comments | « cc/test/test_gpu_memory_buffer_manager.cc ('k') | content/common/gpu/client/gpu_memory_buffer_impl_shared_memory.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698