1d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles)/* 2d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) * Copyright (C) 2009 Apple Inc. All rights reserved. 3d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) * 4d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) * Redistribution and use in source and binary forms, with or without 5d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) * modification, are permitted provided that the following conditions 6d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) * are met: 7d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) * 1. Redistributions of source code must retain the above copyright 8d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) * notice, this list of conditions and the following disclaimer. 9d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) * 2. Redistributions in binary form must reproduce the above copyright 10d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) * notice, this list of conditions and the following disclaimer in the 11d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) * documentation and/or other materials provided with the distribution. 12d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) * 13d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY 14d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 15d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 16d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR 17d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 18d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 19d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 20d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 21d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 23d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) */ 25d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 26d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles)#ifndef WebGLRenderingContextBase_h 27d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles)#define WebGLRenderingContextBase_h 28d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 29197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch#include "bindings/core/v8/Nullable.h" 30d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles)#include "core/dom/ActiveDOMObject.h" 31d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles)#include "core/html/canvas/CanvasRenderingContext.h" 32d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles)#include "core/html/canvas/WebGLExtensionName.h" 33d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles)#include "core/html/canvas/WebGLGetInfo.h" 34d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles)#include "core/page/Page.h" 35d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles)#include "core/rendering/RenderBoxModelObject.h" 36d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles)#include "platform/Timer.h" 37d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles)#include "platform/graphics/GraphicsTypes3D.h" 38d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles)#include "platform/graphics/ImageBuffer.h" 39a9984bf9ddc3cf73fdae3f29134a2bab379e7029Ben Murdoch#include "platform/graphics/gpu/DrawingBuffer.h" 40d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles)#include "platform/graphics/gpu/Extensions3DUtil.h" 41d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles)#include "platform/graphics/gpu/WebGLImageConversion.h" 42d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles)#include "public/platform/WebGraphicsContext3D.h" 43d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles)#include "wtf/Float32Array.h" 44d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles)#include "wtf/Int32Array.h" 45d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles)#include "wtf/OwnPtr.h" 46d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles)#include "wtf/text/WTFString.h" 47d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 48d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles)namespace blink { 49d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles)class WebLayer; 50d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles)} 51d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 52c1847b1379d12d0e05df27436bf19a9b1bf12deaTorne (Richard Coles)namespace blink { 53d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 54d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles)class ANGLEInstancedArrays; 55d6cdb82654e8f3343a693ca752d5c4cee0324e17Torne (Richard Coles)class EXTBlendMinMax; 56d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles)class EXTFragDepth; 576f543c786fc42989f552b4daa774ca5ff32fa697Ben Murdochclass EXTShaderTextureLOD; 58d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles)class EXTTextureFilterAnisotropic; 59d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles)class ExceptionState; 60d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles)class HTMLImageElement; 61d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles)class HTMLVideoElement; 62d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles)class ImageBuffer; 63d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles)class ImageData; 64d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles)class IntSize; 65d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles)class OESElementIndexUint; 66d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles)class OESStandardDerivatives; 67d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles)class OESTextureFloat; 68d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles)class OESTextureFloatLinear; 69d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles)class OESTextureHalfFloat; 70d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles)class OESTextureHalfFloatLinear; 71d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles)class OESVertexArrayObject; 72d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles)class WebGLActiveInfo; 73d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles)class WebGLBuffer; 74d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles)class WebGLCompressedTextureATC; 7510f88d5669dbd969c059d61ba09fa37dd72ac559Ben Murdochclass WebGLCompressedTextureETC1; 76d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles)class WebGLCompressedTexturePVRTC; 77d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles)class WebGLCompressedTextureS3TC; 78d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles)class WebGLContextAttributes; 79d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles)class WebGLContextGroup; 80d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles)class WebGLContextObject; 81d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles)class WebGLDebugRendererInfo; 82d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles)class WebGLDebugShaders; 83d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles)class WebGLDepthTexture; 84d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles)class WebGLDrawBuffers; 85d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles)class WebGLExtension; 86d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles)class WebGLFramebuffer; 87d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles)class WebGLLoseContext; 88d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles)class WebGLObject; 89d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles)class WebGLProgram; 90d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles)class WebGLRenderbuffer; 91d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles)class WebGLShader; 92d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles)class WebGLShaderPrecisionFormat; 93d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles)class WebGLSharedObject; 94c1847b1379d12d0e05df27436bf19a9b1bf12deaTorne (Richard Coles)class WebGLSharedWebGraphicsContext3D; 95d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles)class WebGLTexture; 96d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles)class WebGLUniformLocation; 97d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles)class WebGLVertexArrayObjectOES; 98d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 99d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles)class WebGLRenderingContextLostCallback; 100d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles)class WebGLRenderingContextErrorMessageCallback; 101d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 102f91f5fa1608c2cdd9af1842fb5dadbe78275be2aBo Liuclass WebGLRenderingContextBase: public CanvasRenderingContext, public ActiveDOMObject, public Page::MultisamplingChangedObserver { 103f91f5fa1608c2cdd9af1842fb5dadbe78275be2aBo Liu WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(WebGLRenderingContextBase); 104d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles)public: 105d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) virtual ~WebGLRenderingContextBase(); 106d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 107d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) virtual unsigned version() const = 0; 108d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) virtual String contextName() const = 0; 109d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) virtual void registerContextExtensions() = 0; 110d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 111d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) static unsigned getWebGLVersion(const CanvasRenderingContext*); 112d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 113d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) int drawingBufferWidth() const; 114d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) int drawingBufferHeight() const; 115d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 116d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) void activeTexture(GLenum texture); 117d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) void attachShader(WebGLProgram*, WebGLShader*); 118d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) void bindAttribLocation(WebGLProgram*, GLuint index, const String& name); 119d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) void bindBuffer(GLenum target, WebGLBuffer*); 120d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) void bindFramebuffer(GLenum target, WebGLFramebuffer*); 121d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) void bindRenderbuffer(GLenum target, WebGLRenderbuffer*); 122d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) void bindTexture(GLenum target, WebGLTexture*); 123d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) void blendColor(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); 124d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) void blendEquation(GLenum mode); 125d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) void blendEquationSeparate(GLenum modeRGB, GLenum modeAlpha); 126d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) void blendFunc(GLenum sfactor, GLenum dfactor); 127d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) void blendFuncSeparate(GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); 128d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 129d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) void bufferData(GLenum target, long long size, GLenum usage); 130d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) void bufferData(GLenum target, ArrayBuffer* data, GLenum usage); 131d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) void bufferData(GLenum target, ArrayBufferView* data, GLenum usage); 132d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) void bufferSubData(GLenum target, long long offset, ArrayBuffer* data); 133d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) void bufferSubData(GLenum target, long long offset, ArrayBufferView* data); 134d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 135d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) GLenum checkFramebufferStatus(GLenum target); 136d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) void clear(GLbitfield mask); 137d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) void clearColor(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); 138d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) void clearDepth(GLfloat); 139d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) void clearStencil(GLint); 140d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) void colorMask(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha); 141d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) void compileShader(WebGLShader*); 142d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 143d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) void compressedTexImage2D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, ArrayBufferView* data); 144d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) void compressedTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, ArrayBufferView* data); 145d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 146d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) void copyTexImage2D(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); 147d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) void copyTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); 148d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 149c1847b1379d12d0e05df27436bf19a9b1bf12deaTorne (Richard Coles) PassRefPtrWillBeRawPtr<WebGLBuffer> createBuffer(); 150c1847b1379d12d0e05df27436bf19a9b1bf12deaTorne (Richard Coles) PassRefPtrWillBeRawPtr<WebGLFramebuffer> createFramebuffer(); 151c1847b1379d12d0e05df27436bf19a9b1bf12deaTorne (Richard Coles) PassRefPtrWillBeRawPtr<WebGLProgram> createProgram(); 152c1847b1379d12d0e05df27436bf19a9b1bf12deaTorne (Richard Coles) PassRefPtrWillBeRawPtr<WebGLRenderbuffer> createRenderbuffer(); 153c1847b1379d12d0e05df27436bf19a9b1bf12deaTorne (Richard Coles) PassRefPtrWillBeRawPtr<WebGLShader> createShader(GLenum type); 154c1847b1379d12d0e05df27436bf19a9b1bf12deaTorne (Richard Coles) PassRefPtrWillBeRawPtr<WebGLTexture> createTexture(); 155d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 156d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) void cullFace(GLenum mode); 157d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 158d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) void deleteBuffer(WebGLBuffer*); 159d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) void deleteFramebuffer(WebGLFramebuffer*); 160d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) void deleteProgram(WebGLProgram*); 161d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) void deleteRenderbuffer(WebGLRenderbuffer*); 162d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) void deleteShader(WebGLShader*); 163d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) void deleteTexture(WebGLTexture*); 164d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 165d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) void depthFunc(GLenum); 166d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) void depthMask(GLboolean); 167d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) void depthRange(GLfloat zNear, GLfloat zFar); 168d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) void detachShader(WebGLProgram*, WebGLShader*); 169d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) void disable(GLenum cap); 170d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) void disableVertexAttribArray(GLuint index); 171d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) void drawArrays(GLenum mode, GLint first, GLsizei count); 172d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) void drawElements(GLenum mode, GLsizei count, GLenum type, long long offset); 173d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 174d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) void drawArraysInstancedANGLE(GLenum mode, GLint first, GLsizei count, GLsizei primcount); 175f91f5fa1608c2cdd9af1842fb5dadbe78275be2aBo Liu void drawElementsInstancedANGLE(GLenum mode, GLsizei count, GLenum type, long long offset, GLsizei primcount); 176d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 177d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) void enable(GLenum cap); 178d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) void enableVertexAttribArray(GLuint index); 179d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) void finish(); 180d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) void flush(); 181d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) void framebufferRenderbuffer(GLenum target, GLenum attachment, GLenum renderbuffertarget, WebGLRenderbuffer*); 182d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) void framebufferTexture2D(GLenum target, GLenum attachment, GLenum textarget, WebGLTexture*, GLint level); 183d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) void frontFace(GLenum mode); 184d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) void generateMipmap(GLenum target); 185d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 186c1847b1379d12d0e05df27436bf19a9b1bf12deaTorne (Richard Coles) PassRefPtrWillBeRawPtr<WebGLActiveInfo> getActiveAttrib(WebGLProgram*, GLuint index); 187c1847b1379d12d0e05df27436bf19a9b1bf12deaTorne (Richard Coles) PassRefPtrWillBeRawPtr<WebGLActiveInfo> getActiveUniform(WebGLProgram*, GLuint index); 188c1847b1379d12d0e05df27436bf19a9b1bf12deaTorne (Richard Coles) bool getAttachedShaders(WebGLProgram*, WillBeHeapVector<RefPtrWillBeMember<WebGLShader> >&); 189c1847b1379d12d0e05df27436bf19a9b1bf12deaTorne (Richard Coles) Nullable<WillBeHeapVector<RefPtrWillBeMember<WebGLShader> > > getAttachedShaders(WebGLProgram*); 190d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) GLint getAttribLocation(WebGLProgram*, const String& name); 191d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) WebGLGetInfo getBufferParameter(GLenum target, GLenum pname); 192c1847b1379d12d0e05df27436bf19a9b1bf12deaTorne (Richard Coles) PassRefPtrWillBeRawPtr<WebGLContextAttributes> getContextAttributes(); 193d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) GLenum getError(); 194c1847b1379d12d0e05df27436bf19a9b1bf12deaTorne (Richard Coles) PassRefPtrWillBeRawPtr<WebGLExtension> getExtension(const String& name); 195d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) WebGLGetInfo getFramebufferAttachmentParameter(GLenum target, GLenum attachment, GLenum pname); 196d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) WebGLGetInfo getParameter(GLenum pname); 197d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) WebGLGetInfo getProgramParameter(WebGLProgram*, GLenum pname); 198d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) String getProgramInfoLog(WebGLProgram*); 199d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) WebGLGetInfo getRenderbufferParameter(GLenum target, GLenum pname); 200d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) WebGLGetInfo getShaderParameter(WebGLShader*, GLenum pname); 201d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) String getShaderInfoLog(WebGLShader*); 202c1847b1379d12d0e05df27436bf19a9b1bf12deaTorne (Richard Coles) PassRefPtrWillBeRawPtr<WebGLShaderPrecisionFormat> getShaderPrecisionFormat(GLenum shaderType, GLenum precisionType); 203d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) String getShaderSource(WebGLShader*); 204197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch Nullable<Vector<String> > getSupportedExtensions(); 205d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) WebGLGetInfo getTexParameter(GLenum target, GLenum pname); 206d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) WebGLGetInfo getUniform(WebGLProgram*, const WebGLUniformLocation*); 207c1847b1379d12d0e05df27436bf19a9b1bf12deaTorne (Richard Coles) PassRefPtrWillBeRawPtr<WebGLUniformLocation> getUniformLocation(WebGLProgram*, const String&); 208d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) WebGLGetInfo getVertexAttrib(GLuint index, GLenum pname); 209d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) long long getVertexAttribOffset(GLuint index, GLenum pname); 210d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 211d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) void hint(GLenum target, GLenum mode); 212d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) GLboolean isBuffer(WebGLBuffer*); 213a9984bf9ddc3cf73fdae3f29134a2bab379e7029Ben Murdoch bool isContextLost() const; 214d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) GLboolean isEnabled(GLenum cap); 215d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) GLboolean isFramebuffer(WebGLFramebuffer*); 216d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) GLboolean isProgram(WebGLProgram*); 217d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) GLboolean isRenderbuffer(WebGLRenderbuffer*); 218d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) GLboolean isShader(WebGLShader*); 219d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) GLboolean isTexture(WebGLTexture*); 220d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 221d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) void lineWidth(GLfloat); 222d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) void linkProgram(WebGLProgram*); 223d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) void pixelStorei(GLenum pname, GLint param); 224d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) void polygonOffset(GLfloat factor, GLfloat units); 225d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) void readPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, ArrayBufferView* pixels); 226d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) void renderbufferStorage(GLenum target, GLenum internalformat, GLsizei width, GLsizei height); 227d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) void sampleCoverage(GLfloat value, GLboolean invert); 228d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) void scissor(GLint x, GLint y, GLsizei width, GLsizei height); 229d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) void shaderSource(WebGLShader*, const String&); 230d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) void stencilFunc(GLenum func, GLint ref, GLuint mask); 231d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) void stencilFuncSeparate(GLenum face, GLenum func, GLint ref, GLuint mask); 232d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) void stencilMask(GLuint); 233d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) void stencilMaskSeparate(GLenum face, GLuint mask); 234d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) void stencilOp(GLenum fail, GLenum zfail, GLenum zpass); 235d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) void stencilOpSeparate(GLenum face, GLenum fail, GLenum zfail, GLenum zpass); 236d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 237d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) void texImage2D(GLenum target, GLint level, GLenum internalformat, 238d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) GLsizei width, GLsizei height, GLint border, 239d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) GLenum format, GLenum type, ArrayBufferView*, ExceptionState&); 240d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) void texImage2D(GLenum target, GLint level, GLenum internalformat, 241d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) GLenum format, GLenum type, ImageData*, ExceptionState&); 242d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) void texImage2D(GLenum target, GLint level, GLenum internalformat, 243d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) GLenum format, GLenum type, HTMLImageElement*, ExceptionState&); 244d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) void texImage2D(GLenum target, GLint level, GLenum internalformat, 245d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) GLenum format, GLenum type, HTMLCanvasElement*, ExceptionState&); 246d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) void texImage2D(GLenum target, GLint level, GLenum internalformat, 247d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) GLenum format, GLenum type, HTMLVideoElement*, ExceptionState&); 248d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 249d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) void texParameterf(GLenum target, GLenum pname, GLfloat param); 250d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) void texParameteri(GLenum target, GLenum pname, GLint param); 251d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 252d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) void texSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, 253d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) GLsizei width, GLsizei height, 254d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) GLenum format, GLenum type, ArrayBufferView*, ExceptionState&); 255d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) void texSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, 256d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) GLenum format, GLenum type, ImageData*, ExceptionState&); 257d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) void texSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, 258d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) GLenum format, GLenum type, HTMLImageElement*, ExceptionState&); 259d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) void texSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, 260d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) GLenum format, GLenum type, HTMLCanvasElement*, ExceptionState&); 261d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) void texSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, 262d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) GLenum format, GLenum type, HTMLVideoElement*, ExceptionState&); 263d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 264d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) void uniform1f(const WebGLUniformLocation*, GLfloat x); 265d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) void uniform1fv(const WebGLUniformLocation*, Float32Array* v); 266d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) void uniform1fv(const WebGLUniformLocation*, GLfloat* v, GLsizei); 267d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) void uniform1i(const WebGLUniformLocation*, GLint x); 268d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) void uniform1iv(const WebGLUniformLocation*, Int32Array* v); 269d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) void uniform1iv(const WebGLUniformLocation*, GLint* v, GLsizei); 270d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) void uniform2f(const WebGLUniformLocation*, GLfloat x, GLfloat y); 271d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) void uniform2fv(const WebGLUniformLocation*, Float32Array* v); 272d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) void uniform2fv(const WebGLUniformLocation*, GLfloat* v, GLsizei); 273d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) void uniform2i(const WebGLUniformLocation*, GLint x, GLint y); 274d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) void uniform2iv(const WebGLUniformLocation*, Int32Array* v); 275d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) void uniform2iv(const WebGLUniformLocation*, GLint* v, GLsizei); 276d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) void uniform3f(const WebGLUniformLocation*, GLfloat x, GLfloat y, GLfloat z); 277d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) void uniform3fv(const WebGLUniformLocation*, Float32Array* v); 278d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) void uniform3fv(const WebGLUniformLocation*, GLfloat* v, GLsizei); 279d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) void uniform3i(const WebGLUniformLocation*, GLint x, GLint y, GLint z); 280d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) void uniform3iv(const WebGLUniformLocation*, Int32Array* v); 281d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) void uniform3iv(const WebGLUniformLocation*, GLint* v, GLsizei); 282d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) void uniform4f(const WebGLUniformLocation*, GLfloat x, GLfloat y, GLfloat z, GLfloat w); 283d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) void uniform4fv(const WebGLUniformLocation*, Float32Array* v); 284d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) void uniform4fv(const WebGLUniformLocation*, GLfloat* v, GLsizei); 285d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) void uniform4i(const WebGLUniformLocation*, GLint x, GLint y, GLint z, GLint w); 286d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) void uniform4iv(const WebGLUniformLocation*, Int32Array* v); 287d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) void uniform4iv(const WebGLUniformLocation*, GLint* v, GLsizei); 288d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) void uniformMatrix2fv(const WebGLUniformLocation*, GLboolean transpose, Float32Array* value); 289d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) void uniformMatrix2fv(const WebGLUniformLocation*, GLboolean transpose, GLfloat* value, GLsizei); 290d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) void uniformMatrix3fv(const WebGLUniformLocation*, GLboolean transpose, Float32Array* value); 291d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) void uniformMatrix3fv(const WebGLUniformLocation*, GLboolean transpose, GLfloat* value, GLsizei); 292d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) void uniformMatrix4fv(const WebGLUniformLocation*, GLboolean transpose, Float32Array* value); 293d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) void uniformMatrix4fv(const WebGLUniformLocation*, GLboolean transpose, GLfloat* value, GLsizei); 294d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 295d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) void useProgram(WebGLProgram*); 296d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) void validateProgram(WebGLProgram*); 297d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 298d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) void vertexAttrib1f(GLuint index, GLfloat x); 299d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) void vertexAttrib1fv(GLuint index, Float32Array* values); 300d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) void vertexAttrib1fv(GLuint index, GLfloat* values, GLsizei); 301d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) void vertexAttrib2f(GLuint index, GLfloat x, GLfloat y); 302d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) void vertexAttrib2fv(GLuint index, Float32Array* values); 303d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) void vertexAttrib2fv(GLuint index, GLfloat* values, GLsizei); 304d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) void vertexAttrib3f(GLuint index, GLfloat x, GLfloat y, GLfloat z); 305d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) void vertexAttrib3fv(GLuint index, Float32Array* values); 306d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) void vertexAttrib3fv(GLuint index, GLfloat* values, GLsizei); 307d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) void vertexAttrib4f(GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); 308d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) void vertexAttrib4fv(GLuint index, Float32Array* values); 309d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) void vertexAttrib4fv(GLuint index, GLfloat* values, GLsizei); 310d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) void vertexAttribPointer(GLuint index, GLint size, GLenum type, GLboolean normalized, 311d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) GLsizei stride, long long offset); 312d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 313d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) void vertexAttribDivisorANGLE(GLuint index, GLuint divisor); 314d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 315d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) void viewport(GLint x, GLint y, GLsizei width, GLsizei height); 316d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 3177242dc3dbeb210b5e876a3c42d1ec1a667fc621aPrimiano Tucci // WEBGL_lose_context support 318d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) enum LostContextMode { 3197242dc3dbeb210b5e876a3c42d1ec1a667fc621aPrimiano Tucci NotLostContext, 3207242dc3dbeb210b5e876a3c42d1ec1a667fc621aPrimiano Tucci 321d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) // Lost context occurred at the graphics system level. 322d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) RealLostContext, 323d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 3247242dc3dbeb210b5e876a3c42d1ec1a667fc621aPrimiano Tucci // Lost context provoked by WEBGL_lose_context. 3257242dc3dbeb210b5e876a3c42d1ec1a667fc621aPrimiano Tucci WebGLLoseContextLostContext, 3267242dc3dbeb210b5e876a3c42d1ec1a667fc621aPrimiano Tucci 3277242dc3dbeb210b5e876a3c42d1ec1a667fc621aPrimiano Tucci // Lost context occurred due to internal implementation reasons. 328d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) SyntheticLostContext, 3297242dc3dbeb210b5e876a3c42d1ec1a667fc621aPrimiano Tucci }; 3307242dc3dbeb210b5e876a3c42d1ec1a667fc621aPrimiano Tucci enum AutoRecoveryMethod { 3317242dc3dbeb210b5e876a3c42d1ec1a667fc621aPrimiano Tucci // Don't restore automatically. 3327242dc3dbeb210b5e876a3c42d1ec1a667fc621aPrimiano Tucci Manual, 3337242dc3dbeb210b5e876a3c42d1ec1a667fc621aPrimiano Tucci 3347242dc3dbeb210b5e876a3c42d1ec1a667fc621aPrimiano Tucci // Restore when resources are available. 3357242dc3dbeb210b5e876a3c42d1ec1a667fc621aPrimiano Tucci WhenAvailable, 336d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 3377242dc3dbeb210b5e876a3c42d1ec1a667fc621aPrimiano Tucci // Restore as soon as possible. 3387242dc3dbeb210b5e876a3c42d1ec1a667fc621aPrimiano Tucci Auto 339d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) }; 3407242dc3dbeb210b5e876a3c42d1ec1a667fc621aPrimiano Tucci void forceLostContext(LostContextMode, AutoRecoveryMethod); 341d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) void forceRestoreContext(); 3427242dc3dbeb210b5e876a3c42d1ec1a667fc621aPrimiano Tucci void loseContextImpl(LostContextMode, AutoRecoveryMethod); 343d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 344c1847b1379d12d0e05df27436bf19a9b1bf12deaTorne (Richard Coles) blink::WebGraphicsContext3D* webContext() const { return drawingBuffer()->context(); } 345d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) WebGLContextGroup* contextGroup() const { return m_contextGroup.get(); } 346d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) Extensions3DUtil* extensionsUtil(); 347d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 348d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) void reshape(int width, int height); 349d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 350d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) void markLayerComposited(); 351aafa69cb17c9d6606c07663ade5f81388a2c5986Ben Murdoch PassRefPtrWillBeRawPtr<ImageData> paintRenderingResultsToImageData(); 352d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 353d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) void removeSharedObject(WebGLSharedObject*); 354d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) void removeContextObject(WebGLContextObject*); 355d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 356d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) unsigned maxVertexAttribs() const { return m_maxVertexAttribs; } 357d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 358d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) // ActiveDOMObject notifications 359d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) virtual bool hasPendingActivity() const OVERRIDE; 360d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) virtual void stop() OVERRIDE; 361d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 3625d92fedcae5e801a8b224de090094f2d9df0b54aTorne (Richard Coles) void setSavingImage(bool isSaving) { m_savingImage = isSaving; } 363c1847b1379d12d0e05df27436bf19a9b1bf12deaTorne (Richard Coles) 364c1847b1379d12d0e05df27436bf19a9b1bf12deaTorne (Richard Coles) virtual void trace(Visitor*) OVERRIDE; 365c1847b1379d12d0e05df27436bf19a9b1bf12deaTorne (Richard Coles) 366c1847b1379d12d0e05df27436bf19a9b1bf12deaTorne (Richard Coles) class TextureUnitState { 367c1847b1379d12d0e05df27436bf19a9b1bf12deaTorne (Richard Coles) ALLOW_ONLY_INLINE_ALLOCATION(); 368c1847b1379d12d0e05df27436bf19a9b1bf12deaTorne (Richard Coles) public: 369c1847b1379d12d0e05df27436bf19a9b1bf12deaTorne (Richard Coles) RefPtrWillBeMember<WebGLTexture> m_texture2DBinding; 370c1847b1379d12d0e05df27436bf19a9b1bf12deaTorne (Richard Coles) RefPtrWillBeMember<WebGLTexture> m_textureCubeMapBinding; 371c1847b1379d12d0e05df27436bf19a9b1bf12deaTorne (Richard Coles) 372c1847b1379d12d0e05df27436bf19a9b1bf12deaTorne (Richard Coles) void trace(Visitor*); 373c1847b1379d12d0e05df27436bf19a9b1bf12deaTorne (Richard Coles) }; 374c1847b1379d12d0e05df27436bf19a9b1bf12deaTorne (Richard Coles) 375d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles)protected: 376d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) friend class WebGLDrawBuffers; 377d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) friend class WebGLFramebuffer; 378d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) friend class WebGLObject; 379c1847b1379d12d0e05df27436bf19a9b1bf12deaTorne (Richard Coles) friend class WebGLContextObject; 380d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) friend class OESVertexArrayObject; 381d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) friend class WebGLDebugShaders; 382d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) friend class WebGLCompressedTextureATC; 38310f88d5669dbd969c059d61ba09fa37dd72ac559Ben Murdoch friend class WebGLCompressedTextureETC1; 384d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) friend class WebGLCompressedTexturePVRTC; 385d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) friend class WebGLCompressedTextureS3TC; 386d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) friend class WebGLRenderingContextErrorMessageCallback; 387d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) friend class WebGLVertexArrayObjectOES; 38843e7502580f146aa5b3db8267ba6dbb5c733a489Torne (Richard Coles) friend class ScopedTexture2DRestorer; 389d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 390d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) WebGLRenderingContextBase(HTMLCanvasElement*, PassOwnPtr<blink::WebGraphicsContext3D>, WebGLContextAttributes*); 391f6b7aed3f7ce69aca0d7a032d144cbd088b04393Torne (Richard Coles) PassRefPtr<DrawingBuffer> createDrawingBuffer(PassOwnPtr<blink::WebGraphicsContext3D>); 392d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) void initializeNewContext(); 393d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) void setupFlags(); 394d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 395c1847b1379d12d0e05df27436bf19a9b1bf12deaTorne (Richard Coles)#if ENABLE(OILPAN) 396c1847b1379d12d0e05df27436bf19a9b1bf12deaTorne (Richard Coles) PassRefPtr<WebGLSharedWebGraphicsContext3D> sharedWebGraphicsContext3D() const; 397c1847b1379d12d0e05df27436bf19a9b1bf12deaTorne (Richard Coles)#endif 398c1847b1379d12d0e05df27436bf19a9b1bf12deaTorne (Richard Coles) 3997242dc3dbeb210b5e876a3c42d1ec1a667fc621aPrimiano Tucci // CanvasRenderingContext implementation. 4007242dc3dbeb210b5e876a3c42d1ec1a667fc621aPrimiano Tucci virtual bool is3d() const OVERRIDE { return true; } 4017242dc3dbeb210b5e876a3c42d1ec1a667fc621aPrimiano Tucci virtual bool isAccelerated() const OVERRIDE { return true; } 4027242dc3dbeb210b5e876a3c42d1ec1a667fc621aPrimiano Tucci virtual void setIsHidden(bool) OVERRIDE; 4037242dc3dbeb210b5e876a3c42d1ec1a667fc621aPrimiano Tucci virtual void paintRenderingResultsToCanvas() OVERRIDE; 4047242dc3dbeb210b5e876a3c42d1ec1a667fc621aPrimiano Tucci virtual blink::WebLayer* platformLayer() const OVERRIDE; 4057242dc3dbeb210b5e876a3c42d1ec1a667fc621aPrimiano Tucci 406d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) void addSharedObject(WebGLSharedObject*); 407d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) void addContextObject(WebGLContextObject*); 408d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) void detachAndRemoveAllObjects(); 409d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 410d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) void destroyContext(); 411d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) void markContextChanged(ContentChangeType); 412d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 413d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) // Query if the GL implementation is NPOT strict. 414d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) bool isGLES2NPOTStrict() { return m_isGLES2NPOTStrict; } 415d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) // Query if depth_stencil buffer is supported. 416d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) bool isDepthStencilSupported() { return m_isDepthStencilSupported; } 417d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 418d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) // Helper to return the size in bytes of OpenGL data types 419d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) // like GL_FLOAT, GL_INT, etc. 420d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) unsigned sizeInBytes(GLenum type); 421d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 422d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) // Check if each enabled vertex attribute is bound to a buffer. 423d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) bool validateRenderingState(const char*); 424d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 425d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) bool validateWebGLObject(const char*, WebGLObject*); 426d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 427d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) // Adds a compressed texture format. 428d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) void addCompressedTextureFormat(GLenum); 429d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) void removeAllCompressedTextureFormats(); 430d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 431d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) PassRefPtr<Image> drawImageIntoBuffer(Image*, int width, int height, const char* functionName); 432d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 433d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) PassRefPtr<Image> videoFrameToImage(HTMLVideoElement*, BackingStoreCopy); 434d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 435d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) WebGLRenderbuffer* ensureEmulatedStencilBuffer(GLenum target, WebGLRenderbuffer*); 436d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 437d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) // Structure for rendering to a DrawingBuffer, instead of directly 438d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) // to the back-buffer of m_context. 439c1847b1379d12d0e05df27436bf19a9b1bf12deaTorne (Richard Coles)#if ENABLE(OILPAN) 440c1847b1379d12d0e05df27436bf19a9b1bf12deaTorne (Richard Coles) RefPtr<WebGLSharedWebGraphicsContext3D> m_sharedWebGraphicsContext3D; 441c1847b1379d12d0e05df27436bf19a9b1bf12deaTorne (Richard Coles)#else 442d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) RefPtr<DrawingBuffer> m_drawingBuffer; 443c1847b1379d12d0e05df27436bf19a9b1bf12deaTorne (Richard Coles)#endif 444c1847b1379d12d0e05df27436bf19a9b1bf12deaTorne (Richard Coles) DrawingBuffer* drawingBuffer() const; 445c1847b1379d12d0e05df27436bf19a9b1bf12deaTorne (Richard Coles) 446a9984bf9ddc3cf73fdae3f29134a2bab379e7029Ben Murdoch RefPtr<WebGLContextGroup> m_contextGroup; 447d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 4487242dc3dbeb210b5e876a3c42d1ec1a667fc621aPrimiano Tucci LostContextMode m_contextLostMode; 4497242dc3dbeb210b5e876a3c42d1ec1a667fc621aPrimiano Tucci AutoRecoveryMethod m_autoRecoveryMethod; 450d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) // Dispatches a context lost event once it is determined that one is needed. 4517242dc3dbeb210b5e876a3c42d1ec1a667fc621aPrimiano Tucci // This is used for synthetic, WEBGL_lose_context and real context losses. For real ones, it's 452d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) // likely that there's no JavaScript on the stack, but that might be dependent 453d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) // on how exactly the platform discovers that the context was lost. For better 454d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) // portability we always defer the dispatch of the event. 455d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) Timer<WebGLRenderingContextBase> m_dispatchContextLostEventTimer; 456d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) bool m_restoreAllowed; 457d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) Timer<WebGLRenderingContextBase> m_restoreTimer; 458d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 459d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) bool m_needsUpdate; 460d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) bool m_markedCanvasDirty; 461c1847b1379d12d0e05df27436bf19a9b1bf12deaTorne (Richard Coles) WillBeHeapHashSet<RawPtrWillBeWeakMember<WebGLContextObject> > m_contextObjects; 462d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 463c1847b1379d12d0e05df27436bf19a9b1bf12deaTorne (Richard Coles) OwnPtrWillBeMember<WebGLRenderingContextLostCallback> m_contextLostCallbackAdapter; 464c1847b1379d12d0e05df27436bf19a9b1bf12deaTorne (Richard Coles) OwnPtrWillBeMember<WebGLRenderingContextErrorMessageCallback> m_errorMessageCallbackAdapter; 465d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 466d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) // List of bound VBO's. Used to maintain info about sizes for ARRAY_BUFFER and stored values for ELEMENT_ARRAY_BUFFER 467c1847b1379d12d0e05df27436bf19a9b1bf12deaTorne (Richard Coles) RefPtrWillBeMember<WebGLBuffer> m_boundArrayBuffer; 468d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 469c1847b1379d12d0e05df27436bf19a9b1bf12deaTorne (Richard Coles) RefPtrWillBeMember<WebGLVertexArrayObjectOES> m_defaultVertexArrayObject; 470c1847b1379d12d0e05df27436bf19a9b1bf12deaTorne (Richard Coles) RefPtrWillBeMember<WebGLVertexArrayObjectOES> m_boundVertexArrayObject; 471c1847b1379d12d0e05df27436bf19a9b1bf12deaTorne (Richard Coles) void setBoundVertexArrayObject(PassRefPtrWillBeRawPtr<WebGLVertexArrayObjectOES> arrayObject) 472d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) { 473d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) if (arrayObject) 474d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) m_boundVertexArrayObject = arrayObject; 475d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) else 476d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) m_boundVertexArrayObject = m_defaultVertexArrayObject; 477d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) } 478d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 479d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) class VertexAttribValue { 480d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) public: 481d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) VertexAttribValue() 482d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) { 483d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) initValue(); 484d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) } 485d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 486d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) void initValue() 487d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) { 488d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) value[0] = 0.0f; 489d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) value[1] = 0.0f; 490d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) value[2] = 0.0f; 491d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) value[3] = 1.0f; 492d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) } 493d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 494d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) GLfloat value[4]; 495d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) }; 496d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) Vector<VertexAttribValue> m_vertexAttribValue; 497d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) unsigned m_maxVertexAttribs; 498c1847b1379d12d0e05df27436bf19a9b1bf12deaTorne (Richard Coles) RefPtrWillBeMember<WebGLBuffer> m_vertexAttrib0Buffer; 499d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) long m_vertexAttrib0BufferSize; 500d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) GLfloat m_vertexAttrib0BufferValue[4]; 501d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) bool m_forceAttrib0BufferRefill; 502d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) bool m_vertexAttrib0UsedBefore; 503d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 504c1847b1379d12d0e05df27436bf19a9b1bf12deaTorne (Richard Coles) RefPtrWillBeMember<WebGLProgram> m_currentProgram; 505c1847b1379d12d0e05df27436bf19a9b1bf12deaTorne (Richard Coles) RefPtrWillBeMember<WebGLFramebuffer> m_framebufferBinding; 506c1847b1379d12d0e05df27436bf19a9b1bf12deaTorne (Richard Coles) RefPtrWillBeMember<WebGLRenderbuffer> m_renderbufferBinding; 507c1847b1379d12d0e05df27436bf19a9b1bf12deaTorne (Richard Coles) 508c1847b1379d12d0e05df27436bf19a9b1bf12deaTorne (Richard Coles) WillBeHeapVector<TextureUnitState> m_textureUnits; 509d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) unsigned long m_activeTextureUnit; 510d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 511c1847b1379d12d0e05df27436bf19a9b1bf12deaTorne (Richard Coles) RefPtrWillBeMember<WebGLTexture> m_blackTexture2D; 512c1847b1379d12d0e05df27436bf19a9b1bf12deaTorne (Richard Coles) RefPtrWillBeMember<WebGLTexture> m_blackTextureCubeMap; 513d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 514d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) Vector<GLenum> m_compressedTextureFormats; 515d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 516d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) // Fixed-size cache of reusable image buffers for video texImage2D calls. 517d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) class LRUImageBufferCache { 518d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) public: 519d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) LRUImageBufferCache(int capacity); 520d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) // The pointer returned is owned by the image buffer map. 521d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) ImageBuffer* imageBuffer(const IntSize& size); 522d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) private: 523d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) void bubbleToFront(int idx); 524d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) OwnPtr<OwnPtr<ImageBuffer>[]> m_buffers; 525d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) int m_capacity; 526d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) }; 527d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) LRUImageBufferCache m_generatedImageCache; 528d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 529d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) GLint m_maxTextureSize; 530d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) GLint m_maxCubeMapTextureSize; 531d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) GLint m_maxRenderbufferSize; 532d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) GLint m_maxViewportDims[2]; 533d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) GLint m_maxTextureLevel; 534d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) GLint m_maxCubeMapTextureLevel; 535d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 536d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) GLint m_maxDrawBuffers; 537d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) GLint m_maxColorAttachments; 538d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) GLenum m_backDrawBuffer; 539d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) bool m_drawBuffersWebGLRequirementsChecked; 540d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) bool m_drawBuffersSupported; 541d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 542d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) GLint m_packAlignment; 543d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) GLint m_unpackAlignment; 544d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) bool m_unpackFlipY; 545d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) bool m_unpackPremultiplyAlpha; 546d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) GLenum m_unpackColorspaceConversion; 547c1847b1379d12d0e05df27436bf19a9b1bf12deaTorne (Richard Coles) RefPtrWillBeMember<WebGLContextAttributes> m_requestedAttributes; 548d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 549d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) bool m_layerCleared; 550d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) GLfloat m_clearColor[4]; 551d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) bool m_scissorEnabled; 552d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) GLfloat m_clearDepth; 553d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) GLint m_clearStencil; 554d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) GLboolean m_colorMask[4]; 555d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) GLboolean m_depthMask; 556d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 557d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) bool m_stencilEnabled; 558d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) GLuint m_stencilMask, m_stencilMaskBack; 559d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) GLint m_stencilFuncRef, m_stencilFuncRefBack; // Note that these are the user specified values, not the internal clamped value. 560d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) GLuint m_stencilFuncMask, m_stencilFuncMaskBack; 561d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 562d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) bool m_isGLES2NPOTStrict; 563d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) bool m_isDepthStencilSupported; 564d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 565d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) bool m_synthesizedErrorsToConsole; 566d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) int m_numGLErrorsToConsoleAllowed; 567d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 568d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) bool m_multisamplingAllowed; 569d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) bool m_multisamplingObserverRegistered; 570d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 571d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) unsigned long m_onePlusMaxNonDefaultTextureUnit; 572d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 573d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) OwnPtr<Extensions3DUtil> m_extensionsUtil; 574d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 5755d92fedcae5e801a8b224de090094f2d9df0b54aTorne (Richard Coles) bool m_savingImage; 5765d92fedcae5e801a8b224de090094f2d9df0b54aTorne (Richard Coles) 577d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) enum ExtensionFlags { 57807a852d8c1953036774d8f3b65d18dcfea3bb4a2Ben Murdoch ApprovedExtension = 0x00, 57907a852d8c1953036774d8f3b65d18dcfea3bb4a2Ben Murdoch // Extension that is behind the draft extensions runtime flag: 58007a852d8c1953036774d8f3b65d18dcfea3bb4a2Ben Murdoch DraftExtension = 0x01, 581d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) }; 582d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 583c1847b1379d12d0e05df27436bf19a9b1bf12deaTorne (Richard Coles) class ExtensionTracker : public NoBaseWillBeGarbageCollected<ExtensionTracker> { 584d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) public: 585d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) ExtensionTracker(ExtensionFlags flags, const char* const* prefixes) 586d6cdb82654e8f3343a693ca752d5c4cee0324e17Torne (Richard Coles) : m_draft(flags & DraftExtension) 587d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) , m_prefixes(prefixes) 588d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) { 589d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) } 590d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 591c1847b1379d12d0e05df27436bf19a9b1bf12deaTorne (Richard Coles)#if !ENABLE(OILPAN) 592d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) virtual ~ExtensionTracker() 593d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) { 594d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) } 595c1847b1379d12d0e05df27436bf19a9b1bf12deaTorne (Richard Coles)#endif 596d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 597d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) bool draft() const 598d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) { 599d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) return m_draft; 600d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) } 601d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 60207a852d8c1953036774d8f3b65d18dcfea3bb4a2Ben Murdoch const char* const* prefixes() const; 603d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) bool matchesNameWithPrefixes(const String&) const; 604d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 605c1847b1379d12d0e05df27436bf19a9b1bf12deaTorne (Richard Coles) virtual PassRefPtrWillBeRawPtr<WebGLExtension> getExtension(WebGLRenderingContextBase*) = 0; 606d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) virtual bool supported(WebGLRenderingContextBase*) const = 0; 607d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) virtual const char* extensionName() const = 0; 608d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) virtual void loseExtension() = 0; 609d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 610c1847b1379d12d0e05df27436bf19a9b1bf12deaTorne (Richard Coles) virtual void trace(Visitor*) { } 611c1847b1379d12d0e05df27436bf19a9b1bf12deaTorne (Richard Coles) 612d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) private: 613d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) bool m_draft; 614d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) const char* const* m_prefixes; 615d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) }; 616d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 617d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) template <typename T> 618d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) class TypedExtensionTracker FINAL : public ExtensionTracker { 619d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) public: 620c1847b1379d12d0e05df27436bf19a9b1bf12deaTorne (Richard Coles) static PassOwnPtrWillBeRawPtr<TypedExtensionTracker<T> > create(RefPtrWillBeMember<T>& extensionField, ExtensionFlags flags, const char* const* prefixes) 621d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) { 622c1847b1379d12d0e05df27436bf19a9b1bf12deaTorne (Richard Coles) return adoptPtrWillBeNoop(new TypedExtensionTracker<T>(extensionField, flags, prefixes)); 623d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) } 624d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 625c1847b1379d12d0e05df27436bf19a9b1bf12deaTorne (Richard Coles)#if !ENABLE(OILPAN) 626d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) virtual ~TypedExtensionTracker() 627d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) { 628d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) if (m_extension) { 629d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) m_extension->lose(true); 630d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) m_extension = nullptr; 631d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) } 632d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) } 633c1847b1379d12d0e05df27436bf19a9b1bf12deaTorne (Richard Coles)#endif 634d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 635c1847b1379d12d0e05df27436bf19a9b1bf12deaTorne (Richard Coles) virtual PassRefPtrWillBeRawPtr<WebGLExtension> getExtension(WebGLRenderingContextBase* context) OVERRIDE 636d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) { 637d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) if (!m_extension) { 638d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) m_extension = T::create(context); 639d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) m_extensionField = m_extension; 640d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) } 641d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 642d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) return m_extension; 643d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) } 644d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 645d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) virtual bool supported(WebGLRenderingContextBase* context) const OVERRIDE 646d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) { 647d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) return T::supported(context); 648d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) } 649d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 650d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) virtual const char* extensionName() const OVERRIDE 651d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) { 652d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) return T::extensionName(); 653d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) } 654d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 655d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) virtual void loseExtension() OVERRIDE 656d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) { 657d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) if (m_extension) { 658d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) m_extension->lose(false); 659d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) if (m_extension->isLost()) 660d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) m_extension = nullptr; 661d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) } 662d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) } 663d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 664c1847b1379d12d0e05df27436bf19a9b1bf12deaTorne (Richard Coles) virtual void trace(Visitor* visitor) OVERRIDE 665c1847b1379d12d0e05df27436bf19a9b1bf12deaTorne (Richard Coles) { 666c1847b1379d12d0e05df27436bf19a9b1bf12deaTorne (Richard Coles) visitor->trace(m_extension); 667c1847b1379d12d0e05df27436bf19a9b1bf12deaTorne (Richard Coles) ExtensionTracker::trace(visitor); 668c1847b1379d12d0e05df27436bf19a9b1bf12deaTorne (Richard Coles) } 669c1847b1379d12d0e05df27436bf19a9b1bf12deaTorne (Richard Coles) 670d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) private: 671c1847b1379d12d0e05df27436bf19a9b1bf12deaTorne (Richard Coles) TypedExtensionTracker(RefPtrWillBeMember<T>& extensionField, ExtensionFlags flags, const char* const* prefixes) 672c1847b1379d12d0e05df27436bf19a9b1bf12deaTorne (Richard Coles) : ExtensionTracker(flags, prefixes) 673c1847b1379d12d0e05df27436bf19a9b1bf12deaTorne (Richard Coles) , m_extensionField(extensionField) 674c1847b1379d12d0e05df27436bf19a9b1bf12deaTorne (Richard Coles) { 675c1847b1379d12d0e05df27436bf19a9b1bf12deaTorne (Richard Coles) } 676c1847b1379d12d0e05df27436bf19a9b1bf12deaTorne (Richard Coles) 677c1847b1379d12d0e05df27436bf19a9b1bf12deaTorne (Richard Coles) RefPtrWillBeMember<T>& m_extensionField; 678d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) // ExtensionTracker holds it's own reference to the extension to ensure 679d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) // that it is not deleted before this object's destructor is called 680c1847b1379d12d0e05df27436bf19a9b1bf12deaTorne (Richard Coles) RefPtrWillBeMember<T> m_extension; 681d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) }; 682d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 683d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) bool m_extensionEnabled[WebGLExtensionNameCount]; 684c1847b1379d12d0e05df27436bf19a9b1bf12deaTorne (Richard Coles) WillBeHeapVector<OwnPtrWillBeMember<ExtensionTracker> > m_extensions; 685d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 686d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) template <typename T> 687c1847b1379d12d0e05df27436bf19a9b1bf12deaTorne (Richard Coles) void registerExtension(RefPtrWillBeMember<T>& extensionPtr, ExtensionFlags flags = ApprovedExtension, const char* const* prefixes = 0) 688d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) { 689c1847b1379d12d0e05df27436bf19a9b1bf12deaTorne (Richard Coles) m_extensions.append(TypedExtensionTracker<T>::create(extensionPtr, flags, prefixes)); 690d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) } 691d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 69207a852d8c1953036774d8f3b65d18dcfea3bb4a2Ben Murdoch bool extensionSupportedAndAllowed(const ExtensionTracker*); 69307a852d8c1953036774d8f3b65d18dcfea3bb4a2Ben Murdoch 694d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) inline bool extensionEnabled(WebGLExtensionName name) 695d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) { 696d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) return m_extensionEnabled[name]; 697d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) } 698d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 699d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) // Errors raised by synthesizeGLError() while the context is lost. 700d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) Vector<GLenum> m_lostContextErrors; 701d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 702d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) // Helpers for getParameter and others 703d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) WebGLGetInfo getBooleanParameter(GLenum); 704d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) WebGLGetInfo getBooleanArrayParameter(GLenum); 705d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) WebGLGetInfo getFloatParameter(GLenum); 706d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) WebGLGetInfo getIntParameter(GLenum); 707d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) WebGLGetInfo getUnsignedIntParameter(GLenum); 708d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) WebGLGetInfo getWebGLFloatArrayParameter(GLenum); 709d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) WebGLGetInfo getWebGLIntArrayParameter(GLenum); 710d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 711d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) // Clear the backbuffer if it was composited since the last operation. 712d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) // clearMask is set to the bitfield of any clear that would happen anyway at this time 713d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) // and the function returns true if that clear is now unnecessary. 714d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) bool clearIfComposited(GLbitfield clearMask = 0); 715d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 716d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) // Helper to restore state that clearing the framebuffer may destroy. 717d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) void restoreStateAfterClear(); 718d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 719d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) // Convert texture internal format. 720d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) GLenum convertTexInternalFormat(GLenum internalformat, GLenum type); 721d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 722d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) void texImage2DBase(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void* pixels, ExceptionState&); 723d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) void texImage2DImpl(GLenum target, GLint level, GLenum internalformat, GLenum format, GLenum type, Image*, WebGLImageConversion::ImageHtmlDomSource, bool flipY, bool premultiplyAlpha, ExceptionState&); 724d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) void texSubImage2DBase(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void* pixels, ExceptionState&); 725d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) void texSubImage2DImpl(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLenum format, GLenum type, Image*, WebGLImageConversion::ImageHtmlDomSource, bool flipY, bool premultiplyAlpha, ExceptionState&); 726d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 727d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) void handleTextureCompleteness(const char*, bool); 728d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) void createFallbackBlackTextures1x1(); 729d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 730d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) // Helper function for copyTex{Sub}Image, check whether the internalformat 731d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) // and the color buffer format of the current bound framebuffer combination 732d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) // is valid. 733d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) bool isTexInternalFormatColorBufferCombinationValid(GLenum texInternalFormat, GLenum colorBufferFormat); 734d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 735d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) // Helper function to get the bound framebuffer's color buffer format. 736d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) GLenum boundFramebufferColorFormat(); 737d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 738d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) // Helper function to verify limits on the length of uniform and attribute locations. 739d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) bool validateLocationLength(const char* functionName, const String&); 740d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 741d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) // Helper function to check if size is non-negative. 742d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) // Generate GL error and return false for negative inputs; otherwise, return true. 743d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) bool validateSize(const char* functionName, GLint x, GLint y); 744d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 745d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) // Helper function to check if all characters in the string belong to the 746d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) // ASCII subset as defined in GLSL ES 1.0 spec section 3.1. 747d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) bool validateString(const char* functionName, const String&); 748d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 749d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) // Helper function to check target and texture bound to the target. 750d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) // Generate GL errors and return 0 if target is invalid or texture bound is 751d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) // null. Otherwise, return the texture bound to the target. 752d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) WebGLTexture* validateTextureBinding(const char* functionName, GLenum target, bool useSixEnumsForCubeMap); 753d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 754d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) // Helper function to check input format/type for functions {copy}Tex{Sub}Image. 755d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) // Generates GL error and returns false if parameters are invalid. 756d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) bool validateTexFuncFormatAndType(const char* functionName, GLenum format, GLenum type, GLint level); 757d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 758d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) // Helper function to check input level for functions {copy}Tex{Sub}Image. 759d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) // Generates GL error and returns false if level is invalid. 760d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) bool validateTexFuncLevel(const char* functionName, GLenum target, GLint level); 761d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 762f91f5fa1608c2cdd9af1842fb5dadbe78275be2aBo Liu // Helper function to check if a 64-bit value is non-negative and can fit into a 32-bit integer. 763f91f5fa1608c2cdd9af1842fb5dadbe78275be2aBo Liu // Generates GL error and returns false if not. 764f91f5fa1608c2cdd9af1842fb5dadbe78275be2aBo Liu bool validateValueFitNonNegInt32(const char* functionName, const char* paramName, long long value); 765f91f5fa1608c2cdd9af1842fb5dadbe78275be2aBo Liu 766d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) enum TexFuncValidationFunctionType { 767d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) NotTexSubImage2D, 768d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) TexSubImage2D, 769d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) }; 770d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 771d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) enum TexFuncValidationSourceType { 772d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) SourceArrayBufferView, 773d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) SourceImageData, 774d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) SourceHTMLImageElement, 775d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) SourceHTMLCanvasElement, 776d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) SourceHTMLVideoElement, 777d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) }; 778d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 779d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) // Helper function for tex{Sub}Image2D to check if the input format/type/level/target/width/height/border/xoffset/yoffset are valid. 780d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) // Otherwise, it would return quickly without doing other work. 781d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) bool validateTexFunc(const char* functionName, TexFuncValidationFunctionType, TexFuncValidationSourceType, GLenum target, GLint level, GLenum internalformat, GLsizei width, 782d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) GLsizei height, GLint border, GLenum format, GLenum type, GLint xoffset, GLint yoffset); 783d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 784d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) // Helper function to check input width and height for functions {copy, compressed}Tex{Sub}Image. 785d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) // Generates GL error and returns false if width or height is invalid. 786d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) bool validateTexFuncDimensions(const char* functionName, TexFuncValidationFunctionType, GLenum target, GLint level, GLsizei width, GLsizei height); 787d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 788d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) // Helper function to check input parameters for functions {copy}Tex{Sub}Image. 789d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) // Generates GL error and returns false if parameters are invalid. 790d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) bool validateTexFuncParameters(const char* functionName, TexFuncValidationFunctionType, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type); 791d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 792d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) enum NullDisposition { 793d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) NullAllowed, 794d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) NullNotAllowed 795d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) }; 796d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 797d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) // Helper function to validate that the given ArrayBufferView 798d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) // is of the correct type and contains enough data for the texImage call. 799d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) // Generates GL error and returns false if parameters are invalid. 800d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) bool validateTexFuncData(const char* functionName, GLint level, GLsizei width, GLsizei height, GLenum format, GLenum type, ArrayBufferView* pixels, NullDisposition); 801d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 802d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) // Helper function to validate a given texture format is settable as in 803d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) // you can supply data to texImage2D, or call texImage2D, copyTexImage2D and 804d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) // copyTexSubImage2D. 805d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) // Generates GL error and returns false if the format is not settable. 806d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) bool validateSettableTexFormat(const char* functionName, GLenum format); 807d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 808d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) // Helper function to validate compressed texture data is correct size 809d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) // for the given format and dimensions. 810d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) bool validateCompressedTexFuncData(const char* functionName, GLsizei width, GLsizei height, GLenum format, ArrayBufferView* pixels); 811d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 812d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) // Helper function for validating compressed texture formats. 813d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) bool validateCompressedTexFormat(GLenum format); 814d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 815d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) // Helper function to validate compressed texture dimensions are valid for 816d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) // the given format. 817d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) bool validateCompressedTexDimensions(const char* functionName, TexFuncValidationFunctionType, GLenum target, GLint level, GLsizei width, GLsizei height, GLenum format); 818d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 819d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) // Helper function to validate compressed texture dimensions are valid for 820d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) // the given format. 821d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) bool validateCompressedTexSubDimensions(const char* functionName, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, WebGLTexture*); 822d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 823d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) // Helper function to validate mode for draw{Arrays/Elements}. 824d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) bool validateDrawMode(const char* functionName, GLenum); 825d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 826d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) // Helper function to validate if front/back stencilMask and stencilFunc settings are the same. 827d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) bool validateStencilSettings(const char* functionName); 828d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 829d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) // Helper function to validate stencil or depth func. 830d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) bool validateStencilOrDepthFunc(const char* functionName, GLenum); 831d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 832d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) // Helper function for texParameterf and texParameteri. 833d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) void texParameter(GLenum target, GLenum pname, GLfloat parami, GLint paramf, bool isFloat); 834d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 835d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) // Helper function to print GL errors to console. 836d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) void printGLErrorToConsole(const String&); 837d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 838d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) // Helper function to print warnings to console. Currently 839d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) // used only to warn about use of obsolete functions. 840d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) void printWarningToConsole(const String&); 841d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 842d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) // Helper function to validate input parameters for framebuffer functions. 843d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) // Generate GL error if parameters are illegal. 844d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) bool validateFramebufferFuncParameters(const char* functionName, GLenum target, GLenum attachment); 845d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 846d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) // Helper function to validate blend equation mode. 847d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) bool validateBlendEquation(const char* functionName, GLenum); 848d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 849d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) // Helper function to validate blend func factors. 850d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) bool validateBlendFuncFactors(const char* functionName, GLenum src, GLenum dst); 851d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 852d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) // Helper function to validate a GL capability. 853d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) bool validateCapability(const char* functionName, GLenum); 854d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 855d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) // Helper function to validate input parameters for uniform functions. 856d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) bool validateUniformParameters(const char* functionName, const WebGLUniformLocation*, Float32Array*, GLsizei mod); 857d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) bool validateUniformParameters(const char* functionName, const WebGLUniformLocation*, Int32Array*, GLsizei mod); 858d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) bool validateUniformParameters(const char* functionName, const WebGLUniformLocation*, void*, GLsizei, GLsizei mod); 859d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) bool validateUniformMatrixParameters(const char* functionName, const WebGLUniformLocation*, GLboolean transpose, Float32Array*, GLsizei mod); 860d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) bool validateUniformMatrixParameters(const char* functionName, const WebGLUniformLocation*, GLboolean transpose, void*, GLsizei, GLsizei mod); 861d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 862f91f5fa1608c2cdd9af1842fb5dadbe78275be2aBo Liu // Helper function to validate the target for bufferData. 863f91f5fa1608c2cdd9af1842fb5dadbe78275be2aBo Liu // Return the current bound buffer to target, or 0 if the target is invalid. 864f91f5fa1608c2cdd9af1842fb5dadbe78275be2aBo Liu WebGLBuffer* validateBufferDataTarget(const char* functionName, GLenum target); 865d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 866d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) // Helper function for tex{Sub}Image2D to make sure image is ready and wouldn't taint Origin. 867d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) bool validateHTMLImageElement(const char* functionName, HTMLImageElement*, ExceptionState&); 868d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 869d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) // Helper function for tex{Sub}Image2D to make sure canvas is ready and wouldn't taint Origin. 870d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) bool validateHTMLCanvasElement(const char* functionName, HTMLCanvasElement*, ExceptionState&); 871d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 872d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) // Helper function for tex{Sub}Image2D to make sure video is ready wouldn't taint Origin. 873d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) bool validateHTMLVideoElement(const char* functionName, HTMLVideoElement*, ExceptionState&); 874d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 875d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) // Helper function to validate drawArrays(Instanced) calls 876d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) bool validateDrawArrays(const char* functionName, GLenum mode, GLint first, GLsizei count); 877d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 878d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) // Helper function to validate drawElements(Instanced) calls 879d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) bool validateDrawElements(const char* functionName, GLenum mode, GLsizei count, GLenum type, long long offset); 880d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 881d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) // Helper function to validate draw*Instanced calls 882d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) bool validateDrawInstanced(const char* functionName, GLsizei primcount); 883d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 884d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) // Helper functions for vertexAttribNf{v}. 885d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) void vertexAttribfImpl(const char* functionName, GLuint index, GLsizei expectedSize, GLfloat, GLfloat, GLfloat, GLfloat); 886d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) void vertexAttribfvImpl(const char* functionName, GLuint index, Float32Array*, GLsizei expectedSize); 887d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) void vertexAttribfvImpl(const char* functionName, GLuint index, GLfloat*, GLsizei, GLsizei expectedSize); 888d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 889f91f5fa1608c2cdd9af1842fb5dadbe78275be2aBo Liu // Helper functions to bufferData() and bufferSubData(). 890f91f5fa1608c2cdd9af1842fb5dadbe78275be2aBo Liu void bufferDataImpl(GLenum target, long long size, const void* data, GLenum usage); 891f91f5fa1608c2cdd9af1842fb5dadbe78275be2aBo Liu void bufferSubDataImpl(GLenum target, long long offset, GLsizeiptr size, const void* data); 892f91f5fa1608c2cdd9af1842fb5dadbe78275be2aBo Liu 893d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) // Helper function for delete* (deleteBuffer, deleteProgram, etc) functions. 894d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) // Return false if caller should return without further processing. 895d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) bool deleteObject(WebGLObject*); 896d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 897d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) // Helper function for bind* (bindBuffer, bindTexture, etc) and useProgram. 898d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) // If the object has already been deleted, set deleted to true upon return. 899d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) // Return false if caller should return without further processing. 900d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) bool checkObjectToBeBound(const char* functionName, WebGLObject*, bool& deleted); 901d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 902d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) void dispatchContextLostEvent(Timer<WebGLRenderingContextBase>*); 903d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) // Helper for restoration after context lost. 904d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) void maybeRestoreContext(Timer<WebGLRenderingContextBase>*); 905d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 906d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) enum ConsoleDisplayPreference { 907d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) DisplayInConsole, 908d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) DontDisplayInConsole 909d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) }; 910d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 911d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) // Wrapper for WebGraphicsContext3D::synthesizeGLError that sends a message 912d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) // to the JavaScript console. 913d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) void synthesizeGLError(GLenum, const char* functionName, const char* description, ConsoleDisplayPreference = DisplayInConsole); 914d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) void emitGLWarning(const char* function, const char* reason); 915d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 916d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) String ensureNotNull(const String&) const; 917d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 918d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) // Enable or disable stencil test based on user setting and 919d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) // whether the current FBO has a stencil buffer. 920d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) void applyStencilTest(); 921d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 922d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) // Helper for enabling or disabling a capability. 923d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) void enableOrDisable(GLenum capability, bool enable); 924d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 925d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) // Clamp the width and height to GL_MAX_VIEWPORT_DIMS. 926d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) IntSize clampedCanvasSize(); 927d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 928d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) // First time called, if EXT_draw_buffers is supported, query the value; otherwise return 0. 929d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) // Later, return the cached value. 930d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) GLint maxDrawBuffers(); 931d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) GLint maxColorAttachments(); 932d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 933d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) void setBackDrawBuffer(GLenum); 934d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 935d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) void restoreCurrentFramebuffer(); 936d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) void restoreCurrentTexture2D(); 937d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 938d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) virtual void multisamplingChanged(bool) OVERRIDE; 939d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 940d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) void findNewMaxNonDefaultTextureUnit(); 941d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 942d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) friend class WebGLStateRestorer; 943d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) friend class WebGLRenderingContextEvictionManager; 944d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 945d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) static Vector<WebGLRenderingContextBase*>& activeContexts(); 946d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) static Vector<WebGLRenderingContextBase*>& forciblyEvictedContexts(); 947d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 948d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) static void activateContext(WebGLRenderingContextBase*); 9497242dc3dbeb210b5e876a3c42d1ec1a667fc621aPrimiano Tucci static void deactivateContext(WebGLRenderingContextBase*); 9507242dc3dbeb210b5e876a3c42d1ec1a667fc621aPrimiano Tucci static void addToEvictedList(WebGLRenderingContextBase*); 9517242dc3dbeb210b5e876a3c42d1ec1a667fc621aPrimiano Tucci static void removeFromEvictedList(WebGLRenderingContextBase*); 952d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) static void willDestroyContext(WebGLRenderingContextBase*); 953d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) static void forciblyLoseOldestContext(const String& reason); 954d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) // Return the least recently used context's position in the active context vector. 955d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) // If the vector is empty, return the maximum allowed active context number. 956d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) static size_t oldestContextIndex(); 957d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) static IntSize oldestContextSize(); 958d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles)}; 959d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 960d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles)DEFINE_TYPE_CASTS(WebGLRenderingContextBase, CanvasRenderingContext, context, context->is3d(), context.is3d()); 961d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 962c1847b1379d12d0e05df27436bf19a9b1bf12deaTorne (Richard Coles)} // namespace blink 963c1847b1379d12d0e05df27436bf19a9b1bf12deaTorne (Richard Coles) 964c1847b1379d12d0e05df27436bf19a9b1bf12deaTorne (Richard Coles)WTF_ALLOW_MOVE_INIT_AND_COMPARE_WITH_MEM_FUNCTIONS(blink::WebGLRenderingContextBase::TextureUnitState); 965d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 966d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles)#endif // WebGLRenderingContextBase_h 967