| 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 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 355 return blink::WebString::fromUTF8( | 355 return blink::WebString::fromUTF8( |
| 356 reinterpret_cast<const char*>(gl_->GetString(name))); | 356 reinterpret_cast<const char*>(gl_->GetString(name))); |
| 357 } | 357 } |
| 358 | 358 |
| 359 void WebGraphicsContext3DImpl::shaderSource( | 359 void WebGraphicsContext3DImpl::shaderSource( |
| 360 WebGLId shader, const WGC3Dchar* string) { | 360 WebGLId shader, const WGC3Dchar* string) { |
| 361 GLint length = strlen(string); | 361 GLint length = strlen(string); |
| 362 gl_->ShaderSource(shader, 1, &string, &length); | 362 gl_->ShaderSource(shader, 1, &string, &length); |
| 363 } | 363 } |
| 364 | 364 |
| 365 WebGLId WebGraphicsContext3DImpl::createBuffer() { | |
| 366 GLuint o; | |
| 367 gl_->GenBuffers(1, &o); | |
| 368 return o; | |
| 369 } | |
| 370 | |
| 371 WebGLId WebGraphicsContext3DImpl::createFramebuffer() { | |
| 372 GLuint o = 0; | |
| 373 gl_->GenFramebuffers(1, &o); | |
| 374 return o; | |
| 375 } | |
| 376 | |
| 377 WebGLId WebGraphicsContext3DImpl::createRenderbuffer() { | |
| 378 GLuint o; | |
| 379 gl_->GenRenderbuffers(1, &o); | |
| 380 return o; | |
| 381 } | |
| 382 | |
| 383 WebGLId WebGraphicsContext3DImpl::createTexture() { | |
| 384 GLuint o; | |
| 385 gl_->GenTextures(1, &o); | |
| 386 return o; | |
| 387 } | |
| 388 | |
| 389 void WebGraphicsContext3DImpl::deleteBuffer(WebGLId buffer) { | |
| 390 gl_->DeleteBuffers(1, &buffer); | |
| 391 } | |
| 392 | |
| 393 void WebGraphicsContext3DImpl::deleteFramebuffer( | |
| 394 WebGLId framebuffer) { | |
| 395 gl_->DeleteFramebuffers(1, &framebuffer); | |
| 396 } | |
| 397 | |
| 398 void WebGraphicsContext3DImpl::deleteRenderbuffer( | |
| 399 WebGLId renderbuffer) { | |
| 400 gl_->DeleteRenderbuffers(1, &renderbuffer); | |
| 401 } | |
| 402 | |
| 403 void WebGraphicsContext3DImpl::deleteTexture(WebGLId texture) { | |
| 404 gl_->DeleteTextures(1, &texture); | |
| 405 } | |
| 406 | |
| 407 void WebGraphicsContext3DImpl::setErrorMessageCallback( | 365 void WebGraphicsContext3DImpl::setErrorMessageCallback( |
| 408 WebGraphicsContext3D::WebGraphicsErrorMessageCallback* cb) { | 366 WebGraphicsContext3D::WebGraphicsErrorMessageCallback* cb) { |
| 409 error_message_callback_ = cb; | 367 error_message_callback_ = cb; |
| 410 } | 368 } |
| 411 | 369 |
| 412 void WebGraphicsContext3DImpl::setContextLostCallback( | 370 void WebGraphicsContext3DImpl::setContextLostCallback( |
| 413 WebGraphicsContext3D::WebGraphicsContextLostCallback* cb) { | 371 WebGraphicsContext3D::WebGraphicsContextLostCallback* cb) { |
| 414 context_lost_callback_ = cb; | 372 context_lost_callback_ = cb; |
| 415 } | 373 } |
| 416 | 374 |
| 417 WebGLId WebGraphicsContext3DImpl::createQueryEXT() { | |
| 418 GLuint o; | |
| 419 gl_->GenQueriesEXT(1, &o); | |
| 420 return o; | |
| 421 } | |
| 422 | |
| 423 void WebGraphicsContext3DImpl::deleteQueryEXT( | |
| 424 WebGLId query) { | |
| 425 gl_->DeleteQueriesEXT(1, &query); | |
| 426 } | |
| 427 | |
| 428 WebGLId WebGraphicsContext3DImpl::createValuebufferCHROMIUM() { | |
| 429 GLuint o; | |
| 430 gl_->GenValuebuffersCHROMIUM(1, &o); | |
| 431 return o; | |
| 432 } | |
| 433 | |
| 434 void WebGraphicsContext3DImpl::deleteValuebufferCHROMIUM(WebGLId valuebuffer) { | |
| 435 gl_->DeleteValuebuffersCHROMIUM(1, &valuebuffer); | |
| 436 } | |
| 437 | |
| 438 void WebGraphicsContext3DImpl::pushGroupMarkerEXT( | 375 void WebGraphicsContext3DImpl::pushGroupMarkerEXT( |
| 439 const WGC3Dchar* marker) { | 376 const WGC3Dchar* marker) { |
| 440 gl_->PushGroupMarkerEXT(0, marker); | 377 gl_->PushGroupMarkerEXT(0, marker); |
| 441 } | 378 } |
| 442 | 379 |
| 443 WebGLId WebGraphicsContext3DImpl::createVertexArrayOES() { | |
| 444 GLuint array; | |
| 445 gl_->GenVertexArraysOES(1, &array); | |
| 446 return array; | |
| 447 } | |
| 448 | |
| 449 void WebGraphicsContext3DImpl::deleteVertexArrayOES( | |
| 450 WebGLId array) { | |
| 451 gl_->DeleteVertexArraysOES(1, &array); | |
| 452 } | |
| 453 | |
| 454 DELEGATE_TO_GL_1(beginTransformFeedback, BeginTransformFeedback, WGC3Denum) | 380 DELEGATE_TO_GL_1(beginTransformFeedback, BeginTransformFeedback, WGC3Denum) |
| 455 DELEGATE_TO_GL_3(bindBufferBase, BindBufferBase, WGC3Denum, WGC3Duint, | 381 DELEGATE_TO_GL_3(bindBufferBase, BindBufferBase, WGC3Denum, WGC3Duint, |
| 456 WGC3Duint) | 382 WGC3Duint) |
| 457 DELEGATE_TO_GL_5(bindBufferRange, BindBufferRange, WGC3Denum, WGC3Duint, | 383 DELEGATE_TO_GL_5(bindBufferRange, BindBufferRange, WGC3Denum, WGC3Duint, |
| 458 WGC3Duint, WGC3Dintptr, WGC3Dsizeiptr) | 384 WGC3Duint, WGC3Dintptr, WGC3Dsizeiptr) |
| 459 DELEGATE_TO_GL_2(bindSampler, BindSampler, WGC3Duint, WebGLId) | 385 DELEGATE_TO_GL_2(bindSampler, BindSampler, WGC3Duint, WebGLId) |
| 460 DELEGATE_TO_GL_2(bindTransformFeedback, BindTransformFeedback, WGC3Denum, | 386 DELEGATE_TO_GL_2(bindTransformFeedback, BindTransformFeedback, WGC3Denum, |
| 461 WebGLId) | 387 WebGLId) |
| 462 DELEGATE_TO_GL_4(clearBufferfi, ClearBufferfi, WGC3Denum, WGC3Dint, WGC3Dfloat, | 388 DELEGATE_TO_GL_4(clearBufferfi, ClearBufferfi, WGC3Denum, WGC3Dint, WGC3Dfloat, |
| 463 WGC3Dint) | 389 WGC3Dint) |
| 464 DELEGATE_TO_GL_3(clearBufferfv, ClearBufferfv, WGC3Denum, WGC3Dint, | 390 DELEGATE_TO_GL_3(clearBufferfv, ClearBufferfv, WGC3Denum, WGC3Dint, |
| 465 const WGC3Dfloat *) | 391 const WGC3Dfloat *) |
| 466 DELEGATE_TO_GL_3(clearBufferiv, ClearBufferiv, WGC3Denum, WGC3Dint, | 392 DELEGATE_TO_GL_3(clearBufferiv, ClearBufferiv, WGC3Denum, WGC3Dint, |
| 467 const WGC3Dint *) | 393 const WGC3Dint *) |
| 468 DELEGATE_TO_GL_3(clearBufferuiv, ClearBufferuiv, WGC3Denum, WGC3Dint, | 394 DELEGATE_TO_GL_3(clearBufferuiv, ClearBufferuiv, WGC3Denum, WGC3Dint, |
| 469 const WGC3Duint *) | 395 const WGC3Duint *) |
| 470 DELEGATE_TO_GL_9(compressedTexImage3D, CompressedTexImage3D, WGC3Denum, | 396 DELEGATE_TO_GL_9(compressedTexImage3D, CompressedTexImage3D, WGC3Denum, |
| 471 WGC3Dint, WGC3Denum, WGC3Dsizei, WGC3Dsizei, WGC3Dsizei, | 397 WGC3Dint, WGC3Denum, WGC3Dsizei, WGC3Dsizei, WGC3Dsizei, |
| 472 WGC3Dint, WGC3Dsizei, const void *) | 398 WGC3Dint, WGC3Dsizei, const void *) |
| 473 DELEGATE_TO_GL_11(compressedTexSubImage3D, CompressedTexSubImage3D, WGC3Denum, | 399 DELEGATE_TO_GL_11(compressedTexSubImage3D, CompressedTexSubImage3D, WGC3Denum, |
| 474 WGC3Dint, WGC3Dint, WGC3Dint, WGC3Dint, WGC3Dsizei, | 400 WGC3Dint, WGC3Dint, WGC3Dint, WGC3Dint, WGC3Dsizei, |
| 475 WGC3Dsizei, WGC3Dsizei, WGC3Denum, WGC3Dsizei, const void *) | 401 WGC3Dsizei, WGC3Dsizei, WGC3Denum, WGC3Dsizei, const void *) |
| 476 DELEGATE_TO_GL_5(copyBufferSubData, CopyBufferSubData, WGC3Denum, WGC3Denum, | 402 DELEGATE_TO_GL_5(copyBufferSubData, CopyBufferSubData, WGC3Denum, WGC3Denum, |
| 477 WGC3Dintptr, WGC3Dintptr, WGC3Dsizeiptr) | 403 WGC3Dintptr, WGC3Dintptr, WGC3Dsizeiptr) |
| 478 DELEGATE_TO_GL_9(copyTexSubImage3D, CopyTexSubImage3D, WGC3Denum, WGC3Dint, | 404 DELEGATE_TO_GL_9(copyTexSubImage3D, CopyTexSubImage3D, WGC3Denum, WGC3Dint, |
| 479 WGC3Dint, WGC3Dint, WGC3Dint, WGC3Dint, WGC3Dint, WGC3Dsizei, | 405 WGC3Dint, WGC3Dint, WGC3Dint, WGC3Dint, WGC3Dint, WGC3Dsizei, |
| 480 WGC3Dsizei) | 406 WGC3Dsizei) |
| 481 WebGLId WebGraphicsContext3DImpl::createSampler() { | |
| 482 GLuint sampler; | |
| 483 gl_->GenSamplers(1, &sampler); | |
| 484 return sampler; | |
| 485 } | |
| 486 WebGLId WebGraphicsContext3DImpl::createTransformFeedback() { | |
| 487 GLuint tf; | |
| 488 gl_->GenTransformFeedbacks(1, &tf); | |
| 489 return tf; | |
| 490 } | |
| 491 void WebGraphicsContext3DImpl::deleteSampler(WebGLId sampler) { | |
| 492 gl_->DeleteSamplers(1, &sampler); | |
| 493 } | |
| 494 void WebGraphicsContext3DImpl::deleteTransformFeedback(WebGLId tf) { | |
| 495 gl_->DeleteTransformFeedbacks(1, &tf); | |
| 496 } | |
| 497 DELEGATE_TO_GL(endTransformFeedback, EndTransformFeedback) | 407 DELEGATE_TO_GL(endTransformFeedback, EndTransformFeedback) |
| 498 DELEGATE_TO_GL_5(getActiveUniformBlockName, GetActiveUniformBlockName, | 408 DELEGATE_TO_GL_5(getActiveUniformBlockName, GetActiveUniformBlockName, |
| 499 WGC3Duint, WGC3Duint, WGC3Dsizei, WGC3Dsizei *, WGC3Dchar *) | 409 WGC3Duint, WGC3Duint, WGC3Dsizei, WGC3Dsizei *, WGC3Dchar *) |
| 500 DELEGATE_TO_GL_4(getActiveUniformBlockiv, GetActiveUniformBlockiv, WGC3Duint, | 410 DELEGATE_TO_GL_4(getActiveUniformBlockiv, GetActiveUniformBlockiv, WGC3Duint, |
| 501 WGC3Duint, WGC3Denum, WGC3Dint *) | 411 WGC3Duint, WGC3Denum, WGC3Dint *) |
| 502 DELEGATE_TO_GL_5(getActiveUniformsiv, GetActiveUniformsiv, WGC3Duint, | 412 DELEGATE_TO_GL_5(getActiveUniformsiv, GetActiveUniformsiv, WGC3Duint, |
| 503 WGC3Dsizei, const WGC3Duint *, WGC3Denum, WGC3Dint *) | 413 WGC3Dsizei, const WGC3Duint *, WGC3Denum, WGC3Dint *) |
| 504 DELEGATE_TO_GL_2R(getFragDataLocation, GetFragDataLocation, WGC3Duint, | 414 DELEGATE_TO_GL_2R(getFragDataLocation, GetFragDataLocation, WGC3Duint, |
| 505 const WGC3Dchar *, WGC3Dint) | 415 const WGC3Dchar *, WGC3Dint) |
| 506 DELEGATE_TO_GL_5(getInternalformativ, GetInternalformativ, WGC3Denum, WGC3Denum, | 416 DELEGATE_TO_GL_5(getInternalformativ, GetInternalformativ, WGC3Denum, WGC3Denum, |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 603 output_attribs->context_type = ::gpu::gles2::CONTEXT_TYPE_WEBGL2; | 513 output_attribs->context_type = ::gpu::gles2::CONTEXT_TYPE_WEBGL2; |
| 604 break; | 514 break; |
| 605 default: | 515 default: |
| 606 NOTREACHED(); | 516 NOTREACHED(); |
| 607 output_attribs->context_type = ::gpu::gles2::CONTEXT_TYPE_OPENGLES2; | 517 output_attribs->context_type = ::gpu::gles2::CONTEXT_TYPE_OPENGLES2; |
| 608 break; | 518 break; |
| 609 } | 519 } |
| 610 } | 520 } |
| 611 | 521 |
| 612 } // namespace gpu_blink | 522 } // namespace gpu_blink |
| OLD | NEW |