OLD | NEW |
| (Empty) |
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_GPU_WEBGRAPHICSCONTEXT3D_IN_PROCESS_IMPL_H_ | |
6 #define WEBKIT_GPU_WEBGRAPHICSCONTEXT3D_IN_PROCESS_IMPL_H_ | |
7 | |
8 #include <list> | |
9 #include <set> | |
10 | |
11 #include "base/compiler_specific.h" | |
12 #include "base/hash_tables.h" | |
13 #include "base/memory/ref_counted.h" | |
14 #include "third_party/WebKit/Source/Platform/chromium/public/WebGraphicsContext3
D.h" | |
15 #include "third_party/WebKit/Source/Platform/chromium/public/WebString.h" | |
16 #include "third_party/angle/include/GLSLANG/ShaderLang.h" | |
17 #include "ui/gfx/native_widget_types.h" | |
18 #include "webkit/gpu/webkit_gpu_export.h" | |
19 | |
20 namespace gfx { | |
21 class GLContext; | |
22 class GLSurface; | |
23 class GLShareGroup; | |
24 } | |
25 | |
26 using WebKit::WGC3Dbyte; | |
27 using WebKit::WGC3Dchar; | |
28 using WebKit::WGC3Denum; | |
29 using WebKit::WGC3Dboolean; | |
30 using WebKit::WGC3Dbitfield; | |
31 using WebKit::WGC3Dint; | |
32 using WebKit::WGC3Dsizei; | |
33 using WebKit::WGC3Duint; | |
34 using WebKit::WGC3Dfloat; | |
35 using WebKit::WGC3Dclampf; | |
36 using WebKit::WGC3Dintptr; | |
37 using WebKit::WGC3Dsizeiptr; | |
38 | |
39 using WebKit::WebGLId; | |
40 | |
41 using WebKit::WebString; | |
42 | |
43 using WebKit::WebGraphicsContext3D; | |
44 | |
45 namespace webkit { | |
46 namespace gpu { | |
47 | |
48 // The default implementation of WebGL. In Chromium, using this class | |
49 // requires the sandbox to be disabled, which is strongly discouraged. | |
50 // It is provided for support of test_shell and any Chromium ports | |
51 // where an in-renderer WebGL implementation would be helpful. | |
52 | |
53 class WEBKIT_GPU_EXPORT WebGraphicsContext3DInProcessImpl : | |
54 public NON_EXPORTED_BASE(WebGraphicsContext3D) { | |
55 public: | |
56 // Creates a WebGraphicsContext3DInProcessImpl for a given window. If window | |
57 // is gfx::kNullPluginWindow, then it creates an offscreen context. | |
58 // share_group is the group this context shares namespaces with. It's only | |
59 // used for window-bound countexts. | |
60 WebGraphicsContext3DInProcessImpl(gfx::GLSurface* surface, | |
61 gfx::GLContext* context, | |
62 bool render_directly_to_webview); | |
63 virtual ~WebGraphicsContext3DInProcessImpl(); | |
64 static WebGraphicsContext3DInProcessImpl* CreateForWindow( | |
65 WebGraphicsContext3D::Attributes attributes, | |
66 gfx::AcceleratedWidget window, | |
67 gfx::GLShareGroup* share_group); | |
68 | |
69 //---------------------------------------------------------------------- | |
70 // WebGraphicsContext3D methods | |
71 virtual bool makeContextCurrent(); | |
72 | |
73 virtual int width(); | |
74 virtual int height(); | |
75 | |
76 virtual bool isGLES2Compliant(); | |
77 | |
78 virtual bool setParentContext(WebGraphicsContext3D* parent_context); | |
79 | |
80 virtual void reshape(int width, int height); | |
81 virtual void reshapeWithScaleFactor( | |
82 int width, int height, float scaleFactor); | |
83 | |
84 virtual bool readBackFramebuffer(unsigned char* pixels, size_t bufferSize); | |
85 virtual bool readBackFramebuffer(unsigned char* pixels, size_t buffer_size, | |
86 WebGLId framebuffer, int width, int height); | |
87 | |
88 virtual WebGLId getPlatformTextureId(); | |
89 virtual void prepareTexture(); | |
90 virtual void postSubBufferCHROMIUM(int x, int y, int width, int height); | |
91 | |
92 virtual void synthesizeGLError(WGC3Denum error); | |
93 virtual void* mapBufferSubDataCHROMIUM(WGC3Denum target, WGC3Dintptr offset, | |
94 WGC3Dsizeiptr size, WGC3Denum access); | |
95 virtual void unmapBufferSubDataCHROMIUM(const void*); | |
96 virtual void* mapTexSubImage2DCHROMIUM( | |
97 WGC3Denum target, | |
98 WGC3Dint level, | |
99 WGC3Dint xoffset, | |
100 WGC3Dint yoffset, | |
101 WGC3Dsizei width, | |
102 WGC3Dsizei height, | |
103 WGC3Denum format, | |
104 WGC3Denum type, | |
105 WGC3Denum access); | |
106 virtual void unmapTexSubImage2DCHROMIUM(const void*); | |
107 | |
108 virtual void setVisibilityCHROMIUM(bool visible); | |
109 | |
110 virtual void setMemoryAllocationChangedCallbackCHROMIUM( | |
111 WebGraphicsMemoryAllocationChangedCallbackCHROMIUM* callback); | |
112 | |
113 virtual void discardFramebufferEXT(WGC3Denum target, | |
114 WGC3Dsizei numAttachments, | |
115 const WGC3Denum* attachments); | |
116 virtual void discardBackbufferCHROMIUM(); | |
117 virtual void ensureBackbufferCHROMIUM(); | |
118 | |
119 virtual void copyTextureToParentTextureCHROMIUM( | |
120 WebGLId texture, WebGLId parentTexture); | |
121 | |
122 virtual void rateLimitOffscreenContextCHROMIUM() { } | |
123 | |
124 virtual WebString getRequestableExtensionsCHROMIUM(); | |
125 virtual void requestExtensionCHROMIUM(const char*); | |
126 | |
127 virtual void blitFramebufferCHROMIUM( | |
128 WGC3Dint srcX0, WGC3Dint srcY0, WGC3Dint srcX1, WGC3Dint srcY1, | |
129 WGC3Dint dstX0, WGC3Dint dstY0, WGC3Dint dstX1, WGC3Dint dstY1, | |
130 WGC3Dbitfield mask, WGC3Denum filter); | |
131 virtual void renderbufferStorageMultisampleCHROMIUM( | |
132 WGC3Denum target, WGC3Dsizei samples, WGC3Denum internalformat, | |
133 WGC3Dsizei width, WGC3Dsizei height); | |
134 | |
135 virtual void activeTexture(WGC3Denum texture); | |
136 virtual void attachShader(WebGLId program, WebGLId shader); | |
137 virtual void bindAttribLocation( | |
138 WebGLId program, WGC3Duint index, const WGC3Dchar* name); | |
139 virtual void bindBuffer(WGC3Denum target, WebGLId buffer); | |
140 virtual void bindFramebuffer(WGC3Denum target, WebGLId framebuffer); | |
141 virtual void bindRenderbuffer( | |
142 WGC3Denum target, WebGLId renderbuffer); | |
143 virtual void bindTexture(WGC3Denum target, WebGLId texture); | |
144 virtual void blendColor( | |
145 WGC3Dclampf red, WGC3Dclampf green, WGC3Dclampf blue, WGC3Dclampf alpha); | |
146 virtual void blendEquation(WGC3Denum mode); | |
147 virtual void blendEquationSeparate(WGC3Denum modeRGB, WGC3Denum modeAlpha); | |
148 virtual void blendFunc(WGC3Denum sfactor, WGC3Denum dfactor); | |
149 virtual void blendFuncSeparate(WGC3Denum srcRGB, WGC3Denum dstRGB, | |
150 WGC3Denum srcAlpha, WGC3Denum dstAlpha); | |
151 | |
152 virtual void bufferData( | |
153 WGC3Denum target, WGC3Dsizeiptr size, const void* data, WGC3Denum usage); | |
154 virtual void bufferSubData(WGC3Denum target, WGC3Dintptr offset, | |
155 WGC3Dsizeiptr size, const void* data); | |
156 | |
157 virtual WGC3Denum checkFramebufferStatus(WGC3Denum target); | |
158 virtual void clear(WGC3Dbitfield mask); | |
159 virtual void clearColor( | |
160 WGC3Dclampf red, WGC3Dclampf green, WGC3Dclampf blue, WGC3Dclampf alpha); | |
161 virtual void clearDepth(WGC3Dclampf depth); | |
162 virtual void clearStencil(WGC3Dint s); | |
163 virtual void colorMask(WGC3Dboolean red, WGC3Dboolean green, | |
164 WGC3Dboolean blue, WGC3Dboolean alpha); | |
165 virtual void compileShader(WebGLId shader); | |
166 | |
167 virtual void compressedTexImage2D( | |
168 WGC3Denum target, | |
169 WGC3Dint level, | |
170 WGC3Denum internalformat, | |
171 WGC3Dsizei width, | |
172 WGC3Dsizei height, | |
173 WGC3Dint border, | |
174 WGC3Dsizei imageSize, | |
175 const void* data); | |
176 virtual void compressedTexSubImage2D( | |
177 WGC3Denum target, | |
178 WGC3Dint level, | |
179 WGC3Dint xoffset, | |
180 WGC3Dint yoffset, | |
181 WGC3Dsizei width, | |
182 WGC3Dsizei height, | |
183 WGC3Denum format, | |
184 WGC3Dsizei imageSize, | |
185 const void* data); | |
186 virtual void copyTexImage2D( | |
187 WGC3Denum target, | |
188 WGC3Dint level, | |
189 WGC3Denum internalformat, | |
190 WGC3Dint x, | |
191 WGC3Dint y, | |
192 WGC3Dsizei width, | |
193 WGC3Dsizei height, | |
194 WGC3Dint border); | |
195 virtual void copyTexSubImage2D( | |
196 WGC3Denum target, | |
197 WGC3Dint level, | |
198 WGC3Dint xoffset, | |
199 WGC3Dint yoffset, | |
200 WGC3Dint x, | |
201 WGC3Dint y, | |
202 WGC3Dsizei width, | |
203 WGC3Dsizei height); | |
204 virtual void cullFace(WGC3Denum mode); | |
205 virtual void depthFunc(WGC3Denum func); | |
206 virtual void depthMask(WGC3Dboolean flag); | |
207 virtual void depthRange(WGC3Dclampf zNear, WGC3Dclampf zFar); | |
208 virtual void detachShader(WebGLId program, WebGLId shader); | |
209 virtual void disable(WGC3Denum cap); | |
210 virtual void disableVertexAttribArray(WGC3Duint index); | |
211 virtual void drawArrays(WGC3Denum mode, WGC3Dint first, WGC3Dsizei count); | |
212 virtual void drawElements( | |
213 WGC3Denum mode, | |
214 WGC3Dsizei count, | |
215 WGC3Denum type, | |
216 WGC3Dintptr offset); | |
217 | |
218 virtual void enable(WGC3Denum cap); | |
219 virtual void enableVertexAttribArray(WGC3Duint index); | |
220 virtual void finish(); | |
221 virtual void flush(); | |
222 virtual void framebufferRenderbuffer( | |
223 WGC3Denum target, | |
224 WGC3Denum attachment, | |
225 WGC3Denum renderbuffertarget, | |
226 WebGLId renderbuffer); | |
227 virtual void framebufferTexture2D( | |
228 WGC3Denum target, | |
229 WGC3Denum attachment, | |
230 WGC3Denum textarget, | |
231 WebGLId texture, | |
232 WGC3Dint level); | |
233 virtual void frontFace(WGC3Denum mode); | |
234 virtual void generateMipmap(WGC3Denum target); | |
235 | |
236 virtual bool getActiveAttrib(WebGLId program, WGC3Duint index, ActiveInfo&); | |
237 virtual bool getActiveUniform(WebGLId program, WGC3Duint index, ActiveInfo&); | |
238 | |
239 virtual void getAttachedShaders(WebGLId program, WGC3Dsizei maxCount, | |
240 WGC3Dsizei* count, WebGLId* shaders); | |
241 | |
242 virtual WGC3Dint getAttribLocation(WebGLId program, const WGC3Dchar* name); | |
243 | |
244 virtual void getBooleanv(WGC3Denum pname, WGC3Dboolean* value); | |
245 | |
246 virtual void getBufferParameteriv( | |
247 WGC3Denum target, WGC3Denum pname, WGC3Dint* value); | |
248 | |
249 virtual Attributes getContextAttributes(); | |
250 | |
251 virtual WGC3Denum getError(); | |
252 | |
253 virtual bool isContextLost(); | |
254 | |
255 virtual void getFloatv(WGC3Denum pname, WGC3Dfloat* value); | |
256 | |
257 virtual void getFramebufferAttachmentParameteriv( | |
258 WGC3Denum target, | |
259 WGC3Denum attachment, | |
260 WGC3Denum pname, | |
261 WGC3Dint* value); | |
262 | |
263 virtual void getIntegerv(WGC3Denum pname, WGC3Dint* value); | |
264 | |
265 virtual void getProgramiv( | |
266 WebGLId program, WGC3Denum pname, WGC3Dint* value); | |
267 | |
268 virtual WebString getProgramInfoLog(WebGLId program); | |
269 | |
270 virtual void getRenderbufferParameteriv( | |
271 WGC3Denum target, WGC3Denum pname, WGC3Dint* value); | |
272 | |
273 virtual void getShaderiv( | |
274 WebGLId shader, WGC3Denum pname, WGC3Dint* value); | |
275 | |
276 virtual WebString getShaderInfoLog(WebGLId shader); | |
277 | |
278 virtual void getShaderPrecisionFormat( | |
279 WGC3Denum shadertype, WGC3Denum precisiontype, | |
280 WGC3Dint* range, WGC3Dint* precision); | |
281 | |
282 virtual WebString getShaderSource(WebGLId shader); | |
283 virtual WebString getString(WGC3Denum name); | |
284 | |
285 virtual void getTexParameterfv( | |
286 WGC3Denum target, WGC3Denum pname, WGC3Dfloat* value); | |
287 virtual void getTexParameteriv( | |
288 WGC3Denum target, WGC3Denum pname, WGC3Dint* value); | |
289 | |
290 virtual void getUniformfv( | |
291 WebGLId program, WGC3Dint location, WGC3Dfloat* value); | |
292 virtual void getUniformiv( | |
293 WebGLId program, WGC3Dint location, WGC3Dint* value); | |
294 | |
295 virtual WGC3Dint getUniformLocation(WebGLId program, const WGC3Dchar* name); | |
296 | |
297 virtual void getVertexAttribfv( | |
298 WGC3Duint index, WGC3Denum pname, WGC3Dfloat* value); | |
299 virtual void getVertexAttribiv( | |
300 WGC3Duint index, WGC3Denum pname, WGC3Dint* value); | |
301 | |
302 virtual WGC3Dsizeiptr getVertexAttribOffset( | |
303 WGC3Duint index, WGC3Denum pname); | |
304 | |
305 virtual void hint(WGC3Denum target, WGC3Denum mode); | |
306 virtual WGC3Dboolean isBuffer(WebGLId buffer); | |
307 virtual WGC3Dboolean isEnabled(WGC3Denum cap); | |
308 virtual WGC3Dboolean isFramebuffer(WebGLId framebuffer); | |
309 virtual WGC3Dboolean isProgram(WebGLId program); | |
310 virtual WGC3Dboolean isRenderbuffer(WebGLId renderbuffer); | |
311 virtual WGC3Dboolean isShader(WebGLId shader); | |
312 virtual WGC3Dboolean isTexture(WebGLId texture); | |
313 virtual void lineWidth(WGC3Dfloat width); | |
314 virtual void linkProgram(WebGLId program); | |
315 virtual void pixelStorei(WGC3Denum pname, WGC3Dint param); | |
316 virtual void polygonOffset(WGC3Dfloat factor, WGC3Dfloat units); | |
317 | |
318 virtual void readPixels( | |
319 WGC3Dint x, WGC3Dint y, | |
320 WGC3Dsizei width, WGC3Dsizei height, | |
321 WGC3Denum format, | |
322 WGC3Denum type, | |
323 void* pixels); | |
324 | |
325 virtual void releaseShaderCompiler(); | |
326 virtual void renderbufferStorage( | |
327 WGC3Denum target, | |
328 WGC3Denum internalformat, | |
329 WGC3Dsizei width, | |
330 WGC3Dsizei height); | |
331 virtual void sampleCoverage(WGC3Dclampf value, WGC3Dboolean invert); | |
332 virtual void scissor( | |
333 WGC3Dint x, WGC3Dint y, WGC3Dsizei width, WGC3Dsizei height); | |
334 virtual void shaderSource(WebGLId shader, const WGC3Dchar* source); | |
335 virtual void stencilFunc(WGC3Denum func, WGC3Dint ref, WGC3Duint mask); | |
336 virtual void stencilFuncSeparate( | |
337 WGC3Denum face, WGC3Denum func, WGC3Dint ref, WGC3Duint mask); | |
338 virtual void stencilMask(WGC3Duint mask); | |
339 virtual void stencilMaskSeparate(WGC3Denum face, WGC3Duint mask); | |
340 virtual void stencilOp(WGC3Denum fail, WGC3Denum zfail, WGC3Denum zpass); | |
341 virtual void stencilOpSeparate( | |
342 WGC3Denum face, | |
343 WGC3Denum fail, | |
344 WGC3Denum zfail, | |
345 WGC3Denum zpass); | |
346 | |
347 virtual void texImage2D( | |
348 WGC3Denum target, | |
349 WGC3Dint level, | |
350 WGC3Denum internalformat, | |
351 WGC3Dsizei width, | |
352 WGC3Dsizei height, | |
353 WGC3Dint border, | |
354 WGC3Denum format, | |
355 WGC3Denum type, | |
356 const void* pixels); | |
357 | |
358 virtual void texParameterf( | |
359 WGC3Denum target, WGC3Denum pname, WGC3Dfloat param); | |
360 virtual void texParameteri( | |
361 WGC3Denum target, WGC3Denum pname, WGC3Dint param); | |
362 | |
363 virtual void texSubImage2D( | |
364 WGC3Denum target, | |
365 WGC3Dint level, | |
366 WGC3Dint xoffset, | |
367 WGC3Dint yoffset, | |
368 WGC3Dsizei width, | |
369 WGC3Dsizei height, | |
370 WGC3Denum format, | |
371 WGC3Denum type, | |
372 const void* pixels); | |
373 | |
374 virtual void uniform1f(WGC3Dint location, WGC3Dfloat x); | |
375 virtual void uniform1fv(WGC3Dint location, WGC3Dsizei count, | |
376 const WGC3Dfloat* v); | |
377 virtual void uniform1i(WGC3Dint location, WGC3Dint x); | |
378 virtual void uniform1iv(WGC3Dint location, WGC3Dsizei count, | |
379 const WGC3Dint* v); | |
380 virtual void uniform2f(WGC3Dint location, WGC3Dfloat x, WGC3Dfloat y); | |
381 virtual void uniform2fv(WGC3Dint location, WGC3Dsizei count, | |
382 const WGC3Dfloat* v); | |
383 virtual void uniform2i(WGC3Dint location, WGC3Dint x, WGC3Dint y); | |
384 virtual void uniform2iv(WGC3Dint location, WGC3Dsizei count, | |
385 const WGC3Dint* v); | |
386 virtual void uniform3f(WGC3Dint location, | |
387 WGC3Dfloat x, WGC3Dfloat y, WGC3Dfloat z); | |
388 virtual void uniform3fv(WGC3Dint location, WGC3Dsizei count, | |
389 const WGC3Dfloat* v); | |
390 virtual void uniform3i(WGC3Dint location, WGC3Dint x, WGC3Dint y, WGC3Dint z); | |
391 virtual void uniform3iv(WGC3Dint location, WGC3Dsizei count, | |
392 const WGC3Dint* v); | |
393 virtual void uniform4f(WGC3Dint location, WGC3Dfloat x, WGC3Dfloat y, | |
394 WGC3Dfloat z, WGC3Dfloat w); | |
395 virtual void uniform4fv(WGC3Dint location, WGC3Dsizei count, | |
396 const WGC3Dfloat* v); | |
397 virtual void uniform4i(WGC3Dint location, WGC3Dint x, WGC3Dint y, | |
398 WGC3Dint z, WGC3Dint w); | |
399 virtual void uniform4iv(WGC3Dint location, WGC3Dsizei count, | |
400 const WGC3Dint* v); | |
401 virtual void uniformMatrix2fv( | |
402 WGC3Dint location, WGC3Dsizei count, | |
403 WGC3Dboolean transpose, const WGC3Dfloat* value); | |
404 virtual void uniformMatrix3fv( | |
405 WGC3Dint location, WGC3Dsizei count, | |
406 WGC3Dboolean transpose, const WGC3Dfloat* value); | |
407 virtual void uniformMatrix4fv( | |
408 WGC3Dint location, WGC3Dsizei count, | |
409 WGC3Dboolean transpose, const WGC3Dfloat* value); | |
410 | |
411 virtual void useProgram(WebGLId program); | |
412 virtual void validateProgram(WebGLId program); | |
413 | |
414 virtual void vertexAttrib1f(WGC3Duint index, WGC3Dfloat x); | |
415 virtual void vertexAttrib1fv(WGC3Duint index, const WGC3Dfloat* values); | |
416 virtual void vertexAttrib2f(WGC3Duint index, WGC3Dfloat x, WGC3Dfloat y); | |
417 virtual void vertexAttrib2fv(WGC3Duint index, const WGC3Dfloat* values); | |
418 virtual void vertexAttrib3f( | |
419 WGC3Duint index, WGC3Dfloat x, WGC3Dfloat y, WGC3Dfloat z); | |
420 virtual void vertexAttrib3fv(WGC3Duint index, const WGC3Dfloat* values); | |
421 virtual void vertexAttrib4f( | |
422 WGC3Duint index, WGC3Dfloat x, WGC3Dfloat y, WGC3Dfloat z, WGC3Dfloat w); | |
423 virtual void vertexAttrib4fv(WGC3Duint index, const WGC3Dfloat* values); | |
424 virtual void vertexAttribPointer( | |
425 WGC3Duint index, | |
426 WGC3Dint size, | |
427 WGC3Denum type, | |
428 WGC3Dboolean normalized, | |
429 WGC3Dsizei stride, | |
430 WGC3Dintptr offset); | |
431 | |
432 virtual void viewport( | |
433 WGC3Dint x, WGC3Dint y, WGC3Dsizei width, WGC3Dsizei height); | |
434 | |
435 // Support for buffer creation and deletion | |
436 virtual WebGLId createBuffer(); | |
437 virtual WebGLId createFramebuffer(); | |
438 virtual WebGLId createProgram(); | |
439 virtual WebGLId createRenderbuffer(); | |
440 virtual WebGLId createShader(WGC3Denum); | |
441 virtual WebGLId createTexture(); | |
442 | |
443 virtual void deleteBuffer(WebGLId); | |
444 virtual void deleteFramebuffer(WebGLId); | |
445 virtual void deleteProgram(WebGLId); | |
446 virtual void deleteRenderbuffer(WebGLId); | |
447 virtual void deleteShader(WebGLId); | |
448 virtual void deleteTexture(WebGLId); | |
449 | |
450 virtual void setContextLostCallback( | |
451 WebGraphicsContext3D::WebGraphicsContextLostCallback* callback) {} | |
452 virtual WGC3Denum getGraphicsResetStatusARB(); | |
453 | |
454 virtual void setSwapBuffersCompleteCallbackCHROMIUM( | |
455 WebGraphicsContext3D:: | |
456 WebGraphicsSwapBuffersCompleteCallbackCHROMIUM* callback) {} | |
457 | |
458 virtual void texImageIOSurface2DCHROMIUM( | |
459 WGC3Denum target, WGC3Dint width, WGC3Dint height, | |
460 WGC3Duint ioSurfaceId, WGC3Duint plane); | |
461 | |
462 virtual void texStorage2DEXT( | |
463 WGC3Denum target, WGC3Dint levels, WGC3Duint internalformat, | |
464 WGC3Dint width, WGC3Dint height); | |
465 | |
466 virtual WebGLId createQueryEXT(); | |
467 virtual void deleteQueryEXT(WebGLId query); | |
468 virtual WGC3Dboolean isQueryEXT(WebGLId query); | |
469 virtual void beginQueryEXT(WGC3Denum target, WebGLId query); | |
470 virtual void endQueryEXT(WGC3Denum target); | |
471 virtual void getQueryivEXT( | |
472 WGC3Denum target, WGC3Denum pname, WGC3Dint* params); | |
473 virtual void getQueryObjectuivEXT( | |
474 WebGLId query, WGC3Denum pname, WGC3Duint* params); | |
475 | |
476 virtual void copyTextureCHROMIUM(WGC3Denum target, WGC3Duint source_id, | |
477 WGC3Duint dest_id, WGC3Dint level, | |
478 WGC3Denum internal_format, | |
479 WGC3Denum dest_type); | |
480 | |
481 virtual void bindUniformLocationCHROMIUM(WebGLId program, WGC3Dint location, | |
482 const WGC3Dchar* uniform); | |
483 | |
484 // CHROMIUM_shallow_flush | |
485 // Only applies to contexts that use the command buffer. | |
486 virtual void shallowFlushCHROMIUM() { } | |
487 | |
488 virtual void genMailboxCHROMIUM(WGC3Dbyte* mailbox); | |
489 virtual void produceTextureCHROMIUM(WGC3Denum target, | |
490 const WGC3Dbyte* mailbox); | |
491 virtual void consumeTextureCHROMIUM(WGC3Denum target, | |
492 const WGC3Dbyte* mailbox); | |
493 | |
494 virtual void bindTexImage2DCHROMIUM(WGC3Denum target, WGC3Dint imageId); | |
495 virtual void releaseTexImage2DCHROMIUM(WGC3Denum target, WGC3Dint imageId); | |
496 | |
497 virtual void* mapBufferCHROMIUM(WGC3Denum target, WGC3Denum access); | |
498 virtual WGC3Dboolean unmapBufferCHROMIUM(WGC3Denum target); | |
499 | |
500 virtual void drawBuffersEXT(WGC3Dsizei n, const WGC3Denum* bufs); | |
501 | |
502 protected: | |
503 virtual GrGLInterface* onCreateGrGLInterface(); | |
504 | |
505 private: | |
506 bool Initialize(Attributes attributes); | |
507 | |
508 // ANGLE related. | |
509 struct ShaderSourceEntry; | |
510 | |
511 typedef base::hash_map<WebGLId, ShaderSourceEntry*> ShaderSourceMap; | |
512 | |
513 bool AllocateOffscreenFrameBuffer(int width, int height); | |
514 void ClearRenderTarget(); | |
515 | |
516 void FlipVertically(unsigned char* framebuffer, | |
517 unsigned int width, | |
518 unsigned int height); | |
519 | |
520 // Take into account the user's requested context creation attributes, in | |
521 // particular stencil and antialias, and determine which could or could | |
522 // not be honored based on the capabilities of the OpenGL implementation. | |
523 void ValidateAttributes(); | |
524 | |
525 // Resolve the given rectangle of the multisampled framebuffer if necessary. | |
526 void ResolveMultisampledFramebuffer( | |
527 WGC3Dint x, WGC3Dint y, WGC3Dsizei width, WGC3Dsizei height); | |
528 | |
529 bool AngleCreateCompilers(); | |
530 void AngleDestroyCompilers(); | |
531 bool AngleValidateShaderSource(ShaderSourceEntry* entry); | |
532 | |
533 WebGraphicsContext3D::Attributes attributes_; | |
534 bool initialized_; | |
535 bool render_directly_to_web_view_; | |
536 bool is_gles2_; | |
537 bool have_ext_framebuffer_object_; | |
538 bool have_ext_framebuffer_multisample_; | |
539 bool have_angle_framebuffer_multisample_; | |
540 bool have_ext_oes_standard_derivatives_; | |
541 bool have_ext_oes_egl_image_external_; | |
542 | |
543 WebGLId texture_; | |
544 WebGLId fbo_; | |
545 WebGLId depth_stencil_buffer_; | |
546 int cached_width_, cached_height_; | |
547 | |
548 // For multisampling | |
549 WebGLId multisample_fbo_; | |
550 WebGLId multisample_depth_stencil_buffer_; | |
551 WebGLId multisample_color_buffer_; | |
552 | |
553 // For tracking which FBO is bound | |
554 WebGLId bound_fbo_; | |
555 | |
556 // For tracking which texture is bound | |
557 WebGLId bound_texture_; | |
558 | |
559 unsigned char* scanline_; | |
560 | |
561 // Errors raised by synthesizeGLError(). | |
562 std::list<WGC3Denum> synthetic_errors_list_; | |
563 std::set<WGC3Denum> synthetic_errors_set_; | |
564 | |
565 scoped_refptr<gfx::GLContext> gl_context_; | |
566 scoped_refptr<gfx::GLSurface> gl_surface_; | |
567 | |
568 ShaderSourceMap shader_source_map_; | |
569 | |
570 ShHandle fragment_compiler_; | |
571 ShHandle vertex_compiler_; | |
572 }; | |
573 | |
574 } // namespace gpu | |
575 } // namespace webkit | |
576 | |
577 #endif // WEBKIT_GPU_WEBGRAPHICSCONTEXT3D_IN_PROCESS_IMPL_H_ | |
OLD | NEW |