| 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 "gpu/blink/webgraphicscontext3d_impl.h" | 5 #include "gpu/blink/webgraphicscontext3d_impl.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include "base/atomicops.h" | 9 #include "base/atomicops.h" |
| 10 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
| (...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 323 return blink::WebString::fromUTF8( | 323 return blink::WebString::fromUTF8( |
| 324 reinterpret_cast<const char*>(gl_->GetString(name))); | 324 reinterpret_cast<const char*>(gl_->GetString(name))); |
| 325 } | 325 } |
| 326 | 326 |
| 327 void WebGraphicsContext3DImpl::shaderSource( | 327 void WebGraphicsContext3DImpl::shaderSource( |
| 328 WebGLId shader, const WGC3Dchar* string) { | 328 WebGLId shader, const WGC3Dchar* string) { |
| 329 GLint length = strlen(string); | 329 GLint length = strlen(string); |
| 330 gl_->ShaderSource(shader, 1, &string, &length); | 330 gl_->ShaderSource(shader, 1, &string, &length); |
| 331 } | 331 } |
| 332 | 332 |
| 333 WebGLId WebGraphicsContext3DImpl::createBuffer() { |
| 334 GLuint o; |
| 335 gl_->GenBuffers(1, &o); |
| 336 return o; |
| 337 } |
| 338 |
| 339 WebGLId WebGraphicsContext3DImpl::createFramebuffer() { |
| 340 GLuint o = 0; |
| 341 gl_->GenFramebuffers(1, &o); |
| 342 return o; |
| 343 } |
| 344 |
| 345 WebGLId WebGraphicsContext3DImpl::createRenderbuffer() { |
| 346 GLuint o; |
| 347 gl_->GenRenderbuffers(1, &o); |
| 348 return o; |
| 349 } |
| 350 |
| 351 WebGLId WebGraphicsContext3DImpl::createTexture() { |
| 352 GLuint o; |
| 353 gl_->GenTextures(1, &o); |
| 354 return o; |
| 355 } |
| 356 |
| 357 void WebGraphicsContext3DImpl::deleteBuffer(WebGLId buffer) { |
| 358 gl_->DeleteBuffers(1, &buffer); |
| 359 } |
| 360 |
| 361 void WebGraphicsContext3DImpl::deleteFramebuffer( |
| 362 WebGLId framebuffer) { |
| 363 gl_->DeleteFramebuffers(1, &framebuffer); |
| 364 } |
| 365 |
| 366 void WebGraphicsContext3DImpl::deleteRenderbuffer( |
| 367 WebGLId renderbuffer) { |
| 368 gl_->DeleteRenderbuffers(1, &renderbuffer); |
| 369 } |
| 370 |
| 371 void WebGraphicsContext3DImpl::deleteTexture(WebGLId texture) { |
| 372 gl_->DeleteTextures(1, &texture); |
| 373 } |
| 374 |
| 333 void WebGraphicsContext3DImpl::setErrorMessageCallback( | 375 void WebGraphicsContext3DImpl::setErrorMessageCallback( |
| 334 WebGraphicsContext3D::WebGraphicsErrorMessageCallback* cb) { | 376 WebGraphicsContext3D::WebGraphicsErrorMessageCallback* cb) { |
| 335 error_message_callback_ = cb; | 377 error_message_callback_ = cb; |
| 336 } | 378 } |
| 337 | 379 |
| 338 void WebGraphicsContext3DImpl::setContextLostCallback( | 380 void WebGraphicsContext3DImpl::setContextLostCallback( |
| 339 WebGraphicsContext3D::WebGraphicsContextLostCallback* cb) { | 381 WebGraphicsContext3D::WebGraphicsContextLostCallback* cb) { |
| 340 context_lost_callback_ = cb; | 382 context_lost_callback_ = cb; |
| 341 } | 383 } |
| 342 | 384 |
| 385 WebGLId WebGraphicsContext3DImpl::createQueryEXT() { |
| 386 GLuint o; |
| 387 gl_->GenQueriesEXT(1, &o); |
| 388 return o; |
| 389 } |
| 390 |
| 391 void WebGraphicsContext3DImpl::deleteQueryEXT( |
| 392 WebGLId query) { |
| 393 gl_->DeleteQueriesEXT(1, &query); |
| 394 } |
| 395 |
| 396 WebGLId WebGraphicsContext3DImpl::createValuebufferCHROMIUM() { |
| 397 GLuint o; |
| 398 gl_->GenValuebuffersCHROMIUM(1, &o); |
| 399 return o; |
| 400 } |
| 401 |
| 402 void WebGraphicsContext3DImpl::deleteValuebufferCHROMIUM(WebGLId valuebuffer) { |
| 403 gl_->DeleteValuebuffersCHROMIUM(1, &valuebuffer); |
| 404 } |
| 405 |
| 343 void WebGraphicsContext3DImpl::pushGroupMarkerEXT( | 406 void WebGraphicsContext3DImpl::pushGroupMarkerEXT( |
| 344 const WGC3Dchar* marker) { | 407 const WGC3Dchar* marker) { |
| 345 gl_->PushGroupMarkerEXT(0, marker); | 408 gl_->PushGroupMarkerEXT(0, marker); |
| 346 } | 409 } |
| 347 | 410 |
| 411 WebGLId WebGraphicsContext3DImpl::createVertexArrayOES() { |
| 412 GLuint array; |
| 413 gl_->GenVertexArraysOES(1, &array); |
| 414 return array; |
| 415 } |
| 416 |
| 417 void WebGraphicsContext3DImpl::deleteVertexArrayOES( |
| 418 WebGLId array) { |
| 419 gl_->DeleteVertexArraysOES(1, &array); |
| 420 } |
| 421 |
| 348 DELEGATE_TO_GL_1(beginTransformFeedback, BeginTransformFeedback, WGC3Denum) | 422 DELEGATE_TO_GL_1(beginTransformFeedback, BeginTransformFeedback, WGC3Denum) |
| 349 DELEGATE_TO_GL_3(bindBufferBase, BindBufferBase, WGC3Denum, WGC3Duint, | 423 DELEGATE_TO_GL_3(bindBufferBase, BindBufferBase, WGC3Denum, WGC3Duint, |
| 350 WGC3Duint) | 424 WGC3Duint) |
| 351 DELEGATE_TO_GL_5(bindBufferRange, BindBufferRange, WGC3Denum, WGC3Duint, | 425 DELEGATE_TO_GL_5(bindBufferRange, BindBufferRange, WGC3Denum, WGC3Duint, |
| 352 WGC3Duint, WGC3Dintptr, WGC3Dsizeiptr) | 426 WGC3Duint, WGC3Dintptr, WGC3Dsizeiptr) |
| 353 DELEGATE_TO_GL_2(bindSampler, BindSampler, WGC3Duint, WebGLId) | 427 DELEGATE_TO_GL_2(bindSampler, BindSampler, WGC3Duint, WebGLId) |
| 354 DELEGATE_TO_GL_2(bindTransformFeedback, BindTransformFeedback, WGC3Denum, | 428 DELEGATE_TO_GL_2(bindTransformFeedback, BindTransformFeedback, WGC3Denum, |
| 355 WebGLId) | 429 WebGLId) |
| 356 DELEGATE_TO_GL_4(clearBufferfi, ClearBufferfi, WGC3Denum, WGC3Dint, WGC3Dfloat, | 430 DELEGATE_TO_GL_4(clearBufferfi, ClearBufferfi, WGC3Denum, WGC3Dint, WGC3Dfloat, |
| 357 WGC3Dint) | 431 WGC3Dint) |
| 358 DELEGATE_TO_GL_3(clearBufferfv, ClearBufferfv, WGC3Denum, WGC3Dint, | 432 DELEGATE_TO_GL_3(clearBufferfv, ClearBufferfv, WGC3Denum, WGC3Dint, |
| 359 const WGC3Dfloat *) | 433 const WGC3Dfloat *) |
| 360 DELEGATE_TO_GL_3(clearBufferiv, ClearBufferiv, WGC3Denum, WGC3Dint, | 434 DELEGATE_TO_GL_3(clearBufferiv, ClearBufferiv, WGC3Denum, WGC3Dint, |
| 361 const WGC3Dint *) | 435 const WGC3Dint *) |
| 362 DELEGATE_TO_GL_3(clearBufferuiv, ClearBufferuiv, WGC3Denum, WGC3Dint, | 436 DELEGATE_TO_GL_3(clearBufferuiv, ClearBufferuiv, WGC3Denum, WGC3Dint, |
| 363 const WGC3Duint *) | 437 const WGC3Duint *) |
| 364 DELEGATE_TO_GL_9(compressedTexImage3D, CompressedTexImage3D, WGC3Denum, | 438 DELEGATE_TO_GL_9(compressedTexImage3D, CompressedTexImage3D, WGC3Denum, |
| 365 WGC3Dint, WGC3Denum, WGC3Dsizei, WGC3Dsizei, WGC3Dsizei, | 439 WGC3Dint, WGC3Denum, WGC3Dsizei, WGC3Dsizei, WGC3Dsizei, |
| 366 WGC3Dint, WGC3Dsizei, const void *) | 440 WGC3Dint, WGC3Dsizei, const void *) |
| 367 DELEGATE_TO_GL_11(compressedTexSubImage3D, CompressedTexSubImage3D, WGC3Denum, | 441 DELEGATE_TO_GL_11(compressedTexSubImage3D, CompressedTexSubImage3D, WGC3Denum, |
| 368 WGC3Dint, WGC3Dint, WGC3Dint, WGC3Dint, WGC3Dsizei, | 442 WGC3Dint, WGC3Dint, WGC3Dint, WGC3Dint, WGC3Dsizei, |
| 369 WGC3Dsizei, WGC3Dsizei, WGC3Denum, WGC3Dsizei, const void *) | 443 WGC3Dsizei, WGC3Dsizei, WGC3Denum, WGC3Dsizei, const void *) |
| 370 DELEGATE_TO_GL_5(copyBufferSubData, CopyBufferSubData, WGC3Denum, WGC3Denum, | 444 DELEGATE_TO_GL_5(copyBufferSubData, CopyBufferSubData, WGC3Denum, WGC3Denum, |
| 371 WGC3Dintptr, WGC3Dintptr, WGC3Dsizeiptr) | 445 WGC3Dintptr, WGC3Dintptr, WGC3Dsizeiptr) |
| 372 DELEGATE_TO_GL_9(copyTexSubImage3D, CopyTexSubImage3D, WGC3Denum, WGC3Dint, | 446 DELEGATE_TO_GL_9(copyTexSubImage3D, CopyTexSubImage3D, WGC3Denum, WGC3Dint, |
| 373 WGC3Dint, WGC3Dint, WGC3Dint, WGC3Dint, WGC3Dint, WGC3Dsizei, | 447 WGC3Dint, WGC3Dint, WGC3Dint, WGC3Dint, WGC3Dint, WGC3Dsizei, |
| 374 WGC3Dsizei) | 448 WGC3Dsizei) |
| 449 WebGLId WebGraphicsContext3DImpl::createSampler() { |
| 450 GLuint sampler; |
| 451 gl_->GenSamplers(1, &sampler); |
| 452 return sampler; |
| 453 } |
| 454 WebGLId WebGraphicsContext3DImpl::createTransformFeedback() { |
| 455 GLuint tf; |
| 456 gl_->GenTransformFeedbacks(1, &tf); |
| 457 return tf; |
| 458 } |
| 459 void WebGraphicsContext3DImpl::deleteSampler(WebGLId sampler) { |
| 460 gl_->DeleteSamplers(1, &sampler); |
| 461 } |
| 462 void WebGraphicsContext3DImpl::deleteTransformFeedback(WebGLId tf) { |
| 463 gl_->DeleteTransformFeedbacks(1, &tf); |
| 464 } |
| 375 DELEGATE_TO_GL(endTransformFeedback, EndTransformFeedback) | 465 DELEGATE_TO_GL(endTransformFeedback, EndTransformFeedback) |
| 376 DELEGATE_TO_GL_5(getActiveUniformBlockName, GetActiveUniformBlockName, | 466 DELEGATE_TO_GL_5(getActiveUniformBlockName, GetActiveUniformBlockName, |
| 377 WGC3Duint, WGC3Duint, WGC3Dsizei, WGC3Dsizei *, WGC3Dchar *) | 467 WGC3Duint, WGC3Duint, WGC3Dsizei, WGC3Dsizei *, WGC3Dchar *) |
| 378 DELEGATE_TO_GL_4(getActiveUniformBlockiv, GetActiveUniformBlockiv, WGC3Duint, | 468 DELEGATE_TO_GL_4(getActiveUniformBlockiv, GetActiveUniformBlockiv, WGC3Duint, |
| 379 WGC3Duint, WGC3Denum, WGC3Dint *) | 469 WGC3Duint, WGC3Denum, WGC3Dint *) |
| 380 DELEGATE_TO_GL_5(getActiveUniformsiv, GetActiveUniformsiv, WGC3Duint, | 470 DELEGATE_TO_GL_5(getActiveUniformsiv, GetActiveUniformsiv, WGC3Duint, |
| 381 WGC3Dsizei, const WGC3Duint *, WGC3Denum, WGC3Dint *) | 471 WGC3Dsizei, const WGC3Duint *, WGC3Denum, WGC3Dint *) |
| 382 DELEGATE_TO_GL_2R(getFragDataLocation, GetFragDataLocation, WGC3Duint, | 472 DELEGATE_TO_GL_2R(getFragDataLocation, GetFragDataLocation, WGC3Duint, |
| 383 const WGC3Dchar *, WGC3Dint) | 473 const WGC3Dchar *, WGC3Dint) |
| 384 DELEGATE_TO_GL_5(getInternalformativ, GetInternalformativ, WGC3Denum, WGC3Denum, | 474 DELEGATE_TO_GL_5(getInternalformativ, GetInternalformativ, WGC3Denum, WGC3Denum, |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 481 output_attribs->context_type = ::gpu::gles2::CONTEXT_TYPE_WEBGL2; | 571 output_attribs->context_type = ::gpu::gles2::CONTEXT_TYPE_WEBGL2; |
| 482 break; | 572 break; |
| 483 default: | 573 default: |
| 484 NOTREACHED(); | 574 NOTREACHED(); |
| 485 output_attribs->context_type = ::gpu::gles2::CONTEXT_TYPE_OPENGLES2; | 575 output_attribs->context_type = ::gpu::gles2::CONTEXT_TYPE_OPENGLES2; |
| 486 break; | 576 break; |
| 487 } | 577 } |
| 488 } | 578 } |
| 489 | 579 |
| 490 } // namespace gpu_blink | 580 } // namespace gpu_blink |
| OLD | NEW |