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 #include "WebGLFormats.h"
11 
12 namespace mozilla {
13 
WebGLExtensionCompressedTextureRGTC(WebGLContext * const webgl)14 WebGLExtensionCompressedTextureRGTC::WebGLExtensionCompressedTextureRGTC(
15     WebGLContext* const webgl)
16     : WebGLExtensionBase(webgl) {
17   MOZ_ASSERT(IsSupported(webgl), "Don't construct extension if unsupported.");
18 
19   auto& fua = webgl->mFormatUsage;
20 
21   const auto fnAdd = [&](const GLenum sizedFormat,
22                          const webgl::EffectiveFormat effFormat) {
23     auto usage = fua->EditUsage(effFormat);
24     usage->isFilterable = true;
25     fua->AllowSizedTexFormat(sizedFormat, usage);
26   };
27 
28 #define _(X) LOCAL_GL_##X, webgl::EffectiveFormat::X
29 
30   fnAdd(_(COMPRESSED_RED_RGTC1));
31   fnAdd(_(COMPRESSED_SIGNED_RED_RGTC1));
32   fnAdd(_(COMPRESSED_RG_RGTC2));
33   fnAdd(_(COMPRESSED_SIGNED_RG_RGTC2));
34 
35 #undef _
36 }
37 
IsSupported(const WebGLContext * const webgl)38 bool WebGLExtensionCompressedTextureRGTC::IsSupported(
39     const WebGLContext* const webgl) {
40   return webgl->gl->IsSupported(gl::GLFeature::texture_compression_rgtc);
41 }
42 
43 }  // namespace mozilla
44