2 * Copyright (C) 2012 Google Inc. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above
11 * copyright notice, this list of conditions and the following disclaimer
12 * in the documentation and/or other materials provided with the
14 * * Neither the name of Google Inc. nor the names of its
15 * contributors may be used to endorse or promote products derived from
16 * this software without specific prior written permission.
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 #ifndef WebGraphicsContext3D_h
32 #define WebGraphicsContext3D_h
34 #include "WebCommon.h"
35 #include "WebNonCopyable.h"
36 #include "WebString.h"
42 // WGC3D types match the corresponding GL types as defined in OpenGL ES 2.0
43 // header file gl2.h from khronos.org.
44 typedef char WGC3Dchar
;
45 typedef unsigned WGC3Denum
;
46 typedef unsigned char WGC3Dboolean
;
47 typedef unsigned WGC3Dbitfield
;
48 typedef signed char WGC3Dbyte
;
49 typedef unsigned char WGC3Dubyte
;
50 typedef short WGC3Dshort
;
51 typedef unsigned short WGC3Dushort
;
53 typedef int WGC3Dsizei
;
54 typedef unsigned WGC3Duint
;
55 typedef float WGC3Dfloat
;
56 typedef float WGC3Dclampf
;
57 typedef signed long int WGC3Dintptr
;
58 typedef signed long int WGC3Dsizeiptr
;
59 typedef int64_t WGC3Dint64
;
60 typedef uint64_t WGC3Duint64
;
61 typedef struct __WGC3Dsync
*WGC3Dsync
;
63 // Typedef for server-side objects like OpenGL textures and program objects.
64 typedef WGC3Duint WebGLId
;
70 WebString rendererInfo
;
71 WebString driverVersion
;
72 WebString contextInfoCollectionFailure
;
75 // This interface abstracts the operations performed by the
76 // GraphicsContext3D in order to implement WebGL. Nearly all of the
77 // methods exposed on this interface map directly to entry points in
78 // the OpenGL ES 2.0 API.
79 class WebGraphicsContext3D
: public WebNonCopyable
{
81 // Return value from getActiveUniform and getActiveAttrib.
88 // Context creation attributes.
95 , premultipliedAlpha(true)
96 , canRecoverFromContextLoss(true)
98 , shareResources(true)
99 , preferDiscreteGPU(false)
100 , noAutomaticFlushes(false)
101 , failIfMajorPerformanceCaveat(false)
111 bool premultipliedAlpha
;
112 bool canRecoverFromContextLoss
;
115 bool preferDiscreteGPU
;
116 bool noAutomaticFlushes
;
117 bool failIfMajorPerformanceCaveat
;
119 unsigned webGLVersion
;
120 // FIXME: ideally this would be a WebURL, but it is currently not
121 // possible to pass a WebURL by value across the WebKit API boundary.
122 // See https://bugs.webkit.org/show_bug.cgi?id=103793#c13 .
123 WebString topDocumentURL
;
126 class WebGraphicsContextLostCallback
{
128 virtual void onContextLost() = 0;
131 virtual ~WebGraphicsContextLostCallback() { }
134 class WebGraphicsErrorMessageCallback
{
136 virtual void onErrorMessage(const WebString
&, WGC3Dint
) = 0;
139 virtual ~WebGraphicsErrorMessageCallback() { }
142 // This destructor needs to be public so that using classes can destroy instances if initialization fails.
143 virtual ~WebGraphicsContext3D() { }
145 // Each flush or finish is assigned an unique ID. The larger
146 // the ID number, the more recently the context has been flushed.
147 virtual uint32_t lastFlushID() { return 0; }
149 // Resizes the region into which this WebGraphicsContext3D is drawing.
150 virtual void reshapeWithScaleFactor(int width
, int height
, float scaleFactor
) { }
152 // GL_CHROMIUM_setVisibility - Changes the visibility of the backbuffer
153 virtual void setVisibilityCHROMIUM(bool visible
) = 0;
155 // GL_EXT_discard_framebuffer - makes specified attachments of currently bound framebuffer undefined.
156 virtual void discardFramebufferEXT(WGC3Denum target
, WGC3Dsizei numAttachments
, const WGC3Denum
* attachments
) { }
158 // GL_CHROMIUM_discard_backbuffer - controls allocation/deallocation of the back buffer.
159 virtual void discardBackbufferCHROMIUM() { }
160 virtual void ensureBackbufferCHROMIUM() { }
162 virtual unsigned insertSyncPoint() { return 0; }
163 virtual void waitSyncPoint(unsigned) { }
165 // Copies the contents of the off-screen render target used by the WebGL
166 // context to the corresponding texture used by the compositor.
167 virtual void prepareTexture() = 0;
169 // GL_CHROMIUM_post_sub_buffer - Copies part of the back buffer to the front buffer.
170 virtual void postSubBufferCHROMIUM(int x
, int y
, int width
, int height
) = 0;
172 // Synthesizes an OpenGL error which will be returned from a
173 // later call to getError. This is used to emulate OpenGL ES
174 // 2.0 behavior on the desktop and to enforce additional error
175 // checking mandated by WebGL.
177 // Per the behavior of glGetError, this stores at most one
178 // instance of any given error, and returns them from calls to
179 // getError in the order they were added.
180 virtual void synthesizeGLError(WGC3Denum
) = 0;
182 virtual bool isContextLost() = 0;
184 // GL_CHROMIUM_map_sub
185 virtual void* mapBufferSubDataCHROMIUM(WGC3Denum target
, WGC3Dintptr offset
, WGC3Dsizeiptr size
, WGC3Denum access
) = 0;
186 virtual void unmapBufferSubDataCHROMIUM(const void*) = 0;
187 virtual void* mapTexSubImage2DCHROMIUM(WGC3Denum target
, WGC3Dint level
, WGC3Dint xoffset
, WGC3Dint yoffset
, WGC3Dsizei width
, WGC3Dsizei height
, WGC3Denum format
, WGC3Denum type
, WGC3Denum access
) = 0;
188 virtual void unmapTexSubImage2DCHROMIUM(const void*) = 0;
190 // GL_CHROMIUM_request_extension
191 virtual WebString
getRequestableExtensionsCHROMIUM() = 0;
192 virtual void requestExtensionCHROMIUM(const char*) = 0;
194 // GL_CHROMIUM_framebuffer_multisample
195 virtual void blitFramebufferCHROMIUM(WGC3Dint srcX0
, WGC3Dint srcY0
, WGC3Dint srcX1
, WGC3Dint srcY1
, WGC3Dint dstX0
, WGC3Dint dstY0
, WGC3Dint dstX1
, WGC3Dint dstY1
, WGC3Dbitfield mask
, WGC3Denum filter
) = 0;
196 virtual void renderbufferStorageMultisampleCHROMIUM(WGC3Denum target
, WGC3Dsizei samples
, WGC3Denum internalformat
, WGC3Dsizei width
, WGC3Dsizei height
) = 0;
198 // GL_CHROMIUM_lose_context
199 virtual void loseContextCHROMIUM(WGC3Denum current
, WGC3Denum other
) { }
201 // The entry points below map directly to the OpenGL ES 2.0 API.
202 // See: http://www.khronos.org/registry/gles/
203 // and: http://www.khronos.org/opengles/sdk/docs/man/
204 virtual void activeTexture(WGC3Denum texture
) = 0;
205 virtual void attachShader(WebGLId program
, WebGLId shader
) = 0;
206 virtual void bindAttribLocation(WebGLId program
, WGC3Duint index
, const WGC3Dchar
* name
) = 0;
207 virtual void bindBuffer(WGC3Denum target
, WebGLId buffer
) = 0;
208 virtual void bindFramebuffer(WGC3Denum target
, WebGLId framebuffer
) = 0;
209 virtual void bindRenderbuffer(WGC3Denum target
, WebGLId renderbuffer
) = 0;
210 virtual void bindTexture(WGC3Denum target
, WebGLId texture
) = 0;
211 virtual void blendColor(WGC3Dclampf red
, WGC3Dclampf green
, WGC3Dclampf blue
, WGC3Dclampf alpha
) = 0;
212 virtual void blendEquation(WGC3Denum mode
) = 0;
213 virtual void blendEquationSeparate(WGC3Denum modeRGB
, WGC3Denum modeAlpha
) = 0;
214 virtual void blendFunc(WGC3Denum sfactor
, WGC3Denum dfactor
) = 0;
215 virtual void blendFuncSeparate(WGC3Denum srcRGB
, WGC3Denum dstRGB
, WGC3Denum srcAlpha
, WGC3Denum dstAlpha
) = 0;
217 virtual void bufferData(WGC3Denum target
, WGC3Dsizeiptr size
, const void* data
, WGC3Denum usage
) = 0;
218 virtual void bufferSubData(WGC3Denum target
, WGC3Dintptr offset
, WGC3Dsizeiptr size
, const void* data
) = 0;
220 virtual WGC3Denum
checkFramebufferStatus(WGC3Denum target
) = 0;
221 virtual void clear(WGC3Dbitfield mask
) = 0;
222 virtual void clearColor(WGC3Dclampf red
, WGC3Dclampf green
, WGC3Dclampf blue
, WGC3Dclampf alpha
) = 0;
223 virtual void clearDepth(WGC3Dclampf depth
) = 0;
224 virtual void clearStencil(WGC3Dint s
) = 0;
225 virtual void colorMask(WGC3Dboolean red
, WGC3Dboolean green
, WGC3Dboolean blue
, WGC3Dboolean alpha
) = 0;
226 virtual void compileShader(WebGLId shader
) = 0;
228 virtual void compressedTexImage2D(WGC3Denum target
, WGC3Dint level
, WGC3Denum internalformat
, WGC3Dsizei width
, WGC3Dsizei height
, WGC3Dint border
, WGC3Dsizei imageSize
, const void* data
) = 0;
229 virtual void compressedTexSubImage2D(WGC3Denum target
, WGC3Dint level
, WGC3Dint xoffset
, WGC3Dint yoffset
, WGC3Dsizei width
, WGC3Dsizei height
, WGC3Denum format
, WGC3Dsizei imageSize
, const void* data
) = 0;
230 virtual void copyTexImage2D(WGC3Denum target
, WGC3Dint level
, WGC3Denum internalformat
, WGC3Dint x
, WGC3Dint y
, WGC3Dsizei width
, WGC3Dsizei height
, WGC3Dint border
) = 0;
231 virtual void copyTexSubImage2D(WGC3Denum target
, WGC3Dint level
, WGC3Dint xoffset
, WGC3Dint yoffset
, WGC3Dint x
, WGC3Dint y
, WGC3Dsizei width
, WGC3Dsizei height
) = 0;
232 virtual void cullFace(WGC3Denum mode
) = 0;
233 virtual void depthFunc(WGC3Denum func
) = 0;
234 virtual void depthMask(WGC3Dboolean flag
) = 0;
235 virtual void depthRange(WGC3Dclampf zNear
, WGC3Dclampf zFar
) = 0;
236 virtual void detachShader(WebGLId program
, WebGLId shader
) = 0;
237 virtual void disable(WGC3Denum cap
) = 0;
238 virtual void disableVertexAttribArray(WGC3Duint index
) = 0;
239 virtual void drawArrays(WGC3Denum mode
, WGC3Dint first
, WGC3Dsizei count
) = 0;
240 virtual void drawElements(WGC3Denum mode
, WGC3Dsizei count
, WGC3Denum type
, WGC3Dintptr offset
) = 0;
242 virtual void enable(WGC3Denum cap
) = 0;
243 virtual void enableVertexAttribArray(WGC3Duint index
) = 0;
244 virtual void finish() = 0;
245 virtual void flush() = 0;
246 virtual void framebufferRenderbuffer(WGC3Denum target
, WGC3Denum attachment
, WGC3Denum renderbuffertarget
, WebGLId renderbuffer
) = 0;
247 virtual void framebufferTexture2D(WGC3Denum target
, WGC3Denum attachment
, WGC3Denum textarget
, WebGLId texture
, WGC3Dint level
) = 0;
248 virtual void frontFace(WGC3Denum mode
) = 0;
249 virtual void generateMipmap(WGC3Denum target
) = 0;
251 virtual bool getActiveAttrib(WebGLId program
, WGC3Duint index
, ActiveInfo
&) = 0;
252 virtual bool getActiveUniform(WebGLId program
, WGC3Duint index
, ActiveInfo
&) = 0;
253 virtual void getAttachedShaders(WebGLId program
, WGC3Dsizei maxCount
, WGC3Dsizei
* count
, WebGLId
* shaders
) = 0;
254 virtual WGC3Dint
getAttribLocation(WebGLId program
, const WGC3Dchar
* name
) = 0;
255 virtual void getBooleanv(WGC3Denum pname
, WGC3Dboolean
* value
) = 0;
256 virtual void getBufferParameteriv(WGC3Denum target
, WGC3Denum pname
, WGC3Dint
* value
) = 0;
257 virtual WGC3Denum
getError() = 0;
258 virtual void getFloatv(WGC3Denum pname
, WGC3Dfloat
* value
) = 0;
259 virtual void getFramebufferAttachmentParameteriv(WGC3Denum target
, WGC3Denum attachment
, WGC3Denum pname
, WGC3Dint
* value
) = 0;
260 virtual void getIntegerv(WGC3Denum pname
, WGC3Dint
* value
) = 0;
261 virtual void getProgramiv(WebGLId program
, WGC3Denum pname
, WGC3Dint
* value
) = 0;
262 virtual WebString
getProgramInfoLog(WebGLId program
) = 0;
263 virtual void getRenderbufferParameteriv(WGC3Denum target
, WGC3Denum pname
, WGC3Dint
* value
) = 0;
264 virtual void getShaderiv(WebGLId shader
, WGC3Denum pname
, WGC3Dint
* value
) = 0;
265 virtual WebString
getShaderInfoLog(WebGLId shader
) = 0;
266 virtual void getShaderPrecisionFormat(WGC3Denum shadertype
, WGC3Denum precisiontype
, WGC3Dint
* range
, WGC3Dint
* precision
) = 0;
267 virtual WebString
getShaderSource(WebGLId shader
) = 0;
268 virtual WebString
getString(WGC3Denum name
) = 0;
269 virtual void getTexParameterfv(WGC3Denum target
, WGC3Denum pname
, WGC3Dfloat
* value
) = 0;
270 virtual void getTexParameteriv(WGC3Denum target
, WGC3Denum pname
, WGC3Dint
* value
) = 0;
271 virtual void getUniformfv(WebGLId program
, WGC3Dint location
, WGC3Dfloat
* value
) = 0;
272 virtual void getUniformiv(WebGLId program
, WGC3Dint location
, WGC3Dint
* value
) = 0;
273 virtual WGC3Dint
getUniformLocation(WebGLId program
, const WGC3Dchar
* name
) = 0;
274 virtual void getVertexAttribfv(WGC3Duint index
, WGC3Denum pname
, WGC3Dfloat
* value
) = 0;
275 virtual void getVertexAttribiv(WGC3Duint index
, WGC3Denum pname
, WGC3Dint
* value
) = 0;
276 virtual WGC3Dintptr
getVertexAttribOffset(WGC3Duint index
, WGC3Denum pname
) = 0;
278 virtual void hint(WGC3Denum target
, WGC3Denum mode
) = 0;
279 virtual WGC3Dboolean
isBuffer(WebGLId buffer
) = 0;
280 virtual WGC3Dboolean
isEnabled(WGC3Denum cap
) = 0;
281 virtual WGC3Dboolean
isFramebuffer(WebGLId framebuffer
) = 0;
282 virtual WGC3Dboolean
isProgram(WebGLId program
) = 0;
283 virtual WGC3Dboolean
isRenderbuffer(WebGLId renderbuffer
) = 0;
284 virtual WGC3Dboolean
isShader(WebGLId shader
) = 0;
285 virtual WGC3Dboolean
isTexture(WebGLId texture
) = 0;
286 virtual void lineWidth(WGC3Dfloat
) = 0;
287 virtual void linkProgram(WebGLId program
) = 0;
288 virtual void pixelStorei(WGC3Denum pname
, WGC3Dint param
) = 0;
289 virtual void polygonOffset(WGC3Dfloat factor
, WGC3Dfloat units
) = 0;
291 virtual void readPixels(WGC3Dint x
, WGC3Dint y
, WGC3Dsizei width
, WGC3Dsizei height
, WGC3Denum format
, WGC3Denum type
, void* pixels
) = 0;
293 virtual void releaseShaderCompiler() = 0;
295 virtual void renderbufferStorage(WGC3Denum target
, WGC3Denum internalformat
, WGC3Dsizei width
, WGC3Dsizei height
) = 0;
296 virtual void sampleCoverage(WGC3Dclampf value
, WGC3Dboolean invert
) = 0;
297 virtual void scissor(WGC3Dint x
, WGC3Dint y
, WGC3Dsizei width
, WGC3Dsizei height
) = 0;
298 virtual void shaderSource(WebGLId shader
, const WGC3Dchar
* string
) = 0;
299 virtual void stencilFunc(WGC3Denum func
, WGC3Dint ref
, WGC3Duint mask
) = 0;
300 virtual void stencilFuncSeparate(WGC3Denum face
, WGC3Denum func
, WGC3Dint ref
, WGC3Duint mask
) = 0;
301 virtual void stencilMask(WGC3Duint mask
) = 0;
302 virtual void stencilMaskSeparate(WGC3Denum face
, WGC3Duint mask
) = 0;
303 virtual void stencilOp(WGC3Denum fail
, WGC3Denum zfail
, WGC3Denum zpass
) = 0;
304 virtual void stencilOpSeparate(WGC3Denum face
, WGC3Denum fail
, WGC3Denum zfail
, WGC3Denum zpass
) = 0;
306 virtual void texImage2D(WGC3Denum target
, WGC3Dint level
, WGC3Denum internalformat
, WGC3Dsizei width
, WGC3Dsizei height
, WGC3Dint border
, WGC3Denum format
, WGC3Denum type
, const void* pixels
) = 0;
308 virtual void texParameterf(WGC3Denum target
, WGC3Denum pname
, WGC3Dfloat param
) = 0;
309 virtual void texParameteri(WGC3Denum target
, WGC3Denum pname
, WGC3Dint param
) = 0;
311 virtual void texSubImage2D(WGC3Denum target
, WGC3Dint level
, WGC3Dint xoffset
, WGC3Dint yoffset
, WGC3Dsizei width
, WGC3Dsizei height
, WGC3Denum format
, WGC3Denum type
, const void* pixels
) = 0;
313 virtual void uniform1f(WGC3Dint location
, WGC3Dfloat x
) = 0;
314 virtual void uniform1fv(WGC3Dint location
, WGC3Dsizei count
, const WGC3Dfloat
* v
) = 0;
315 virtual void uniform1i(WGC3Dint location
, WGC3Dint x
) = 0;
316 virtual void uniform1iv(WGC3Dint location
, WGC3Dsizei count
, const WGC3Dint
* v
) = 0;
317 virtual void uniform2f(WGC3Dint location
, WGC3Dfloat x
, WGC3Dfloat y
) = 0;
318 virtual void uniform2fv(WGC3Dint location
, WGC3Dsizei count
, const WGC3Dfloat
* v
) = 0;
319 virtual void uniform2i(WGC3Dint location
, WGC3Dint x
, WGC3Dint y
) = 0;
320 virtual void uniform2iv(WGC3Dint location
, WGC3Dsizei count
, const WGC3Dint
* v
) = 0;
321 virtual void uniform3f(WGC3Dint location
, WGC3Dfloat x
, WGC3Dfloat y
, WGC3Dfloat z
) = 0;
322 virtual void uniform3fv(WGC3Dint location
, WGC3Dsizei count
, const WGC3Dfloat
* v
) = 0;
323 virtual void uniform3i(WGC3Dint location
, WGC3Dint x
, WGC3Dint y
, WGC3Dint z
) = 0;
324 virtual void uniform3iv(WGC3Dint location
, WGC3Dsizei count
, const WGC3Dint
* v
) = 0;
325 virtual void uniform4f(WGC3Dint location
, WGC3Dfloat x
, WGC3Dfloat y
, WGC3Dfloat z
, WGC3Dfloat w
) = 0;
326 virtual void uniform4fv(WGC3Dint location
, WGC3Dsizei count
, const WGC3Dfloat
* v
) = 0;
327 virtual void uniform4i(WGC3Dint location
, WGC3Dint x
, WGC3Dint y
, WGC3Dint z
, WGC3Dint w
) = 0;
328 virtual void uniform4iv(WGC3Dint location
, WGC3Dsizei count
, const WGC3Dint
* v
) = 0;
329 virtual void uniformMatrix2fv(WGC3Dint location
, WGC3Dsizei count
, WGC3Dboolean transpose
, const WGC3Dfloat
* value
) = 0;
330 virtual void uniformMatrix3fv(WGC3Dint location
, WGC3Dsizei count
, WGC3Dboolean transpose
, const WGC3Dfloat
* value
) = 0;
331 virtual void uniformMatrix4fv(WGC3Dint location
, WGC3Dsizei count
, WGC3Dboolean transpose
, const WGC3Dfloat
* value
) = 0;
333 virtual void useProgram(WebGLId program
) = 0;
334 virtual void validateProgram(WebGLId program
) = 0;
336 virtual void vertexAttrib1f(WGC3Duint index
, WGC3Dfloat x
) = 0;
337 virtual void vertexAttrib1fv(WGC3Duint index
, const WGC3Dfloat
* values
) = 0;
338 virtual void vertexAttrib2f(WGC3Duint index
, WGC3Dfloat x
, WGC3Dfloat y
) = 0;
339 virtual void vertexAttrib2fv(WGC3Duint index
, const WGC3Dfloat
* values
) = 0;
340 virtual void vertexAttrib3f(WGC3Duint index
, WGC3Dfloat x
, WGC3Dfloat y
, WGC3Dfloat z
) = 0;
341 virtual void vertexAttrib3fv(WGC3Duint index
, const WGC3Dfloat
* values
) = 0;
342 virtual void vertexAttrib4f(WGC3Duint index
, WGC3Dfloat x
, WGC3Dfloat y
, WGC3Dfloat z
, WGC3Dfloat w
) = 0;
343 virtual void vertexAttrib4fv(WGC3Duint index
, const WGC3Dfloat
* values
) = 0;
344 virtual void vertexAttribPointer(WGC3Duint index
, WGC3Dint size
, WGC3Denum type
, WGC3Dboolean normalized
,
345 WGC3Dsizei stride
, WGC3Dintptr offset
) = 0;
347 virtual void viewport(WGC3Dint x
, WGC3Dint y
, WGC3Dsizei width
, WGC3Dsizei height
) = 0;
349 virtual WebGLId
createBuffer() = 0;
350 virtual WebGLId
createFramebuffer() = 0;
351 virtual WebGLId
createRenderbuffer() = 0;
352 virtual WebGLId
createTexture() = 0;
354 virtual void deleteBuffer(WebGLId
) = 0;
355 virtual void deleteFramebuffer(WebGLId
) = 0;
356 virtual void deleteRenderbuffer(WebGLId
) = 0;
357 virtual void deleteTexture(WebGLId
) = 0;
359 virtual WebGLId
createProgram() = 0;
360 virtual WebGLId
createShader(WGC3Denum
) = 0;
362 virtual void deleteShader(WebGLId
) = 0;
363 virtual void deleteProgram(WebGLId
) = 0;
365 virtual void setContextLostCallback(WebGraphicsContextLostCallback
* callback
) { }
366 virtual void setErrorMessageCallback(WebGraphicsErrorMessageCallback
* callback
) { }
369 // This entry point must provide slightly different semantics than
370 // the GL_ARB_robustness extension; specifically, the lost context
371 // state is sticky, rather than reported only once.
372 virtual WGC3Denum
getGraphicsResetStatusARB() { return 0; /* GL_NO_ERROR */ }
374 virtual WebString
getTranslatedShaderSourceANGLE(WebGLId shader
) = 0;
376 // GL_CHROMIUM_screen_space_antialiasing
377 virtual void applyScreenSpaceAntialiasingCHROMIUM() { }
379 // GL_CHROMIUM_iosurface
380 virtual void texImageIOSurface2DCHROMIUM(WGC3Denum target
, WGC3Dint width
, WGC3Dint height
, WGC3Duint ioSurfaceId
, WGC3Duint plane
) { }
382 // GL_EXT_texture_storage
383 virtual void texStorage2DEXT(WGC3Denum target
, WGC3Dint levels
, WGC3Duint internalformat
,
384 WGC3Dint width
, WGC3Dint height
) { }
386 // GL_EXT_occlusion_query
387 virtual WebGLId
createQueryEXT() { return 0; }
388 virtual void deleteQueryEXT(WebGLId query
) { }
389 virtual WGC3Dboolean
isQueryEXT(WebGLId query
) { return false; }
390 virtual void beginQueryEXT(WGC3Denum target
, WebGLId query
) { }
391 virtual void endQueryEXT(WGC3Denum target
) { }
392 virtual void getQueryivEXT(WGC3Denum target
, WGC3Denum pname
, WGC3Dint
* params
) { }
393 virtual void getQueryObjectuivEXT(WebGLId query
, WGC3Denum pname
, WGC3Duint
* params
) { }
395 // GL_EXT_disjoint_timer_query
396 virtual void queryCounterEXT(WebGLId query
, WGC3Denum target
) {}
397 virtual void getQueryObjectui64vEXT(WebGLId query
, WGC3Denum pname
, WGC3Duint64
* params
) {}
399 // GL_CHROMIUM_bind_uniform_location
400 virtual void bindUniformLocationCHROMIUM(WebGLId program
, WGC3Dint location
, const WGC3Dchar
* uniform
) { }
402 // GL_CHROMIUM_copy_texture
403 virtual void copyTextureCHROMIUM(WGC3Denum target
, WGC3Duint sourceId
,
404 WGC3Duint destId
, WGC3Denum internalFormat
, WGC3Denum destType
,
405 WGC3Dboolean unpackFlipY
, WGC3Dboolean unpackPremultiplyAlpha
, WGC3Dboolean unpackUnmultiplyAlpha
) { }
406 virtual void copySubTextureCHROMIUM(WGC3Denum target
, WGC3Duint sourceId
,
407 WGC3Duint destId
, WGC3Dint xoffset
, WGC3Dint yoffset
, WGC3Dint x
,
408 WGC3Dint y
, WGC3Dsizei width
, WGC3Dsizei height
,
409 WGC3Dboolean unpackFlipY
, WGC3Dboolean unpackPremultiplyAlpha
, WGC3Dboolean unpackUnmultiplyAlpha
) { }
411 // GL_CHROMIUM_shallow_flush
412 virtual void shallowFlushCHROMIUM() { }
413 virtual void shallowFinishCHROMIUM() { }
415 // GL_CHROMIUM_subscribe_uniform
416 virtual void genValuebuffersCHROMIUM(WGC3Dsizei count
, WebGLId
* ids
) { }
417 virtual WebGLId
createValuebufferCHROMIUM() { return 0; }
418 virtual void deleteValuebuffersCHROMIUM(WGC3Dsizei count
, WebGLId
* ids
) { }
419 virtual void deleteValuebufferCHROMIUM(WebGLId
) { }
420 virtual WGC3Dboolean
isValuebufferCHROMIUM(WebGLId renderbuffer
) { return false; }
421 virtual void bindValuebufferCHROMIUM(WGC3Denum target
, WebGLId valuebuffer
) { }
422 virtual void subscribeValueCHROMIUM(WGC3Denum target
, WGC3Denum subscription
) { }
423 virtual void populateSubscribedValuesCHROMIUM(WGC3Denum target
) { }
424 virtual void uniformValuebufferCHROMIUM(WGC3Dint location
, WGC3Denum target
, WGC3Denum subscription
) { }
426 // GL_CHROMIUM_texture_mailbox
427 virtual void genMailboxCHROMIUM(WGC3Dbyte
* mailbox
) { }
428 virtual void produceTextureCHROMIUM(WGC3Denum target
, const WGC3Dbyte
* mailbox
) { }
429 virtual void produceTextureDirectCHROMIUM(WebGLId texture
, WGC3Denum target
, const WGC3Dbyte
* mailbox
) { }
431 virtual void consumeTextureCHROMIUM(WGC3Denum target
, const WGC3Dbyte
* mailbox
) { }
432 virtual WebGLId
createAndConsumeTextureCHROMIUM(WGC3Denum target
, const WGC3Dbyte
* mailbox
) { return 0; }
434 // GL_EXT_debug_marker
435 virtual void insertEventMarkerEXT(const WGC3Dchar
* marker
) { }
436 virtual void pushGroupMarkerEXT(const WGC3Dchar
* marker
) { }
437 virtual void popGroupMarkerEXT(void) { }
439 // GL_CHROMIUM_trace_marker
440 virtual void traceBeginCHROMIUM(const WGC3Dchar
* category
, const WGC3Dchar
* trace
) { }
441 virtual void traceEndCHROMIUM() { }
443 // GL_OES_vertex_array_object
444 virtual WebGLId
createVertexArrayOES() { return 0; }
445 virtual void deleteVertexArrayOES(WebGLId array
) { }
446 virtual WGC3Dboolean
isVertexArrayOES(WebGLId array
) { return false; }
447 virtual void bindVertexArrayOES(WebGLId array
) { }
449 // GL_CHROMIUM_texture_from_image
450 virtual void bindTexImage2DCHROMIUM(WGC3Denum target
, WGC3Dint imageId
) { }
451 virtual void releaseTexImage2DCHROMIUM(WGC3Denum target
, WGC3Dint imageId
) { }
453 // GL_CHROMIUM_pixel_transfer_buffer_object
454 virtual void* mapBufferCHROMIUM(WGC3Denum target
, WGC3Denum access
) { return nullptr; }
455 virtual WGC3Dboolean
unmapBufferCHROMIUM(WGC3Denum target
) { return false; }
457 // GL_CHROMIUM_async_pixel_transfers
458 virtual void asyncTexImage2DCHROMIUM(WGC3Denum target
, WGC3Dint level
, WGC3Denum internalformat
, WGC3Dsizei width
, WGC3Dsizei height
, WGC3Dint border
, WGC3Denum format
, WGC3Denum type
, const void* pixels
) { }
459 virtual void asyncTexSubImage2DCHROMIUM(WGC3Denum target
, WGC3Dint level
, WGC3Dint xoffset
, WGC3Dint yoffset
, WGC3Dsizei width
, WGC3Dsizei height
, WGC3Denum format
, WGC3Denum type
, const void* pixels
) { }
460 virtual void waitAsyncTexImage2DCHROMIUM(WGC3Denum
) { }
462 // GL_EXT_draw_buffers
463 virtual void drawBuffersEXT(WGC3Dsizei n
, const WGC3Denum
* bufs
) { }
465 virtual GrGLInterface
* createGrGLInterface() { return nullptr; }
468 virtual void destroyImageCHROMIUM(WGC3Duint imageId
) { }
470 // GL_CHROMIUM_gpu_memory_buffer_image
471 virtual WGC3Duint
createGpuMemoryBufferImageCHROMIUM(WGC3Dsizei width
, WGC3Dsizei height
, WGC3Denum internalformat
, WGC3Denum usage
) { return 0; }
473 // GL_ANGLE_instanced_arrays
474 virtual void drawArraysInstancedANGLE(WGC3Denum mode
, WGC3Dint first
, WGC3Dsizei count
, WGC3Dsizei primcount
) { }
475 virtual void drawElementsInstancedANGLE(WGC3Denum mode
, WGC3Dsizei count
, WGC3Denum type
, WGC3Dintptr offset
, WGC3Dsizei primcount
) { }
476 virtual void vertexAttribDivisorANGLE(WGC3Duint index
, WGC3Duint divisor
) { }
478 // GL_EXT_multisampled_render_to_texture
479 virtual void framebufferTexture2DMultisampleEXT(WGC3Denum target
, WGC3Denum attachment
, WGC3Denum textarget
, WebGLId texture
, WGC3Dint level
, WGC3Dsizei samples
) { }
480 virtual void renderbufferStorageMultisampleEXT(WGC3Denum target
, WGC3Dsizei samples
, WGC3Denum internalformat
, WGC3Dsizei width
, WGC3Dsizei height
) { };
482 // OpenGL ES 3.0 functions not represented by pre-existing extensions
483 virtual void beginTransformFeedback(WGC3Denum primitiveMode
) { }
484 virtual void bindBufferBase(WGC3Denum target
, WGC3Duint index
, WebGLId buffer
) { }
485 virtual void bindBufferRange(WGC3Denum target
, WGC3Duint index
, WebGLId buffer
, WGC3Dintptr offset
, WGC3Dsizeiptr size
) { }
486 virtual void bindSampler(WGC3Duint unit
, WebGLId sampler
) { }
487 virtual void bindTransformFeedback(WGC3Denum target
, WebGLId transformfeedback
) { }
488 virtual void clearBufferfi(WGC3Denum buffer
, WGC3Dint drawbuffer
, WGC3Dfloat depth
, WGC3Dint stencil
) { }
489 virtual void clearBufferfv(WGC3Denum buffer
, WGC3Dint drawbuffer
, const WGC3Dfloat
*value
) { }
490 virtual void clearBufferiv(WGC3Denum buffer
, WGC3Dint drawbuffer
, const WGC3Dint
*value
) { }
491 virtual void clearBufferuiv(WGC3Denum buffer
, WGC3Dint drawbuffer
, const WGC3Duint
*value
) { }
492 virtual WGC3Denum
clientWaitSync(WGC3Dsync sync
, WGC3Dbitfield flags
, WGC3Duint64 timeout
) { return 0x911D; /* GL_WAIT_FAILED */ }
493 virtual void compressedTexImage3D(WGC3Denum target
, WGC3Dint level
, WGC3Denum internalformat
, WGC3Dsizei width
, WGC3Dsizei height
, WGC3Dsizei depth
, WGC3Dint border
, WGC3Dsizei imageSize
, const void *data
) { }
494 virtual void compressedTexSubImage3D(WGC3Denum target
, WGC3Dint level
, WGC3Dint xoffset
, WGC3Dint yoffset
, WGC3Dint zoffset
, WGC3Dsizei width
, WGC3Dsizei height
, WGC3Dsizei depth
, WGC3Denum format
, WGC3Dsizei imageSize
, const void *data
) { }
495 virtual void copyBufferSubData(WGC3Denum readTarget
, WGC3Denum writeTarget
, WGC3Dintptr readOffset
, WGC3Dintptr writeOffset
, WGC3Dsizeiptr size
) { }
496 virtual void copyTexSubImage3D(WGC3Denum target
, WGC3Dint level
, WGC3Dint xoffset
, WGC3Dint yoffset
, WGC3Dint zoffset
, WGC3Dint x
, WGC3Dint y
, WGC3Dsizei width
, WGC3Dsizei height
) { }
497 virtual WebGLId
createSampler() { return 0; }
498 virtual WebGLId
createTransformFeedback() { return 0; }
499 virtual void deleteSampler(WebGLId sampler
) { }
500 virtual void deleteSync(WGC3Dsync sync
) { }
501 virtual void deleteTransformFeedback(WebGLId transformfeedback
) { }
502 virtual void drawRangeElements(WGC3Denum mode
, WGC3Duint start
, WGC3Duint end
, WGC3Dsizei count
, WGC3Denum type
, WGC3Dintptr offset
) { }
503 virtual void endTransformFeedback(void) { }
504 virtual WGC3Dsync
fenceSync(WGC3Denum condition
, WGC3Dbitfield flags
) { return nullptr; }
505 virtual void framebufferTextureLayer(WGC3Denum target
, WGC3Denum attachment
, WGC3Duint texture
, WGC3Dint level
, WGC3Dint layer
) { }
506 virtual void getActiveUniformBlockName(WebGLId program
, WGC3Duint uniformBlockIndex
, WGC3Dsizei bufSize
, WGC3Dsizei
*length
, WGC3Dchar
*uniformBlockName
) { }
507 virtual void getActiveUniformBlockiv(WebGLId program
, WGC3Duint uniformBlockIndex
, WGC3Denum pname
, WGC3Dint
*params
) { }
508 virtual void getActiveUniformsiv(WebGLId program
, WGC3Dsizei uniformCount
, const WGC3Duint
*uniformIndices
, WGC3Denum pname
, WGC3Dint
*params
) { }
509 virtual void getBufferParameteri64v(WGC3Denum target
, WGC3Denum pname
, WGC3Dint64
*value
) { }
510 virtual WGC3Dint
getFragDataLocation(WebGLId program
, const WGC3Dchar
*name
) { return -1; }
511 virtual void getInteger64v(WGC3Denum pname
, WGC3Dint64
*data
) { }
512 virtual void getIntegeri_v(WGC3Denum target
, WGC3Duint index
, WGC3Dint
*data
) { }
513 virtual void getInteger64i_v(WGC3Denum target
, WGC3Duint index
, WGC3Dint64
*data
) { }
514 virtual void getInternalformativ(WGC3Denum target
, WGC3Denum internalformat
, WGC3Denum pname
, WGC3Dsizei bufSize
, WGC3Dint
*params
) { }
515 virtual void getSamplerParameterfv(WebGLId sampler
, WGC3Denum pname
, WGC3Dfloat
*params
) { }
516 virtual void getSamplerParameteriv(WebGLId sampler
, WGC3Denum pname
, WGC3Dint
*params
) { }
517 virtual void getSynciv(WGC3Dsync sync
, WGC3Denum pname
, WGC3Dsizei bufSize
, WGC3Dsizei
*length
, WGC3Dint
*params
) { }
518 virtual void getTransformFeedbackVarying(WebGLId program
, WGC3Duint index
, WGC3Dsizei bufSize
, WGC3Dsizei
*length
, WGC3Dsizei
*size
, WGC3Denum
*type
, WGC3Dchar
*name
) { }
519 virtual WGC3Duint
getUniformBlockIndex(WebGLId program
, const WGC3Dchar
*uniformBlockName
) { return 0xFFFFFFFFu
; /* GL_INVALID_INDEX */ }
520 virtual void getUniformIndices(WebGLId program
, WGC3Dsizei uniformCount
, const WGC3Dchar
*const*uniformNames
, WGC3Duint
*uniformIndices
) { }
521 virtual void getUniformuiv(WebGLId program
, WGC3Dint location
, WGC3Duint
*params
) { }
522 virtual void getVertexAttribIiv(WGC3Duint index
, WGC3Denum pname
, WGC3Dint
*params
) { }
523 virtual void getVertexAttribIuiv(WGC3Duint index
, WGC3Denum pname
, WGC3Duint
*params
) { }
524 virtual void invalidateFramebuffer(WGC3Denum target
, WGC3Dsizei numAttachments
, const WGC3Denum
*attachments
) { }
525 virtual void invalidateSubFramebuffer(WGC3Denum target
, WGC3Dsizei numAttachments
, const WGC3Denum
*attachments
, WGC3Dint x
, WGC3Dint y
, WGC3Dsizei width
, WGC3Dsizei height
) { }
526 virtual WGC3Dboolean
isSampler(WebGLId sampler
) { return false; }
527 virtual WGC3Dboolean
isSync(WGC3Dsync sync
) { return false; }
528 virtual WGC3Dboolean
isTransformFeedback(WebGLId transformfeedback
) { return false; }
529 virtual void* mapBufferRange(WGC3Denum target
, WGC3Dintptr offset
, WGC3Dsizeiptr length
, WGC3Dbitfield access
) { return 0; }
530 virtual void pauseTransformFeedback(void) { }
531 virtual void programParameteri(WebGLId program
, WGC3Denum pname
, WGC3Dint value
) { }
532 virtual void readBuffer(WGC3Denum src
) { }
533 virtual void resumeTransformFeedback(void) { }
534 virtual void samplerParameterf(WebGLId sampler
, WGC3Denum pname
, WGC3Dfloat param
) { }
535 virtual void samplerParameterfv(WebGLId sampler
, WGC3Denum pname
, const WGC3Dfloat
*param
) { }
536 virtual void samplerParameteri(WebGLId sampler
, WGC3Denum pname
, WGC3Dint param
) { }
537 virtual void samplerParameteriv(WebGLId sampler
, WGC3Denum pname
, const WGC3Dint
*param
) { }
538 virtual void texImage3D(WGC3Denum target
, WGC3Dint level
, WGC3Dint internalformat
, WGC3Dsizei width
, WGC3Dsizei height
, WGC3Dsizei depth
, WGC3Dint border
, WGC3Denum format
, WGC3Denum type
, const void *pixels
) { }
539 virtual void texStorage3D(WGC3Denum target
, WGC3Dsizei levels
, WGC3Denum internalformat
, WGC3Dsizei width
, WGC3Dsizei height
, WGC3Dsizei depth
) { }
540 virtual void texSubImage3D(WGC3Denum target
, WGC3Dint level
, WGC3Dint xoffset
, WGC3Dint yoffset
, WGC3Dint zoffset
, WGC3Dsizei width
, WGC3Dsizei height
, WGC3Dsizei depth
, WGC3Denum format
, WGC3Denum type
, const void *pixels
) { }
541 virtual void transformFeedbackVaryings(WebGLId program
, WGC3Dsizei count
, const WGC3Dchar
*const*varyings
, WGC3Denum bufferMode
) { }
542 virtual void uniform1ui(WGC3Dint location
, WGC3Duint x
) { }
543 virtual void uniform1uiv(WGC3Dint location
, WGC3Dsizei count
, const WGC3Duint
*value
) { }
544 virtual void uniform2ui(WGC3Dint location
, WGC3Duint x
, WGC3Duint y
) { }
545 virtual void uniform2uiv(WGC3Dint location
, WGC3Dsizei count
, const WGC3Duint
*value
) { }
546 virtual void uniform3ui(WGC3Dint location
, WGC3Duint x
, WGC3Duint y
, WGC3Duint z
) { }
547 virtual void uniform3uiv(WGC3Dint location
, WGC3Dsizei count
, const WGC3Duint
*value
) { }
548 virtual void uniform4ui(WGC3Dint location
, WGC3Duint x
, WGC3Duint y
, WGC3Duint z
, WGC3Duint w
) { }
549 virtual void uniform4uiv(WGC3Dint location
, WGC3Dsizei count
, const WGC3Duint
*value
) { }
550 virtual void uniformBlockBinding(WebGLId program
, WGC3Duint uniformBlockIndex
, WGC3Duint uniformBlockBinding
) { }
551 virtual void uniformMatrix2x3fv(WGC3Dint location
, WGC3Dsizei count
, WGC3Dboolean transpose
, const WGC3Dfloat
* value
) { }
552 virtual void uniformMatrix2x4fv(WGC3Dint location
, WGC3Dsizei count
, WGC3Dboolean transpose
, const WGC3Dfloat
* value
) { }
553 virtual void uniformMatrix3x2fv(WGC3Dint location
, WGC3Dsizei count
, WGC3Dboolean transpose
, const WGC3Dfloat
* value
) { }
554 virtual void uniformMatrix3x4fv(WGC3Dint location
, WGC3Dsizei count
, WGC3Dboolean transpose
, const WGC3Dfloat
* value
) { }
555 virtual void uniformMatrix4x2fv(WGC3Dint location
, WGC3Dsizei count
, WGC3Dboolean transpose
, const WGC3Dfloat
* value
) { }
556 virtual void uniformMatrix4x3fv(WGC3Dint location
, WGC3Dsizei count
, WGC3Dboolean transpose
, const WGC3Dfloat
* value
) { }
557 virtual WGC3Dboolean
unmapBuffer(WGC3Denum target
) { return false; }
559 virtual void vertexAttribI4i(WGC3Duint index
, WGC3Dint x
, WGC3Dint y
, WGC3Dint z
, WGC3Dint w
) { }
560 virtual void vertexAttribI4iv(WGC3Duint index
, const WGC3Dint
*v
) { }
561 virtual void vertexAttribI4ui(WGC3Duint index
, WGC3Duint x
, WGC3Duint y
, WGC3Duint z
, WGC3Duint w
) { }
562 virtual void vertexAttribI4uiv(WGC3Duint index
, const WGC3Duint
*v
) { }
563 virtual void vertexAttribIPointer(WGC3Duint index
, WGC3Dint size
, WGC3Denum type
, WGC3Dsizei stride
, WGC3Dintptr pointer
) { }
564 virtual void waitSync(WGC3Dsync sync
, WGC3Dbitfield flags
, WGC3Duint64 timeout
) { }