/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

#include "nsISupports.idl"
#include "nsIVariant.idl"

interface nsIDOMElement;
interface nsIDOMHTMLCanvasElement;
interface nsIPropertyBag;

// XXX should we comment out these typedefs in the C++ header?

typedef unsigned long  WebGLenum;
typedef boolean        WebGLboolean;
typedef unsigned long  WebGLbitfield;
typedef long           WebGLint;
typedef long           WebGLsizei;
typedef long long      WebGLsizeiptr;
typedef long long      WebGLintptr;
typedef unsigned long  WebGLuint;
typedef float          WebGLfloat;
typedef float          WebGLclampf;

%{C++
// for jsval
#include "jsapi.h"

namespace mozilla {
namespace dom {
class Element;
} // namespace dom
} // namespace mozilla

/* Avoid conflict with WinAPI */
#undef NO_ERROR
%}

[ptr] native WebGLJSObjectPtr (JSObject);
[ptr] native Element (mozilla::dom::Element);

//
// OpenGL object wrappers
//

[scriptable, builtinclass, uuid(0df9f4ed-f5ff-4e51-a6ff-2bd9785a7639)]
interface nsIWebGLTexture : nsISupports
{
  [noscript] attribute WebGLuint name;
};

[scriptable, builtinclass, uuid(9eca9c32-8305-11de-b89b-000c29206271)]
interface nsIWebGLBuffer : nsISupports
{
  [noscript] attribute WebGLuint name;
};

[scriptable, builtinclass, uuid(a6a19e74-8305-11de-9ce9-000c29206271)]
interface nsIWebGLProgram : nsISupports
{
  [noscript] attribute WebGLuint name;
};

[scriptable, builtinclass, uuid(ac7440a4-8305-11de-807b-000c29206271)]
interface nsIWebGLShader : nsISupports
{
  [noscript] attribute WebGLuint name;
};

[scriptable, builtinclass, uuid(beea4b38-3094-4e8d-b6e6-8b21d07e8994)]
interface nsIWebGLShaderArray : nsISupports
{
    readonly attribute unsigned long length;
    nsIWebGLShader item(in unsigned long index);
};

[scriptable, builtinclass, uuid(bce8be60-8305-11de-9f3c-000c29206271)]
interface nsIWebGLFramebuffer : nsISupports
{
  [noscript] attribute WebGLuint name;
};

[scriptable, builtinclass, uuid(c82eacd0-8305-11de-9de9-000c29206271)]
interface nsIWebGLRenderbuffer : nsISupports
{
  [noscript] attribute WebGLuint name;
};

[scriptable, builtinclass, uuid(a85d4fd0-5b9f-4cb8-aeee-5a2c5c5bad76)]
interface nsIWebGLActiveInfo : nsISupports
{
    readonly attribute WebGLint size;
    readonly attribute WebGLenum type;
    readonly attribute DOMString name;
};

[scriptable, builtinclass, uuid(76265e93-2e8f-40ca-b25b-eea5995e9641)]
interface nsIWebGLShaderPrecisionFormat : nsISupports
{
    readonly attribute WebGLint rangeMin;
    readonly attribute WebGLint rangeMax;
    readonly attribute WebGLint precision;
};

[scriptable, builtinclass, uuid(d38b0467-623e-4c82-9140-5f14a3bd1bad)]
interface nsIWebGLUniformLocation : nsISupports
{
    [noscript] attribute WebGLint location;
};

/* Base class for all WebGL extensions, and for those without
 * any additional tokens/methods.
 */
[scriptable, builtinclass, uuid(70814f32-a5c5-4b95-83d5-ac653bac3316)]
interface nsIWebGLExtension : nsISupports
{
};

/* Classes that extend on nsIWebGLExtension and provide
 * extra tokens, functions, etc.
 */
[scriptable, builtinclass, uuid(3de3dfd9-864a-4e4c-989b-2977eaa80b7b)]
interface nsIWebGLExtensionStandardDerivatives : nsIWebGLExtension
{
  //
  //  CONSTANTS
  //

  /* Fragment shader hint */
  const WebGLenum FRAGMENT_SHADER_DERIVATIVE_HINT_OES   = 0x8B8B;
};

[scriptable, uuid(b0afc2eb-0895-4509-98de-5c383d160694)]
interface nsIWebGLExtensionLoseContext : nsIWebGLExtension
{
  void loseContext();
  void restoreContext();
};

[scriptable, uuid(73bfb64d-94bd-4a7a-9eab-6b6d32e57aa0)]
interface nsIWebGLExtensionTextureFilterAnisotropic : nsIWebGLExtension
{
  const WebGLenum TEXTURE_MAX_ANISOTROPY_EXT = 0x84FE;
  const WebGLenum MAX_TEXTURE_MAX_ANISOTROPY_EXT = 0x84FF;
};

[scriptable, builtinclass, uuid(a1508b6f-f2ab-44cf-bbb4-3cfb339e1e8a)]
interface nsIWebGLExtensionCompressedTextureS3TC : nsIWebGLExtension
{
    /* Compressed Texture Formats */
    const WebGLenum COMPRESSED_RGB_S3TC_DXT1_EXT        = 0x83F0;
    const WebGLenum COMPRESSED_RGBA_S3TC_DXT1_EXT       = 0x83F1;
    const WebGLenum COMPRESSED_RGBA_S3TC_DXT3_EXT       = 0x83F2;
    const WebGLenum COMPRESSED_RGBA_S3TC_DXT5_EXT       = 0x83F3;
};

[scriptable, builtinclass, uuid(a1fdfb76-6a08-4a1a-b0c9-d92ef3357cb9)]
interface nsIDOMWebGLRenderingContext : nsISupports
{
  //
  //  CONSTANTS
  //

  /* ClearBufferMask */
  const unsigned long DEPTH_BUFFER_BIT               = 0x00000100;
  const unsigned long STENCIL_BUFFER_BIT             = 0x00000400;
  const unsigned long COLOR_BUFFER_BIT               = 0x00004000;

