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