OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CONTENT_COMMON_GPU_CLIENT_WEBGRAPHICSCONTEXT3D_COMMAND_BUFFER_IMPL_H_ | 5 #ifndef CONTENT_COMMON_GPU_CLIENT_WEBGRAPHICSCONTEXT3D_COMMAND_BUFFER_IMPL_H_ |
6 #define CONTENT_COMMON_GPU_CLIENT_WEBGRAPHICSCONTEXT3D_COMMAND_BUFFER_IMPL_H_ | 6 #define CONTENT_COMMON_GPU_CLIENT_WEBGRAPHICSCONTEXT3D_COMMAND_BUFFER_IMPL_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/callback.h" | 11 #include "base/callback.h" |
12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
13 #include "base/memory/weak_ptr.h" | 13 #include "base/memory/weak_ptr.h" |
14 #include "base/synchronization/lock.h" | 14 #include "base/synchronization/lock.h" |
15 #include "content/common/content_export.h" | 15 #include "content/common/content_export.h" |
16 #include "content/common/gpu/client/command_buffer_proxy_impl.h" | 16 #include "content/common/gpu/client/command_buffer_proxy_impl.h" |
17 #include "third_party/WebKit/public/platform/WebGraphicsContext3D.h" | 17 #include "third_party/WebKit/public/platform/WebGraphicsContext3D.h" |
18 #include "third_party/WebKit/public/platform/WebString.h" | 18 #include "third_party/WebKit/public/platform/WebString.h" |
19 #include "ui/gfx/native_widget_types.h" | 19 #include "ui/gfx/native_widget_types.h" |
20 #include "ui/gl/gpu_preference.h" | 20 #include "ui/gl/gpu_preference.h" |
21 #include "url/gurl.h" | 21 #include "url/gurl.h" |
| 22 #include "webkit/common/gpu/webgraphicscontext3d_impl.h" |
22 | 23 |
23 namespace gpu { | 24 namespace gpu { |
24 | 25 |
25 class ContextSupport; | 26 class ContextSupport; |
26 class TransferBuffer; | 27 class TransferBuffer; |
27 | 28 |
28 namespace gles2 { | 29 namespace gles2 { |
29 class GLES2CmdHelper; | 30 class GLES2CmdHelper; |
30 class GLES2Implementation; | 31 class GLES2Implementation; |
31 class GLES2Interface; | 32 class GLES2Interface; |
32 } | 33 } |
33 } | 34 } |
34 | 35 |
35 using blink::WebGLId; | |
36 | |
37 using blink::WGC3Dbyte; | |
38 using blink::WGC3Dchar; | |
39 using blink::WGC3Denum; | |
40 using blink::WGC3Dboolean; | |
41 using blink::WGC3Dbitfield; | |
42 using blink::WGC3Dint; | |
43 using blink::WGC3Dsizei; | |
44 using blink::WGC3Duint; | |
45 using blink::WGC3Dfloat; | |
46 using blink::WGC3Dclampf; | |
47 using blink::WGC3Dintptr; | |
48 using blink::WGC3Dsizeiptr; | |
49 | |
50 namespace content { | 36 namespace content { |
51 class GpuChannelHost; | 37 class GpuChannelHost; |
52 | 38 |
53 const size_t kDefaultCommandBufferSize = 1024 * 1024; | 39 const size_t kDefaultCommandBufferSize = 1024 * 1024; |
54 const size_t kDefaultStartTransferBufferSize = 1 * 1024 * 1024; | 40 const size_t kDefaultStartTransferBufferSize = 1 * 1024 * 1024; |
55 const size_t kDefaultMinTransferBufferSize = 1 * 256 * 1024; | 41 const size_t kDefaultMinTransferBufferSize = 1 * 256 * 1024; |
56 const size_t kDefaultMaxTransferBufferSize = 16 * 1024 * 1024; | 42 const size_t kDefaultMaxTransferBufferSize = 16 * 1024 * 1024; |
57 | 43 |
58 class WebGraphicsContext3DErrorMessageCallback; | |
59 | |
60 class WebGraphicsContext3DCommandBufferImpl | 44 class WebGraphicsContext3DCommandBufferImpl |
61 : public blink::WebGraphicsContext3D { | 45 : public WebGraphicsContext3DImpl { |
62 public: | 46 public: |
63 enum MappedMemoryReclaimLimit { | 47 enum MappedMemoryReclaimLimit { |
64 kNoLimit = 0, | 48 kNoLimit = 0, |
65 }; | 49 }; |
66 | 50 |
67 struct CONTENT_EXPORT SharedMemoryLimits { | 51 struct CONTENT_EXPORT SharedMemoryLimits { |
68 SharedMemoryLimits(); | 52 SharedMemoryLimits(); |
69 | 53 |
70 size_t command_buffer_size; | 54 size_t command_buffer_size; |
71 size_t start_transfer_buffer_size; | 55 size_t start_transfer_buffer_size; |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 } | 143 } |
160 | 144 |
161 //---------------------------------------------------------------------- | 145 //---------------------------------------------------------------------- |
162 // WebGraphicsContext3D methods | 146 // WebGraphicsContext3D methods |
163 | 147 |
164 // Must be called after initialize() and before any of the following methods. | 148 // Must be called after initialize() and before any of the following methods. |
165 // Permanently binds to the first calling thread. Returns false if the | 149 // Permanently binds to the first calling thread. Returns false if the |
166 // graphics context fails to create. Do not call from more than one thread. | 150 // graphics context fails to create. Do not call from more than one thread. |
167 virtual bool makeContextCurrent(); | 151 virtual bool makeContextCurrent(); |
168 | 152 |
169 virtual uint32_t lastFlushID(); | |
170 | |
171 virtual unsigned int insertSyncPoint(); | |
172 virtual void waitSyncPoint(unsigned int sync_point); | |
173 | |
174 virtual void loseContextCHROMIUM(WGC3Denum current, WGC3Denum other); | |
175 | |
176 virtual void reshapeWithScaleFactor( | |
177 int width, int height, float scale_factor); | |
178 | |
179 virtual void prepareTexture(); | |
180 virtual void postSubBufferCHROMIUM(int x, int y, int width, int height); | |
181 | |
182 virtual void activeTexture(WGC3Denum texture); | |
183 virtual void attachShader(WebGLId program, WebGLId shader); | |
184 virtual void bindAttribLocation(WebGLId program, WGC3Duint index, | |
185 const WGC3Dchar* name); | |
186 virtual void bindBuffer(WGC3Denum target, WebGLId buffer); | |
187 virtual void bindFramebuffer(WGC3Denum target, WebGLId framebuffer); | |
188 virtual void bindRenderbuffer(WGC3Denum target, WebGLId renderbuffer); | |
189 virtual void bindTexture(WGC3Denum target, WebGLId texture); | |
190 virtual void blendColor(WGC3Dclampf red, WGC3Dclampf green, | |
191 WGC3Dclampf blue, WGC3Dclampf alpha); | |
192 virtual void blendEquation(WGC3Denum mode); | |
193 virtual void blendEquationSeparate(WGC3Denum modeRGB, | |
194 WGC3Denum modeAlpha); | |
195 virtual void blendFunc(WGC3Denum sfactor, WGC3Denum dfactor); | |
196 virtual void blendFuncSeparate(WGC3Denum srcRGB, | |
197 WGC3Denum dstRGB, | |
198 WGC3Denum srcAlpha, | |
199 WGC3Denum dstAlpha); | |
200 | |
201 virtual void bufferData(WGC3Denum target, WGC3Dsizeiptr size, | |
202 const void* data, WGC3Denum usage); | |
203 virtual void bufferSubData(WGC3Denum target, WGC3Dintptr offset, | |
204 WGC3Dsizeiptr size, const void* data); | |
205 | |
206 virtual WGC3Denum checkFramebufferStatus(WGC3Denum target); | |
207 virtual void clear(WGC3Dbitfield mask); | |
208 virtual void clearColor(WGC3Dclampf red, WGC3Dclampf green, | |
209 WGC3Dclampf blue, WGC3Dclampf alpha); | |
210 virtual void clearDepth(WGC3Dclampf depth); | |
211 virtual void clearStencil(WGC3Dint s); | |
212 virtual void colorMask(WGC3Dboolean red, WGC3Dboolean green, | |
213 WGC3Dboolean blue, WGC3Dboolean alpha); | |
214 virtual void compileShader(WebGLId shader); | |
215 | |
216 virtual void compressedTexImage2D(WGC3Denum target, | |
217 WGC3Dint level, | |
218 WGC3Denum internalformat, | |
219 WGC3Dsizei width, | |
220 WGC3Dsizei height, | |
221 WGC3Dint border, | |
222 WGC3Dsizei imageSize, | |
223 const void* data); | |
224 virtual void compressedTexSubImage2D(WGC3Denum target, | |
225 WGC3Dint level, | |
226 WGC3Dint xoffset, | |
227 WGC3Dint yoffset, | |
228 WGC3Dsizei width, | |
229 WGC3Dsizei height, | |
230 WGC3Denum format, | |
231 WGC3Dsizei imageSize, | |
232 const void* data); | |
233 virtual void copyTexImage2D(WGC3Denum target, | |
234 WGC3Dint level, | |
235 WGC3Denum internalformat, | |
236 WGC3Dint x, | |
237 WGC3Dint y, | |
238 WGC3Dsizei width, | |
239 WGC3Dsizei height, | |
240 WGC3Dint border); | |
241 virtual void copyTexSubImage2D(WGC3Denum target, | |
242 WGC3Dint level, | |
243 WGC3Dint xoffset, | |
244 WGC3Dint yoffset, | |
245 WGC3Dint x, | |
246 WGC3Dint y, | |
247 WGC3Dsizei width, | |
248 WGC3Dsizei height); | |
249 virtual void cullFace(WGC3Denum mode); | |
250 virtual void depthFunc(WGC3Denum func); | |
251 virtual void depthMask(WGC3Dboolean flag); | |
252 virtual void depthRange(WGC3Dclampf zNear, WGC3Dclampf zFar); | |
253 virtual void detachShader(WebGLId program, WebGLId shader); | |
254 virtual void disable(WGC3Denum cap); | |
255 virtual void disableVertexAttribArray(WGC3Duint index); | |
256 virtual void drawArrays(WGC3Denum mode, WGC3Dint first, WGC3Dsizei count); | |
257 virtual void drawElements(WGC3Denum mode, | |
258 WGC3Dsizei count, | |
259 WGC3Denum type, | |
260 WGC3Dintptr offset); | |
261 | |
262 virtual void enable(WGC3Denum cap); | |
263 virtual void enableVertexAttribArray(WGC3Duint index); | |
264 virtual void finish(); | |
265 virtual void flush(); | |
266 virtual void framebufferRenderbuffer(WGC3Denum target, | |
267 WGC3Denum attachment, | |
268 WGC3Denum renderbuffertarget, | |
269 WebGLId renderbuffer); | |
270 virtual void framebufferTexture2D(WGC3Denum target, | |
271 WGC3Denum attachment, | |
272 WGC3Denum textarget, | |
273 WebGLId texture, | |
274 WGC3Dint level); | |
275 virtual void frontFace(WGC3Denum mode); | |
276 virtual void generateMipmap(WGC3Denum target); | |
277 | |
278 virtual bool getActiveAttrib(WebGLId program, | |
279 WGC3Duint index, | |
280 ActiveInfo&); | |
281 virtual bool getActiveUniform(WebGLId program, | |
282 WGC3Duint index, | |
283 ActiveInfo&); | |
284 | |
285 virtual void getAttachedShaders(WebGLId program, | |
286 WGC3Dsizei maxCount, | |
287 WGC3Dsizei* count, | |
288 WebGLId* shaders); | |
289 | |
290 virtual WGC3Dint getAttribLocation(WebGLId program, const WGC3Dchar* name); | |
291 | |
292 virtual void getBooleanv(WGC3Denum pname, WGC3Dboolean* value); | |
293 | |
294 virtual void getBufferParameteriv(WGC3Denum target, | |
295 WGC3Denum pname, | |
296 WGC3Dint* value); | |
297 | |
298 virtual Attributes getContextAttributes(); | |
299 | |
300 virtual WGC3Denum getError(); | |
301 | |
302 virtual bool isContextLost(); | 153 virtual bool isContextLost(); |
303 | 154 |
304 virtual void getFloatv(WGC3Denum pname, WGC3Dfloat* value); | |
305 | |
306 virtual void getFramebufferAttachmentParameteriv(WGC3Denum target, | |
307 WGC3Denum attachment, | |
308 WGC3Denum pname, | |
309 WGC3Dint* value); | |
310 | |
311 virtual void getIntegerv(WGC3Denum pname, WGC3Dint* value); | |
312 | |
313 virtual void getProgramiv(WebGLId program, WGC3Denum pname, WGC3Dint* value); | |
314 | |
315 virtual blink::WebString getProgramInfoLog(WebGLId program); | |
316 | |
317 virtual void getRenderbufferParameteriv(WGC3Denum target, | |
318 WGC3Denum pname, | |
319 WGC3Dint* value); | |
320 | |
321 virtual void getShaderiv(WebGLId shader, WGC3Denum pname, WGC3Dint* value); | |
322 | |
323 virtual blink::WebString getShaderInfoLog(WebGLId shader); | |
324 | |
325 virtual void getShaderPrecisionFormat(WGC3Denum shadertype, | |
326 WGC3Denum precisiontype, | |
327 WGC3Dint* range, | |
328 WGC3Dint* precision); | |
329 | |
330 virtual blink::WebString getShaderSource(WebGLId shader); | |
331 virtual blink::WebString getString(WGC3Denum name); | |
332 | |
333 virtual void getTexParameterfv(WGC3Denum target, | |
334 WGC3Denum pname, | |
335 WGC3Dfloat* value); | |
336 virtual void getTexParameteriv(WGC3Denum target, | |
337 WGC3Denum pname, | |
338 WGC3Dint* value); | |
339 | |
340 virtual void getUniformfv(WebGLId program, | |
341 WGC3Dint location, | |
342 WGC3Dfloat* value); | |
343 virtual void getUniformiv(WebGLId program, | |
344 WGC3Dint location, | |
345 WGC3Dint* value); | |
346 | |
347 virtual WGC3Dint getUniformLocation(WebGLId program, const WGC3Dchar* name); | |
348 | |
349 virtual void getVertexAttribfv(WGC3Duint index, WGC3Denum pname, | |
350 WGC3Dfloat* value); | |
351 virtual void getVertexAttribiv(WGC3Duint index, WGC3Denum pname, | |
352 WGC3Dint* value); | |
353 | |
354 virtual WGC3Dsizeiptr getVertexAttribOffset(WGC3Duint index, WGC3Denum pname); | |
355 | |
356 virtual void hint(WGC3Denum target, WGC3Denum mode); | |
357 virtual WGC3Dboolean isBuffer(WebGLId buffer); | |
358 virtual WGC3Dboolean isEnabled(WGC3Denum cap); | |
359 virtual WGC3Dboolean isFramebuffer(WebGLId framebuffer); | |
360 virtual WGC3Dboolean isProgram(WebGLId program); | |
361 virtual WGC3Dboolean isRenderbuffer(WebGLId renderbuffer); | |
362 virtual WGC3Dboolean isShader(WebGLId shader); | |
363 virtual WGC3Dboolean isTexture(WebGLId texture); | |
364 virtual void lineWidth(WGC3Dfloat); | |
365 virtual void linkProgram(WebGLId program); | |
366 virtual void pixelStorei(WGC3Denum pname, WGC3Dint param); | |
367 virtual void polygonOffset(WGC3Dfloat factor, WGC3Dfloat units); | |
368 | |
369 virtual void readPixels(WGC3Dint x, | |
370 WGC3Dint y, | |
371 WGC3Dsizei width, | |
372 WGC3Dsizei height, | |
373 WGC3Denum format, | |
374 WGC3Denum type, | |
375 void* pixels); | |
376 | |
377 virtual void releaseShaderCompiler(); | |
378 virtual void renderbufferStorage(WGC3Denum target, | |
379 WGC3Denum internalformat, | |
380 WGC3Dsizei width, | |
381 WGC3Dsizei height); | |
382 virtual void sampleCoverage(WGC3Dfloat value, WGC3Dboolean invert); | |
383 virtual void scissor(WGC3Dint x, WGC3Dint y, | |
384 WGC3Dsizei width, WGC3Dsizei height); | |
385 virtual void shaderSource(WebGLId shader, const WGC3Dchar* string); | |
386 virtual void stencilFunc(WGC3Denum func, WGC3Dint ref, WGC3Duint mask); | |
387 virtual void stencilFuncSeparate(WGC3Denum face, | |
388 WGC3Denum func, | |
389 WGC3Dint ref, | |
390 WGC3Duint mask); | |
391 virtual void stencilMask(WGC3Duint mask); | |
392 virtual void stencilMaskSeparate(WGC3Denum face, WGC3Duint mask); | |
393 virtual void stencilOp(WGC3Denum fail, | |
394 WGC3Denum zfail, | |
395 WGC3Denum zpass); | |
396 virtual void stencilOpSeparate(WGC3Denum face, | |
397 WGC3Denum fail, | |
398 WGC3Denum zfail, | |
399 WGC3Denum zpass); | |
400 | |
401 virtual void texImage2D(WGC3Denum target, | |
402 WGC3Dint level, | |
403 WGC3Denum internalformat, | |
404 WGC3Dsizei width, | |
405 WGC3Dsizei height, | |
406 WGC3Dint border, | |
407 WGC3Denum format, | |
408 WGC3Denum type, | |
409 const void* pixels); | |
410 | |
411 virtual void texParameterf(WGC3Denum target, | |
412 WGC3Denum pname, | |
413 WGC3Dfloat param); | |
414 virtual void texParameteri(WGC3Denum target, | |
415 WGC3Denum pname, | |
416 WGC3Dint param); | |
417 | |
418 virtual void texSubImage2D(WGC3Denum target, | |
419 WGC3Dint level, | |
420 WGC3Dint xoffset, | |
421 WGC3Dint yoffset, | |
422 WGC3Dsizei width, | |
423 WGC3Dsizei height, | |
424 WGC3Denum format, | |
425 WGC3Denum type, | |
426 const void* pixels); | |
427 | |
428 virtual void uniform1f(WGC3Dint location, WGC3Dfloat x); | |
429 virtual void uniform1fv(WGC3Dint location, | |
430 WGC3Dsizei count, const WGC3Dfloat* v); | |
431 virtual void uniform1i(WGC3Dint location, WGC3Dint x); | |
432 virtual void uniform1iv(WGC3Dint location, | |
433 WGC3Dsizei count, const WGC3Dint* v); | |
434 virtual void uniform2f(WGC3Dint location, WGC3Dfloat x, WGC3Dfloat y); | |
435 virtual void uniform2fv(WGC3Dint location, | |
436 WGC3Dsizei count, const WGC3Dfloat* v); | |
437 virtual void uniform2i(WGC3Dint location, WGC3Dint x, WGC3Dint y); | |
438 virtual void uniform2iv(WGC3Dint location, | |
439 WGC3Dsizei count, const WGC3Dint* v); | |
440 virtual void uniform3f(WGC3Dint location, | |
441 WGC3Dfloat x, WGC3Dfloat y, WGC3Dfloat z); | |
442 virtual void uniform3fv(WGC3Dint location, | |
443 WGC3Dsizei count, const WGC3Dfloat* v); | |
444 virtual void uniform3i(WGC3Dint location, | |
445 WGC3Dint x, WGC3Dint y, WGC3Dint z); | |
446 virtual void uniform3iv(WGC3Dint location, | |
447 WGC3Dsizei count, const WGC3Dint* v); | |
448 virtual void uniform4f(WGC3Dint location, | |
449 WGC3Dfloat x, WGC3Dfloat y, | |
450 WGC3Dfloat z, WGC3Dfloat w); | |
451 virtual void uniform4fv(WGC3Dint location, | |
452 WGC3Dsizei count, const WGC3Dfloat* v); | |
453 virtual void uniform4i(WGC3Dint location, | |
454 WGC3Dint x, WGC3Dint y, WGC3Dint z, WGC3Dint w); | |
455 virtual void uniform4iv(WGC3Dint location, | |
456 WGC3Dsizei count, const WGC3Dint* v); | |
457 virtual void uniformMatrix2fv(WGC3Dint location, | |
458 WGC3Dsizei count, | |
459 WGC3Dboolean transpose, | |
460 const WGC3Dfloat* value); | |
461 virtual void uniformMatrix3fv(WGC3Dint location, | |
462 WGC3Dsizei count, | |
463 WGC3Dboolean transpose, | |
464 const WGC3Dfloat* value); | |
465 virtual void uniformMatrix4fv(WGC3Dint location, | |
466 WGC3Dsizei count, | |
467 WGC3Dboolean transpose, | |
468 const WGC3Dfloat* value); | |
469 | |
470 virtual void useProgram(WebGLId program); | |
471 virtual void validateProgram(WebGLId program); | |
472 | |
473 virtual void vertexAttrib1f(WGC3Duint index, WGC3Dfloat x); | |
474 virtual void vertexAttrib1fv(WGC3Duint index, const WGC3Dfloat* values); | |
475 virtual void vertexAttrib2f(WGC3Duint index, WGC3Dfloat x, WGC3Dfloat y); | |
476 virtual void vertexAttrib2fv(WGC3Duint index, const WGC3Dfloat* values); | |
477 virtual void vertexAttrib3f(WGC3Duint index, | |
478 WGC3Dfloat x, WGC3Dfloat y, WGC3Dfloat z); | |
479 virtual void vertexAttrib3fv(WGC3Duint index, const WGC3Dfloat* values); | |
480 virtual void vertexAttrib4f(WGC3Duint index, | |
481 WGC3Dfloat x, WGC3Dfloat y, | |
482 WGC3Dfloat z, WGC3Dfloat w); | |
483 virtual void vertexAttrib4fv(WGC3Duint index, const WGC3Dfloat* values); | |
484 virtual void vertexAttribPointer(WGC3Duint index, | |
485 WGC3Dint size, | |
486 WGC3Denum type, | |
487 WGC3Dboolean normalized, | |
488 WGC3Dsizei stride, | |
489 WGC3Dintptr offset); | |
490 | |
491 virtual void viewport(WGC3Dint x, WGC3Dint y, | |
492 WGC3Dsizei width, WGC3Dsizei height); | |
493 | |
494 // Support for buffer creation and deletion | |
495 virtual void genBuffers(WGC3Dsizei count, WebGLId* ids); | |
496 virtual void genFramebuffers(WGC3Dsizei count, WebGLId* ids); | |
497 virtual void genRenderbuffers(WGC3Dsizei count, WebGLId* ids); | |
498 virtual void genTextures(WGC3Dsizei count, WebGLId* ids); | |
499 | |
500 virtual void deleteBuffers(WGC3Dsizei count, WebGLId* ids); | |
501 virtual void deleteFramebuffers(WGC3Dsizei count, WebGLId* ids); | |
502 virtual void deleteRenderbuffers(WGC3Dsizei count, WebGLId* ids); | |
503 virtual void deleteTextures(WGC3Dsizei count, WebGLId* ids); | |
504 | |
505 virtual WebGLId createBuffer(); | |
506 virtual WebGLId createFramebuffer(); | |
507 virtual WebGLId createRenderbuffer(); | |
508 virtual WebGLId createTexture(); | |
509 | |
510 virtual void deleteBuffer(WebGLId); | |
511 virtual void deleteFramebuffer(WebGLId); | |
512 virtual void deleteRenderbuffer(WebGLId); | |
513 virtual void deleteTexture(WebGLId); | |
514 | |
515 virtual WebGLId createProgram(); | |
516 virtual WebGLId createShader(WGC3Denum); | |
517 | |
518 virtual void deleteProgram(WebGLId); | |
519 virtual void deleteShader(WebGLId); | |
520 | |
521 virtual void synthesizeGLError(WGC3Denum); | |
522 | |
523 virtual void* mapBufferSubDataCHROMIUM( | |
524 WGC3Denum target, WGC3Dintptr offset, | |
525 WGC3Dsizeiptr size, WGC3Denum access); | |
526 virtual void unmapBufferSubDataCHROMIUM(const void*); | |
527 virtual void* mapTexSubImage2DCHROMIUM( | |
528 WGC3Denum target, | |
529 WGC3Dint level, | |
530 WGC3Dint xoffset, | |
531 WGC3Dint yoffset, | |
532 WGC3Dsizei width, | |
533 WGC3Dsizei height, | |
534 WGC3Denum format, | |
535 WGC3Denum type, | |
536 WGC3Denum access); | |
537 virtual void unmapTexSubImage2DCHROMIUM(const void*); | |
538 | |
539 virtual void setVisibilityCHROMIUM(bool visible); | |
540 | |
541 virtual void discardFramebufferEXT(WGC3Denum target, | |
542 WGC3Dsizei numAttachments, | |
543 const WGC3Denum* attachments); | |
544 virtual void copyTextureToParentTextureCHROMIUM( | |
545 WebGLId texture, WebGLId parentTexture); | |
546 | |
547 virtual blink::WebString getRequestableExtensionsCHROMIUM(); | |
548 virtual void requestExtensionCHROMIUM(const char*); | |
549 | |
550 virtual void blitFramebufferCHROMIUM( | |
551 WGC3Dint srcX0, WGC3Dint srcY0, WGC3Dint srcX1, WGC3Dint srcY1, | |
552 WGC3Dint dstX0, WGC3Dint dstY0, WGC3Dint dstX1, WGC3Dint dstY1, | |
553 WGC3Dbitfield mask, WGC3Denum filter); | |
554 virtual void renderbufferStorageMultisampleCHROMIUM( | |
555 WGC3Denum target, WGC3Dsizei samples, WGC3Denum internalformat, | |
556 WGC3Dsizei width, WGC3Dsizei height); | |
557 | |
558 virtual blink::WebString getTranslatedShaderSourceANGLE(WebGLId shader); | |
559 | |
560 virtual void setContextLostCallback( | |
561 WebGraphicsContext3D::WebGraphicsContextLostCallback* callback); | |
562 | |
563 virtual WGC3Denum getGraphicsResetStatusARB(); | 155 virtual WGC3Denum getGraphicsResetStatusARB(); |
564 | 156 |
565 virtual void setErrorMessageCallback( | |
566 WebGraphicsContext3D::WebGraphicsErrorMessageCallback* callback); | |
567 | |
568 virtual void texImageIOSurface2DCHROMIUM( | |
569 WGC3Denum target, WGC3Dint width, WGC3Dint height, | |
570 WGC3Duint ioSurfaceId, WGC3Duint plane); | |
571 | |
572 virtual void texStorage2DEXT( | |
573 WGC3Denum target, WGC3Dint levels, WGC3Duint internalformat, | |
574 WGC3Dint width, WGC3Dint height); | |
575 | |
576 virtual WebGLId createQueryEXT(); | |
577 virtual void deleteQueryEXT(WebGLId query); | |
578 virtual WGC3Dboolean isQueryEXT(WGC3Duint query); | |
579 virtual void beginQueryEXT(WGC3Denum target, WebGLId query); | |
580 virtual void endQueryEXT(WGC3Denum target); | |
581 virtual void getQueryivEXT( | |
582 WGC3Denum target, WGC3Denum pname, WGC3Dint* params); | |
583 virtual void getQueryObjectuivEXT( | |
584 WebGLId query, WGC3Denum pname, WGC3Duint* params); | |
585 | |
586 virtual void copyTextureCHROMIUM(WGC3Denum target, WebGLId source_id, | |
587 WebGLId dest_id, WGC3Dint level, | |
588 WGC3Denum internal_format, | |
589 WGC3Denum dest_type); | |
590 | |
591 virtual void bindUniformLocationCHROMIUM(WebGLId program, WGC3Dint location, | |
592 const WGC3Dchar* uniform); | |
593 | |
594 virtual void shallowFlushCHROMIUM(); | |
595 virtual void shallowFinishCHROMIUM(); | |
596 | |
597 virtual void genMailboxCHROMIUM(WGC3Dbyte* mailbox); | |
598 virtual void produceTextureCHROMIUM(WGC3Denum target, | |
599 const WGC3Dbyte* mailbox); | |
600 virtual void consumeTextureCHROMIUM(WGC3Denum target, | |
601 const WGC3Dbyte* mailbox); | |
602 | |
603 virtual void insertEventMarkerEXT(const WGC3Dchar* marker); | |
604 virtual void pushGroupMarkerEXT(const WGC3Dchar* marker); | |
605 virtual void popGroupMarkerEXT(); | |
606 | |
607 // GL_OES_vertex_array_object | |
608 virtual WebGLId createVertexArrayOES(); | |
609 virtual void deleteVertexArrayOES(WebGLId array); | |
610 virtual WGC3Dboolean isVertexArrayOES(WebGLId array); | |
611 virtual void bindVertexArrayOES(WebGLId array); | |
612 | |
613 virtual void bindTexImage2DCHROMIUM(WGC3Denum target, WGC3Dint image_id); | |
614 virtual void releaseTexImage2DCHROMIUM(WGC3Denum target, WGC3Dint image_id); | |
615 | |
616 virtual void* mapBufferCHROMIUM(WGC3Denum target, WGC3Denum access); | |
617 virtual WGC3Dboolean unmapBufferCHROMIUM(WGC3Denum target); | |
618 | |
619 // Async pixel transfer functions. | |
620 virtual void asyncTexImage2DCHROMIUM( | |
621 WGC3Denum target, | |
622 WGC3Dint level, | |
623 WGC3Denum internalformat, | |
624 WGC3Dsizei width, | |
625 WGC3Dsizei height, | |
626 WGC3Dint border, | |
627 WGC3Denum format, | |
628 WGC3Denum type, | |
629 const void* pixels); | |
630 virtual void asyncTexSubImage2DCHROMIUM( | |
631 WGC3Denum target, | |
632 WGC3Dint level, | |
633 WGC3Dint xoffset, | |
634 WGC3Dint yoffset, | |
635 WGC3Dsizei width, | |
636 WGC3Dsizei height, | |
637 WGC3Denum format, | |
638 WGC3Denum type, | |
639 const void* pixels); | |
640 virtual void waitAsyncTexImage2DCHROMIUM(WGC3Denum target); | |
641 | |
642 // GL_EXT_draw_buffers | |
643 virtual void drawBuffersEXT( | |
644 WGC3Dsizei n, | |
645 const WGC3Denum* bufs); | |
646 | |
647 // GL_ANGLE_instanced_arrays | |
648 virtual void drawArraysInstancedANGLE(WGC3Denum mode, WGC3Dint first, | |
649 WGC3Dsizei count, WGC3Dsizei primcount); | |
650 virtual void drawElementsInstancedANGLE(WGC3Denum mode, WGC3Dsizei count, | |
651 WGC3Denum type, WGC3Dintptr offset, WGC3Dsizei primcount); | |
652 virtual void vertexAttribDivisorANGLE(WGC3Duint index, WGC3Duint divisor); | |
653 | |
654 // GL_CHROMIUM_map_image | |
655 virtual WGC3Duint createImageCHROMIUM(WGC3Dsizei width, | |
656 WGC3Dsizei height, | |
657 WGC3Denum internalformat, | |
658 WGC3Denum usage); | |
659 virtual void destroyImageCHROMIUM(WGC3Duint image_id); | |
660 virtual void getImageParameterivCHROMIUM( | |
661 WGC3Duint image_id, WGC3Denum pname, WGC3Dint* params); | |
662 virtual void* mapImageCHROMIUM(WGC3Duint image_id); | |
663 virtual void unmapImageCHROMIUM(WGC3Duint image_id); | |
664 | |
665 // GL_EXT_multisampled_render_to_texture | |
666 virtual void framebufferTexture2DMultisampleEXT(WGC3Denum target, | |
667 WGC3Denum attachment, | |
668 WGC3Denum textarget, | |
669 WebGLId texture, | |
670 WGC3Dint level, | |
671 WGC3Dsizei samples); | |
672 virtual void renderbufferStorageMultisampleEXT( | |
673 WGC3Denum target, WGC3Dsizei samples, WGC3Denum internalformat, | |
674 WGC3Dsizei width, WGC3Dsizei height); | |
675 | |
676 virtual GrGLInterface* createGrGLInterface(); | |
677 | |
678 private: | 157 private: |
679 // These are the same error codes as used by EGL. | 158 // These are the same error codes as used by EGL. |
680 enum Error { | 159 enum Error { |
681 SUCCESS = 0x3000, | 160 SUCCESS = 0x3000, |
682 BAD_ATTRIBUTE = 0x3004, | 161 BAD_ATTRIBUTE = 0x3004, |
683 CONTEXT_LOST = 0x300E | 162 CONTEXT_LOST = 0x300E |
684 }; | 163 }; |
685 // WebGraphicsContext3DCommandBufferImpl configuration attributes. Those in | 164 // WebGraphicsContext3DCommandBufferImpl configuration attributes. Those in |
686 // the 16-bit range are the same as used by EGL. Those outside the 16-bit | 165 // the 16-bit range are the same as used by EGL. Those outside the 16-bit |
687 // range are unique to Chromium. Attributes are matched using a closest fit | 166 // range are unique to Chromium. Attributes are matched using a closest fit |
(...skipping 11 matching lines...) Expand all Loading... |
699 SAMPLES = 0x3031, | 178 SAMPLES = 0x3031, |
700 SAMPLE_BUFFERS = 0x3032, | 179 SAMPLE_BUFFERS = 0x3032, |
701 HEIGHT = 0x3056, | 180 HEIGHT = 0x3056, |
702 WIDTH = 0x3057, | 181 WIDTH = 0x3057, |
703 NONE = 0x3038, // Attrib list = terminator | 182 NONE = 0x3038, // Attrib list = terminator |
704 SHARE_RESOURCES = 0x10000, | 183 SHARE_RESOURCES = 0x10000, |
705 BIND_GENERATES_RESOURCES = 0x10001, | 184 BIND_GENERATES_RESOURCES = 0x10001, |
706 FAIL_IF_MAJOR_PERF_CAVEAT = 0x10002, | 185 FAIL_IF_MAJOR_PERF_CAVEAT = 0x10002, |
707 LOSE_CONTEXT_WHEN_OUT_OF_MEMORY = 0x10003, | 186 LOSE_CONTEXT_WHEN_OUT_OF_MEMORY = 0x10003, |
708 }; | 187 }; |
709 friend class WebGraphicsContext3DErrorMessageCallback; | |
710 | 188 |
711 // Initialize the underlying GL context. May be called multiple times; second | 189 // Initialize the underlying GL context. May be called multiple times; second |
712 // and subsequent calls are ignored. Must be called from the thread that is | 190 // and subsequent calls are ignored. Must be called from the thread that is |
713 // going to use this object to issue GL commands (which might not be the main | 191 // going to use this object to issue GL commands (which might not be the main |
714 // thread). | 192 // thread). |
715 bool MaybeInitializeGL(); | 193 bool MaybeInitializeGL(); |
716 | 194 |
717 bool InitializeCommandBuffer(bool onscreen, | 195 bool InitializeCommandBuffer(bool onscreen, |
718 WebGraphicsContext3DCommandBufferImpl* share_context); | 196 WebGraphicsContext3DCommandBufferImpl* share_context); |
719 | 197 |
720 void Destroy(); | 198 void Destroy(); |
721 | 199 |
722 // Create a CommandBufferProxy that renders directly to a view. The view and | 200 // Create a CommandBufferProxy that renders directly to a view. The view and |
723 // the associated window must not be destroyed until the returned | 201 // the associated window must not be destroyed until the returned |
724 // CommandBufferProxy has been destroyed, otherwise the GPU process might | 202 // CommandBufferProxy has been destroyed, otherwise the GPU process might |
725 // attempt to render to an invalid window handle. | 203 // attempt to render to an invalid window handle. |
726 // | 204 // |
727 // NOTE: on Mac OS X, this entry point is only used to set up the | 205 // NOTE: on Mac OS X, this entry point is only used to set up the |
728 // accelerated compositor's output. On this platform, we actually pass | 206 // accelerated compositor's output. On this platform, we actually pass |
729 // a gfx::PluginWindowHandle in place of the gfx::NativeViewId, | 207 // a gfx::PluginWindowHandle in place of the gfx::NativeViewId, |
730 // because the facility to allocate a fake PluginWindowHandle is | 208 // because the facility to allocate a fake PluginWindowHandle is |
731 // already in place. We could add more entry points and messages to | 209 // already in place. We could add more entry points and messages to |
732 // allocate both fake PluginWindowHandles and NativeViewIds and map | 210 // allocate both fake PluginWindowHandles and NativeViewIds and map |
733 // from fake NativeViewIds to PluginWindowHandles, but this seems like | 211 // from fake NativeViewIds to PluginWindowHandles, but this seems like |
734 // unnecessary complexity at the moment. | 212 // unnecessary complexity at the moment. |
735 bool CreateContext(bool onscreen); | 213 bool CreateContext(bool onscreen); |
736 | 214 |
737 virtual void OnGpuChannelLost(); | 215 virtual void OnGpuChannelLost(); |
738 virtual void OnErrorMessage(const std::string& message, int id); | |
739 | |
740 bool initialize_failed_; | |
741 | 216 |
742 bool visible_; | 217 bool visible_; |
743 | 218 |
744 // State needed by MaybeInitializeGL. | 219 // State needed by MaybeInitializeGL. |
745 scoped_refptr<GpuChannelHost> host_; | 220 scoped_refptr<GpuChannelHost> host_; |
746 int32 surface_id_; | 221 int32 surface_id_; |
747 GURL active_url_; | 222 GURL active_url_; |
748 | 223 |
749 WebGraphicsContext3D::WebGraphicsContextLostCallback* context_lost_callback_; | |
750 WGC3Denum context_lost_reason_; | |
751 | |
752 WebGraphicsContext3D::WebGraphicsErrorMessageCallback* | |
753 error_message_callback_; | |
754 scoped_ptr<WebGraphicsContext3DErrorMessageCallback> | |
755 client_error_message_callback_; | |
756 | |
757 blink::WebGraphicsContext3D::Attributes attributes_; | |
758 gfx::GpuPreference gpu_preference_; | 224 gfx::GpuPreference gpu_preference_; |
759 | 225 |
760 // Errors raised by synthesizeGLError(). | |
761 std::vector<WGC3Denum> synthetic_errors_; | |
762 | |
763 base::WeakPtrFactory<WebGraphicsContext3DCommandBufferImpl> weak_ptr_factory_; | 226 base::WeakPtrFactory<WebGraphicsContext3DCommandBufferImpl> weak_ptr_factory_; |
764 | 227 |
765 bool initialized_; | |
766 scoped_ptr<CommandBufferProxyImpl> command_buffer_; | 228 scoped_ptr<CommandBufferProxyImpl> command_buffer_; |
767 scoped_ptr<gpu::gles2::GLES2CmdHelper> gles2_helper_; | 229 scoped_ptr<gpu::gles2::GLES2CmdHelper> gles2_helper_; |
768 scoped_ptr<gpu::TransferBuffer> transfer_buffer_; | 230 scoped_ptr<gpu::TransferBuffer> transfer_buffer_; |
769 gpu::gles2::GLES2Interface* gl_; | |
770 scoped_ptr<gpu::gles2::GLES2Implementation> real_gl_; | 231 scoped_ptr<gpu::gles2::GLES2Implementation> real_gl_; |
771 scoped_ptr<gpu::gles2::GLES2Interface> trace_gl_; | 232 scoped_ptr<gpu::gles2::GLES2Interface> trace_gl_; |
772 Error last_error_; | 233 Error last_error_; |
773 bool lose_context_when_out_of_memory_; | |
774 SharedMemoryLimits mem_limits_; | 234 SharedMemoryLimits mem_limits_; |
775 | |
776 uint32_t flush_id_; | |
777 scoped_refptr<ShareGroup> share_group_; | 235 scoped_refptr<ShareGroup> share_group_; |
778 }; | 236 }; |
779 | 237 |
780 } // namespace content | 238 } // namespace content |
781 | 239 |
782 #endif // CONTENT_COMMON_GPU_CLIENT_WEBGRAPHICSCONTEXT3D_COMMAND_BUFFER_IMPL_H_ | 240 #endif // CONTENT_COMMON_GPU_CLIENT_WEBGRAPHICSCONTEXT3D_COMMAND_BUFFER_IMPL_H_ |
OLD | NEW |