  /* BeginMode */
  const unsigned long POINTS                         = 0x0000;
  const unsigned long LINES                          = 0x0001;
  const unsigned long LINE_LOOP                      = 0x0002;
  const unsigned long LINE_STRIP                     = 0x0003;
  const unsigned long TRIANGLES                      = 0x0004;
  const unsigned long TRIANGLE_STRIP                 = 0x0005;
  const unsigned long TRIANGLE_FAN                   = 0x0006;

  /* BlendingFactorDest */
  const unsigned long ZERO                           = 0;
  const unsigned long ONE                            = 1;
  const unsigned long SRC_COLOR                      = 0x0300;
  const unsigned long ONE_MINUS_SRC_COLOR            = 0x0301;
  const unsigned long SRC_ALPHA                      = 0x0302;
  const unsigned long ONE_MINUS_SRC_ALPHA            = 0x0303;
  const unsigned long DST_ALPHA                      = 0x0304;
  const unsigned long ONE_MINUS_DST_ALPHA            = 0x0305;

  /* BlendingFactorSrc */
  /*      GL_ZERO */
  /*      GL_ONE */
  const unsigned long DST_COLOR                      = 0x0306;
  const unsigned long ONE_MINUS_DST_COLOR            = 0x0307;
  const unsigned long SRC_ALPHA_SATURATE             = 0x0308;
  /*      GL_SRC_ALPHA */
  /*      GL_ONE_MINUS_SRC_ALPHA */
  /*      GL_DST_ALPHA */
  /*      GL_ONE_MINUS_DST_ALPHA */

  /* BlendEquationSeparate */
  const unsigned long FUNC_ADD                       = 0x8006;
  const unsigned long BLEND_EQUATION                 = 0x8009;
  const unsigned long BLEND_EQUATION_RGB             = 0x8009;   /* same as BLEND_EQUATION */
  const unsigned long BLEND_EQUATION_ALPHA           = 0x883D;

  /* BlendSubtract */
  const unsigned long FUNC_SUBTRACT                  = 0x800A;
  const unsigned long FUNC_REVERSE_SUBTRACT          = 0x800B;

  /* Separate Blend Functions */
  const unsigned long BLEND_DST_RGB                  = 0x80C8;
  const unsigned long BLEND_SRC_RGB                  = 0x80C9;
  const unsigned long BLEND_DST_ALPHA                = 0x80CA;
  const unsigned long BLEND_SRC_ALPHA                = 0x80CB;
  const unsigned long CONSTANT_COLOR                 = 0x8001;
  const unsigned long ONE_MINUS_CONSTANT_COLOR       = 0x8002;
  const unsigned long CONSTANT_ALPHA                 = 0x8003;
  const unsigned long ONE_MINUS_CONSTANT_ALPHA       = 0x8004;
  const unsigned long BLEND_COLOR                    = 0x8005;

  /* Buffer Objects */
  const unsigned long ARRAY_BUFFER                   = 0x8892;
  const unsigned long ELEMENT_ARRAY_BUFFER           = 0x8893;
  const unsigned long ARRAY_BUFFER_BINDING           = 0x8894;
  const unsigned long ELEMENT_ARRAY_BUFFER_BINDING   = 0x8895;

  const unsigned long STREAM_DRAW                    = 0x88E0;
  const unsigned long STATIC_DRAW                    = 0x88E4;
  const unsigned long DYNAMIC_DRAW                   = 0x88E8;

  const unsigned long BUFFER_SIZE                    = 0x8764;
  const unsigned long BUFFER_USAGE                   = 0x8765;

  const unsigned long CURRENT_VERTEX_ATTRIB          = 0x8626;

  /* CullFaceMode */
  const unsigned long FRONT                          = 0x0404;
  const unsigned long BACK                           = 0x0405;
  const unsigned long FRONT_AND_BACK                 = 0x0408;

  /* DepthFunction */
  /*      GL_NEVER */
  /*      GL_LESS */
  /*      GL_EQUAL */
  /*      GL_LEQUAL */
  /*      GL_GREATER */
  /*      GL_NOTEQUAL */
  /*      GL_GEQUAL */
  /*      GL_ALWAYS */

  /* EnableCap */
  const unsigned long TEXTURE_2D                     = 0x0DE1;
  const unsigned long CULL_FACE                      = 0x0B44;
  const unsigned long BLEND                          = 0x0BE2;
  const unsigned long DITHER                         = 0x0BD0;
  const unsigned long STENCIL_TEST                   = 0x0B90;
  const unsigned long DEPTH_TEST                     = 0x0B71;
  const unsigned long SCISSOR_TEST                   = 0x0C11;
  const unsigned long POLYGON_OFFSET_FILL            = 0x8037;
  const unsigned long SAMPLE_ALPHA_TO_COVERAGE       = 0x809E;
  const unsigned long SAMPLE_COVERAGE                = 0x80A0;

  /* ErrorCode */
  const unsigned long NO_ERROR                       = 0;
  const unsigned long INVALID_ENUM                   = 0x0500;
  const unsigned long INVALID_VALUE                  = 0x0501;
  const unsigned long INVALID_OPERATION              = 0x0502;
  const unsigned long OUT_OF_MEMORY                  = 0x0505;

  /* FrontFaceDirection */
  const unsigned long CW                             = 0x0900;
  const unsigned long CCW                            = 0x0901;

  /* GetPName */
  const unsigned long LINE_WIDTH                     = 0x0B21;
  const unsigned long ALIASED_POINT_SIZE_RANGE       = 0x846D;
  const unsigned long ALIASED_LINE_WIDTH_RANGE       = 0x846E;
  const unsigned long CULL_FACE_MODE                 = 0x0B45;
  const unsigned long FRONT_FACE                     = 0x0B46;
  const unsigned long DEPTH_RANGE                    = 0x0B70;
  const unsigned long DEPTH_WRITEMASK                = 0x0B72;
  const unsigned long DEPTH_CLEAR_VALUE              = 0x0B73;
  const unsigned long DEPTH_FUNC                     = 0x0B74;
  const unsigned long STENCIL_CLEAR_VALUE            = 0x0B91;
  const unsigned long STENCIL_FUNC                   = 0x0B92;
  const unsigned long STENCIL_FAIL                   = 0x0B94;
  const unsigned long STENCIL_PASS_DEPTH_FAIL        = 0x0B95;
  const unsigned long STENCIL_PASS_DEPTH_PASS        = 0x0B96;
  const unsigned long STENCIL_REF                    = 0x0B97;
  const unsigned long STENCIL_VALUE_MASK             = 0x0B93;
  const unsigned long STENCIL_WRITEMASK              = 0x0B98;
  const unsigned long STENCIL_BACK_FUNC              = 0x8800;
  const unsigned long STENCIL_BACK_FAIL              = 0x8801;
  const unsigned long STENCIL_BACK_PASS_DEPTH_FAIL   = 0x8802;
  const unsigned long STENCIL_BACK_PASS_DEPTH_PASS   = 0x8803;
  const unsigned long STENCIL_BACK_REF               = 0x8CA3;
  const unsigned long STENCIL_BACK_VALUE_MASK        = 0x8CA4;
  const unsigned long STENCIL_BACK_WRITEMASK         = 0x8CA5;
  // This is defined using a scriptable helper in nsDOMClassInfo.h,
  // because otherwise the case conflicts with the viewport()
  // method.  WebIDL is case-sensitive, but our current IDL parser
  // is not.  Once this is fixed, the WebGL context can go back to
  // using nsDOMGenericSH instead of nsWebGLViewportHandlerSH.
  // It is not visible to non-JS languages, but the constant value
  // can just be used.
  //const unsigned long VIEWPORT                       = 0x0BA2;
  const unsigned long SCISSOR_BOX                    = 0x0C10;
  /*      GL_SCISSOR_TEST */
  const unsigned long COLOR_CLEAR_VALUE              = 0x0C22;
  const unsigned long COLOR_WRITEMASK                = 0x0C23;
  const unsigned long UNPACK_ALIGNMENT               = 0x0CF5;
  const unsigned long PACK_ALIGNMENT                 = 0x0D05;
  const unsigned long MAX_TEXTURE_SIZE               = 0x0D33;
  const unsigned long MAX_VIEWPORT_DIMS              = 0x0D3A;
  const unsigned long SUBPIXEL_BITS                  = 0x0D50;
  const unsigned long RED_BITS                       = 0x0D52;
  const unsigned long GREEN_BITS                     = 0x0D53;
  const unsigned long BLUE_BITS                      = 0x0D54;
  const unsigned long ALPHA_BITS                     = 0x0D55;
  const unsigned long DEPTH_BITS                     = 0x0D56;
  const unsigned long STENCIL_BITS                   = 0x0D57;
  const unsigned long POLYGON_OFFSET_UNITS           = 0x2A00;
  /*      GL_POLYGON_OFFSET_FILL */
  const unsigned long POLYGON_OFFSET_FACTOR          = 0x8038;
  const unsigned long TEXTURE_BINDING_2D             = 0x8069;
  const unsigned long SAMPLE_BUFFERS                 = 0x80A8;
  const unsigned long SAMPLES                        = 0x80A9;
  const unsigned long SAMPLE_COVERAGE_VALUE          = 0x80AA;
  const unsigned long SAMPLE_COVERAGE_INVERT         = 0x80AB;

  /* GetTextureParameter */
  /*      GL_TEXTURE_MAG_FILTER */
  /*      GL_TEXTURE_MIN_FILTER */
  /*      GL_TEXTURE_WRAP_S */
  /*      GL_TEXTURE_WRAP_T */

  const unsigned long NUM_COMPRESSED_TEXTURE_FORMATS = 0x86A2;
  const unsigned long COMPRESSED_TEXTURE_FORMATS     = 0x86A3;

  /* HintMode */
  const unsigned long DONT_CARE                      = 0x1100;
  const unsigned long FASTEST                        = 0x1101;
  const unsigned long NICEST                         = 0x1102;

  /* HintTarget */
  const unsigned long GENERATE_MIPMAP_HINT            = 0x8192;

  /* DataType */
  const unsigned long BYTE                           = 0x1400;
  const unsigned long UNSIGNED_BYTE                  = 0x1401;
  const unsigned long SHORT                          = 0x1402;
  const unsigned long UNSIGNED_SHORT                 = 0x1403;
  const unsigned long INT                            = 0x1404;
  const unsigned long UNSIGNED_INT                   = 0x1405;
  const unsigned long FLOAT                          = 0x1406;

  /* PixelFormat */
  const unsigned long DEPTH_COMPONENT                = 0x1902;
  const unsigned long ALPHA                          = 0x1906;
  const unsigned long RGB                            = 0x1907;
  const unsigned long RGBA                           = 0x1908;
  const unsigned long LUMINANCE                      = 0x1909;
  const unsigned long LUMINANCE_ALPHA                = 0x190A;

  /* PixelType */
  /*      GL_UNSIGNED_BYTE */
  const unsigned long UNSIGNED_SHORT_4_4_4_4         = 0x8033;
  const unsigned long UNSIGNED_SHORT_5_5_5_1         = 0x8034;
  const unsigned long UNSIGNED_SHORT_5_6_5           = 0x8363;

  /* Shaders */
  const unsigned long FRAGMENT_SHADER                  = 0x8B30;
  const unsigned long VERTEX_SHADER                    = 0x8B31;
  const unsigned long MAX_VERTEX_ATTRIBS               = 0x8869;
  const unsigned long MAX_VERTEX_UNIFORM_VECTORS       = 0x8DFB;
  const unsigned long MAX_VARYING_VECTORS              = 0x8DFC;
  const unsigned long MAX_COMBINED_TEXTURE_IMAGE_UNITS = 0x8B4D;
  const unsigned long MAX_VERTEX_TEXTURE_IMAGE_UNITS   = 0x8B4C;
  const unsigned long MAX_TEXTURE_IMAGE_UNITS          = 0x8872;
  const unsigned long MAX_FRAGMENT_UNIFORM_VECTORS     = 0x8DFD;
  const unsigned long SHADER_TYPE                      = 0x8B4F;
  const unsigned long DELETE_STATUS                    = 0x8B80;
  const unsigned long LINK_STATUS                      = 0x8B82;
  const unsigned long VALIDATE_STATUS                  = 0x8B83;
  const unsigned long ATTACHED_SHADERS                 = 0x8B85;
  const unsigned long ACTIVE_UNIFORMS                  = 0x8B86;
  const unsigned long ACTIVE_ATTRIBUTES                = 0x8B89;
  const unsigned long SHADING_LANGUAGE_VERSION         = 0x8B8C;
  const unsigned long CURRENT_PROGRAM                  = 0x8B8D;

  /* StencilFunction */
  const unsigned long NEVER                          = 0x0200;
  const unsigned long LESS                           = 0x0201;
  const unsigned long EQUAL                          = 0x0202;
  const unsigned long LEQUAL                         = 0x0203;
  const unsigned long GREATER                        = 0x0204;
  const unsigned long NOTEQUAL                       = 0x0205;
  const unsigned long GEQUAL                         = 0x0206;
  const unsigned long ALWAYS                         = 0x0207;

  /* StencilOp */
  /*      GL_ZERO */
  const unsigned long KEEP                           = 0x1E00;
  const unsigned long REPLACE                        = 0x1E01;
  const unsigned long INCR                           = 0x1E02;
  const unsigned long DECR                           = 0x1E03;
  const unsigned long INVERT                         = 0x150A;
  const unsigned long INCR_WRAP                      = 0x8507;
  const unsigned long DECR_WRAP                      = 0x8508;

  /* StringName */
  const unsigned long VENDOR                         = 0x1F00;
  const unsigned long RENDERER                       = 0x1F01;
  const unsigned long VERSION                        = 0x1F02;
  const unsigned long EXTENSIONS                     = 0x1F03;

  /* TextureMagFilter */
  const unsigned long NEAREST                        = 0x2600;
  const unsigned long LINEAR                         = 0x2601;

  /* TextureMinFilter */
  /*      GL_NEAREST */
  /*      GL_LINEAR */
  const unsigned long NEAREST_MIPMAP_NEAREST         = 0x2700;
  const unsigned long LINEAR_MIPMAP_NEAREST          = 0x2701;
  const unsigned long NEAREST_MIPMAP_LINEAR          = 0x2702;
  const unsigned long LINEAR_MIPMAP_LINEAR           = 0x2703;

  /* TextureParameterName */
  const unsigned long TEXTURE_MAG_FILTER             = 0x2800;
  const unsigned long TEXTURE_MIN_FILTER             = 0x2801;
  const unsigned long TEXTURE_WRAP_S                 = 0x2802;
  const unsigned long TEXTURE_WRAP_T                 = 0x2803;

  /* TextureTarget */
  /*      GL_TEXTURE_2D */
  const unsigned long TEXTURE                        = 0x1702;

  const unsigned long TEXTURE_CUBE_MAP               = 0x8513;
  const unsigned long TEXTURE_BINDING_CUBE_MAP       = 0x8514;
  const unsigned long TEXTURE_CUBE_MAP_POSITIVE_X    = 0x8515;
  const unsigned long TEXTURE_CUBE_MAP_NEGATIVE_X    = 0x8516;
  const unsigned long TEXTURE_CUBE_MAP_POSITIVE_Y    = 0x8517;
  const unsigned long TEXTURE_CUBE_MAP_NEGATIVE_Y    = 0x8518;
  const unsigned long TEXTURE_CUBE_MAP_POSITIVE_Z    = 0x8519;
  const unsigned long TEXTURE_CUBE_MAP_NEGATIVE_Z    = 0x851A;
  const unsigned long MAX_CUBE_MAP_TEXTURE_SIZE      = 0x851C;

  /* TextureUnit */
  const unsigned long TEXTURE0                       = 0x84C0;
  const unsigned long TEXTURE1                       = 0x84C1;
  const unsigned long TEXTURE2                       = 0x84C2;
  const unsigned long TEXTURE3                       = 0x84C3;
  const unsigned long TEXTURE4                       = 0x84C4;
  const unsigned long TEXTURE5                       = 0x84C5;
  const unsigned long TEXTURE6                       = 0x84C6;
  const unsigned long TEXTURE7                       = 0x84C7;
  const unsigned long TEXTURE8                       = 0x84C8;
  const unsigned long TEXTURE9                       = 0x84C9;
  const unsigned long TEXTURE10                      = 0x84CA;
  const unsigned long TEXTURE11                      = 0x84CB;
  const unsigned long TEXTURE12                      = 0x84CC;
  const unsigned long TEXTURE13                      = 0x84CD;
  const unsigned long TEXTURE14                      = 0x84CE;
  const unsigned long TEXTURE15                      = 0x84CF;
  const unsigned long TEXTURE16                      = 0x84D0;
  const unsigned long TEXTURE17                      = 0x84D1;
  const unsigned long TEXTURE18                      = 0x84D2;
  const unsigned long TEXTURE19                      = 0x84D3;
  const unsigned long TEXTURE20                      = 0x84D4;
  const unsigned long TEXTURE21                      = 0x84D5;
  const unsigned long TEXTURE22                      = 0x84D6;
  const unsigned long TEXTURE23                      = 0x84D7;
  const unsigned long TEXTURE24                      = 0x84D8;
  const unsigned long TEXTURE25                      = 0x84D9;
  const unsigned long TEXTURE26                      = 0x84DA;
  const unsigned long TEXTURE27                      = 0x84DB;
  const unsigned long TEXTURE28                      = 0x84DC;
  const unsigned long TEXTURE29                      = 0x84DD;
  const unsigned long TEXTURE30                      = 0x84DE;
  const unsigned long TEXTURE31                      = 0x84DF;
  const unsigned long ACTIVE_TEXTURE                 = 0x84E0;

  /* TextureWrapMode */
  const unsigned long REPEAT                         = 0x2901;
  const unsigned long CLAMP_TO_EDGE                  = 0x812F;
  const unsigned long MIRRORED_REPEAT                = 0x8370;

  /* Uniform Types */
  const unsigned long FLOAT_VEC2                     = 0x8B50;
  const unsigned long FLOAT_VEC3                     = 0x8B51;
  const unsigned long FLOAT_VEC4                     = 0x8B52;
  const unsigned long INT_VEC2                       = 0x8B53;
  const unsigned long INT_VEC3                       = 0x8B54;
  const unsigned long INT_VEC4                       = 0x8B55;
  const unsigned long BOOL                           = 0x8B56;
  const unsigned long BOOL_VEC2                      = 0x8B57;
  const unsigned long BOOL_VEC3                      = 0x8B58;
  const unsigned long BOOL_VEC4                      = 0x8B59;
  const unsigned long FLOAT_MAT2                     = 0x8B5A;
  const unsigned long FLOAT_MAT3                     = 0x8B5B;
  const unsigned long FLOAT_MAT4                     = 0x8B5C;
  const unsigned long SAMPLER_2D                     = 0x8B5E;
  const unsigned long SAMPLER_CUBE                   = 0x8B60;

  /* Vertex Arrays */
  const unsigned long VERTEX_ATTRIB_ARRAY_ENABLED        = 0x8622;
  const unsigned long VERTEX_ATTRIB_ARRAY_SIZE           = 0x8623;
  const unsigned long VERTEX_ATTRIB_ARRAY_STRIDE         = 0x8624;
  const unsigned long VERTEX_ATTRIB_ARRAY_TYPE           = 0x8625;
  const unsigned long VERTEX_ATTRIB_ARRAY_NORMALIZED     = 0x886A;
  const unsigned long VERTEX_ATTRIB_ARRAY_POINTER        = 0x8645;
  const unsigned long VERTEX_ATTRIB_ARRAY_BUFFER_BINDING = 0x889F;

  /* Shader Source */
  const unsigned long COMPILE_STATUS                 = 0x8B81;
  const unsigned long SHADER_COMPILER                = 0x8DFA;

  /* Shader Precision-Specified Types */
  const unsigned long LOW_FLOAT                      = 0x8DF0;
  const unsigned long MEDIUM_FLOAT                   = 0x8DF1;
  const unsigned long HIGH_FLOAT                     = 0x8DF2;
  const unsigned long LOW_INT                        = 0x8DF3;
  const unsigned long MEDIUM_INT                     = 0x8DF4;
  const unsigned long HIGH_INT                       = 0x8DF5;

  /* Framebuffer Object. */
  const unsigned long FRAMEBUFFER                    = 0x8D40;
  const unsigned long RENDERBUFFER                   = 0x8D41;

  const unsigned long RGBA4                          = 0x8056;
  const unsigned long RGB5_A1                        = 0x8057;
  const unsigned long RGB565                         = 0x8D62;
  const unsigned long DEPTH_COMPONENT16              = 0x81A5;
  const unsigned long STENCIL_INDEX                  = 0x1901;
  const unsigned long STENCIL_INDEX8                 = 0x8D48;
  const unsigned long DEPTH_STENCIL                  = 0x84F9;

  const unsigned long RENDERBUFFER_WIDTH             = 0x8D42;
  const unsigned long RENDERBUFFER_HEIGHT            = 0x8D43;
  const unsigned long RENDERBUFFER_INTERNAL_FORMAT   = 0x8D44;
  const unsigned long RENDERBUFFER_RED_SIZE          = 0x8D50;
  const unsigned long RENDERBUFFER_GREEN_SIZE        = 0x8D51;
  const unsigned long RENDERBUFFER_BLUE_SIZE         = 0x8D52;
  const unsigned long RENDERBUFFER_ALPHA_SIZE        = 0x8D53;
  const unsigned long RENDERBUFFER_DEPTH_SIZE        = 0x8D54;
  const unsigned long RENDERBUFFER_STENCIL_SIZE      = 0x8D55;

  const unsigned long FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE           = 0x8CD0;
  const unsigned long FRAMEBUFFER_ATTACHMENT_OBJECT_NAME           = 0x8CD1;
  const unsigned long FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL         = 0x8CD2;
  const unsigned long FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE = 0x8CD3;

  const unsigned long COLOR_ATTACHMENT0              = 0x8CE0;
  const unsigned long DEPTH_ATTACHMENT               = 0x8D00;
  const unsigned long STENCIL_ATTACHMENT             = 0x8D20;
  const unsigned long DEPTH_STENCIL_ATTACHMENT       = 0x821A;

  const unsigned long NONE                           = 0;

  const unsigned long FRAMEBUFFER_COMPLETE                      = 0x8CD5;
  const unsigned long FRAMEBUFFER_INCOMPLETE_ATTACHMENT         = 0x8CD6;
  const unsigned long FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT = 0x8CD7;
  const unsigned long FRAMEBUFFER_INCOMPLETE_DIMENSIONS         = 0x8CD9;
  const unsigned long FRAMEBUFFER_UNSUPPORTED                   = 0x8CDD;

  const unsigned long FRAMEBUFFER_BINDING            = 0x8CA6;
  const unsigned long RENDERBUFFER_BINDING           = 0x8CA7;
  const unsigned long MAX_RENDERBUFFER_SIZE          = 0x84E8;

  const unsigned long INVALID_FRAMEBUFFER_OPERATION  = 0x0506;

  const unsigned long UNPACK_FLIP_Y_WEBGL            = 0x9240;
  const unsigned long UNPACK_PREMULTIPLY_ALPHA_WEBGL = 0x9241;
  const unsigned long CONTEXT_LOST_WEBGL             = 0x9242;
  const unsigned long UNPACK_COLORSPACE_CONVERSION_WEBGL = 0x9243;
  const unsigned long BROWSER_DEFAULT_WEBGL          = 0x9244;

  //
  //  ATTRIBUTES
  //
  readonly attribute nsIDOMHTMLCanvasElement canvas;

  //
  //  METHODS
  //
  jsval getContextAttributes();

  [binaryname(MozActiveTexture)]
  void activeTexture(in WebGLenum texture);

  void attachShader([optional] in nsIWebGLProgram program, [optional] in nsIWebGLShader shader);
  void bindAttribLocation(in nsIWebGLProgram program, in WebGLuint index, in DOMString name);
  void bindBuffer(in WebGLenum target, in nsIWebGLBuffer buffer);
  void bindFramebuffer(in WebGLenum target, in nsIWebGLFramebuffer framebuffer);
  void bindRenderbuffer(in WebGLenum target, in nsIWebGLRenderbuffer renderbuffer);
  void bindTexture(in WebGLenum target, in nsIWebGLTexture texture);

  [binaryname(MozBlendColor)]
  void blendColor(in WebGLclampf red, in WebGLclampf green, in WebGLclampf blue, in WebGLclampf alpha);

  [binaryname(MozBlendEquation)]
  void blendEquation(in WebGLenum mode);

  [binaryname(MozBlendEquationSeparate)]
  void blendEquationSeparate(in WebGLenum modeRGB, in WebGLenum modeAlpha);

  [binaryname(MozBlendFunc)]
  void blendFunc(in WebGLenum sfactor, in WebGLenum dfactor);

  [binaryname(MozBlendFuncSeparate)]
  void blendFuncSeparate(in WebGLenum srcRGB, in WebGLenum dstRGB, in WebGLenum srcAlpha, in WebGLenum dstAlpha);

  // Modified: void glBufferData(WebGLenum target, long size, const void* data, WebGLenum usage);
  [implicit_jscontext] void bufferData(in WebGLenum target, in jsval data, in WebGLenum usage);

  [implicit_jscontext] void bufferSubData(in WebGLenum target, in WebGLintptr offset, in jsval data);

  WebGLenum checkFramebufferStatus(in WebGLenum target);

  [binaryname(MozClear)]
  void clear(in WebGLbitfield mask);

  [binaryname(MozClearColor)]
  void clearColor(in WebGLclampf red, in WebGLclampf green, in WebGLclampf blue, in WebGLclampf alpha);

  [binaryname(MozClearDepth)]
  void clearDepth(in WebGLclampf depth);

  [binaryname(MozClearStencil)]
  void clearStencil(in WebGLint s);

  [binaryname(MozColorMask)]
  void colorMask(in WebGLboolean red, in WebGLboolean green, in WebGLboolean blue, in WebGLboolean alpha);

  void compileShader([optional] in nsIWebGLShader shader);

  [implicit_jscontext] void compressedTexImage2D(in WebGLenum target, in WebGLint level, in WebGLenum internalformat,
                            in WebGLsizei width, in WebGLsizei height, in WebGLint border,
                            in jsval pixels);

  [implicit_jscontext] void compressedTexSubImage2D(in WebGLenum target, in WebGLint level, in WebGLint xoffset,
                               in WebGLint yoffset, in WebGLsizei width, in WebGLsizei height,
                               in WebGLenum format, in jsval pixels);

  [binaryname(MozCopyTexImage2D)]
  void copyTexImage2D(in WebGLenum target, in WebGLint level, in WebGLenum internalformat, 
                      in WebGLint x, in WebGLint y, in WebGLsizei width, in WebGLsizei height, in WebGLint border);

  [binaryname(MozCopyTexSubImage2D)]
  void copyTexSubImage2D(in WebGLenum target, in WebGLint level, in WebGLint xoffset, in WebGLint yoffset, 
                         in WebGLint x, in WebGLint y, in WebGLsizei width, in WebGLsizei height);

  nsIWebGLBuffer createBuffer();
  nsIWebGLProgram createProgram();
  nsIWebGLFramebuffer createFramebuffer();
  nsIWebGLRenderbuffer createRenderbuffer();
  nsIWebGLShader createShader(in WebGLenum type);
  nsIWebGLTexture createTexture();

  [binaryname(MozCullFace)]
  void cullFace(in WebGLenum mode);

  void deleteBuffer(in nsIWebGLBuffer buffer);
  void deleteProgram(in nsIWebGLProgram program);
  void deleteFramebuffer(in nsIWebGLFramebuffer framebuffer);
  void deleteRenderbuffer(in nsIWebGLRenderbuffer renderbuffer);
  void deleteShader(in nsIWebGLShader shader);
  void deleteTexture(in nsIWebGLTexture texture);

  [binaryname(MozDepthFunc)]
  void depthFunc(in WebGLenum func);

  [binaryname(MozDepthMask)]
  void depthMask(in WebGLboolean flag);

  [binaryname(MozDepthRange)]
  void depthRange(in WebGLclampf zNear, in WebGLclampf zFar);

  void detachShader(in nsIWebGLProgram program, in nsIWebGLShader shader);

  [binaryname(MozDisable)]
  void disable(in WebGLenum cap);

  [binaryname(MozDisableVertexAttribArray)]
  void disableVertexAttribArray(in WebGLuint index);

  [binaryname(MozDrawArrays)]
  void drawArrays(in WebGLenum mode, in WebGLint first, in WebGLsizei count);

  // Modified: void glDrawElements(WebGLenum mode, WebGLsizei count, WebGLenum type, const void* indices);
  [binaryname(MozDrawElements)]
  void drawElements(in WebGLenum mode, in WebGLsizei count, in WebGLenum type, in WebGLintptr offset);

  [binaryname(MozEnable)]
  void enable(in WebGLenum cap);

  [binaryname(MozEnableVertexAttribArray)]
  void enableVertexAttribArray(in WebGLuint index);

  [binaryname(MozFinish)]
  void finish();

  [binaryname(MozFlush)]
  void flush();

  void framebufferRenderbuffer(in WebGLenum target, in WebGLenum attachment, in WebGLenum renderbuffertarget, 
                               in nsIWebGLRenderbuffer renderbuffer);
  void framebufferTexture2D(in WebGLenum target, in WebGLenum attachment, in WebGLenum textarget, 
                            in nsIWebGLTexture texture, in WebGLint level);

  [binaryname(MozFrontFace)]
  void frontFace(in WebGLenum mode);

  [binaryname(MozGenerateMipmap)]
  void generateMipmap(in WebGLenum target);

  nsIWebGLActiveInfo getActiveAttrib(in nsIWebGLProgram program, in PRUint32 index);
  nsIWebGLActiveInfo getActiveUniform(in nsIWebGLProgram program, in PRUint32 index);

  nsIVariant getAttachedShaders(in nsIWebGLProgram program);

  WebGLint getAttribLocation(in nsIWebGLProgram program, in DOMString name);

  [implicit_jscontext] jsval
  getParameter(in WebGLenum pname);

  // Modified: void glGetBufferParameteriv(WebGLenum target, WebGLenum pname, WebGLint* params);
  jsval getBufferParameter(in WebGLenum target, in WebGLenum pname);

