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 2398 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7037 unsigned char* addr = static_cast<unsigned char*>(buffer.address()); | 7039 unsigned char* addr = static_cast<unsigned char*>(buffer.address()); |
7038 memcpy(addr, coeffs, coeffs_size); | 7040 memcpy(addr, coeffs, coeffs_size); |
7039 | 7041 |
7040 helper_->ProgramPathFragmentInputGenCHROMIUM(program, location, gen_mode, | 7042 helper_->ProgramPathFragmentInputGenCHROMIUM(program, location, gen_mode, |
7041 components, buffer.shm_id(), | 7043 components, buffer.shm_id(), |
7042 buffer.offset()); | 7044 buffer.offset()); |
7043 } | 7045 } |
7044 CheckGLError(); | 7046 CheckGLError(); |
7045 } | 7047 } |
7046 | 7048 |
| 7049 void GLES2Implementation::InitializeDiscardableTextureCHROMIUM( |
| 7050 GLuint texture_id) { |
| 7051 ClientDiscardableManager* manager = share_group()->discardable_manager(); |
| 7052 if (manager->TextureIsValid(texture_id)) { |
| 7053 SetGLError(GL_INVALID_VALUE, "glInitializeDiscardableTextureCHROMIUM", |
| 7054 "Texture ID already initialized"); |
| 7055 return; |
| 7056 } |
| 7057 ClientDiscardableHandle handle = |
| 7058 manager->InitializeTexture(helper_->command_buffer(), texture_id); |
| 7059 helper_->InitializeDiscardableTextureCHROMIUM(texture_id, handle.shm_id(), |
| 7060 handle.byte_offset()); |
| 7061 } |
| 7062 |
| 7063 void GLES2Implementation::UnlockDiscardableTextureCHROMIUM(GLuint texture_id) { |
| 7064 ClientDiscardableManager* manager = share_group()->discardable_manager(); |
| 7065 if (!manager->TextureIsValid(texture_id)) { |
| 7066 SetGLError(GL_INVALID_VALUE, "glUnlockDiscardableTextureCHROMIUM", |
| 7067 "Texture ID not initialized"); |
| 7068 return; |
| 7069 } |
| 7070 helper_->UnlockDiscardableTextureCHROMIUM(texture_id); |
| 7071 } |
| 7072 |
| 7073 bool GLES2Implementation::LockDiscardableTextureCHROMIUM(GLuint texture_id) { |
| 7074 ClientDiscardableManager* manager = share_group()->discardable_manager(); |
| 7075 if (!manager->TextureIsValid(texture_id)) { |
| 7076 SetGLError(GL_INVALID_VALUE, "glLockDiscardableTextureCHROMIUM", |
| 7077 "Texture ID not initialized"); |
| 7078 return false; |
| 7079 } |
| 7080 if (!manager->LockTexture(texture_id)) { |
| 7081 // Failure to lock means that this texture has been deleted on the service |
| 7082 // side. Delete it here as well. |
| 7083 DeleteTexturesHelper(1, &texture_id); |
| 7084 return false; |
| 7085 } |
| 7086 return true; |
| 7087 } |
| 7088 |
7047 void GLES2Implementation::UpdateCachedExtensionsIfNeeded() { | 7089 void GLES2Implementation::UpdateCachedExtensionsIfNeeded() { |
7048 if (cached_extension_string_) { | 7090 if (cached_extension_string_) { |
7049 return; | 7091 return; |
7050 } | 7092 } |
7051 GetStringHelper(GL_EXTENSIONS); | 7093 GetStringHelper(GL_EXTENSIONS); |
7052 } | 7094 } |
7053 | 7095 |
7054 void GLES2Implementation::InvalidateCachedExtensions() { | 7096 void GLES2Implementation::InvalidateCachedExtensions() { |
7055 cached_extension_string_ = nullptr; | 7097 cached_extension_string_ = nullptr; |
7056 cached_extensions_.clear(); | 7098 cached_extensions_.clear(); |
(...skipping 15 matching lines...) Expand all Loading... |
7072 CheckGLError(); | 7114 CheckGLError(); |
7073 } | 7115 } |
7074 | 7116 |
7075 // Include the auto-generated part of this file. We split this because it means | 7117 // Include the auto-generated part of this file. We split this because it means |
7076 // we can easily edit the non-auto generated parts right here in this file | 7118 // we can easily edit the non-auto generated parts right here in this file |
7077 // instead of having to edit some template or the code generator. | 7119 // instead of having to edit some template or the code generator. |
7078 #include "gpu/command_buffer/client/gles2_implementation_impl_autogen.h" | 7120 #include "gpu/command_buffer/client/gles2_implementation_impl_autogen.h" |
7079 | 7121 |
7080 } // namespace gles2 | 7122 } // namespace gles2 |
7081 } // namespace gpu | 7123 } // namespace gpu |
OLD | NEW |