diff options
Diffstat (limited to 'components/view_manager/gles2/mojo_gpu_memory_buffer.cc')
-rw-r--r-- | components/view_manager/gles2/mojo_gpu_memory_buffer.cc | 29 |
1 files changed, 6 insertions, 23 deletions
diff --git a/components/view_manager/gles2/mojo_gpu_memory_buffer.cc b/components/view_manager/gles2/mojo_gpu_memory_buffer.cc index 4545050..254c358 100644 --- a/components/view_manager/gles2/mojo_gpu_memory_buffer.cc +++ b/components/view_manager/gles2/mojo_gpu_memory_buffer.cc @@ -7,31 +7,12 @@ #include "base/logging.h" #include "base/memory/shared_memory.h" #include "base/numerics/safe_conversions.h" +#include "ui/gfx/buffer_format_util.h" namespace gles2 { namespace { -int NumberOfPlanesForGpuMemoryBufferFormat(gfx::BufferFormat format) { - switch (format) { - case gfx::BufferFormat::ATC: - case gfx::BufferFormat::ATCIA: - case gfx::BufferFormat::DXT1: - case gfx::BufferFormat::DXT5: - case gfx::BufferFormat::ETC1: - case gfx::BufferFormat::R_8: - case gfx::BufferFormat::RGBA_4444: - case gfx::BufferFormat::RGBA_8888: - case gfx::BufferFormat::RGBX_8888: - case gfx::BufferFormat::BGRA_8888: - return 1; - case gfx::BufferFormat::YUV_420: - return 3; - } - NOTREACHED(); - return 0; -} - size_t SubsamplingFactor(gfx::BufferFormat format, int plane) { switch (format) { case gfx::BufferFormat::ATC: @@ -86,7 +67,7 @@ size_t StrideInBytes(size_t width, gfx::BufferFormat format, int plane) { size_t BufferSizeInBytes(const gfx::Size& size, gfx::BufferFormat format) { size_t size_in_bytes = 0; - int num_planes = NumberOfPlanesForGpuMemoryBufferFormat(format); + int num_planes = static_cast<int>(gfx::NumberOfPlanesForBufferFormat(format)); for (int i = 0; i < num_planes; ++i) { size_in_bytes += StrideInBytes(size.width(), format, i) * (size.height() / SubsamplingFactor(format, i)); @@ -131,7 +112,8 @@ bool MojoGpuMemoryBufferImpl::Map(void** data) { return false; mapped_ = true; size_t offset = 0; - int num_planes = NumberOfPlanesForGpuMemoryBufferFormat(format_); + int num_planes = static_cast<int>( + gfx::NumberOfPlanesForBufferFormat(format_)); for (int i = 0; i < num_planes; ++i) { data[i] = reinterpret_cast<uint8*>(shared_memory_->memory()) + offset; offset += StrideInBytes(size_.width(), format_, i) * @@ -155,7 +137,8 @@ gfx::BufferFormat MojoGpuMemoryBufferImpl::GetFormat() const { } void MojoGpuMemoryBufferImpl::GetStride(int* stride) const { - int num_planes = NumberOfPlanesForGpuMemoryBufferFormat(format_); + int num_planes = static_cast<int>( + gfx::NumberOfPlanesForBufferFormat(format_)); for (int i = 0; i < num_planes; ++i) stride[i] = base::checked_cast<int>(StrideInBytes(size_.width(), format_, i)); |