Bug 1936278 - Prevent search mode chiclet from being dismissed when clicking in page...
[gecko.git] / dom / canvas / ClientWebGLExtensions.cpp
blob78f661851f86d401940c1276fcf91f610670de38
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"
8 namespace mozilla {
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)
58 // --------------
60 JSObject* ClientWebGLExtensionDepthClamp::WrapObject(
61 JSContext* cx, JS::Handle<JSObject*> givenProto) {
62 return dom::EXT_depth_clamp_Binding::Wrap(cx, this, givenProto);
65 ClientWebGLExtensionDepthClamp::ClientWebGLExtensionDepthClamp(
66 ClientWebGLContext& webgl)
67 : ClientWebGLExtensionBase(webgl) {
68 auto& state = webgl.State();
69 // Add slot for new key:
70 state.mIsEnabledMap[LOCAL_GL_DEPTH_CLAMP] = false;
73 // --------------
75 JSObject* ClientWebGLExtensionDisjointTimerQuery::WrapObject(
76 JSContext* cx, JS::Handle<JSObject*> givenProto) {
77 return dom::EXT_disjoint_timer_query_Binding::Wrap(cx, this, givenProto);
80 ClientWebGLExtensionDisjointTimerQuery::ClientWebGLExtensionDisjointTimerQuery(
81 ClientWebGLContext& webgl)
82 : ClientWebGLExtensionBase(webgl) {
83 auto& state = webgl.State();
84 // Add slot for new key:
85 (void)state.mCurrentQueryByTarget[LOCAL_GL_TIME_ELAPSED];
88 // --------------
89 // Compressed textures
91 void ClientWebGLContext::AddCompressedFormat(const GLenum format) {
92 auto& state = State();
93 state.mCompressedTextureFormats.push_back(format);
96 // -
98 JSObject* ClientWebGLExtensionCompressedTextureASTC::WrapObject(
99 JSContext* cx, JS::Handle<JSObject*> givenProto) {
100 return dom::WEBGL_compressed_texture_astc_Binding::Wrap(cx, this, givenProto);
103 ClientWebGLExtensionCompressedTextureASTC::
104 ClientWebGLExtensionCompressedTextureASTC(ClientWebGLContext& webgl)
105 : ClientWebGLExtensionBase(webgl) {
106 #define _(X) webgl.AddCompressedFormat(LOCAL_GL_##X);
108 _(COMPRESSED_RGBA_ASTC_4x4_KHR)
109 _(COMPRESSED_RGBA_ASTC_5x4_KHR)
110 _(COMPRESSED_RGBA_ASTC_5x5_KHR)
111 _(COMPRESSED_RGBA_ASTC_6x5_KHR)
112 _(COMPRESSED_RGBA_ASTC_6x6_KHR)
113 _(COMPRESSED_RGBA_ASTC_8x5_KHR)
114 _(COMPRESSED_RGBA_ASTC_8x6_KHR)
115 _(COMPRESSED_RGBA_ASTC_8x8_KHR)
116 _(COMPRESSED_RGBA_ASTC_10x5_KHR)
117 _(COMPRESSED_RGBA_ASTC_10x6_KHR)
118 _(COMPRESSED_RGBA_ASTC_10x8_KHR)
119 _(COMPRESSED_RGBA_ASTC_10x10_KHR)
120 _(COMPRESSED_RGBA_ASTC_12x10_KHR)
121 _(COMPRESSED_RGBA_ASTC_12x12_KHR)
123 _(COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR)
124 _(COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR)
125 _(COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR)
126 _(COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR)
127 _(COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR)
128 _(COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR)
129 _(COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR)
130 _(COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR)
131 _(COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR)
132 _(COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR)
133 _(COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR)
134 _(COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR)
135 _(COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR)
136 _(COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR)
138 #undef _
141 // -
143 JSObject* ClientWebGLExtensionCompressedTextureBPTC::WrapObject(
144 JSContext* cx, JS::Handle<JSObject*> givenProto) {
145 return dom::EXT_texture_compression_bptc_Binding::Wrap(cx, this, givenProto);
148 ClientWebGLExtensionCompressedTextureBPTC::
149 ClientWebGLExtensionCompressedTextureBPTC(ClientWebGLContext& webgl)
150 : ClientWebGLExtensionBase(webgl) {
151 #define _(X) webgl.AddCompressedFormat(LOCAL_GL_##X);
152 _(COMPRESSED_RGBA_BPTC_UNORM)
153 _(COMPRESSED_SRGB_ALPHA_BPTC_UNORM)
154 _(COMPRESSED_RGB_BPTC_SIGNED_FLOAT)
155 _(COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT)
156 #undef _
159 // -
161 JSObject* ClientWebGLExtensionCompressedTextureRGTC::WrapObject(
162 JSContext* cx, JS::Handle<JSObject*> givenProto) {
163 return dom::EXT_texture_compression_rgtc_Binding::Wrap(cx, this, givenProto);
166 ClientWebGLExtensionCompressedTextureRGTC::
167 ClientWebGLExtensionCompressedTextureRGTC(ClientWebGLContext& webgl)
168 : ClientWebGLExtensionBase(webgl) {
169 #define _(X) webgl.AddCompressedFormat(LOCAL_GL_##X);
170 _(COMPRESSED_RED_RGTC1)
171 _(COMPRESSED_SIGNED_RED_RGTC1)
172 _(COMPRESSED_RG_RGTC2)
173 _(COMPRESSED_SIGNED_RG_RGTC2)
174 #undef _
177 // -
179 JSObject* ClientWebGLExtensionCompressedTextureES3::WrapObject(
180 JSContext* cx, JS::Handle<JSObject*> givenProto) {
181 return dom::WEBGL_compressed_texture_etc_Binding::Wrap(cx, this, givenProto);
183 ClientWebGLExtensionCompressedTextureES3::
184 ClientWebGLExtensionCompressedTextureES3(ClientWebGLContext& webgl)
185 : ClientWebGLExtensionBase(webgl) {
186 #define _(X) webgl.AddCompressedFormat(LOCAL_GL_##X);
187 _(COMPRESSED_R11_EAC)
188 _(COMPRESSED_SIGNED_R11_EAC)
189 _(COMPRESSED_RG11_EAC)
190 _(COMPRESSED_SIGNED_RG11_EAC)
191 _(COMPRESSED_RGB8_ETC2)
192 _(COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2)
193 _(COMPRESSED_RGBA8_ETC2_EAC)
195 // sRGB support is manadatory in GL 4.3 and GL ES 3.0, which are the only
196 // versions to support ETC2.
197 _(COMPRESSED_SRGB8_ALPHA8_ETC2_EAC)
198 _(COMPRESSED_SRGB8_ETC2)
199 _(COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2)
200 #undef _
203 // -
205 JSObject* ClientWebGLExtensionCompressedTextureETC1::WrapObject(
206 JSContext* cx, JS::Handle<JSObject*> givenProto) {
207 return dom::WEBGL_compressed_texture_etc1_Binding::Wrap(cx, this, givenProto);
209 ClientWebGLExtensionCompressedTextureETC1::
210 ClientWebGLExtensionCompressedTextureETC1(ClientWebGLContext& webgl)
211 : ClientWebGLExtensionBase(webgl) {
212 webgl.AddCompressedFormat(LOCAL_GL_ETC1_RGB8_OES);
215 // -
217 JSObject* ClientWebGLExtensionCompressedTexturePVRTC::WrapObject(
218 JSContext* cx, JS::Handle<JSObject*> givenProto) {
219 return dom::WEBGL_compressed_texture_pvrtc_Binding::Wrap(cx, this,
220 givenProto);
222 ClientWebGLExtensionCompressedTexturePVRTC::
223 ClientWebGLExtensionCompressedTexturePVRTC(ClientWebGLContext& webgl)
224 : ClientWebGLExtensionBase(webgl) {
225 #define _(X) webgl.AddCompressedFormat(LOCAL_GL_##X);
226 _(COMPRESSED_RGB_PVRTC_4BPPV1)
227 _(COMPRESSED_RGB_PVRTC_2BPPV1)
228 _(COMPRESSED_RGBA_PVRTC_4BPPV1)
229 _(COMPRESSED_RGBA_PVRTC_2BPPV1)
230 #undef _
233 // -
235 JSObject* ClientWebGLExtensionCompressedTextureS3TC::WrapObject(
236 JSContext* cx, JS::Handle<JSObject*> givenProto) {
237 return dom::WEBGL_compressed_texture_s3tc_Binding::Wrap(cx, this, givenProto);
239 ClientWebGLExtensionCompressedTextureS3TC::
240 ClientWebGLExtensionCompressedTextureS3TC(ClientWebGLContext& webgl)
241 : ClientWebGLExtensionBase(webgl) {
242 #define _(X) webgl.AddCompressedFormat(LOCAL_GL_##X);
243 _(COMPRESSED_RGB_S3TC_DXT1_EXT)
244 _(COMPRESSED_RGBA_S3TC_DXT1_EXT)
245 _(COMPRESSED_RGBA_S3TC_DXT3_EXT)
246 _(COMPRESSED_RGBA_S3TC_DXT5_EXT)
247 #undef _
250 // -
252 JSObject* ClientWebGLExtensionCompressedTextureS3TC_SRGB::WrapObject(
253 JSContext* cx, JS::Handle<JSObject*> givenProto) {
254 return dom::WEBGL_compressed_texture_s3tc_srgb_Binding::Wrap(cx, this,
255 givenProto);
258 ClientWebGLExtensionCompressedTextureS3TC_SRGB::
259 ClientWebGLExtensionCompressedTextureS3TC_SRGB(ClientWebGLContext& webgl)
260 : ClientWebGLExtensionBase(webgl) {
261 #define _(X) webgl.AddCompressedFormat(LOCAL_GL_##X);
262 _(COMPRESSED_SRGB_S3TC_DXT1_EXT)
263 _(COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT)
264 _(COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT)
265 _(COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT)
266 #undef _
269 } // namespace mozilla