1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "gpu/command_buffer/service/image_factory.h"
7 #include "ui/gl/gl_bindings.h"
11 ImageFactory::ImageFactory() {
14 ImageFactory::~ImageFactory() {
18 gfx::GpuMemoryBuffer::Format
ImageFactory::ImageFormatToGpuMemoryBufferFormat(
19 unsigned internalformat
) {
20 switch (internalformat
) {
22 return gfx::GpuMemoryBuffer::RGBX_8888
;
24 return gfx::GpuMemoryBuffer::RGBA_8888
;
26 return gfx::GpuMemoryBuffer::ATC
;
27 case GL_ATC_RGBA_INTERPOLATED_ALPHA_AMD
:
28 return gfx::GpuMemoryBuffer::ATCIA
;
29 case GL_COMPRESSED_RGB_S3TC_DXT1_EXT
:
30 return gfx::GpuMemoryBuffer::DXT1
;
31 case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT
:
32 return gfx::GpuMemoryBuffer::DXT5
;
33 case GL_ETC1_RGB8_OES
:
34 return gfx::GpuMemoryBuffer::ETC1
;
37 return gfx::GpuMemoryBuffer::RGBA_8888
;
42 gfx::GpuMemoryBuffer::Usage
ImageFactory::ImageUsageToGpuMemoryBufferUsage(
46 return gfx::GpuMemoryBuffer::MAP
;
47 case GL_SCANOUT_CHROMIUM
:
48 return gfx::GpuMemoryBuffer::SCANOUT
;
51 return gfx::GpuMemoryBuffer::MAP
;
56 bool ImageFactory::IsImageFormatCompatibleWithGpuMemoryBufferFormat(
57 unsigned internalformat
,
58 gfx::GpuMemoryBuffer::Format format
) {
59 switch (internalformat
) {
62 case gfx::GpuMemoryBuffer::ATC
:
63 case gfx::GpuMemoryBuffer::ATCIA
:
64 case gfx::GpuMemoryBuffer::DXT1
:
65 case gfx::GpuMemoryBuffer::DXT5
:
66 case gfx::GpuMemoryBuffer::ETC1
:
67 case gfx::GpuMemoryBuffer::RGBX_8888
:
69 case gfx::GpuMemoryBuffer::RGBA_8888
:
70 case gfx::GpuMemoryBuffer::BGRA_8888
:
77 case gfx::GpuMemoryBuffer::RGBX_8888
:
79 case gfx::GpuMemoryBuffer::ATC
:
80 case gfx::GpuMemoryBuffer::ATCIA
:
81 case gfx::GpuMemoryBuffer::DXT1
:
82 case gfx::GpuMemoryBuffer::DXT5
:
83 case gfx::GpuMemoryBuffer::ETC1
:
84 case gfx::GpuMemoryBuffer::RGBA_8888
:
85 case gfx::GpuMemoryBuffer::BGRA_8888
: