| 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/command_buffer/service/context_state.h" | 5 #include "gpu/command_buffer/service/context_state.h" |
| 6 | 6 |
| 7 #include "gpu/command_buffer/common/gles2_cmd_utils.h" | 7 #include "gpu/command_buffer/common/gles2_cmd_utils.h" |
| 8 #include "ui/gl/gl_bindings.h" | 8 #include "ui/gl/gl_bindings.h" |
| 9 #include "ui/gl/gl_implementation.h" | 9 #include "ui/gl/gl_implementation.h" |
| 10 | 10 |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 glBindTexture(GL_TEXTURE_CUBE_MAP, service_id); | 66 glBindTexture(GL_TEXTURE_CUBE_MAP, service_id); |
| 67 // TODO: Restore bindings for GL_TEXTURE_RECTANGLE_ARB and | 67 // TODO: Restore bindings for GL_TEXTURE_RECTANGLE_ARB and |
| 68 // GL_TEXTURE_EXTERNAL_OES. | 68 // GL_TEXTURE_EXTERNAL_OES. |
| 69 } | 69 } |
| 70 glActiveTexture(GL_TEXTURE0 + active_texture_unit); | 70 glActiveTexture(GL_TEXTURE0 + active_texture_unit); |
| 71 | 71 |
| 72 // Restore Attrib State | 72 // Restore Attrib State |
| 73 // TODO: This if should not be needed. RestoreState is getting called | 73 // TODO: This if should not be needed. RestoreState is getting called |
| 74 // before GLES2Decoder::Initialize which is a bug. | 74 // before GLES2Decoder::Initialize which is a bug. |
| 75 if (vertex_attrib_manager) { | 75 if (vertex_attrib_manager) { |
| 76 // TODO(gman): Move this restoration to VertexAttribManager. |
| 76 for (size_t attrib = 0; attrib < vertex_attrib_manager->num_attribs(); | 77 for (size_t attrib = 0; attrib < vertex_attrib_manager->num_attribs(); |
| 77 ++attrib) { | 78 ++attrib) { |
| 78 const VertexAttribManager::VertexAttribInfo* info = | 79 const VertexAttribManager::VertexAttribInfo* info = |
| 79 vertex_attrib_manager->GetVertexAttribInfo(attrib); | 80 vertex_attrib_manager->GetVertexAttribInfo(attrib); |
| 80 const void* ptr = reinterpret_cast<const void*>(info->offset()); | 81 const void* ptr = reinterpret_cast<const void*>(info->offset()); |
| 81 BufferManager::BufferInfo* buffer_info = info->buffer(); | 82 BufferManager::BufferInfo* buffer_info = info->buffer(); |
| 82 glBindBuffer( | 83 glBindBuffer( |
| 83 GL_ARRAY_BUFFER, buffer_info ? buffer_info->service_id() : 0); | 84 GL_ARRAY_BUFFER, buffer_info ? buffer_info->service_id() : 0); |
| 84 glVertexAttribPointer( | 85 glVertexAttribPointer( |
| 85 attrib, info->size(), info->type(), info->normalized(), | 86 attrib, info->size(), info->type(), info->normalized(), |
| 86 info->gl_stride(), ptr); | 87 info->gl_stride(), ptr); |
| 87 if (info->divisor()) | 88 if (info->divisor()) |
| 88 glVertexAttribDivisorANGLE(attrib, info->divisor()); | 89 glVertexAttribDivisorANGLE(attrib, info->divisor()); |
| 89 // Never touch vertex attribute 0's state (in particular, never | 90 // Never touch vertex attribute 0's state (in particular, never |
| 90 // disable it) when running on desktop GL because it will never be | 91 // disable it) when running on desktop GL because it will never be |
| 91 // re-enabled. | 92 // re-enabled. |
| 92 if (attrib != 0 || | 93 if (attrib != 0 || |
| 93 gfx::GetGLImplementation() == gfx::kGLImplementationEGLGLES2) { | 94 gfx::GetGLImplementation() == gfx::kGLImplementationEGLGLES2) { |
| 94 if (info->enabled()) { | 95 if (info->enabled()) { |
| 95 glEnableVertexAttribArray(attrib); | 96 glEnableVertexAttribArray(attrib); |
| 96 } else { | 97 } else { |
| 97 glDisableVertexAttribArray(attrib); | 98 glDisableVertexAttribArray(attrib); |
| 98 } | 99 } |
| 99 } | 100 } |
| 101 glVertexAttrib4fv(attrib, attrib_values[attrib].v); |
| 100 } | 102 } |
| 101 BufferManager::BufferInfo* element_array_buffer = | 103 BufferManager::BufferInfo* element_array_buffer = |
| 102 vertex_attrib_manager->element_array_buffer(); | 104 vertex_attrib_manager->element_array_buffer(); |
| 103 glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, | 105 glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, |
| 104 element_array_buffer ? element_array_buffer->service_id() : 0); | 106 element_array_buffer ? element_array_buffer->service_id() : 0); |
| 105 } | 107 } |
| 106 | 108 |
| 107 // Restore Bindings | 109 // Restore Bindings |
| 108 glBindBuffer( | 110 glBindBuffer( |
| 109 GL_ARRAY_BUFFER, | 111 GL_ARRAY_BUFFER, |
| 110 bound_array_buffer ? bound_array_buffer->service_id() : 0); | 112 bound_array_buffer ? bound_array_buffer->service_id() : 0); |
| 111 glBindRenderbufferEXT( | 113 glBindRenderbufferEXT( |
| 112 GL_RENDERBUFFER, | 114 GL_RENDERBUFFER, |
| 113 bound_renderbuffer ? bound_renderbuffer->service_id() : 0); | 115 bound_renderbuffer ? bound_renderbuffer->service_id() : 0); |
| 114 | 116 |
| 115 glUseProgram(current_program ? current_program->service_id() : 0); | 117 glUseProgram(current_program ? current_program->service_id() : 0); |
| 116 } | 118 } |
| 117 | 119 |
| 118 // Include the auto-generated part of this file. We split this because it means | 120 // Include the auto-generated part of this file. We split this because it means |
| 119 // we can easily edit the non-auto generated parts right here in this file | 121 // we can easily edit the non-auto generated parts right here in this file |
| 120 // instead of having to edit some template or the code generator. | 122 // instead of having to edit some template or the code generator. |
| 121 #include "gpu/command_buffer/service/context_state_impl_autogen.h" | 123 #include "gpu/command_buffer/service/context_state_impl_autogen.h" |
| 122 | 124 |
| 123 } // namespace gles2 | 125 } // namespace gles2 |
| 124 } // namespace gpu | 126 } // namespace gpu |
| 125 | 127 |
| 126 | 128 |
| OLD | NEW |