  [binaryname(MozGetError)]
  WebGLenum getError();

  // Modified: void glGetFramebufferAttachmentParameteriv(WebGLenum target, WebGLenum attachment, WebGLenum pname, WebGLint* params);
  [implicit_jscontext] jsval
  getFramebufferAttachmentParameter(in WebGLenum target, in WebGLenum attachment, in WebGLenum pname);

  // Modified: void glGetProgramiv(nsIWebGLProgram program, WebGLenum pname, WebGLint* params);
  jsval getProgramParameter(in nsIWebGLProgram program, in WebGLenum pname);

  // Modified: void glGetProgramInfoLog(WebGLuint program, WebGLsizei bufsize, WebGLsizei* length, char* infolog);
  DOMString getProgramInfoLog(in nsIWebGLProgram program);

  // Modified: void glGetRenderbufferParameteriv(WebGLenum target, WebGLenum pname, WebGLint* params);
  //nsIWebGLIntArray getRenderbufferParameteriv(in WebGLenum target, in WebGLenum pname);
  jsval getRenderbufferParameter(in WebGLenum target, in WebGLenum pname);

  jsval getShaderParameter(in nsIWebGLShader shader, in WebGLenum pname);

  // Modified: void glGetShaderInfoLog(WebGLuint shader, WebGLsizei bufsize, WebGLsizei* length, char* infolog);
  DOMString getShaderInfoLog(in nsIWebGLShader shader);

  nsIWebGLShaderPrecisionFormat getShaderPrecisionFormat(in WebGLenum shadertype, in WebGLenum precisiontype);

  DOMString getShaderSource(in nsIWebGLShader shader);

  jsval getTexParameter(in WebGLenum target, in WebGLenum pname);

  [implicit_jscontext]
  jsval getUniform(in nsIWebGLProgram program, in nsIWebGLUniformLocation location);

  nsIWebGLUniformLocation getUniformLocation (in nsIWebGLProgram program, in DOMString name);

  [implicit_jscontext] jsval
  getVertexAttrib(in WebGLuint index, in WebGLenum pname);

  // TBD
  // void glGetVertexAttribPointerv(WebGLuint index, WebGLenum pname, void** pointer);
  WebGLuint getVertexAttribOffset(in WebGLuint index, in WebGLenum pname);

  [binaryname(MozHint)]
  void hint(in WebGLenum target, in WebGLenum mode);

  WebGLboolean isBuffer(in nsIWebGLBuffer buffer);
  WebGLboolean isFramebuffer(in nsIWebGLFramebuffer framebuffer);
  WebGLboolean isProgram(in nsIWebGLProgram program);
  WebGLboolean isRenderbuffer(in nsIWebGLRenderbuffer renderbuffer);
  WebGLboolean isShader(in nsIWebGLShader shader);
  WebGLboolean isTexture(in nsIWebGLTexture texture);

  WebGLboolean isEnabled(in WebGLenum cap);

  [binaryname(MozLineWidth)]
  void lineWidth(in WebGLfloat width);

  void linkProgram([optional] in nsIWebGLProgram program);

  [binaryname(MozPixelStorei)]
  void pixelStorei(in WebGLenum pname, in WebGLint param);

  [binaryname(MozPolygonOffset)]
  void polygonOffset(in WebGLfloat factor, in WebGLfloat units);

  [implicit_jscontext] void readPixels(in WebGLint x, in WebGLint y, in WebGLsizei width, in WebGLsizei height,
                  in WebGLenum format, in WebGLenum type, in jsval pixels);

  //void glReleaseShaderCompiler();

  [binaryname(MozRenderbufferStorage)]
  void renderbufferStorage(in WebGLenum target, in WebGLenum internalformat, in WebGLsizei width, in WebGLsizei height);

  [binaryname(MozSampleCoverage)]
  void sampleCoverage(in WebGLclampf value, in WebGLboolean invert);

  [binaryname(MozScissor)]
  void scissor(in WebGLint x, in WebGLint y, in WebGLsizei width, in WebGLsizei height);

  // Modified: void glShaderSource(WebGLuint shader, WebGLsizei count, const char** string, const WebGLint* length);
  void shaderSource([optional] in nsIWebGLShader shader, [optional] in DOMString source);

  [binaryname(MozStencilFunc)]
  void stencilFunc(in WebGLenum func, in WebGLint ref, in WebGLuint mask);

  [binaryname(MozStencilFuncSeparate)]
  void stencilFuncSeparate(in WebGLenum face, in WebGLenum func, in WebGLint ref, in WebGLuint mask);

  [binaryname(MozStencilMask)]
  void stencilMask(in WebGLuint mask);

  [binaryname(MozStencilMaskSeparate)]
  void stencilMaskSeparate(in WebGLenum face, in WebGLuint mask);

  [binaryname(MozStencilOp)]
  void stencilOp(in WebGLenum fail, in WebGLenum zfail, in WebGLenum zpass);

  [binaryname(MozStencilOpSeparate)]
  void stencilOpSeparate(in WebGLenum face, in WebGLenum fail, in WebGLenum zfail, in WebGLenum zpass);

  void texImage2D([optional] in long dummy);
  [noscript,implicit_jscontext] void texImage2D_array(in WebGLenum target, in WebGLint level, in WebGLenum internalformat,
                                   in WebGLsizei width, in WebGLsizei height,
                                   in WebGLint border, in WebGLenum format, in WebGLenum type, in WebGLJSObjectPtr pixels);
  [noscript,implicit_jscontext] void texImage2D_imageData(in WebGLenum target, in WebGLint level, in WebGLenum internalformat,
                                   in WebGLsizei width, in WebGLsizei height,
                                   in WebGLint border, in WebGLenum format, in WebGLenum type, in WebGLJSObjectPtr pixels);

  // HTMLImageElement, HTMLCanvasElement, HTMLVideoElement
  [noscript] void texImage2D_dom(in WebGLenum target, in WebGLint level, in WebGLenum internalformat,
                                 in WebGLenum format, in WebGLenum type, in Element element);

