Line data Source code
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 0 : WebGLExtensionCompressedTextureES3::WebGLExtensionCompressedTextureES3(WebGLContext* webgl)
18 0 : : WebGLExtensionBase(webgl)
19 : {
20 : // GLES 3.0.4, p147, table 3.19
21 : // GLES 3.0.4, p286+, $C.1 "ETC Compressed Texture Image Formats"
22 : // Note that all compressed texture formats are filterable:
23 : // GLES 3.0.4 p161:
24 : // "[A] texture is complete unless any of the following conditions hold true:
25 : // [...]
26 : // * The effective internal format specified for the texture arrays is a sized
27 : // internal color format that is not texture-filterable (see table 3.13) and [the
28 : // mag filter requires filtering]."
29 : // Compressed formats are not sized internal color formats, and indeed they are not
30 : // listed in table 3.13.
31 :
32 0 : RefPtr<WebGLContext> webgl_ = webgl; // Bug 1201275
33 0 : const auto fnAdd = [&webgl_](GLenum sizedFormat, webgl::EffectiveFormat effFormat) {
34 0 : auto& fua = webgl_->mFormatUsage;
35 :
36 0 : auto usage = fua->EditUsage(effFormat);
37 0 : usage->isFilterable = true;
38 0 : fua->AllowSizedTexFormat(sizedFormat, usage);
39 :
40 0 : webgl_->mCompressedTextureFormats.AppendElement(sizedFormat);
41 0 : };
42 :
43 : #define FOO(x) LOCAL_GL_ ## x, webgl::EffectiveFormat::x
44 :
45 0 : fnAdd(FOO(COMPRESSED_R11_EAC));
46 0 : fnAdd(FOO(COMPRESSED_SIGNED_R11_EAC));
47 0 : fnAdd(FOO(COMPRESSED_RG11_EAC));
48 0 : fnAdd(FOO(COMPRESSED_SIGNED_RG11_EAC));
49 0 : fnAdd(FOO(COMPRESSED_RGB8_ETC2));
50 0 : fnAdd(FOO(COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2));
51 0 : fnAdd(FOO(COMPRESSED_RGBA8_ETC2_EAC));
52 :
53 : // sRGB support is manadatory in GL 4.3 and GL ES 3.0, which are the only
54 : // versions to support ETC2.
55 0 : fnAdd(FOO(COMPRESSED_SRGB8_ALPHA8_ETC2_EAC));
56 0 : fnAdd(FOO(COMPRESSED_SRGB8_ETC2));
57 0 : fnAdd(FOO(COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2));
58 :
59 : #undef FOO
60 0 : }
61 :
62 0 : WebGLExtensionCompressedTextureES3::~WebGLExtensionCompressedTextureES3()
63 : {
64 0 : }
65 :
66 0 : IMPL_WEBGL_EXTENSION_GOOP(WebGLExtensionCompressedTextureES3, WEBGL_compressed_texture_etc)
67 :
68 : } // namespace mozilla
|