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 <list> | 10 #include <list> |
| (...skipping 10029 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 10040 } | 10040 } |
| 10041 | 10041 |
| 10042 // Clear the source texture if necessary. | 10042 // Clear the source texture if necessary. |
| 10043 if (!texture_manager()->ClearTextureLevel( | 10043 if (!texture_manager()->ClearTextureLevel( |
| 10044 this, source_texture_ref, source_texture->target(), 0)) { | 10044 this, source_texture_ref, source_texture->target(), 0)) { |
| 10045 LOCAL_SET_GL_ERROR( | 10045 LOCAL_SET_GL_ERROR( |
| 10046 GL_OUT_OF_MEMORY, "glCopyTextureCHROMIUM", "dimensions too big"); | 10046 GL_OUT_OF_MEMORY, "glCopyTextureCHROMIUM", "dimensions too big"); |
| 10047 return; | 10047 return; |
| 10048 } | 10048 } |
| 10049 | 10049 |
| 10050 GLenum source_type = 0; | |
| 10051 GLenum source_internal_format = 0; | |
| 10052 source_texture->GetLevelType( | |
| 10053 source_texture->target(), 0, &source_type, &source_internal_format); | |
| 10054 | |
| 10055 // The destination format should be GL_RGB, or GL_RGBA. GL_ALPHA, | |
| 10056 // GL_LUMINANCE, and GL_LUMINANCE_ALPHA are not supported because they are not | |
| 10057 // renderable on some platforms. | |
| 10058 bool valid_dest_format = | |
| 10059 internal_format == GL_RGB || internal_format == GL_RGBA; | |
| 10060 // The source format can be GL_BGRA_EXT. | |
| 10061 bool valid_source_format = (source_internal_format >= GL_ALPHA && | |
|
no sievers
2014/08/22 18:07:19
nit: mind making this comparison more explicit? i.
dshwang
2014/08/22 19:07:54
Done.
| |
| 10062 source_internal_format <= GL_LUMINANCE_ALPHA) || | |
| 10063 source_internal_format == GL_BGRA_EXT; | |
| 10064 if (!valid_source_format || !valid_dest_format) { | |
|
no sievers
2014/08/22 18:07:19
Should we make it GL_INVALID_OPERATION if !valid_s
dshwang
2014/08/22 19:07:55
Yes! GL_INVALID_OPERATION is right.
| |
| 10065 LOCAL_SET_GL_ERROR( | |
| 10066 GL_INVALID_VALUE, "glCopyTextureCHROMIUM", "invalid internal format"); | |
| 10067 return; | |
| 10068 } | |
| 10069 | |
| 10050 // Defer initializing the CopyTextureCHROMIUMResourceManager until it is | 10070 // Defer initializing the CopyTextureCHROMIUMResourceManager until it is |
| 10051 // needed because it takes 10s of milliseconds to initialize. | 10071 // needed because it takes 10s of milliseconds to initialize. |
| 10052 if (!copy_texture_CHROMIUM_.get()) { | 10072 if (!copy_texture_CHROMIUM_.get()) { |
| 10053 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("glCopyTextureCHROMIUM"); | 10073 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("glCopyTextureCHROMIUM"); |
| 10054 copy_texture_CHROMIUM_.reset(new CopyTextureCHROMIUMResourceManager()); | 10074 copy_texture_CHROMIUM_.reset(new CopyTextureCHROMIUMResourceManager()); |
| 10055 copy_texture_CHROMIUM_->Initialize(this); | 10075 copy_texture_CHROMIUM_->Initialize(this); |
| 10056 RestoreCurrentFramebufferBindings(); | 10076 RestoreCurrentFramebufferBindings(); |
| 10057 if (LOCAL_PEEK_GL_ERROR("glCopyTextureCHROMIUM") != GL_NO_ERROR) | 10077 if (LOCAL_PEEK_GL_ERROR("glCopyTextureCHROMIUM") != GL_NO_ERROR) |
| 10058 return; | 10078 return; |
| 10059 } | 10079 } |
| 10060 | 10080 |
| 10061 GLenum source_type = 0; | |
| 10062 GLenum source_internal_format = 0; | |
| 10063 source_texture->GetLevelType( | |
| 10064 source_texture->target(), 0, &source_type, &source_internal_format); | |
| 10065 | |
| 10066 GLenum dest_type_previous = dest_type; | 10081 GLenum dest_type_previous = dest_type; |
| 10067 GLenum dest_internal_format = internal_format; | 10082 GLenum dest_internal_format = internal_format; |
| 10068 bool dest_level_defined = dest_texture->GetLevelSize( | 10083 bool dest_level_defined = dest_texture->GetLevelSize( |
| 10069 GL_TEXTURE_2D, level, &dest_width, &dest_height); | 10084 GL_TEXTURE_2D, level, &dest_width, &dest_height); |
| 10070 | 10085 |
| 10071 if (dest_level_defined) { | 10086 if (dest_level_defined) { |
| 10072 dest_texture->GetLevelType(GL_TEXTURE_2D, level, &dest_type_previous, | 10087 dest_texture->GetLevelType(GL_TEXTURE_2D, level, &dest_type_previous, |
| 10073 &dest_internal_format); | 10088 &dest_internal_format); |
| 10074 } | 10089 } |
| 10075 | 10090 |
| 10076 // The destination format should be GL_ALPHA, GL_RGB, GL_RGBA, GL_LUMINANCE, | |
| 10077 // or GL_LUMINANCE_ALPHA. | |
| 10078 bool valid_dest_format = dest_internal_format >= GL_ALPHA && | |
| 10079 dest_internal_format <= GL_LUMINANCE_ALPHA; | |
| 10080 // The source format can be GL_BGRA_EXT. | |
| 10081 bool valid_source_format = (source_internal_format >= GL_ALPHA && | |
| 10082 source_internal_format <= GL_LUMINANCE_ALPHA) || | |
| 10083 source_internal_format == GL_BGRA_EXT; | |
| 10084 if (!valid_source_format || !valid_dest_format) { | |
| 10085 LOCAL_SET_GL_ERROR( | |
| 10086 GL_INVALID_VALUE, "glCopyTextureCHROMIUM", "invalid internal format"); | |
| 10087 return; | |
| 10088 } | |
| 10089 | |
| 10090 // Resize the destination texture to the dimensions of the source texture. | 10091 // Resize the destination texture to the dimensions of the source texture. |
| 10091 if (!dest_level_defined || dest_width != source_width || | 10092 if (!dest_level_defined || dest_width != source_width || |
| 10092 dest_height != source_height || | 10093 dest_height != source_height || |
| 10093 dest_internal_format != internal_format || | 10094 dest_internal_format != internal_format || |
| 10094 dest_type_previous != dest_type) { | 10095 dest_type_previous != dest_type) { |
| 10095 // Ensure that the glTexImage2D succeeds. | 10096 // Ensure that the glTexImage2D succeeds. |
| 10096 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("glCopyTextureCHROMIUM"); | 10097 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("glCopyTextureCHROMIUM"); |
| 10097 glBindTexture(GL_TEXTURE_2D, dest_texture->service_id()); | 10098 glBindTexture(GL_TEXTURE_2D, dest_texture->service_id()); |
| 10098 glTexImage2D( | 10099 glTexImage2D( |
| 10099 GL_TEXTURE_2D, level, internal_format, source_width, source_height, | 10100 GL_TEXTURE_2D, level, internal_format, source_width, source_height, |
| (...skipping 857 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 10957 } | 10958 } |
| 10958 } | 10959 } |
| 10959 | 10960 |
| 10960 // Include the auto-generated part of this file. We split this because it means | 10961 // Include the auto-generated part of this file. We split this because it means |
| 10961 // we can easily edit the non-auto generated parts right here in this file | 10962 // we can easily edit the non-auto generated parts right here in this file |
| 10962 // instead of having to edit some template or the code generator. | 10963 // instead of having to edit some template or the code generator. |
| 10963 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" | 10964 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" |
| 10964 | 10965 |
| 10965 } // namespace gles2 | 10966 } // namespace gles2 |
| 10966 } // namespace gpu | 10967 } // namespace gpu |
| OLD | NEW |