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