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: 4; 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 WEBGLTYPES_H_ |
michael@0 | 7 | #define WEBGLTYPES_H_ |
michael@0 | 8 | |
michael@0 | 9 | #include "mozilla/TypedEnum.h" |
michael@0 | 10 | |
michael@0 | 11 | // Most WebIDL typedefs are identical to their OpenGL counterparts. |
michael@0 | 12 | #include "GLTypes.h" |
michael@0 | 13 | |
michael@0 | 14 | // Manual reflection of WebIDL typedefs that are different from their |
michael@0 | 15 | // OpenGL counterparts. |
michael@0 | 16 | typedef int64_t WebGLsizeiptr; |
michael@0 | 17 | typedef int64_t WebGLintptr; |
michael@0 | 18 | typedef bool WebGLboolean; |
michael@0 | 19 | |
michael@0 | 20 | namespace mozilla { |
michael@0 | 21 | |
michael@0 | 22 | /* |
michael@0 | 23 | * WebGLContextFakeBlackStatus and WebGLTextureFakeBlackStatus are enums to |
michael@0 | 24 | * track what needs to use a dummy 1x1 black texture, which we refer to as a |
michael@0 | 25 | * 'fake black' texture. |
michael@0 | 26 | * |
michael@0 | 27 | * There are generally two things that can cause us to use such 'fake black' |
michael@0 | 28 | * textures: |
michael@0 | 29 | * |
michael@0 | 30 | * (1) OpenGL ES rules on sampling incomplete textures specify that they |
michael@0 | 31 | * must be sampled as RGBA(0, 0, 0, 1) (opaque black). We have to implement these rules |
michael@0 | 32 | * ourselves, if only because we do not always run on OpenGL ES, and also |
michael@0 | 33 | * because this is dangerously close to the kind of case where we don't |
michael@0 | 34 | * want to trust the driver with corner cases of texture memory accesses. |
michael@0 | 35 | * |
michael@0 | 36 | * (2) OpenGL has cases where a renderbuffer, or a texture image, can contain |
michael@0 | 37 | * uninitialized image data. See below the comment about WebGLImageDataStatus. |
michael@0 | 38 | * WebGL must never have access to uninitialized image data. The WebGL 1 spec, |
michael@0 | 39 | * section 4.1 'Resource Restrictions', specifies that in any such case, the |
michael@0 | 40 | * uninitialized image data must be exposed to WebGL as if it were filled |
michael@0 | 41 | * with zero bytes, which means it's either opaque or transparent black |
michael@0 | 42 | * depending on whether the image format has alpha. |
michael@0 | 43 | * |
michael@0 | 44 | * Why are there _two_ separate enums there, WebGLContextFakeBlackStatus |
michael@0 | 45 | * and WebGLTextureFakeBlackStatus? That's because each texture must know the precise |
michael@0 | 46 | * reason why it needs to be faked (incomplete texture vs. uninitialized image data), |
michael@0 | 47 | * whereas the WebGL context can only know whether _any_ faking is currently needed at all. |
michael@0 | 48 | */ |
michael@0 | 49 | MOZ_BEGIN_ENUM_CLASS(WebGLContextFakeBlackStatus, int) |
michael@0 | 50 | Unknown, |
michael@0 | 51 | NotNeeded, |
michael@0 | 52 | Needed |
michael@0 | 53 | MOZ_END_ENUM_CLASS(WebGLContextFakeBlackStatus) |
michael@0 | 54 | |
michael@0 | 55 | MOZ_BEGIN_ENUM_CLASS(WebGLTextureFakeBlackStatus, int) |
michael@0 | 56 | Unknown, |
michael@0 | 57 | NotNeeded, |
michael@0 | 58 | IncompleteTexture, |
michael@0 | 59 | UninitializedImageData |
michael@0 | 60 | MOZ_END_ENUM_CLASS(WebGLTextureFakeBlackStatus) |
michael@0 | 61 | |
michael@0 | 62 | /* |
michael@0 | 63 | * Implementing WebGL (or OpenGL ES 2.0) on top of desktop OpenGL requires |
michael@0 | 64 | * emulating the vertex attrib 0 array when it's not enabled. Indeed, |
michael@0 | 65 | * OpenGL ES 2.0 allows drawing without vertex attrib 0 array enabled, but |
michael@0 | 66 | * desktop OpenGL does not allow that. |
michael@0 | 67 | */ |
michael@0 | 68 | MOZ_BEGIN_ENUM_CLASS(WebGLVertexAttrib0Status, int) |
michael@0 | 69 | Default, // default status - no emulation needed |
michael@0 | 70 | EmulatedUninitializedArray, // need an artificial attrib 0 array, but contents may be left uninitialized |
michael@0 | 71 | EmulatedInitializedArray // need an artificial attrib 0 array, and contents must be initialized |
michael@0 | 72 | MOZ_END_ENUM_CLASS(WebGLVertexAttrib0Status) |
michael@0 | 73 | |
michael@0 | 74 | /* |
michael@0 | 75 | * Enum to track the status of image data (renderbuffer or texture image) presence |
michael@0 | 76 | * and initialization. |
michael@0 | 77 | * |
michael@0 | 78 | * - NoImageData is the initial state before any image data is allocated. |
michael@0 | 79 | * - InitializedImageData is the state after image data is allocated and initialized. |
michael@0 | 80 | * - UninitializedImageData is an intermediate state where data is allocated but not |
michael@0 | 81 | * initialized. It is the state that renderbuffers are in after a renderbufferStorage call, |
michael@0 | 82 | * and it is the state that texture images are in after a texImage2D call with null data. |
michael@0 | 83 | */ |
michael@0 | 84 | MOZ_BEGIN_ENUM_CLASS(WebGLImageDataStatus, int) |
michael@0 | 85 | NoImageData, |
michael@0 | 86 | UninitializedImageData, |
michael@0 | 87 | InitializedImageData |
michael@0 | 88 | MOZ_END_ENUM_CLASS(WebGLImageDataStatus) |
michael@0 | 89 | |
michael@0 | 90 | /* |
michael@0 | 91 | * The formats that may participate, either as source or destination formats, |
michael@0 | 92 | * in WebGL texture conversions. This includes: |
michael@0 | 93 | * - all the formats accepted by WebGL.texImage2D, e.g. RGBA4444 |
michael@0 | 94 | * - additional formats provided by extensions, e.g. RGB32F |
michael@0 | 95 | * - additional source formats, depending on browser details, used when uploading |
michael@0 | 96 | * textures from DOM elements. See gfxImageSurface::Format(). |
michael@0 | 97 | */ |
michael@0 | 98 | MOZ_BEGIN_ENUM_CLASS(WebGLTexelFormat, int) |
michael@0 | 99 | // returned by SurfaceFromElementResultToImageSurface to indicate absence of image data |
michael@0 | 100 | None, |
michael@0 | 101 | // dummy error code returned by GetWebGLTexelFormat in error cases, |
michael@0 | 102 | // after assertion failure (so this never happens in debug builds) |
michael@0 | 103 | BadFormat, |
michael@0 | 104 | // dummy pseudo-format meaning "use the other format". |
michael@0 | 105 | // For example, if SrcFormat=Auto and DstFormat=RGB8, then the source |
michael@0 | 106 | // is implicitly treated as being RGB8 itself. |
michael@0 | 107 | Auto, |
michael@0 | 108 | // 1-channel formats |
michael@0 | 109 | R8, |
michael@0 | 110 | A8, |
michael@0 | 111 | D16, // WEBGL_depth_texture |
michael@0 | 112 | D32, // WEBGL_depth_texture |
michael@0 | 113 | R16F, // OES_texture_half_float |
michael@0 | 114 | A16F, // OES_texture_half_float |
michael@0 | 115 | R32F, // OES_texture_float |
michael@0 | 116 | A32F, // OES_texture_float |
michael@0 | 117 | // 2-channel formats |
michael@0 | 118 | RA8, |
michael@0 | 119 | RA16F, // OES_texture_half_float |
michael@0 | 120 | RA32F, // OES_texture_float |
michael@0 | 121 | D24S8, // WEBGL_depth_texture |
michael@0 | 122 | // 3-channel formats |
michael@0 | 123 | RGB8, |
michael@0 | 124 | BGRX8, // used for DOM elements. Source format only. |
michael@0 | 125 | RGB565, |
michael@0 | 126 | RGB16F, // OES_texture_half_float |
michael@0 | 127 | RGB32F, // OES_texture_float |
michael@0 | 128 | // 4-channel formats |
michael@0 | 129 | RGBA8, |
michael@0 | 130 | BGRA8, // used for DOM elements |
michael@0 | 131 | RGBA5551, |
michael@0 | 132 | RGBA4444, |
michael@0 | 133 | RGBA16F, // OES_texture_half_float |
michael@0 | 134 | RGBA32F // OES_texture_float |
michael@0 | 135 | MOZ_END_ENUM_CLASS(WebGLTexelFormat) |
michael@0 | 136 | |
michael@0 | 137 | MOZ_BEGIN_ENUM_CLASS(WebGLTexImageFunc, int) |
michael@0 | 138 | TexImage, |
michael@0 | 139 | TexSubImage, |
michael@0 | 140 | CopyTexImage, |
michael@0 | 141 | CopyTexSubImage, |
michael@0 | 142 | CompTexImage, |
michael@0 | 143 | CompTexSubImage, |
michael@0 | 144 | MOZ_END_ENUM_CLASS(WebGLTexImageFunc) |
michael@0 | 145 | |
michael@0 | 146 | // Please keep extensions in alphabetic order. |
michael@0 | 147 | MOZ_BEGIN_ENUM_CLASS(WebGLExtensionID, uint8_t) |
michael@0 | 148 | ANGLE_instanced_arrays, |
michael@0 | 149 | EXT_color_buffer_half_float, |
michael@0 | 150 | EXT_frag_depth, |
michael@0 | 151 | EXT_sRGB, |
michael@0 | 152 | EXT_texture_filter_anisotropic, |
michael@0 | 153 | OES_element_index_uint, |
michael@0 | 154 | OES_standard_derivatives, |
michael@0 | 155 | OES_texture_float, |
michael@0 | 156 | OES_texture_float_linear, |
michael@0 | 157 | OES_texture_half_float, |
michael@0 | 158 | OES_texture_half_float_linear, |
michael@0 | 159 | OES_vertex_array_object, |
michael@0 | 160 | WEBGL_color_buffer_float, |
michael@0 | 161 | WEBGL_compressed_texture_atc, |
michael@0 | 162 | WEBGL_compressed_texture_etc1, |
michael@0 | 163 | WEBGL_compressed_texture_pvrtc, |
michael@0 | 164 | WEBGL_compressed_texture_s3tc, |
michael@0 | 165 | WEBGL_debug_renderer_info, |
michael@0 | 166 | WEBGL_debug_shaders, |
michael@0 | 167 | WEBGL_depth_texture, |
michael@0 | 168 | WEBGL_draw_buffers, |
michael@0 | 169 | WEBGL_lose_context, |
michael@0 | 170 | Max, |
michael@0 | 171 | Unknown |
michael@0 | 172 | MOZ_END_ENUM_CLASS(WebGLExtensionID) |
michael@0 | 173 | |
michael@0 | 174 | } // namespace mozilla |
michael@0 | 175 | |
michael@0 | 176 | #endif |