| 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 // A class to emulate GLES2 over command buffers. | 5 // A class to emulate GLES2 over command buffers. |
| 6 | 6 |
| 7 #include "gpu/command_buffer/client/gles2_implementation.h" | 7 #include "gpu/command_buffer/client/gles2_implementation.h" |
| 8 | 8 |
| 9 #include <GLES2/gl2ext.h> | 9 #include <GLES2/gl2ext.h> |
| 10 #include <GLES2/gl2extchromium.h> | 10 #include <GLES2/gl2extchromium.h> |
| (...skipping 2346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2357 | 2357 |
| 2358 void GLES2Implementation::GenVertexArraysOESHelper( | 2358 void GLES2Implementation::GenVertexArraysOESHelper( |
| 2359 GLsizei n, const GLuint* arrays) { | 2359 GLsizei n, const GLuint* arrays) { |
| 2360 vertex_array_object_manager_->GenVertexArrays(n, arrays); | 2360 vertex_array_object_manager_->GenVertexArrays(n, arrays); |
| 2361 } | 2361 } |
| 2362 | 2362 |
| 2363 void GLES2Implementation::GenQueriesEXTHelper( | 2363 void GLES2Implementation::GenQueriesEXTHelper( |
| 2364 GLsizei /* n */, const GLuint* /* queries */) { | 2364 GLsizei /* n */, const GLuint* /* queries */) { |
| 2365 } | 2365 } |
| 2366 | 2366 |
| 2367 void GLES2Implementation::GenValuebuffersCHROMIUMHelper( | |
| 2368 GLsizei /* n */, | |
| 2369 const GLuint* /* valuebuffers */) { | |
| 2370 } | |
| 2371 | |
| 2372 // NOTE #1: On old versions of OpenGL, calling glBindXXX with an unused id | 2367 // NOTE #1: On old versions of OpenGL, calling glBindXXX with an unused id |
| 2373 // generates a new resource. On newer versions of OpenGL they don't. The code | 2368 // generates a new resource. On newer versions of OpenGL they don't. The code |
| 2374 // related to binding below will need to change if we switch to the new OpenGL | 2369 // related to binding below will need to change if we switch to the new OpenGL |
| 2375 // model. Specifically it assumes a bind will succeed which is always true in | 2370 // model. Specifically it assumes a bind will succeed which is always true in |
| 2376 // the old model but possibly not true in the new model if another context has | 2371 // the old model but possibly not true in the new model if another context has |
| 2377 // deleted the resource. | 2372 // deleted the resource. |
| 2378 | 2373 |
| 2379 bool GLES2Implementation::BindBufferHelper( | 2374 bool GLES2Implementation::BindBufferHelper( |
| 2380 GLenum target, GLuint buffer_id) { | 2375 GLenum target, GLuint buffer_id) { |
| 2381 // TODO(gman): See note #1 above. | 2376 // TODO(gman): See note #1 above. |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2511 GL_INVALID_OPERATION, "glBindVertexArrayOES", | 2506 GL_INVALID_OPERATION, "glBindVertexArrayOES", |
| 2512 "id was not generated with glGenVertexArrayOES"); | 2507 "id was not generated with glGenVertexArrayOES"); |
| 2513 } | 2508 } |
| 2514 // Unlike other BindXXXHelpers we don't call MarkAsUsedForBind | 2509 // Unlike other BindXXXHelpers we don't call MarkAsUsedForBind |
| 2515 // because unlike other resources VertexArrayObject ids must | 2510 // because unlike other resources VertexArrayObject ids must |
| 2516 // be generated by GenVertexArrays. A random id to Bind will not | 2511 // be generated by GenVertexArrays. A random id to Bind will not |
| 2517 // generate a new object. | 2512 // generate a new object. |
| 2518 return changed; | 2513 return changed; |
| 2519 } | 2514 } |
| 2520 | 2515 |
| 2521 bool GLES2Implementation::BindValuebufferCHROMIUMHelper(GLenum target, | |
| 2522 GLuint valuebuffer) { | |
| 2523 bool changed = false; | |
| 2524 switch (target) { | |
| 2525 case GL_SUBSCRIBED_VALUES_BUFFER_CHROMIUM: | |
| 2526 if (bound_valuebuffer_ != valuebuffer) { | |
| 2527 bound_valuebuffer_ = valuebuffer; | |
| 2528 changed = true; | |
| 2529 } | |
| 2530 break; | |
| 2531 default: | |
| 2532 changed = true; | |
| 2533 break; | |
| 2534 } | |
| 2535 // TODO(gman): There's a bug here. If the target is invalid the ID will not be | |
| 2536 // used even though it's marked it as used here. | |
| 2537 GetIdHandler(id_namespaces::kValuebuffers)->MarkAsUsedForBind(valuebuffer); | |
| 2538 return changed; | |
| 2539 } | |
| 2540 | |
| 2541 bool GLES2Implementation::UseProgramHelper(GLuint program) { | 2516 bool GLES2Implementation::UseProgramHelper(GLuint program) { |
| 2542 bool changed = false; | 2517 bool changed = false; |
| 2543 if (current_program_ != program) { | 2518 if (current_program_ != program) { |
| 2544 current_program_ = program; | 2519 current_program_ = program; |
| 2545 changed = true; | 2520 changed = true; |
| 2546 } | 2521 } |
| 2547 return changed; | 2522 return changed; |
| 2548 } | 2523 } |
| 2549 | 2524 |
| 2550 bool GLES2Implementation::IsBufferReservedId(GLuint id) { | 2525 bool GLES2Implementation::IsBufferReservedId(GLuint id) { |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2647 if (textures[ii] == unit.bound_texture_cube_map) { | 2622 if (textures[ii] == unit.bound_texture_cube_map) { |
| 2648 unit.bound_texture_cube_map = 0; | 2623 unit.bound_texture_cube_map = 0; |
| 2649 } | 2624 } |
| 2650 if (textures[ii] == unit.bound_texture_external_oes) { | 2625 if (textures[ii] == unit.bound_texture_external_oes) { |
| 2651 unit.bound_texture_external_oes = 0; | 2626 unit.bound_texture_external_oes = 0; |
| 2652 } | 2627 } |
| 2653 } | 2628 } |
| 2654 } | 2629 } |
| 2655 } | 2630 } |
| 2656 | 2631 |
| 2657 void GLES2Implementation::DeleteTexturesStub(GLsizei n, | |
| 2658 const GLuint* textures) { | |
| 2659 helper_->DeleteTexturesImmediate(n, textures); | |
| 2660 } | |
| 2661 | |
| 2662 void GLES2Implementation::DeleteVertexArraysOESHelper( | 2632 void GLES2Implementation::DeleteVertexArraysOESHelper( |
| 2663 GLsizei n, const GLuint* arrays) { | 2633 GLsizei n, const GLuint* arrays) { |
| 2664 vertex_array_object_manager_->DeleteVertexArrays(n, arrays); | 2634 vertex_array_object_manager_->DeleteVertexArrays(n, arrays); |
| 2665 if (!GetIdHandler(id_namespaces::kVertexArrays)->FreeIds( | 2635 if (!GetIdHandler(id_namespaces::kVertexArrays)->FreeIds( |
| 2666 this, n, arrays, &GLES2Implementation::DeleteVertexArraysOESStub)) { | 2636 this, n, arrays, &GLES2Implementation::DeleteVertexArraysOESStub)) { |
| 2667 SetGLError( | 2637 SetGLError( |
| 2668 GL_INVALID_VALUE, | 2638 GL_INVALID_VALUE, |
| 2669 "glDeleteVertexArraysOES", "id not created by this context."); | 2639 "glDeleteVertexArraysOES", "id not created by this context."); |
| 2670 return; | 2640 return; |
| 2671 } | 2641 } |
| 2672 } | 2642 } |
| 2673 | 2643 |
| 2674 void GLES2Implementation::DeleteVertexArraysOESStub( | 2644 void GLES2Implementation::DeleteVertexArraysOESStub( |
| 2675 GLsizei n, const GLuint* arrays) { | 2645 GLsizei n, const GLuint* arrays) { |
| 2676 helper_->DeleteVertexArraysOESImmediate(n, arrays); | 2646 helper_->DeleteVertexArraysOESImmediate(n, arrays); |
| 2677 } | 2647 } |
| 2678 | 2648 |
| 2679 void GLES2Implementation::DeleteValuebuffersCHROMIUMHelper( | 2649 void GLES2Implementation::DeleteTexturesStub( |
| 2680 GLsizei n, | 2650 GLsizei n, const GLuint* textures) { |
| 2681 const GLuint* valuebuffers) { | 2651 helper_->DeleteTexturesImmediate(n, textures); |
| 2682 if (!GetIdHandler(id_namespaces::kValuebuffers) | |
| 2683 ->FreeIds(this, n, valuebuffers, | |
| 2684 &GLES2Implementation::DeleteValuebuffersCHROMIUMStub)) { | |
| 2685 SetGLError(GL_INVALID_VALUE, "glDeleteValuebuffersCHROMIUM", | |
| 2686 "id not created by this context."); | |
| 2687 return; | |
| 2688 } | |
| 2689 for (GLsizei ii = 0; ii < n; ++ii) { | |
| 2690 if (valuebuffers[ii] == bound_valuebuffer_) { | |
| 2691 bound_valuebuffer_ = 0; | |
| 2692 } | |
| 2693 } | |
| 2694 } | |
| 2695 | |
| 2696 void GLES2Implementation::DeleteValuebuffersCHROMIUMStub( | |
| 2697 GLsizei n, | |
| 2698 const GLuint* valuebuffers) { | |
| 2699 helper_->DeleteValuebuffersCHROMIUMImmediate(n, valuebuffers); | |
| 2700 } | 2652 } |
| 2701 | 2653 |
| 2702 void GLES2Implementation::DisableVertexAttribArray(GLuint index) { | 2654 void GLES2Implementation::DisableVertexAttribArray(GLuint index) { |
| 2703 GPU_CLIENT_SINGLE_THREAD_CHECK(); | 2655 GPU_CLIENT_SINGLE_THREAD_CHECK(); |
| 2704 GPU_CLIENT_LOG( | 2656 GPU_CLIENT_LOG( |
| 2705 "[" << GetLogPrefix() << "] glDisableVertexAttribArray(" << index << ")"); | 2657 "[" << GetLogPrefix() << "] glDisableVertexAttribArray(" << index << ")"); |
| 2706 vertex_array_object_manager_->SetAttribEnable(index, false); | 2658 vertex_array_object_manager_->SetAttribEnable(index, false); |
| 2707 helper_->DisableVertexAttribArray(index); | 2659 helper_->DisableVertexAttribArray(index); |
| 2708 CheckGLError(); | 2660 CheckGLError(); |
| 2709 } | 2661 } |
| (...skipping 1406 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4116 return true; | 4068 return true; |
| 4117 } | 4069 } |
| 4118 | 4070 |
| 4119 // Include the auto-generated part of this file. We split this because it means | 4071 // Include the auto-generated part of this file. We split this because it means |
| 4120 // we can easily edit the non-auto generated parts right here in this file | 4072 // we can easily edit the non-auto generated parts right here in this file |
| 4121 // instead of having to edit some template or the code generator. | 4073 // instead of having to edit some template or the code generator. |
| 4122 #include "gpu/command_buffer/client/gles2_implementation_impl_autogen.h" | 4074 #include "gpu/command_buffer/client/gles2_implementation_impl_autogen.h" |
| 4123 | 4075 |
| 4124 } // namespace gles2 | 4076 } // namespace gles2 |
| 4125 } // namespace gpu | 4077 } // namespace gpu |
| OLD | NEW |