Thu, 15 Jan 2015 21:03:48 +0100
Integrate friendly tips from Tor colleagues to make (or not) 4.5 alpha 3;
This includes removal of overloaded (but unused) methods, and addition of
a overlooked call to DataStruct::SetData(nsISupports, uint32_t, bool.)
michael@0 | 1 | /* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
michael@0 | 2 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 5 | |
michael@0 | 6 | #ifndef WEBGLEXTENSIONS_H_ |
michael@0 | 7 | #define WEBGLEXTENSIONS_H_ |
michael@0 | 8 | |
michael@0 | 9 | #include "jsapi.h" |
michael@0 | 10 | #include "mozilla/Attributes.h" |
michael@0 | 11 | #include "nsWrapperCache.h" |
michael@0 | 12 | #include "WebGLObjectModel.h" |
michael@0 | 13 | #include "WebGLTypes.h" |
michael@0 | 14 | |
michael@0 | 15 | namespace mozilla { |
michael@0 | 16 | |
michael@0 | 17 | class WebGLContext; |
michael@0 | 18 | class WebGLShader; |
michael@0 | 19 | class WebGLVertexArray; |
michael@0 | 20 | |
michael@0 | 21 | class WebGLExtensionBase |
michael@0 | 22 | : public nsWrapperCache |
michael@0 | 23 | , public WebGLContextBoundObject |
michael@0 | 24 | { |
michael@0 | 25 | public: |
michael@0 | 26 | WebGLExtensionBase(WebGLContext*); |
michael@0 | 27 | virtual ~WebGLExtensionBase(); |
michael@0 | 28 | |
michael@0 | 29 | WebGLContext *GetParentObject() const { |
michael@0 | 30 | return Context(); |
michael@0 | 31 | } |
michael@0 | 32 | |
michael@0 | 33 | void MarkLost(); |
michael@0 | 34 | |
michael@0 | 35 | NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(WebGLExtensionBase) |
michael@0 | 36 | NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(WebGLExtensionBase) |
michael@0 | 37 | |
michael@0 | 38 | protected: |
michael@0 | 39 | bool mIsLost; |
michael@0 | 40 | }; |
michael@0 | 41 | |
michael@0 | 42 | #define DECL_WEBGL_EXTENSION_GOOP \ |
michael@0 | 43 | virtual JSObject* WrapObject(JSContext *cx) MOZ_OVERRIDE; |
michael@0 | 44 | |
michael@0 | 45 | #define IMPL_WEBGL_EXTENSION_GOOP(WebGLExtensionType) \ |
michael@0 | 46 | JSObject* \ |
michael@0 | 47 | WebGLExtensionType::WrapObject(JSContext *cx) { \ |
michael@0 | 48 | return dom::WebGLExtensionType##Binding::Wrap(cx, this); \ |
michael@0 | 49 | } |
michael@0 | 50 | |
michael@0 | 51 | class WebGLExtensionCompressedTextureATC |
michael@0 | 52 | : public WebGLExtensionBase |
michael@0 | 53 | { |
michael@0 | 54 | public: |
michael@0 | 55 | WebGLExtensionCompressedTextureATC(WebGLContext*); |
michael@0 | 56 | virtual ~WebGLExtensionCompressedTextureATC(); |
michael@0 | 57 | |
michael@0 | 58 | DECL_WEBGL_EXTENSION_GOOP |
michael@0 | 59 | }; |
michael@0 | 60 | |
michael@0 | 61 | class WebGLExtensionCompressedTextureETC1 |
michael@0 | 62 | : public WebGLExtensionBase |
michael@0 | 63 | { |
michael@0 | 64 | public: |
michael@0 | 65 | WebGLExtensionCompressedTextureETC1(WebGLContext*); |
michael@0 | 66 | virtual ~WebGLExtensionCompressedTextureETC1(); |
michael@0 | 67 | |
michael@0 | 68 | DECL_WEBGL_EXTENSION_GOOP |
michael@0 | 69 | }; |
michael@0 | 70 | |
michael@0 | 71 | class WebGLExtensionCompressedTexturePVRTC |
michael@0 | 72 | : public WebGLExtensionBase |
michael@0 | 73 | { |
michael@0 | 74 | public: |
michael@0 | 75 | WebGLExtensionCompressedTexturePVRTC(WebGLContext*); |
michael@0 | 76 | virtual ~WebGLExtensionCompressedTexturePVRTC(); |
michael@0 | 77 | |
michael@0 | 78 | DECL_WEBGL_EXTENSION_GOOP |
michael@0 | 79 | }; |
michael@0 | 80 | |
michael@0 | 81 | class WebGLExtensionCompressedTextureS3TC |
michael@0 | 82 | : public WebGLExtensionBase |
michael@0 | 83 | { |
michael@0 | 84 | public: |
michael@0 | 85 | WebGLExtensionCompressedTextureS3TC(WebGLContext*); |
michael@0 | 86 | virtual ~WebGLExtensionCompressedTextureS3TC(); |
michael@0 | 87 | |
michael@0 | 88 | DECL_WEBGL_EXTENSION_GOOP |
michael@0 | 89 | }; |
michael@0 | 90 | |
michael@0 | 91 | class WebGLExtensionDebugRendererInfo |
michael@0 | 92 | : public WebGLExtensionBase |
michael@0 | 93 | { |
michael@0 | 94 | public: |
michael@0 | 95 | WebGLExtensionDebugRendererInfo(WebGLContext*); |
michael@0 | 96 | virtual ~WebGLExtensionDebugRendererInfo(); |
michael@0 | 97 | |
michael@0 | 98 | DECL_WEBGL_EXTENSION_GOOP |
michael@0 | 99 | }; |
michael@0 | 100 | |
michael@0 | 101 | class WebGLExtensionDebugShaders |
michael@0 | 102 | : public WebGLExtensionBase |
michael@0 | 103 | { |
michael@0 | 104 | public: |
michael@0 | 105 | WebGLExtensionDebugShaders(WebGLContext*); |
michael@0 | 106 | virtual ~WebGLExtensionDebugShaders(); |
michael@0 | 107 | |
michael@0 | 108 | void GetTranslatedShaderSource(WebGLShader* shader, nsAString& retval); |
michael@0 | 109 | |
michael@0 | 110 | DECL_WEBGL_EXTENSION_GOOP |
michael@0 | 111 | }; |
michael@0 | 112 | |
michael@0 | 113 | class WebGLExtensionDepthTexture |
michael@0 | 114 | : public WebGLExtensionBase |
michael@0 | 115 | { |
michael@0 | 116 | public: |
michael@0 | 117 | WebGLExtensionDepthTexture(WebGLContext*); |
michael@0 | 118 | virtual ~WebGLExtensionDepthTexture(); |
michael@0 | 119 | |
michael@0 | 120 | DECL_WEBGL_EXTENSION_GOOP |
michael@0 | 121 | }; |
michael@0 | 122 | |
michael@0 | 123 | class WebGLExtensionElementIndexUint |
michael@0 | 124 | : public WebGLExtensionBase |
michael@0 | 125 | { |
michael@0 | 126 | public: |
michael@0 | 127 | WebGLExtensionElementIndexUint(WebGLContext*); |
michael@0 | 128 | virtual ~WebGLExtensionElementIndexUint(); |
michael@0 | 129 | |
michael@0 | 130 | DECL_WEBGL_EXTENSION_GOOP |
michael@0 | 131 | }; |
michael@0 | 132 | |
michael@0 | 133 | class WebGLExtensionFragDepth |
michael@0 | 134 | : public WebGLExtensionBase |
michael@0 | 135 | { |
michael@0 | 136 | public: |
michael@0 | 137 | WebGLExtensionFragDepth(WebGLContext*); |
michael@0 | 138 | virtual ~WebGLExtensionFragDepth(); |
michael@0 | 139 | |
michael@0 | 140 | static bool IsSupported(const WebGLContext* context); |
michael@0 | 141 | |
michael@0 | 142 | DECL_WEBGL_EXTENSION_GOOP |
michael@0 | 143 | }; |
michael@0 | 144 | |
michael@0 | 145 | class WebGLExtensionLoseContext |
michael@0 | 146 | : public WebGLExtensionBase |
michael@0 | 147 | { |
michael@0 | 148 | public: |
michael@0 | 149 | WebGLExtensionLoseContext(WebGLContext*); |
michael@0 | 150 | virtual ~WebGLExtensionLoseContext(); |
michael@0 | 151 | |
michael@0 | 152 | void LoseContext(); |
michael@0 | 153 | void RestoreContext(); |
michael@0 | 154 | |
michael@0 | 155 | DECL_WEBGL_EXTENSION_GOOP |
michael@0 | 156 | }; |
michael@0 | 157 | |
michael@0 | 158 | class WebGLExtensionSRGB |
michael@0 | 159 | : public WebGLExtensionBase |
michael@0 | 160 | { |
michael@0 | 161 | public: |
michael@0 | 162 | WebGLExtensionSRGB(WebGLContext*); |
michael@0 | 163 | virtual ~WebGLExtensionSRGB(); |
michael@0 | 164 | |
michael@0 | 165 | static bool IsSupported(const WebGLContext* context); |
michael@0 | 166 | |
michael@0 | 167 | DECL_WEBGL_EXTENSION_GOOP |
michael@0 | 168 | }; |
michael@0 | 169 | |
michael@0 | 170 | class WebGLExtensionStandardDerivatives |
michael@0 | 171 | : public WebGLExtensionBase |
michael@0 | 172 | { |
michael@0 | 173 | public: |
michael@0 | 174 | WebGLExtensionStandardDerivatives(WebGLContext*); |
michael@0 | 175 | virtual ~WebGLExtensionStandardDerivatives(); |
michael@0 | 176 | |
michael@0 | 177 | DECL_WEBGL_EXTENSION_GOOP |
michael@0 | 178 | }; |
michael@0 | 179 | |
michael@0 | 180 | class WebGLExtensionTextureFilterAnisotropic |
michael@0 | 181 | : public WebGLExtensionBase |
michael@0 | 182 | { |
michael@0 | 183 | public: |
michael@0 | 184 | WebGLExtensionTextureFilterAnisotropic(WebGLContext*); |
michael@0 | 185 | virtual ~WebGLExtensionTextureFilterAnisotropic(); |
michael@0 | 186 | |
michael@0 | 187 | DECL_WEBGL_EXTENSION_GOOP |
michael@0 | 188 | }; |
michael@0 | 189 | |
michael@0 | 190 | class WebGLExtensionTextureFloat |
michael@0 | 191 | : public WebGLExtensionBase |
michael@0 | 192 | { |
michael@0 | 193 | public: |
michael@0 | 194 | WebGLExtensionTextureFloat(WebGLContext*); |
michael@0 | 195 | virtual ~WebGLExtensionTextureFloat(); |
michael@0 | 196 | |
michael@0 | 197 | DECL_WEBGL_EXTENSION_GOOP |
michael@0 | 198 | }; |
michael@0 | 199 | |
michael@0 | 200 | class WebGLExtensionTextureFloatLinear |
michael@0 | 201 | : public WebGLExtensionBase |
michael@0 | 202 | { |
michael@0 | 203 | public: |
michael@0 | 204 | WebGLExtensionTextureFloatLinear(WebGLContext*); |
michael@0 | 205 | virtual ~WebGLExtensionTextureFloatLinear(); |
michael@0 | 206 | |
michael@0 | 207 | DECL_WEBGL_EXTENSION_GOOP |
michael@0 | 208 | }; |
michael@0 | 209 | |
michael@0 | 210 | class WebGLExtensionTextureHalfFloat |
michael@0 | 211 | : public WebGLExtensionBase |
michael@0 | 212 | { |
michael@0 | 213 | public: |
michael@0 | 214 | WebGLExtensionTextureHalfFloat(WebGLContext*); |
michael@0 | 215 | virtual ~WebGLExtensionTextureHalfFloat(); |
michael@0 | 216 | |
michael@0 | 217 | DECL_WEBGL_EXTENSION_GOOP |
michael@0 | 218 | }; |
michael@0 | 219 | |
michael@0 | 220 | class WebGLExtensionTextureHalfFloatLinear |
michael@0 | 221 | : public WebGLExtensionBase |
michael@0 | 222 | { |
michael@0 | 223 | public: |
michael@0 | 224 | WebGLExtensionTextureHalfFloatLinear(WebGLContext*); |
michael@0 | 225 | virtual ~WebGLExtensionTextureHalfFloatLinear(); |
michael@0 | 226 | |
michael@0 | 227 | DECL_WEBGL_EXTENSION_GOOP |
michael@0 | 228 | }; |
michael@0 | 229 | |
michael@0 | 230 | class WebGLExtensionColorBufferFloat |
michael@0 | 231 | : public WebGLExtensionBase |
michael@0 | 232 | { |
michael@0 | 233 | public: |
michael@0 | 234 | WebGLExtensionColorBufferFloat(WebGLContext*); |
michael@0 | 235 | virtual ~WebGLExtensionColorBufferFloat(); |
michael@0 | 236 | |
michael@0 | 237 | static bool IsSupported(const WebGLContext*); |
michael@0 | 238 | |
michael@0 | 239 | DECL_WEBGL_EXTENSION_GOOP |
michael@0 | 240 | }; |
michael@0 | 241 | |
michael@0 | 242 | class WebGLExtensionColorBufferHalfFloat |
michael@0 | 243 | : public WebGLExtensionBase |
michael@0 | 244 | { |
michael@0 | 245 | public: |
michael@0 | 246 | WebGLExtensionColorBufferHalfFloat(WebGLContext*); |
michael@0 | 247 | virtual ~WebGLExtensionColorBufferHalfFloat(); |
michael@0 | 248 | |
michael@0 | 249 | static bool IsSupported(const WebGLContext*); |
michael@0 | 250 | |
michael@0 | 251 | DECL_WEBGL_EXTENSION_GOOP |
michael@0 | 252 | }; |
michael@0 | 253 | |
michael@0 | 254 | class WebGLExtensionDrawBuffers |
michael@0 | 255 | : public WebGLExtensionBase |
michael@0 | 256 | { |
michael@0 | 257 | public: |
michael@0 | 258 | WebGLExtensionDrawBuffers(WebGLContext*); |
michael@0 | 259 | virtual ~WebGLExtensionDrawBuffers(); |
michael@0 | 260 | |
michael@0 | 261 | void DrawBuffersWEBGL(const dom::Sequence<GLenum>& buffers); |
michael@0 | 262 | |
michael@0 | 263 | static bool IsSupported(const WebGLContext*); |
michael@0 | 264 | |
michael@0 | 265 | static const size_t sMinColorAttachments = 4; |
michael@0 | 266 | static const size_t sMinDrawBuffers = 4; |
michael@0 | 267 | /* |
michael@0 | 268 | WEBGL_draw_buffers does not give a minal value for GL_MAX_DRAW_BUFFERS. But, we request |
michael@0 | 269 | for GL_MAX_DRAW_BUFFERS = 4 at least to be able to use all requested color attachments. |
michael@0 | 270 | See DrawBuffersWEBGL in WebGLExtensionDrawBuffers.cpp inner comments for more informations. |
michael@0 | 271 | */ |
michael@0 | 272 | |
michael@0 | 273 | DECL_WEBGL_EXTENSION_GOOP |
michael@0 | 274 | }; |
michael@0 | 275 | |
michael@0 | 276 | class WebGLExtensionVertexArray |
michael@0 | 277 | : public WebGLExtensionBase |
michael@0 | 278 | { |
michael@0 | 279 | public: |
michael@0 | 280 | WebGLExtensionVertexArray(WebGLContext*); |
michael@0 | 281 | virtual ~WebGLExtensionVertexArray(); |
michael@0 | 282 | |
michael@0 | 283 | already_AddRefed<WebGLVertexArray> CreateVertexArrayOES(); |
michael@0 | 284 | void DeleteVertexArrayOES(WebGLVertexArray* array); |
michael@0 | 285 | bool IsVertexArrayOES(WebGLVertexArray* array); |
michael@0 | 286 | void BindVertexArrayOES(WebGLVertexArray* array); |
michael@0 | 287 | |
michael@0 | 288 | static bool IsSupported(const WebGLContext* context); |
michael@0 | 289 | |
michael@0 | 290 | DECL_WEBGL_EXTENSION_GOOP |
michael@0 | 291 | }; |
michael@0 | 292 | |
michael@0 | 293 | class WebGLExtensionInstancedArrays |
michael@0 | 294 | : public WebGLExtensionBase |
michael@0 | 295 | { |
michael@0 | 296 | public: |
michael@0 | 297 | WebGLExtensionInstancedArrays(WebGLContext* context); |
michael@0 | 298 | virtual ~WebGLExtensionInstancedArrays(); |
michael@0 | 299 | |
michael@0 | 300 | void DrawArraysInstancedANGLE(GLenum mode, GLint first, |
michael@0 | 301 | GLsizei count, GLsizei primcount); |
michael@0 | 302 | void DrawElementsInstancedANGLE(GLenum mode, GLsizei count, |
michael@0 | 303 | GLenum type, WebGLintptr offset, |
michael@0 | 304 | GLsizei primcount); |
michael@0 | 305 | void VertexAttribDivisorANGLE(GLuint index, GLuint divisor); |
michael@0 | 306 | |
michael@0 | 307 | static bool IsSupported(const WebGLContext* context); |
michael@0 | 308 | |
michael@0 | 309 | DECL_WEBGL_EXTENSION_GOOP |
michael@0 | 310 | }; |
michael@0 | 311 | |
michael@0 | 312 | } // namespace mozilla |
michael@0 | 313 | |
michael@0 | 314 | #endif // WEBGLEXTENSIONS_H_ |