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 <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 13064 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 13075 } | 13075 } |
| 13076 | 13076 |
| 13077 Texture* source_texture = source_texture_ref->texture(); | 13077 Texture* source_texture = source_texture_ref->texture(); |
| 13078 Texture* dest_texture = dest_texture_ref->texture(); | 13078 Texture* dest_texture = dest_texture_ref->texture(); |
| 13079 if (source_texture == dest_texture) { | 13079 if (source_texture == dest_texture) { |
| 13080 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, function_name, | 13080 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, function_name, |
| 13081 "source and destination textures are the same"); | 13081 "source and destination textures are the same"); |
| 13082 return false; | 13082 return false; |
| 13083 } | 13083 } |
| 13084 | 13084 |
| 13085 if (dest_texture->target() != GL_TEXTURE_2D || | 13085 if ((dest_texture->target() != GL_TEXTURE_2D && |
| 13086 dest_texture->target() != GL_TEXTURE_RECTANGLE_ARB) || | |
|
Zhenyao Mo
2016/01/04 22:43:54
nit: maybe use two switch statements here? Looks
erikchen
2016/01/04 23:28:52
Done.
| |
| 13086 (source_texture->target() != GL_TEXTURE_2D && | 13087 (source_texture->target() != GL_TEXTURE_2D && |
| 13087 source_texture->target() != GL_TEXTURE_RECTANGLE_ARB && | 13088 source_texture->target() != GL_TEXTURE_RECTANGLE_ARB && |
| 13088 source_texture->target() != GL_TEXTURE_EXTERNAL_OES)) { | 13089 source_texture->target() != GL_TEXTURE_EXTERNAL_OES)) { |
| 13089 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, function_name, | 13090 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, function_name, |
| 13090 "invalid texture target binding"); | 13091 "invalid texture target binding"); |
| 13091 return false; | 13092 return false; |
| 13092 } | 13093 } |
| 13093 | 13094 |
| 13094 GLenum source_type = 0; | 13095 GLenum source_type = 0; |
| 13095 GLenum source_internal_format = 0; | 13096 GLenum source_internal_format = 0; |
| (...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 13309 | 13310 |
| 13310 DoCopyTexImageIfNeeded(source_texture, source_target); | 13311 DoCopyTexImageIfNeeded(source_texture, source_target); |
| 13311 | 13312 |
| 13312 // GL_TEXTURE_EXTERNAL_OES texture requires apply a transform matrix | 13313 // GL_TEXTURE_EXTERNAL_OES texture requires apply a transform matrix |
| 13313 // before presenting. | 13314 // before presenting. |
| 13314 if (source_target == GL_TEXTURE_EXTERNAL_OES) { | 13315 if (source_target == GL_TEXTURE_EXTERNAL_OES) { |
| 13315 // TODO(hkuang): get the StreamTexture transform matrix in GPU process | 13316 // TODO(hkuang): get the StreamTexture transform matrix in GPU process |
| 13316 // instead of using kIdentityMatrix crbug.com/226218. | 13317 // instead of using kIdentityMatrix crbug.com/226218. |
| 13317 copy_texture_CHROMIUM_->DoCopyTextureWithTransform( | 13318 copy_texture_CHROMIUM_->DoCopyTextureWithTransform( |
| 13318 this, source_target, source_texture->service_id(), | 13319 this, source_target, source_texture->service_id(), |
| 13319 dest_texture->service_id(), source_width, source_height, | 13320 dest_target, dest_texture->service_id(), source_width, source_height, |
| 13320 unpack_flip_y == GL_TRUE, | 13321 unpack_flip_y == GL_TRUE, |
| 13321 unpack_premultiply_alpha == GL_TRUE, | 13322 unpack_premultiply_alpha == GL_TRUE, |
| 13322 unpack_unmultiply_alpha == GL_TRUE, | 13323 unpack_unmultiply_alpha == GL_TRUE, |
| 13323 kIdentityMatrix); | 13324 kIdentityMatrix); |
| 13324 } else { | 13325 } else { |
| 13325 copy_texture_CHROMIUM_->DoCopyTexture( | 13326 copy_texture_CHROMIUM_->DoCopyTexture( |
| 13326 this, source_target, source_texture->service_id(), | 13327 this, source_target, source_texture->service_id(), |
| 13327 source_internal_format, dest_texture->service_id(), internal_format, | 13328 source_internal_format, dest_target, dest_texture->service_id(), |
| 13328 source_width, source_height, | 13329 internal_format, source_width, source_height, |
| 13329 unpack_flip_y == GL_TRUE, | 13330 unpack_flip_y == GL_TRUE, |
| 13330 unpack_premultiply_alpha == GL_TRUE, | 13331 unpack_premultiply_alpha == GL_TRUE, |
| 13331 unpack_unmultiply_alpha == GL_TRUE); | 13332 unpack_unmultiply_alpha == GL_TRUE); |
| 13332 } | 13333 } |
| 13333 } | 13334 } |
| 13334 | 13335 |
| 13335 void GLES2DecoderImpl::DoCopySubTextureCHROMIUM( | 13336 void GLES2DecoderImpl::DoCopySubTextureCHROMIUM( |
| 13336 GLuint source_id, | 13337 GLuint source_id, |
| 13337 GLuint dest_id, | 13338 GLuint dest_id, |
| 13338 GLint xoffset, | 13339 GLint xoffset, |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 13481 gfx::Rect(x, y, width, height))) { | 13482 gfx::Rect(x, y, width, height))) { |
| 13482 return; | 13483 return; |
| 13483 } | 13484 } |
| 13484 } | 13485 } |
| 13485 | 13486 |
| 13486 DoCopyTexImageIfNeeded(source_texture, source_target); | 13487 DoCopyTexImageIfNeeded(source_texture, source_target); |
| 13487 | 13488 |
| 13488 // TODO(hkuang): get the StreamTexture transform matrix in GPU process. | 13489 // TODO(hkuang): get the StreamTexture transform matrix in GPU process. |
| 13489 // crbug.com/226218. | 13490 // crbug.com/226218. |
| 13490 copy_texture_CHROMIUM_->DoCopySubTexture( | 13491 copy_texture_CHROMIUM_->DoCopySubTexture( |
| 13491 this, source_target, source_texture->service_id(), | 13492 this, source_target, source_texture->service_id(), source_internal_format, |
| 13492 source_internal_format, dest_texture->service_id(), dest_internal_format, | 13493 dest_target, dest_texture->service_id(), dest_internal_format, |
| 13493 xoffset, yoffset, x, y, width, height, dest_width, dest_height, | 13494 xoffset, yoffset, x, y, width, height, dest_width, dest_height, |
| 13494 source_width, source_height, | 13495 source_width, source_height, |
| 13495 unpack_flip_y == GL_TRUE, | 13496 unpack_flip_y == GL_TRUE, |
| 13496 unpack_premultiply_alpha == GL_TRUE, | 13497 unpack_premultiply_alpha == GL_TRUE, |
| 13497 unpack_unmultiply_alpha == GL_TRUE); | 13498 unpack_unmultiply_alpha == GL_TRUE); |
| 13498 } | 13499 } |
| 13499 | 13500 |
| 13500 void GLES2DecoderImpl::DoCompressedCopyTextureCHROMIUM(GLenum target, | 13501 void GLES2DecoderImpl::DoCompressedCopyTextureCHROMIUM(GLenum target, |
| 13501 GLuint source_id, | 13502 GLuint source_id, |
| 13502 GLuint dest_id) { | 13503 GLuint dest_id) { |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 13656 source_height, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, | 13657 source_height, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, |
| 13657 gfx::Rect(source_width, source_height)); | 13658 gfx::Rect(source_width, source_height)); |
| 13658 | 13659 |
| 13659 // GL_TEXTURE_EXTERNAL_OES texture requires apply a transform matrix | 13660 // GL_TEXTURE_EXTERNAL_OES texture requires apply a transform matrix |
| 13660 // before presenting. | 13661 // before presenting. |
| 13661 if (source_texture->target() == GL_TEXTURE_EXTERNAL_OES) { | 13662 if (source_texture->target() == GL_TEXTURE_EXTERNAL_OES) { |
| 13662 // TODO(hkuang): get the StreamTexture transform matrix in GPU process | 13663 // TODO(hkuang): get the StreamTexture transform matrix in GPU process |
| 13663 // instead of using kIdentityMatrix crbug.com/226218. | 13664 // instead of using kIdentityMatrix crbug.com/226218. |
| 13664 copy_texture_CHROMIUM_->DoCopyTextureWithTransform( | 13665 copy_texture_CHROMIUM_->DoCopyTextureWithTransform( |
| 13665 this, source_texture->target(), source_texture->service_id(), | 13666 this, source_texture->target(), source_texture->service_id(), |
| 13666 dest_texture->service_id(), source_width, source_height, | 13667 dest_texture->target(), dest_texture->service_id(), source_width, |
| 13667 false, false, false, kIdentityMatrix); | 13668 source_height, false, false, false, kIdentityMatrix); |
| 13668 } else { | 13669 } else { |
| 13669 copy_texture_CHROMIUM_->DoCopyTexture( | 13670 copy_texture_CHROMIUM_->DoCopyTexture( |
| 13670 this, source_texture->target(), source_texture->service_id(), | 13671 this, source_texture->target(), source_texture->service_id(), |
| 13671 source_internal_format, dest_texture->service_id(), GL_RGBA, | 13672 source_internal_format, dest_texture->target(), |
| 13672 source_width, source_height, false, false, false); | 13673 dest_texture->service_id(), GL_RGBA, source_width, source_height, false, |
| 13674 false, false); | |
| 13673 } | 13675 } |
| 13674 } | 13676 } |
| 13675 | 13677 |
| 13676 void GLES2DecoderImpl::DoCompressedCopySubTextureCHROMIUM(GLenum target, | 13678 void GLES2DecoderImpl::DoCompressedCopySubTextureCHROMIUM(GLenum target, |
| 13677 GLuint source_id, | 13679 GLuint source_id, |
| 13678 GLuint dest_id, | 13680 GLuint dest_id, |
| 13679 GLint xoffset, | 13681 GLint xoffset, |
| 13680 GLint yoffset, | 13682 GLint yoffset, |
| 13681 GLint x, | 13683 GLint x, |
| 13682 GLint y, | 13684 GLint y, |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 13841 | 13843 |
| 13842 // As a fallback, copy into a non-compressed GL_RGBA texture. | 13844 // As a fallback, copy into a non-compressed GL_RGBA texture. |
| 13843 if (dest_internal_format != GL_RGBA) { | 13845 if (dest_internal_format != GL_RGBA) { |
| 13844 // To preserve the contents of the original destination texture we must | 13846 // To preserve the contents of the original destination texture we must |
| 13845 // first copy the original destination texture to a temporary storage, then | 13847 // first copy the original destination texture to a temporary storage, then |
| 13846 // copy it back to the original destination texture. | 13848 // copy it back to the original destination texture. |
| 13847 GLuint tmp_service_id; | 13849 GLuint tmp_service_id; |
| 13848 glGenTextures(1, &tmp_service_id); | 13850 glGenTextures(1, &tmp_service_id); |
| 13849 DCHECK_NE(0u, tmp_service_id); | 13851 DCHECK_NE(0u, tmp_service_id); |
| 13850 | 13852 |
| 13851 glBindTexture(GL_TEXTURE_2D, tmp_service_id); | 13853 glBindTexture(GL_TEXTURE_2D, tmp_service_id); |
|
Zhenyao Mo
2016/01/04 22:43:54
I think it's clearer if you define a variable of i
erikchen
2016/01/04 23:28:52
Done. I used the name "tmp_target" to match "tmp_s
| |
| 13852 | 13854 |
| 13853 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("glCompressedCopyTextureCHROMIUM"); | 13855 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("glCompressedCopyTextureCHROMIUM"); |
| 13854 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, dest_width, dest_height, 0, GL_RGBA, | 13856 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, dest_width, dest_height, 0, GL_RGBA, |
| 13855 GL_UNSIGNED_BYTE, NULL); | 13857 GL_UNSIGNED_BYTE, NULL); |
| 13856 GLenum error = LOCAL_PEEK_GL_ERROR("glCompressedCopySubTextureCHROMIUM"); | 13858 GLenum error = LOCAL_PEEK_GL_ERROR("glCompressedCopySubTextureCHROMIUM"); |
| 13857 if (error != GL_NO_ERROR) | 13859 if (error != GL_NO_ERROR) |
| 13858 return; | 13860 return; |
| 13859 | 13861 |
| 13860 copy_texture_CHROMIUM_->DoCopyTexture( | 13862 copy_texture_CHROMIUM_->DoCopyTexture( |
| 13861 this, dest_texture->target(), dest_texture->service_id(), | 13863 this, dest_texture->target(), dest_texture->service_id(), |
| 13862 dest_internal_format, tmp_service_id, GL_RGBA, | 13864 dest_internal_format, GL_TEXTURE_2D, tmp_service_id, GL_RGBA, |
| 13863 dest_width, dest_height, false, false, false); | 13865 dest_width, dest_height, false, false, false); |
| 13864 | 13866 |
| 13865 // Redefine destination texture to use RGBA. | 13867 // Redefine destination texture to use RGBA. |
| 13866 glBindTexture(GL_TEXTURE_2D, dest_texture->service_id()); | 13868 glBindTexture(GL_TEXTURE_2D, dest_texture->service_id()); |
|
Zhenyao Mo
2016/01/04 22:43:55
Here we have the assumption that dest_texture->tar
erikchen
2016/01/04 23:28:52
I added a DCHECK to the beginning. Note that this
| |
| 13867 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("glCompressedCopyTextureCHROMIUM"); | 13869 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("glCompressedCopyTextureCHROMIUM"); |
| 13868 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, dest_width, dest_height, 0, GL_RGBA, | 13870 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, dest_width, dest_height, 0, GL_RGBA, |
| 13869 GL_UNSIGNED_BYTE, NULL); | 13871 GL_UNSIGNED_BYTE, NULL); |
| 13870 error = LOCAL_PEEK_GL_ERROR("glCompressedCopySubTextureCHROMIUM"); | 13872 error = LOCAL_PEEK_GL_ERROR("glCompressedCopySubTextureCHROMIUM"); |
| 13871 if (error != GL_NO_ERROR) | 13873 if (error != GL_NO_ERROR) |
| 13872 return; | 13874 return; |
| 13873 | 13875 |
| 13874 texture_manager()->SetLevelInfo( | 13876 texture_manager()->SetLevelInfo( |
| 13875 dest_texture_ref, GL_TEXTURE_2D, 0, GL_RGBA, dest_width, dest_height, | 13877 dest_texture_ref, GL_TEXTURE_2D, 0, GL_RGBA, dest_width, dest_height, |
| 13876 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, gfx::Rect(dest_width, dest_height)); | 13878 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, gfx::Rect(dest_width, dest_height)); |
| 13877 | 13879 |
| 13878 copy_texture_CHROMIUM_->DoCopyTexture( | 13880 copy_texture_CHROMIUM_->DoCopyTexture( |
| 13879 this, GL_TEXTURE_2D, tmp_service_id, GL_RGBA, | 13881 this, GL_TEXTURE_2D, tmp_service_id, GL_RGBA, |
| 13880 dest_texture->service_id(), GL_RGBA, | 13882 dest_texture->target(), dest_texture->service_id(), GL_RGBA, |
| 13881 dest_width, dest_height, false, false, false); | 13883 dest_width, dest_height, false, false, false); |
| 13882 | 13884 |
| 13883 glDeleteTextures(1, &tmp_service_id); | 13885 glDeleteTextures(1, &tmp_service_id); |
| 13884 } | 13886 } |
| 13885 | 13887 |
| 13886 // TODO(hkuang): get the StreamTexture transform matrix in GPU process. | 13888 // TODO(hkuang): get the StreamTexture transform matrix in GPU process. |
| 13887 // crbug.com/226218. | 13889 // crbug.com/226218. |
| 13888 copy_texture_CHROMIUM_->DoCopySubTexture( | 13890 copy_texture_CHROMIUM_->DoCopySubTexture( |
| 13889 this, source_texture->target(), source_texture->service_id(), | 13891 this, source_texture->target(), source_texture->service_id(), |
| 13890 source_internal_format, dest_texture->service_id(), GL_RGBA, | 13892 source_internal_format, dest_texture->target(), |
| 13891 xoffset, yoffset, x, y, width, height, dest_width, dest_height, | 13893 dest_texture->service_id(), GL_RGBA, xoffset, yoffset, x, y, width, |
| 13892 source_width, source_height, false, false, false); | 13894 height, dest_width, dest_height, source_width, source_height, false, |
| 13895 false, false); | |
| 13893 } | 13896 } |
| 13894 | 13897 |
| 13895 void GLES2DecoderImpl::DoTexStorage2DEXT( | 13898 void GLES2DecoderImpl::DoTexStorage2DEXT( |
| 13896 GLenum target, | 13899 GLenum target, |
| 13897 GLint levels, | 13900 GLint levels, |
| 13898 GLenum internal_format, | 13901 GLenum internal_format, |
| 13899 GLsizei width, | 13902 GLsizei width, |
| 13900 GLsizei height) { | 13903 GLsizei height) { |
| 13901 TRACE_EVENT2("gpu", "GLES2DecoderImpl::DoTexStorage2DEXT", | 13904 TRACE_EVENT2("gpu", "GLES2DecoderImpl::DoTexStorage2DEXT", |
| 13902 "width", width, "height", height); | 13905 "width", width, "height", height); |
| (...skipping 1874 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 15777 } | 15780 } |
| 15778 | 15781 |
| 15779 // Include the auto-generated part of this file. We split this because it means | 15782 // Include the auto-generated part of this file. We split this because it means |
| 15780 // we can easily edit the non-auto generated parts right here in this file | 15783 // we can easily edit the non-auto generated parts right here in this file |
| 15781 // instead of having to edit some template or the code generator. | 15784 // instead of having to edit some template or the code generator. |
| 15782 #include "base/macros.h" | 15785 #include "base/macros.h" |
| 15783 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" | 15786 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" |
| 15784 | 15787 |
| 15785 } // namespace gles2 | 15788 } // namespace gles2 |
| 15786 } // namespace gpu | 15789 } // namespace gpu |
| OLD | NEW |