| 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/gles2_cmd_decoder.h" | 5 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" |
| 6 | 6 |
| 7 #include <stdio.h> | 7 #include <stdio.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <list> | 10 #include <list> |
| (...skipping 9563 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9574 SetGLError(GL_INVALID_VALUE, | 9574 SetGLError(GL_INVALID_VALUE, |
| 9575 "glCopyTextureCHROMIUM", "Bad dimensions"); | 9575 "glCopyTextureCHROMIUM", "Bad dimensions"); |
| 9576 return; | 9576 return; |
| 9577 } | 9577 } |
| 9578 | 9578 |
| 9579 // Defer initializing the CopyTextureCHROMIUMResourceManager until it is | 9579 // Defer initializing the CopyTextureCHROMIUMResourceManager until it is |
| 9580 // needed because it takes 10s of milliseconds to initialize. | 9580 // needed because it takes 10s of milliseconds to initialize. |
| 9581 if (!copy_texture_CHROMIUM_.get()) { | 9581 if (!copy_texture_CHROMIUM_.get()) { |
| 9582 CopyRealGLErrorsToWrapper(); | 9582 CopyRealGLErrorsToWrapper(); |
| 9583 copy_texture_CHROMIUM_.reset(new CopyTextureCHROMIUMResourceManager()); | 9583 copy_texture_CHROMIUM_.reset(new CopyTextureCHROMIUMResourceManager()); |
| 9584 copy_texture_CHROMIUM_->Initialize(); | 9584 copy_texture_CHROMIUM_->Initialize(this); |
| 9585 RestoreCurrentFramebufferBindings(); | 9585 RestoreCurrentFramebufferBindings(); |
| 9586 if (PeekGLError() != GL_NO_ERROR) | 9586 if (PeekGLError() != GL_NO_ERROR) |
| 9587 return; | 9587 return; |
| 9588 } | 9588 } |
| 9589 | 9589 |
| 9590 GLenum dest_type; | 9590 GLenum dest_type; |
| 9591 GLenum dest_internal_format; | 9591 GLenum dest_internal_format; |
| 9592 bool dest_level_defined = dest_info->GetLevelSize(GL_TEXTURE_2D, level, | 9592 bool dest_level_defined = dest_info->GetLevelSize(GL_TEXTURE_2D, level, |
| 9593 &dest_width, | 9593 &dest_width, |
| 9594 &dest_height); | 9594 &dest_height); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 9618 return; | 9618 return; |
| 9619 } | 9619 } |
| 9620 | 9620 |
| 9621 texture_manager()->SetLevelInfo( | 9621 texture_manager()->SetLevelInfo( |
| 9622 dest_info, GL_TEXTURE_2D, level, internal_format, source_width, | 9622 dest_info, GL_TEXTURE_2D, level, internal_format, source_width, |
| 9623 source_height, 1, 0, internal_format, dest_type, true); | 9623 source_height, 1, 0, internal_format, dest_type, true); |
| 9624 } else { | 9624 } else { |
| 9625 texture_manager()->SetLevelCleared(dest_info, GL_TEXTURE_2D, level, true); | 9625 texture_manager()->SetLevelCleared(dest_info, GL_TEXTURE_2D, level, true); |
| 9626 } | 9626 } |
| 9627 | 9627 |
| 9628 clear_state_dirty_ = true; | 9628 copy_texture_CHROMIUM_->DoCopyTexture(this, |
| 9629 glViewport(0, 0, source_width, source_height); | 9629 target, source_info->service_id(), |
| 9630 copy_texture_CHROMIUM_->DoCopyTexture(target, source_info->service_id(), | |
| 9631 dest_info->service_id(), level, | 9630 dest_info->service_id(), level, |
| 9631 source_width, source_height, |
| 9632 unpack_flip_y_, | 9632 unpack_flip_y_, |
| 9633 unpack_premultiply_alpha_, | 9633 unpack_premultiply_alpha_, |
| 9634 unpack_unpremultiply_alpha_); | 9634 unpack_unpremultiply_alpha_); |
| 9635 glViewport( | |
| 9636 state_.viewport_x, state_.viewport_y, | |
| 9637 state_.viewport_width, state_.viewport_height); | |
| 9638 | |
| 9639 // Restore all of the state touched by the extension. | |
| 9640 if (state_.current_program) | |
| 9641 glUseProgram(state_.current_program->service_id()); | |
| 9642 else | |
| 9643 glUseProgram(0); | |
| 9644 | |
| 9645 RestoreCurrentFramebufferBindings(); | |
| 9646 RestoreCurrentTexture2DBindings(); | |
| 9647 RestoreStateForAttrib( | |
| 9648 CopyTextureCHROMIUMResourceManager::kVertexPositionAttrib); | |
| 9649 RestoreStateForAttrib( | |
| 9650 CopyTextureCHROMIUMResourceManager::kVertexTextureAttrib); | |
| 9651 | |
| 9652 ApplyDirtyState(); | |
| 9653 } | 9635 } |
| 9654 | 9636 |
| 9655 static GLenum ExtractTypeFromStorageFormat(GLenum internalformat) { | 9637 static GLenum ExtractTypeFromStorageFormat(GLenum internalformat) { |
| 9656 switch (internalformat) { | 9638 switch (internalformat) { |
| 9657 case GL_RGB565: | 9639 case GL_RGB565: |
| 9658 return GL_UNSIGNED_SHORT_5_6_5; | 9640 return GL_UNSIGNED_SHORT_5_6_5; |
| 9659 case GL_RGBA4: | 9641 case GL_RGBA4: |
| 9660 return GL_UNSIGNED_SHORT_4_4_4_4; | 9642 return GL_UNSIGNED_SHORT_4_4_4_4; |
| 9661 case GL_RGB5_A1: | 9643 case GL_RGB5_A1: |
| 9662 return GL_UNSIGNED_SHORT_5_5_5_1; | 9644 return GL_UNSIGNED_SHORT_5_5_5_1; |
| (...skipping 510 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10173 return error::kNoError; | 10155 return error::kNoError; |
| 10174 } | 10156 } |
| 10175 | 10157 |
| 10176 // Include the auto-generated part of this file. We split this because it means | 10158 // Include the auto-generated part of this file. We split this because it means |
| 10177 // we can easily edit the non-auto generated parts right here in this file | 10159 // we can easily edit the non-auto generated parts right here in this file |
| 10178 // instead of having to edit some template or the code generator. | 10160 // instead of having to edit some template or the code generator. |
| 10179 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" | 10161 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" |
| 10180 | 10162 |
| 10181 } // namespace gles2 | 10163 } // namespace gles2 |
| 10182 } // namespace gpu | 10164 } // namespace gpu |
| OLD | NEW |