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