• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.
4 
5 #ifndef WEBKIT_COMMON_GPU_WEBGRAPHICSCONTEXT3D_IN_PROCESS_COMMAND_BUFFER_IMPL_H_
6 #define WEBKIT_COMMON_GPU_WEBGRAPHICSCONTEXT3D_IN_PROCESS_COMMAND_BUFFER_IMPL_H_
7 
8 #include <vector>
9 
10 #include "base/compiler_specific.h"
11 #include "base/memory/scoped_ptr.h"
12 #include "third_party/WebKit/public/platform/WebGraphicsContext3D.h"
13 #include "third_party/WebKit/public/platform/WebString.h"
14 #include "ui/gfx/native_widget_types.h"
15 #include "webkit/common/gpu/webkit_gpu_export.h"
16 
17 namespace gpu {
18 class ContextSupport;
19 
20 namespace gles2 {
21 class GLES2Interface;
22 class GLES2Implementation;
23 }
24 }
25 
26 using blink::WebGLId;
27 
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 
41 namespace gpu {
42 class GLInProcessContext;
43 struct GLInProcessContextAttribs;
44 }
45 
46 namespace webkit {
47 namespace gpu {
48 
49 class WEBKIT_GPU_EXPORT WebGraphicsContext3DInProcessCommandBufferImpl
NON_EXPORTED_BASE(blink::WebGraphicsContext3D)50     : public NON_EXPORTED_BASE(blink::WebGraphicsContext3D) {
51  public:
52   static scoped_ptr<WebGraphicsContext3DInProcessCommandBufferImpl>
53       CreateViewContext(
54           const blink::WebGraphicsContext3D::Attributes& attributes,
55           gfx::AcceleratedWidget window);
56 
57   static scoped_ptr<WebGraphicsContext3DInProcessCommandBufferImpl>
58       CreateOffscreenContext(
59           const blink::WebGraphicsContext3D::Attributes& attributes);
60 
61   static scoped_ptr<WebGraphicsContext3DInProcessCommandBufferImpl>
62       WrapContext(
63           scoped_ptr< ::gpu::GLInProcessContext> context,
64           const blink::WebGraphicsContext3D::Attributes& attributes);
65 
66   virtual ~WebGraphicsContext3DInProcessCommandBufferImpl();
67 
68   // Convert WebGL context creation attributes into GLInProcessContext / EGL
69   // size requests.
70   static void ConvertAttributes(
71       const blink::WebGraphicsContext3D::Attributes& attributes,
72       ::gpu::GLInProcessContextAttribs* output_attribs);
73 
74   //----------------------------------------------------------------------
75   // WebGraphicsContext3D methods
76   virtual bool makeContextCurrent();
77 
78   virtual uint32_t lastFlushID();
79 
80   virtual void reshapeWithScaleFactor(int width, int height, float scaleFactor);
81 
82   virtual void prepareTexture();
83   virtual void postSubBufferCHROMIUM(int x, int y, int width, int height);
84 
85   virtual void activeTexture(WGC3Denum texture);
86   virtual void attachShader(WebGLId program, WebGLId shader);
87   virtual void bindAttribLocation(WebGLId program, WGC3Duint index,
88                                   const WGC3Dchar* name);
89   virtual void bindBuffer(WGC3Denum target, WebGLId buffer);
90   virtual void bindFramebuffer(WGC3Denum target, WebGLId framebuffer);
91   virtual void bindRenderbuffer(WGC3Denum target, WebGLId renderbuffer);
92   virtual void bindTexture(WGC3Denum target, WebGLId texture);
93   virtual void blendColor(WGC3Dclampf red, WGC3Dclampf green,
94                           WGC3Dclampf blue, WGC3Dclampf alpha);
95   virtual void blendEquation(WGC3Denum mode);
96   virtual void blendEquationSeparate(WGC3Denum modeRGB,
97                                      WGC3Denum modeAlpha);
98   virtual void blendFunc(WGC3Denum sfactor, WGC3Denum dfactor);
99   virtual void blendFuncSeparate(WGC3Denum srcRGB,
100                                  WGC3Denum dstRGB,
101                                  WGC3Denum srcAlpha,
102                                  WGC3Denum dstAlpha);
103 
104   virtual void bufferData(WGC3Denum target, WGC3Dsizeiptr size,
105                           const void* data, WGC3Denum usage);
106   virtual void bufferSubData(WGC3Denum target, WGC3Dintptr offset,
107                              WGC3Dsizeiptr size, const void* data);
108 
109   virtual WGC3Denum checkFramebufferStatus(WGC3Denum target);
110   virtual void clear(WGC3Dbitfield mask);
111   virtual void clearColor(WGC3Dclampf red, WGC3Dclampf green,
112                           WGC3Dclampf blue, WGC3Dclampf alpha);
113   virtual void clearDepth(WGC3Dclampf depth);
114   virtual void clearStencil(WGC3Dint s);
115   virtual void colorMask(WGC3Dboolean red, WGC3Dboolean green,
116                          WGC3Dboolean blue, WGC3Dboolean alpha);
117   virtual void compileShader(WebGLId shader);
118 
119   virtual void compressedTexImage2D(WGC3Denum target,
120                                     WGC3Dint level,
121                                     WGC3Denum internalformat,
122                                     WGC3Dsizei width,
123                                     WGC3Dsizei height,
124                                     WGC3Dint border,
125                                     WGC3Dsizei imageSize,
126                                     const void* data);
127   virtual void compressedTexSubImage2D(WGC3Denum target,
128                                        WGC3Dint level,
129                                        WGC3Dint xoffset,
130                                        WGC3Dint yoffset,
131                                        WGC3Dsizei width,
132                                        WGC3Dsizei height,
133                                        WGC3Denum format,
134                                        WGC3Dsizei imageSize,
135                                        const void* data);
136   virtual void copyTexImage2D(WGC3Denum target,
137                               WGC3Dint level,
138                               WGC3Denum internalformat,
139                               WGC3Dint x,
140                               WGC3Dint y,
141                               WGC3Dsizei width,
142                               WGC3Dsizei height,
143                               WGC3Dint border);
144   virtual void copyTexSubImage2D(WGC3Denum target,
145                                  WGC3Dint level,
146                                  WGC3Dint xoffset,
147                                  WGC3Dint yoffset,
148                                  WGC3Dint x,
149                                  WGC3Dint y,
150                                  WGC3Dsizei width,
151                                  WGC3Dsizei height);
152   virtual void cullFace(WGC3Denum mode);
153   virtual void depthFunc(WGC3Denum func);
154   virtual void depthMask(WGC3Dboolean flag);
155   virtual void depthRange(WGC3Dclampf zNear, WGC3Dclampf zFar);
156   virtual void detachShader(WebGLId program, WebGLId shader);
157   virtual void disable(WGC3Denum cap);
158   virtual void disableVertexAttribArray(WGC3Duint index);
159   virtual void drawArrays(WGC3Denum mode, WGC3Dint first, WGC3Dsizei count);
160   virtual void drawElements(WGC3Denum mode,
161                             WGC3Dsizei count,
162                             WGC3Denum type,
163                             WGC3Dintptr offset);
164 
165   virtual void enable(WGC3Denum cap);
166   virtual void enableVertexAttribArray(WGC3Duint index);
167   virtual void finish();
168   virtual void flush();
169   virtual void framebufferRenderbuffer(WGC3Denum target,
170                                        WGC3Denum attachment,
171                                        WGC3Denum renderbuffertarget,
172                                        WebGLId renderbuffer);
173   virtual void framebufferTexture2D(WGC3Denum target,
174                                     WGC3Denum attachment,
175                                     WGC3Denum textarget,
176                                     WebGLId texture,
177                                     WGC3Dint level);
178   virtual void frontFace(WGC3Denum mode);
179   virtual void generateMipmap(WGC3Denum target);
180 
181   virtual bool getActiveAttrib(WebGLId program,
182                                WGC3Duint index,
183                                ActiveInfo&);
184   virtual bool getActiveUniform(WebGLId program,
185                                 WGC3Duint index,
186                                 ActiveInfo&);
187 
188   virtual void getAttachedShaders(WebGLId program,
189                                   WGC3Dsizei maxCount,
190                                   WGC3Dsizei* count,
191                                   WebGLId* shaders);
192 
193   virtual WGC3Dint  getAttribLocation(WebGLId program, const WGC3Dchar* name);
194 
195   virtual void getBooleanv(WGC3Denum pname, WGC3Dboolean* value);
196 
197   virtual void getBufferParameteriv(WGC3Denum target,
198                                     WGC3Denum pname,
199                                     WGC3Dint* value);
200 
201   virtual Attributes getContextAttributes();
202 
203   virtual WGC3Denum getError();
204 
205   virtual bool isContextLost();
206 
207   virtual void getFloatv(WGC3Denum pname, WGC3Dfloat* value);
208 
209   virtual void getFramebufferAttachmentParameteriv(WGC3Denum target,
210                                                    WGC3Denum attachment,
211                                                    WGC3Denum pname,
212                                                    WGC3Dint* value);
213 
214   virtual void getIntegerv(WGC3Denum pname, WGC3Dint* value);
215 
216   virtual void getProgramiv(WebGLId program, WGC3Denum pname, WGC3Dint* value);
217 
218   virtual blink::WebString getProgramInfoLog(WebGLId program);
219 
220   virtual void getRenderbufferParameteriv(WGC3Denum target,
221                                           WGC3Denum pname,
222                                           WGC3Dint* value);
223 
224   virtual void getShaderiv(WebGLId shader, WGC3Denum pname, WGC3Dint* value);
225 
226   virtual blink::WebString getShaderInfoLog(WebGLId shader);
227 
228   virtual void getShaderPrecisionFormat(WGC3Denum shadertype,
229                                         WGC3Denum precisiontype,
230                                         WGC3Dint* range,
231                                         WGC3Dint* precision);
232 
233   virtual blink::WebString getShaderSource(WebGLId shader);
234   virtual blink::WebString getString(WGC3Denum name);
235 
236   virtual void getTexParameterfv(WGC3Denum target,
237                                  WGC3Denum pname,
238                                  WGC3Dfloat* value);
239   virtual void getTexParameteriv(WGC3Denum target,
240                                  WGC3Denum pname,
241                                  WGC3Dint* value);
242 
243   virtual void getUniformfv(WebGLId program,
244                             WGC3Dint location,
245                             WGC3Dfloat* value);
246   virtual void getUniformiv(WebGLId program,
247                             WGC3Dint location,
248                             WGC3Dint* value);
249 
250   virtual WGC3Dint getUniformLocation(WebGLId program, const WGC3Dchar* name);
251 
252   virtual void getVertexAttribfv(WGC3Duint index, WGC3Denum pname,
253                                  WGC3Dfloat* value);
254   virtual void getVertexAttribiv(WGC3Duint index, WGC3Denum pname,
255                                  WGC3Dint* value);
256 
257   virtual WGC3Dsizeiptr getVertexAttribOffset(WGC3Duint index, WGC3Denum pname);
258 
259   virtual void hint(WGC3Denum target, WGC3Denum mode);
260   virtual WGC3Dboolean isBuffer(WebGLId buffer);
261   virtual WGC3Dboolean isEnabled(WGC3Denum cap);
262   virtual WGC3Dboolean isFramebuffer(WebGLId framebuffer);
263   virtual WGC3Dboolean isProgram(WebGLId program);
264   virtual WGC3Dboolean isRenderbuffer(WebGLId renderbuffer);
265   virtual WGC3Dboolean isShader(WebGLId shader);
266   virtual WGC3Dboolean isTexture(WebGLId texture);
267   virtual void lineWidth(WGC3Dfloat);
268   virtual void linkProgram(WebGLId program);
269   virtual void pixelStorei(WGC3Denum pname, WGC3Dint param);
270   virtual void polygonOffset(WGC3Dfloat factor, WGC3Dfloat units);
271 
272   virtual void readPixels(WGC3Dint x,
273                           WGC3Dint y,
274                           WGC3Dsizei width,
275                           WGC3Dsizei height,
276                           WGC3Denum format,
277                           WGC3Denum type,
278                           void* pixels);
279 
280   virtual void releaseShaderCompiler();
281   virtual void renderbufferStorage(WGC3Denum target,
282                                    WGC3Denum internalformat,
283                                    WGC3Dsizei width,
284                                    WGC3Dsizei height);
285   virtual void sampleCoverage(WGC3Dfloat value, WGC3Dboolean invert);
286   virtual void scissor(WGC3Dint x, WGC3Dint y,
287                        WGC3Dsizei width, WGC3Dsizei height);
288   virtual void shaderSource(WebGLId shader, const WGC3Dchar* string);
289   virtual void stencilFunc(WGC3Denum func, WGC3Dint ref, WGC3Duint mask);
290   virtual void stencilFuncSeparate(WGC3Denum face,
291                                    WGC3Denum func,
292                                    WGC3Dint ref,
293                                    WGC3Duint mask);
294   virtual void stencilMask(WGC3Duint mask);
295   virtual void stencilMaskSeparate(WGC3Denum face, WGC3Duint mask);
296   virtual void stencilOp(WGC3Denum fail,
297                          WGC3Denum zfail,
298                          WGC3Denum zpass);
299   virtual void stencilOpSeparate(WGC3Denum face,
300                                  WGC3Denum fail,
301                                  WGC3Denum zfail,
302                                  WGC3Denum zpass);
303 
304   virtual void texImage2D(WGC3Denum target,
305                           WGC3Dint level,
306                           WGC3Denum internalformat,
307                           WGC3Dsizei width,
308                           WGC3Dsizei height,
309                           WGC3Dint border,
310                           WGC3Denum format,
311                           WGC3Denum type,
312                           const void* pixels);
313 
314   virtual void texParameterf(WGC3Denum target,
315                              WGC3Denum pname,
316                              WGC3Dfloat param);
317   virtual void texParameteri(WGC3Denum target,
318                              WGC3Denum pname,
319                              WGC3Dint param);
320 
321   virtual void texSubImage2D(WGC3Denum target,
322                              WGC3Dint level,
323                              WGC3Dint xoffset,
324                              WGC3Dint yoffset,
325                              WGC3Dsizei width,
326                              WGC3Dsizei height,
327                              WGC3Denum format,
328                              WGC3Denum type,
329                              const void* pixels);
330 
331   virtual void uniform1f(WGC3Dint location, WGC3Dfloat x);
332   virtual void uniform1fv(WGC3Dint location,
333                           WGC3Dsizei count, const WGC3Dfloat* v);
334   virtual void uniform1i(WGC3Dint location, WGC3Dint x);
335   virtual void uniform1iv(WGC3Dint location,
336                           WGC3Dsizei count, const WGC3Dint* v);
337   virtual void uniform2f(WGC3Dint location, WGC3Dfloat x, WGC3Dfloat y);
338   virtual void uniform2fv(WGC3Dint location,
339                           WGC3Dsizei count, const WGC3Dfloat* v);
340   virtual void uniform2i(WGC3Dint location, WGC3Dint x, WGC3Dint y);
341   virtual void uniform2iv(WGC3Dint location,
342                           WGC3Dsizei count, const WGC3Dint* v);
343   virtual void uniform3f(WGC3Dint location,
344                          WGC3Dfloat x, WGC3Dfloat y, WGC3Dfloat z);
345   virtual void uniform3fv(WGC3Dint location,
346                           WGC3Dsizei count, const WGC3Dfloat* v);
347   virtual void uniform3i(WGC3Dint location,
348                          WGC3Dint x, WGC3Dint y, WGC3Dint z);
349   virtual void uniform3iv(WGC3Dint location,
350                           WGC3Dsizei count, const WGC3Dint* v);
351   virtual void uniform4f(WGC3Dint location,
352                          WGC3Dfloat x, WGC3Dfloat y,
353                          WGC3Dfloat z, WGC3Dfloat w);
354   virtual void uniform4fv(WGC3Dint location,
355                           WGC3Dsizei count, const WGC3Dfloat* v);
356   virtual void uniform4i(WGC3Dint location,
357                          WGC3Dint x, WGC3Dint y, WGC3Dint z, WGC3Dint w);
358   virtual void uniform4iv(WGC3Dint location,
359                           WGC3Dsizei count, const WGC3Dint* v);
360   virtual void uniformMatrix2fv(WGC3Dint location,
361                                 WGC3Dsizei count,
362                                 WGC3Dboolean transpose,
363                                 const WGC3Dfloat* value);
364   virtual void uniformMatrix3fv(WGC3Dint location,
365                                 WGC3Dsizei count,
366                                 WGC3Dboolean transpose,
367                                 const WGC3Dfloat* value);
368   virtual void uniformMatrix4fv(WGC3Dint location,
369                                 WGC3Dsizei count,
370                                 WGC3Dboolean transpose,
371                                 const WGC3Dfloat* value);
372 
373   virtual void useProgram(WebGLId program);
374   virtual void validateProgram(WebGLId program);
375 
376   virtual void vertexAttrib1f(WGC3Duint index, WGC3Dfloat x);
377   virtual void vertexAttrib1fv(WGC3Duint index, const WGC3Dfloat* values);
378   virtual void vertexAttrib2f(WGC3Duint index, WGC3Dfloat x, WGC3Dfloat y);
379   virtual void vertexAttrib2fv(WGC3Duint index, const WGC3Dfloat* values);
380   virtual void vertexAttrib3f(WGC3Duint index,
381                               WGC3Dfloat x, WGC3Dfloat y, WGC3Dfloat z);
382   virtual void vertexAttrib3fv(WGC3Duint index, const WGC3Dfloat* values);
383   virtual void vertexAttrib4f(WGC3Duint index,
384                               WGC3Dfloat x, WGC3Dfloat y,
385                               WGC3Dfloat z, WGC3Dfloat w);
386   virtual void vertexAttrib4fv(WGC3Duint index, const WGC3Dfloat* values);
387   virtual void vertexAttribPointer(WGC3Duint index,
388                                    WGC3Dint size,
389                                    WGC3Denum type,
390                                    WGC3Dboolean normalized,
391                                    WGC3Dsizei stride,
392                                    WGC3Dintptr offset);
393 
394   virtual void viewport(WGC3Dint x, WGC3Dint y,
395                         WGC3Dsizei width, WGC3Dsizei height);
396 
397   // Support for buffer creation and deletion
398   virtual void genBuffers(WGC3Dsizei count, WebGLId* ids);
399   virtual void genFramebuffers(WGC3Dsizei count, WebGLId* ids);
400   virtual void genRenderbuffers(WGC3Dsizei count, WebGLId* ids);
401   virtual void genTextures(WGC3Dsizei count, WebGLId* ids);
402 
403   virtual void deleteBuffers(WGC3Dsizei count, WebGLId* ids);
404   virtual void deleteFramebuffers(WGC3Dsizei count, WebGLId* ids);
405   virtual void deleteRenderbuffers(WGC3Dsizei count, WebGLId* ids);
406   virtual void deleteTextures(WGC3Dsizei count, WebGLId* ids);
407 
408   virtual WebGLId createBuffer();
409   virtual WebGLId createFramebuffer();
410   virtual WebGLId createRenderbuffer();
411   virtual WebGLId createTexture();
412 
413   virtual void deleteBuffer(WebGLId);
414   virtual void deleteFramebuffer(WebGLId);
415   virtual void deleteRenderbuffer(WebGLId);
416   virtual void deleteTexture(WebGLId);
417 
418   virtual WebGLId createProgram();
419   virtual WebGLId createShader(WGC3Denum);
420 
421   virtual void deleteProgram(WebGLId);
422   virtual void deleteShader(WebGLId);
423 
424   virtual void synthesizeGLError(WGC3Denum);
425 
426   virtual void* mapBufferSubDataCHROMIUM(
427       WGC3Denum target, WGC3Dintptr offset,
428       WGC3Dsizeiptr size, WGC3Denum access);
429   virtual void unmapBufferSubDataCHROMIUM(const void*);
430   virtual void* mapTexSubImage2DCHROMIUM(
431       WGC3Denum target,
432       WGC3Dint level,
433       WGC3Dint xoffset,
434       WGC3Dint yoffset,
435       WGC3Dsizei width,
436       WGC3Dsizei height,
437       WGC3Denum format,
438       WGC3Denum type,
439       WGC3Denum access);
440   virtual void unmapTexSubImage2DCHROMIUM(const void*);
441 
442   virtual void setVisibilityCHROMIUM(bool visible);
443 
444   virtual void discardFramebufferEXT(WGC3Denum target,
445                                      WGC3Dsizei numAttachments,
446                                      const WGC3Denum* attachments);
447 
448   virtual void copyTextureToParentTextureCHROMIUM(
449       WebGLId texture, WebGLId parentTexture);
450 
451   virtual void rateLimitOffscreenContextCHROMIUM();
452 
453   virtual blink::WebString getRequestableExtensionsCHROMIUM();
454   virtual void requestExtensionCHROMIUM(const char*);
455 
456   virtual void blitFramebufferCHROMIUM(
457       WGC3Dint srcX0, WGC3Dint srcY0, WGC3Dint srcX1, WGC3Dint srcY1,
458       WGC3Dint dstX0, WGC3Dint dstY0, WGC3Dint dstX1, WGC3Dint dstY1,
459       WGC3Dbitfield mask, WGC3Denum filter);
460   virtual void renderbufferStorageMultisampleCHROMIUM(
461       WGC3Denum target, WGC3Dsizei samples, WGC3Denum internalformat,
462       WGC3Dsizei width, WGC3Dsizei height);
463 
464   virtual blink::WebString getTranslatedShaderSourceANGLE(WebGLId shader);
465 
466   virtual void setContextLostCallback(
467       WebGraphicsContext3D::WebGraphicsContextLostCallback* callback);
468   virtual WGC3Denum getGraphicsResetStatusARB();
469 
470   virtual void texImageIOSurface2DCHROMIUM(
471       WGC3Denum target, WGC3Dint width, WGC3Dint height,
472       WGC3Duint ioSurfaceId, WGC3Duint plane);
473 
474   virtual void bindTexImage2DCHROMIUM(WGC3Denum target, WGC3Dint imageId);
475   virtual void releaseTexImage2DCHROMIUM(WGC3Denum target, WGC3Dint imageId);
476 
477   virtual WebGLId createStreamTextureCHROMIUM(WebGLId texture);
478   virtual void destroyStreamTextureCHROMIUM(WebGLId texture);
479 
480   virtual void texStorage2DEXT(
481       WGC3Denum target, WGC3Dint levels, WGC3Duint internalformat,
482       WGC3Dint width, WGC3Dint height);
483   virtual WGC3Duint createImageCHROMIUM(
484       WGC3Dsizei width, WGC3Dsizei height, WGC3Denum internalformat);
485   virtual void destroyImageCHROMIUM(WGC3Duint image_id);
486   virtual void getImageParameterivCHROMIUM(
487       WGC3Duint image_id, WGC3Denum pname, WGC3Dint* params);
488   virtual void* mapImageCHROMIUM(WGC3Duint image_id, WGC3Denum access);
489   virtual void unmapImageCHROMIUM(WGC3Duint image_id);
490   virtual WebGLId createQueryEXT();
491   virtual void deleteQueryEXT(WebGLId query);
492   virtual WGC3Dboolean isQueryEXT(WebGLId query);
493   virtual void beginQueryEXT(WGC3Denum target, WebGLId query);
494   virtual void endQueryEXT(WGC3Denum target);
495   virtual void getQueryivEXT(
496       WGC3Denum target, WGC3Denum pname, WGC3Dint* params);
497   virtual void getQueryObjectuivEXT(
498       WebGLId query, WGC3Denum pname, WGC3Duint* params);
499 
500   virtual void copyTextureCHROMIUM(WGC3Denum target, WGC3Duint source_id,
501                                    WGC3Duint dest_id, WGC3Dint level,
502                                    WGC3Denum internal_format,
503                                    WGC3Denum dest_type);
504 
505   virtual void bindUniformLocationCHROMIUM(WebGLId program, WGC3Dint location,
506                                            const WGC3Dchar* uniform);
507 
508   virtual void shallowFlushCHROMIUM();
509   virtual void shallowFinishCHROMIUM();
510 
511   virtual void genMailboxCHROMIUM(WGC3Dbyte* mailbox);
512   virtual void produceTextureCHROMIUM(WGC3Denum target,
513                                       const WGC3Dbyte* mailbox);
514   virtual void consumeTextureCHROMIUM(WGC3Denum target,
515                                       const WGC3Dbyte* mailbox);
516 
517   virtual void insertEventMarkerEXT(const WGC3Dchar* marker);
518   virtual void pushGroupMarkerEXT(const WGC3Dchar* marker);
519   virtual void popGroupMarkerEXT();
520 
521   virtual void* mapBufferCHROMIUM(WGC3Denum target, WGC3Denum access);
522   virtual WGC3Dboolean unmapBufferCHROMIUM(WGC3Denum target);
523 
524   // Async pixel transfer functions.
525   virtual void asyncTexImage2DCHROMIUM(
526       WGC3Denum target,
527       WGC3Dint level,
528       WGC3Denum internalformat,
529       WGC3Dsizei width,
530       WGC3Dsizei height,
531       WGC3Dint border,
532       WGC3Denum format,
533       WGC3Denum type,
534       const void* pixels);
535   virtual void asyncTexSubImage2DCHROMIUM(
536       WGC3Denum target,
537       WGC3Dint level,
538       WGC3Dint xoffset,
539       WGC3Dint yoffset,
540       WGC3Dsizei width,
541       WGC3Dsizei height,
542       WGC3Denum format,
543       WGC3Denum type,
544       const void* pixels);
545   virtual void waitAsyncTexImage2DCHROMIUM(WGC3Denum target);
546 
547   virtual void drawBuffersEXT(WGC3Dsizei n, const WGC3Denum* bufs);
548 
549   virtual unsigned insertSyncPoint();
550 
551   virtual void loseContextCHROMIUM(WGC3Denum current, WGC3Denum other);
552 
553   virtual GrGLInterface* createGrGLInterface();
554 
555   ::gpu::gles2::GLES2Interface* GetGLInterface();
556   ::gpu::ContextSupport* GetContextSupport();
557 
558   ::gpu::gles2::GLES2Implementation* GetImplementation() {
559     return gl_;
560   }
561 
562  private:
563   WebGraphicsContext3DInProcessCommandBufferImpl(
564       scoped_ptr< ::gpu::GLInProcessContext> context,
565       const blink::WebGraphicsContext3D::Attributes& attributes,
566       bool is_offscreen,
567       gfx::AcceleratedWidget window);
568 
569   void OnContextLost();
570 
571   bool MaybeInitializeGL();
572 
573   // Used to try to find bugs in code that calls gl directly through the gl api
574   // instead of going through WebGraphicsContext3D.
575   void ClearContext();
576 
577   bool is_offscreen_;
578   // Only used when not offscreen.
579   gfx::AcceleratedWidget window_;
580 
581   bool initialized_;
582   bool initialize_failed_;
583 
584   // The context we use for OpenGL rendering.
585   scoped_ptr< ::gpu::GLInProcessContext> context_;
586   // The GLES2Implementation we use for OpenGL rendering.
587   ::gpu::gles2::GLES2Implementation* gl_;
588 
589   WebGraphicsContext3D::WebGraphicsContextLostCallback* context_lost_callback_;
590   WGC3Denum context_lost_reason_;
591 
592   blink::WebGraphicsContext3D::Attributes attributes_;
593 
594   // Errors raised by synthesizeGLError().
595   std::vector<WGC3Denum> synthetic_errors_;
596 
597   uint32_t flush_id_;
598 };
599 
600 }  // namespace gpu
601 }  // namespace webkit
602 
603 #endif  // WEBKIT_COMMON_GPU_WEBGRAPHICSCONTEXT3D_IN_PROCESS_COMMAND_BUFFER_IMPL_H_
604