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 #include "webkit/common/gpu/webgraphicscontext3d_in_process_command_buffer_impl.
h" | 5 #include "webkit/common/gpu/webgraphicscontext3d_in_process_command_buffer_impl.
h" |
6 | 6 |
7 #include <GLES2/gl2.h> | 7 #include <GLES2/gl2.h> |
8 #ifndef GL_GLEXT_PROTOTYPES | 8 #ifndef GL_GLEXT_PROTOTYPES |
9 #define GL_GLEXT_PROTOTYPES 1 | 9 #define GL_GLEXT_PROTOTYPES 1 |
10 #endif | 10 #endif |
(...skipping 23 matching lines...) Expand all Loading... |
34 | 34 |
35 namespace { | 35 namespace { |
36 | 36 |
37 const int32 kCommandBufferSize = 1024 * 1024; | 37 const int32 kCommandBufferSize = 1024 * 1024; |
38 // TODO(kbr): make the transfer buffer size configurable via context | 38 // TODO(kbr): make the transfer buffer size configurable via context |
39 // creation attributes. | 39 // creation attributes. |
40 const size_t kStartTransferBufferSize = 4 * 1024 * 1024; | 40 const size_t kStartTransferBufferSize = 4 * 1024 * 1024; |
41 const size_t kMinTransferBufferSize = 1 * 256 * 1024; | 41 const size_t kMinTransferBufferSize = 1 * 256 * 1024; |
42 const size_t kMaxTransferBufferSize = 16 * 1024 * 1024; | 42 const size_t kMaxTransferBufferSize = 16 * 1024 * 1024; |
43 | 43 |
44 uint32_t GenFlushID() { | |
45 static base::subtle::Atomic32 flush_id = 0; | |
46 | |
47 base::subtle::Atomic32 my_id = base::subtle::Barrier_AtomicIncrement( | |
48 &flush_id, 1); | |
49 return static_cast<uint32_t>(my_id); | |
50 } | |
51 | |
52 // Singleton used to initialize and terminate the gles2 library. | 44 // Singleton used to initialize and terminate the gles2 library. |
53 class GLES2Initializer { | 45 class GLES2Initializer { |
54 public: | 46 public: |
55 GLES2Initializer() { | 47 GLES2Initializer() { |
56 ::gles2::Initialize(); | 48 ::gles2::Initialize(); |
57 } | 49 } |
58 | 50 |
59 ~GLES2Initializer() { | 51 ~GLES2Initializer() { |
60 ::gles2::Terminate(); | 52 ::gles2::Terminate(); |
61 } | 53 } |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 gfx::kNullAcceleratedWidget /* window. Not used. */)); | 105 gfx::kNullAcceleratedWidget /* window. Not used. */)); |
114 } | 106 } |
115 | 107 |
116 WebGraphicsContext3DInProcessCommandBufferImpl:: | 108 WebGraphicsContext3DInProcessCommandBufferImpl:: |
117 WebGraphicsContext3DInProcessCommandBufferImpl( | 109 WebGraphicsContext3DInProcessCommandBufferImpl( |
118 scoped_ptr< ::gpu::GLInProcessContext> context, | 110 scoped_ptr< ::gpu::GLInProcessContext> context, |
119 const blink::WebGraphicsContext3D::Attributes& attributes, | 111 const blink::WebGraphicsContext3D::Attributes& attributes, |
120 bool lose_context_when_out_of_memory, | 112 bool lose_context_when_out_of_memory, |
121 bool is_offscreen, | 113 bool is_offscreen, |
122 gfx::AcceleratedWidget window) | 114 gfx::AcceleratedWidget window) |
123 : is_offscreen_(is_offscreen), | 115 : WebGraphicsContext3DImpl(attributes, lose_context_when_out_of_memory), |
| 116 is_offscreen_(is_offscreen), |
124 window_(window), | 117 window_(window), |
125 initialized_(false), | 118 context_(context.Pass()) { |
126 initialize_failed_(false), | 119 } |
127 context_(context.Pass()), | |
128 gl_(NULL), | |
129 context_lost_callback_(NULL), | |
130 context_lost_reason_(GL_NO_ERROR), | |
131 attributes_(attributes), | |
132 lose_context_when_out_of_memory_(lose_context_when_out_of_memory), | |
133 flush_id_(0) {} | |
134 | 120 |
135 WebGraphicsContext3DInProcessCommandBufferImpl:: | 121 WebGraphicsContext3DInProcessCommandBufferImpl:: |
136 ~WebGraphicsContext3DInProcessCommandBufferImpl() { | 122 ~WebGraphicsContext3DInProcessCommandBufferImpl() { |
137 } | 123 } |
138 | 124 |
139 // static | 125 // static |
140 void WebGraphicsContext3DInProcessCommandBufferImpl::ConvertAttributes( | 126 void WebGraphicsContext3DInProcessCommandBufferImpl::ConvertAttributes( |
141 const blink::WebGraphicsContext3D::Attributes& attributes, | 127 const blink::WebGraphicsContext3D::Attributes& attributes, |
142 ::gpu::GLInProcessContextAttribs* output_attribs) { | 128 ::gpu::GLInProcessContextAttribs* output_attribs) { |
143 output_attribs->alpha_size = attributes.alpha ? 8 : 0; | 129 output_attribs->alpha_size = attributes.alpha ? 8 : 0; |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
184 if (context_) { | 170 if (context_) { |
185 base::Closure context_lost_callback = base::Bind( | 171 base::Closure context_lost_callback = base::Bind( |
186 &WebGraphicsContext3DInProcessCommandBufferImpl::OnContextLost, | 172 &WebGraphicsContext3DInProcessCommandBufferImpl::OnContextLost, |
187 base::Unretained(this)); | 173 base::Unretained(this)); |
188 context_->SetContextLostCallback(context_lost_callback); | 174 context_->SetContextLostCallback(context_lost_callback); |
189 } else { | 175 } else { |
190 initialize_failed_ = true; | 176 initialize_failed_ = true; |
191 return false; | 177 return false; |
192 } | 178 } |
193 | 179 |
194 gl_ = context_->GetImplementation(); | 180 real_gl_ = context_->GetImplementation(); |
| 181 setGLInterface(real_gl_); |
195 | 182 |
196 if (gl_ && attributes_.noExtensions) | 183 if (real_gl_ && attributes_.noExtensions) |
197 gl_->EnableFeatureCHROMIUM("webgl_enable_glsl_webgl_validation"); | 184 real_gl_->EnableFeatureCHROMIUM("webgl_enable_glsl_webgl_validation"); |
198 | 185 |
199 // Set attributes_ from created offscreen context. | 186 // Set attributes_ from created offscreen context. |
200 { | 187 { |
201 GLint alpha_bits = 0; | 188 GLint alpha_bits = 0; |
202 getIntegerv(GL_ALPHA_BITS, &alpha_bits); | 189 getIntegerv(GL_ALPHA_BITS, &alpha_bits); |
203 attributes_.alpha = alpha_bits > 0; | 190 attributes_.alpha = alpha_bits > 0; |
204 GLint depth_bits = 0; | 191 GLint depth_bits = 0; |
205 getIntegerv(GL_DEPTH_BITS, &depth_bits); | 192 getIntegerv(GL_DEPTH_BITS, &depth_bits); |
206 attributes_.depth = depth_bits > 0; | 193 attributes_.depth = depth_bits > 0; |
207 GLint stencil_bits = 0; | 194 GLint stencil_bits = 0; |
208 getIntegerv(GL_STENCIL_BITS, &stencil_bits); | 195 getIntegerv(GL_STENCIL_BITS, &stencil_bits); |
209 attributes_.stencil = stencil_bits > 0; | 196 attributes_.stencil = stencil_bits > 0; |
210 GLint sample_buffers = 0; | 197 GLint sample_buffers = 0; |
211 getIntegerv(GL_SAMPLE_BUFFERS, &sample_buffers); | 198 getIntegerv(GL_SAMPLE_BUFFERS, &sample_buffers); |
212 attributes_.antialias = sample_buffers > 0; | 199 attributes_.antialias = sample_buffers > 0; |
213 } | 200 } |
214 | 201 |
215 initialized_ = true; | 202 initialized_ = true; |
216 return true; | 203 return true; |
217 } | 204 } |
218 | 205 |
219 bool WebGraphicsContext3DInProcessCommandBufferImpl::makeContextCurrent() { | 206 bool WebGraphicsContext3DInProcessCommandBufferImpl::makeContextCurrent() { |
220 if (!MaybeInitializeGL()) | 207 if (!MaybeInitializeGL()) |
221 return false; | 208 return false; |
222 ::gles2::SetGLContext(gl_); | 209 ::gles2::SetGLContext(GetGLInterface()); |
223 return context_ && !isContextLost(); | 210 return context_ && !isContextLost(); |
224 } | 211 } |
225 | 212 |
226 uint32_t WebGraphicsContext3DInProcessCommandBufferImpl::lastFlushID() { | |
227 return flush_id_; | |
228 } | |
229 | |
230 void WebGraphicsContext3DInProcessCommandBufferImpl::ClearContext() { | |
231 // NOTE: Comment in the line below to check for code that is not calling | |
232 // eglMakeCurrent where appropriate. The issue is code using | |
233 // WebGraphicsContext3D does not need to call makeContextCurrent. Code using | |
234 // direct OpenGL bindings needs to call the appropriate form of | |
235 // eglMakeCurrent. If it doesn't it will be issuing commands on the wrong | |
236 // context. Uncommenting the line below clears the current context so that | |
237 // any code not calling eglMakeCurrent in the appropriate place should crash. | |
238 // This is not a perfect test but generally code that used the direct OpenGL | |
239 // bindings should not be mixed with code that uses WebGraphicsContext3D. | |
240 // | |
241 // GLInProcessContext::MakeCurrent(NULL); | |
242 } | |
243 | |
244 // Helper macros to reduce the amount of code. | |
245 | |
246 #define DELEGATE_TO_GL(name, glname) \ | |
247 void WebGraphicsContext3DInProcessCommandBufferImpl::name() { \ | |
248 ClearContext(); \ | |
249 gl_->glname(); \ | |
250 } | |
251 | |
252 #define DELEGATE_TO_GL_R(name, glname, rt) \ | |
253 rt WebGraphicsContext3DInProcessCommandBufferImpl::name() { \ | |
254 ClearContext(); \ | |
255 return gl_->glname(); \ | |
256 } | |
257 | |
258 #define DELEGATE_TO_GL_1(name, glname, t1) \ | |
259 void WebGraphicsContext3DInProcessCommandBufferImpl::name(t1 a1) { \ | |
260 ClearContext(); \ | |
261 gl_->glname(a1); \ | |
262 } | |
263 | |
264 #define DELEGATE_TO_GL_1R(name, glname, t1, rt) \ | |
265 rt WebGraphicsContext3DInProcessCommandBufferImpl::name(t1 a1) { \ | |
266 ClearContext(); \ | |
267 return gl_->glname(a1); \ | |
268 } | |
269 | |
270 #define DELEGATE_TO_GL_1RB(name, glname, t1, rt) \ | |
271 rt WebGraphicsContext3DInProcessCommandBufferImpl::name(t1 a1) { \ | |
272 ClearContext(); \ | |
273 return gl_->glname(a1) ? true : false; \ | |
274 } | |
275 | |
276 #define DELEGATE_TO_GL_2(name, glname, t1, t2) \ | |
277 void WebGraphicsContext3DInProcessCommandBufferImpl::name( \ | |
278 t1 a1, t2 a2) { \ | |
279 ClearContext(); \ | |
280 gl_->glname(a1, a2); \ | |
281 } | |
282 | |
283 #define DELEGATE_TO_GL_2R(name, glname, t1, t2, rt) \ | |
284 rt WebGraphicsContext3DInProcessCommandBufferImpl::name(t1 a1, t2 a2) { \ | |
285 ClearContext(); \ | |
286 return gl_->glname(a1, a2); \ | |
287 } | |
288 | |
289 #define DELEGATE_TO_GL_3(name, glname, t1, t2, t3) \ | |
290 void WebGraphicsContext3DInProcessCommandBufferImpl::name( \ | |
291 t1 a1, t2 a2, t3 a3) { \ | |
292 ClearContext(); \ | |
293 gl_->glname(a1, a2, a3); \ | |
294 } | |
295 | |
296 #define DELEGATE_TO_GL_4(name, glname, t1, t2, t3, t4) \ | |
297 void WebGraphicsContext3DInProcessCommandBufferImpl::name( \ | |
298 t1 a1, t2 a2, t3 a3, t4 a4) { \ | |
299 ClearContext(); \ | |
300 gl_->glname(a1, a2, a3, a4); \ | |
301 } | |
302 | |
303 #define DELEGATE_TO_GL_4R(name, glname, t1, t2, t3, t4, rt) \ | |
304 rt WebGraphicsContext3DInProcessCommandBufferImpl::name( \ | |
305 t1 a1, t2 a2, t3 a3, t4 a4) { \ | |
306 ClearContext(); \ | |
307 return gl_->glname(a1, a2, a3, a4); \ | |
308 } | |
309 | |
310 #define DELEGATE_TO_GL_5(name, glname, t1, t2, t3, t4, t5) \ | |
311 void WebGraphicsContext3DInProcessCommandBufferImpl::name( \ | |
312 t1 a1, t2 a2, t3 a3, t4 a4, t5 a5) { \ | |
313 ClearContext(); \ | |
314 gl_->glname(a1, a2, a3, a4, a5); \ | |
315 } | |
316 | |
317 #define DELEGATE_TO_GL_6(name, glname, t1, t2, t3, t4, t5, t6) \ | |
318 void WebGraphicsContext3DInProcessCommandBufferImpl::name( \ | |
319 t1 a1, t2 a2, t3 a3, t4 a4, t5 a5, t6 a6) { \ | |
320 ClearContext(); \ | |
321 gl_->glname(a1, a2, a3, a4, a5, a6); \ | |
322 } | |
323 | |
324 #define DELEGATE_TO_GL_7(name, glname, t1, t2, t3, t4, t5, t6, t7) \ | |
325 void WebGraphicsContext3DInProcessCommandBufferImpl::name( \ | |
326 t1 a1, t2 a2, t3 a3, t4 a4, t5 a5, t6 a6, t7 a7) { \ | |
327 ClearContext(); \ | |
328 gl_->glname(a1, a2, a3, a4, a5, a6, a7); \ | |
329 } | |
330 | |
331 #define DELEGATE_TO_GL_8(name, glname, t1, t2, t3, t4, t5, t6, t7, t8) \ | |
332 void WebGraphicsContext3DInProcessCommandBufferImpl::name( \ | |
333 t1 a1, t2 a2, t3 a3, t4 a4, t5 a5, t6 a6, t7 a7, t8 a8) { \ | |
334 ClearContext(); \ | |
335 gl_->glname(a1, a2, a3, a4, a5, a6, a7, a8); \ | |
336 } | |
337 | |
338 #define DELEGATE_TO_GL_9(name, glname, t1, t2, t3, t4, t5, t6, t7, t8, t9) \ | |
339 void WebGraphicsContext3DInProcessCommandBufferImpl::name( \ | |
340 t1 a1, t2 a2, t3 a3, t4 a4, t5 a5, t6 a6, t7 a7, t8 a8, t9 a9) { \ | |
341 ClearContext(); \ | |
342 gl_->glname(a1, a2, a3, a4, a5, a6, a7, a8, a9); \ | |
343 } | |
344 | |
345 void WebGraphicsContext3DInProcessCommandBufferImpl::prepareTexture() { | |
346 NOTREACHED(); | |
347 } | |
348 | |
349 void WebGraphicsContext3DInProcessCommandBufferImpl::postSubBufferCHROMIUM( | |
350 int x, int y, int width, int height) { | |
351 NOTREACHED(); | |
352 } | |
353 | |
354 DELEGATE_TO_GL_3(reshapeWithScaleFactor, ResizeCHROMIUM, int, int, float) | |
355 | |
356 void WebGraphicsContext3DInProcessCommandBufferImpl::synthesizeGLError( | |
357 WGC3Denum error) { | |
358 if (std::find(synthetic_errors_.begin(), synthetic_errors_.end(), error) == | |
359 synthetic_errors_.end()) { | |
360 synthetic_errors_.push_back(error); | |
361 } | |
362 } | |
363 | |
364 void* WebGraphicsContext3DInProcessCommandBufferImpl::mapBufferSubDataCHROMIUM( | |
365 WGC3Denum target, | |
366 WGC3Dintptr offset, | |
367 WGC3Dsizeiptr size, | |
368 WGC3Denum access) { | |
369 ClearContext(); | |
370 return gl_->MapBufferSubDataCHROMIUM(target, offset, size, access); | |
371 } | |
372 | |
373 void WebGraphicsContext3DInProcessCommandBufferImpl::unmapBufferSubDataCHROMIUM( | |
374 const void* mem) { | |
375 ClearContext(); | |
376 return gl_->UnmapBufferSubDataCHROMIUM(mem); | |
377 } | |
378 | |
379 void* WebGraphicsContext3DInProcessCommandBufferImpl::mapTexSubImage2DCHROMIUM( | |
380 WGC3Denum target, | |
381 WGC3Dint level, | |
382 WGC3Dint xoffset, | |
383 WGC3Dint yoffset, | |
384 WGC3Dsizei width, | |
385 WGC3Dsizei height, | |
386 WGC3Denum format, | |
387 WGC3Denum type, | |
388 WGC3Denum access) { | |
389 ClearContext(); | |
390 return gl_->MapTexSubImage2DCHROMIUM( | |
391 target, level, xoffset, yoffset, width, height, format, type, access); | |
392 } | |
393 | |
394 void WebGraphicsContext3DInProcessCommandBufferImpl::unmapTexSubImage2DCHROMIUM( | |
395 const void* mem) { | |
396 ClearContext(); | |
397 gl_->UnmapTexSubImage2DCHROMIUM(mem); | |
398 } | |
399 | |
400 void WebGraphicsContext3DInProcessCommandBufferImpl::setVisibilityCHROMIUM( | |
401 bool visible) { | |
402 } | |
403 | |
404 void WebGraphicsContext3DInProcessCommandBufferImpl::discardFramebufferEXT( | |
405 WGC3Denum target, WGC3Dsizei numAttachments, const WGC3Denum* attachments) { | |
406 gl_->DiscardFramebufferEXT(target, numAttachments, attachments); | |
407 } | |
408 | |
409 void WebGraphicsContext3DInProcessCommandBufferImpl:: | |
410 copyTextureToParentTextureCHROMIUM(WebGLId texture, WebGLId parentTexture) { | |
411 NOTIMPLEMENTED(); | |
412 } | |
413 | |
414 blink::WebString WebGraphicsContext3DInProcessCommandBufferImpl:: | |
415 getRequestableExtensionsCHROMIUM() { | |
416 // TODO(gmam): See if we can comment this in. | |
417 // ClearContext(); | |
418 return blink::WebString::fromUTF8( | |
419 gl_->GetRequestableExtensionsCHROMIUM()); | |
420 } | |
421 | |
422 void WebGraphicsContext3DInProcessCommandBufferImpl::requestExtensionCHROMIUM( | |
423 const char* extension) { | |
424 // TODO(gmam): See if we can comment this in. | |
425 // ClearContext(); | |
426 gl_->RequestExtensionCHROMIUM(extension); | |
427 } | |
428 | |
429 void WebGraphicsContext3DInProcessCommandBufferImpl::blitFramebufferCHROMIUM( | |
430 WGC3Dint srcX0, WGC3Dint srcY0, WGC3Dint srcX1, WGC3Dint srcY1, | |
431 WGC3Dint dstX0, WGC3Dint dstY0, WGC3Dint dstX1, WGC3Dint dstY1, | |
432 WGC3Dbitfield mask, WGC3Denum filter) { | |
433 ClearContext(); | |
434 gl_->BlitFramebufferCHROMIUM( | |
435 srcX0, srcY0, srcX1, srcY1, | |
436 dstX0, dstY0, dstX1, dstY1, | |
437 mask, filter); | |
438 } | |
439 | |
440 void WebGraphicsContext3DInProcessCommandBufferImpl:: | |
441 renderbufferStorageMultisampleCHROMIUM( | |
442 WGC3Denum target, WGC3Dsizei samples, WGC3Denum internalformat, | |
443 WGC3Dsizei width, WGC3Dsizei height) { | |
444 ClearContext(); | |
445 gl_->RenderbufferStorageMultisampleCHROMIUM( | |
446 target, samples, internalformat, width, height); | |
447 } | |
448 | |
449 DELEGATE_TO_GL_1(activeTexture, ActiveTexture, WGC3Denum) | |
450 | |
451 DELEGATE_TO_GL_2(attachShader, AttachShader, WebGLId, WebGLId) | |
452 | |
453 DELEGATE_TO_GL_3(bindAttribLocation, BindAttribLocation, WebGLId, | |
454 WGC3Duint, const WGC3Dchar*) | |
455 | |
456 DELEGATE_TO_GL_2(bindBuffer, BindBuffer, WGC3Denum, WebGLId) | |
457 | |
458 void WebGraphicsContext3DInProcessCommandBufferImpl::bindFramebuffer( | |
459 WGC3Denum target, | |
460 WebGLId framebuffer) { | |
461 ClearContext(); | |
462 gl_->BindFramebuffer(target, framebuffer); | |
463 } | |
464 | |
465 DELEGATE_TO_GL_2(bindRenderbuffer, BindRenderbuffer, WGC3Denum, WebGLId) | |
466 | |
467 DELEGATE_TO_GL_2(bindTexture, BindTexture, WGC3Denum, WebGLId) | |
468 | |
469 DELEGATE_TO_GL_4(blendColor, BlendColor, | |
470 WGC3Dclampf, WGC3Dclampf, WGC3Dclampf, WGC3Dclampf) | |
471 | |
472 DELEGATE_TO_GL_1(blendEquation, BlendEquation, WGC3Denum) | |
473 | |
474 DELEGATE_TO_GL_2(blendEquationSeparate, BlendEquationSeparate, | |
475 WGC3Denum, WGC3Denum) | |
476 | |
477 DELEGATE_TO_GL_2(blendFunc, BlendFunc, WGC3Denum, WGC3Denum) | |
478 | |
479 DELEGATE_TO_GL_4(blendFuncSeparate, BlendFuncSeparate, | |
480 WGC3Denum, WGC3Denum, WGC3Denum, WGC3Denum) | |
481 | |
482 DELEGATE_TO_GL_4(bufferData, BufferData, | |
483 WGC3Denum, WGC3Dsizeiptr, const void*, WGC3Denum) | |
484 | |
485 DELEGATE_TO_GL_4(bufferSubData, BufferSubData, | |
486 WGC3Denum, WGC3Dintptr, WGC3Dsizeiptr, const void*) | |
487 | |
488 DELEGATE_TO_GL_1R(checkFramebufferStatus, CheckFramebufferStatus, | |
489 WGC3Denum, WGC3Denum) | |
490 | |
491 DELEGATE_TO_GL_1(clear, Clear, WGC3Dbitfield) | |
492 | |
493 DELEGATE_TO_GL_4(clearColor, ClearColor, | |
494 WGC3Dclampf, WGC3Dclampf, WGC3Dclampf, WGC3Dclampf) | |
495 | |
496 DELEGATE_TO_GL_1(clearDepth, ClearDepthf, WGC3Dclampf) | |
497 | |
498 DELEGATE_TO_GL_1(clearStencil, ClearStencil, WGC3Dint) | |
499 | |
500 DELEGATE_TO_GL_4(colorMask, ColorMask, | |
501 WGC3Dboolean, WGC3Dboolean, WGC3Dboolean, WGC3Dboolean) | |
502 | |
503 DELEGATE_TO_GL_1(compileShader, CompileShader, WebGLId) | |
504 | |
505 DELEGATE_TO_GL_8(compressedTexImage2D, CompressedTexImage2D, | |
506 WGC3Denum, WGC3Dint, WGC3Denum, WGC3Dint, WGC3Dint, | |
507 WGC3Dsizei, WGC3Dsizei, const void*) | |
508 | |
509 DELEGATE_TO_GL_9(compressedTexSubImage2D, CompressedTexSubImage2D, | |
510 WGC3Denum, WGC3Dint, WGC3Dint, WGC3Dint, WGC3Dint, WGC3Dint, | |
511 WGC3Denum, WGC3Dsizei, const void*) | |
512 | |
513 DELEGATE_TO_GL_8(copyTexImage2D, CopyTexImage2D, | |
514 WGC3Denum, WGC3Dint, WGC3Denum, WGC3Dint, WGC3Dint, | |
515 WGC3Dsizei, WGC3Dsizei, WGC3Dint) | |
516 | |
517 DELEGATE_TO_GL_8(copyTexSubImage2D, CopyTexSubImage2D, | |
518 WGC3Denum, WGC3Dint, WGC3Dint, WGC3Dint, WGC3Dint, WGC3Dint, | |
519 WGC3Dsizei, WGC3Dsizei) | |
520 | |
521 DELEGATE_TO_GL_1(cullFace, CullFace, WGC3Denum) | |
522 | |
523 DELEGATE_TO_GL_1(depthFunc, DepthFunc, WGC3Denum) | |
524 | |
525 DELEGATE_TO_GL_1(depthMask, DepthMask, WGC3Dboolean) | |
526 | |
527 DELEGATE_TO_GL_2(depthRange, DepthRangef, WGC3Dclampf, WGC3Dclampf) | |
528 | |
529 DELEGATE_TO_GL_2(detachShader, DetachShader, WebGLId, WebGLId) | |
530 | |
531 DELEGATE_TO_GL_1(disable, Disable, WGC3Denum) | |
532 | |
533 DELEGATE_TO_GL_1(disableVertexAttribArray, DisableVertexAttribArray, | |
534 WGC3Duint) | |
535 | |
536 DELEGATE_TO_GL_3(drawArrays, DrawArrays, WGC3Denum, WGC3Dint, WGC3Dsizei) | |
537 | |
538 void WebGraphicsContext3DInProcessCommandBufferImpl::drawElements( | |
539 WGC3Denum mode, | |
540 WGC3Dsizei count, | |
541 WGC3Denum type, | |
542 WGC3Dintptr offset) { | |
543 ClearContext(); | |
544 gl_->DrawElements( | |
545 mode, count, type, | |
546 reinterpret_cast<void*>(static_cast<intptr_t>(offset))); | |
547 } | |
548 | |
549 DELEGATE_TO_GL_1(enable, Enable, WGC3Denum) | |
550 | |
551 DELEGATE_TO_GL_1(enableVertexAttribArray, EnableVertexAttribArray, | |
552 WGC3Duint) | |
553 | |
554 void WebGraphicsContext3DInProcessCommandBufferImpl::finish() { | |
555 flush_id_ = GenFlushID(); | |
556 gl_->Finish(); | |
557 } | |
558 | |
559 void WebGraphicsContext3DInProcessCommandBufferImpl::flush() { | |
560 flush_id_ = GenFlushID(); | |
561 gl_->Flush(); | |
562 } | |
563 | |
564 DELEGATE_TO_GL_4(framebufferRenderbuffer, FramebufferRenderbuffer, | |
565 WGC3Denum, WGC3Denum, WGC3Denum, WebGLId) | |
566 | |
567 DELEGATE_TO_GL_5(framebufferTexture2D, FramebufferTexture2D, | |
568 WGC3Denum, WGC3Denum, WGC3Denum, WebGLId, WGC3Dint) | |
569 | |
570 DELEGATE_TO_GL_1(frontFace, FrontFace, WGC3Denum) | |
571 | |
572 DELEGATE_TO_GL_1(generateMipmap, GenerateMipmap, WGC3Denum) | |
573 | |
574 bool WebGraphicsContext3DInProcessCommandBufferImpl::getActiveAttrib( | |
575 WebGLId program, WGC3Duint index, ActiveInfo& info) { | |
576 ClearContext(); | |
577 if (!program) { | |
578 synthesizeGLError(GL_INVALID_VALUE); | |
579 return false; | |
580 } | |
581 GLint max_name_length = -1; | |
582 gl_->GetProgramiv( | |
583 program, GL_ACTIVE_ATTRIBUTE_MAX_LENGTH, &max_name_length); | |
584 if (max_name_length < 0) | |
585 return false; | |
586 scoped_ptr<GLchar[]> name(new GLchar[max_name_length]); | |
587 if (!name) { | |
588 synthesizeGLError(GL_OUT_OF_MEMORY); | |
589 return false; | |
590 } | |
591 GLsizei length = 0; | |
592 GLint size = -1; | |
593 GLenum type = 0; | |
594 gl_->GetActiveAttrib( | |
595 program, index, max_name_length, &length, &size, &type, name.get()); | |
596 if (size < 0) { | |
597 return false; | |
598 } | |
599 info.name = blink::WebString::fromUTF8(name.get(), length); | |
600 info.type = type; | |
601 info.size = size; | |
602 return true; | |
603 } | |
604 | |
605 bool WebGraphicsContext3DInProcessCommandBufferImpl::getActiveUniform( | |
606 WebGLId program, WGC3Duint index, ActiveInfo& info) { | |
607 ClearContext(); | |
608 GLint max_name_length = -1; | |
609 gl_->GetProgramiv( | |
610 program, GL_ACTIVE_UNIFORM_MAX_LENGTH, &max_name_length); | |
611 if (max_name_length < 0) | |
612 return false; | |
613 scoped_ptr<GLchar[]> name(new GLchar[max_name_length]); | |
614 if (!name) { | |
615 synthesizeGLError(GL_OUT_OF_MEMORY); | |
616 return false; | |
617 } | |
618 GLsizei length = 0; | |
619 GLint size = -1; | |
620 GLenum type = 0; | |
621 gl_->GetActiveUniform( | |
622 program, index, max_name_length, &length, &size, &type, name.get()); | |
623 if (size < 0) { | |
624 return false; | |
625 } | |
626 info.name = blink::WebString::fromUTF8(name.get(), length); | |
627 info.type = type; | |
628 info.size = size; | |
629 return true; | |
630 } | |
631 | |
632 DELEGATE_TO_GL_4(getAttachedShaders, GetAttachedShaders, | |
633 WebGLId, WGC3Dsizei, WGC3Dsizei*, WebGLId*) | |
634 | |
635 DELEGATE_TO_GL_2R(getAttribLocation, GetAttribLocation, | |
636 WebGLId, const WGC3Dchar*, WGC3Dint) | |
637 | |
638 DELEGATE_TO_GL_2(getBooleanv, GetBooleanv, WGC3Denum, WGC3Dboolean*) | |
639 | |
640 DELEGATE_TO_GL_3(getBufferParameteriv, GetBufferParameteriv, | |
641 WGC3Denum, WGC3Denum, WGC3Dint*) | |
642 | |
643 blink::WebGraphicsContext3D::Attributes | |
644 WebGraphicsContext3DInProcessCommandBufferImpl::getContextAttributes() { | |
645 return attributes_; | |
646 } | |
647 | |
648 WGC3Denum WebGraphicsContext3DInProcessCommandBufferImpl::getError() { | |
649 ClearContext(); | |
650 if (!synthetic_errors_.empty()) { | |
651 std::vector<WGC3Denum>::iterator iter = synthetic_errors_.begin(); | |
652 WGC3Denum err = *iter; | |
653 synthetic_errors_.erase(iter); | |
654 return err; | |
655 } | |
656 | |
657 return gl_->GetError(); | |
658 } | |
659 | |
660 bool WebGraphicsContext3DInProcessCommandBufferImpl::isContextLost() { | 213 bool WebGraphicsContext3DInProcessCommandBufferImpl::isContextLost() { |
661 return context_lost_reason_ != GL_NO_ERROR; | 214 return context_lost_reason_ != GL_NO_ERROR; |
662 } | 215 } |
663 | 216 |
664 DELEGATE_TO_GL_2(getFloatv, GetFloatv, WGC3Denum, WGC3Dfloat*) | |
665 | |
666 DELEGATE_TO_GL_4(getFramebufferAttachmentParameteriv, | |
667 GetFramebufferAttachmentParameteriv, | |
668 WGC3Denum, WGC3Denum, WGC3Denum, WGC3Dint*) | |
669 | |
670 DELEGATE_TO_GL_2(getIntegerv, GetIntegerv, WGC3Denum, WGC3Dint*) | |
671 | |
672 DELEGATE_TO_GL_3(getProgramiv, GetProgramiv, WebGLId, WGC3Denum, WGC3Dint*) | |
673 | |
674 blink::WebString WebGraphicsContext3DInProcessCommandBufferImpl:: | |
675 getProgramInfoLog(WebGLId program) { | |
676 ClearContext(); | |
677 GLint logLength = 0; | |
678 gl_->GetProgramiv(program, GL_INFO_LOG_LENGTH, &logLength); | |
679 if (!logLength) | |
680 return blink::WebString(); | |
681 scoped_ptr<GLchar[]> log(new GLchar[logLength]); | |
682 if (!log) | |
683 return blink::WebString(); | |
684 GLsizei returnedLogLength = 0; | |
685 gl_->GetProgramInfoLog( | |
686 program, logLength, &returnedLogLength, log.get()); | |
687 DCHECK_EQ(logLength, returnedLogLength + 1); | |
688 blink::WebString res = | |
689 blink::WebString::fromUTF8(log.get(), returnedLogLength); | |
690 return res; | |
691 } | |
692 | |
693 DELEGATE_TO_GL_3(getRenderbufferParameteriv, GetRenderbufferParameteriv, | |
694 WGC3Denum, WGC3Denum, WGC3Dint*) | |
695 | |
696 DELEGATE_TO_GL_3(getShaderiv, GetShaderiv, WebGLId, WGC3Denum, WGC3Dint*) | |
697 | |
698 blink::WebString WebGraphicsContext3DInProcessCommandBufferImpl:: | |
699 getShaderInfoLog(WebGLId shader) { | |
700 ClearContext(); | |
701 GLint logLength = 0; | |
702 gl_->GetShaderiv(shader, GL_INFO_LOG_LENGTH, &logLength); | |
703 if (!logLength) | |
704 return blink::WebString(); | |
705 scoped_ptr<GLchar[]> log(new GLchar[logLength]); | |
706 if (!log) | |
707 return blink::WebString(); | |
708 GLsizei returnedLogLength = 0; | |
709 gl_->GetShaderInfoLog( | |
710 shader, logLength, &returnedLogLength, log.get()); | |
711 DCHECK_EQ(logLength, returnedLogLength + 1); | |
712 blink::WebString res = | |
713 blink::WebString::fromUTF8(log.get(), returnedLogLength); | |
714 return res; | |
715 } | |
716 | |
717 DELEGATE_TO_GL_4(getShaderPrecisionFormat, GetShaderPrecisionFormat, | |
718 WGC3Denum, WGC3Denum, WGC3Dint*, WGC3Dint*) | |
719 | |
720 blink::WebString WebGraphicsContext3DInProcessCommandBufferImpl:: | |
721 getShaderSource(WebGLId shader) { | |
722 ClearContext(); | |
723 GLint logLength = 0; | |
724 gl_->GetShaderiv(shader, GL_SHADER_SOURCE_LENGTH, &logLength); | |
725 if (!logLength) | |
726 return blink::WebString(); | |
727 scoped_ptr<GLchar[]> log(new GLchar[logLength]); | |
728 if (!log) | |
729 return blink::WebString(); | |
730 GLsizei returnedLogLength = 0; | |
731 gl_->GetShaderSource( | |
732 shader, logLength, &returnedLogLength, log.get()); | |
733 if (!returnedLogLength) | |
734 return blink::WebString(); | |
735 DCHECK_EQ(logLength, returnedLogLength + 1); | |
736 blink::WebString res = | |
737 blink::WebString::fromUTF8(log.get(), returnedLogLength); | |
738 return res; | |
739 } | |
740 | |
741 blink::WebString WebGraphicsContext3DInProcessCommandBufferImpl:: | |
742 getTranslatedShaderSourceANGLE(WebGLId shader) { | |
743 ClearContext(); | |
744 GLint logLength = 0; | |
745 gl_->GetShaderiv( | |
746 shader, GL_TRANSLATED_SHADER_SOURCE_LENGTH_ANGLE, &logLength); | |
747 if (!logLength) | |
748 return blink::WebString(); | |
749 scoped_ptr<GLchar[]> log(new GLchar[logLength]); | |
750 if (!log) | |
751 return blink::WebString(); | |
752 GLsizei returnedLogLength = 0; | |
753 gl_->GetTranslatedShaderSourceANGLE( | |
754 shader, logLength, &returnedLogLength, log.get()); | |
755 if (!returnedLogLength) | |
756 return blink::WebString(); | |
757 DCHECK_EQ(logLength, returnedLogLength + 1); | |
758 blink::WebString res = | |
759 blink::WebString::fromUTF8(log.get(), returnedLogLength); | |
760 return res; | |
761 } | |
762 | |
763 blink::WebString WebGraphicsContext3DInProcessCommandBufferImpl::getString( | |
764 WGC3Denum name) { | |
765 ClearContext(); | |
766 return blink::WebString::fromUTF8( | |
767 reinterpret_cast<const char*>(gl_->GetString(name))); | |
768 } | |
769 | |
770 DELEGATE_TO_GL_3(getTexParameterfv, GetTexParameterfv, | |
771 WGC3Denum, WGC3Denum, WGC3Dfloat*) | |
772 | |
773 DELEGATE_TO_GL_3(getTexParameteriv, GetTexParameteriv, | |
774 WGC3Denum, WGC3Denum, WGC3Dint*) | |
775 | |
776 DELEGATE_TO_GL_3(getUniformfv, GetUniformfv, WebGLId, WGC3Dint, WGC3Dfloat*) | |
777 | |
778 DELEGATE_TO_GL_3(getUniformiv, GetUniformiv, WebGLId, WGC3Dint, WGC3Dint*) | |
779 | |
780 DELEGATE_TO_GL_2R(getUniformLocation, GetUniformLocation, | |
781 WebGLId, const WGC3Dchar*, WGC3Dint) | |
782 | |
783 DELEGATE_TO_GL_3(getVertexAttribfv, GetVertexAttribfv, | |
784 WGC3Duint, WGC3Denum, WGC3Dfloat*) | |
785 | |
786 DELEGATE_TO_GL_3(getVertexAttribiv, GetVertexAttribiv, | |
787 WGC3Duint, WGC3Denum, WGC3Dint*) | |
788 | |
789 WGC3Dsizeiptr WebGraphicsContext3DInProcessCommandBufferImpl:: | |
790 getVertexAttribOffset(WGC3Duint index, WGC3Denum pname) { | |
791 ClearContext(); | |
792 GLvoid* value = NULL; | |
793 // NOTE: If pname is ever a value that returns more then 1 element | |
794 // this will corrupt memory. | |
795 gl_->GetVertexAttribPointerv(index, pname, &value); | |
796 return static_cast<WGC3Dsizeiptr>(reinterpret_cast<intptr_t>(value)); | |
797 } | |
798 | |
799 DELEGATE_TO_GL_2(hint, Hint, WGC3Denum, WGC3Denum) | |
800 | |
801 DELEGATE_TO_GL_1RB(isBuffer, IsBuffer, WebGLId, WGC3Dboolean) | |
802 | |
803 DELEGATE_TO_GL_1RB(isEnabled, IsEnabled, WGC3Denum, WGC3Dboolean) | |
804 | |
805 DELEGATE_TO_GL_1RB(isFramebuffer, IsFramebuffer, WebGLId, WGC3Dboolean) | |
806 | |
807 DELEGATE_TO_GL_1RB(isProgram, IsProgram, WebGLId, WGC3Dboolean) | |
808 | |
809 DELEGATE_TO_GL_1RB(isRenderbuffer, IsRenderbuffer, WebGLId, WGC3Dboolean) | |
810 | |
811 DELEGATE_TO_GL_1RB(isShader, IsShader, WebGLId, WGC3Dboolean) | |
812 | |
813 DELEGATE_TO_GL_1RB(isTexture, IsTexture, WebGLId, WGC3Dboolean) | |
814 | |
815 DELEGATE_TO_GL_1(lineWidth, LineWidth, WGC3Dfloat) | |
816 | |
817 DELEGATE_TO_GL_1(linkProgram, LinkProgram, WebGLId) | |
818 | |
819 DELEGATE_TO_GL_2(pixelStorei, PixelStorei, WGC3Denum, WGC3Dint) | |
820 | |
821 DELEGATE_TO_GL_2(polygonOffset, PolygonOffset, WGC3Dfloat, WGC3Dfloat) | |
822 | |
823 DELEGATE_TO_GL_7(readPixels, ReadPixels, | |
824 WGC3Dint, WGC3Dint, WGC3Dsizei, WGC3Dsizei, WGC3Denum, | |
825 WGC3Denum, void*) | |
826 | |
827 void WebGraphicsContext3DInProcessCommandBufferImpl::releaseShaderCompiler() { | |
828 ClearContext(); | |
829 } | |
830 | |
831 DELEGATE_TO_GL_4(renderbufferStorage, RenderbufferStorage, | |
832 WGC3Denum, WGC3Denum, WGC3Dsizei, WGC3Dsizei) | |
833 | |
834 DELEGATE_TO_GL_2(sampleCoverage, SampleCoverage, WGC3Dfloat, WGC3Dboolean) | |
835 | |
836 DELEGATE_TO_GL_4(scissor, Scissor, WGC3Dint, WGC3Dint, WGC3Dsizei, WGC3Dsizei) | |
837 | |
838 void WebGraphicsContext3DInProcessCommandBufferImpl::shaderSource( | |
839 WebGLId shader, const WGC3Dchar* string) { | |
840 ClearContext(); | |
841 GLint length = strlen(string); | |
842 gl_->ShaderSource(shader, 1, &string, &length); | |
843 } | |
844 | |
845 DELEGATE_TO_GL_3(stencilFunc, StencilFunc, WGC3Denum, WGC3Dint, WGC3Duint) | |
846 | |
847 DELEGATE_TO_GL_4(stencilFuncSeparate, StencilFuncSeparate, | |
848 WGC3Denum, WGC3Denum, WGC3Dint, WGC3Duint) | |
849 | |
850 DELEGATE_TO_GL_1(stencilMask, StencilMask, WGC3Duint) | |
851 | |
852 DELEGATE_TO_GL_2(stencilMaskSeparate, StencilMaskSeparate, | |
853 WGC3Denum, WGC3Duint) | |
854 | |
855 DELEGATE_TO_GL_3(stencilOp, StencilOp, | |
856 WGC3Denum, WGC3Denum, WGC3Denum) | |
857 | |
858 DELEGATE_TO_GL_4(stencilOpSeparate, StencilOpSeparate, | |
859 WGC3Denum, WGC3Denum, WGC3Denum, WGC3Denum) | |
860 | |
861 DELEGATE_TO_GL_9(texImage2D, TexImage2D, | |
862 WGC3Denum, WGC3Dint, WGC3Denum, WGC3Dsizei, WGC3Dsizei, | |
863 WGC3Dint, WGC3Denum, WGC3Denum, const void*) | |
864 | |
865 DELEGATE_TO_GL_3(texParameterf, TexParameterf, | |
866 WGC3Denum, WGC3Denum, WGC3Dfloat); | |
867 | |
868 static const unsigned int kTextureWrapR = 0x8072; | |
869 | |
870 void WebGraphicsContext3DInProcessCommandBufferImpl::texParameteri( | |
871 WGC3Denum target, WGC3Denum pname, WGC3Dint param) { | |
872 ClearContext(); | |
873 // TODO(kbr): figure out whether the setting of TEXTURE_WRAP_R in | |
874 // GraphicsContext3D.cpp is strictly necessary to avoid seams at the | |
875 // edge of cube maps, and, if it is, push it into the GLES2 service | |
876 // side code. | |
877 if (pname == kTextureWrapR) { | |
878 return; | |
879 } | |
880 gl_->TexParameteri(target, pname, param); | |
881 } | |
882 | |
883 DELEGATE_TO_GL_9(texSubImage2D, TexSubImage2D, | |
884 WGC3Denum, WGC3Dint, WGC3Dint, WGC3Dint, WGC3Dsizei, | |
885 WGC3Dsizei, WGC3Denum, WGC3Denum, const void*) | |
886 | |
887 DELEGATE_TO_GL_2(uniform1f, Uniform1f, WGC3Dint, WGC3Dfloat) | |
888 | |
889 DELEGATE_TO_GL_3(uniform1fv, Uniform1fv, WGC3Dint, WGC3Dsizei, | |
890 const WGC3Dfloat*) | |
891 | |
892 DELEGATE_TO_GL_2(uniform1i, Uniform1i, WGC3Dint, WGC3Dint) | |
893 | |
894 DELEGATE_TO_GL_3(uniform1iv, Uniform1iv, WGC3Dint, WGC3Dsizei, const WGC3Dint*) | |
895 | |
896 DELEGATE_TO_GL_3(uniform2f, Uniform2f, WGC3Dint, WGC3Dfloat, WGC3Dfloat) | |
897 | |
898 DELEGATE_TO_GL_3(uniform2fv, Uniform2fv, WGC3Dint, WGC3Dsizei, | |
899 const WGC3Dfloat*) | |
900 | |
901 DELEGATE_TO_GL_3(uniform2i, Uniform2i, WGC3Dint, WGC3Dint, WGC3Dint) | |
902 | |
903 DELEGATE_TO_GL_3(uniform2iv, Uniform2iv, WGC3Dint, WGC3Dsizei, const WGC3Dint*) | |
904 | |
905 DELEGATE_TO_GL_4(uniform3f, Uniform3f, WGC3Dint, | |
906 WGC3Dfloat, WGC3Dfloat, WGC3Dfloat) | |
907 | |
908 DELEGATE_TO_GL_3(uniform3fv, Uniform3fv, WGC3Dint, WGC3Dsizei, | |
909 const WGC3Dfloat*) | |
910 | |
911 DELEGATE_TO_GL_4(uniform3i, Uniform3i, WGC3Dint, WGC3Dint, WGC3Dint, WGC3Dint) | |
912 | |
913 DELEGATE_TO_GL_3(uniform3iv, Uniform3iv, WGC3Dint, WGC3Dsizei, const WGC3Dint*) | |
914 | |
915 DELEGATE_TO_GL_5(uniform4f, Uniform4f, WGC3Dint, | |
916 WGC3Dfloat, WGC3Dfloat, WGC3Dfloat, WGC3Dfloat) | |
917 | |
918 DELEGATE_TO_GL_3(uniform4fv, Uniform4fv, WGC3Dint, WGC3Dsizei, | |
919 const WGC3Dfloat*) | |
920 | |
921 DELEGATE_TO_GL_5(uniform4i, Uniform4i, WGC3Dint, | |
922 WGC3Dint, WGC3Dint, WGC3Dint, WGC3Dint) | |
923 | |
924 DELEGATE_TO_GL_3(uniform4iv, Uniform4iv, WGC3Dint, WGC3Dsizei, const WGC3Dint*) | |
925 | |
926 DELEGATE_TO_GL_4(uniformMatrix2fv, UniformMatrix2fv, | |
927 WGC3Dint, WGC3Dsizei, WGC3Dboolean, const WGC3Dfloat*) | |
928 | |
929 DELEGATE_TO_GL_4(uniformMatrix3fv, UniformMatrix3fv, | |
930 WGC3Dint, WGC3Dsizei, WGC3Dboolean, const WGC3Dfloat*) | |
931 | |
932 DELEGATE_TO_GL_4(uniformMatrix4fv, UniformMatrix4fv, | |
933 WGC3Dint, WGC3Dsizei, WGC3Dboolean, const WGC3Dfloat*) | |
934 | |
935 DELEGATE_TO_GL_1(useProgram, UseProgram, WebGLId) | |
936 | |
937 DELEGATE_TO_GL_1(validateProgram, ValidateProgram, WebGLId) | |
938 | |
939 DELEGATE_TO_GL_2(vertexAttrib1f, VertexAttrib1f, WGC3Duint, WGC3Dfloat) | |
940 | |
941 DELEGATE_TO_GL_2(vertexAttrib1fv, VertexAttrib1fv, WGC3Duint, | |
942 const WGC3Dfloat*) | |
943 | |
944 DELEGATE_TO_GL_3(vertexAttrib2f, VertexAttrib2f, WGC3Duint, | |
945 WGC3Dfloat, WGC3Dfloat) | |
946 | |
947 DELEGATE_TO_GL_2(vertexAttrib2fv, VertexAttrib2fv, WGC3Duint, | |
948 const WGC3Dfloat*) | |
949 | |
950 DELEGATE_TO_GL_4(vertexAttrib3f, VertexAttrib3f, WGC3Duint, | |
951 WGC3Dfloat, WGC3Dfloat, WGC3Dfloat) | |
952 | |
953 DELEGATE_TO_GL_2(vertexAttrib3fv, VertexAttrib3fv, WGC3Duint, | |
954 const WGC3Dfloat*) | |
955 | |
956 DELEGATE_TO_GL_5(vertexAttrib4f, VertexAttrib4f, WGC3Duint, | |
957 WGC3Dfloat, WGC3Dfloat, WGC3Dfloat, WGC3Dfloat) | |
958 | |
959 DELEGATE_TO_GL_2(vertexAttrib4fv, VertexAttrib4fv, WGC3Duint, | |
960 const WGC3Dfloat*) | |
961 | |
962 void WebGraphicsContext3DInProcessCommandBufferImpl::vertexAttribPointer( | |
963 WGC3Duint index, WGC3Dint size, WGC3Denum type, WGC3Dboolean normalized, | |
964 WGC3Dsizei stride, WGC3Dintptr offset) { | |
965 ClearContext(); | |
966 gl_->VertexAttribPointer( | |
967 index, size, type, normalized, stride, | |
968 reinterpret_cast<void*>(static_cast<intptr_t>(offset))); | |
969 } | |
970 | |
971 DELEGATE_TO_GL_4(viewport, Viewport, | |
972 WGC3Dint, WGC3Dint, WGC3Dsizei, WGC3Dsizei) | |
973 | |
974 DELEGATE_TO_GL_2(genBuffers, GenBuffers, WGC3Dsizei, WebGLId*); | |
975 | |
976 DELEGATE_TO_GL_2(genFramebuffers, GenFramebuffers, WGC3Dsizei, WebGLId*); | |
977 | |
978 DELEGATE_TO_GL_2(genRenderbuffers, GenRenderbuffers, WGC3Dsizei, WebGLId*); | |
979 | |
980 DELEGATE_TO_GL_2(genTextures, GenTextures, WGC3Dsizei, WebGLId*); | |
981 | |
982 DELEGATE_TO_GL_2(deleteBuffers, DeleteBuffers, WGC3Dsizei, WebGLId*); | |
983 | |
984 DELEGATE_TO_GL_2(deleteFramebuffers, DeleteFramebuffers, WGC3Dsizei, WebGLId*); | |
985 | |
986 DELEGATE_TO_GL_2(deleteRenderbuffers, DeleteRenderbuffers, WGC3Dsizei, | |
987 WebGLId*); | |
988 | |
989 DELEGATE_TO_GL_2(deleteTextures, DeleteTextures, WGC3Dsizei, WebGLId*); | |
990 | |
991 WebGLId WebGraphicsContext3DInProcessCommandBufferImpl::createBuffer() { | |
992 ClearContext(); | |
993 GLuint o; | |
994 gl_->GenBuffers(1, &o); | |
995 return o; | |
996 } | |
997 | |
998 WebGLId WebGraphicsContext3DInProcessCommandBufferImpl::createFramebuffer() { | |
999 ClearContext(); | |
1000 GLuint o = 0; | |
1001 gl_->GenFramebuffers(1, &o); | |
1002 return o; | |
1003 } | |
1004 | |
1005 WebGLId WebGraphicsContext3DInProcessCommandBufferImpl::createRenderbuffer() { | |
1006 ClearContext(); | |
1007 GLuint o; | |
1008 gl_->GenRenderbuffers(1, &o); | |
1009 return o; | |
1010 } | |
1011 | |
1012 WebGLId WebGraphicsContext3DInProcessCommandBufferImpl::createTexture() { | |
1013 ClearContext(); | |
1014 GLuint o; | |
1015 gl_->GenTextures(1, &o); | |
1016 return o; | |
1017 } | |
1018 | |
1019 void WebGraphicsContext3DInProcessCommandBufferImpl::deleteBuffer( | |
1020 WebGLId buffer) { | |
1021 ClearContext(); | |
1022 gl_->DeleteBuffers(1, &buffer); | |
1023 } | |
1024 | |
1025 void WebGraphicsContext3DInProcessCommandBufferImpl::deleteFramebuffer( | |
1026 WebGLId framebuffer) { | |
1027 ClearContext(); | |
1028 gl_->DeleteFramebuffers(1, &framebuffer); | |
1029 } | |
1030 | |
1031 void WebGraphicsContext3DInProcessCommandBufferImpl::deleteRenderbuffer( | |
1032 WebGLId renderbuffer) { | |
1033 ClearContext(); | |
1034 gl_->DeleteRenderbuffers(1, &renderbuffer); | |
1035 } | |
1036 | |
1037 void WebGraphicsContext3DInProcessCommandBufferImpl::deleteTexture( | |
1038 WebGLId texture) { | |
1039 ClearContext(); | |
1040 gl_->DeleteTextures(1, &texture); | |
1041 } | |
1042 | |
1043 DELEGATE_TO_GL_R(createProgram, CreateProgram, WebGLId); | |
1044 | |
1045 DELEGATE_TO_GL_1R(createShader, CreateShader, WGC3Denum, WebGLId); | |
1046 | |
1047 DELEGATE_TO_GL_1(deleteProgram, DeleteProgram, WebGLId); | |
1048 | |
1049 DELEGATE_TO_GL_1(deleteShader, DeleteShader, WebGLId); | |
1050 | |
1051 void WebGraphicsContext3DInProcessCommandBufferImpl::setContextLostCallback( | |
1052 WebGraphicsContext3D::WebGraphicsContextLostCallback* cb) { | |
1053 context_lost_callback_ = cb; | |
1054 } | |
1055 | |
1056 WGC3Denum WebGraphicsContext3DInProcessCommandBufferImpl:: | 217 WGC3Denum WebGraphicsContext3DInProcessCommandBufferImpl:: |
1057 getGraphicsResetStatusARB() { | 218 getGraphicsResetStatusARB() { |
1058 return context_lost_reason_; | 219 return context_lost_reason_; |
1059 } | 220 } |
1060 | 221 |
1061 DELEGATE_TO_GL_5(texImageIOSurface2DCHROMIUM, TexImageIOSurface2DCHROMIUM, | |
1062 WGC3Denum, WGC3Dint, WGC3Dint, WGC3Duint, WGC3Duint) | |
1063 | |
1064 DELEGATE_TO_GL_5(texStorage2DEXT, TexStorage2DEXT, | |
1065 WGC3Denum, WGC3Dint, WGC3Duint, WGC3Dint, WGC3Dint) | |
1066 | |
1067 WebGLId WebGraphicsContext3DInProcessCommandBufferImpl::createQueryEXT() { | |
1068 GLuint o; | |
1069 gl_->GenQueriesEXT(1, &o); | |
1070 return o; | |
1071 } | |
1072 | |
1073 void WebGraphicsContext3DInProcessCommandBufferImpl:: | |
1074 deleteQueryEXT(WebGLId query) { | |
1075 gl_->DeleteQueriesEXT(1, &query); | |
1076 } | |
1077 | |
1078 DELEGATE_TO_GL_1R(isQueryEXT, IsQueryEXT, WebGLId, WGC3Dboolean) | |
1079 DELEGATE_TO_GL_2(beginQueryEXT, BeginQueryEXT, WGC3Denum, WebGLId) | |
1080 DELEGATE_TO_GL_1(endQueryEXT, EndQueryEXT, WGC3Denum) | |
1081 DELEGATE_TO_GL_3(getQueryivEXT, GetQueryivEXT, WGC3Denum, WGC3Denum, WGC3Dint*) | |
1082 DELEGATE_TO_GL_3(getQueryObjectuivEXT, GetQueryObjectuivEXT, | |
1083 WebGLId, WGC3Denum, WGC3Duint*) | |
1084 | |
1085 DELEGATE_TO_GL_6(copyTextureCHROMIUM, CopyTextureCHROMIUM, WGC3Denum, WGC3Duint, | |
1086 WGC3Duint, WGC3Dint, WGC3Denum, WGC3Denum) | |
1087 | |
1088 void WebGraphicsContext3DInProcessCommandBufferImpl::insertEventMarkerEXT( | |
1089 const WGC3Dchar* marker) { | |
1090 gl_->InsertEventMarkerEXT(0, marker); | |
1091 } | |
1092 | |
1093 void WebGraphicsContext3DInProcessCommandBufferImpl::pushGroupMarkerEXT( | |
1094 const WGC3Dchar* marker) { | |
1095 gl_->PushGroupMarkerEXT(0, marker); | |
1096 } | |
1097 | |
1098 DELEGATE_TO_GL(popGroupMarkerEXT, PopGroupMarkerEXT); | |
1099 | |
1100 DELEGATE_TO_GL_2(bindTexImage2DCHROMIUM, BindTexImage2DCHROMIUM, | |
1101 WGC3Denum, WGC3Dint) | |
1102 DELEGATE_TO_GL_2(releaseTexImage2DCHROMIUM, ReleaseTexImage2DCHROMIUM, | |
1103 WGC3Denum, WGC3Dint) | |
1104 | |
1105 void* WebGraphicsContext3DInProcessCommandBufferImpl::mapBufferCHROMIUM( | |
1106 WGC3Denum target, WGC3Denum access) { | |
1107 ClearContext(); | |
1108 return gl_->MapBufferCHROMIUM(target, access); | |
1109 } | |
1110 | |
1111 WGC3Dboolean WebGraphicsContext3DInProcessCommandBufferImpl:: | |
1112 unmapBufferCHROMIUM(WGC3Denum target) { | |
1113 ClearContext(); | |
1114 return gl_->UnmapBufferCHROMIUM(target); | |
1115 } | |
1116 | |
1117 GrGLInterface* WebGraphicsContext3DInProcessCommandBufferImpl:: | |
1118 createGrGLInterface() { | |
1119 makeContextCurrent(); | |
1120 return skia_bindings::CreateCommandBufferSkiaGLBinding(); | |
1121 } | |
1122 | |
1123 ::gpu::gles2::GLES2Interface* | |
1124 WebGraphicsContext3DInProcessCommandBufferImpl::GetGLInterface() { | |
1125 return gl_; | |
1126 } | |
1127 | |
1128 ::gpu::ContextSupport* | 222 ::gpu::ContextSupport* |
1129 WebGraphicsContext3DInProcessCommandBufferImpl::GetContextSupport() { | 223 WebGraphicsContext3DInProcessCommandBufferImpl::GetContextSupport() { |
1130 return gl_; | 224 return real_gl_; |
1131 } | 225 } |
1132 | 226 |
1133 void WebGraphicsContext3DInProcessCommandBufferImpl::OnContextLost() { | 227 void WebGraphicsContext3DInProcessCommandBufferImpl::OnContextLost() { |
1134 // TODO(kbr): improve the precision here. | 228 // TODO(kbr): improve the precision here. |
1135 context_lost_reason_ = GL_UNKNOWN_CONTEXT_RESET_ARB; | 229 context_lost_reason_ = GL_UNKNOWN_CONTEXT_RESET_ARB; |
1136 if (context_lost_callback_) { | 230 if (context_lost_callback_) { |
1137 context_lost_callback_->onContextLost(); | 231 context_lost_callback_->onContextLost(); |
1138 } | 232 } |
1139 } | 233 } |
1140 | 234 |
1141 DELEGATE_TO_GL_4R(createImageCHROMIUM, | |
1142 CreateImageCHROMIUM, | |
1143 WGC3Dsizei, | |
1144 WGC3Dsizei, | |
1145 WGC3Denum, | |
1146 WGC3Denum, | |
1147 WGC3Duint); | |
1148 | |
1149 DELEGATE_TO_GL_1(destroyImageCHROMIUM, DestroyImageCHROMIUM, WGC3Duint); | |
1150 | |
1151 DELEGATE_TO_GL_3(getImageParameterivCHROMIUM, GetImageParameterivCHROMIUM, | |
1152 WGC3Duint, WGC3Denum, GLint*); | |
1153 | |
1154 DELEGATE_TO_GL_1R(mapImageCHROMIUM, MapImageCHROMIUM, WGC3Duint, void*); | |
1155 | |
1156 DELEGATE_TO_GL_1(unmapImageCHROMIUM, UnmapImageCHROMIUM, WGC3Duint); | |
1157 | |
1158 DELEGATE_TO_GL_6(framebufferTexture2DMultisampleEXT, | |
1159 FramebufferTexture2DMultisampleEXT, | |
1160 WGC3Denum, WGC3Denum, WGC3Denum, WebGLId, WGC3Dint, WGC3Dsizei) | |
1161 | |
1162 DELEGATE_TO_GL_5(renderbufferStorageMultisampleEXT, | |
1163 RenderbufferStorageMultisampleEXT, WGC3Denum, WGC3Dsizei, | |
1164 WGC3Denum, WGC3Dsizei, WGC3Dsizei) | |
1165 | |
1166 DELEGATE_TO_GL_3(bindUniformLocationCHROMIUM, BindUniformLocationCHROMIUM, | |
1167 WebGLId, WGC3Dint, const WGC3Dchar*) | |
1168 | |
1169 void WebGraphicsContext3DInProcessCommandBufferImpl::shallowFlushCHROMIUM() { | |
1170 flush_id_ = GenFlushID(); | |
1171 gl_->ShallowFlushCHROMIUM(); | |
1172 } | |
1173 | |
1174 void WebGraphicsContext3DInProcessCommandBufferImpl::shallowFinishCHROMIUM() { | |
1175 flush_id_ = GenFlushID(); | |
1176 gl_->ShallowFinishCHROMIUM(); | |
1177 } | |
1178 | |
1179 DELEGATE_TO_GL_1(genMailboxCHROMIUM, GenMailboxCHROMIUM, WGC3Dbyte*) | |
1180 DELEGATE_TO_GL_2(produceTextureCHROMIUM, ProduceTextureCHROMIUM, | |
1181 WGC3Denum, const WGC3Dbyte*) | |
1182 DELEGATE_TO_GL_2(consumeTextureCHROMIUM, ConsumeTextureCHROMIUM, | |
1183 WGC3Denum, const WGC3Dbyte*) | |
1184 | |
1185 DELEGATE_TO_GL_2(drawBuffersEXT, DrawBuffersEXT, | |
1186 WGC3Dsizei, const WGC3Denum*) | |
1187 | |
1188 DELEGATE_TO_GL_R(insertSyncPoint, InsertSyncPointCHROMIUM, unsigned) | |
1189 | |
1190 void WebGraphicsContext3DInProcessCommandBufferImpl::loseContextCHROMIUM( | |
1191 WGC3Denum current, WGC3Denum other) { | |
1192 gl_->LoseContextCHROMIUM(current, other); | |
1193 gl_->ShallowFlushCHROMIUM(); | |
1194 } | |
1195 | |
1196 DELEGATE_TO_GL_9(asyncTexImage2DCHROMIUM, AsyncTexImage2DCHROMIUM, | |
1197 WGC3Denum, WGC3Dint, WGC3Denum, WGC3Dsizei, WGC3Dsizei, WGC3Dint, | |
1198 WGC3Denum, WGC3Denum, const void*) | |
1199 | |
1200 DELEGATE_TO_GL_9(asyncTexSubImage2DCHROMIUM, AsyncTexSubImage2DCHROMIUM, | |
1201 WGC3Denum, WGC3Dint, WGC3Dint, WGC3Dint, WGC3Dsizei, WGC3Dsizei, | |
1202 WGC3Denum, WGC3Denum, const void*) | |
1203 | |
1204 DELEGATE_TO_GL_1(waitAsyncTexImage2DCHROMIUM, WaitAsyncTexImage2DCHROMIUM, | |
1205 WGC3Denum) | |
1206 | |
1207 } // namespace gpu | 235 } // namespace gpu |
1208 } // namespace webkit | 236 } // namespace webkit |
OLD | NEW |