1 /* -*- Mode: C++; tab-width: 4; 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/. */
9 #include "mozilla/TypedEnum.h"
11 // Most WebIDL typedefs are identical to their OpenGL counterparts.
14 // Manual reflection of WebIDL typedefs that are different from their
15 // OpenGL counterparts.
16 typedef int64_t WebGLsizeiptr
;
17 typedef int64_t WebGLintptr
;
18 typedef bool WebGLboolean
;
23 * WebGLContextFakeBlackStatus and WebGLTextureFakeBlackStatus are enums to
24 * track what needs to use a dummy 1x1 black texture, which we refer to as a
25 * 'fake black' texture.
27 * There are generally two things that can cause us to use such 'fake black'
30 * (1) OpenGL ES rules on sampling incomplete textures specify that they
31 * must be sampled as RGBA(0, 0, 0, 1) (opaque black). We have to implement these rules
32 * ourselves, if only because we do not always run on OpenGL ES, and also
33 * because this is dangerously close to the kind of case where we don't
34 * want to trust the driver with corner cases of texture memory accesses.
36 * (2) OpenGL has cases where a renderbuffer, or a texture image, can contain
37 * uninitialized image data. See below the comment about WebGLImageDataStatus.
38 * WebGL must never have access to uninitialized image data. The WebGL 1 spec,
39 * section 4.1 'Resource Restrictions', specifies that in any such case, the
40 * uninitialized image data must be exposed to WebGL as if it were filled
41 * with zero bytes, which means it's either opaque or transparent black
42 * depending on whether the image format has alpha.
44 * Why are there _two_ separate enums there, WebGLContextFakeBlackStatus
45 * and WebGLTextureFakeBlackStatus? That's because each texture must know the precise
46 * reason why it needs to be faked (incomplete texture vs. uninitialized image data),
47 * whereas the WebGL context can only know whether _any_ faking is currently needed at all.
49 MOZ_BEGIN_ENUM_CLASS(WebGLContextFakeBlackStatus
, int)
53 MOZ_END_ENUM_CLASS(WebGLContextFakeBlackStatus
)
55 MOZ_BEGIN_ENUM_CLASS(WebGLTextureFakeBlackStatus
, int)
59 UninitializedImageData
60 MOZ_END_ENUM_CLASS(WebGLTextureFakeBlackStatus
)
63 * Implementing WebGL (or OpenGL ES 2.0) on top of desktop OpenGL requires
64 * emulating the vertex attrib 0 array when it's not enabled. Indeed,
65 * OpenGL ES 2.0 allows drawing without vertex attrib 0 array enabled, but
66 * desktop OpenGL does not allow that.
68 MOZ_BEGIN_ENUM_CLASS(WebGLVertexAttrib0Status
, int)
69 Default
, // default status - no emulation needed
70 EmulatedUninitializedArray
, // need an artificial attrib 0 array, but contents may be left uninitialized
71 EmulatedInitializedArray
// need an artificial attrib 0 array, and contents must be initialized
72 MOZ_END_ENUM_CLASS(WebGLVertexAttrib0Status
)
75 * Enum to track the status of image data (renderbuffer or texture image) presence
78 * - NoImageData is the initial state before any image data is allocated.
79 * - InitializedImageData is the state after image data is allocated and initialized.
80 * - UninitializedImageData is an intermediate state where data is allocated but not
81 * initialized. It is the state that renderbuffers are in after a renderbufferStorage call,
82 * and it is the state that texture images are in after a texImage2D call with null data.
84 MOZ_BEGIN_ENUM_CLASS(WebGLImageDataStatus
, int)
86 UninitializedImageData
,
88 MOZ_END_ENUM_CLASS(WebGLImageDataStatus
)
91 * The formats that may participate, either as source or destination formats,
92 * in WebGL texture conversions. This includes:
93 * - all the formats accepted by WebGL.texImage2D, e.g. RGBA4444
94 * - additional formats provided by extensions, e.g. RGB32F
95 * - additional source formats, depending on browser details, used when uploading
96 * textures from DOM elements. See gfxImageSurface::Format().
98 MOZ_BEGIN_ENUM_CLASS(WebGLTexelFormat
, int)
99 // returned by SurfaceFromElementResultToImageSurface to indicate absence of image data
101 // dummy error code returned by GetWebGLTexelFormat in error cases,
102 // after assertion failure (so this never happens in debug builds)
104 // dummy pseudo-format meaning "use the other format".
105 // For example, if SrcFormat=Auto and DstFormat=RGB8, then the source
106 // is implicitly treated as being RGB8 itself.
111 D16
, // used for WEBGL_depth_texture extension
112 D32
, // used for WEBGL_depth_texture extension
113 R32F
, // used for OES_texture_float extension
114 A32F
, // used for OES_texture_float extension
118 D24S8
, // used for WEBGL_depth_texture extension
121 BGRX8
, // used for DOM elements. Source format only.
123 RGB32F
, // used for OES_texture_float extension
126 BGRA8
, // used for DOM elements
129 RGBA32F
// used for OES_texture_float extension
130 MOZ_END_ENUM_CLASS(WebGLTexelFormat
)
132 } // namespace mozilla