Rewrite AndroidSyncSettings to be significantly simpler.
[chromium-blink-merge.git] / gpu / command_buffer / service / image_factory.cc
blob1665c1eea85ce316866569cbfe3d6adf5bec27b1
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"
9 namespace gpu {
11 ImageFactory::ImageFactory() {
14 ImageFactory::~ImageFactory() {
17 // static
18 gfx::GpuMemoryBuffer::Format ImageFactory::ImageFormatToGpuMemoryBufferFormat(
19 unsigned internalformat) {
20 switch (internalformat) {
21 case GL_RGB:
22 return gfx::GpuMemoryBuffer::RGBX_8888;
23 case GL_RGBA:
24 return gfx::GpuMemoryBuffer::RGBA_8888;
25 case GL_ATC_RGB_AMD:
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;
35 default:
36 NOTREACHED();
37 return gfx::GpuMemoryBuffer::RGBA_8888;
41 // static
42 gfx::GpuMemoryBuffer::Usage ImageFactory::ImageUsageToGpuMemoryBufferUsage(
43 unsigned usage) {
44 switch (usage) {
45 case GL_MAP_CHROMIUM:
46 return gfx::GpuMemoryBuffer::MAP;
47 case GL_SCANOUT_CHROMIUM:
48 return gfx::GpuMemoryBuffer::SCANOUT;
49 default:
50 NOTREACHED();
51 return gfx::GpuMemoryBuffer::MAP;
55 // static
56 bool ImageFactory::IsImageFormatCompatibleWithGpuMemoryBufferFormat(
57 unsigned internalformat,
58 gfx::GpuMemoryBuffer::Format format) {
59 switch (internalformat) {
60 case GL_RGB:
61 switch (format) {
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:
68 return true;
69 case gfx::GpuMemoryBuffer::RGBA_8888:
70 case gfx::GpuMemoryBuffer::BGRA_8888:
71 return false;
73 NOTREACHED();
74 return false;
75 case GL_RGBA:
76 switch (format) {
77 case gfx::GpuMemoryBuffer::RGBX_8888:
78 return false;
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:
86 return true;
88 NOTREACHED();
89 return false;
90 default:
91 NOTREACHED();
92 return false;
96 } // namespace gpu