Bug 1700051: part 26) Correct typo in comment of `mozInlineSpellWordUtil::BuildSoftTe...
[gecko.git] / dom / canvas / WebGLExtensionCompressedTextureS3TC_SRGB.cpp
blob3ba8b9e2973730d440e08905372dce64e9103578
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/. */
5 #include "WebGLExtensions.h"
7 #include "GLContext.h"
8 #include "mozilla/dom/WebGLRenderingContextBinding.h"
9 #include "WebGLContext.h"
10 #include "WebGLFormats.h"
12 namespace mozilla {
14 WebGLExtensionCompressedTextureS3TC_SRGB::
15 WebGLExtensionCompressedTextureS3TC_SRGB(WebGLContext* webgl)
16 : WebGLExtensionBase(webgl) {
17 RefPtr<WebGLContext> webgl_ = webgl; // Bug 1201275
18 const auto fnAdd = [&webgl_](GLenum sizedFormat,
19 webgl::EffectiveFormat effFormat) {
20 auto& fua = webgl_->mFormatUsage;
22 auto usage = fua->EditUsage(effFormat);
23 usage->isFilterable = true;
24 fua->AllowSizedTexFormat(sizedFormat, usage);
27 #define FOO(x) LOCAL_GL_##x, webgl::EffectiveFormat::x
29 fnAdd(FOO(COMPRESSED_SRGB_S3TC_DXT1_EXT));
30 fnAdd(FOO(COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT));
31 fnAdd(FOO(COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT));
32 fnAdd(FOO(COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT));
34 #undef FOO
37 bool WebGLExtensionCompressedTextureS3TC_SRGB::IsSupported(
38 const WebGLContext* webgl) {
39 gl::GLContext* gl = webgl->GL();
40 if (gl->IsGLES())
41 return gl->IsExtensionSupported(
42 gl::GLContext::EXT_texture_compression_s3tc_srgb);
44 // Desktop GL is more complicated: It's EXT_texture_sRGB, when
45 // EXT_texture_compression_s3tc is supported, that enables srgb+s3tc.
46 return gl->IsExtensionSupported(gl::GLContext::EXT_texture_sRGB) &&
47 gl->IsExtensionSupported(gl::GLContext::EXT_texture_compression_s3tc);
50 } // namespace mozilla