Bug 1700051: part 26) Correct typo in comment of `mozInlineSpellWordUtil::BuildSoftTe...
[gecko.git] / dom / canvas / ClientWebGLExtensions.cpp
blobcc6073a352d060538f0cbfaed7e53e224599970b
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 NS_IMPL_CYCLE_COLLECTION_ROOT_NATIVE(ClientWebGLExtensionBase, AddRef)
13 NS_IMPL_CYCLE_COLLECTION_UNROOT_NATIVE(ClientWebGLExtensionBase, Release)
15 DEFINE_WEBGL_EXTENSION_GOOP(ANGLE_instanced_arrays,
16 WebGLExtensionInstancedArrays)
17 DEFINE_WEBGL_EXTENSION_GOOP(EXT_blend_minmax, WebGLExtensionBlendMinMax)
18 DEFINE_WEBGL_EXTENSION_GOOP(EXT_color_buffer_float,
19 WebGLExtensionEXTColorBufferFloat)
20 DEFINE_WEBGL_EXTENSION_GOOP(EXT_color_buffer_half_float,
21 WebGLExtensionColorBufferHalfFloat)
22 DEFINE_WEBGL_EXTENSION_GOOP(EXT_float_blend, WebGLExtensionFloatBlend)
23 DEFINE_WEBGL_EXTENSION_GOOP(EXT_frag_depth, WebGLExtensionFragDepth)
24 DEFINE_WEBGL_EXTENSION_GOOP(EXT_sRGB, WebGLExtensionSRGB)
25 DEFINE_WEBGL_EXTENSION_GOOP(EXT_shader_texture_lod,
26 WebGLExtensionShaderTextureLod)
27 DEFINE_WEBGL_EXTENSION_GOOP(EXT_texture_filter_anisotropic,
28 WebGLExtensionTextureFilterAnisotropic)
29 DEFINE_WEBGL_EXTENSION_GOOP(EXT_texture_norm16, WebGLExtensionTextureNorm16)
30 DEFINE_WEBGL_EXTENSION_GOOP(MOZ_debug, WebGLExtensionMOZDebug)
31 DEFINE_WEBGL_EXTENSION_GOOP(OES_element_index_uint,
32 WebGLExtensionElementIndexUint)
33 DEFINE_WEBGL_EXTENSION_GOOP(OES_fbo_render_mipmap,
34 WebGLExtensionFBORenderMipmap)
35 DEFINE_WEBGL_EXTENSION_GOOP(OES_standard_derivatives,
36 WebGLExtensionStandardDerivatives)
37 DEFINE_WEBGL_EXTENSION_GOOP(OES_texture_float, WebGLExtensionTextureFloat)
38 DEFINE_WEBGL_EXTENSION_GOOP(OES_texture_float_linear,
39 WebGLExtensionTextureFloatLinear)
40 DEFINE_WEBGL_EXTENSION_GOOP(OES_texture_half_float,
41 WebGLExtensionTextureHalfFloat)
42 DEFINE_WEBGL_EXTENSION_GOOP(OES_texture_half_float_linear,
43 WebGLExtensionTextureHalfFloatLinear)
44 DEFINE_WEBGL_EXTENSION_GOOP(OES_vertex_array_object, WebGLExtensionVertexArray)
45 DEFINE_WEBGL_EXTENSION_GOOP(OVR_multiview2, WebGLExtensionMultiview)
46 DEFINE_WEBGL_EXTENSION_GOOP(WEBGL_color_buffer_float,
47 WebGLExtensionColorBufferFloat)
48 DEFINE_WEBGL_EXTENSION_GOOP(WEBGL_debug_renderer_info,
49 WebGLExtensionDebugRendererInfo)
50 DEFINE_WEBGL_EXTENSION_GOOP(WEBGL_debug_shaders, WebGLExtensionDebugShaders)
51 DEFINE_WEBGL_EXTENSION_GOOP(WEBGL_depth_texture, WebGLExtensionDepthTexture)
52 DEFINE_WEBGL_EXTENSION_GOOP(WEBGL_draw_buffers, WebGLExtensionDrawBuffers)
53 DEFINE_WEBGL_EXTENSION_GOOP(WEBGL_explicit_present,
54 WebGLExtensionExplicitPresent)
55 DEFINE_WEBGL_EXTENSION_GOOP(WEBGL_lose_context, WebGLExtensionLoseContext)
57 // --------------
59 JSObject* ClientWebGLExtensionDisjointTimerQuery::WrapObject(
60 JSContext* cx, JS::Handle<JSObject*> givenProto) {
61 return dom::EXT_disjoint_timer_query_Binding::Wrap(cx, this, givenProto);
64 ClientWebGLExtensionDisjointTimerQuery::ClientWebGLExtensionDisjointTimerQuery(
65 ClientWebGLContext& webgl)
66 : ClientWebGLExtensionBase(webgl) {
67 auto& state = webgl.State();
68 // Add slot for new key:
69 (void)state.mCurrentQueryByTarget[LOCAL_GL_TIME_ELAPSED];
72 // --------------
73 // Compressed textures
75 void ClientWebGLContext::AddCompressedFormat(const GLenum format) {
76 auto& state = State();
77 state.mCompressedTextureFormats.push_back(format);
80 // -
82 JSObject* ClientWebGLExtensionCompressedTextureASTC::WrapObject(
83 JSContext* cx, JS::Handle<JSObject*> givenProto) {
84 return dom::WEBGL_compressed_texture_astc_Binding::Wrap(cx, this, givenProto);
87 ClientWebGLExtensionCompressedTextureASTC::
88 ClientWebGLExtensionCompressedTextureASTC(ClientWebGLContext& webgl)
89 : ClientWebGLExtensionBase(webgl) {
90 #define _(X) webgl.AddCompressedFormat(LOCAL_GL_##X);
92 _(COMPRESSED_RGBA_ASTC_4x4_KHR)
93 _(COMPRESSED_RGBA_ASTC_5x4_KHR)
94 _(COMPRESSED_RGBA_ASTC_5x5_KHR)
95 _(COMPRESSED_RGBA_ASTC_6x5_KHR)
96 _(COMPRESSED_RGBA_ASTC_6x6_KHR)
97 _(COMPRESSED_RGBA_ASTC_8x5_KHR)
98 _(COMPRESSED_RGBA_ASTC_8x6_KHR)
99 _(COMPRESSED_RGBA_ASTC_8x8_KHR)
100 _(COMPRESSED_RGBA_ASTC_10x5_KHR)
101 _(COMPRESSED_RGBA_ASTC_10x6_KHR)
102 _(COMPRESSED_RGBA_ASTC_10x8_KHR)
103 _(COMPRESSED_RGBA_ASTC_10x10_KHR)
104 _(COMPRESSED_RGBA_ASTC_12x10_KHR)
105 _(COMPRESSED_RGBA_ASTC_12x12_KHR)
107 _(COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR)
108 _(COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR)
109 _(COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR)
110 _(COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR)
111 _(COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR)
112 _(COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR)
113 _(COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR)
114 _(COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR)
115 _(COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR)
116 _(COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR)
117 _(COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR)
118 _(COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR)
119 _(COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR)
120 _(COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR)
122 #undef _
125 // -
127 JSObject* ClientWebGLExtensionCompressedTextureBPTC::WrapObject(
128 JSContext* cx, JS::Handle<JSObject*> givenProto) {
129 return dom::EXT_texture_compression_bptc_Binding::Wrap(cx, this, givenProto);
132 ClientWebGLExtensionCompressedTextureBPTC::
133 ClientWebGLExtensionCompressedTextureBPTC(ClientWebGLContext& webgl)
134 : ClientWebGLExtensionBase(webgl) {
135 #define _(X) webgl.AddCompressedFormat(LOCAL_GL_##X);
136 _(COMPRESSED_RGBA_BPTC_UNORM)
137 _(COMPRESSED_SRGB_ALPHA_BPTC_UNORM)
138 _(COMPRESSED_RGB_BPTC_SIGNED_FLOAT)
139 _(COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT)
140 #undef _
143 // -
145 JSObject* ClientWebGLExtensionCompressedTextureRGTC::WrapObject(
146 JSContext* cx, JS::Handle<JSObject*> givenProto) {
147 return dom::EXT_texture_compression_rgtc_Binding::Wrap(cx, this, givenProto);
150 ClientWebGLExtensionCompressedTextureRGTC::
151 ClientWebGLExtensionCompressedTextureRGTC(ClientWebGLContext& webgl)
152 : ClientWebGLExtensionBase(webgl) {
153 #define _(X) webgl.AddCompressedFormat(LOCAL_GL_##X);
154 _(COMPRESSED_RED_RGTC1)
155 _(COMPRESSED_SIGNED_RED_RGTC1)
156 _(COMPRESSED_RG_RGTC2)
157 _(COMPRESSED_SIGNED_RG_RGTC2)
158 #undef _
161 // -
163 JSObject* ClientWebGLExtensionCompressedTextureES3::WrapObject(
164 JSContext* cx, JS::Handle<JSObject*> givenProto) {
165 return dom::WEBGL_compressed_texture_etc_Binding::Wrap(cx, this, givenProto);
167 ClientWebGLExtensionCompressedTextureES3::
168 ClientWebGLExtensionCompressedTextureES3(ClientWebGLContext& webgl)
169 : ClientWebGLExtensionBase(webgl) {
170 #define _(X) webgl.AddCompressedFormat(LOCAL_GL_##X);
171 _(COMPRESSED_R11_EAC)
172 _(COMPRESSED_SIGNED_R11_EAC)
173 _(COMPRESSED_RG11_EAC)
174 _(COMPRESSED_SIGNED_RG11_EAC)
175 _(COMPRESSED_RGB8_ETC2)
176 _(COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2)
177 _(COMPRESSED_RGBA8_ETC2_EAC)
179 // sRGB support is manadatory in GL 4.3 and GL ES 3.0, which are the only
180 // versions to support ETC2.
181 _(COMPRESSED_SRGB8_ALPHA8_ETC2_EAC)
182 _(COMPRESSED_SRGB8_ETC2)
183 _(COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2)
184 #undef _
187 // -
189 JSObject* ClientWebGLExtensionCompressedTextureETC1::WrapObject(
190 JSContext* cx, JS::Handle<JSObject*> givenProto) {
191 return dom::WEBGL_compressed_texture_etc1_Binding::Wrap(cx, this, givenProto);
193 ClientWebGLExtensionCompressedTextureETC1::
194 ClientWebGLExtensionCompressedTextureETC1(ClientWebGLContext& webgl)
195 : ClientWebGLExtensionBase(webgl) {
196 webgl.AddCompressedFormat(LOCAL_GL_ETC1_RGB8_OES);
199 // -
201 JSObject* ClientWebGLExtensionCompressedTexturePVRTC::WrapObject(
202 JSContext* cx, JS::Handle<JSObject*> givenProto) {
203 return dom::WEBGL_compressed_texture_pvrtc_Binding::Wrap(cx, this,
204 givenProto);
206 ClientWebGLExtensionCompressedTexturePVRTC::
207 ClientWebGLExtensionCompressedTexturePVRTC(ClientWebGLContext& webgl)
208 : ClientWebGLExtensionBase(webgl) {
209 #define _(X) webgl.AddCompressedFormat(LOCAL_GL_##X);
210 _(COMPRESSED_RGB_PVRTC_4BPPV1)
211 _(COMPRESSED_RGB_PVRTC_2BPPV1)
212 _(COMPRESSED_RGBA_PVRTC_4BPPV1)
213 _(COMPRESSED_RGBA_PVRTC_2BPPV1)
214 #undef _
217 // -
219 JSObject* ClientWebGLExtensionCompressedTextureS3TC::WrapObject(
220 JSContext* cx, JS::Handle<JSObject*> givenProto) {
221 return dom::WEBGL_compressed_texture_s3tc_Binding::Wrap(cx, this, givenProto);
223 ClientWebGLExtensionCompressedTextureS3TC::
224 ClientWebGLExtensionCompressedTextureS3TC(ClientWebGLContext& webgl)
225 : ClientWebGLExtensionBase(webgl) {
226 #define _(X) webgl.AddCompressedFormat(LOCAL_GL_##X);
227 _(COMPRESSED_RGB_S3TC_DXT1_EXT)
228 _(COMPRESSED_RGBA_S3TC_DXT1_EXT)
229 _(COMPRESSED_RGBA_S3TC_DXT3_EXT)
230 _(COMPRESSED_RGBA_S3TC_DXT5_EXT)
231 #undef _
234 // -
236 JSObject* ClientWebGLExtensionCompressedTextureS3TC_SRGB::WrapObject(
237 JSContext* cx, JS::Handle<JSObject*> givenProto) {
238 return dom::WEBGL_compressed_texture_s3tc_srgb_Binding::Wrap(cx, this,
239 givenProto);
242 ClientWebGLExtensionCompressedTextureS3TC_SRGB::
243 ClientWebGLExtensionCompressedTextureS3TC_SRGB(ClientWebGLContext& webgl)
244 : ClientWebGLExtensionBase(webgl) {
245 #define _(X) webgl.AddCompressedFormat(LOCAL_GL_##X);
246 _(COMPRESSED_SRGB_S3TC_DXT1_EXT)
247 _(COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT)
248 _(COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT)
249 _(COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT)
250 #undef _
253 } // namespace mozilla