Line data Source code
1 : /* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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/. */
5 :
6 : #ifndef WEBGL_EXTENSIONS_H_
7 : #define WEBGL_EXTENSIONS_H_
8 :
9 : #include "mozilla/AlreadyAddRefed.h"
10 : #include "nsString.h"
11 : #include "nsTArray.h"
12 : #include "nsWrapperCache.h"
13 : #include "WebGLObjectModel.h"
14 : #include "WebGLTypes.h"
15 :
16 : namespace mozilla {
17 : class ErrorResult;
18 :
19 : namespace dom {
20 : template<typename> struct Nullable;
21 : template<typename> class Sequence;
22 : } // namespace dom
23 :
24 : namespace webgl {
25 : class FormatUsageAuthority;
26 : } // namespace webgl
27 :
28 : class WebGLContext;
29 : class WebGLShader;
30 : class WebGLQuery;
31 : class WebGLVertexArray;
32 :
33 : class WebGLExtensionBase
34 : : public nsWrapperCache
35 : , public WebGLContextBoundObject
36 : {
37 : public:
38 : explicit WebGLExtensionBase(WebGLContext* webgl);
39 :
40 0 : WebGLContext* GetParentObject() const {
41 0 : return mContext;
42 : }
43 :
44 : void MarkLost();
45 :
46 0 : NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(WebGLExtensionBase)
47 0 : NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(WebGLExtensionBase)
48 :
49 : protected:
50 : virtual ~WebGLExtensionBase();
51 :
52 0 : virtual void OnMarkLost() { }
53 :
54 : bool mIsLost;
55 : };
56 :
57 : #define DECL_WEBGL_EXTENSION_GOOP \
58 : virtual JSObject* WrapObject(JSContext* cx, JS::Handle<JSObject*> givenProto) override;
59 :
60 : #define IMPL_WEBGL_EXTENSION_GOOP(WebGLExtensionType, WebGLBindingType)\
61 : JSObject* \
62 : WebGLExtensionType::WrapObject(JSContext* cx, JS::Handle<JSObject*> givenProto) { \
63 : return dom::WebGLBindingType##Binding::Wrap(cx, this, givenProto); \
64 : }
65 :
66 : ////
67 :
68 : class WebGLExtensionCompressedTextureASTC
69 : : public WebGLExtensionBase
70 : {
71 : public:
72 : explicit WebGLExtensionCompressedTextureASTC(WebGLContext* webgl);
73 : virtual ~WebGLExtensionCompressedTextureASTC();
74 :
75 : void GetSupportedProfiles(dom::Nullable< nsTArray<nsString> >& retval) const;
76 :
77 : static bool IsSupported(const WebGLContext* webgl);
78 :
79 : DECL_WEBGL_EXTENSION_GOOP
80 : };
81 :
82 : class WebGLExtensionCompressedTextureATC
83 : : public WebGLExtensionBase
84 : {
85 : public:
86 : explicit WebGLExtensionCompressedTextureATC(WebGLContext*);
87 : virtual ~WebGLExtensionCompressedTextureATC();
88 :
89 : DECL_WEBGL_EXTENSION_GOOP
90 : };
91 :
92 : class WebGLExtensionCompressedTextureES3
93 : : public WebGLExtensionBase
94 : {
95 : public:
96 : explicit WebGLExtensionCompressedTextureES3(WebGLContext*);
97 : virtual ~WebGLExtensionCompressedTextureES3();
98 :
99 : DECL_WEBGL_EXTENSION_GOOP
100 : };
101 :
102 : class WebGLExtensionCompressedTextureETC1
103 : : public WebGLExtensionBase
104 : {
105 : public:
106 : explicit WebGLExtensionCompressedTextureETC1(WebGLContext*);
107 : virtual ~WebGLExtensionCompressedTextureETC1();
108 :
109 : DECL_WEBGL_EXTENSION_GOOP
110 : };
111 :
112 : class WebGLExtensionCompressedTexturePVRTC
113 : : public WebGLExtensionBase
114 : {
115 : public:
116 : explicit WebGLExtensionCompressedTexturePVRTC(WebGLContext*);
117 : virtual ~WebGLExtensionCompressedTexturePVRTC();
118 :
119 : DECL_WEBGL_EXTENSION_GOOP
120 : };
121 :
122 : class WebGLExtensionCompressedTextureS3TC
123 : : public WebGLExtensionBase
124 : {
125 : public:
126 : explicit WebGLExtensionCompressedTextureS3TC(WebGLContext*);
127 : virtual ~WebGLExtensionCompressedTextureS3TC();
128 :
129 : static bool IsSupported(const WebGLContext*);
130 :
131 : DECL_WEBGL_EXTENSION_GOOP
132 : };
133 :
134 : class WebGLExtensionCompressedTextureS3TC_SRGB
135 : : public WebGLExtensionBase
136 : {
137 : public:
138 : explicit WebGLExtensionCompressedTextureS3TC_SRGB(WebGLContext*);
139 : virtual ~WebGLExtensionCompressedTextureS3TC_SRGB();
140 :
141 : DECL_WEBGL_EXTENSION_GOOP
142 : };
143 :
144 : class WebGLExtensionDebugRendererInfo
145 : : public WebGLExtensionBase
146 : {
147 : public:
148 : explicit WebGLExtensionDebugRendererInfo(WebGLContext*);
149 : virtual ~WebGLExtensionDebugRendererInfo();
150 :
151 : DECL_WEBGL_EXTENSION_GOOP
152 : };
153 :
154 : class WebGLExtensionDebugShaders
155 : : public WebGLExtensionBase
156 : {
157 : public:
158 : explicit WebGLExtensionDebugShaders(WebGLContext*);
159 : virtual ~WebGLExtensionDebugShaders();
160 :
161 : void GetTranslatedShaderSource(const WebGLShader& shader, nsAString& retval) const;
162 :
163 : DECL_WEBGL_EXTENSION_GOOP
164 : };
165 :
166 : class WebGLExtensionDepthTexture
167 : : public WebGLExtensionBase
168 : {
169 : public:
170 : explicit WebGLExtensionDepthTexture(WebGLContext*);
171 : virtual ~WebGLExtensionDepthTexture();
172 :
173 : DECL_WEBGL_EXTENSION_GOOP
174 : };
175 :
176 : class WebGLExtensionElementIndexUint
177 : : public WebGLExtensionBase
178 : {
179 : public:
180 : explicit WebGLExtensionElementIndexUint(WebGLContext*);
181 : virtual ~WebGLExtensionElementIndexUint();
182 :
183 : DECL_WEBGL_EXTENSION_GOOP
184 : };
185 :
186 : class WebGLExtensionEXTColorBufferFloat
187 : : public WebGLExtensionBase
188 : {
189 : public:
190 : explicit WebGLExtensionEXTColorBufferFloat(WebGLContext*);
191 0 : virtual ~WebGLExtensionEXTColorBufferFloat() { }
192 :
193 : static bool IsSupported(const WebGLContext*);
194 :
195 : DECL_WEBGL_EXTENSION_GOOP
196 : };
197 :
198 : class WebGLExtensionFragDepth
199 : : public WebGLExtensionBase
200 : {
201 : public:
202 : explicit WebGLExtensionFragDepth(WebGLContext*);
203 : virtual ~WebGLExtensionFragDepth();
204 :
205 : static bool IsSupported(const WebGLContext* context);
206 :
207 : DECL_WEBGL_EXTENSION_GOOP
208 : };
209 :
210 : class WebGLExtensionLoseContext
211 : : public WebGLExtensionBase
212 : {
213 : public:
214 : explicit WebGLExtensionLoseContext(WebGLContext*);
215 : virtual ~WebGLExtensionLoseContext();
216 :
217 : void LoseContext();
218 : void RestoreContext();
219 :
220 : DECL_WEBGL_EXTENSION_GOOP
221 : };
222 :
223 : class WebGLExtensionSRGB
224 : : public WebGLExtensionBase
225 : {
226 : public:
227 : explicit WebGLExtensionSRGB(WebGLContext*);
228 : virtual ~WebGLExtensionSRGB();
229 :
230 : static bool IsSupported(const WebGLContext* context);
231 :
232 : DECL_WEBGL_EXTENSION_GOOP
233 : };
234 :
235 : class WebGLExtensionStandardDerivatives
236 : : public WebGLExtensionBase
237 : {
238 : public:
239 : explicit WebGLExtensionStandardDerivatives(WebGLContext*);
240 : virtual ~WebGLExtensionStandardDerivatives();
241 :
242 : DECL_WEBGL_EXTENSION_GOOP
243 : };
244 :
245 : class WebGLExtensionShaderTextureLod
246 : : public WebGLExtensionBase
247 : {
248 : public:
249 : explicit WebGLExtensionShaderTextureLod(WebGLContext*);
250 : virtual ~WebGLExtensionShaderTextureLod();
251 :
252 : DECL_WEBGL_EXTENSION_GOOP
253 : };
254 :
255 : class WebGLExtensionTextureFilterAnisotropic
256 : : public WebGLExtensionBase
257 : {
258 : public:
259 : explicit WebGLExtensionTextureFilterAnisotropic(WebGLContext*);
260 : virtual ~WebGLExtensionTextureFilterAnisotropic();
261 :
262 : DECL_WEBGL_EXTENSION_GOOP
263 : };
264 :
265 : class WebGLExtensionTextureFloat
266 : : public WebGLExtensionBase
267 : {
268 : public:
269 : static void InitWebGLFormats(webgl::FormatUsageAuthority* authority);
270 :
271 : explicit WebGLExtensionTextureFloat(WebGLContext*);
272 : virtual ~WebGLExtensionTextureFloat();
273 :
274 : static bool IsSupported(const WebGLContext*);
275 :
276 : DECL_WEBGL_EXTENSION_GOOP
277 : };
278 :
279 : class WebGLExtensionTextureFloatLinear
280 : : public WebGLExtensionBase
281 : {
282 : public:
283 : explicit WebGLExtensionTextureFloatLinear(WebGLContext*);
284 : virtual ~WebGLExtensionTextureFloatLinear();
285 :
286 : DECL_WEBGL_EXTENSION_GOOP
287 : };
288 :
289 : class WebGLExtensionTextureHalfFloat
290 : : public WebGLExtensionBase
291 : {
292 : public:
293 : static void InitWebGLFormats(webgl::FormatUsageAuthority* authority);
294 :
295 : explicit WebGLExtensionTextureHalfFloat(WebGLContext*);
296 : virtual ~WebGLExtensionTextureHalfFloat();
297 :
298 : static bool IsSupported(const WebGLContext*);
299 :
300 : DECL_WEBGL_EXTENSION_GOOP
301 : };
302 :
303 : class WebGLExtensionTextureHalfFloatLinear
304 : : public WebGLExtensionBase
305 : {
306 : public:
307 : explicit WebGLExtensionTextureHalfFloatLinear(WebGLContext*);
308 : virtual ~WebGLExtensionTextureHalfFloatLinear();
309 :
310 : DECL_WEBGL_EXTENSION_GOOP
311 : };
312 :
313 : class WebGLExtensionColorBufferFloat
314 : : public WebGLExtensionBase
315 : {
316 : public:
317 : explicit WebGLExtensionColorBufferFloat(WebGLContext*);
318 : virtual ~WebGLExtensionColorBufferFloat();
319 :
320 : static bool IsSupported(const WebGLContext*);
321 :
322 : DECL_WEBGL_EXTENSION_GOOP
323 : };
324 :
325 : class WebGLExtensionColorBufferHalfFloat
326 : : public WebGLExtensionBase
327 : {
328 : public:
329 : explicit WebGLExtensionColorBufferHalfFloat(WebGLContext*);
330 : virtual ~WebGLExtensionColorBufferHalfFloat();
331 :
332 : static bool IsSupported(const WebGLContext*);
333 :
334 : DECL_WEBGL_EXTENSION_GOOP
335 : };
336 :
337 : class WebGLExtensionDrawBuffers
338 : : public WebGLExtensionBase
339 : {
340 : public:
341 : explicit WebGLExtensionDrawBuffers(WebGLContext*);
342 : virtual ~WebGLExtensionDrawBuffers();
343 :
344 : void DrawBuffersWEBGL(const dom::Sequence<GLenum>& buffers);
345 :
346 : static bool IsSupported(const WebGLContext*);
347 :
348 : DECL_WEBGL_EXTENSION_GOOP
349 : };
350 :
351 : class WebGLExtensionVertexArray
352 : : public WebGLExtensionBase
353 : {
354 : public:
355 : explicit WebGLExtensionVertexArray(WebGLContext* webgl);
356 : virtual ~WebGLExtensionVertexArray();
357 :
358 : already_AddRefed<WebGLVertexArray> CreateVertexArrayOES();
359 : void DeleteVertexArrayOES(WebGLVertexArray* array);
360 : bool IsVertexArrayOES(const WebGLVertexArray* array);
361 : void BindVertexArrayOES(WebGLVertexArray* array);
362 :
363 : DECL_WEBGL_EXTENSION_GOOP
364 : };
365 :
366 : class WebGLExtensionInstancedArrays
367 : : public WebGLExtensionBase
368 : {
369 : public:
370 : explicit WebGLExtensionInstancedArrays(WebGLContext* webgl);
371 : virtual ~WebGLExtensionInstancedArrays();
372 :
373 : void DrawArraysInstancedANGLE(GLenum mode, GLint first, GLsizei count,
374 : GLsizei primcount);
375 : void DrawElementsInstancedANGLE(GLenum mode, GLsizei count, GLenum type,
376 : WebGLintptr offset, GLsizei primcount);
377 : void VertexAttribDivisorANGLE(GLuint index, GLuint divisor);
378 :
379 : static bool IsSupported(const WebGLContext* webgl);
380 :
381 : DECL_WEBGL_EXTENSION_GOOP
382 : };
383 :
384 : class WebGLExtensionBlendMinMax
385 : : public WebGLExtensionBase
386 : {
387 : public:
388 : explicit WebGLExtensionBlendMinMax(WebGLContext* webgl);
389 : virtual ~WebGLExtensionBlendMinMax();
390 :
391 : static bool IsSupported(const WebGLContext*);
392 :
393 : DECL_WEBGL_EXTENSION_GOOP
394 : };
395 :
396 : class WebGLExtensionDisjointTimerQuery
397 : : public WebGLExtensionBase
398 : {
399 : public:
400 : explicit WebGLExtensionDisjointTimerQuery(WebGLContext* webgl);
401 : virtual ~WebGLExtensionDisjointTimerQuery();
402 :
403 : already_AddRefed<WebGLQuery> CreateQueryEXT() const;
404 : void DeleteQueryEXT(WebGLQuery* query) const;
405 : bool IsQueryEXT(const WebGLQuery* query) const;
406 : void BeginQueryEXT(GLenum target, WebGLQuery& query) const;
407 : void EndQueryEXT(GLenum target) const;
408 : void QueryCounterEXT(WebGLQuery& query, GLenum target) const;
409 : void GetQueryEXT(JSContext* cx, GLenum target, GLenum pname,
410 : JS::MutableHandleValue retval) const;
411 : void GetQueryObjectEXT(JSContext* cx, const WebGLQuery& query,
412 : GLenum pname, JS::MutableHandleValue retval) const;
413 :
414 : static bool IsSupported(const WebGLContext*);
415 :
416 : DECL_WEBGL_EXTENSION_GOOP
417 : };
418 :
419 : class WebGLExtensionMOZDebug final
420 : : public WebGLExtensionBase
421 : {
422 : public:
423 : explicit WebGLExtensionMOZDebug(WebGLContext* webgl);
424 : virtual ~WebGLExtensionMOZDebug();
425 :
426 : void GetParameter(JSContext* cx, GLenum pname,
427 : JS::MutableHandle<JS::Value> retval, ErrorResult& er) const;
428 :
429 : DECL_WEBGL_EXTENSION_GOOP
430 : };
431 :
432 : } // namespace mozilla
433 :
434 : #endif // WEBGL_EXTENSIONS_H_
|