| 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 | |
| 375 void WebGraphicsContext3DImpl::setErrorMessageCallback( | 333 void WebGraphicsContext3DImpl::setErrorMessageCallback( |
| 376 WebGraphicsContext3D::WebGraphicsErrorMessageCallback* cb) { | 334 WebGraphicsContext3D::WebGraphicsErrorMessageCallback* cb) { |
| 377 error_message_callback_ = cb; | 335 error_message_callback_ = cb; |
| 378 } | 336 } |
| 379 | 337 |
| 380 void WebGraphicsContext3DImpl::setContextLostCallback( | 338 void WebGraphicsContext3DImpl::setContextLostCallback( |
| 381 WebGraphicsContext3D::WebGraphicsContextLostCallback* cb) { | 339 WebGraphicsContext3D::WebGraphicsContextLostCallback* cb) { |
| 382 context_lost_callback_ = cb; | 340 context_lost_callback_ = cb; |
| 383 } | 341 } |
| 384 | 342 |
| 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 | |
| 406 void WebGraphicsContext3DImpl::pushGroupMarkerEXT( | 343 void WebGraphicsContext3DImpl::pushGroupMarkerEXT( |
| 407 const WGC3Dchar* marker) { | 344 const WGC3Dchar* marker) { |
| 408 gl_->PushGroupMarkerEXT(0, marker); | 345 gl_->PushGroupMarkerEXT(0, marker); |
| 409 } | 346 } |
| 410 | 347 |
| 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 | |
| 422 DELEGATE_TO_GL_1(beginTransformFeedback, BeginTransformFeedback, WGC3Denum) | 348 DELEGATE_TO_GL_1(beginTransformFeedback, BeginTransformFeedback, WGC3Denum) |
| 423 DELEGATE_TO_GL_3(bindBufferBase, BindBufferBase, WGC3Denum, WGC3Duint, | 349 DELEGATE_TO_GL_3(bindBufferBase, BindBufferBase, WGC3Denum, WGC3Duint, |
| 424 WGC3Duint) | 350 WGC3Duint) |
| 425 DELEGATE_TO_GL_5(bindBufferRange, BindBufferRange, WGC3Denum, WGC3Duint, | 351 DELEGATE_TO_GL_5(bindBufferRange, BindBufferRange, WGC3Denum, WGC3Duint, |
| 426 WGC3Duint, WGC3Dintptr, WGC3Dsizeiptr) | 352 WGC3Duint, WGC3Dintptr, WGC3Dsizeiptr) |
| 427 DELEGATE_TO_GL_2(bindSampler, BindSampler, WGC3Duint, WebGLId) | 353 DELEGATE_TO_GL_2(bindSampler, BindSampler, WGC3Duint, WebGLId) |
| 428 DELEGATE_TO_GL_2(bindTransformFeedback, BindTransformFeedback, WGC3Denum, | 354 DELEGATE_TO_GL_2(bindTransformFeedback, BindTransformFeedback, WGC3Denum, |
| 429 WebGLId) | 355 WebGLId) |
| 430 DELEGATE_TO_GL_4(clearBufferfi, ClearBufferfi, WGC3Denum, WGC3Dint, WGC3Dfloat, | 356 DELEGATE_TO_GL_4(clearBufferfi, ClearBufferfi, WGC3Denum, WGC3Dint, WGC3Dfloat, |
| 431 WGC3Dint) | 357 WGC3Dint) |
| 432 DELEGATE_TO_GL_3(clearBufferfv, ClearBufferfv, WGC3Denum, WGC3Dint, | 358 DELEGATE_TO_GL_3(clearBufferfv, ClearBufferfv, WGC3Denum, WGC3Dint, |
| 433 const WGC3Dfloat *) | 359 const WGC3Dfloat *) |
| 434 DELEGATE_TO_GL_3(clearBufferiv, ClearBufferiv, WGC3Denum, WGC3Dint, | 360 DELEGATE_TO_GL_3(clearBufferiv, ClearBufferiv, WGC3Denum, WGC3Dint, |
| 435 const WGC3Dint *) | 361 const WGC3Dint *) |
| 436 DELEGATE_TO_GL_3(clearBufferuiv, ClearBufferuiv, WGC3Denum, WGC3Dint, | 362 DELEGATE_TO_GL_3(clearBufferuiv, ClearBufferuiv, WGC3Denum, WGC3Dint, |
| 437 const WGC3Duint *) | 363 const WGC3Duint *) |
| 438 DELEGATE_TO_GL_9(compressedTexImage3D, CompressedTexImage3D, WGC3Denum, | 364 DELEGATE_TO_GL_9(compressedTexImage3D, CompressedTexImage3D, WGC3Denum, |
| 439 WGC3Dint, WGC3Denum, WGC3Dsizei, WGC3Dsizei, WGC3Dsizei, | 365 WGC3Dint, WGC3Denum, WGC3Dsizei, WGC3Dsizei, WGC3Dsizei, |
| 440 WGC3Dint, WGC3Dsizei, const void *) | 366 WGC3Dint, WGC3Dsizei, const void *) |
| 441 DELEGATE_TO_GL_11(compressedTexSubImage3D, CompressedTexSubImage3D, WGC3Denum, | 367 DELEGATE_TO_GL_11(compressedTexSubImage3D, CompressedTexSubImage3D, WGC3Denum, |
| 442 WGC3Dint, WGC3Dint, WGC3Dint, WGC3Dint, WGC3Dsizei, | 368 WGC3Dint, WGC3Dint, WGC3Dint, WGC3Dint, WGC3Dsizei, |
| 443 WGC3Dsizei, WGC3Dsizei, WGC3Denum, WGC3Dsizei, const void *) | 369 WGC3Dsizei, WGC3Dsizei, WGC3Denum, WGC3Dsizei, const void *) |
| 444 DELEGATE_TO_GL_5(copyBufferSubData, CopyBufferSubData, WGC3Denum, WGC3Denum, | 370 DELEGATE_TO_GL_5(copyBufferSubData, CopyBufferSubData, WGC3Denum, WGC3Denum, |
| 445 WGC3Dintptr, WGC3Dintptr, WGC3Dsizeiptr) | 371 WGC3Dintptr, WGC3Dintptr, WGC3Dsizeiptr) |
| 446 DELEGATE_TO_GL_9(copyTexSubImage3D, CopyTexSubImage3D, WGC3Denum, WGC3Dint, | 372 DELEGATE_TO_GL_9(copyTexSubImage3D, CopyTexSubImage3D, WGC3Denum, WGC3Dint, |
| 447 WGC3Dint, WGC3Dint, WGC3Dint, WGC3Dint, WGC3Dint, WGC3Dsizei, | 373 WGC3Dint, WGC3Dint, WGC3Dint, WGC3Dint, WGC3Dint, WGC3Dsizei, |
| 448 WGC3Dsizei) | 374 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 } | |
| 465 DELEGATE_TO_GL(endTransformFeedback, EndTransformFeedback) | 375 DELEGATE_TO_GL(endTransformFeedback, EndTransformFeedback) |
| 466 DELEGATE_TO_GL_5(getActiveUniformBlockName, GetActiveUniformBlockName, | 376 DELEGATE_TO_GL_5(getActiveUniformBlockName, GetActiveUniformBlockName, |
| 467 WGC3Duint, WGC3Duint, WGC3Dsizei, WGC3Dsizei *, WGC3Dchar *) | 377 WGC3Duint, WGC3Duint, WGC3Dsizei, WGC3Dsizei *, WGC3Dchar *) |
| 468 DELEGATE_TO_GL_4(getActiveUniformBlockiv, GetActiveUniformBlockiv, WGC3Duint, | 378 DELEGATE_TO_GL_4(getActiveUniformBlockiv, GetActiveUniformBlockiv, WGC3Duint, |
| 469 WGC3Duint, WGC3Denum, WGC3Dint *) | 379 WGC3Duint, WGC3Denum, WGC3Dint *) |
| 470 DELEGATE_TO_GL_5(getActiveUniformsiv, GetActiveUniformsiv, WGC3Duint, | 380 DELEGATE_TO_GL_5(getActiveUniformsiv, GetActiveUniformsiv, WGC3Duint, |
| 471 WGC3Dsizei, const WGC3Duint *, WGC3Denum, WGC3Dint *) | 381 WGC3Dsizei, const WGC3Duint *, WGC3Denum, WGC3Dint *) |
| 472 DELEGATE_TO_GL_2R(getFragDataLocation, GetFragDataLocation, WGC3Duint, | 382 DELEGATE_TO_GL_2R(getFragDataLocation, GetFragDataLocation, WGC3Duint, |
| 473 const WGC3Dchar *, WGC3Dint) | 383 const WGC3Dchar *, WGC3Dint) |
| 474 DELEGATE_TO_GL_5(getInternalformativ, GetInternalformativ, WGC3Denum, WGC3Denum, | 384 DELEGATE_TO_GL_5(getInternalformativ, GetInternalformativ, WGC3Denum, WGC3Denum, |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 571 output_attribs->context_type = ::gpu::gles2::CONTEXT_TYPE_WEBGL2; | 481 output_attribs->context_type = ::gpu::gles2::CONTEXT_TYPE_WEBGL2; |
| 572 break; | 482 break; |
| 573 default: | 483 default: |
| 574 NOTREACHED(); | 484 NOTREACHED(); |
| 575 output_attribs->context_type = ::gpu::gles2::CONTEXT_TYPE_OPENGLES2; | 485 output_attribs->context_type = ::gpu::gles2::CONTEXT_TYPE_OPENGLES2; |
| 576 break; | 486 break; |
| 577 } | 487 } |
| 578 } | 488 } |
| 579 | 489 |
| 580 } // namespace gpu_blink | 490 } // namespace gpu_blink |
| OLD | NEW |