OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "gpu/command_buffer/service/image_factory.h" | 5 #include "gpu/command_buffer/service/image_factory.h" |
6 | 6 |
7 #include "gpu/command_buffer/common/capabilities.h" | 7 #include "gpu/command_buffer/common/capabilities.h" |
8 #include "ui/gl/gl_bindings.h" | 8 #include "ui/gl/gl_bindings.h" |
9 | 9 |
10 namespace gpu { | 10 namespace gpu { |
11 | 11 |
12 ImageFactory::ImageFactory() { | 12 ImageFactory::ImageFactory() { |
13 } | 13 } |
14 | 14 |
15 ImageFactory::~ImageFactory() { | 15 ImageFactory::~ImageFactory() { |
16 } | 16 } |
17 | 17 |
18 // static | 18 // static |
19 gfx::GpuMemoryBuffer::Format ImageFactory::ImageFormatToGpuMemoryBufferFormat( | 19 gfx::GpuMemoryBuffer::Format ImageFactory::ImageFormatToGpuMemoryBufferFormat( |
20 unsigned internalformat) { | 20 unsigned internalformat) { |
21 switch (internalformat) { | 21 switch (internalformat) { |
22 case GL_RGB: | 22 case GL_RGB: |
23 return gfx::GpuMemoryBuffer::RGBX_8888; | 23 return gfx::GpuMemoryBuffer::RGBX_8888; |
24 case GL_RGBA: | 24 case GL_RGBA: |
25 return gfx::GpuMemoryBuffer::RGBA_8888; | 25 return gfx::GpuMemoryBuffer::RGBA_8888; |
| 26 case GL_BGRA_EXT: |
| 27 return gfx::GpuMemoryBuffer::BGRA_8888; |
26 case GL_ATC_RGB_AMD: | 28 case GL_ATC_RGB_AMD: |
27 return gfx::GpuMemoryBuffer::ATC; | 29 return gfx::GpuMemoryBuffer::ATC; |
28 case GL_ATC_RGBA_INTERPOLATED_ALPHA_AMD: | 30 case GL_ATC_RGBA_INTERPOLATED_ALPHA_AMD: |
29 return gfx::GpuMemoryBuffer::ATCIA; | 31 return gfx::GpuMemoryBuffer::ATCIA; |
30 case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: | 32 case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: |
31 return gfx::GpuMemoryBuffer::DXT1; | 33 return gfx::GpuMemoryBuffer::DXT1; |
32 case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT: | 34 case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT: |
33 return gfx::GpuMemoryBuffer::DXT5; | 35 return gfx::GpuMemoryBuffer::DXT5; |
34 case GL_ETC1_RGB8_OES: | 36 case GL_ETC1_RGB8_OES: |
35 return gfx::GpuMemoryBuffer::ETC1; | 37 return gfx::GpuMemoryBuffer::ETC1; |
(...skipping 14 matching lines...) Expand all Loading... |
50 default: | 52 default: |
51 NOTREACHED(); | 53 NOTREACHED(); |
52 return gfx::GpuMemoryBuffer::MAP; | 54 return gfx::GpuMemoryBuffer::MAP; |
53 } | 55 } |
54 } | 56 } |
55 | 57 |
56 // static | 58 // static |
57 bool ImageFactory::IsImageFormatCompatibleWithGpuMemoryBufferFormat( | 59 bool ImageFactory::IsImageFormatCompatibleWithGpuMemoryBufferFormat( |
58 unsigned internalformat, | 60 unsigned internalformat, |
59 gfx::GpuMemoryBuffer::Format format) { | 61 gfx::GpuMemoryBuffer::Format format) { |
60 switch (internalformat) { | 62 return ImageFormatToGpuMemoryBufferFormat(internalformat) == format; |
61 case GL_RGB: | |
62 switch (format) { | |
63 case gfx::GpuMemoryBuffer::ATC: | |
64 case gfx::GpuMemoryBuffer::ATCIA: | |
65 case gfx::GpuMemoryBuffer::DXT1: | |
66 case gfx::GpuMemoryBuffer::DXT5: | |
67 case gfx::GpuMemoryBuffer::ETC1: | |
68 case gfx::GpuMemoryBuffer::RGBX_8888: | |
69 return true; | |
70 case gfx::GpuMemoryBuffer::RGBA_8888: | |
71 case gfx::GpuMemoryBuffer::BGRA_8888: | |
72 return false; | |
73 } | |
74 NOTREACHED(); | |
75 return false; | |
76 case GL_RGBA: | |
77 switch (format) { | |
78 case gfx::GpuMemoryBuffer::RGBX_8888: | |
79 return false; | |
80 case gfx::GpuMemoryBuffer::ATC: | |
81 case gfx::GpuMemoryBuffer::ATCIA: | |
82 case gfx::GpuMemoryBuffer::DXT1: | |
83 case gfx::GpuMemoryBuffer::DXT5: | |
84 case gfx::GpuMemoryBuffer::ETC1: | |
85 case gfx::GpuMemoryBuffer::RGBA_8888: | |
86 case gfx::GpuMemoryBuffer::BGRA_8888: | |
87 return true; | |
88 } | |
89 NOTREACHED(); | |
90 return false; | |
91 default: | |
92 NOTREACHED(); | |
93 return false; | |
94 } | |
95 } | 63 } |
96 | 64 |
97 // static | 65 // static |
98 bool ImageFactory::IsGpuMemoryBufferFormatSupported( | 66 bool ImageFactory::IsGpuMemoryBufferFormatSupported( |
99 gfx::GpuMemoryBuffer::Format format, | 67 gfx::GpuMemoryBuffer::Format format, |
100 const gpu::Capabilities& capabilities) { | 68 const gpu::Capabilities& capabilities) { |
101 switch (format) { | 69 switch (format) { |
102 case gfx::GpuMemoryBuffer::ATC: | 70 case gfx::GpuMemoryBuffer::ATC: |
103 case gfx::GpuMemoryBuffer::ATCIA: | 71 case gfx::GpuMemoryBuffer::ATCIA: |
104 return capabilities.texture_format_atc; | 72 return capabilities.texture_format_atc; |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 case gfx::GpuMemoryBuffer::BGRA_8888: | 104 case gfx::GpuMemoryBuffer::BGRA_8888: |
137 case gfx::GpuMemoryBuffer::RGBX_8888: | 105 case gfx::GpuMemoryBuffer::RGBX_8888: |
138 return true; | 106 return true; |
139 } | 107 } |
140 | 108 |
141 NOTREACHED(); | 109 NOTREACHED(); |
142 return false; | 110 return false; |
143 } | 111 } |
144 | 112 |
145 } // namespace gpu | 113 } // namespace gpu |
OLD | NEW |