| 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 10037 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10048 // needed because it takes 10s of milliseconds to initialize. | 10048 // needed because it takes 10s of milliseconds to initialize. |
| 10049 if (!copy_texture_CHROMIUM_.get()) { | 10049 if (!copy_texture_CHROMIUM_.get()) { |
| 10050 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("glCopyTextureCHROMIUM"); | 10050 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("glCopyTextureCHROMIUM"); |
| 10051 copy_texture_CHROMIUM_.reset(new CopyTextureCHROMIUMResourceManager()); | 10051 copy_texture_CHROMIUM_.reset(new CopyTextureCHROMIUMResourceManager()); |
| 10052 copy_texture_CHROMIUM_->Initialize(this); | 10052 copy_texture_CHROMIUM_->Initialize(this); |
| 10053 RestoreCurrentFramebufferBindings(); | 10053 RestoreCurrentFramebufferBindings(); |
| 10054 if (LOCAL_PEEK_GL_ERROR("glCopyTextureCHROMIUM") != GL_NO_ERROR) | 10054 if (LOCAL_PEEK_GL_ERROR("glCopyTextureCHROMIUM") != GL_NO_ERROR) |
| 10055 return; | 10055 return; |
| 10056 } | 10056 } |
| 10057 | 10057 |
| 10058 GLenum source_type = 0; |
| 10059 GLenum source_internal_format = 0; |
| 10060 source_texture->GetLevelType( |
| 10061 source_texture->target(), 0, &source_type, &source_internal_format); |
| 10062 |
| 10058 GLenum dest_type_previous = dest_type; | 10063 GLenum dest_type_previous = dest_type; |
| 10059 GLenum dest_internal_format = internal_format; | 10064 GLenum dest_internal_format = internal_format; |
| 10060 bool dest_level_defined = dest_texture->GetLevelSize( | 10065 bool dest_level_defined = dest_texture->GetLevelSize( |
| 10061 GL_TEXTURE_2D, level, &dest_width, &dest_height); | 10066 GL_TEXTURE_2D, level, &dest_width, &dest_height); |
| 10062 | 10067 |
| 10063 if (dest_level_defined) { | 10068 if (dest_level_defined) { |
| 10064 dest_texture->GetLevelType(GL_TEXTURE_2D, level, &dest_type_previous, | 10069 dest_texture->GetLevelType(GL_TEXTURE_2D, level, &dest_type_previous, |
| 10065 &dest_internal_format); | 10070 &dest_internal_format); |
| 10066 } | 10071 } |
| 10067 | 10072 |
| 10073 // The destination format should be GL_ALPHA, GL_RGB, GL_RGBA, GL_LUMINANCE, |
| 10074 // or GL_LUMINANCE_ALPHA. |
| 10075 bool valid_dest_format = dest_internal_format >= GL_ALPHA && |
| 10076 dest_internal_format <= GL_LUMINANCE_ALPHA; |
| 10077 // The source format can be GL_BGRA_EXT. |
| 10078 bool valid_source_format = (source_internal_format >= GL_ALPHA && |
| 10079 source_internal_format <= GL_LUMINANCE_ALPHA) || |
| 10080 source_internal_format == GL_BGRA_EXT; |
| 10081 if (!valid_source_format || !valid_dest_format) { |
| 10082 LOCAL_SET_GL_ERROR( |
| 10083 GL_INVALID_VALUE, "glCopyTextureCHROMIUM", "invalid internal format"); |
| 10084 return; |
| 10085 } |
| 10086 |
| 10068 // Resize the destination texture to the dimensions of the source texture. | 10087 // Resize the destination texture to the dimensions of the source texture. |
| 10069 if (!dest_level_defined || dest_width != source_width || | 10088 if (!dest_level_defined || dest_width != source_width || |
| 10070 dest_height != source_height || | 10089 dest_height != source_height || |
| 10071 dest_internal_format != internal_format || | 10090 dest_internal_format != internal_format || |
| 10072 dest_type_previous != dest_type) { | 10091 dest_type_previous != dest_type) { |
| 10073 // Ensure that the glTexImage2D succeeds. | 10092 // Ensure that the glTexImage2D succeeds. |
| 10074 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("glCopyTextureCHROMIUM"); | 10093 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("glCopyTextureCHROMIUM"); |
| 10075 glBindTexture(GL_TEXTURE_2D, dest_texture->service_id()); | 10094 glBindTexture(GL_TEXTURE_2D, dest_texture->service_id()); |
| 10076 glTexImage2D( | 10095 glTexImage2D( |
| 10077 GL_TEXTURE_2D, level, internal_format, source_width, source_height, | 10096 GL_TEXTURE_2D, level, internal_format, source_width, source_height, |
| (...skipping 20 matching lines...) Expand all Loading... |
| 10098 if (source_texture->target() == GL_TEXTURE_EXTERNAL_OES) { | 10117 if (source_texture->target() == GL_TEXTURE_EXTERNAL_OES) { |
| 10099 // TODO(hkuang): get the StreamTexture transform matrix in GPU process | 10118 // TODO(hkuang): get the StreamTexture transform matrix in GPU process |
| 10100 // instead of using default matrix crbug.com/226218. | 10119 // instead of using default matrix crbug.com/226218. |
| 10101 const static GLfloat default_matrix[16] = {1.0f, 0.0f, 0.0f, 0.0f, | 10120 const static GLfloat default_matrix[16] = {1.0f, 0.0f, 0.0f, 0.0f, |
| 10102 0.0f, 1.0f, 0.0f, 0.0f, | 10121 0.0f, 1.0f, 0.0f, 0.0f, |
| 10103 0.0f, 0.0f, 1.0f, 0.0f, | 10122 0.0f, 0.0f, 1.0f, 0.0f, |
| 10104 0.0f, 0.0f, 0.0f, 1.0f}; | 10123 0.0f, 0.0f, 0.0f, 1.0f}; |
| 10105 copy_texture_CHROMIUM_->DoCopyTextureWithTransform( | 10124 copy_texture_CHROMIUM_->DoCopyTextureWithTransform( |
| 10106 this, | 10125 this, |
| 10107 source_texture->target(), | 10126 source_texture->target(), |
| 10108 dest_texture->target(), | |
| 10109 source_texture->service_id(), | 10127 source_texture->service_id(), |
| 10110 dest_texture->service_id(), level, | 10128 dest_texture->service_id(), |
| 10111 source_width, source_height, | 10129 level, |
| 10130 source_width, |
| 10131 source_height, |
| 10112 unpack_flip_y_, | 10132 unpack_flip_y_, |
| 10113 unpack_premultiply_alpha_, | 10133 unpack_premultiply_alpha_, |
| 10114 unpack_unpremultiply_alpha_, | 10134 unpack_unpremultiply_alpha_, |
| 10115 default_matrix); | 10135 default_matrix); |
| 10116 } else { | 10136 } else { |
| 10117 copy_texture_CHROMIUM_->DoCopyTexture( | 10137 copy_texture_CHROMIUM_->DoCopyTexture(this, |
| 10118 this, | 10138 source_texture->target(), |
| 10119 source_texture->target(), | 10139 source_texture->service_id(), |
| 10120 dest_texture->target(), | 10140 source_internal_format, |
| 10121 source_texture->service_id(), | 10141 dest_texture->service_id(), |
| 10122 dest_texture->service_id(), level, | 10142 level, |
| 10123 source_width, source_height, | 10143 internal_format, |
| 10124 unpack_flip_y_, | 10144 source_width, |
| 10125 unpack_premultiply_alpha_, | 10145 source_height, |
| 10126 unpack_unpremultiply_alpha_); | 10146 unpack_flip_y_, |
| 10147 unpack_premultiply_alpha_, |
| 10148 unpack_unpremultiply_alpha_); |
| 10127 } | 10149 } |
| 10128 | 10150 |
| 10129 DoDidUseTexImageIfNeeded(source_texture, source_texture->target()); | 10151 DoDidUseTexImageIfNeeded(source_texture, source_texture->target()); |
| 10130 } | 10152 } |
| 10131 | 10153 |
| 10132 static GLenum ExtractTypeFromStorageFormat(GLenum internalformat) { | 10154 static GLenum ExtractTypeFromStorageFormat(GLenum internalformat) { |
| 10133 switch (internalformat) { | 10155 switch (internalformat) { |
| 10134 case GL_RGB565: | 10156 case GL_RGB565: |
| 10135 return GL_UNSIGNED_SHORT_5_6_5; | 10157 return GL_UNSIGNED_SHORT_5_6_5; |
| 10136 case GL_RGBA4: | 10158 case GL_RGBA4: |
| (...skipping 795 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10932 } | 10954 } |
| 10933 } | 10955 } |
| 10934 | 10956 |
| 10935 // Include the auto-generated part of this file. We split this because it means | 10957 // Include the auto-generated part of this file. We split this because it means |
| 10936 // we can easily edit the non-auto generated parts right here in this file | 10958 // we can easily edit the non-auto generated parts right here in this file |
| 10937 // instead of having to edit some template or the code generator. | 10959 // instead of having to edit some template or the code generator. |
| 10938 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" | 10960 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" |
| 10939 | 10961 |
| 10940 } // namespace gles2 | 10962 } // namespace gles2 |
| 10941 } // namespace gpu | 10963 } // namespace gpu |
| OLD | NEW |