1 /* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #include "ClientWebGLExtensions.h"
10 NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE_0(ClientWebGLExtensionBase
)
12 DEFINE_WEBGL_EXTENSION_GOOP(ANGLE_instanced_arrays
,
13 WebGLExtensionInstancedArrays
)
14 DEFINE_WEBGL_EXTENSION_GOOP(EXT_blend_minmax
, WebGLExtensionBlendMinMax
)
15 DEFINE_WEBGL_EXTENSION_GOOP(EXT_color_buffer_float
,
16 WebGLExtensionEXTColorBufferFloat
)
17 DEFINE_WEBGL_EXTENSION_GOOP(EXT_color_buffer_half_float
,
18 WebGLExtensionColorBufferHalfFloat
)
19 DEFINE_WEBGL_EXTENSION_GOOP(EXT_float_blend
, WebGLExtensionFloatBlend
)
20 DEFINE_WEBGL_EXTENSION_GOOP(EXT_frag_depth
, WebGLExtensionFragDepth
)
21 DEFINE_WEBGL_EXTENSION_GOOP(EXT_sRGB
, WebGLExtensionSRGB
)
22 DEFINE_WEBGL_EXTENSION_GOOP(EXT_shader_texture_lod
,
23 WebGLExtensionShaderTextureLod
)
24 DEFINE_WEBGL_EXTENSION_GOOP(EXT_texture_filter_anisotropic
,
25 WebGLExtensionTextureFilterAnisotropic
)
26 DEFINE_WEBGL_EXTENSION_GOOP(EXT_texture_norm16
, WebGLExtensionTextureNorm16
)
27 DEFINE_WEBGL_EXTENSION_GOOP(MOZ_debug
, WebGLExtensionMOZDebug
)
28 DEFINE_WEBGL_EXTENSION_GOOP(OES_draw_buffers_indexed
,
29 WebGLExtensionDrawBuffersIndexed
)
30 DEFINE_WEBGL_EXTENSION_GOOP(OES_element_index_uint
,
31 WebGLExtensionElementIndexUint
)
32 DEFINE_WEBGL_EXTENSION_GOOP(OES_fbo_render_mipmap
,
33 WebGLExtensionFBORenderMipmap
)
34 DEFINE_WEBGL_EXTENSION_GOOP(OES_standard_derivatives
,
35 WebGLExtensionStandardDerivatives
)
36 DEFINE_WEBGL_EXTENSION_GOOP(OES_texture_float
, WebGLExtensionTextureFloat
)
37 DEFINE_WEBGL_EXTENSION_GOOP(OES_texture_float_linear
,
38 WebGLExtensionTextureFloatLinear
)
39 DEFINE_WEBGL_EXTENSION_GOOP(OES_texture_half_float
,
40 WebGLExtensionTextureHalfFloat
)
41 DEFINE_WEBGL_EXTENSION_GOOP(OES_texture_half_float_linear
,
42 WebGLExtensionTextureHalfFloatLinear
)
43 DEFINE_WEBGL_EXTENSION_GOOP(OES_vertex_array_object
, WebGLExtensionVertexArray
)
44 DEFINE_WEBGL_EXTENSION_GOOP(OVR_multiview2
, WebGLExtensionMultiview
)
45 DEFINE_WEBGL_EXTENSION_GOOP(WEBGL_color_buffer_float
,
46 WebGLExtensionColorBufferFloat
)
47 DEFINE_WEBGL_EXTENSION_GOOP(WEBGL_debug_renderer_info
,
48 WebGLExtensionDebugRendererInfo
)
49 DEFINE_WEBGL_EXTENSION_GOOP(WEBGL_debug_shaders
, WebGLExtensionDebugShaders
)
50 DEFINE_WEBGL_EXTENSION_GOOP(WEBGL_depth_texture
, WebGLExtensionDepthTexture
)
51 DEFINE_WEBGL_EXTENSION_GOOP(WEBGL_draw_buffers
, WebGLExtensionDrawBuffers
)
52 DEFINE_WEBGL_EXTENSION_GOOP(WEBGL_explicit_present
,
53 WebGLExtensionExplicitPresent
)
54 DEFINE_WEBGL_EXTENSION_GOOP(WEBGL_lose_context
, WebGLExtensionLoseContext
)
55 DEFINE_WEBGL_EXTENSION_GOOP(WEBGL_provoking_vertex
,
56 WebGLExtensionProvokingVertex
)
60 JSObject
* ClientWebGLExtensionDisjointTimerQuery::WrapObject(
61 JSContext
* cx
, JS::Handle
<JSObject
*> givenProto
) {
62 return dom::EXT_disjoint_timer_query_Binding::Wrap(cx
, this, givenProto
);
65 ClientWebGLExtensionDisjointTimerQuery::ClientWebGLExtensionDisjointTimerQuery(
66 ClientWebGLContext
& webgl
)
67 : ClientWebGLExtensionBase(webgl
) {
68 auto& state
= webgl
.State();
69 // Add slot for new key:
70 (void)state
.mCurrentQueryByTarget
[LOCAL_GL_TIME_ELAPSED
];
74 // Compressed textures
76 void ClientWebGLContext::AddCompressedFormat(const GLenum format
) {
77 auto& state
= State();
78 state
.mCompressedTextureFormats
.push_back(format
);
83 JSObject
* ClientWebGLExtensionCompressedTextureASTC::WrapObject(
84 JSContext
* cx
, JS::Handle
<JSObject
*> givenProto
) {
85 return dom::WEBGL_compressed_texture_astc_Binding::Wrap(cx
, this, givenProto
);
88 ClientWebGLExtensionCompressedTextureASTC::
89 ClientWebGLExtensionCompressedTextureASTC(ClientWebGLContext
& webgl
)
90 : ClientWebGLExtensionBase(webgl
) {
91 #define _(X) webgl.AddCompressedFormat(LOCAL_GL_##X);
93 _(COMPRESSED_RGBA_ASTC_4x4_KHR
)
94 _(COMPRESSED_RGBA_ASTC_5x4_KHR
)
95 _(COMPRESSED_RGBA_ASTC_5x5_KHR
)
96 _(COMPRESSED_RGBA_ASTC_6x5_KHR
)
97 _(COMPRESSED_RGBA_ASTC_6x6_KHR
)
98 _(COMPRESSED_RGBA_ASTC_8x5_KHR
)
99 _(COMPRESSED_RGBA_ASTC_8x6_KHR
)
100 _(COMPRESSED_RGBA_ASTC_8x8_KHR
)
101 _(COMPRESSED_RGBA_ASTC_10x5_KHR
)
102 _(COMPRESSED_RGBA_ASTC_10x6_KHR
)
103 _(COMPRESSED_RGBA_ASTC_10x8_KHR
)
104 _(COMPRESSED_RGBA_ASTC_10x10_KHR
)
105 _(COMPRESSED_RGBA_ASTC_12x10_KHR
)
106 _(COMPRESSED_RGBA_ASTC_12x12_KHR
)
108 _(COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR
)
109 _(COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR
)
110 _(COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR
)
111 _(COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR
)
112 _(COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR
)
113 _(COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR
)
114 _(COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR
)
115 _(COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR
)
116 _(COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR
)
117 _(COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR
)
118 _(COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR
)
119 _(COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR
)
120 _(COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR
)
121 _(COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR
)
128 JSObject
* ClientWebGLExtensionCompressedTextureBPTC::WrapObject(
129 JSContext
* cx
, JS::Handle
<JSObject
*> givenProto
) {
130 return dom::EXT_texture_compression_bptc_Binding::Wrap(cx
, this, givenProto
);
133 ClientWebGLExtensionCompressedTextureBPTC::
134 ClientWebGLExtensionCompressedTextureBPTC(ClientWebGLContext
& webgl
)
135 : ClientWebGLExtensionBase(webgl
) {
136 #define _(X) webgl.AddCompressedFormat(LOCAL_GL_##X);
137 _(COMPRESSED_RGBA_BPTC_UNORM
)
138 _(COMPRESSED_SRGB_ALPHA_BPTC_UNORM
)
139 _(COMPRESSED_RGB_BPTC_SIGNED_FLOAT
)
140 _(COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT
)
146 JSObject
* ClientWebGLExtensionCompressedTextureRGTC::WrapObject(
147 JSContext
* cx
, JS::Handle
<JSObject
*> givenProto
) {
148 return dom::EXT_texture_compression_rgtc_Binding::Wrap(cx
, this, givenProto
);
151 ClientWebGLExtensionCompressedTextureRGTC::
152 ClientWebGLExtensionCompressedTextureRGTC(ClientWebGLContext
& webgl
)
153 : ClientWebGLExtensionBase(webgl
) {
154 #define _(X) webgl.AddCompressedFormat(LOCAL_GL_##X);
155 _(COMPRESSED_RED_RGTC1
)
156 _(COMPRESSED_SIGNED_RED_RGTC1
)
157 _(COMPRESSED_RG_RGTC2
)
158 _(COMPRESSED_SIGNED_RG_RGTC2
)
164 JSObject
* ClientWebGLExtensionCompressedTextureES3::WrapObject(
165 JSContext
* cx
, JS::Handle
<JSObject
*> givenProto
) {
166 return dom::WEBGL_compressed_texture_etc_Binding::Wrap(cx
, this, givenProto
);
168 ClientWebGLExtensionCompressedTextureES3::
169 ClientWebGLExtensionCompressedTextureES3(ClientWebGLContext
& webgl
)
170 : ClientWebGLExtensionBase(webgl
) {
171 #define _(X) webgl.AddCompressedFormat(LOCAL_GL_##X);
172 _(COMPRESSED_R11_EAC
)
173 _(COMPRESSED_SIGNED_R11_EAC
)
174 _(COMPRESSED_RG11_EAC
)
175 _(COMPRESSED_SIGNED_RG11_EAC
)
176 _(COMPRESSED_RGB8_ETC2
)
177 _(COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2
)
178 _(COMPRESSED_RGBA8_ETC2_EAC
)
180 // sRGB support is manadatory in GL 4.3 and GL ES 3.0, which are the only
181 // versions to support ETC2.
182 _(COMPRESSED_SRGB8_ALPHA8_ETC2_EAC
)
183 _(COMPRESSED_SRGB8_ETC2
)
184 _(COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2
)
190 JSObject
* ClientWebGLExtensionCompressedTextureETC1::WrapObject(
191 JSContext
* cx
, JS::Handle
<JSObject
*> givenProto
) {
192 return dom::WEBGL_compressed_texture_etc1_Binding::Wrap(cx
, this, givenProto
);
194 ClientWebGLExtensionCompressedTextureETC1::
195 ClientWebGLExtensionCompressedTextureETC1(ClientWebGLContext
& webgl
)
196 : ClientWebGLExtensionBase(webgl
) {
197 webgl
.AddCompressedFormat(LOCAL_GL_ETC1_RGB8_OES
);
202 JSObject
* ClientWebGLExtensionCompressedTexturePVRTC::WrapObject(
203 JSContext
* cx
, JS::Handle
<JSObject
*> givenProto
) {
204 return dom::WEBGL_compressed_texture_pvrtc_Binding::Wrap(cx
, this,
207 ClientWebGLExtensionCompressedTexturePVRTC::
208 ClientWebGLExtensionCompressedTexturePVRTC(ClientWebGLContext
& webgl
)
209 : ClientWebGLExtensionBase(webgl
) {
210 #define _(X) webgl.AddCompressedFormat(LOCAL_GL_##X);
211 _(COMPRESSED_RGB_PVRTC_4BPPV1
)
212 _(COMPRESSED_RGB_PVRTC_2BPPV1
)
213 _(COMPRESSED_RGBA_PVRTC_4BPPV1
)
214 _(COMPRESSED_RGBA_PVRTC_2BPPV1
)
220 JSObject
* ClientWebGLExtensionCompressedTextureS3TC::WrapObject(
221 JSContext
* cx
, JS::Handle
<JSObject
*> givenProto
) {
222 return dom::WEBGL_compressed_texture_s3tc_Binding::Wrap(cx
, this, givenProto
);
224 ClientWebGLExtensionCompressedTextureS3TC::
225 ClientWebGLExtensionCompressedTextureS3TC(ClientWebGLContext
& webgl
)
226 : ClientWebGLExtensionBase(webgl
) {
227 #define _(X) webgl.AddCompressedFormat(LOCAL_GL_##X);
228 _(COMPRESSED_RGB_S3TC_DXT1_EXT
)
229 _(COMPRESSED_RGBA_S3TC_DXT1_EXT
)
230 _(COMPRESSED_RGBA_S3TC_DXT3_EXT
)
231 _(COMPRESSED_RGBA_S3TC_DXT5_EXT
)
237 JSObject
* ClientWebGLExtensionCompressedTextureS3TC_SRGB::WrapObject(
238 JSContext
* cx
, JS::Handle
<JSObject
*> givenProto
) {
239 return dom::WEBGL_compressed_texture_s3tc_srgb_Binding::Wrap(cx
, this,
243 ClientWebGLExtensionCompressedTextureS3TC_SRGB::
244 ClientWebGLExtensionCompressedTextureS3TC_SRGB(ClientWebGLContext
& webgl
)
245 : ClientWebGLExtensionBase(webgl
) {
246 #define _(X) webgl.AddCompressedFormat(LOCAL_GL_##X);
247 _(COMPRESSED_SRGB_S3TC_DXT1_EXT
)
248 _(COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT
)
249 _(COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT
)
250 _(COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT
)
254 } // namespace mozilla