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 893 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
904 GLsizei width, | 904 GLsizei width, |
905 GLsizei height, | 905 GLsizei height, |
906 GLuint io_surface_id, | 906 GLuint io_surface_id, |
907 GLuint plane); | 907 GLuint plane); |
908 | 908 |
909 void DoCopyTextureCHROMIUM( | 909 void DoCopyTextureCHROMIUM( |
910 GLenum target, | 910 GLenum target, |
911 GLuint source_id, | 911 GLuint source_id, |
912 GLuint target_id, | 912 GLuint target_id, |
913 GLint level, | 913 GLint level, |
914 GLenum internal_format); | 914 GLenum internal_format, |
| 915 GLenum dest_type); |
915 | 916 |
916 // Wrapper for TexStorage2DEXT. | 917 // Wrapper for TexStorage2DEXT. |
917 void DoTexStorage2DEXT( | 918 void DoTexStorage2DEXT( |
918 GLenum target, | 919 GLenum target, |
919 GLint levels, | 920 GLint levels, |
920 GLenum internal_format, | 921 GLenum internal_format, |
921 GLsizei width, | 922 GLsizei width, |
922 GLsizei height); | 923 GLsizei height); |
923 | 924 |
924 void DoProduceTextureCHROMIUM(GLenum target, const GLbyte* key); | 925 void DoProduceTextureCHROMIUM(GLenum target, const GLbyte* key); |
(...skipping 8838 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9763 return GL_LUMINANCE_ALPHA; | 9764 return GL_LUMINANCE_ALPHA; |
9764 case GL_BGRA8_EXT: | 9765 case GL_BGRA8_EXT: |
9765 return GL_BGRA_EXT; | 9766 return GL_BGRA_EXT; |
9766 default: | 9767 default: |
9767 return GL_NONE; | 9768 return GL_NONE; |
9768 } | 9769 } |
9769 } | 9770 } |
9770 | 9771 |
9771 void GLES2DecoderImpl::DoCopyTextureCHROMIUM( | 9772 void GLES2DecoderImpl::DoCopyTextureCHROMIUM( |
9772 GLenum target, GLuint source_id, GLuint dest_id, GLint level, | 9773 GLenum target, GLuint source_id, GLuint dest_id, GLint level, |
9773 GLenum internal_format) { | 9774 GLenum internal_format, GLenum dest_type) { |
9774 Texture* dest_texture = GetTexture(dest_id); | 9775 Texture* dest_texture = GetTexture(dest_id); |
9775 Texture* source_texture = GetTexture(source_id); | 9776 Texture* source_texture = GetTexture(source_id); |
9776 | 9777 |
9777 if (!source_texture || !dest_texture) { | 9778 if (!source_texture || !dest_texture) { |
9778 LOCAL_SET_GL_ERROR( | 9779 LOCAL_SET_GL_ERROR( |
9779 GL_INVALID_VALUE, "glCopyTextureCHROMIUM", "unknown texture id"); | 9780 GL_INVALID_VALUE, "glCopyTextureCHROMIUM", "unknown texture id"); |
9780 return; | 9781 return; |
9781 } | 9782 } |
9782 | 9783 |
9783 if (GL_TEXTURE_2D != target) { | 9784 if (GL_TEXTURE_2D != target) { |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9829 // needed because it takes 10s of milliseconds to initialize. | 9830 // needed because it takes 10s of milliseconds to initialize. |
9830 if (!copy_texture_CHROMIUM_.get()) { | 9831 if (!copy_texture_CHROMIUM_.get()) { |
9831 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("glCopyTextureCHROMIUM"); | 9832 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("glCopyTextureCHROMIUM"); |
9832 copy_texture_CHROMIUM_.reset(new CopyTextureCHROMIUMResourceManager()); | 9833 copy_texture_CHROMIUM_.reset(new CopyTextureCHROMIUMResourceManager()); |
9833 copy_texture_CHROMIUM_->Initialize(this); | 9834 copy_texture_CHROMIUM_->Initialize(this); |
9834 RestoreCurrentFramebufferBindings(); | 9835 RestoreCurrentFramebufferBindings(); |
9835 if (LOCAL_PEEK_GL_ERROR("glCopyTextureCHROMIUM") != GL_NO_ERROR) | 9836 if (LOCAL_PEEK_GL_ERROR("glCopyTextureCHROMIUM") != GL_NO_ERROR) |
9836 return; | 9837 return; |
9837 } | 9838 } |
9838 | 9839 |
9839 GLenum dest_type; | 9840 GLenum dest_type_previous; |
9840 GLenum dest_internal_format; | 9841 GLenum dest_internal_format; |
9841 bool dest_level_defined = dest_texture->GetLevelSize( | 9842 bool dest_level_defined = dest_texture->GetLevelSize( |
9842 GL_TEXTURE_2D, level, &dest_width, &dest_height); | 9843 GL_TEXTURE_2D, level, &dest_width, &dest_height); |
9843 | 9844 |
9844 if (dest_level_defined) { | 9845 if (dest_level_defined) { |
9845 dest_texture->GetLevelType(GL_TEXTURE_2D, level, &dest_type, | 9846 dest_texture->GetLevelType(GL_TEXTURE_2D, level, &dest_type_previous, |
9846 &dest_internal_format); | 9847 &dest_internal_format); |
9847 } else { | |
9848 GLenum source_internal_format; | |
9849 source_texture->GetLevelType(GL_TEXTURE_2D, 0, &dest_type, | |
9850 &source_internal_format); | |
9851 } | 9848 } |
9852 | 9849 |
9853 // Set source texture's width and height to be the same as | 9850 // Set source texture's width and height to be the same as |
9854 // destination texture when source is GL_TEXTURE_EXTERNAL_OES. | 9851 // destination texture when source is GL_TEXTURE_EXTERNAL_OES. |
9855 if (source_texture->target() == GL_TEXTURE_EXTERNAL_OES) { | 9852 if (source_texture->target() == GL_TEXTURE_EXTERNAL_OES) { |
9856 source_width = dest_width; | 9853 source_width = dest_width; |
9857 source_height = dest_height; | 9854 source_height = dest_height; |
9858 } | 9855 } |
9859 | 9856 |
9860 // Resize the destination texture to the dimensions of the source texture. | 9857 // Resize the destination texture to the dimensions of the source texture. |
9861 if (!dest_level_defined || dest_width != source_width || | 9858 if (!dest_level_defined || dest_width != source_width || |
9862 dest_height != source_height || | 9859 dest_height != source_height || |
9863 dest_internal_format != internal_format) { | 9860 dest_internal_format != internal_format || |
| 9861 dest_type_previous != dest_type) { |
9864 // Ensure that the glTexImage2D succeeds. | 9862 // Ensure that the glTexImage2D succeeds. |
9865 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("glCopyTextureCHROMIUM"); | 9863 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("glCopyTextureCHROMIUM"); |
9866 glBindTexture(GL_TEXTURE_2D, dest_texture->service_id()); | 9864 glBindTexture(GL_TEXTURE_2D, dest_texture->service_id()); |
9867 WrappedTexImage2D( | 9865 WrappedTexImage2D( |
9868 GL_TEXTURE_2D, level, internal_format, source_width, source_height, | 9866 GL_TEXTURE_2D, level, internal_format, source_width, source_height, |
9869 0, internal_format, dest_type, NULL); | 9867 0, internal_format, dest_type, NULL); |
9870 GLenum error = LOCAL_PEEK_GL_ERROR("glCopyTextureCHROMIUM"); | 9868 GLenum error = LOCAL_PEEK_GL_ERROR("glCopyTextureCHROMIUM"); |
9871 if (error != GL_NO_ERROR) { | 9869 if (error != GL_NO_ERROR) { |
9872 RestoreCurrentTexture2DBindings(); | 9870 RestoreCurrentTexture2DBindings(); |
9873 return; | 9871 return; |
(...skipping 659 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10533 return error::kNoError; | 10531 return error::kNoError; |
10534 } | 10532 } |
10535 | 10533 |
10536 // Include the auto-generated part of this file. We split this because it means | 10534 // Include the auto-generated part of this file. We split this because it means |
10537 // we can easily edit the non-auto generated parts right here in this file | 10535 // we can easily edit the non-auto generated parts right here in this file |
10538 // instead of having to edit some template or the code generator. | 10536 // instead of having to edit some template or the code generator. |
10539 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" | 10537 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" |
10540 | 10538 |
10541 } // namespace gles2 | 10539 } // namespace gles2 |
10542 } // namespace gpu | 10540 } // namespace gpu |
OLD | NEW |