/src/mozilla-central/dom/canvas/WebGLExtensionCompressedTextureES3.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 | | WebGLExtensionCompressedTextureES3::WebGLExtensionCompressedTextureES3(WebGLContext* webgl) |
18 | | : WebGLExtensionBase(webgl) |
19 | 0 | { |
20 | 0 | // GLES 3.0.4, p147, table 3.19 |
21 | 0 | // GLES 3.0.4, p286+, $C.1 "ETC Compressed Texture Image Formats" |
22 | 0 | // Note that all compressed texture formats are filterable: |
23 | 0 | // GLES 3.0.4 p161: |
24 | 0 | // "[A] texture is complete unless any of the following conditions hold true: |
25 | 0 | // [...] |
26 | 0 | // * The effective internal format specified for the texture arrays is a sized |
27 | 0 | // internal color format that is not texture-filterable (see table 3.13) and [the |
28 | 0 | // mag filter requires filtering]." |
29 | 0 | // Compressed formats are not sized internal color formats, and indeed they are not |
30 | 0 | // listed in table 3.13. |
31 | 0 |
|
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 | 0 |
|
36 | 0 | auto usage = fua->EditUsage(effFormat); |
37 | 0 | usage->isFilterable = true; |
38 | 0 | fua->AllowSizedTexFormat(sizedFormat, usage); |
39 | 0 |
|
40 | 0 | webgl_->mCompressedTextureFormats.AppendElement(sizedFormat); |
41 | 0 | }; |
42 | 0 |
|
43 | 0 | #define FOO(x) LOCAL_GL_ ## x, webgl::EffectiveFormat::x |
44 | 0 |
|
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 | 0 |
|
53 | 0 | // sRGB support is manadatory in GL 4.3 and GL ES 3.0, which are the only |
54 | 0 | // 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 | 0 |
|
59 | 0 | #undef FOO |
60 | 0 | } |
61 | | |
62 | | WebGLExtensionCompressedTextureES3::~WebGLExtensionCompressedTextureES3() |
63 | 0 | { |
64 | 0 | } |
65 | | |
66 | | IMPL_WEBGL_EXTENSION_GOOP(WebGLExtensionCompressedTextureES3, WEBGL_compressed_texture_etc) |
67 | | |
68 | | } // namespace mozilla |