| 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 13893 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13904 bool unpack_premultiply_alpha_change = | 13904 bool unpack_premultiply_alpha_change = |
| 13905 (unpack_premultiply_alpha ^ unpack_unmultiply_alpha) != 0; | 13905 (unpack_premultiply_alpha ^ unpack_unmultiply_alpha) != 0; |
| 13906 if (image && !unpack_flip_y && !unpack_premultiply_alpha_change) { | 13906 if (image && !unpack_flip_y && !unpack_premultiply_alpha_change) { |
| 13907 glBindTexture(dest_target, dest_texture->service_id()); | 13907 glBindTexture(dest_target, dest_texture->service_id()); |
| 13908 if (image->CopyTexImage(dest_target)) | 13908 if (image->CopyTexImage(dest_target)) |
| 13909 return; | 13909 return; |
| 13910 } | 13910 } |
| 13911 | 13911 |
| 13912 DoCopyTexImageIfNeeded(source_texture, source_target); | 13912 DoCopyTexImageIfNeeded(source_texture, source_target); |
| 13913 | 13913 |
| 13914 // GL_TEXTURE_EXTERNAL_OES texture requires apply a transform matrix | 13914 // GL_TEXTURE_EXTERNAL_OES texture requires that we apply a transform matrix |
| 13915 // before presenting. | 13915 // before presenting. |
| 13916 if (source_target == GL_TEXTURE_EXTERNAL_OES) { | 13916 if (source_target == GL_TEXTURE_EXTERNAL_OES) { |
| 13917 // TODO(hkuang): get the StreamTexture transform matrix in GPU process | |
| 13918 // instead of using kIdentityMatrix crbug.com/226218. AVDACodecImage does | |
| 13919 // this correctly, but others (e.g., stream_texture_android.cc) don't. | |
| 13920 // (crbug.com/371500, crbug.com/588837) | |
| 13921 GLfloat transform_matrix[16]; | |
| 13922 memcpy(transform_matrix, kIdentityMatrix, sizeof(transform_matrix)); | |
| 13923 if (GLStreamTextureImage* image = | 13917 if (GLStreamTextureImage* image = |
| 13924 source_texture->GetLevelStreamTextureImage(GL_TEXTURE_EXTERNAL_OES, | 13918 source_texture->GetLevelStreamTextureImage(GL_TEXTURE_EXTERNAL_OES, |
| 13925 0)) { | 13919 0)) { |
| 13926 image->GetTextureMatrix(transform_matrix); | 13920 // The coordinate system of this matrix is y-up, not y-down, so a flip is |
| 13921 // needed. |
| 13922 GLfloat transform_matrix[16]; |
| 13923 image->GetFlippedTextureMatrix(transform_matrix); |
| 13924 copy_texture_CHROMIUM_->DoCopyTextureWithTransform( |
| 13925 this, source_target, source_texture->service_id(), dest_target, |
| 13926 dest_texture->service_id(), source_width, source_height, |
| 13927 unpack_flip_y == GL_TRUE, unpack_premultiply_alpha == GL_TRUE, |
| 13928 unpack_unmultiply_alpha == GL_TRUE, transform_matrix); |
| 13929 return; |
| 13927 } | 13930 } |
| 13928 copy_texture_CHROMIUM_->DoCopyTextureWithTransform( | |
| 13929 this, source_target, source_texture->service_id(), dest_target, | |
| 13930 dest_texture->service_id(), source_width, source_height, | |
| 13931 unpack_flip_y == GL_TRUE, unpack_premultiply_alpha == GL_TRUE, | |
| 13932 unpack_unmultiply_alpha == GL_TRUE, transform_matrix); | |
| 13933 } else { | |
| 13934 copy_texture_CHROMIUM_->DoCopyTexture( | |
| 13935 this, source_target, source_texture->service_id(), | |
| 13936 source_internal_format, dest_target, dest_texture->service_id(), | |
| 13937 internal_format, source_width, source_height, | |
| 13938 unpack_flip_y == GL_TRUE, | |
| 13939 unpack_premultiply_alpha == GL_TRUE, | |
| 13940 unpack_unmultiply_alpha == GL_TRUE); | |
| 13941 } | 13931 } |
| 13932 copy_texture_CHROMIUM_->DoCopyTexture( |
| 13933 this, source_target, source_texture->service_id(), source_internal_format, |
| 13934 dest_target, dest_texture->service_id(), internal_format, source_width, |
| 13935 source_height, unpack_flip_y == GL_TRUE, |
| 13936 unpack_premultiply_alpha == GL_TRUE, unpack_unmultiply_alpha == GL_TRUE); |
| 13942 } | 13937 } |
| 13943 | 13938 |
| 13944 void GLES2DecoderImpl::DoCopySubTextureCHROMIUM( | 13939 void GLES2DecoderImpl::DoCopySubTextureCHROMIUM( |
| 13945 GLuint source_id, | 13940 GLuint source_id, |
| 13946 GLuint dest_id, | 13941 GLuint dest_id, |
| 13947 GLint xoffset, | 13942 GLint xoffset, |
| 13948 GLint yoffset, | 13943 GLint yoffset, |
| 13949 GLint x, | 13944 GLint x, |
| 13950 GLint y, | 13945 GLint y, |
| 13951 GLsizei width, | 13946 GLsizei width, |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 14102 ScopedTextureBinder binder( | 14097 ScopedTextureBinder binder( |
| 14103 &state_, dest_texture->service_id(), dest_target); | 14098 &state_, dest_texture->service_id(), dest_target); |
| 14104 if (image->CopyTexSubImage(dest_target, gfx::Point(xoffset, yoffset), | 14099 if (image->CopyTexSubImage(dest_target, gfx::Point(xoffset, yoffset), |
| 14105 gfx::Rect(x, y, width, height))) { | 14100 gfx::Rect(x, y, width, height))) { |
| 14106 return; | 14101 return; |
| 14107 } | 14102 } |
| 14108 } | 14103 } |
| 14109 | 14104 |
| 14110 DoCopyTexImageIfNeeded(source_texture, source_target); | 14105 DoCopyTexImageIfNeeded(source_texture, source_target); |
| 14111 | 14106 |
| 14112 // TODO(hkuang): get the StreamTexture transform matrix in GPU process. | 14107 |
| 14113 // crbug.com/226218. | 14108 // GL_TEXTURE_EXTERNAL_OES texture requires apply a transform matrix |
| 14109 // before presenting. |
| 14110 if (source_target == GL_TEXTURE_EXTERNAL_OES) { |
| 14111 if (GLStreamTextureImage* image = |
| 14112 source_texture->GetLevelStreamTextureImage(GL_TEXTURE_EXTERNAL_OES, |
| 14113 0)) { |
| 14114 // The coordinate system of this matrix is y-up, not y-down, so a flip is |
| 14115 // needed. |
| 14116 GLfloat transform_matrix[16]; |
| 14117 image->GetFlippedTextureMatrix(transform_matrix); |
| 14118 copy_texture_CHROMIUM_->DoCopySubTextureWithTransform( |
| 14119 this, source_target, source_texture->service_id(), |
| 14120 source_internal_format, dest_target, dest_texture->service_id(), |
| 14121 dest_internal_format, xoffset, yoffset, x, y, width, height, |
| 14122 dest_width, dest_height, source_width, source_height, |
| 14123 unpack_flip_y == GL_TRUE, unpack_premultiply_alpha == GL_TRUE, |
| 14124 unpack_unmultiply_alpha == GL_TRUE, transform_matrix); |
| 14125 return; |
| 14126 } |
| 14127 } |
| 14114 copy_texture_CHROMIUM_->DoCopySubTexture( | 14128 copy_texture_CHROMIUM_->DoCopySubTexture( |
| 14115 this, source_target, source_texture->service_id(), source_internal_format, | 14129 this, source_target, source_texture->service_id(), source_internal_format, |
| 14116 dest_target, dest_texture->service_id(), dest_internal_format, | 14130 dest_target, dest_texture->service_id(), dest_internal_format, xoffset, |
| 14117 xoffset, yoffset, x, y, width, height, dest_width, dest_height, | 14131 yoffset, x, y, width, height, dest_width, dest_height, source_width, |
| 14118 source_width, source_height, | 14132 source_height, unpack_flip_y == GL_TRUE, |
| 14119 unpack_flip_y == GL_TRUE, | 14133 unpack_premultiply_alpha == GL_TRUE, unpack_unmultiply_alpha == GL_TRUE); |
| 14120 unpack_premultiply_alpha == GL_TRUE, | |
| 14121 unpack_unmultiply_alpha == GL_TRUE); | |
| 14122 } | 14134 } |
| 14123 | 14135 |
| 14124 void GLES2DecoderImpl::DoCompressedCopyTextureCHROMIUM(GLuint source_id, | 14136 void GLES2DecoderImpl::DoCompressedCopyTextureCHROMIUM(GLuint source_id, |
| 14125 GLuint dest_id) { | 14137 GLuint dest_id) { |
| 14126 TRACE_EVENT0("gpu", "GLES2DecoderImpl::DoCompressedCopyTextureCHROMIUM"); | 14138 TRACE_EVENT0("gpu", "GLES2DecoderImpl::DoCompressedCopyTextureCHROMIUM"); |
| 14127 | 14139 |
| 14128 TextureRef* source_texture_ref = GetTexture(source_id); | 14140 TextureRef* source_texture_ref = GetTexture(source_id); |
| 14129 TextureRef* dest_texture_ref = GetTexture(dest_id); | 14141 TextureRef* dest_texture_ref = GetTexture(dest_id); |
| 14130 | 14142 |
| 14131 if (!source_texture_ref || !dest_texture_ref) { | 14143 if (!source_texture_ref || !dest_texture_ref) { |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 14272 if (error != GL_NO_ERROR) { | 14284 if (error != GL_NO_ERROR) { |
| 14273 RestoreCurrentTextureBindings(&state_, dest_texture->target()); | 14285 RestoreCurrentTextureBindings(&state_, dest_texture->target()); |
| 14274 return; | 14286 return; |
| 14275 } | 14287 } |
| 14276 | 14288 |
| 14277 texture_manager()->SetLevelInfo( | 14289 texture_manager()->SetLevelInfo( |
| 14278 dest_texture_ref, dest_texture->target(), 0, GL_RGBA, source_width, | 14290 dest_texture_ref, dest_texture->target(), 0, GL_RGBA, source_width, |
| 14279 source_height, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, | 14291 source_height, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, |
| 14280 gfx::Rect(source_width, source_height)); | 14292 gfx::Rect(source_width, source_height)); |
| 14281 | 14293 |
| 14282 // GL_TEXTURE_EXTERNAL_OES texture requires apply a transform matrix | 14294 copy_texture_CHROMIUM_->DoCopyTexture( |
| 14283 // before presenting. | 14295 this, source_texture->target(), source_texture->service_id(), |
| 14284 if (source_texture->target() == GL_TEXTURE_EXTERNAL_OES) { | 14296 source_internal_format, dest_texture->target(), |
| 14285 // TODO(hkuang): get the StreamTexture transform matrix in GPU process | 14297 dest_texture->service_id(), GL_RGBA, source_width, source_height, false, |
| 14286 // instead of using kIdentityMatrix crbug.com/226218. | 14298 false, false); |
| 14287 copy_texture_CHROMIUM_->DoCopyTextureWithTransform( | |
| 14288 this, source_texture->target(), source_texture->service_id(), | |
| 14289 dest_texture->target(), dest_texture->service_id(), source_width, | |
| 14290 source_height, false, false, false, kIdentityMatrix); | |
| 14291 } else { | |
| 14292 copy_texture_CHROMIUM_->DoCopyTexture( | |
| 14293 this, source_texture->target(), source_texture->service_id(), | |
| 14294 source_internal_format, dest_texture->target(), | |
| 14295 dest_texture->service_id(), GL_RGBA, source_width, source_height, false, | |
| 14296 false, false); | |
| 14297 } | |
| 14298 } | 14299 } |
| 14299 | 14300 |
| 14300 void GLES2DecoderImpl::DoTexStorage2DEXT( | 14301 void GLES2DecoderImpl::DoTexStorage2DEXT( |
| 14301 GLenum target, | 14302 GLenum target, |
| 14302 GLint levels, | 14303 GLint levels, |
| 14303 GLenum internal_format, | 14304 GLenum internal_format, |
| 14304 GLsizei width, | 14305 GLsizei width, |
| 14305 GLsizei height) { | 14306 GLsizei height) { |
| 14306 TRACE_EVENT2("gpu", "GLES2DecoderImpl::DoTexStorage2DEXT", | 14307 TRACE_EVENT2("gpu", "GLES2DecoderImpl::DoTexStorage2DEXT", |
| 14307 "width", width, "height", height); | 14308 "width", width, "height", height); |
| (...skipping 2068 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 16376 } | 16377 } |
| 16377 | 16378 |
| 16378 // Include the auto-generated part of this file. We split this because it means | 16379 // Include the auto-generated part of this file. We split this because it means |
| 16379 // we can easily edit the non-auto generated parts right here in this file | 16380 // we can easily edit the non-auto generated parts right here in this file |
| 16380 // instead of having to edit some template or the code generator. | 16381 // instead of having to edit some template or the code generator. |
| 16381 #include "base/macros.h" | 16382 #include "base/macros.h" |
| 16382 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" | 16383 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" |
| 16383 | 16384 |
| 16384 } // namespace gles2 | 16385 } // namespace gles2 |
| 16385 } // namespace gpu | 16386 } // namespace gpu |
| OLD | NEW |