1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef GPU_BLINK_WEBGRAPHICSCONTEXT3D_IMPL_H_
6 #define GPU_BLINK_WEBGRAPHICSCONTEXT3D_IMPL_H_
11 #include "base/callback.h"
12 #include "base/memory/scoped_ptr.h"
13 #include "gpu/blink/gpu_blink_export.h"
14 #include "third_party/WebKit/public/platform/WebGraphicsContext3D.h"
15 #include "third_party/WebKit/public/platform/WebString.h"
21 class GLES2ImplementationErrorMessageCallback
;
22 struct ContextCreationAttribHelper
;
28 using blink::WGC3Dbyte
;
29 using blink::WGC3Dchar
;
30 using blink::WGC3Denum
;
31 using blink::WGC3Dboolean
;
32 using blink::WGC3Dbitfield
;
33 using blink::WGC3Dint
;
34 using blink::WGC3Dsizei
;
35 using blink::WGC3Duint
;
36 using blink::WGC3Dfloat
;
37 using blink::WGC3Dclampf
;
38 using blink::WGC3Dintptr
;
39 using blink::WGC3Dsizeiptr
;
40 using blink::WGC3Duint64
;
44 class WebGraphicsContext3DErrorMessageCallback
;
46 class GPU_BLINK_EXPORT WebGraphicsContext3DImpl
47 : public NON_EXPORTED_BASE(blink::WebGraphicsContext3D
) {
49 virtual ~WebGraphicsContext3DImpl();
51 //----------------------------------------------------------------------
52 // WebGraphicsContext3D methods
54 virtual uint32_t lastFlushID();
56 virtual unsigned int insertSyncPoint();
57 virtual void waitSyncPoint(unsigned int sync_point
);
59 virtual void loseContextCHROMIUM(WGC3Denum current
, WGC3Denum other
);
61 virtual void reshapeWithScaleFactor(
62 int width
, int height
, float scale_factor
);
64 virtual void prepareTexture();
65 virtual void postSubBufferCHROMIUM(int x
, int y
, int width
, int height
);
67 virtual void activeTexture(WGC3Denum texture
);
68 virtual void attachShader(WebGLId program
, WebGLId shader
);
69 virtual void bindAttribLocation(WebGLId program
, WGC3Duint index
,
70 const WGC3Dchar
* name
);
71 virtual void bindBuffer(WGC3Denum target
, WebGLId buffer
);
72 virtual void bindFramebuffer(WGC3Denum target
, WebGLId framebuffer
);
73 virtual void bindRenderbuffer(WGC3Denum target
, WebGLId renderbuffer
);
74 virtual void bindTexture(WGC3Denum target
, WebGLId texture
);
75 virtual void blendColor(WGC3Dclampf red
, WGC3Dclampf green
,
76 WGC3Dclampf blue
, WGC3Dclampf alpha
);
77 virtual void blendEquation(WGC3Denum mode
);
78 virtual void blendEquationSeparate(WGC3Denum modeRGB
,
80 virtual void blendFunc(WGC3Denum sfactor
, WGC3Denum dfactor
);
81 virtual void blendFuncSeparate(WGC3Denum srcRGB
,
86 virtual void bufferData(WGC3Denum target
, WGC3Dsizeiptr size
,
87 const void* data
, WGC3Denum usage
);
88 virtual void bufferSubData(WGC3Denum target
, WGC3Dintptr offset
,
89 WGC3Dsizeiptr size
, const void* data
);
91 virtual WGC3Denum
checkFramebufferStatus(WGC3Denum target
);
92 virtual void clear(WGC3Dbitfield mask
);
93 virtual void clearColor(WGC3Dclampf red
, WGC3Dclampf green
,
94 WGC3Dclampf blue
, WGC3Dclampf alpha
);
95 virtual void clearDepth(WGC3Dclampf depth
);
96 virtual void clearStencil(WGC3Dint s
);
97 virtual void colorMask(WGC3Dboolean red
, WGC3Dboolean green
,
98 WGC3Dboolean blue
, WGC3Dboolean alpha
);
99 virtual void compileShader(WebGLId shader
);
101 virtual void compressedTexImage2D(WGC3Denum target
,
103 WGC3Denum internalformat
,
107 WGC3Dsizei imageSize
,
109 virtual void compressedTexSubImage2D(WGC3Denum target
,
116 WGC3Dsizei imageSize
,
118 virtual void copyTexImage2D(WGC3Denum target
,
120 WGC3Denum internalformat
,
126 virtual void copyTexSubImage2D(WGC3Denum target
,
134 virtual void cullFace(WGC3Denum mode
);
135 virtual void depthFunc(WGC3Denum func
);
136 virtual void depthMask(WGC3Dboolean flag
);
137 virtual void depthRange(WGC3Dclampf zNear
, WGC3Dclampf zFar
);
138 virtual void detachShader(WebGLId program
, WebGLId shader
);
139 virtual void disable(WGC3Denum cap
);
140 virtual void disableVertexAttribArray(WGC3Duint index
);
141 virtual void drawArrays(WGC3Denum mode
, WGC3Dint first
, WGC3Dsizei count
);
142 virtual void drawElements(WGC3Denum mode
,
147 virtual void enable(WGC3Denum cap
);
148 virtual void enableVertexAttribArray(WGC3Duint index
);
149 virtual void finish();
150 virtual void flush();
151 virtual void framebufferRenderbuffer(WGC3Denum target
,
152 WGC3Denum attachment
,
153 WGC3Denum renderbuffertarget
,
154 WebGLId renderbuffer
);
155 virtual void framebufferTexture2D(WGC3Denum target
,
156 WGC3Denum attachment
,
160 virtual void frontFace(WGC3Denum mode
);
161 virtual void generateMipmap(WGC3Denum target
);
163 virtual bool getActiveAttrib(WebGLId program
,
166 virtual bool getActiveUniform(WebGLId program
,
170 virtual void getAttachedShaders(WebGLId program
,
175 virtual WGC3Dint
getAttribLocation(WebGLId program
, const WGC3Dchar
* name
);
177 virtual void getBooleanv(WGC3Denum pname
, WGC3Dboolean
* value
);
179 virtual void getBufferParameteriv(WGC3Denum target
,
183 virtual WGC3Denum
getError();
185 virtual void getFloatv(WGC3Denum pname
, WGC3Dfloat
* value
);
187 virtual void getFramebufferAttachmentParameteriv(WGC3Denum target
,
188 WGC3Denum attachment
,
192 virtual void getIntegerv(WGC3Denum pname
, WGC3Dint
* value
);
194 virtual void getProgramiv(WebGLId program
, WGC3Denum pname
, WGC3Dint
* value
);
196 virtual blink::WebString
getProgramInfoLog(WebGLId program
);
198 virtual void getRenderbufferParameteriv(WGC3Denum target
,
202 virtual void getShaderiv(WebGLId shader
, WGC3Denum pname
, WGC3Dint
* value
);
204 virtual blink::WebString
getShaderInfoLog(WebGLId shader
);
206 virtual void getShaderPrecisionFormat(WGC3Denum shadertype
,
207 WGC3Denum precisiontype
,
209 WGC3Dint
* precision
);
211 virtual blink::WebString
getShaderSource(WebGLId shader
);
212 virtual blink::WebString
getString(WGC3Denum name
);
214 virtual void getTexParameterfv(WGC3Denum target
,
217 virtual void getTexParameteriv(WGC3Denum target
,
221 virtual void getUniformfv(WebGLId program
,
224 virtual void getUniformiv(WebGLId program
,
228 virtual WGC3Dint
getUniformLocation(WebGLId program
, const WGC3Dchar
* name
);
230 virtual void getVertexAttribfv(WGC3Duint index
, WGC3Denum pname
,
232 virtual void getVertexAttribiv(WGC3Duint index
, WGC3Denum pname
,
235 virtual WGC3Dsizeiptr
getVertexAttribOffset(WGC3Duint index
, WGC3Denum pname
);
237 virtual void hint(WGC3Denum target
, WGC3Denum mode
);
238 virtual WGC3Dboolean
isBuffer(WebGLId buffer
);
239 virtual WGC3Dboolean
isEnabled(WGC3Denum cap
);
240 virtual WGC3Dboolean
isFramebuffer(WebGLId framebuffer
);
241 virtual WGC3Dboolean
isProgram(WebGLId program
);
242 virtual WGC3Dboolean
isRenderbuffer(WebGLId renderbuffer
);
243 virtual WGC3Dboolean
isShader(WebGLId shader
);
244 virtual WGC3Dboolean
isTexture(WebGLId texture
);
245 virtual void lineWidth(WGC3Dfloat
);
246 virtual void linkProgram(WebGLId program
);
247 virtual void pixelStorei(WGC3Denum pname
, WGC3Dint param
);
248 virtual void polygonOffset(WGC3Dfloat factor
, WGC3Dfloat units
);
250 virtual void readPixels(WGC3Dint x
,
258 virtual void releaseShaderCompiler();
259 virtual void renderbufferStorage(WGC3Denum target
,
260 WGC3Denum internalformat
,
263 virtual void sampleCoverage(WGC3Dfloat value
, WGC3Dboolean invert
);
264 virtual void scissor(WGC3Dint x
, WGC3Dint y
,
265 WGC3Dsizei width
, WGC3Dsizei height
);
266 virtual void shaderSource(WebGLId shader
, const WGC3Dchar
* string
);
267 virtual void stencilFunc(WGC3Denum func
, WGC3Dint ref
, WGC3Duint mask
);
268 virtual void stencilFuncSeparate(WGC3Denum face
,
272 virtual void stencilMask(WGC3Duint mask
);
273 virtual void stencilMaskSeparate(WGC3Denum face
, WGC3Duint mask
);
274 virtual void stencilOp(WGC3Denum fail
,
277 virtual void stencilOpSeparate(WGC3Denum face
,
282 virtual void texImage2D(WGC3Denum target
,
284 WGC3Denum internalformat
,
292 virtual void texParameterf(WGC3Denum target
,
295 virtual void texParameteri(WGC3Denum target
,
299 virtual void texSubImage2D(WGC3Denum target
,
309 virtual void uniform1f(WGC3Dint location
, WGC3Dfloat x
);
310 virtual void uniform1fv(WGC3Dint location
,
311 WGC3Dsizei count
, const WGC3Dfloat
* v
);
312 virtual void uniform1i(WGC3Dint location
, WGC3Dint x
);
313 virtual void uniform1iv(WGC3Dint location
,
314 WGC3Dsizei count
, const WGC3Dint
* v
);
315 virtual void uniform2f(WGC3Dint location
, WGC3Dfloat x
, WGC3Dfloat y
);
316 virtual void uniform2fv(WGC3Dint location
,
317 WGC3Dsizei count
, const WGC3Dfloat
* v
);
318 virtual void uniform2i(WGC3Dint location
, WGC3Dint x
, WGC3Dint y
);
319 virtual void uniform2iv(WGC3Dint location
,
320 WGC3Dsizei count
, const WGC3Dint
* v
);
321 virtual void uniform3f(WGC3Dint location
,
322 WGC3Dfloat x
, WGC3Dfloat y
, WGC3Dfloat z
);
323 virtual void uniform3fv(WGC3Dint location
,
324 WGC3Dsizei count
, const WGC3Dfloat
* v
);
325 virtual void uniform3i(WGC3Dint location
,
326 WGC3Dint x
, WGC3Dint y
, WGC3Dint z
);
327 virtual void uniform3iv(WGC3Dint location
,
328 WGC3Dsizei count
, const WGC3Dint
* v
);
329 virtual void uniform4f(WGC3Dint location
,
330 WGC3Dfloat x
, WGC3Dfloat y
,
331 WGC3Dfloat z
, WGC3Dfloat w
);
332 virtual void uniform4fv(WGC3Dint location
,
333 WGC3Dsizei count
, const WGC3Dfloat
* v
);
334 virtual void uniform4i(WGC3Dint location
,
335 WGC3Dint x
, WGC3Dint y
, WGC3Dint z
, WGC3Dint w
);
336 virtual void uniform4iv(WGC3Dint location
,
337 WGC3Dsizei count
, const WGC3Dint
* v
);
338 virtual void uniformMatrix2fv(WGC3Dint location
,
340 WGC3Dboolean transpose
,
341 const WGC3Dfloat
* value
);
342 virtual void uniformMatrix3fv(WGC3Dint location
,
344 WGC3Dboolean transpose
,
345 const WGC3Dfloat
* value
);
346 virtual void uniformMatrix4fv(WGC3Dint location
,
348 WGC3Dboolean transpose
,
349 const WGC3Dfloat
* value
);
351 virtual void useProgram(WebGLId program
);
352 virtual void validateProgram(WebGLId program
);
354 virtual void vertexAttrib1f(WGC3Duint index
, WGC3Dfloat x
);
355 virtual void vertexAttrib1fv(WGC3Duint index
, const WGC3Dfloat
* values
);
356 virtual void vertexAttrib2f(WGC3Duint index
, WGC3Dfloat x
, WGC3Dfloat y
);
357 virtual void vertexAttrib2fv(WGC3Duint index
, const WGC3Dfloat
* values
);
358 virtual void vertexAttrib3f(WGC3Duint index
,
359 WGC3Dfloat x
, WGC3Dfloat y
, WGC3Dfloat z
);
360 virtual void vertexAttrib3fv(WGC3Duint index
, const WGC3Dfloat
* values
);
361 virtual void vertexAttrib4f(WGC3Duint index
,
362 WGC3Dfloat x
, WGC3Dfloat y
,
363 WGC3Dfloat z
, WGC3Dfloat w
);
364 virtual void vertexAttrib4fv(WGC3Duint index
, const WGC3Dfloat
* values
);
365 virtual void vertexAttribPointer(WGC3Duint index
,
368 WGC3Dboolean normalized
,
372 virtual void viewport(WGC3Dint x
, WGC3Dint y
,
373 WGC3Dsizei width
, WGC3Dsizei height
);
375 virtual WebGLId
createBuffer();
376 virtual WebGLId
createFramebuffer();
377 virtual WebGLId
createRenderbuffer();
378 virtual WebGLId
createTexture();
380 virtual void deleteBuffer(WebGLId
);
381 virtual void deleteFramebuffer(WebGLId
);
382 virtual void deleteRenderbuffer(WebGLId
);
383 virtual void deleteTexture(WebGLId
);
385 virtual WebGLId
createProgram();
386 virtual WebGLId
createShader(WGC3Denum
);
388 virtual void deleteProgram(WebGLId
);
389 virtual void deleteShader(WebGLId
);
391 virtual void synthesizeGLError(WGC3Denum
);
393 virtual void* mapBufferSubDataCHROMIUM(
394 WGC3Denum target
, WGC3Dintptr offset
,
395 WGC3Dsizeiptr size
, WGC3Denum access
);
396 virtual void unmapBufferSubDataCHROMIUM(const void*);
397 virtual void* mapTexSubImage2DCHROMIUM(
407 virtual void unmapTexSubImage2DCHROMIUM(const void*);
409 virtual void setVisibilityCHROMIUM(bool visible
);
411 virtual void discardFramebufferEXT(WGC3Denum target
,
412 WGC3Dsizei numAttachments
,
413 const WGC3Denum
* attachments
);
414 virtual void copyTextureToParentTextureCHROMIUM(
415 WebGLId texture
, WebGLId parentTexture
);
417 virtual blink::WebString
getRequestableExtensionsCHROMIUM();
418 virtual void requestExtensionCHROMIUM(const char*);
420 virtual void blitFramebufferCHROMIUM(
421 WGC3Dint srcX0
, WGC3Dint srcY0
, WGC3Dint srcX1
, WGC3Dint srcY1
,
422 WGC3Dint dstX0
, WGC3Dint dstY0
, WGC3Dint dstX1
, WGC3Dint dstY1
,
423 WGC3Dbitfield mask
, WGC3Denum filter
);
424 virtual void renderbufferStorageMultisampleCHROMIUM(
425 WGC3Denum target
, WGC3Dsizei samples
, WGC3Denum internalformat
,
426 WGC3Dsizei width
, WGC3Dsizei height
);
428 virtual blink::WebString
getTranslatedShaderSourceANGLE(WebGLId shader
);
430 virtual void setContextLostCallback(
431 WebGraphicsContext3D::WebGraphicsContextLostCallback
* callback
);
433 virtual void setErrorMessageCallback(
434 WebGraphicsContext3D::WebGraphicsErrorMessageCallback
* callback
);
436 virtual void texImageIOSurface2DCHROMIUM(
437 WGC3Denum target
, WGC3Dint width
, WGC3Dint height
,
438 WGC3Duint ioSurfaceId
, WGC3Duint plane
);
440 virtual void texStorage2DEXT(
441 WGC3Denum target
, WGC3Dint levels
, WGC3Duint internalformat
,
442 WGC3Dint width
, WGC3Dint height
);
444 virtual WebGLId
createQueryEXT();
445 virtual void deleteQueryEXT(WebGLId query
);
446 virtual WGC3Dboolean
isQueryEXT(WGC3Duint query
);
447 virtual void beginQueryEXT(WGC3Denum target
, WebGLId query
);
448 virtual void endQueryEXT(WGC3Denum target
);
449 virtual void getQueryivEXT(
450 WGC3Denum target
, WGC3Denum pname
, WGC3Dint
* params
);
451 virtual void getQueryObjectuivEXT(
452 WebGLId query
, WGC3Denum pname
, WGC3Duint
* params
);
454 virtual void copyTextureCHROMIUM(WGC3Denum target
, WebGLId source_id
,
455 WebGLId dest_id
, WGC3Dint level
,
456 WGC3Denum internal_format
,
457 WGC3Denum dest_type
);
459 virtual void bindUniformLocationCHROMIUM(WebGLId program
, WGC3Dint location
,
460 const WGC3Dchar
* uniform
);
462 virtual void shallowFlushCHROMIUM();
463 virtual void shallowFinishCHROMIUM();
465 virtual void genMailboxCHROMIUM(WGC3Dbyte
* mailbox
);
466 virtual void produceTextureCHROMIUM(WGC3Denum target
,
467 const WGC3Dbyte
* mailbox
);
468 virtual void produceTextureDirectCHROMIUM(WebGLId texture
, WGC3Denum target
,
469 const WGC3Dbyte
* mailbox
);
470 virtual void consumeTextureCHROMIUM(WGC3Denum target
,
471 const WGC3Dbyte
* mailbox
);
472 virtual WebGLId
createAndConsumeTextureCHROMIUM(WGC3Denum target
,
473 const WGC3Dbyte
* mailbox
);
475 virtual void genValuebuffersCHROMIUM(WGC3Dsizei count
, WebGLId
* ids
);
476 virtual WebGLId
createValuebufferCHROMIUM();
477 virtual void deleteValuebuffersCHROMIUM(WGC3Dsizei count
, WebGLId
* ids
);
478 virtual void deleteValuebufferCHROMIUM(WebGLId
);
479 virtual void bindValuebufferCHROMIUM(WGC3Denum target
, WebGLId valuebuffer
);
480 virtual WGC3Dboolean
isValuebufferCHROMIUM(WebGLId renderbuffer
);
481 virtual void subscribeValueCHROMIUM(WGC3Denum target
, WGC3Denum subscription
);
482 virtual void populateSubscribedValuesCHROMIUM(WGC3Denum target
);
483 virtual void uniformValuebufferCHROMIUM(WGC3Dint location
,
485 WGC3Denum subscription
);
486 virtual void traceBeginCHROMIUM(const WGC3Dchar
* category_name
,
487 const WGC3Dchar
* trace_name
);
488 virtual void traceEndCHROMIUM();
490 virtual void insertEventMarkerEXT(const WGC3Dchar
* marker
);
491 virtual void pushGroupMarkerEXT(const WGC3Dchar
* marker
);
492 virtual void popGroupMarkerEXT();
494 // GL_OES_vertex_array_object
495 virtual WebGLId
createVertexArrayOES();
496 virtual void deleteVertexArrayOES(WebGLId array
);
497 virtual WGC3Dboolean
isVertexArrayOES(WebGLId array
);
498 virtual void bindVertexArrayOES(WebGLId array
);
500 virtual void bindTexImage2DCHROMIUM(WGC3Denum target
, WGC3Dint image_id
);
501 virtual void releaseTexImage2DCHROMIUM(WGC3Denum target
, WGC3Dint image_id
);
503 virtual void* mapBufferCHROMIUM(WGC3Denum target
, WGC3Denum access
);
504 virtual WGC3Dboolean
unmapBufferCHROMIUM(WGC3Denum target
);
506 // Async pixel transfer functions.
507 virtual void asyncTexImage2DCHROMIUM(
510 WGC3Denum internalformat
,
517 virtual void asyncTexSubImage2DCHROMIUM(
527 virtual void waitAsyncTexImage2DCHROMIUM(WGC3Denum target
);
529 // GL_EXT_draw_buffers
530 virtual void drawBuffersEXT(
532 const WGC3Denum
* bufs
);
534 // GL_ANGLE_instanced_arrays
535 virtual void drawArraysInstancedANGLE(WGC3Denum mode
, WGC3Dint first
,
536 WGC3Dsizei count
, WGC3Dsizei primcount
);
537 virtual void drawElementsInstancedANGLE(WGC3Denum mode
, WGC3Dsizei count
,
538 WGC3Denum type
, WGC3Dintptr offset
, WGC3Dsizei primcount
);
539 virtual void vertexAttribDivisorANGLE(WGC3Duint index
, WGC3Duint divisor
);
541 // GL_CHROMIUM_gpu_memory_buffer_image
542 virtual WGC3Duint
createGpuMemoryBufferImageCHROMIUM(WGC3Dsizei width
,
544 WGC3Denum internalformat
,
546 virtual void destroyImageCHROMIUM(WGC3Duint image_id
);
548 // GL_EXT_multisampled_render_to_texture
549 virtual void framebufferTexture2DMultisampleEXT(WGC3Denum target
,
550 WGC3Denum attachment
,
555 virtual void renderbufferStorageMultisampleEXT(
556 WGC3Denum target
, WGC3Dsizei samples
, WGC3Denum internalformat
,
557 WGC3Dsizei width
, WGC3Dsizei height
);
559 // OpenGL ES 3.0 functions not represented by pre-existing extensions
560 virtual void beginTransformFeedback(WGC3Denum primitiveMode
);
561 virtual void bindBufferBase(WGC3Denum target
, WGC3Duint index
,
563 virtual void bindBufferRange(WGC3Denum target
, WGC3Duint index
,
564 WGC3Duint buffer
, WGC3Dintptr offset
, WGC3Dsizeiptr size
);
565 virtual void bindSampler(WGC3Duint unit
, WebGLId sampler
);
566 virtual void bindTransformFeedback(WGC3Denum target
,
567 WebGLId transformfeedback
);
568 virtual void clearBufferfi(WGC3Denum buffer
, WGC3Dint drawbuffer
,
569 WGC3Dfloat depth
, WGC3Dint stencil
);
570 virtual void clearBufferfv(WGC3Denum buffer
, WGC3Dint drawbuffer
,
571 const WGC3Dfloat
*value
);
572 virtual void clearBufferiv(WGC3Denum buffer
, WGC3Dint drawbuffer
,
573 const WGC3Dint
*value
);
574 virtual void clearBufferuiv(WGC3Denum buffer
, WGC3Dint drawbuffer
,
575 const WGC3Duint
*value
);
576 //virtual WGC3Denum clientWaitSync(WebGLId sync, WGC3Dbitfield flags,
577 // WGC3Duint64 timeout);
578 //virtual void compressedTexImage3D(WGC3Denum target, WGC3Dint level,
579 // WGC3Denum internalformat, WGC3Dsizei width, WGC3Dsizei height,
580 // WGC3Dsizei depth, WGC3Dint border, WGC3Dsizei imageSize,
581 // const void *data);
582 //virtual void compressedTexSubImage3D(WGC3Denum target, WGC3Dint level,
583 // WGC3Dint xoffset, WGC3Dint yoffset, WGC3Dint zoffset, WGC3Dsizei width,
584 // WGC3Dsizei height, WGC3Dsizei depth, WGC3Denum format,
585 // WGC3Dsizei imageSize, const void *data);
586 virtual void copyBufferSubData(WGC3Denum readTarget
, WGC3Denum writeTarget
,
587 WGC3Dintptr readOffset
, WGC3Dintptr writeOffset
, WGC3Dsizeiptr size
);
588 virtual void copyTexSubImage3D(WGC3Denum target
, WGC3Dint level
,
589 WGC3Dint xoffset
, WGC3Dint yoffset
, WGC3Dint zoffset
, WGC3Dint x
,
590 WGC3Dint y
, WGC3Dsizei width
, WGC3Dsizei height
);
591 virtual WebGLId
createSampler();
592 virtual WebGLId
createTransformFeedback();
593 virtual void deleteSampler(WebGLId sampler
);
594 //virtual void deleteSync(WebGLId sync);
595 virtual void deleteTransformFeedback(WebGLId transformfeedback
);
596 virtual void endTransformFeedback(void);
597 //virtual WebGLId fenceSync(WGC3Denum condition, WGC3Dbitfield flags);
598 virtual void framebufferTextureLayer(WGC3Denum target
, WGC3Denum attachment
,
599 WGC3Duint texture
, WGC3Dint level
, WGC3Dint layer
);
600 virtual void getActiveUniformBlockName(WGC3Duint program
,
601 WGC3Duint uniformBlockIndex
, WGC3Dsizei bufSize
, WGC3Dsizei
*length
,
602 WGC3Dchar
*uniformBlockName
);
603 virtual void getActiveUniformBlockiv(WGC3Duint program
,
604 WGC3Duint uniformBlockIndex
, WGC3Denum pname
, WGC3Dint
*params
);
605 //virtual void getActiveUniformsiv(WGC3Duint program, WGC3Dsizei uniformCount,
606 // const WGC3Duint *uniformIndices, WGC3Denum pname, WGC3Dint *params);
607 virtual WGC3Dint
getFragDataLocation(WGC3Duint program
,
608 const WGC3Dchar
*name
);
609 virtual void getInternalformativ(WGC3Denum target
, WGC3Denum internalformat
,
610 WGC3Denum pname
, WGC3Dsizei bufSize
, WGC3Dint
*params
);
611 virtual void getSamplerParameterfv(WGC3Duint sampler
, WGC3Denum pname
,
613 virtual void getSamplerParameteriv(WGC3Duint sampler
, WGC3Denum pname
,
615 //virtual void getTransformFeedbackVarying(WGC3Duint program, WGC3Duint index,
616 // WGC3Dsizei bufSize, WGC3Dsizei *length, WGC3Dsizei *size,
617 // WGC3Denum *type, WGC3Dchar *name);
618 virtual WGC3Duint
getUniformBlockIndex(WGC3Duint program
,
619 const WGC3Dchar
*uniformBlockName
);
620 //virtual void getUniformIndices(WGC3Duint program, WGC3Dsizei uniformCount,
621 // const WGC3Dchar *const*uniformNames, WGC3Duint *uniformIndices);
622 //virtual void getUniformuiv(WGC3Duint program, WGC3Dint location,
623 // WGC3Duint *params);
624 //virtual void getVertexAttribIiv(WGC3Duint index, WGC3Denum pname,
625 // WGC3Dint *params);
626 //virtual void getVertexAttribIuiv(WGC3Duint index, WGC3Denum pname,
627 // WGC3Duint *params);
628 virtual void invalidateFramebuffer(WGC3Denum target
,
629 WGC3Dsizei numAttachments
, const WGC3Denum
*attachments
);
630 virtual void invalidateSubFramebuffer(WGC3Denum target
,
631 WGC3Dsizei numAttachments
, const WGC3Denum
*attachments
, WGC3Dint x
,
632 WGC3Dint y
, WGC3Dsizei width
, WGC3Dsizei height
);
633 virtual WGC3Dboolean
isSampler(WebGLId sampler
);
634 //virtual WGC3Dboolean isSync(WebGLId sync);
635 virtual WGC3Dboolean
isTransformFeedback(WGC3Duint id
);
636 virtual void pauseTransformFeedback(void);
637 //virtual void programParameteri(WGC3Duint program, WGC3Denum pname,
639 virtual void readBuffer(WGC3Denum src
);
640 virtual void resumeTransformFeedback(void);
641 virtual void samplerParameterf(WGC3Duint sampler
, WGC3Denum pname
,
643 virtual void samplerParameterfv(WGC3Duint sampler
, WGC3Denum pname
,
644 const WGC3Dfloat
*param
);
645 virtual void samplerParameteri(WGC3Duint sampler
, WGC3Denum pname
,
647 virtual void samplerParameteriv(WGC3Duint sampler
, WGC3Denum pname
,
648 const WGC3Dint
*param
);
649 virtual void texImage3D(WGC3Denum target
, WGC3Dint level
,
650 WGC3Dint internalformat
, WGC3Dsizei width
, WGC3Dsizei height
,
651 WGC3Dsizei depth
, WGC3Dint border
, WGC3Denum format
, WGC3Denum type
,
653 virtual void texStorage3D(WGC3Denum target
, WGC3Dsizei levels
,
654 WGC3Denum internalformat
, WGC3Dsizei width
, WGC3Dsizei height
,
656 virtual void texSubImage3D(WGC3Denum target
, WGC3Dint level
, WGC3Dint xoffset
,
657 WGC3Dint yoffset
, WGC3Dint zoffset
, WGC3Dsizei width
, WGC3Dsizei height
,
658 WGC3Dsizei depth
, WGC3Denum format
, WGC3Denum type
, const void *pixels
);
659 virtual void transformFeedbackVaryings(WGC3Duint program
, WGC3Dsizei count
,
660 const WGC3Dchar
*const*varyings
, WGC3Denum bufferMode
);
661 virtual void uniform1ui(WGC3Dint location
, WGC3Duint x
);
662 virtual void uniform1uiv(WGC3Dint location
, WGC3Dsizei count
,
663 const WGC3Duint
*value
);
664 virtual void uniform2ui(WGC3Dint location
, WGC3Duint x
, WGC3Duint y
);
665 virtual void uniform2uiv(WGC3Dint location
, WGC3Dsizei count
,
666 const WGC3Duint
*value
);
667 virtual void uniform3ui(WGC3Dint location
, WGC3Duint x
, WGC3Duint y
,
669 virtual void uniform3uiv(WGC3Dint location
, WGC3Dsizei count
,
670 const WGC3Duint
*value
);
671 virtual void uniform4ui(WGC3Dint location
, WGC3Duint x
, WGC3Duint y
,
672 WGC3Duint z
, WGC3Duint w
);
673 virtual void uniform4uiv(WGC3Dint location
, WGC3Dsizei count
,
674 const WGC3Duint
*value
);
675 virtual void uniformBlockBinding(WGC3Duint program
,
676 WGC3Duint uniformBlockIndex
, WGC3Duint uniformBlockBinding
);
677 virtual void uniformMatrix2x3fv(WGC3Dint location
, WGC3Dsizei count
,
678 WGC3Dboolean transpose
, const WGC3Dfloat
* value
);
679 virtual void uniformMatrix2x4fv(WGC3Dint location
, WGC3Dsizei count
,
680 WGC3Dboolean transpose
, const WGC3Dfloat
* value
);
681 virtual void uniformMatrix3x2fv(WGC3Dint location
, WGC3Dsizei count
,
682 WGC3Dboolean transpose
, const WGC3Dfloat
* value
);
683 virtual void uniformMatrix3x4fv(WGC3Dint location
, WGC3Dsizei count
,
684 WGC3Dboolean transpose
, const WGC3Dfloat
* value
);
685 virtual void uniformMatrix4x2fv(WGC3Dint location
, WGC3Dsizei count
,
686 WGC3Dboolean transpose
, const WGC3Dfloat
* value
);
687 virtual void uniformMatrix4x3fv(WGC3Dint location
, WGC3Dsizei count
,
688 WGC3Dboolean transpose
, const WGC3Dfloat
* value
);
689 virtual void vertexAttribI4i(WGC3Duint index
, WGC3Dint x
, WGC3Dint y
,
690 WGC3Dint z
, WGC3Dint w
);
691 virtual void vertexAttribI4iv(WGC3Duint index
, const WGC3Dint
*v
);
692 virtual void vertexAttribI4ui(WGC3Duint index
, WGC3Duint x
, WGC3Duint y
,
693 WGC3Duint z
, WGC3Duint w
);
694 virtual void vertexAttribI4uiv(WGC3Duint index
, const WGC3Duint
*v
);
695 virtual void vertexAttribIPointer(WGC3Duint index
, WGC3Dint size
,
696 WGC3Denum type
, WGC3Dsizei stride
, WGC3Dintptr pointer
);
697 //virtual void waitSync(WebGLId sync, WGC3Dbitfield flags,
698 // WGC3Duint64 timeout);
700 virtual GrGLInterface
* createGrGLInterface();
702 ::gpu::gles2::GLES2Interface
* GetGLInterface() {
706 // Convert WebGL context creation attributes into command buffer / EGL size
708 static void ConvertAttributes(
709 const blink::WebGraphicsContext3D::Attributes
& attributes
,
710 ::gpu::gles2::ContextCreationAttribHelper
* output_attribs
);
713 friend class WebGraphicsContext3DErrorMessageCallback
;
715 WebGraphicsContext3DImpl();
717 ::gpu::gles2::GLES2ImplementationErrorMessageCallback
*
718 getErrorMessageCallback();
719 virtual void OnErrorMessage(const std::string
& message
, int id
);
721 void setGLInterface(::gpu::gles2::GLES2Interface
* gl
) {
726 bool initialize_failed_
;
728 WebGraphicsContext3D::WebGraphicsContextLostCallback
* context_lost_callback_
;
729 WGC3Denum context_lost_reason_
;
731 WebGraphicsContext3D::WebGraphicsErrorMessageCallback
*
732 error_message_callback_
;
733 scoped_ptr
<WebGraphicsContext3DErrorMessageCallback
>
734 client_error_message_callback_
;
736 // Errors raised by synthesizeGLError().
737 std::vector
<WGC3Denum
> synthetic_errors_
;
739 ::gpu::gles2::GLES2Interface
* gl_
;
740 bool lose_context_when_out_of_memory_
;
744 } // namespace gpu_blink
746 #endif // GPU_BLINK_WEBGRAPHICSCONTEXT3D_IMPL_H_