| Index: gpu/command_buffer/service/image_factory.cc
|
| diff --git a/gpu/command_buffer/service/image_factory.cc b/gpu/command_buffer/service/image_factory.cc
|
| index 1665c1eea85ce316866569cbfe3d6adf5bec27b1..9a2d458abd8cf9bf3673dcc2ab43e4e69895ee41 100644
|
| --- a/gpu/command_buffer/service/image_factory.cc
|
| +++ b/gpu/command_buffer/service/image_factory.cc
|
| @@ -4,6 +4,7 @@
|
|
|
| #include "gpu/command_buffer/service/image_factory.h"
|
|
|
| +#include "gpu/command_buffer/common/capabilities.h"
|
| #include "ui/gl/gl_bindings.h"
|
|
|
| namespace gpu {
|
| @@ -93,4 +94,52 @@ bool ImageFactory::IsImageFormatCompatibleWithGpuMemoryBufferFormat(
|
| }
|
| }
|
|
|
| +// static
|
| +bool ImageFactory::IsGpuMemoryBufferFormatSupported(
|
| + gfx::GpuMemoryBuffer::Format format,
|
| + const gpu::Capabilities& capabilities) {
|
| + switch (format) {
|
| + case gfx::GpuMemoryBuffer::ATC:
|
| + case gfx::GpuMemoryBuffer::ATCIA:
|
| + return capabilities.texture_format_atc;
|
| + case gfx::GpuMemoryBuffer::BGRA_8888:
|
| + return capabilities.texture_format_bgra8888;
|
| + case gfx::GpuMemoryBuffer::DXT1:
|
| + return capabilities.texture_format_dxt1;
|
| + case gfx::GpuMemoryBuffer::DXT5:
|
| + return capabilities.texture_format_dxt5;
|
| + case gfx::GpuMemoryBuffer::ETC1:
|
| + return capabilities.texture_format_etc1;
|
| + case gfx::GpuMemoryBuffer::RGBA_8888:
|
| + case gfx::GpuMemoryBuffer::RGBX_8888:
|
| + return true;
|
| + }
|
| +
|
| + NOTREACHED();
|
| + return false;
|
| +}
|
| +
|
| +// static
|
| +bool ImageFactory::IsImageSizeValidForGpuMemoryBufferFormat(
|
| + const gfx::Size& size,
|
| + gfx::GpuMemoryBuffer::Format format) {
|
| + switch (format) {
|
| + case gfx::GpuMemoryBuffer::ATC:
|
| + case gfx::GpuMemoryBuffer::ATCIA:
|
| + case gfx::GpuMemoryBuffer::DXT1:
|
| + case gfx::GpuMemoryBuffer::DXT5:
|
| + case gfx::GpuMemoryBuffer::ETC1:
|
| + // Compressed images must have a width and height that's evenly divisible
|
| + // by the block size.
|
| + return size.width() % 4 == 0 && size.height() % 4 == 0;
|
| + case gfx::GpuMemoryBuffer::RGBA_8888:
|
| + case gfx::GpuMemoryBuffer::BGRA_8888:
|
| + case gfx::GpuMemoryBuffer::RGBX_8888:
|
| + return true;
|
| + }
|
| +
|
| + NOTREACHED();
|
| + return false;
|
| +}
|
| +
|
| } // namespace gpu
|
|
|