• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2012 Google Inc. All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions are
6  * met:
7  *
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
13  * distribution.
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.
17  *
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.
29  */
30 
31 #ifndef WebGraphicsContext3D_h
32 #define WebGraphicsContext3D_h
33 
34 #include "WebCommon.h"
35 #include "WebNonCopyable.h"
36 #include "WebString.h"
37 
38 struct GrGLInterface;
39 
40 namespace blink {
41 
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 int WGC3Denum;
46 typedef unsigned char WGC3Dboolean;
47 typedef unsigned int WGC3Dbitfield;
48 typedef signed char WGC3Dbyte;
49 typedef unsigned char WGC3Dubyte;
50 typedef short WGC3Dshort;
51 typedef unsigned short WGC3Dushort;
52 typedef int WGC3Dint;
53 typedef int WGC3Dsizei;
54 typedef unsigned int WGC3Duint;
55 typedef float WGC3Dfloat;
56 typedef float WGC3Dclampf;
57 typedef signed long int WGC3Dintptr;
58 typedef signed long int WGC3Dsizeiptr;
59 
60 // Typedef for server-side objects like OpenGL textures and program objects.
61 typedef WGC3Duint WebGLId;
62 
63 // This interface abstracts the operations performed by the
64 // GraphicsContext3D in order to implement WebGL. Nearly all of the
65 // methods exposed on this interface map directly to entry points in
66 // the OpenGL ES 2.0 API.
67 //
68 // Creating a WebGraphicsContext does not make it current, or guarantee
69 // that the context has been created successfully. Use
70 // makeContextCurrent() to complete initialization of the context, treating
71 // a false return value as indication that the context could not be created
72 // successfully.
73 class WebGraphicsContext3D : public WebNonCopyable {
74 public:
75     // Return value from getActiveUniform and getActiveAttrib.
76     struct ActiveInfo {
77         WebString name;
78         WGC3Denum type;
79         WGC3Dint size;
80     };
81 
82     // Context creation attributes.
83     struct Attributes {
AttributesAttributes84         Attributes()
85             : alpha(true)
86             , depth(true)
87             , stencil(true)
88             , antialias(true)
89             , premultipliedAlpha(true)
90             , canRecoverFromContextLoss(true)
91             , noExtensions(false)
92             , shareResources(true)
93             , preferDiscreteGPU(false)
94             , noAutomaticFlushes(false)
95             , failIfMajorPerformanceCaveat(false)
96         {
97         }
98 
99         bool alpha;
100         bool depth;
101         bool stencil;
102         bool antialias;
103         bool premultipliedAlpha;
104         bool canRecoverFromContextLoss;
105         bool noExtensions;
106         bool shareResources;
107         bool preferDiscreteGPU;
108         bool noAutomaticFlushes;
109         bool failIfMajorPerformanceCaveat;
110         // FIXME: ideally this would be a WebURL, but it is currently not
111         // possible to pass a WebURL by value across the WebKit API boundary.
112         // See https://bugs.webkit.org/show_bug.cgi?id=103793#c13 .
113         WebString topDocumentURL;
114     };
115 
116     class WebGraphicsContextLostCallback {
117     public:
118         virtual void onContextLost() = 0;
119 
120     protected:
~WebGraphicsContextLostCallback()121         virtual ~WebGraphicsContextLostCallback() { }
122     };
123 
124     class WebGraphicsErrorMessageCallback {
125     public:
126         virtual void onErrorMessage(const WebString&, WGC3Dint) = 0;
127 
128     protected:
~WebGraphicsErrorMessageCallback()129         virtual ~WebGraphicsErrorMessageCallback() { }
130     };
131 
132     class WebGraphicsSwapBuffersCompleteCallbackCHROMIUM {
133     public:
134         virtual void onSwapBuffersComplete() = 0;
135 
136     protected:
~WebGraphicsSwapBuffersCompleteCallbackCHROMIUM()137         virtual ~WebGraphicsSwapBuffersCompleteCallbackCHROMIUM() { }
138     };
139 
140     // This destructor needs to be public so that using classes can destroy instances if initialization fails.
~WebGraphicsContext3D()141     virtual ~WebGraphicsContext3D() { }
142 
143     // Makes the OpenGL context current on the current thread. Returns true on
144     // success.
145     virtual bool makeContextCurrent() = 0;
146 
147     // Each flush or finish is assigned an unique ID. The larger
148     // the ID number, the more recently the context has been flushed.
lastFlushID()149     virtual uint32_t lastFlushID() { return 0; }
150 
151     // Resizes the region into which this WebGraphicsContext3D is drawing.
reshapeWithScaleFactor(int width,int height,float scaleFactor)152     virtual void reshapeWithScaleFactor(int width, int height, float scaleFactor) { }
153 
154     // GL_CHROMIUM_setVisibility - Changes the visibility of the backbuffer
155     virtual void setVisibilityCHROMIUM(bool visible) = 0;
156 
157     // GL_EXT_discard_framebuffer - makes specified attachments of currently bound framebuffer undefined.
discardFramebufferEXT(WGC3Denum target,WGC3Dsizei numAttachments,const WGC3Denum * attachments)158     virtual void discardFramebufferEXT(WGC3Denum target, WGC3Dsizei numAttachments, const WGC3Denum* attachments) { }
159 
160     // GL_CHROMIUM_discard_backbuffer - controls allocation/deallocation of the back buffer.
discardBackbufferCHROMIUM()161     virtual void discardBackbufferCHROMIUM() { }
ensureBackbufferCHROMIUM()162     virtual void ensureBackbufferCHROMIUM() { }
163 
insertSyncPoint()164     virtual unsigned insertSyncPoint() { return 0; }
waitSyncPoint(unsigned)165     virtual void waitSyncPoint(unsigned) { }
166 
167     // Copies the contents of the off-screen render target used by the WebGL
168     // context to the corresponding texture used by the compositor.
169     virtual void prepareTexture() = 0;
170 
171     // GL_CHROMIUM_post_sub_buffer - Copies part of the back buffer to the front buffer.
172     virtual void postSubBufferCHROMIUM(int x, int y, int width, int height) = 0;
173 
174     // Synthesizes an OpenGL error which will be returned from a
175     // later call to getError. This is used to emulate OpenGL ES
176     // 2.0 behavior on the desktop and to enforce additional error
177     // checking mandated by WebGL.
178     //
179     // Per the behavior of glGetError, this stores at most one
180     // instance of any given error, and returns them from calls to
181     // getError in the order they were added.
182     virtual void synthesizeGLError(WGC3Denum) = 0;
183 
184     virtual bool isContextLost() = 0;
185 
186     // GL_CHROMIUM_map_sub
187     virtual void* mapBufferSubDataCHROMIUM(WGC3Denum target, WGC3Dintptr offset, WGC3Dsizeiptr size, WGC3Denum access) = 0;
188     virtual void unmapBufferSubDataCHROMIUM(const void*) = 0;
189     virtual void* mapTexSubImage2DCHROMIUM(WGC3Denum target, WGC3Dint level, WGC3Dint xoffset, WGC3Dint yoffset, WGC3Dsizei width, WGC3Dsizei height, WGC3Denum format, WGC3Denum type, WGC3Denum access) = 0;
190     virtual void unmapTexSubImage2DCHROMIUM(const void*) = 0;
191 
192     // GL_CHROMIUM_request_extension
193     virtual WebString getRequestableExtensionsCHROMIUM() = 0;
194     virtual void requestExtensionCHROMIUM(const char*) = 0;
195 
196     // GL_CHROMIUM_framebuffer_multisample
197     virtual void blitFramebufferCHROMIUM(WGC3Dint srcX0, WGC3Dint srcY0, WGC3Dint srcX1, WGC3Dint srcY1, WGC3Dint dstX0, WGC3Dint dstY0, WGC3Dint dstX1, WGC3Dint dstY1, WGC3Dbitfield mask, WGC3Denum filter) = 0;
198     virtual void renderbufferStorageMultisampleCHROMIUM(WGC3Denum target, WGC3Dsizei samples, WGC3Denum internalformat, WGC3Dsizei width, WGC3Dsizei height) = 0;
199 
200     // GL_CHROMIUM_swapbuffers_complete_callback
setSwapBuffersCompleteCallbackCHROMIUM(WebGraphicsSwapBuffersCompleteCallbackCHROMIUM * callback)201     virtual void setSwapBuffersCompleteCallbackCHROMIUM(WebGraphicsSwapBuffersCompleteCallbackCHROMIUM* callback) { }
202 
203     // GL_CHROMIUM_rate_limit_offscreen_context
rateLimitOffscreenContextCHROMIUM()204     virtual void rateLimitOffscreenContextCHROMIUM() { }
205 
206     // GL_CHROMIUM_stream_texture
207     // Returns the stream end point identifier created for the given texture.
createStreamTextureCHROMIUM(WebGLId texture)208     virtual WebGLId createStreamTextureCHROMIUM(WebGLId texture) { return 0; }
209     // Destroys the stream for the given texture.
destroyStreamTextureCHROMIUM(WebGLId texture)210     virtual void destroyStreamTextureCHROMIUM(WebGLId texture) { }
211 
212     // GL_CHROMIUM_lose_context
loseContextCHROMIUM(WGC3Denum current,WGC3Denum other)213     virtual void loseContextCHROMIUM(WGC3Denum current, WGC3Denum other) { }
214 
215     // The entry points below map directly to the OpenGL ES 2.0 API.
216     // See: http://www.khronos.org/registry/gles/
217     // and: http://www.khronos.org/opengles/sdk/docs/man/
218     virtual void activeTexture(WGC3Denum texture) = 0;
219     virtual void attachShader(WebGLId program, WebGLId shader) = 0;
220     virtual void bindAttribLocation(WebGLId program, WGC3Duint index, const WGC3Dchar* name) = 0;
221     virtual void bindBuffer(WGC3Denum target, WebGLId buffer) = 0;
222     virtual void bindFramebuffer(WGC3Denum target, WebGLId framebuffer) = 0;
223     virtual void bindRenderbuffer(WGC3Denum target, WebGLId renderbuffer) = 0;
224     virtual void bindTexture(WGC3Denum target, WebGLId texture) = 0;
225     virtual void blendColor(WGC3Dclampf red, WGC3Dclampf green, WGC3Dclampf blue, WGC3Dclampf alpha) = 0;
226     virtual void blendEquation(WGC3Denum mode) = 0;
227     virtual void blendEquationSeparate(WGC3Denum modeRGB, WGC3Denum modeAlpha) = 0;
228     virtual void blendFunc(WGC3Denum sfactor, WGC3Denum dfactor) = 0;
229     virtual void blendFuncSeparate(WGC3Denum srcRGB, WGC3Denum dstRGB, WGC3Denum srcAlpha, WGC3Denum dstAlpha) = 0;
230 
231     virtual void bufferData(WGC3Denum target, WGC3Dsizeiptr size, const void* data, WGC3Denum usage) = 0;
232     virtual void bufferSubData(WGC3Denum target, WGC3Dintptr offset, WGC3Dsizeiptr size, const void* data) = 0;
233 
234     virtual WGC3Denum checkFramebufferStatus(WGC3Denum target) = 0;
235     virtual void clear(WGC3Dbitfield mask) = 0;
236     virtual void clearColor(WGC3Dclampf red, WGC3Dclampf green, WGC3Dclampf blue, WGC3Dclampf alpha) = 0;
237     virtual void clearDepth(WGC3Dclampf depth) = 0;
238     virtual void clearStencil(WGC3Dint s) = 0;
239     virtual void colorMask(WGC3Dboolean red, WGC3Dboolean green, WGC3Dboolean blue, WGC3Dboolean alpha) = 0;
240     virtual void compileShader(WebGLId shader) = 0;
241 
242     virtual void compressedTexImage2D(WGC3Denum target, WGC3Dint level, WGC3Denum internalformat, WGC3Dsizei width, WGC3Dsizei height, WGC3Dint border, WGC3Dsizei imageSize, const void* data) = 0;
243     virtual void compressedTexSubImage2D(WGC3Denum target, WGC3Dint level, WGC3Dint xoffset, WGC3Dint yoffset, WGC3Dsizei width, WGC3Dsizei height, WGC3Denum format, WGC3Dsizei imageSize, const void* data) = 0;
244     virtual void copyTexImage2D(WGC3Denum target, WGC3Dint level, WGC3Denum internalformat, WGC3Dint x, WGC3Dint y, WGC3Dsizei width, WGC3Dsizei height, WGC3Dint border) = 0;
245     virtual void copyTexSubImage2D(WGC3Denum target, WGC3Dint level, WGC3Dint xoffset, WGC3Dint yoffset, WGC3Dint x, WGC3Dint y, WGC3Dsizei width, WGC3Dsizei height) = 0;
246     virtual void cullFace(WGC3Denum mode) = 0;
247     virtual void depthFunc(WGC3Denum func) = 0;
248     virtual void depthMask(WGC3Dboolean flag) = 0;
249     virtual void depthRange(WGC3Dclampf zNear, WGC3Dclampf zFar) = 0;
250     virtual void detachShader(WebGLId program, WebGLId shader) = 0;
251     virtual void disable(WGC3Denum cap) = 0;
252     virtual void disableVertexAttribArray(WGC3Duint index) = 0;
253     virtual void drawArrays(WGC3Denum mode, WGC3Dint first, WGC3Dsizei count) = 0;
254     virtual void drawElements(WGC3Denum mode, WGC3Dsizei count, WGC3Denum type, WGC3Dintptr offset) = 0;
255 
256     virtual void enable(WGC3Denum cap) = 0;
257     virtual void enableVertexAttribArray(WGC3Duint index) = 0;
258     virtual void finish() = 0;
259     virtual void flush() = 0;
260     virtual void framebufferRenderbuffer(WGC3Denum target, WGC3Denum attachment, WGC3Denum renderbuffertarget, WebGLId renderbuffer) = 0;
261     virtual void framebufferTexture2D(WGC3Denum target, WGC3Denum attachment, WGC3Denum textarget, WebGLId texture, WGC3Dint level) = 0;
262     virtual void frontFace(WGC3Denum mode) = 0;
263     virtual void generateMipmap(WGC3Denum target) = 0;
264 
265     virtual bool getActiveAttrib(WebGLId program, WGC3Duint index, ActiveInfo&) = 0;
266     virtual bool getActiveUniform(WebGLId program, WGC3Duint index, ActiveInfo&) = 0;
267     virtual void getAttachedShaders(WebGLId program, WGC3Dsizei maxCount, WGC3Dsizei* count, WebGLId* shaders) = 0;
268     virtual WGC3Dint getAttribLocation(WebGLId program, const WGC3Dchar* name) = 0;
269     virtual void getBooleanv(WGC3Denum pname, WGC3Dboolean* value) = 0;
270     virtual void getBufferParameteriv(WGC3Denum target, WGC3Denum pname, WGC3Dint* value) = 0;
271     virtual Attributes getContextAttributes() = 0;
272     virtual WGC3Denum getError() = 0;
273     virtual void getFloatv(WGC3Denum pname, WGC3Dfloat* value) = 0;
274     virtual void getFramebufferAttachmentParameteriv(WGC3Denum target, WGC3Denum attachment, WGC3Denum pname, WGC3Dint* value) = 0;
275     virtual void getIntegerv(WGC3Denum pname, WGC3Dint* value) = 0;
276     virtual void getProgramiv(WebGLId program, WGC3Denum pname, WGC3Dint* value) = 0;
277     virtual WebString getProgramInfoLog(WebGLId program) = 0;
278     virtual void getRenderbufferParameteriv(WGC3Denum target, WGC3Denum pname, WGC3Dint* value) = 0;
279     virtual void getShaderiv(WebGLId shader, WGC3Denum pname, WGC3Dint* value) = 0;
280     virtual WebString getShaderInfoLog(WebGLId shader) = 0;
281     virtual void getShaderPrecisionFormat(WGC3Denum shadertype, WGC3Denum precisiontype, WGC3Dint* range, WGC3Dint* precision) = 0;
282     virtual WebString getShaderSource(WebGLId shader) = 0;
283     virtual WebString getString(WGC3Denum name) = 0;
284     virtual void getTexParameterfv(WGC3Denum target, WGC3Denum pname, WGC3Dfloat* value) = 0;
285     virtual void getTexParameteriv(WGC3Denum target, WGC3Denum pname, WGC3Dint* value) = 0;
286     virtual void getUniformfv(WebGLId program, WGC3Dint location, WGC3Dfloat* value) = 0;
287     virtual void getUniformiv(WebGLId program, WGC3Dint location, WGC3Dint* value) = 0;
288     virtual WGC3Dint getUniformLocation(WebGLId program, const WGC3Dchar* name) = 0;
289     virtual void getVertexAttribfv(WGC3Duint index, WGC3Denum pname, WGC3Dfloat* value) = 0;
290     virtual void getVertexAttribiv(WGC3Duint index, WGC3Denum pname, WGC3Dint* value) = 0;
291     virtual WGC3Dsizeiptr getVertexAttribOffset(WGC3Duint index, WGC3Denum pname) = 0;
292 
293     virtual void hint(WGC3Denum target, WGC3Denum mode) = 0;
294     virtual WGC3Dboolean isBuffer(WebGLId buffer) = 0;
295     virtual WGC3Dboolean isEnabled(WGC3Denum cap) = 0;
296     virtual WGC3Dboolean isFramebuffer(WebGLId framebuffer) = 0;
297     virtual WGC3Dboolean isProgram(WebGLId program) = 0;
298     virtual WGC3Dboolean isRenderbuffer(WebGLId renderbuffer) = 0;
299     virtual WGC3Dboolean isShader(WebGLId shader) = 0;
300     virtual WGC3Dboolean isTexture(WebGLId texture) = 0;
301     virtual void lineWidth(WGC3Dfloat) = 0;
302     virtual void linkProgram(WebGLId program) = 0;
303     virtual void pixelStorei(WGC3Denum pname, WGC3Dint param) = 0;
304     virtual void polygonOffset(WGC3Dfloat factor, WGC3Dfloat units) = 0;
305 
306     virtual void readPixels(WGC3Dint x, WGC3Dint y, WGC3Dsizei width, WGC3Dsizei height, WGC3Denum format, WGC3Denum type, void* pixels) = 0;
307 
308     virtual void releaseShaderCompiler() = 0;
309 
310     virtual void renderbufferStorage(WGC3Denum target, WGC3Denum internalformat, WGC3Dsizei width, WGC3Dsizei height) = 0;
311     virtual void sampleCoverage(WGC3Dclampf value, WGC3Dboolean invert) = 0;
312     virtual void scissor(WGC3Dint x, WGC3Dint y, WGC3Dsizei width, WGC3Dsizei height) = 0;
313     virtual void shaderSource(WebGLId shader, const WGC3Dchar* string) = 0;
314     virtual void stencilFunc(WGC3Denum func, WGC3Dint ref, WGC3Duint mask) = 0;
315     virtual void stencilFuncSeparate(WGC3Denum face, WGC3Denum func, WGC3Dint ref, WGC3Duint mask) = 0;
316     virtual void stencilMask(WGC3Duint mask) = 0;
317     virtual void stencilMaskSeparate(WGC3Denum face, WGC3Duint mask) = 0;
318     virtual void stencilOp(WGC3Denum fail, WGC3Denum zfail, WGC3Denum zpass) = 0;
319     virtual void stencilOpSeparate(WGC3Denum face, WGC3Denum fail, WGC3Denum zfail, WGC3Denum zpass) = 0;
320 
321     virtual void texImage2D(WGC3Denum target, WGC3Dint level, WGC3Denum internalformat, WGC3Dsizei width, WGC3Dsizei height, WGC3Dint border, WGC3Denum format, WGC3Denum type, const void* pixels) = 0;
322 
323     virtual void texParameterf(WGC3Denum target, WGC3Denum pname, WGC3Dfloat param) = 0;
324     virtual void texParameteri(WGC3Denum target, WGC3Denum pname, WGC3Dint param) = 0;
325 
326     virtual void texSubImage2D(WGC3Denum target, WGC3Dint level, WGC3Dint xoffset, WGC3Dint yoffset, WGC3Dsizei width, WGC3Dsizei height, WGC3Denum format, WGC3Denum type, const void* pixels) = 0;
327 
328     virtual void uniform1f(WGC3Dint location, WGC3Dfloat x) = 0;
329     virtual void uniform1fv(WGC3Dint location, WGC3Dsizei count, const WGC3Dfloat* v) = 0;
330     virtual void uniform1i(WGC3Dint location, WGC3Dint x) = 0;
331     virtual void uniform1iv(WGC3Dint location, WGC3Dsizei count, const WGC3Dint* v) = 0;
332     virtual void uniform2f(WGC3Dint location, WGC3Dfloat x, WGC3Dfloat y) = 0;
333     virtual void uniform2fv(WGC3Dint location, WGC3Dsizei count, const WGC3Dfloat* v) = 0;
334     virtual void uniform2i(WGC3Dint location, WGC3Dint x, WGC3Dint y) = 0;
335     virtual void uniform2iv(WGC3Dint location, WGC3Dsizei count, const WGC3Dint* v) = 0;
336     virtual void uniform3f(WGC3Dint location, WGC3Dfloat x, WGC3Dfloat y, WGC3Dfloat z) = 0;
337     virtual void uniform3fv(WGC3Dint location, WGC3Dsizei count, const WGC3Dfloat* v) = 0;
338     virtual void uniform3i(WGC3Dint location, WGC3Dint x, WGC3Dint y, WGC3Dint z) = 0;
339     virtual void uniform3iv(WGC3Dint location, WGC3Dsizei count, const WGC3Dint* v) = 0;
340     virtual void uniform4f(WGC3Dint location, WGC3Dfloat x, WGC3Dfloat y, WGC3Dfloat z, WGC3Dfloat w) = 0;
341     virtual void uniform4fv(WGC3Dint location, WGC3Dsizei count, const WGC3Dfloat* v) = 0;
342     virtual void uniform4i(WGC3Dint location, WGC3Dint x, WGC3Dint y, WGC3Dint z, WGC3Dint w) = 0;
343     virtual void uniform4iv(WGC3Dint location, WGC3Dsizei count, const WGC3Dint* v) = 0;
344     virtual void uniformMatrix2fv(WGC3Dint location, WGC3Dsizei count, WGC3Dboolean transpose, const WGC3Dfloat* value) = 0;
345     virtual void uniformMatrix3fv(WGC3Dint location, WGC3Dsizei count, WGC3Dboolean transpose, const WGC3Dfloat* value) = 0;
346     virtual void uniformMatrix4fv(WGC3Dint location, WGC3Dsizei count, WGC3Dboolean transpose, const WGC3Dfloat* value) = 0;
347 
348     virtual void useProgram(WebGLId program) = 0;
349     virtual void validateProgram(WebGLId program) = 0;
350 
351     virtual void vertexAttrib1f(WGC3Duint index, WGC3Dfloat x) = 0;
352     virtual void vertexAttrib1fv(WGC3Duint index, const WGC3Dfloat* values) = 0;
353     virtual void vertexAttrib2f(WGC3Duint index, WGC3Dfloat x, WGC3Dfloat y) = 0;
354     virtual void vertexAttrib2fv(WGC3Duint index, const WGC3Dfloat* values) = 0;
355     virtual void vertexAttrib3f(WGC3Duint index, WGC3Dfloat x, WGC3Dfloat y, WGC3Dfloat z) = 0;
356     virtual void vertexAttrib3fv(WGC3Duint index, const WGC3Dfloat* values) = 0;
357     virtual void vertexAttrib4f(WGC3Duint index, WGC3Dfloat x, WGC3Dfloat y, WGC3Dfloat z, WGC3Dfloat w) = 0;
358     virtual void vertexAttrib4fv(WGC3Duint index, const WGC3Dfloat* values) = 0;
359     virtual void vertexAttribPointer(WGC3Duint index, WGC3Dint size, WGC3Denum type, WGC3Dboolean normalized,
360                                      WGC3Dsizei stride, WGC3Dintptr offset) = 0;
361 
362     virtual void viewport(WGC3Dint x, WGC3Dint y, WGC3Dsizei width, WGC3Dsizei height) = 0;
363 
364     // Support for buffer creation and deletion.
genBuffers(WGC3Dsizei count,WebGLId * ids)365     virtual void genBuffers(WGC3Dsizei count, WebGLId* ids) { }
genFramebuffers(WGC3Dsizei count,WebGLId * ids)366     virtual void genFramebuffers(WGC3Dsizei count, WebGLId* ids) { }
genRenderbuffers(WGC3Dsizei count,WebGLId * ids)367     virtual void genRenderbuffers(WGC3Dsizei count, WebGLId* ids) { }
genTextures(WGC3Dsizei count,WebGLId * ids)368     virtual void genTextures(WGC3Dsizei count, WebGLId* ids) { }
369 
deleteBuffers(WGC3Dsizei count,WebGLId * ids)370     virtual void deleteBuffers(WGC3Dsizei count, WebGLId* ids) { }
deleteFramebuffers(WGC3Dsizei count,WebGLId * ids)371     virtual void deleteFramebuffers(WGC3Dsizei count, WebGLId* ids) { }
deleteRenderbuffers(WGC3Dsizei count,WebGLId * ids)372     virtual void deleteRenderbuffers(WGC3Dsizei count, WebGLId* ids) { }
deleteTextures(WGC3Dsizei count,WebGLId * ids)373     virtual void deleteTextures(WGC3Dsizei count, WebGLId* ids) { }
374 
375     virtual WebGLId createBuffer() = 0;
376     virtual WebGLId createFramebuffer() = 0;
377     virtual WebGLId createRenderbuffer() = 0;
378     virtual WebGLId createTexture() = 0;
379 
380     virtual void deleteBuffer(WebGLId) = 0;
381     virtual void deleteFramebuffer(WebGLId) = 0;
382     virtual void deleteRenderbuffer(WebGLId) = 0;
383     virtual void deleteTexture(WebGLId) = 0;
384 
385     virtual WebGLId createProgram() = 0;
386     virtual WebGLId createShader(WGC3Denum) = 0;
387 
388     virtual void deleteShader(WebGLId) = 0;
389     virtual void deleteProgram(WebGLId) = 0;
390 
setContextLostCallback(WebGraphicsContextLostCallback * callback)391     virtual void setContextLostCallback(WebGraphicsContextLostCallback* callback) { }
setErrorMessageCallback(WebGraphicsErrorMessageCallback * callback)392     virtual void setErrorMessageCallback(WebGraphicsErrorMessageCallback* callback) { }
393     // GL_ARB_robustness
394     //
395     // This entry point must provide slightly different semantics than
396     // the GL_ARB_robustness extension; specifically, the lost context
397     // state is sticky, rather than reported only once.
getGraphicsResetStatusARB()398     virtual WGC3Denum getGraphicsResetStatusARB() { return 0; /* GL_NO_ERROR */ }
399 
400     // FIXME: make this function pure virtual once it is implemented in
401     // both command buffer port and in-process port.
getTranslatedShaderSourceANGLE(WebGLId shader)402     virtual WebString getTranslatedShaderSourceANGLE(WebGLId shader) { return WebString(); }
403 
404     // GL_CHROMIUM_iosurface
texImageIOSurface2DCHROMIUM(WGC3Denum target,WGC3Dint width,WGC3Dint height,WGC3Duint ioSurfaceId,WGC3Duint plane)405     virtual void texImageIOSurface2DCHROMIUM(WGC3Denum target, WGC3Dint width, WGC3Dint height, WGC3Duint ioSurfaceId, WGC3Duint plane) { }
406 
407     // GL_EXT_texture_storage
texStorage2DEXT(WGC3Denum target,WGC3Dint levels,WGC3Duint internalformat,WGC3Dint width,WGC3Dint height)408     virtual void texStorage2DEXT(WGC3Denum target, WGC3Dint levels, WGC3Duint internalformat,
409                                  WGC3Dint width, WGC3Dint height) { }
410 
411     // GL_EXT_occlusion_query
createQueryEXT()412     virtual WebGLId createQueryEXT() { return 0; }
deleteQueryEXT(WebGLId query)413     virtual void deleteQueryEXT(WebGLId query) { }
isQueryEXT(WebGLId query)414     virtual WGC3Dboolean isQueryEXT(WebGLId query) { return false; }
beginQueryEXT(WGC3Denum target,WebGLId query)415     virtual void beginQueryEXT(WGC3Denum target, WebGLId query) { }
endQueryEXT(WGC3Denum target)416     virtual void endQueryEXT(WGC3Denum target) { }
getQueryivEXT(WGC3Denum target,WGC3Denum pname,WGC3Dint * params)417     virtual void getQueryivEXT(WGC3Denum target, WGC3Denum pname, WGC3Dint* params) { }
getQueryObjectuivEXT(WebGLId query,WGC3Denum pname,WGC3Duint * params)418     virtual void getQueryObjectuivEXT(WebGLId query, WGC3Denum pname, WGC3Duint* params) { }
419 
420     // GL_CHROMIUM_bind_uniform_location
bindUniformLocationCHROMIUM(WebGLId program,WGC3Dint location,const WGC3Dchar * uniform)421     virtual void bindUniformLocationCHROMIUM(WebGLId program, WGC3Dint location, const WGC3Dchar* uniform) { }
422 
423     // GL_CHROMIUM_copy_texture
copyTextureCHROMIUM(WGC3Denum target,WGC3Duint sourceId,WGC3Duint destId,WGC3Dint level,WGC3Denum internalFormat,WGC3Denum destType)424     virtual void copyTextureCHROMIUM(WGC3Denum target, WGC3Duint sourceId,
425         WGC3Duint destId, WGC3Dint level, WGC3Denum internalFormat, WGC3Denum destType) { }
426 
427     // GL_CHROMIUM_shallow_flush
shallowFlushCHROMIUM()428     virtual void shallowFlushCHROMIUM() { }
shallowFinishCHROMIUM()429     virtual void shallowFinishCHROMIUM() { }
430 
431     // GL_CHROMIUM_texture_mailbox
genMailboxCHROMIUM(WGC3Dbyte * mailbox)432     virtual void genMailboxCHROMIUM(WGC3Dbyte* mailbox) { }
produceTextureCHROMIUM(WGC3Denum target,const WGC3Dbyte * mailbox)433     virtual void produceTextureCHROMIUM(WGC3Denum target, const WGC3Dbyte* mailbox) { }
consumeTextureCHROMIUM(WGC3Denum target,const WGC3Dbyte * mailbox)434     virtual void consumeTextureCHROMIUM(WGC3Denum target, const WGC3Dbyte* mailbox) { }
435 
436     // GL_EXT_debug_marker
insertEventMarkerEXT(const WGC3Dchar * marker)437     virtual void insertEventMarkerEXT(const WGC3Dchar* marker) { }
pushGroupMarkerEXT(const WGC3Dchar * marker)438     virtual void pushGroupMarkerEXT(const WGC3Dchar* marker) { }
popGroupMarkerEXT(void)439     virtual void popGroupMarkerEXT(void) { }
440 
441     // GL_OES_vertex_array_object
createVertexArrayOES()442     virtual WebGLId createVertexArrayOES() { return 0; }
deleteVertexArrayOES(WebGLId array)443     virtual void deleteVertexArrayOES(WebGLId array) { }
isVertexArrayOES(WebGLId array)444     virtual WGC3Dboolean isVertexArrayOES(WebGLId array) { return false; }
bindVertexArrayOES(WebGLId array)445     virtual void bindVertexArrayOES(WebGLId array) { }
446 
447     // GL_CHROMIUM_texture_from_image
bindTexImage2DCHROMIUM(WGC3Denum target,WGC3Dint imageId)448     virtual void bindTexImage2DCHROMIUM(WGC3Denum target, WGC3Dint imageId) { }
releaseTexImage2DCHROMIUM(WGC3Denum target,WGC3Dint imageId)449     virtual void releaseTexImage2DCHROMIUM(WGC3Denum target, WGC3Dint imageId) { }
450 
451     // GL_CHROMIUM_pixel_transfer_buffer_object
mapBufferCHROMIUM(WGC3Denum target,WGC3Denum access)452     virtual void* mapBufferCHROMIUM(WGC3Denum target, WGC3Denum access) { return 0; }
unmapBufferCHROMIUM(WGC3Denum target)453     virtual WGC3Dboolean unmapBufferCHROMIUM(WGC3Denum target) { return false; }
454 
455     // GL_CHROMIUM_async_pixel_transfers
asyncTexImage2DCHROMIUM(WGC3Denum target,WGC3Dint level,WGC3Denum internalformat,WGC3Dsizei width,WGC3Dsizei height,WGC3Dint border,WGC3Denum format,WGC3Denum type,const void * pixels)456     virtual void asyncTexImage2DCHROMIUM(WGC3Denum target, WGC3Dint level, WGC3Denum internalformat, WGC3Dsizei width, WGC3Dsizei height, WGC3Dint border, WGC3Denum format, WGC3Denum type, const void* pixels) { }
asyncTexSubImage2DCHROMIUM(WGC3Denum target,WGC3Dint level,WGC3Dint xoffset,WGC3Dint yoffset,WGC3Dsizei width,WGC3Dsizei height,WGC3Denum format,WGC3Denum type,const void * pixels)457     virtual void asyncTexSubImage2DCHROMIUM(WGC3Denum target, WGC3Dint level, WGC3Dint xoffset, WGC3Dint yoffset, WGC3Dsizei width, WGC3Dsizei height, WGC3Denum format, WGC3Denum type, const void* pixels) { }
waitAsyncTexImage2DCHROMIUM(WGC3Denum)458     virtual void waitAsyncTexImage2DCHROMIUM(WGC3Denum) { }
459 
460     // GL_EXT_draw_buffers
drawBuffersEXT(WGC3Dsizei n,const WGC3Denum * bufs)461     virtual void drawBuffersEXT(WGC3Dsizei n, const WGC3Denum* bufs) { }
462 
createGrGLInterface()463     virtual GrGLInterface* createGrGLInterface() { return 0; }
464 
465     // GL_CHROMIUM_map_image
createImageCHROMIUM(WGC3Dsizei width,WGC3Dsizei height,WGC3Denum internalformat)466     virtual WGC3Duint createImageCHROMIUM(WGC3Dsizei width, WGC3Dsizei height, WGC3Denum internalformat) { return 0; }
destroyImageCHROMIUM(WGC3Duint imageId)467     virtual void destroyImageCHROMIUM(WGC3Duint imageId) { }
getImageParameterivCHROMIUM(WGC3Duint imageId,WGC3Denum pname,WGC3Dint * params)468     virtual void getImageParameterivCHROMIUM(WGC3Duint imageId, WGC3Denum pname, WGC3Dint* params) { }
mapImageCHROMIUM(WGC3Duint imageId,WGC3Denum access)469     virtual void* mapImageCHROMIUM(WGC3Duint imageId, WGC3Denum access) { return 0; }
unmapImageCHROMIUM(WGC3Duint imageId)470     virtual void unmapImageCHROMIUM(WGC3Duint imageId) { }
471 
472     // GL_ANGLE_instanced_arrays
drawArraysInstancedANGLE(WGC3Denum mode,WGC3Dint first,WGC3Dsizei count,WGC3Dsizei primcount)473     virtual void drawArraysInstancedANGLE(WGC3Denum mode, WGC3Dint first, WGC3Dsizei count, WGC3Dsizei primcount) { }
drawElementsInstancedANGLE(WGC3Denum mode,WGC3Dsizei count,WGC3Denum type,WGC3Dintptr offset,WGC3Dsizei primcount)474     virtual void drawElementsInstancedANGLE(WGC3Denum mode, WGC3Dsizei count, WGC3Denum type, WGC3Dintptr offset, WGC3Dsizei primcount) { }
vertexAttribDivisorANGLE(WGC3Duint index,WGC3Duint divisor)475     virtual void vertexAttribDivisorANGLE(WGC3Duint index, WGC3Duint divisor) { }
476 };
477 
478 } // namespace blink
479 
480 #endif
481