/src/mozilla-central/dom/canvas/WebGLExtensionCompressedTextureS3TC_SRGB.cpp
Line | Count | Source (jump to first uncovered line) |
1 | | /* This Source Code Form is subject to the terms of the Mozilla Public |
2 | | * License, v. 2.0. If a copy of the MPL was not distributed with this file, |
3 | | * You can obtain one at http://mozilla.org/MPL/2.0/. */ |
4 | | |
5 | | #include "WebGLExtensions.h" |
6 | | |
7 | | #include "GLContext.h" |
8 | | #include "mozilla/dom/WebGLRenderingContextBinding.h" |
9 | | #include "WebGLContext.h" |
10 | | |
11 | | #ifdef FOO |
12 | | #error FOO is already defined! We use FOO() macros to keep things succinct in this file. |
13 | | #endif |
14 | | |
15 | | namespace mozilla { |
16 | | |
17 | | WebGLExtensionCompressedTextureS3TC_SRGB::WebGLExtensionCompressedTextureS3TC_SRGB(WebGLContext* webgl) |
18 | | : WebGLExtensionBase(webgl) |
19 | 0 | { |
20 | 0 | RefPtr<WebGLContext> webgl_ = webgl; // Bug 1201275 |
21 | 0 | const auto fnAdd = [&webgl_](GLenum sizedFormat, webgl::EffectiveFormat effFormat) { |
22 | 0 | auto& fua = webgl_->mFormatUsage; |
23 | 0 |
|
24 | 0 | auto usage = fua->EditUsage(effFormat); |
25 | 0 | usage->isFilterable = true; |
26 | 0 | fua->AllowSizedTexFormat(sizedFormat, usage); |
27 | 0 |
|
28 | 0 | webgl_->mCompressedTextureFormats.AppendElement(sizedFormat); |
29 | 0 | }; |
30 | 0 |
|
31 | 0 | #define FOO(x) LOCAL_GL_ ## x, webgl::EffectiveFormat::x |
32 | 0 |
|
33 | 0 | fnAdd(FOO(COMPRESSED_SRGB_S3TC_DXT1_EXT)); |
34 | 0 | fnAdd(FOO(COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT)); |
35 | 0 | fnAdd(FOO(COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT)); |
36 | 0 | fnAdd(FOO(COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT)); |
37 | 0 |
|
38 | 0 | #undef FOO |
39 | 0 | } |
40 | | |
41 | | WebGLExtensionCompressedTextureS3TC_SRGB::~WebGLExtensionCompressedTextureS3TC_SRGB() |
42 | 0 | { |
43 | 0 | } |
44 | | |
45 | | bool |
46 | | WebGLExtensionCompressedTextureS3TC_SRGB::IsSupported(const WebGLContext* webgl) |
47 | 0 | { |
48 | 0 | gl::GLContext* gl = webgl->GL(); |
49 | 0 | if (gl->IsGLES()) |
50 | 0 | return gl->IsExtensionSupported(gl::GLContext::EXT_texture_compression_s3tc_srgb); |
51 | 0 | |
52 | 0 | // Desktop GL is more complicated: It's EXT_texture_sRGB, when |
53 | 0 | // EXT_texture_compression_s3tc is supported, that enables srgb+s3tc. |
54 | 0 | return gl->IsExtensionSupported(gl::GLContext::EXT_texture_sRGB) && |
55 | 0 | gl->IsExtensionSupported(gl::GLContext::EXT_texture_compression_s3tc); |
56 | 0 | } |
57 | | |
58 | | IMPL_WEBGL_EXTENSION_GOOP(WebGLExtensionCompressedTextureS3TC_SRGB, WEBGL_compressed_texture_s3tc_srgb) |
59 | | |
60 | | } // namespace mozilla |