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 <limits.h> | 7 #include <limits.h> |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 #include <stdio.h> | 10 #include <stdio.h> |
(...skipping 9640 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
9651 gl::GLImage* image) { | 9651 gl::GLImage* image) { |
9652 // Note: We update the state to COPIED prior to calling CopyTexImage() | 9652 // Note: We update the state to COPIED prior to calling CopyTexImage() |
9653 // as that allows the GLImage implemenatation to set it back to UNBOUND | 9653 // as that allows the GLImage implemenatation to set it back to UNBOUND |
9654 // and ensure that CopyTexImage() is called each time the texture is | 9654 // and ensure that CopyTexImage() is called each time the texture is |
9655 // used. | 9655 // used. |
9656 texture->SetLevelImageState(textarget, 0, Texture::COPIED); | 9656 texture->SetLevelImageState(textarget, 0, Texture::COPIED); |
9657 bool rv = image->CopyTexImage(textarget); | 9657 bool rv = image->CopyTexImage(textarget); |
9658 DCHECK(rv) << "CopyTexImage() failed"; | 9658 DCHECK(rv) << "CopyTexImage() failed"; |
9659 } | 9659 } |
9660 | 9660 |
9661 void GLES2DecoderImpl::DoCopyTexImageIfNeeded(Texture* texture, | 9661 void GLES2DecoderImpl::DoCopyTexImageIfNeeded(Texture* texture, |
sandersd (OOO until July 31)
2017/05/23 23:23:31
Perhaps this needs a new name? (Please update the
| |
9662 GLenum textarget) { | 9662 GLenum textarget) { |
9663 // Image is already in use if texture is attached to a framebuffer. | 9663 // Image is already in use if texture is attached to a framebuffer. |
9664 if (texture && !texture->IsAttachedToFramebuffer()) { | 9664 if (texture && !texture->IsAttachedToFramebuffer()) { |
9665 Texture::ImageState image_state; | 9665 Texture::ImageState image_state; |
9666 gl::GLImage* image = texture->GetLevelImage(textarget, 0, &image_state); | 9666 gl::GLImage* image = texture->GetLevelImage(textarget, 0, &image_state); |
9667 if (image && image_state == Texture::UNBOUND) { | 9667 if (image && image_state == Texture::UNBOUND) { |
9668 ScopedGLErrorSuppressor suppressor( | 9668 ScopedGLErrorSuppressor suppressor( |
9669 "GLES2DecoderImpl::DoCopyTexImageIfNeeded", GetErrorState()); | 9669 "GLES2DecoderImpl::DoCopyTexImageIfNeeded", GetErrorState()); |
9670 glBindTexture(textarget, texture->service_id()); | 9670 glBindTexture(textarget, texture->service_id()); |
9671 DoCopyTexImage(texture, textarget, image); | 9671 if (image->BindTexImage(textarget)) { |
9672 image_state = Texture::BOUND; | |
9673 } else { | |
9674 DoCopyTexImage(texture, textarget, image); | |
9675 } | |
9672 RestoreCurrentTextureBindings(&state_, textarget); | 9676 RestoreCurrentTextureBindings(&state_, textarget); |
9673 } | 9677 } |
9674 } | 9678 } |
9675 } | 9679 } |
9676 | 9680 |
9677 void GLES2DecoderImpl::DoCopyBufferSubData(GLenum readtarget, | 9681 void GLES2DecoderImpl::DoCopyBufferSubData(GLenum readtarget, |
9678 GLenum writetarget, | 9682 GLenum writetarget, |
9679 GLintptr readoffset, | 9683 GLintptr readoffset, |
9680 GLintptr writeoffset, | 9684 GLintptr writeoffset, |
9681 GLsizeiptr size) { | 9685 GLsizeiptr size) { |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
9726 | 9730 |
9727 if (textarget != GL_TEXTURE_CUBE_MAP) { | 9731 if (textarget != GL_TEXTURE_CUBE_MAP) { |
9728 Texture* texture = texture_ref->texture(); | 9732 Texture* texture = texture_ref->texture(); |
9729 Texture::ImageState image_state; | 9733 Texture::ImageState image_state; |
9730 gl::GLImage* image = | 9734 gl::GLImage* image = |
9731 texture->GetLevelImage(textarget, 0, &image_state); | 9735 texture->GetLevelImage(textarget, 0, &image_state); |
9732 if (image && image_state == Texture::UNBOUND && | 9736 if (image && image_state == Texture::UNBOUND && |
9733 !texture->IsAttachedToFramebuffer()) { | 9737 !texture->IsAttachedToFramebuffer()) { |
9734 ScopedGLErrorSuppressor suppressor( | 9738 ScopedGLErrorSuppressor suppressor( |
9735 "GLES2DecoderImpl::PrepareTexturesForRender", GetErrorState()); | 9739 "GLES2DecoderImpl::PrepareTexturesForRender", GetErrorState()); |
9740 glActiveTexture(GL_TEXTURE0 + texture_unit_index); | |
9741 if (image->BindTexImage(textarget)) { | |
sandersd (OOO until July 31)
2017/05/23 23:23:31
This is same as the core of DoCopyTexImageIfNeeded
| |
9742 image_state = Texture::BOUND; | |
9743 } else { | |
9744 DoCopyTexImage(texture, textarget, image); | |
9745 } | |
9736 textures_set = true; | 9746 textures_set = true; |
9737 glActiveTexture(GL_TEXTURE0 + texture_unit_index); | |
9738 DoCopyTexImage(texture, textarget, image); | |
9739 continue; | 9747 continue; |
9740 } | 9748 } |
9741 } | 9749 } |
9742 } | 9750 } |
9743 // else: should this be an error? | 9751 // else: should this be an error? |
9744 } | 9752 } |
9745 } | 9753 } |
9746 return !textures_set; | 9754 return !textures_set; |
9747 } | 9755 } |
9748 | 9756 |
(...skipping 9976 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
19725 } | 19733 } |
19726 | 19734 |
19727 // Include the auto-generated part of this file. We split this because it means | 19735 // Include the auto-generated part of this file. We split this because it means |
19728 // we can easily edit the non-auto generated parts right here in this file | 19736 // we can easily edit the non-auto generated parts right here in this file |
19729 // instead of having to edit some template or the code generator. | 19737 // instead of having to edit some template or the code generator. |
19730 #include "base/macros.h" | 19738 #include "base/macros.h" |
19731 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" | 19739 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" |
19732 | 19740 |
19733 } // namespace gles2 | 19741 } // namespace gles2 |
19734 } // namespace gpu | 19742 } // namespace gpu |
OLD | NEW |