  void texSubImage2D([optional] in long dummy);
  [noscript,implicit_jscontext] void texSubImage2D_array(in WebGLenum target, in WebGLint level,
                                      in WebGLint xoffset, in WebGLint yoffset, in WebGLsizei width, in WebGLsizei height,
                                      in WebGLenum format, in WebGLenum type, in WebGLJSObjectPtr pixels);
  [noscript,implicit_jscontext] void texSubImage2D_imageData(in WebGLenum target, in WebGLint level,
                                      in WebGLint xoffset, in WebGLint yoffset, in WebGLsizei width, in WebGLsizei height,
                                      in WebGLenum format, in WebGLenum type, in WebGLJSObjectPtr pixels);
  // HTMLImageElement, HTMLCanvasElement, HTMLVideoElement
  [noscript] void texSubImage2D_dom(in WebGLenum target, in WebGLint level,
                                    in WebGLint xoffset, in WebGLint yoffset, in WebGLenum format, in WebGLenum type,
                                    in Element element);

  // Modified: This replaces glTexParameterf, glTexParameterfv, glTexParameteri and glTexParameteriv
  [binaryname(MozTexParameterf)]
  void texParameterf(in WebGLenum target, in WebGLenum pname, in WebGLfloat param);

  [binaryname(MozTexParameteri)]
  void texParameteri(in WebGLenum target, in WebGLenum pname, in WebGLint param);
  //void glTexParameter(in WebGLenum target, in WebGLenum pname, in nsIWebGLArray params);

  // Modified: All the glUniform*v forms below are modified by replacing 'count' and 'v' with a nsIWebGLArray
  void uniform1f (in nsIWebGLUniformLocation location, in WebGLfloat x);
  void uniform1i (in nsIWebGLUniformLocation location, in WebGLint x);
  void uniform2f (in nsIWebGLUniformLocation location, in WebGLfloat x, in WebGLfloat y);
  void uniform2i (in nsIWebGLUniformLocation location, in WebGLint x, in WebGLint y);
  void uniform3f (in nsIWebGLUniformLocation location, in WebGLfloat x, in WebGLfloat y, in WebGLfloat z);
  void uniform3i (in nsIWebGLUniformLocation location, in WebGLint x, in WebGLint y, in WebGLint z);
  void uniform4f (in nsIWebGLUniformLocation location, in WebGLfloat x, in WebGLfloat y, in WebGLfloat z, in WebGLfloat w);
  void uniform4i (in nsIWebGLUniformLocation location, in WebGLint x, in WebGLint y, in WebGLint z, in WebGLint w);

  [implicit_jscontext] void uniform1fv(in nsIWebGLUniformLocation location, in jsval v);
  [implicit_jscontext] void uniform1iv(in nsIWebGLUniformLocation location, in jsval v);
  [implicit_jscontext] void uniform2fv(in nsIWebGLUniformLocation location, in jsval v);
  [implicit_jscontext] void uniform2iv(in nsIWebGLUniformLocation location, in jsval v);
  [implicit_jscontext] void uniform3fv(in nsIWebGLUniformLocation location, in jsval v);
  [implicit_jscontext] void uniform3iv(in nsIWebGLUniformLocation location, in jsval v);
  [implicit_jscontext] void uniform4fv(in nsIWebGLUniformLocation location, in jsval v);
  [implicit_jscontext] void uniform4iv(in nsIWebGLUniformLocation location, in jsval v);

  [implicit_jscontext] void uniformMatrix2fv(in nsIWebGLUniformLocation location, in boolean transpose, in jsval value);
  [implicit_jscontext] void uniformMatrix3fv(in nsIWebGLUniformLocation location, in boolean transpose, in jsval value);
  [implicit_jscontext] void uniformMatrix4fv(in nsIWebGLUniformLocation location, in boolean transpose, in jsval value);

  // Added API using top entry from the passed nsIWebGLMatrixStack
  //ZZ void glUniformMatrix(in WebGLint location, in WebGLboolean transpose, in nsIWebGLMatrixStack value);

  void useProgram(in nsIWebGLProgram program);
  void validateProgram(in nsIWebGLProgram program);

  // Modified: All the glVertexAttrib*v forms below are modified by replacing 'values' with a WebGLJSObjectPtr
  [binaryname(MozVertexAttrib1f)]
  void vertexAttrib1f(in WebGLuint indx, in WebGLfloat x);

  [binaryname(MozVertexAttrib2f)]
  void vertexAttrib2f(in WebGLuint indx, in WebGLfloat x, in WebGLfloat y);

  [binaryname(MozVertexAttrib3f)]
  void vertexAttrib3f(in WebGLuint indx, in WebGLfloat x, in WebGLfloat y, in WebGLfloat z);

  [binaryname(MozVertexAttrib4f)]
  void vertexAttrib4f(in WebGLuint indx, in WebGLfloat x, in WebGLfloat y, in WebGLfloat z, in WebGLfloat w);

  [implicit_jscontext] void vertexAttrib1fv(in WebGLuint indx, in jsval values);
  [implicit_jscontext] void vertexAttrib2fv(in WebGLuint indx, in jsval values);
  [implicit_jscontext] void vertexAttrib3fv(in WebGLuint indx, in jsval values);
  [implicit_jscontext] void vertexAttrib4fv(in WebGLuint indx, in jsval values);

  // size is number of elements per attrib; offset, stride are in bytes
  [binaryname(MozVertexAttribPointer)]
  void vertexAttribPointer(in WebGLuint idx, in WebGLint size, in WebGLenum type, in WebGLboolean normalized, in WebGLsizei stride, in WebGLintptr offset);

  [binaryname(MozViewport)]
  void viewport(in WebGLint x, in WebGLint y, in WebGLsizei width, in WebGLsizei height);

  // get an underlying GL parameter, without any WebGL intervention.
  // Most useful for querying GL_VENDOR/GL_RENDERER for identifying
  // the underlying renderer to the user.
  [noscript] DOMString mozGetUnderlyingParamString(in WebGLenum pname);

  // extensions
  nsIWebGLExtension getExtension(in DOMString name);

  nsIVariant getSupportedExtensions();
  WebGLboolean isContextLost();

  readonly attribute WebGLsizei drawingBufferWidth;
  readonly attribute WebGLsizei drawingBufferHeight;
};
