Chromium Code Reviews| 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 <cmath> | 10 #include <cmath> |
| (...skipping 985 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 996 void DoCopyTextureCHROMIUM(GLenum target, | 996 void DoCopyTextureCHROMIUM(GLenum target, |
| 997 GLuint source_id, | 997 GLuint source_id, |
| 998 GLuint dest_id, | 998 GLuint dest_id, |
| 999 GLenum internal_format, | 999 GLenum internal_format, |
| 1000 GLenum dest_type); | 1000 GLenum dest_type); |
| 1001 | 1001 |
| 1002 void DoCopySubTextureCHROMIUM(GLenum target, | 1002 void DoCopySubTextureCHROMIUM(GLenum target, |
| 1003 GLuint source_id, | 1003 GLuint source_id, |
| 1004 GLuint dest_id, | 1004 GLuint dest_id, |
| 1005 GLint xoffset, | 1005 GLint xoffset, |
| 1006 GLint yoffset); | 1006 GLint yoffset, |
| 1007 GLint x, | |
| 1008 GLint y, | |
| 1009 GLsizei width, | |
| 1010 GLsizei height); | |
| 1007 | 1011 |
| 1008 // Wrapper for TexStorage2DEXT. | 1012 // Wrapper for TexStorage2DEXT. |
| 1009 void DoTexStorage2DEXT( | 1013 void DoTexStorage2DEXT( |
| 1010 GLenum target, | 1014 GLenum target, |
| 1011 GLint levels, | 1015 GLint levels, |
| 1012 GLenum internal_format, | 1016 GLenum internal_format, |
| 1013 GLsizei width, | 1017 GLsizei width, |
| 1014 GLsizei height); | 1018 GLsizei height); |
| 1015 | 1019 |
| 1016 void DoProduceTextureCHROMIUM(GLenum target, const GLbyte* key); | 1020 void DoProduceTextureCHROMIUM(GLenum target, const GLbyte* key); |
| (...skipping 10971 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 11988 unpack_unpremultiply_alpha_); | 11992 unpack_unpremultiply_alpha_); |
| 11989 } | 11993 } |
| 11990 | 11994 |
| 11991 DoDidUseTexImageIfNeeded(source_texture, source_texture->target()); | 11995 DoDidUseTexImageIfNeeded(source_texture, source_texture->target()); |
| 11992 } | 11996 } |
| 11993 | 11997 |
| 11994 void GLES2DecoderImpl::DoCopySubTextureCHROMIUM(GLenum target, | 11998 void GLES2DecoderImpl::DoCopySubTextureCHROMIUM(GLenum target, |
| 11995 GLuint source_id, | 11999 GLuint source_id, |
| 11996 GLuint dest_id, | 12000 GLuint dest_id, |
| 11997 GLint xoffset, | 12001 GLint xoffset, |
| 11998 GLint yoffset) { | 12002 GLint yoffset, |
| 12003 GLint x, | |
| 12004 GLint y, | |
| 12005 GLsizei width, | |
| 12006 GLsizei height) { | |
| 11999 TRACE_EVENT0("gpu", "GLES2DecoderImpl::DoCopySubTextureCHROMIUM"); | 12007 TRACE_EVENT0("gpu", "GLES2DecoderImpl::DoCopySubTextureCHROMIUM"); |
| 12000 | 12008 |
| 12001 TextureRef* source_texture_ref = GetTexture(source_id); | 12009 TextureRef* source_texture_ref = GetTexture(source_id); |
| 12002 TextureRef* dest_texture_ref = GetTexture(dest_id); | 12010 TextureRef* dest_texture_ref = GetTexture(dest_id); |
| 12003 Texture* source_texture = source_texture_ref->texture(); | 12011 Texture* source_texture = source_texture_ref->texture(); |
| 12004 Texture* dest_texture = dest_texture_ref->texture(); | 12012 Texture* dest_texture = dest_texture_ref->texture(); |
| 12005 int source_width = 0; | 12013 int source_width = 0; |
| 12006 int source_height = 0; | 12014 int source_height = 0; |
| 12007 gfx::GLImage* image = | 12015 gfx::GLImage* image = |
| 12008 source_texture->GetLevelImage(source_texture->target(), 0); | 12016 source_texture->GetLevelImage(source_texture->target(), 0); |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 12029 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glCopySubTextureCHROMIUM", | 12037 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glCopySubTextureCHROMIUM", |
| 12030 "source texture bad dimensions"); | 12038 "source texture bad dimensions"); |
| 12031 return; | 12039 return; |
| 12032 } | 12040 } |
| 12033 } | 12041 } |
| 12034 | 12042 |
| 12035 GLenum source_type = 0; | 12043 GLenum source_type = 0; |
| 12036 GLenum source_internal_format = 0; | 12044 GLenum source_internal_format = 0; |
| 12037 source_texture->GetLevelType(source_texture->target(), 0, &source_type, | 12045 source_texture->GetLevelType(source_texture->target(), 0, &source_type, |
| 12038 &source_internal_format); | 12046 &source_internal_format); |
| 12047 if (!source_texture->ValidForTexture(source_texture->target(), 0, x, y, 0, | |
| 12048 width, height, 1, source_type)) { | |
| 12049 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glCopySubTextureCHROMIUM", | |
| 12050 "source texture bad dimensions."); | |
| 12051 return; | |
| 12052 } | |
| 12053 | |
| 12039 GLenum dest_type = 0; | 12054 GLenum dest_type = 0; |
| 12040 GLenum dest_internal_format = 0; | 12055 GLenum dest_internal_format = 0; |
| 12041 bool dest_level_defined = dest_texture->GetLevelType( | 12056 bool dest_level_defined = dest_texture->GetLevelType( |
| 12042 dest_texture->target(), 0, &dest_type, &dest_internal_format); | 12057 dest_texture->target(), 0, &dest_type, &dest_internal_format); |
| 12043 if (!dest_level_defined) { | 12058 if (!dest_level_defined) { |
| 12044 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, "glCopySubTextureCHROMIUM", | 12059 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, "glCopySubTextureCHROMIUM", |
| 12045 "destination texture is not defined"); | 12060 "destination texture is not defined"); |
| 12046 return; | 12061 return; |
| 12047 } | 12062 } |
| 12048 if (!dest_texture->ValidForTexture(dest_texture->target(), 0, xoffset, | 12063 if (!dest_texture->ValidForTexture(dest_texture->target(), 0, xoffset, |
| 12049 yoffset, 0, source_width, source_height, | 12064 yoffset, 0, width, height, 1, dest_type)) { |
| 12050 1, dest_type)) { | |
| 12051 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glCopySubTextureCHROMIUM", | 12065 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glCopySubTextureCHROMIUM", |
| 12052 "destination texture bad dimensions."); | 12066 "destination texture bad dimensions."); |
| 12053 return; | 12067 return; |
| 12054 } | 12068 } |
| 12055 | 12069 |
| 12056 if (!ValidateCopyTextureCHROMIUM("glCopySubTextureCHROMIUM", target, | 12070 if (!ValidateCopyTextureCHROMIUM("glCopySubTextureCHROMIUM", target, |
| 12057 source_texture_ref, dest_texture_ref, | 12071 source_texture_ref, dest_texture_ref, |
| 12058 dest_internal_format)) { | 12072 dest_internal_format)) { |
| 12059 return; | 12073 return; |
| 12060 } | 12074 } |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 12076 RestoreCurrentFramebufferBindings(); | 12090 RestoreCurrentFramebufferBindings(); |
| 12077 if (LOCAL_PEEK_GL_ERROR("glCopySubTextureCHROMIUM") != GL_NO_ERROR) | 12091 if (LOCAL_PEEK_GL_ERROR("glCopySubTextureCHROMIUM") != GL_NO_ERROR) |
| 12078 return; | 12092 return; |
| 12079 } | 12093 } |
| 12080 | 12094 |
| 12081 int dest_width = 0; | 12095 int dest_width = 0; |
| 12082 int dest_height = 0; | 12096 int dest_height = 0; |
| 12083 bool ok = dest_texture->GetLevelSize( | 12097 bool ok = dest_texture->GetLevelSize( |
| 12084 GL_TEXTURE_2D, 0, &dest_width, &dest_height, nullptr); | 12098 GL_TEXTURE_2D, 0, &dest_width, &dest_height, nullptr); |
| 12085 DCHECK(ok); | 12099 DCHECK(ok); |
| 12086 if (xoffset != 0 || yoffset != 0 || source_width != dest_width || | 12100 if (xoffset != 0 || yoffset != 0 || width != dest_width || |
| 12087 source_height != dest_height) { | 12101 height != dest_height) { |
| 12088 if (!texture_manager()->ClearTextureLevel(this, dest_texture_ref, target, | 12102 if (!texture_manager()->ClearTextureLevel(this, dest_texture_ref, target, |
| 12089 0)) { | 12103 0)) { |
| 12090 LOCAL_SET_GL_ERROR(GL_OUT_OF_MEMORY, "glCopySubTextureCHROMIUM", | 12104 LOCAL_SET_GL_ERROR(GL_OUT_OF_MEMORY, "glCopySubTextureCHROMIUM", |
| 12091 "destination texture dimensions too big"); | 12105 "destination texture dimensions too big"); |
| 12092 return; | 12106 return; |
| 12093 } | 12107 } |
| 12094 } else { | 12108 } else { |
| 12095 texture_manager()->SetLevelCleared(dest_texture_ref, GL_TEXTURE_2D, 0, | 12109 texture_manager()->SetLevelCleared(dest_texture_ref, GL_TEXTURE_2D, 0, |
| 12096 true); | 12110 true); |
| 12097 } | 12111 } |
| 12098 | 12112 |
| 12099 ScopedModifyPixels modify(dest_texture_ref); | 12113 ScopedModifyPixels modify(dest_texture_ref); |
| 12100 | 12114 |
| 12101 // Try using GLImage::CopyTexSubImage when possible. | 12115 // Try using GLImage::CopyTexSubImage when possible. |
| 12102 bool unpack_premultiply_alpha_change = | 12116 bool unpack_premultiply_alpha_change = |
| 12103 unpack_premultiply_alpha_ ^ unpack_unpremultiply_alpha_; | 12117 unpack_premultiply_alpha_ ^ unpack_unpremultiply_alpha_; |
| 12104 if (image && !unpack_flip_y_ && !unpack_premultiply_alpha_change) { | 12118 if (image && !unpack_flip_y_ && !unpack_premultiply_alpha_change) { |
| 12105 glBindTexture(GL_TEXTURE_2D, dest_texture->service_id()); | 12119 glBindTexture(GL_TEXTURE_2D, dest_texture->service_id()); |
| 12106 if (image->CopyTexSubImage(GL_TEXTURE_2D, gfx::Point(xoffset, yoffset), | 12120 if (image->CopyTexSubImage(GL_TEXTURE_2D, gfx::Point(xoffset, yoffset), |
| 12107 gfx::Rect(0, 0, source_width, source_height))) { | 12121 gfx::Rect(x, y, source_width, source_height))) { |
| 12108 return; | 12122 return; |
| 12109 } | 12123 } |
| 12110 } | 12124 } |
| 12111 | 12125 |
| 12112 DoWillUseTexImageIfNeeded(source_texture, source_texture->target()); | 12126 DoWillUseTexImageIfNeeded(source_texture, source_texture->target()); |
| 12113 | 12127 |
| 12114 // GL_TEXTURE_EXTERNAL_OES texture requires apply a transform matrix | 12128 copy_texture_CHROMIUM_->DoCopySubTexture( |
| 12115 // before presenting. | 12129 this, source_texture->target(), source_texture->service_id(), |
| 12116 if (source_texture->target() == GL_TEXTURE_EXTERNAL_OES) { | 12130 source_internal_format, dest_texture->service_id(), dest_internal_format, |
| 12117 // TODO(hkuang): get the StreamTexture transform matrix in GPU process | 12131 xoffset, yoffset, x, y, width, height, dest_width, dest_height, |
| 12118 // instead of using kIdentityMatrix crbug.com/226218. | 12132 source_width, source_height, unpack_flip_y_, unpack_premultiply_alpha_, |
|
piman
2015/05/22 21:11:03
nit: can you keep the TODO and a reference to this
reveman
2015/05/22 22:18:14
We have this TODO and bug reference in GLES2Decode
no sievers
2015/05/22 22:37:55
This stuff is a bit unfortunate. You can put a TOD
reveman
2015/05/23 18:56:13
Can we simply implement the copy in GLImage::CopyT
| |
| 12119 copy_texture_CHROMIUM_->DoCopySubTextureWithTransform( | 12133 unpack_unpremultiply_alpha_); |
| 12120 this, source_texture->target(), source_texture->service_id(), | |
| 12121 dest_texture->service_id(), xoffset, yoffset, dest_width, dest_height, | |
| 12122 source_width, source_height, unpack_flip_y_, unpack_premultiply_alpha_, | |
| 12123 unpack_unpremultiply_alpha_, kIdentityMatrix); | |
| 12124 } else { | |
| 12125 copy_texture_CHROMIUM_->DoCopySubTexture( | |
| 12126 this, source_texture->target(), source_texture->service_id(), | |
| 12127 source_internal_format, dest_texture->service_id(), | |
| 12128 dest_internal_format, xoffset, yoffset, dest_width, dest_height, | |
| 12129 source_width, source_height, unpack_flip_y_, unpack_premultiply_alpha_, | |
| 12130 unpack_unpremultiply_alpha_); | |
| 12131 } | |
| 12132 | 12134 |
| 12133 DoDidUseTexImageIfNeeded(source_texture, source_texture->target()); | 12135 DoDidUseTexImageIfNeeded(source_texture, source_texture->target()); |
| 12134 } | 12136 } |
| 12135 | 12137 |
| 12136 static GLenum ExtractTypeFromStorageFormat(GLenum internalformat) { | 12138 static GLenum ExtractTypeFromStorageFormat(GLenum internalformat) { |
| 12137 switch (internalformat) { | 12139 switch (internalformat) { |
| 12138 case GL_RGB565: | 12140 case GL_RGB565: |
| 12139 return GL_UNSIGNED_SHORT_5_6_5; | 12141 return GL_UNSIGNED_SHORT_5_6_5; |
| 12140 case GL_RGBA4: | 12142 case GL_RGBA4: |
| 12141 return GL_UNSIGNED_SHORT_4_4_4_4; | 12143 return GL_UNSIGNED_SHORT_4_4_4_4; |
| (...skipping 1136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 13278 } | 13280 } |
| 13279 } | 13281 } |
| 13280 | 13282 |
| 13281 // Include the auto-generated part of this file. We split this because it means | 13283 // Include the auto-generated part of this file. We split this because it means |
| 13282 // we can easily edit the non-auto generated parts right here in this file | 13284 // we can easily edit the non-auto generated parts right here in this file |
| 13283 // instead of having to edit some template or the code generator. | 13285 // instead of having to edit some template or the code generator. |
| 13284 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" | 13286 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" |
| 13285 | 13287 |
| 13286 } // namespace gles2 | 13288 } // namespace gles2 |
| 13287 } // namespace gpu | 13289 } // namespace gpu |
| OLD | NEW |