Revert of Roll src/third_party/WebKit e0eac24:489c548 (svn 193311:193320) (patchset...
[chromium-blink-merge.git] / gpu / blink / webgraphicscontext3d_impl.h
blobbde6406cee6d29d23c7789cd2d24bcd562c607e7
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_
8 #include <string>
9 #include <vector>
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"
17 namespace gpu {
19 namespace gles2 {
20 class GLES2Interface;
21 class GLES2ImplementationErrorMessageCallback;
22 struct ContextCreationAttribHelper;
26 namespace gpu_blink {
28 class WebGraphicsContext3DErrorMessageCallback;
30 class GPU_BLINK_EXPORT WebGraphicsContext3DImpl
31 : public NON_EXPORTED_BASE(blink::WebGraphicsContext3D) {
32 public:
33 virtual ~WebGraphicsContext3DImpl();
35 //----------------------------------------------------------------------
36 // WebGraphicsContext3D methods
38 virtual uint32_t lastFlushID();
40 virtual unsigned int insertSyncPoint();
41 virtual void waitSyncPoint(unsigned int sync_point);
43 virtual void loseContextCHROMIUM(blink::WGC3Denum current,
44 blink::WGC3Denum other);
46 virtual void reshapeWithScaleFactor(
47 int width, int height, float scale_factor);
49 virtual void prepareTexture();
50 virtual void postSubBufferCHROMIUM(int x, int y, int width, int height);
52 virtual void activeTexture(blink::WGC3Denum texture);
53 virtual void attachShader(blink::WebGLId program, blink::WebGLId shader);
54 virtual void bindAttribLocation(blink::WebGLId program,
55 blink::WGC3Duint index,
56 const blink::WGC3Dchar* name);
57 virtual void bindBuffer(blink::WGC3Denum target, blink::WebGLId buffer);
58 virtual void bindFramebuffer(blink::WGC3Denum target,
59 blink::WebGLId framebuffer);
60 virtual void bindRenderbuffer(blink::WGC3Denum target,
61 blink::WebGLId renderbuffer);
62 virtual void bindTexture(blink::WGC3Denum target, blink::WebGLId texture);
63 virtual void blendColor(blink::WGC3Dclampf red,
64 blink::WGC3Dclampf green,
65 blink::WGC3Dclampf blue,
66 blink::WGC3Dclampf alpha);
67 virtual void blendEquation(blink::WGC3Denum mode);
68 virtual void blendEquationSeparate(blink::WGC3Denum modeRGB,
69 blink::WGC3Denum modeAlpha);
70 virtual void blendFunc(blink::WGC3Denum sfactor, blink::WGC3Denum dfactor);
71 virtual void blendFuncSeparate(blink::WGC3Denum srcRGB,
72 blink::WGC3Denum dstRGB,
73 blink::WGC3Denum srcAlpha,
74 blink::WGC3Denum dstAlpha);
76 virtual void bufferData(blink::WGC3Denum target,
77 blink::WGC3Dsizeiptr size,
78 const void* data,
79 blink::WGC3Denum usage);
80 virtual void bufferSubData(blink::WGC3Denum target,
81 blink::WGC3Dintptr offset,
82 blink::WGC3Dsizeiptr size,
83 const void* data);
85 virtual blink::WGC3Denum checkFramebufferStatus(blink::WGC3Denum target);
86 virtual void clear(blink::WGC3Dbitfield mask);
87 virtual void clearColor(blink::WGC3Dclampf red,
88 blink::WGC3Dclampf green,
89 blink::WGC3Dclampf blue,
90 blink::WGC3Dclampf alpha);
91 virtual void clearDepth(blink::WGC3Dclampf depth);
92 virtual void clearStencil(blink::WGC3Dint s);
93 virtual void colorMask(blink::WGC3Dboolean red,
94 blink::WGC3Dboolean green,
95 blink::WGC3Dboolean blue,
96 blink::WGC3Dboolean alpha);
97 virtual void compileShader(blink::WebGLId shader);
99 virtual void compressedTexImage2D(blink::WGC3Denum target,
100 blink::WGC3Dint level,
101 blink::WGC3Denum internalformat,
102 blink::WGC3Dsizei width,
103 blink::WGC3Dsizei height,
104 blink::WGC3Dint border,
105 blink::WGC3Dsizei imageSize,
106 const void* data);
107 virtual void compressedTexSubImage2D(blink::WGC3Denum target,
108 blink::WGC3Dint level,
109 blink::WGC3Dint xoffset,
110 blink::WGC3Dint yoffset,
111 blink::WGC3Dsizei width,
112 blink::WGC3Dsizei height,
113 blink::WGC3Denum format,
114 blink::WGC3Dsizei imageSize,
115 const void* data);
116 virtual void copyTexImage2D(blink::WGC3Denum target,
117 blink::WGC3Dint level,
118 blink::WGC3Denum internalformat,
119 blink::WGC3Dint x,
120 blink::WGC3Dint y,
121 blink::WGC3Dsizei width,
122 blink::WGC3Dsizei height,
123 blink::WGC3Dint border);
124 virtual void copyTexSubImage2D(blink::WGC3Denum target,
125 blink::WGC3Dint level,
126 blink::WGC3Dint xoffset,
127 blink::WGC3Dint yoffset,
128 blink::WGC3Dint x,
129 blink::WGC3Dint y,
130 blink::WGC3Dsizei width,
131 blink::WGC3Dsizei height);
132 virtual void cullFace(blink::WGC3Denum mode);
133 virtual void depthFunc(blink::WGC3Denum func);
134 virtual void depthMask(blink::WGC3Dboolean flag);
135 virtual void depthRange(blink::WGC3Dclampf zNear, blink::WGC3Dclampf zFar);
136 virtual void detachShader(blink::WebGLId program, blink::WebGLId shader);
137 virtual void disable(blink::WGC3Denum cap);
138 virtual void disableVertexAttribArray(blink::WGC3Duint index);
139 virtual void drawArrays(blink::WGC3Denum mode,
140 blink::WGC3Dint first,
141 blink::WGC3Dsizei count);
142 virtual void drawElements(blink::WGC3Denum mode,
143 blink::WGC3Dsizei count,
144 blink::WGC3Denum type,
145 blink::WGC3Dintptr offset);
147 virtual void enable(blink::WGC3Denum cap);
148 virtual void enableVertexAttribArray(blink::WGC3Duint index);
149 virtual void finish();
150 virtual void flush();
151 virtual void framebufferRenderbuffer(blink::WGC3Denum target,
152 blink::WGC3Denum attachment,
153 blink::WGC3Denum renderbuffertarget,
154 blink::WebGLId renderbuffer);
155 virtual void framebufferTexture2D(blink::WGC3Denum target,
156 blink::WGC3Denum attachment,
157 blink::WGC3Denum textarget,
158 blink::WebGLId texture,
159 blink::WGC3Dint level);
160 virtual void frontFace(blink::WGC3Denum mode);
161 virtual void generateMipmap(blink::WGC3Denum target);
163 virtual bool getActiveAttrib(blink::WebGLId program,
164 blink::WGC3Duint index,
165 ActiveInfo&);
166 virtual bool getActiveUniform(blink::WebGLId program,
167 blink::WGC3Duint index,
168 ActiveInfo&);
170 virtual void getAttachedShaders(blink::WebGLId program,
171 blink::WGC3Dsizei maxCount,
172 blink::WGC3Dsizei* count,
173 blink::WebGLId* shaders);
175 virtual blink::WGC3Dint getAttribLocation(blink::WebGLId program,
176 const blink::WGC3Dchar* name);
178 virtual void getBooleanv(blink::WGC3Denum pname, blink::WGC3Dboolean* value);
180 virtual void getBufferParameteriv(blink::WGC3Denum target,
181 blink::WGC3Denum pname,
182 blink::WGC3Dint* value);
184 virtual blink::WGC3Denum getError();
186 virtual void getFloatv(blink::WGC3Denum pname, blink::WGC3Dfloat* value);
188 virtual void getFramebufferAttachmentParameteriv(blink::WGC3Denum target,
189 blink::WGC3Denum attachment,
190 blink::WGC3Denum pname,
191 blink::WGC3Dint* value);
193 virtual void getIntegerv(blink::WGC3Denum pname, blink::WGC3Dint* value);
195 virtual void getProgramiv(blink::WebGLId program,
196 blink::WGC3Denum pname,
197 blink::WGC3Dint* value);
199 virtual blink::WebString getProgramInfoLog(blink::WebGLId program);
201 virtual void getRenderbufferParameteriv(blink::WGC3Denum target,
202 blink::WGC3Denum pname,
203 blink::WGC3Dint* value);
205 virtual void getShaderiv(blink::WebGLId shader,
206 blink::WGC3Denum pname,
207 blink::WGC3Dint* value);
209 virtual blink::WebString getShaderInfoLog(blink::WebGLId shader);
211 virtual void getShaderPrecisionFormat(blink::WGC3Denum shadertype,
212 blink::WGC3Denum precisiontype,
213 blink::WGC3Dint* range,
214 blink::WGC3Dint* precision);
216 virtual blink::WebString getShaderSource(blink::WebGLId shader);
217 virtual blink::WebString getString(blink::WGC3Denum name);
219 virtual void getTexParameterfv(blink::WGC3Denum target,
220 blink::WGC3Denum pname,
221 blink::WGC3Dfloat* value);
222 virtual void getTexParameteriv(blink::WGC3Denum target,
223 blink::WGC3Denum pname,
224 blink::WGC3Dint* value);
226 virtual void getUniformfv(blink::WebGLId program,
227 blink::WGC3Dint location,
228 blink::WGC3Dfloat* value);
229 virtual void getUniformiv(blink::WebGLId program,
230 blink::WGC3Dint location,
231 blink::WGC3Dint* value);
233 virtual blink::WGC3Dint getUniformLocation(blink::WebGLId program,
234 const blink::WGC3Dchar* name);
236 virtual void getVertexAttribfv(blink::WGC3Duint index,
237 blink::WGC3Denum pname,
238 blink::WGC3Dfloat* value);
239 virtual void getVertexAttribiv(blink::WGC3Duint index,
240 blink::WGC3Denum pname,
241 blink::WGC3Dint* value);
243 virtual blink::WGC3Dsizeiptr getVertexAttribOffset(blink::WGC3Duint index,
244 blink::WGC3Denum pname);
246 virtual void hint(blink::WGC3Denum target, blink::WGC3Denum mode);
247 virtual blink::WGC3Dboolean isBuffer(blink::WebGLId buffer);
248 virtual blink::WGC3Dboolean isEnabled(blink::WGC3Denum cap);
249 virtual blink::WGC3Dboolean isFramebuffer(blink::WebGLId framebuffer);
250 virtual blink::WGC3Dboolean isProgram(blink::WebGLId program);
251 virtual blink::WGC3Dboolean isRenderbuffer(blink::WebGLId renderbuffer);
252 virtual blink::WGC3Dboolean isShader(blink::WebGLId shader);
253 virtual blink::WGC3Dboolean isTexture(blink::WebGLId texture);
254 virtual void lineWidth(blink::WGC3Dfloat);
255 virtual void linkProgram(blink::WebGLId program);
256 virtual void pixelStorei(blink::WGC3Denum pname, blink::WGC3Dint param);
257 virtual void polygonOffset(blink::WGC3Dfloat factor, blink::WGC3Dfloat units);
259 virtual void readPixels(blink::WGC3Dint x,
260 blink::WGC3Dint y,
261 blink::WGC3Dsizei width,
262 blink::WGC3Dsizei height,
263 blink::WGC3Denum format,
264 blink::WGC3Denum type,
265 void* pixels);
267 virtual void releaseShaderCompiler();
268 virtual void renderbufferStorage(blink::WGC3Denum target,
269 blink::WGC3Denum internalformat,
270 blink::WGC3Dsizei width,
271 blink::WGC3Dsizei height);
272 virtual void sampleCoverage(blink::WGC3Dfloat value,
273 blink::WGC3Dboolean invert);
274 virtual void scissor(blink::WGC3Dint x,
275 blink::WGC3Dint y,
276 blink::WGC3Dsizei width,
277 blink::WGC3Dsizei height);
278 virtual void shaderSource(blink::WebGLId shader,
279 const blink::WGC3Dchar* string);
280 virtual void stencilFunc(blink::WGC3Denum func,
281 blink::WGC3Dint ref,
282 blink::WGC3Duint mask);
283 virtual void stencilFuncSeparate(blink::WGC3Denum face,
284 blink::WGC3Denum func,
285 blink::WGC3Dint ref,
286 blink::WGC3Duint mask);
287 virtual void stencilMask(blink::WGC3Duint mask);
288 virtual void stencilMaskSeparate(blink::WGC3Denum face,
289 blink::WGC3Duint mask);
290 virtual void stencilOp(blink::WGC3Denum fail,
291 blink::WGC3Denum zfail,
292 blink::WGC3Denum zpass);
293 virtual void stencilOpSeparate(blink::WGC3Denum face,
294 blink::WGC3Denum fail,
295 blink::WGC3Denum zfail,
296 blink::WGC3Denum zpass);
298 virtual void texImage2D(blink::WGC3Denum target,
299 blink::WGC3Dint level,
300 blink::WGC3Denum internalformat,
301 blink::WGC3Dsizei width,
302 blink::WGC3Dsizei height,
303 blink::WGC3Dint border,
304 blink::WGC3Denum format,
305 blink::WGC3Denum type,
306 const void* pixels);
308 virtual void texParameterf(blink::WGC3Denum target,
309 blink::WGC3Denum pname,
310 blink::WGC3Dfloat param);
311 virtual void texParameteri(blink::WGC3Denum target,
312 blink::WGC3Denum pname,
313 blink::WGC3Dint param);
315 virtual void texSubImage2D(blink::WGC3Denum target,
316 blink::WGC3Dint level,
317 blink::WGC3Dint xoffset,
318 blink::WGC3Dint yoffset,
319 blink::WGC3Dsizei width,
320 blink::WGC3Dsizei height,
321 blink::WGC3Denum format,
322 blink::WGC3Denum type,
323 const void* pixels);
325 virtual void uniform1f(blink::WGC3Dint location, blink::WGC3Dfloat x);
326 virtual void uniform1fv(blink::WGC3Dint location,
327 blink::WGC3Dsizei count,
328 const blink::WGC3Dfloat* v);
329 virtual void uniform1i(blink::WGC3Dint location, blink::WGC3Dint x);
330 virtual void uniform1iv(blink::WGC3Dint location,
331 blink::WGC3Dsizei count,
332 const blink::WGC3Dint* v);
333 virtual void uniform2f(blink::WGC3Dint location,
334 blink::WGC3Dfloat x,
335 blink::WGC3Dfloat y);
336 virtual void uniform2fv(blink::WGC3Dint location,
337 blink::WGC3Dsizei count,
338 const blink::WGC3Dfloat* v);
339 virtual void uniform2i(blink::WGC3Dint location,
340 blink::WGC3Dint x,
341 blink::WGC3Dint y);
342 virtual void uniform2iv(blink::WGC3Dint location,
343 blink::WGC3Dsizei count,
344 const blink::WGC3Dint* v);
345 virtual void uniform3f(blink::WGC3Dint location,
346 blink::WGC3Dfloat x,
347 blink::WGC3Dfloat y,
348 blink::WGC3Dfloat z);
349 virtual void uniform3fv(blink::WGC3Dint location,
350 blink::WGC3Dsizei count,
351 const blink::WGC3Dfloat* v);
352 virtual void uniform3i(blink::WGC3Dint location,
353 blink::WGC3Dint x,
354 blink::WGC3Dint y,
355 blink::WGC3Dint z);
356 virtual void uniform3iv(blink::WGC3Dint location,
357 blink::WGC3Dsizei count,
358 const blink::WGC3Dint* v);
359 virtual void uniform4f(blink::WGC3Dint location,
360 blink::WGC3Dfloat x,
361 blink::WGC3Dfloat y,
362 blink::WGC3Dfloat z,
363 blink::WGC3Dfloat w);
364 virtual void uniform4fv(blink::WGC3Dint location,
365 blink::WGC3Dsizei count,
366 const blink::WGC3Dfloat* v);
367 virtual void uniform4i(blink::WGC3Dint location,
368 blink::WGC3Dint x,
369 blink::WGC3Dint y,
370 blink::WGC3Dint z,
371 blink::WGC3Dint w);
372 virtual void uniform4iv(blink::WGC3Dint location,
373 blink::WGC3Dsizei count,
374 const blink::WGC3Dint* v);
375 virtual void uniformMatrix2fv(blink::WGC3Dint location,
376 blink::WGC3Dsizei count,
377 blink::WGC3Dboolean transpose,
378 const blink::WGC3Dfloat* value);
379 virtual void uniformMatrix3fv(blink::WGC3Dint location,
380 blink::WGC3Dsizei count,
381 blink::WGC3Dboolean transpose,
382 const blink::WGC3Dfloat* value);
383 virtual void uniformMatrix4fv(blink::WGC3Dint location,
384 blink::WGC3Dsizei count,
385 blink::WGC3Dboolean transpose,
386 const blink::WGC3Dfloat* value);
388 virtual void useProgram(blink::WebGLId program);
389 virtual void validateProgram(blink::WebGLId program);
391 virtual void vertexAttrib1f(blink::WGC3Duint index, blink::WGC3Dfloat x);
392 virtual void vertexAttrib1fv(blink::WGC3Duint index,
393 const blink::WGC3Dfloat* values);
394 virtual void vertexAttrib2f(blink::WGC3Duint index,
395 blink::WGC3Dfloat x,
396 blink::WGC3Dfloat y);
397 virtual void vertexAttrib2fv(blink::WGC3Duint index,
398 const blink::WGC3Dfloat* values);
399 virtual void vertexAttrib3f(blink::WGC3Duint index,
400 blink::WGC3Dfloat x,
401 blink::WGC3Dfloat y,
402 blink::WGC3Dfloat z);
403 virtual void vertexAttrib3fv(blink::WGC3Duint index,
404 const blink::WGC3Dfloat* values);
405 virtual void vertexAttrib4f(blink::WGC3Duint index,
406 blink::WGC3Dfloat x,
407 blink::WGC3Dfloat y,
408 blink::WGC3Dfloat z,
409 blink::WGC3Dfloat w);
410 virtual void vertexAttrib4fv(blink::WGC3Duint index,
411 const blink::WGC3Dfloat* values);
412 virtual void vertexAttribPointer(blink::WGC3Duint index,
413 blink::WGC3Dint size,
414 blink::WGC3Denum type,
415 blink::WGC3Dboolean normalized,
416 blink::WGC3Dsizei stride,
417 blink::WGC3Dintptr offset);
419 virtual void viewport(blink::WGC3Dint x,
420 blink::WGC3Dint y,
421 blink::WGC3Dsizei width,
422 blink::WGC3Dsizei height);
424 virtual blink::WebGLId createBuffer();
425 virtual blink::WebGLId createFramebuffer();
426 virtual blink::WebGLId createRenderbuffer();
427 virtual blink::WebGLId createTexture();
429 virtual void deleteBuffer(blink::WebGLId);
430 virtual void deleteFramebuffer(blink::WebGLId);
431 virtual void deleteRenderbuffer(blink::WebGLId);
432 virtual void deleteTexture(blink::WebGLId);
434 virtual blink::WebGLId createProgram();
435 virtual blink::WebGLId createShader(blink::WGC3Denum);
437 virtual void deleteProgram(blink::WebGLId);
438 virtual void deleteShader(blink::WebGLId);
440 virtual void synthesizeGLError(blink::WGC3Denum);
442 virtual void* mapBufferSubDataCHROMIUM(blink::WGC3Denum target,
443 blink::WGC3Dintptr offset,
444 blink::WGC3Dsizeiptr size,
445 blink::WGC3Denum access);
446 virtual void unmapBufferSubDataCHROMIUM(const void*);
447 virtual void* mapTexSubImage2DCHROMIUM(blink::WGC3Denum target,
448 blink::WGC3Dint level,
449 blink::WGC3Dint xoffset,
450 blink::WGC3Dint yoffset,
451 blink::WGC3Dsizei width,
452 blink::WGC3Dsizei height,
453 blink::WGC3Denum format,
454 blink::WGC3Denum type,
455 blink::WGC3Denum access);
456 virtual void unmapTexSubImage2DCHROMIUM(const void*);
458 virtual void setVisibilityCHROMIUM(bool visible);
460 virtual void discardFramebufferEXT(blink::WGC3Denum target,
461 blink::WGC3Dsizei numAttachments,
462 const blink::WGC3Denum* attachments);
463 virtual void copyTextureToParentTextureCHROMIUM(blink::WebGLId texture,
464 blink::WebGLId parentTexture);
466 virtual blink::WebString getRequestableExtensionsCHROMIUM();
467 virtual void requestExtensionCHROMIUM(const char*);
469 virtual void blitFramebufferCHROMIUM(blink::WGC3Dint srcX0,
470 blink::WGC3Dint srcY0,
471 blink::WGC3Dint srcX1,
472 blink::WGC3Dint srcY1,
473 blink::WGC3Dint dstX0,
474 blink::WGC3Dint dstY0,
475 blink::WGC3Dint dstX1,
476 blink::WGC3Dint dstY1,
477 blink::WGC3Dbitfield mask,
478 blink::WGC3Denum filter);
479 virtual void renderbufferStorageMultisampleCHROMIUM(
480 blink::WGC3Denum target,
481 blink::WGC3Dsizei samples,
482 blink::WGC3Denum internalformat,
483 blink::WGC3Dsizei width,
484 blink::WGC3Dsizei height);
486 virtual blink::WebString getTranslatedShaderSourceANGLE(
487 blink::WebGLId shader);
489 virtual void setContextLostCallback(
490 WebGraphicsContext3D::WebGraphicsContextLostCallback* callback);
492 virtual void setErrorMessageCallback(
493 WebGraphicsContext3D::WebGraphicsErrorMessageCallback* callback);
495 virtual void texImageIOSurface2DCHROMIUM(blink::WGC3Denum target,
496 blink::WGC3Dint width,
497 blink::WGC3Dint height,
498 blink::WGC3Duint ioSurfaceId,
499 blink::WGC3Duint plane);
501 virtual void texStorage2DEXT(blink::WGC3Denum target,
502 blink::WGC3Dint levels,
503 blink::WGC3Duint internalformat,
504 blink::WGC3Dint width,
505 blink::WGC3Dint height);
507 virtual blink::WebGLId createQueryEXT();
508 virtual void deleteQueryEXT(blink::WebGLId query);
509 virtual blink::WGC3Dboolean isQueryEXT(blink::WGC3Duint query);
510 virtual void beginQueryEXT(blink::WGC3Denum target, blink::WebGLId query);
511 virtual void endQueryEXT(blink::WGC3Denum target);
512 virtual void getQueryivEXT(blink::WGC3Denum target,
513 blink::WGC3Denum pname,
514 blink::WGC3Dint* params);
515 virtual void getQueryObjectuivEXT(blink::WebGLId query,
516 blink::WGC3Denum pname,
517 blink::WGC3Duint* params);
519 void copyTextureCHROMIUM(blink::WGC3Denum target,
520 blink::WebGLId source_id,
521 blink::WebGLId dest_id,
522 blink::WGC3Denum internal_format,
523 blink::WGC3Denum dest_type) override;
525 void copySubTextureCHROMIUM(blink::WGC3Denum target,
526 blink::WebGLId source_id,
527 blink::WebGLId dest_id,
528 blink::WGC3Dint xoffset,
529 blink::WGC3Dint yoffset) override;
531 virtual void bindUniformLocationCHROMIUM(blink::WebGLId program,
532 blink::WGC3Dint location,
533 const blink::WGC3Dchar* uniform);
535 virtual void shallowFlushCHROMIUM();
536 virtual void shallowFinishCHROMIUM();
538 virtual void genMailboxCHROMIUM(blink::WGC3Dbyte* mailbox);
539 virtual void produceTextureCHROMIUM(blink::WGC3Denum target,
540 const blink::WGC3Dbyte* mailbox);
541 virtual void produceTextureDirectCHROMIUM(blink::WebGLId texture,
542 blink::WGC3Denum target,
543 const blink::WGC3Dbyte* mailbox);
544 virtual void consumeTextureCHROMIUM(blink::WGC3Denum target,
545 const blink::WGC3Dbyte* mailbox);
546 virtual blink::WebGLId createAndConsumeTextureCHROMIUM(
547 blink::WGC3Denum target,
548 const blink::WGC3Dbyte* mailbox);
550 virtual void genValuebuffersCHROMIUM(blink::WGC3Dsizei count,
551 blink::WebGLId* ids);
552 virtual blink::WebGLId createValuebufferCHROMIUM();
553 virtual void deleteValuebuffersCHROMIUM(blink::WGC3Dsizei count,
554 blink::WebGLId* ids);
555 virtual void deleteValuebufferCHROMIUM(blink::WebGLId);
556 virtual void bindValuebufferCHROMIUM(blink::WGC3Denum target,
557 blink::WebGLId valuebuffer);
558 virtual blink::WGC3Dboolean isValuebufferCHROMIUM(
559 blink::WebGLId renderbuffer);
560 virtual void subscribeValueCHROMIUM(blink::WGC3Denum target,
561 blink::WGC3Denum subscription);
562 virtual void populateSubscribedValuesCHROMIUM(blink::WGC3Denum target);
563 virtual void uniformValuebufferCHROMIUM(blink::WGC3Dint location,
564 blink::WGC3Denum target,
565 blink::WGC3Denum subscription);
566 virtual void traceBeginCHROMIUM(const blink::WGC3Dchar* category_name,
567 const blink::WGC3Dchar* trace_name);
568 virtual void traceEndCHROMIUM();
570 virtual void insertEventMarkerEXT(const blink::WGC3Dchar* marker);
571 virtual void pushGroupMarkerEXT(const blink::WGC3Dchar* marker);
572 virtual void popGroupMarkerEXT();
574 // GL_OES_vertex_array_object
575 virtual blink::WebGLId createVertexArrayOES();
576 virtual void deleteVertexArrayOES(blink::WebGLId array);
577 virtual blink::WGC3Dboolean isVertexArrayOES(blink::WebGLId array);
578 virtual void bindVertexArrayOES(blink::WebGLId array);
580 virtual void bindTexImage2DCHROMIUM(blink::WGC3Denum target,
581 blink::WGC3Dint image_id);
582 virtual void releaseTexImage2DCHROMIUM(blink::WGC3Denum target,
583 blink::WGC3Dint image_id);
585 virtual void* mapBufferCHROMIUM(blink::WGC3Denum target,
586 blink::WGC3Denum access);
587 virtual blink::WGC3Dboolean unmapBufferCHROMIUM(blink::WGC3Denum target);
589 // Async pixel transfer functions.
590 virtual void asyncTexImage2DCHROMIUM(blink::WGC3Denum target,
591 blink::WGC3Dint level,
592 blink::WGC3Denum internalformat,
593 blink::WGC3Dsizei width,
594 blink::WGC3Dsizei height,
595 blink::WGC3Dint border,
596 blink::WGC3Denum format,
597 blink::WGC3Denum type,
598 const void* pixels);
599 virtual void asyncTexSubImage2DCHROMIUM(blink::WGC3Denum target,
600 blink::WGC3Dint level,
601 blink::WGC3Dint xoffset,
602 blink::WGC3Dint yoffset,
603 blink::WGC3Dsizei width,
604 blink::WGC3Dsizei height,
605 blink::WGC3Denum format,
606 blink::WGC3Denum type,
607 const void* pixels);
608 virtual void waitAsyncTexImage2DCHROMIUM(blink::WGC3Denum target);
610 // GL_EXT_draw_buffers
611 virtual void drawBuffersEXT(blink::WGC3Dsizei n,
612 const blink::WGC3Denum* bufs);
614 // GL_ANGLE_instanced_arrays
615 virtual void drawArraysInstancedANGLE(blink::WGC3Denum mode,
616 blink::WGC3Dint first,
617 blink::WGC3Dsizei count,
618 blink::WGC3Dsizei primcount);
619 virtual void drawElementsInstancedANGLE(blink::WGC3Denum mode,
620 blink::WGC3Dsizei count,
621 blink::WGC3Denum type,
622 blink::WGC3Dintptr offset,
623 blink::WGC3Dsizei primcount);
624 virtual void vertexAttribDivisorANGLE(blink::WGC3Duint index,
625 blink::WGC3Duint divisor);
627 // GL_CHROMIUM_gpu_memory_buffer_image
628 virtual blink::WGC3Duint createGpuMemoryBufferImageCHROMIUM(
629 blink::WGC3Dsizei width,
630 blink::WGC3Dsizei height,
631 blink::WGC3Denum internalformat,
632 blink::WGC3Denum usage);
633 virtual void destroyImageCHROMIUM(blink::WGC3Duint image_id);
635 // GL_EXT_multisampled_render_to_texture
636 virtual void framebufferTexture2DMultisampleEXT(blink::WGC3Denum target,
637 blink::WGC3Denum attachment,
638 blink::WGC3Denum textarget,
639 blink::WebGLId texture,
640 blink::WGC3Dint level,
641 blink::WGC3Dsizei samples);
642 virtual void renderbufferStorageMultisampleEXT(
643 blink::WGC3Denum target,
644 blink::WGC3Dsizei samples,
645 blink::WGC3Denum internalformat,
646 blink::WGC3Dsizei width,
647 blink::WGC3Dsizei height);
649 // OpenGL ES 3.0 functions not represented by pre-existing extensions
650 virtual void beginTransformFeedback(blink::WGC3Denum primitiveMode);
651 virtual void bindBufferBase(blink::WGC3Denum target,
652 blink::WGC3Duint index,
653 blink::WGC3Duint buffer);
654 virtual void bindBufferRange(blink::WGC3Denum target,
655 blink::WGC3Duint index,
656 blink::WGC3Duint buffer,
657 blink::WGC3Dintptr offset,
658 blink::WGC3Dsizeiptr size);
659 virtual void bindSampler(blink::WGC3Duint unit, blink::WebGLId sampler);
660 virtual void bindTransformFeedback(blink::WGC3Denum target,
661 blink::WebGLId transformfeedback);
662 virtual void clearBufferfi(blink::WGC3Denum buffer,
663 blink::WGC3Dint drawbuffer,
664 blink::WGC3Dfloat depth,
665 blink::WGC3Dint stencil);
666 virtual void clearBufferfv(blink::WGC3Denum buffer,
667 blink::WGC3Dint drawbuffer,
668 const blink::WGC3Dfloat* value);
669 virtual void clearBufferiv(blink::WGC3Denum buffer,
670 blink::WGC3Dint drawbuffer,
671 const blink::WGC3Dint* value);
672 virtual void clearBufferuiv(blink::WGC3Denum buffer,
673 blink::WGC3Dint drawbuffer,
674 const blink::WGC3Duint* value);
675 virtual blink::WGC3Denum clientWaitSync(blink::WGC3Dsync sync,
676 blink::WGC3Dbitfield flags,
677 blink::WGC3Duint64 timeout);
678 //virtual void compressedTexImage3D(blink::WGC3Denum target,
679 // blink::WGC3Dint level,
680 // blink::WGC3Denum internalformat,
681 // blink::WGC3Dsizei width,
682 // blink::WGC3Dsizei height,
683 // blink::WGC3Dsizei depth,
684 // blink::WGC3Dint border,
685 // blink::WGC3Dsizei imageSize,
686 // const void *data);
687 //virtual void compressedTexSubImage3D(blink::WGC3Denum target,
688 // blink::WGC3Dint level,
689 // blink::WGC3Dint xoffset,
690 // blink::WGC3Dint yoffset,
691 // blink::WGC3Dint zoffset,
692 // blink::WGC3Dsizei width,
693 // blink::WGC3Dsizei height,
694 // blink::WGC3Dsizei depth,
695 // blink::WGC3Denum format,
696 // blink::WGC3Dsizei imageSize,
697 // const void *data);
698 virtual void copyBufferSubData(blink::WGC3Denum readTarget,
699 blink::WGC3Denum writeTarget,
700 blink::WGC3Dintptr readOffset,
701 blink::WGC3Dintptr writeOffset,
702 blink::WGC3Dsizeiptr size);
703 virtual void copyTexSubImage3D(blink::WGC3Denum target,
704 blink::WGC3Dint level,
705 blink::WGC3Dint xoffset,
706 blink::WGC3Dint yoffset,
707 blink::WGC3Dint zoffset,
708 blink::WGC3Dint x,
709 blink::WGC3Dint y,
710 blink::WGC3Dsizei width,
711 blink::WGC3Dsizei height);
712 virtual blink::WebGLId createSampler();
713 virtual blink::WebGLId createTransformFeedback();
714 virtual void deleteSampler(blink::WebGLId sampler);
715 virtual void deleteSync(blink::WGC3Dsync sync);
716 virtual void deleteTransformFeedback(blink::WebGLId transformfeedback);
717 virtual void drawRangeElements(blink::WGC3Denum mode,
718 blink::WGC3Duint start,
719 blink::WGC3Duint end,
720 blink::WGC3Dsizei count,
721 blink::WGC3Denum type,
722 blink::WGC3Dintptr offset);
723 virtual void endTransformFeedback(void);
724 virtual blink::WGC3Dsync fenceSync(blink::WGC3Denum condition,
725 blink::WGC3Dbitfield flags);
726 virtual void framebufferTextureLayer(blink::WGC3Denum target,
727 blink::WGC3Denum attachment,
728 blink::WGC3Duint texture,
729 blink::WGC3Dint level,
730 blink::WGC3Dint layer);
731 virtual void getActiveUniformBlockName(blink::WGC3Duint program,
732 blink::WGC3Duint uniformBlockIndex,
733 blink::WGC3Dsizei bufSize,
734 blink::WGC3Dsizei* length,
735 blink::WGC3Dchar* uniformBlockName);
736 virtual void getActiveUniformBlockiv(blink::WGC3Duint program,
737 blink::WGC3Duint uniformBlockIndex,
738 blink::WGC3Denum pname,
739 blink::WGC3Dint* params);
740 virtual void getActiveUniformsiv(blink::WGC3Duint program,
741 blink::WGC3Dsizei uniformCount,
742 const blink::WGC3Duint *uniformIndices,
743 blink::WGC3Denum pname,
744 blink::WGC3Dint *params);
745 virtual blink::WGC3Dint getFragDataLocation(blink::WGC3Duint program,
746 const blink::WGC3Dchar* name);
747 virtual void getInternalformativ(blink::WGC3Denum target,
748 blink::WGC3Denum internalformat,
749 blink::WGC3Denum pname,
750 blink::WGC3Dsizei bufSize,
751 blink::WGC3Dint* params);
752 virtual void getSamplerParameterfv(blink::WGC3Duint sampler,
753 blink::WGC3Denum pname,
754 blink::WGC3Dfloat* params);
755 virtual void getSamplerParameteriv(blink::WGC3Duint sampler,
756 blink::WGC3Denum pname,
757 blink::WGC3Dint* params);
758 virtual void getTransformFeedbackVarying(blink::WGC3Duint program,
759 blink::WGC3Duint index,
760 blink::WGC3Dsizei bufSize,
761 blink::WGC3Dsizei *length,
762 blink::WGC3Dsizei *size,
763 blink::WGC3Denum *type,
764 blink::WGC3Dchar *name);
765 virtual blink::WGC3Duint getUniformBlockIndex(
766 blink::WGC3Duint program, const blink::WGC3Dchar* uniformBlockName);
767 virtual void getUniformIndices(blink::WGC3Duint program,
768 blink::WGC3Dsizei uniformCount,
769 const blink::WGC3Dchar *const*uniformNames,
770 blink::WGC3Duint *uniformIndices);
771 //virtual void getUniformuiv(blink::WGC3Duint program,
772 // blink::WGC3Dint location,
773 // blink::WGC3Duint *params);
774 //virtual void getVertexAttribIiv(blink::WGC3Duint index,
775 // blink::WGC3Denum pname,
776 // blink::WGC3Dint *params);
777 //virtual void getVertexAttribIuiv(blink::WGC3Duint index,
778 // blink::WGC3Denum pname,
779 // blink::WGC3Duint *params);
780 virtual void invalidateFramebuffer(blink::WGC3Denum target,
781 blink::WGC3Dsizei numAttachments,
782 const blink::WGC3Denum* attachments);
783 virtual void invalidateSubFramebuffer(blink::WGC3Denum target,
784 blink::WGC3Dsizei numAttachments,
785 const blink::WGC3Denum* attachments,
786 blink::WGC3Dint x,
787 blink::WGC3Dint y,
788 blink::WGC3Dsizei width,
789 blink::WGC3Dsizei height);
790 virtual blink::WGC3Dboolean isSampler(blink::WebGLId sampler);
791 virtual blink::WGC3Dboolean isSync(blink::WGC3Dsync sync);
792 virtual blink::WGC3Dboolean isTransformFeedback(blink::WGC3Duint id);
793 virtual void pauseTransformFeedback(void);
794 //virtual void programParameteri(blink::WGC3Duint program,
795 // blink::WGC3Denum pname,
796 // blink::WGC3Dint value);
797 virtual void readBuffer(blink::WGC3Denum src);
798 virtual void resumeTransformFeedback(void);
799 virtual void samplerParameterf(blink::WGC3Duint sampler,
800 blink::WGC3Denum pname,
801 blink::WGC3Dfloat param);
802 virtual void samplerParameterfv(blink::WGC3Duint sampler,
803 blink::WGC3Denum pname,
804 const blink::WGC3Dfloat* param);
805 virtual void samplerParameteri(blink::WGC3Duint sampler,
806 blink::WGC3Denum pname,
807 blink::WGC3Dint param);
808 virtual void samplerParameteriv(blink::WGC3Duint sampler,
809 blink::WGC3Denum pname,
810 const blink::WGC3Dint* param);
811 virtual void texImage3D(blink::WGC3Denum target,
812 blink::WGC3Dint level,
813 blink::WGC3Dint internalformat,
814 blink::WGC3Dsizei width,
815 blink::WGC3Dsizei height,
816 blink::WGC3Dsizei depth,
817 blink::WGC3Dint border,
818 blink::WGC3Denum format,
819 blink::WGC3Denum type,
820 const void* pixels);
821 virtual void texStorage3D(blink::WGC3Denum target,
822 blink::WGC3Dsizei levels,
823 blink::WGC3Denum internalformat,
824 blink::WGC3Dsizei width,
825 blink::WGC3Dsizei height,
826 blink::WGC3Dsizei depth);
827 virtual void texSubImage3D(blink::WGC3Denum target,
828 blink::WGC3Dint level,
829 blink::WGC3Dint xoffset,
830 blink::WGC3Dint yoffset,
831 blink::WGC3Dint zoffset,
832 blink::WGC3Dsizei width,
833 blink::WGC3Dsizei height,
834 blink::WGC3Dsizei depth,
835 blink::WGC3Denum format,
836 blink::WGC3Denum type,
837 const void* pixels);
838 virtual void transformFeedbackVaryings(
839 blink::WGC3Duint program,
840 blink::WGC3Dsizei count,
841 const blink::WGC3Dchar* const* varyings,
842 blink::WGC3Denum bufferMode);
843 virtual void uniform1ui(blink::WGC3Dint location, blink::WGC3Duint x);
844 virtual void uniform1uiv(blink::WGC3Dint location,
845 blink::WGC3Dsizei count,
846 const blink::WGC3Duint* value);
847 virtual void uniform2ui(blink::WGC3Dint location,
848 blink::WGC3Duint x,
849 blink::WGC3Duint y);
850 virtual void uniform2uiv(blink::WGC3Dint location,
851 blink::WGC3Dsizei count,
852 const blink::WGC3Duint* value);
853 virtual void uniform3ui(blink::WGC3Dint location,
854 blink::WGC3Duint x,
855 blink::WGC3Duint y,
856 blink::WGC3Duint z);
857 virtual void uniform3uiv(blink::WGC3Dint location,
858 blink::WGC3Dsizei count,
859 const blink::WGC3Duint* value);
860 virtual void uniform4ui(blink::WGC3Dint location,
861 blink::WGC3Duint x,
862 blink::WGC3Duint y,
863 blink::WGC3Duint z,
864 blink::WGC3Duint w);
865 virtual void uniform4uiv(blink::WGC3Dint location,
866 blink::WGC3Dsizei count,
867 const blink::WGC3Duint* value);
868 virtual void uniformBlockBinding(blink::WGC3Duint program,
869 blink::WGC3Duint uniformBlockIndex,
870 blink::WGC3Duint uniformBlockBinding);
871 virtual void uniformMatrix2x3fv(blink::WGC3Dint location,
872 blink::WGC3Dsizei count,
873 blink::WGC3Dboolean transpose,
874 const blink::WGC3Dfloat* value);
875 virtual void uniformMatrix2x4fv(blink::WGC3Dint location,
876 blink::WGC3Dsizei count,
877 blink::WGC3Dboolean transpose,
878 const blink::WGC3Dfloat* value);
879 virtual void uniformMatrix3x2fv(blink::WGC3Dint location,
880 blink::WGC3Dsizei count,
881 blink::WGC3Dboolean transpose,
882 const blink::WGC3Dfloat* value);
883 virtual void uniformMatrix3x4fv(blink::WGC3Dint location,
884 blink::WGC3Dsizei count,
885 blink::WGC3Dboolean transpose,
886 const blink::WGC3Dfloat* value);
887 virtual void uniformMatrix4x2fv(blink::WGC3Dint location,
888 blink::WGC3Dsizei count,
889 blink::WGC3Dboolean transpose,
890 const blink::WGC3Dfloat* value);
891 virtual void uniformMatrix4x3fv(blink::WGC3Dint location,
892 blink::WGC3Dsizei count,
893 blink::WGC3Dboolean transpose,
894 const blink::WGC3Dfloat* value);
895 virtual void vertexAttribI4i(blink::WGC3Duint index,
896 blink::WGC3Dint x,
897 blink::WGC3Dint y,
898 blink::WGC3Dint z,
899 blink::WGC3Dint w);
900 virtual void vertexAttribI4iv(blink::WGC3Duint index,
901 const blink::WGC3Dint* v);
902 virtual void vertexAttribI4ui(blink::WGC3Duint index,
903 blink::WGC3Duint x,
904 blink::WGC3Duint y,
905 blink::WGC3Duint z,
906 blink::WGC3Duint w);
907 virtual void vertexAttribI4uiv(blink::WGC3Duint index,
908 const blink::WGC3Duint* v);
909 virtual void vertexAttribIPointer(blink::WGC3Duint index,
910 blink::WGC3Dint size,
911 blink::WGC3Denum type,
912 blink::WGC3Dsizei stride,
913 blink::WGC3Dintptr pointer);
914 virtual void waitSync(blink::WGC3Dsync sync,
915 blink::WGC3Dbitfield flags,
916 blink::WGC3Duint64 timeout);
918 virtual GrGLInterface* createGrGLInterface();
920 ::gpu::gles2::GLES2Interface* GetGLInterface() {
921 return gl_;
924 // Convert WebGL context creation attributes into command buffer / EGL size
925 // requests.
926 static void ConvertAttributes(
927 const blink::WebGraphicsContext3D::Attributes& attributes,
928 ::gpu::gles2::ContextCreationAttribHelper* output_attribs);
930 protected:
931 friend class WebGraphicsContext3DErrorMessageCallback;
933 WebGraphicsContext3DImpl();
935 ::gpu::gles2::GLES2ImplementationErrorMessageCallback*
936 getErrorMessageCallback();
937 virtual void OnErrorMessage(const std::string& message, int id);
939 void setGLInterface(::gpu::gles2::GLES2Interface* gl) {
940 gl_ = gl;
943 bool initialized_;
944 bool initialize_failed_;
946 WebGraphicsContext3D::WebGraphicsContextLostCallback* context_lost_callback_;
947 blink::WGC3Denum context_lost_reason_;
949 WebGraphicsContext3D::WebGraphicsErrorMessageCallback*
950 error_message_callback_;
951 scoped_ptr<WebGraphicsContext3DErrorMessageCallback>
952 client_error_message_callback_;
954 // Errors raised by synthesizeGLError().
955 std::vector<blink::WGC3Denum> synthetic_errors_;
957 ::gpu::gles2::GLES2Interface* gl_;
958 bool lose_context_when_out_of_memory_;
959 uint32_t flush_id_;
962 } // namespace gpu_blink
964 #endif // GPU_BLINK_WEBGRAPHICSCONTEXT3D_IMPL_H_