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 8686 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9611 return GL_LUMINANCE_ALPHA; | 9612 return GL_LUMINANCE_ALPHA; |
9612 case GL_BGRA8_EXT: | 9613 case GL_BGRA8_EXT: |
9613 return GL_BGRA_EXT; | 9614 return GL_BGRA_EXT; |
9614 default: | 9615 default: |
9615 return GL_NONE; | 9616 return GL_NONE; |
9616 } | 9617 } |
9617 } | 9618 } |
9618 | 9619 |
9619 void GLES2DecoderImpl::DoCopyTextureCHROMIUM( | 9620 void GLES2DecoderImpl::DoCopyTextureCHROMIUM( |
9620 GLenum target, GLuint source_id, GLuint dest_id, GLint level, | 9621 GLenum target, GLuint source_id, GLuint dest_id, GLint level, |
9621 GLenum internal_format) { | 9622 GLenum internal_format, GLenum dest_type) { |
9622 Texture* dest_texture = GetTexture(dest_id); | 9623 Texture* dest_texture = GetTexture(dest_id); |
9623 Texture* source_texture = GetTexture(source_id); | 9624 Texture* source_texture = GetTexture(source_id); |
9624 | 9625 |
9625 if (!source_texture || !dest_texture) { | 9626 if (!source_texture || !dest_texture) { |
9626 LOCAL_SET_GL_ERROR( | 9627 LOCAL_SET_GL_ERROR( |
9627 GL_INVALID_VALUE, "glCopyTextureCHROMIUM", "unknown texture id"); | 9628 GL_INVALID_VALUE, "glCopyTextureCHROMIUM", "unknown texture id"); |
9628 return; | 9629 return; |
9629 } | 9630 } |
9630 | 9631 |
9631 if (GL_TEXTURE_2D != target) { | 9632 if (GL_TEXTURE_2D != target) { |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9677 // needed because it takes 10s of milliseconds to initialize. | 9678 // needed because it takes 10s of milliseconds to initialize. |
9678 if (!copy_texture_CHROMIUM_.get()) { | 9679 if (!copy_texture_CHROMIUM_.get()) { |
9679 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("glCopyTextureCHROMIUM"); | 9680 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("glCopyTextureCHROMIUM"); |
9680 copy_texture_CHROMIUM_.reset(new CopyTextureCHROMIUMResourceManager()); | 9681 copy_texture_CHROMIUM_.reset(new CopyTextureCHROMIUMResourceManager()); |
9681 copy_texture_CHROMIUM_->Initialize(this); | 9682 copy_texture_CHROMIUM_->Initialize(this); |
9682 RestoreCurrentFramebufferBindings(); | 9683 RestoreCurrentFramebufferBindings(); |
9683 if (LOCAL_PEEK_GL_ERROR("glCopyTextureCHROMIUM") != GL_NO_ERROR) | 9684 if (LOCAL_PEEK_GL_ERROR("glCopyTextureCHROMIUM") != GL_NO_ERROR) |
9684 return; | 9685 return; |
9685 } | 9686 } |
9686 | 9687 |
9687 GLenum dest_type; | 9688 GLenum dest_type_previous; |
9688 GLenum dest_internal_format; | 9689 GLenum dest_internal_format; |
9689 bool dest_level_defined = dest_texture->GetLevelSize( | 9690 bool dest_level_defined = dest_texture->GetLevelSize( |
9690 GL_TEXTURE_2D, level, &dest_width, &dest_height); | 9691 GL_TEXTURE_2D, level, &dest_width, &dest_height); |
9691 | 9692 |
9692 if (dest_level_defined) { | 9693 if (dest_level_defined) { |
9693 dest_texture->GetLevelType(GL_TEXTURE_2D, level, &dest_type, | 9694 dest_texture->GetLevelType(GL_TEXTURE_2D, level, &dest_type_previous, |
9694 &dest_internal_format); | 9695 &dest_internal_format); |
9695 } else { | |
9696 GLenum source_internal_format; | |
9697 source_texture->GetLevelType(GL_TEXTURE_2D, 0, &dest_type, | |
9698 &source_internal_format); | |
9699 } | 9696 } |
9700 | 9697 |
9701 // Set source texture's width and height to be the same as | 9698 // Set source texture's width and height to be the same as |
9702 // destination texture when source is GL_TEXTURE_EXTERNAL_OES. | 9699 // destination texture when source is GL_TEXTURE_EXTERNAL_OES. |
9703 if (source_texture->target() == GL_TEXTURE_EXTERNAL_OES) { | 9700 if (source_texture->target() == GL_TEXTURE_EXTERNAL_OES) { |
9704 source_width = dest_width; | 9701 source_width = dest_width; |
9705 source_height = dest_height; | 9702 source_height = dest_height; |
9706 } | 9703 } |
9707 | 9704 |
9708 // Resize the destination texture to the dimensions of the source texture. | 9705 // Resize the destination texture to the dimensions of the source texture. |
9709 if (!dest_level_defined || dest_width != source_width || | 9706 if (!dest_level_defined || dest_width != source_width || |
9710 dest_height != source_height || | 9707 dest_height != source_height || |
9711 dest_internal_format != internal_format) { | 9708 dest_internal_format != internal_format || |
| 9709 dest_type_previous != dest_type) { |
9712 // Ensure that the glTexImage2D succeeds. | 9710 // Ensure that the glTexImage2D succeeds. |
9713 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("glCopyTextureCHROMIUM"); | 9711 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("glCopyTextureCHROMIUM"); |
9714 glBindTexture(GL_TEXTURE_2D, dest_texture->service_id()); | 9712 glBindTexture(GL_TEXTURE_2D, dest_texture->service_id()); |
9715 WrappedTexImage2D( | 9713 WrappedTexImage2D( |
9716 GL_TEXTURE_2D, level, internal_format, source_width, source_height, | 9714 GL_TEXTURE_2D, level, internal_format, source_width, source_height, |
9717 0, internal_format, dest_type, NULL); | 9715 0, internal_format, dest_type, NULL); |
9718 GLenum error = LOCAL_PEEK_GL_ERROR("glCopyTextureCHROMIUM"); | 9716 GLenum error = LOCAL_PEEK_GL_ERROR("glCopyTextureCHROMIUM"); |
9719 if (error != GL_NO_ERROR) { | 9717 if (error != GL_NO_ERROR) { |
9720 RestoreCurrentTexture2DBindings(); | 9718 RestoreCurrentTexture2DBindings(); |
9721 return; | 9719 return; |
(...skipping 682 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10404 return error::kNoError; | 10402 return error::kNoError; |
10405 } | 10403 } |
10406 | 10404 |
10407 // Include the auto-generated part of this file. We split this because it means | 10405 // Include the auto-generated part of this file. We split this because it means |
10408 // we can easily edit the non-auto generated parts right here in this file | 10406 // we can easily edit the non-auto generated parts right here in this file |
10409 // instead of having to edit some template or the code generator. | 10407 // instead of having to edit some template or the code generator. |
10410 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" | 10408 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" |
10411 | 10409 |
10412 } // namespace gles2 | 10410 } // namespace gles2 |
10413 } // namespace gpu | 10411 } // namespace gpu |
OLD | NEW |