| 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/gl2.h> | 9 #include <GLES2/gl2.h> |
| 10 #include <GLES2/gl2ext.h> | 10 #include <GLES2/gl2ext.h> |
| (...skipping 4608 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4619 void GLES2Implementation::DeleteTexturesHelper( | 4619 void GLES2Implementation::DeleteTexturesHelper( |
| 4620 GLsizei n, const GLuint* textures) { | 4620 GLsizei n, const GLuint* textures) { |
| 4621 if (!GetIdHandler(id_namespaces::kTextures)->FreeIds( | 4621 if (!GetIdHandler(id_namespaces::kTextures)->FreeIds( |
| 4622 this, n, textures, &GLES2Implementation::DeleteTexturesStub)) { | 4622 this, n, textures, &GLES2Implementation::DeleteTexturesStub)) { |
| 4623 SetGLError( | 4623 SetGLError( |
| 4624 GL_INVALID_VALUE, | 4624 GL_INVALID_VALUE, |
| 4625 "glDeleteTextures", "id not created by this context."); | 4625 "glDeleteTextures", "id not created by this context."); |
| 4626 return; | 4626 return; |
| 4627 } | 4627 } |
| 4628 for (GLsizei ii = 0; ii < n; ++ii) { | 4628 for (GLsizei ii = 0; ii < n; ++ii) { |
| 4629 share_group_->discardable_manager()->FreeTexture(textures[ii]); |
| 4630 |
| 4629 for (GLint tt = 0; tt < capabilities_.max_combined_texture_image_units; | 4631 for (GLint tt = 0; tt < capabilities_.max_combined_texture_image_units; |
| 4630 ++tt) { | 4632 ++tt) { |
| 4631 TextureUnit& unit = texture_units_[tt]; | 4633 TextureUnit& unit = texture_units_[tt]; |
| 4632 if (textures[ii] == unit.bound_texture_2d) { | 4634 if (textures[ii] == unit.bound_texture_2d) { |
| 4633 unit.bound_texture_2d = 0; | 4635 unit.bound_texture_2d = 0; |
| 4634 } | 4636 } |
| 4635 if (textures[ii] == unit.bound_texture_cube_map) { | 4637 if (textures[ii] == unit.bound_texture_cube_map) { |
| 4636 unit.bound_texture_cube_map = 0; | 4638 unit.bound_texture_cube_map = 0; |
| 4637 } | 4639 } |
| 4638 if (textures[ii] == unit.bound_texture_external_oes) { | 4640 if (textures[ii] == unit.bound_texture_external_oes) { |
| (...skipping 2403 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7042 unsigned char* addr = static_cast<unsigned char*>(buffer.address()); | 7044 unsigned char* addr = static_cast<unsigned char*>(buffer.address()); |
| 7043 memcpy(addr, coeffs, coeffs_size); | 7045 memcpy(addr, coeffs, coeffs_size); |
| 7044 | 7046 |
| 7045 helper_->ProgramPathFragmentInputGenCHROMIUM(program, location, gen_mode, | 7047 helper_->ProgramPathFragmentInputGenCHROMIUM(program, location, gen_mode, |
| 7046 components, buffer.shm_id(), | 7048 components, buffer.shm_id(), |
| 7047 buffer.offset()); | 7049 buffer.offset()); |
| 7048 } | 7050 } |
| 7049 CheckGLError(); | 7051 CheckGLError(); |
| 7050 } | 7052 } |
| 7051 | 7053 |
| 7054 void GLES2Implementation::InitializeDiscardableTextureCHROMIUM( |
| 7055 GLuint texture_id) { |
| 7056 ClientDiscardableManager* manager = share_group()->discardable_manager(); |
| 7057 if (manager->TextureIsValid(texture_id)) { |
| 7058 SetGLError(GL_INVALID_VALUE, "glInitializeDiscardableTextureCHROMIUM", |
| 7059 "Texture ID already initialized"); |
| 7060 return; |
| 7061 } |
| 7062 ClientDiscardableHandle handle = |
| 7063 manager->InitializeTexture(helper_->command_buffer(), texture_id); |
| 7064 helper_->InitializeDiscardableTextureCHROMIUM(texture_id, handle.shm_id(), |
| 7065 handle.byte_offset()); |
| 7066 } |
| 7067 |
| 7068 void GLES2Implementation::UnlockDiscardableTextureCHROMIUM(GLuint texture_id) { |
| 7069 ClientDiscardableManager* manager = share_group()->discardable_manager(); |
| 7070 if (!manager->TextureIsValid(texture_id)) { |
| 7071 SetGLError(GL_INVALID_VALUE, "glUnlockDiscardableTextureCHROMIUM", |
| 7072 "Texture ID not initialized"); |
| 7073 return; |
| 7074 } |
| 7075 helper_->UnlockDiscardableTextureCHROMIUM(texture_id); |
| 7076 } |
| 7077 |
| 7078 bool GLES2Implementation::LockDiscardableTextureCHROMIUM(GLuint texture_id) { |
| 7079 ClientDiscardableManager* manager = share_group()->discardable_manager(); |
| 7080 if (!manager->TextureIsValid(texture_id)) { |
| 7081 SetGLError(GL_INVALID_VALUE, "glLockDiscardableTextureCHROMIUM", |
| 7082 "Texture ID not initialized"); |
| 7083 return false; |
| 7084 } |
| 7085 if (!manager->LockTexture(texture_id)) { |
| 7086 // Failure to lock means that this texture has been deleted on the service |
| 7087 // side. Delete it here as well. |
| 7088 DeleteTexturesHelper(1, &texture_id); |
| 7089 return false; |
| 7090 } |
| 7091 helper_->LockDiscardableTextureCHROMIUM(texture_id); |
| 7092 return true; |
| 7093 } |
| 7094 |
| 7052 void GLES2Implementation::UpdateCachedExtensionsIfNeeded() { | 7095 void GLES2Implementation::UpdateCachedExtensionsIfNeeded() { |
| 7053 if (cached_extension_string_) { | 7096 if (cached_extension_string_) { |
| 7054 return; | 7097 return; |
| 7055 } | 7098 } |
| 7056 GetStringHelper(GL_EXTENSIONS); | 7099 GetStringHelper(GL_EXTENSIONS); |
| 7057 } | 7100 } |
| 7058 | 7101 |
| 7059 void GLES2Implementation::InvalidateCachedExtensions() { | 7102 void GLES2Implementation::InvalidateCachedExtensions() { |
| 7060 cached_extension_string_ = nullptr; | 7103 cached_extension_string_ = nullptr; |
| 7061 cached_extensions_.clear(); | 7104 cached_extensions_.clear(); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 7077 CheckGLError(); | 7120 CheckGLError(); |
| 7078 } | 7121 } |
| 7079 | 7122 |
| 7080 // Include the auto-generated part of this file. We split this because it means | 7123 // Include the auto-generated part of this file. We split this because it means |
| 7081 // we can easily edit the non-auto generated parts right here in this file | 7124 // we can easily edit the non-auto generated parts right here in this file |
| 7082 // instead of having to edit some template or the code generator. | 7125 // instead of having to edit some template or the code generator. |
| 7083 #include "gpu/command_buffer/client/gles2_implementation_impl_autogen.h" | 7126 #include "gpu/command_buffer/client/gles2_implementation_impl_autogen.h" |
| 7084 | 7127 |
| 7085 } // namespace gles2 | 7128 } // namespace gles2 |
| 7086 } // namespace gpu | 7129 } // namespace gpu |
| OLD | NEW |