Chromium Code Reviews| 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 0c0426f6794c394c3c05ad6abebdf1ace85f611b..405befe3b25906c65b351428ef1ddad28bc223c0 100644 |
| --- a/content/common/gpu/client/gpu_memory_buffer_impl.cc |
| +++ b/content/common/gpu/client/gpu_memory_buffer_impl.cc |
| @@ -30,6 +30,7 @@ GpuMemoryBufferImpl::GpuMemoryBufferImpl(gfx::GpuMemoryBufferId id, |
| : id_(id), |
| size_(size), |
| format_(format), |
| + num_planes_(NumberOfPlanesForGpuMemoryBufferFormat(format)), |
| callback_(callback), |
| mapped_(false), |
| destruction_sync_point_(0) { |
| @@ -80,7 +81,7 @@ GpuMemoryBufferImpl* GpuMemoryBufferImpl::FromClientBuffer( |
| bool GpuMemoryBufferImpl::StrideInBytes(size_t width, |
| Format format, |
| size_t* stride_in_bytes) { |
| - base::CheckedNumeric<size_t> s = width; |
|
reveman
2015/03/23 22:24:01
Is this change needed?
emircan
2015/03/24 16:52:27
I was trying to change the function signature to w
|
| + base::CheckedNumeric<uint32> s = width; |
| switch (format) { |
| case ATCIA: |
| case DXT5: |
| @@ -111,6 +112,10 @@ bool GpuMemoryBufferImpl::StrideInBytes(size_t width, |
| return false; |
| } |
| +size_t GpuMemoryBufferImpl::GetNumberOfPlanes() const { |
| + return num_planes_; |
| +} |
| + |
| gfx::GpuMemoryBuffer::Format GpuMemoryBufferImpl::GetFormat() const { |
| return format_; |
| } |
| @@ -123,4 +128,23 @@ ClientBuffer GpuMemoryBufferImpl::AsClientBuffer() { |
| return reinterpret_cast<ClientBuffer>(this); |
| } |
| +// static |
| +size_t GpuMemoryBufferImpl::NumberOfPlanesForGpuMemoryBufferFormat( |
| + gfx::GpuMemoryBuffer::Format format) { |
| + 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: |
| + return 1; |
| + default: |
| + NOTREACHED(); |
| + return 0; |
| + } |
| +} |
| + |
| } // namespace content |