michael@0: /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef WEBGLTYPES_H_ michael@0: #define WEBGLTYPES_H_ michael@0: michael@0: #include "mozilla/TypedEnum.h" michael@0: michael@0: // Most WebIDL typedefs are identical to their OpenGL counterparts. michael@0: #include "GLTypes.h" michael@0: michael@0: // Manual reflection of WebIDL typedefs that are different from their michael@0: // OpenGL counterparts. michael@0: typedef int64_t WebGLsizeiptr; michael@0: typedef int64_t WebGLintptr; michael@0: typedef bool WebGLboolean; michael@0: michael@0: namespace mozilla { michael@0: michael@0: /* michael@0: * WebGLContextFakeBlackStatus and WebGLTextureFakeBlackStatus are enums to michael@0: * track what needs to use a dummy 1x1 black texture, which we refer to as a michael@0: * 'fake black' texture. michael@0: * michael@0: * There are generally two things that can cause us to use such 'fake black' michael@0: * textures: michael@0: * michael@0: * (1) OpenGL ES rules on sampling incomplete textures specify that they michael@0: * must be sampled as RGBA(0, 0, 0, 1) (opaque black). We have to implement these rules michael@0: * ourselves, if only because we do not always run on OpenGL ES, and also michael@0: * because this is dangerously close to the kind of case where we don't michael@0: * want to trust the driver with corner cases of texture memory accesses. michael@0: * michael@0: * (2) OpenGL has cases where a renderbuffer, or a texture image, can contain michael@0: * uninitialized image data. See below the comment about WebGLImageDataStatus. michael@0: * WebGL must never have access to uninitialized image data. The WebGL 1 spec, michael@0: * section 4.1 'Resource Restrictions', specifies that in any such case, the michael@0: * uninitialized image data must be exposed to WebGL as if it were filled michael@0: * with zero bytes, which means it's either opaque or transparent black michael@0: * depending on whether the image format has alpha. michael@0: * michael@0: * Why are there _two_ separate enums there, WebGLContextFakeBlackStatus michael@0: * and WebGLTextureFakeBlackStatus? That's because each texture must know the precise michael@0: * reason why it needs to be faked (incomplete texture vs. uninitialized image data), michael@0: * whereas the WebGL context can only know whether _any_ faking is currently needed at all. michael@0: */ michael@0: MOZ_BEGIN_ENUM_CLASS(WebGLContextFakeBlackStatus, int) michael@0: Unknown, michael@0: NotNeeded, michael@0: Needed michael@0: MOZ_END_ENUM_CLASS(WebGLContextFakeBlackStatus) michael@0: michael@0: MOZ_BEGIN_ENUM_CLASS(WebGLTextureFakeBlackStatus, int) michael@0: Unknown, michael@0: NotNeeded, michael@0: IncompleteTexture, michael@0: UninitializedImageData michael@0: MOZ_END_ENUM_CLASS(WebGLTextureFakeBlackStatus) michael@0: michael@0: /* michael@0: * Implementing WebGL (or OpenGL ES 2.0) on top of desktop OpenGL requires michael@0: * emulating the vertex attrib 0 array when it's not enabled. Indeed, michael@0: * OpenGL ES 2.0 allows drawing without vertex attrib 0 array enabled, but michael@0: * desktop OpenGL does not allow that. michael@0: */ michael@0: MOZ_BEGIN_ENUM_CLASS(WebGLVertexAttrib0Status, int) michael@0: Default, // default status - no emulation needed michael@0: EmulatedUninitializedArray, // need an artificial attrib 0 array, but contents may be left uninitialized michael@0: EmulatedInitializedArray // need an artificial attrib 0 array, and contents must be initialized michael@0: MOZ_END_ENUM_CLASS(WebGLVertexAttrib0Status) michael@0: michael@0: /* michael@0: * Enum to track the status of image data (renderbuffer or texture image) presence michael@0: * and initialization. michael@0: * michael@0: * - NoImageData is the initial state before any image data is allocated. michael@0: * - InitializedImageData is the state after image data is allocated and initialized. michael@0: * - UninitializedImageData is an intermediate state where data is allocated but not michael@0: * initialized. It is the state that renderbuffers are in after a renderbufferStorage call, michael@0: * and it is the state that texture images are in after a texImage2D call with null data. michael@0: */ michael@0: MOZ_BEGIN_ENUM_CLASS(WebGLImageDataStatus, int) michael@0: NoImageData, michael@0: UninitializedImageData, michael@0: InitializedImageData michael@0: MOZ_END_ENUM_CLASS(WebGLImageDataStatus) michael@0: michael@0: /* michael@0: * The formats that may participate, either as source or destination formats, michael@0: * in WebGL texture conversions. This includes: michael@0: * - all the formats accepted by WebGL.texImage2D, e.g. RGBA4444 michael@0: * - additional formats provided by extensions, e.g. RGB32F michael@0: * - additional source formats, depending on browser details, used when uploading michael@0: * textures from DOM elements. See gfxImageSurface::Format(). michael@0: */ michael@0: MOZ_BEGIN_ENUM_CLASS(WebGLTexelFormat, int) michael@0: // returned by SurfaceFromElementResultToImageSurface to indicate absence of image data michael@0: None, michael@0: // dummy error code returned by GetWebGLTexelFormat in error cases, michael@0: // after assertion failure (so this never happens in debug builds) michael@0: BadFormat, michael@0: // dummy pseudo-format meaning "use the other format". michael@0: // For example, if SrcFormat=Auto and DstFormat=RGB8, then the source michael@0: // is implicitly treated as being RGB8 itself. michael@0: Auto, michael@0: // 1-channel formats michael@0: R8, michael@0: A8, michael@0: D16, // WEBGL_depth_texture michael@0: D32, // WEBGL_depth_texture michael@0: R16F, // OES_texture_half_float michael@0: A16F, // OES_texture_half_float michael@0: R32F, // OES_texture_float michael@0: A32F, // OES_texture_float michael@0: // 2-channel formats michael@0: RA8, michael@0: RA16F, // OES_texture_half_float michael@0: RA32F, // OES_texture_float michael@0: D24S8, // WEBGL_depth_texture michael@0: // 3-channel formats michael@0: RGB8, michael@0: BGRX8, // used for DOM elements. Source format only. michael@0: RGB565, michael@0: RGB16F, // OES_texture_half_float michael@0: RGB32F, // OES_texture_float michael@0: // 4-channel formats michael@0: RGBA8, michael@0: BGRA8, // used for DOM elements michael@0: RGBA5551, michael@0: RGBA4444, michael@0: RGBA16F, // OES_texture_half_float michael@0: RGBA32F // OES_texture_float michael@0: MOZ_END_ENUM_CLASS(WebGLTexelFormat) michael@0: michael@0: MOZ_BEGIN_ENUM_CLASS(WebGLTexImageFunc, int) michael@0: TexImage, michael@0: TexSubImage, michael@0: CopyTexImage, michael@0: CopyTexSubImage, michael@0: CompTexImage, michael@0: CompTexSubImage, michael@0: MOZ_END_ENUM_CLASS(WebGLTexImageFunc) michael@0: michael@0: // Please keep extensions in alphabetic order. michael@0: MOZ_BEGIN_ENUM_CLASS(WebGLExtensionID, uint8_t) michael@0: ANGLE_instanced_arrays, michael@0: EXT_color_buffer_half_float, michael@0: EXT_frag_depth, michael@0: EXT_sRGB, michael@0: EXT_texture_filter_anisotropic, michael@0: OES_element_index_uint, michael@0: OES_standard_derivatives, michael@0: OES_texture_float, michael@0: OES_texture_float_linear, michael@0: OES_texture_half_float, michael@0: OES_texture_half_float_linear, michael@0: OES_vertex_array_object, michael@0: WEBGL_color_buffer_float, michael@0: WEBGL_compressed_texture_atc, michael@0: WEBGL_compressed_texture_etc1, michael@0: WEBGL_compressed_texture_pvrtc, michael@0: WEBGL_compressed_texture_s3tc, michael@0: WEBGL_debug_renderer_info, michael@0: WEBGL_debug_shaders, michael@0: WEBGL_depth_texture, michael@0: WEBGL_draw_buffers, michael@0: WEBGL_lose_context, michael@0: Max, michael@0: Unknown michael@0: MOZ_END_ENUM_CLASS(WebGLExtensionID) michael@0: michael@0: } // namespace mozilla michael@0: michael@0: #endif