Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(269)

Side by Side Diff: gpu/command_buffer/service/gles2_cmd_decoder.cc

Issue 1547873002: Allow GL_TEXTURE_RECTANGLE_ARB to be the destination target for copyTextureCHROMIUM. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Comments from zmo. Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 switch (dest_texture->target()) {
13086 (source_texture->target() != GL_TEXTURE_2D && 13086 case GL_TEXTURE_2D:
13087 source_texture->target() != GL_TEXTURE_RECTANGLE_ARB && 13087 case GL_TEXTURE_RECTANGLE_ARB:
13088 source_texture->target() != GL_TEXTURE_EXTERNAL_OES)) { 13088 break;
13089 default:
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 dest texture target binding");
13091 return false; 13092 return false;
13092 } 13093 }
13093 13094
13095 switch (source_texture->target()) {
13096 case GL_TEXTURE_2D:
13097 case GL_TEXTURE_RECTANGLE_ARB:
13098 case GL_TEXTURE_EXTERNAL_OES:
13099 break;
13100 default:
13101 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, function_name,
13102 "invalid source texture target binding");
13103 return false;
13104 }
13105
13094 GLenum source_type = 0; 13106 GLenum source_type = 0;
13095 GLenum source_internal_format = 0; 13107 GLenum source_internal_format = 0;
13096 source_texture->GetLevelType(source_texture->target(), 0, &source_type, 13108 source_texture->GetLevelType(source_texture->target(), 0, &source_type,
13097 &source_internal_format); 13109 &source_internal_format);
13098 13110
13099 // The destination format should be GL_RGB, or GL_RGBA. GL_ALPHA, 13111 // The destination format should be GL_RGB, or GL_RGBA. GL_ALPHA,
13100 // GL_LUMINANCE, and GL_LUMINANCE_ALPHA are not supported because they are not 13112 // GL_LUMINANCE, and GL_LUMINANCE_ALPHA are not supported because they are not
13101 // renderable on some platforms. 13113 // renderable on some platforms.
13102 bool valid_dest_format = dest_internal_format == GL_RGB || 13114 bool valid_dest_format = dest_internal_format == GL_RGB ||
13103 dest_internal_format == GL_RGBA || 13115 dest_internal_format == GL_RGBA ||
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
13309 13321
13310 DoCopyTexImageIfNeeded(source_texture, source_target); 13322 DoCopyTexImageIfNeeded(source_texture, source_target);
13311 13323
13312 // GL_TEXTURE_EXTERNAL_OES texture requires apply a transform matrix 13324 // GL_TEXTURE_EXTERNAL_OES texture requires apply a transform matrix
13313 // before presenting. 13325 // before presenting.
13314 if (source_target == GL_TEXTURE_EXTERNAL_OES) { 13326 if (source_target == GL_TEXTURE_EXTERNAL_OES) {
13315 // TODO(hkuang): get the StreamTexture transform matrix in GPU process 13327 // TODO(hkuang): get the StreamTexture transform matrix in GPU process
13316 // instead of using kIdentityMatrix crbug.com/226218. 13328 // instead of using kIdentityMatrix crbug.com/226218.
13317 copy_texture_CHROMIUM_->DoCopyTextureWithTransform( 13329 copy_texture_CHROMIUM_->DoCopyTextureWithTransform(
13318 this, source_target, source_texture->service_id(), 13330 this, source_target, source_texture->service_id(),
13319 dest_texture->service_id(), source_width, source_height, 13331 dest_target, dest_texture->service_id(), source_width, source_height,
13320 unpack_flip_y == GL_TRUE, 13332 unpack_flip_y == GL_TRUE,
13321 unpack_premultiply_alpha == GL_TRUE, 13333 unpack_premultiply_alpha == GL_TRUE,
13322 unpack_unmultiply_alpha == GL_TRUE, 13334 unpack_unmultiply_alpha == GL_TRUE,
13323 kIdentityMatrix); 13335 kIdentityMatrix);
13324 } else { 13336 } else {
13325 copy_texture_CHROMIUM_->DoCopyTexture( 13337 copy_texture_CHROMIUM_->DoCopyTexture(
13326 this, source_target, source_texture->service_id(), 13338 this, source_target, source_texture->service_id(),
13327 source_internal_format, dest_texture->service_id(), internal_format, 13339 source_internal_format, dest_target, dest_texture->service_id(),
13328 source_width, source_height, 13340 internal_format, source_width, source_height,
13329 unpack_flip_y == GL_TRUE, 13341 unpack_flip_y == GL_TRUE,
13330 unpack_premultiply_alpha == GL_TRUE, 13342 unpack_premultiply_alpha == GL_TRUE,
13331 unpack_unmultiply_alpha == GL_TRUE); 13343 unpack_unmultiply_alpha == GL_TRUE);
13332 } 13344 }
13333 } 13345 }
13334 13346
13335 void GLES2DecoderImpl::DoCopySubTextureCHROMIUM( 13347 void GLES2DecoderImpl::DoCopySubTextureCHROMIUM(
13336 GLuint source_id, 13348 GLuint source_id,
13337 GLuint dest_id, 13349 GLuint dest_id,
13338 GLint xoffset, 13350 GLint xoffset,
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
13481 gfx::Rect(x, y, width, height))) { 13493 gfx::Rect(x, y, width, height))) {
13482 return; 13494 return;
13483 } 13495 }
13484 } 13496 }
13485 13497
13486 DoCopyTexImageIfNeeded(source_texture, source_target); 13498 DoCopyTexImageIfNeeded(source_texture, source_target);
13487 13499
13488 // TODO(hkuang): get the StreamTexture transform matrix in GPU process. 13500 // TODO(hkuang): get the StreamTexture transform matrix in GPU process.
13489 // crbug.com/226218. 13501 // crbug.com/226218.
13490 copy_texture_CHROMIUM_->DoCopySubTexture( 13502 copy_texture_CHROMIUM_->DoCopySubTexture(
13491 this, source_target, source_texture->service_id(), 13503 this, source_target, source_texture->service_id(), source_internal_format,
13492 source_internal_format, dest_texture->service_id(), dest_internal_format, 13504 dest_target, dest_texture->service_id(), dest_internal_format,
13493 xoffset, yoffset, x, y, width, height, dest_width, dest_height, 13505 xoffset, yoffset, x, y, width, height, dest_width, dest_height,
13494 source_width, source_height, 13506 source_width, source_height,
13495 unpack_flip_y == GL_TRUE, 13507 unpack_flip_y == GL_TRUE,
13496 unpack_premultiply_alpha == GL_TRUE, 13508 unpack_premultiply_alpha == GL_TRUE,
13497 unpack_unmultiply_alpha == GL_TRUE); 13509 unpack_unmultiply_alpha == GL_TRUE);
13498 } 13510 }
13499 13511
13500 void GLES2DecoderImpl::DoCompressedCopyTextureCHROMIUM(GLenum target, 13512 void GLES2DecoderImpl::DoCompressedCopyTextureCHROMIUM(GLenum target,
13501 GLuint source_id, 13513 GLuint source_id,
13502 GLuint dest_id) { 13514 GLuint dest_id) {
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
13656 source_height, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 13668 source_height, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE,
13657 gfx::Rect(source_width, source_height)); 13669 gfx::Rect(source_width, source_height));
13658 13670
13659 // GL_TEXTURE_EXTERNAL_OES texture requires apply a transform matrix 13671 // GL_TEXTURE_EXTERNAL_OES texture requires apply a transform matrix
13660 // before presenting. 13672 // before presenting.
13661 if (source_texture->target() == GL_TEXTURE_EXTERNAL_OES) { 13673 if (source_texture->target() == GL_TEXTURE_EXTERNAL_OES) {
13662 // TODO(hkuang): get the StreamTexture transform matrix in GPU process 13674 // TODO(hkuang): get the StreamTexture transform matrix in GPU process
13663 // instead of using kIdentityMatrix crbug.com/226218. 13675 // instead of using kIdentityMatrix crbug.com/226218.
13664 copy_texture_CHROMIUM_->DoCopyTextureWithTransform( 13676 copy_texture_CHROMIUM_->DoCopyTextureWithTransform(
13665 this, source_texture->target(), source_texture->service_id(), 13677 this, source_texture->target(), source_texture->service_id(),
13666 dest_texture->service_id(), source_width, source_height, 13678 dest_texture->target(), dest_texture->service_id(), source_width,
13667 false, false, false, kIdentityMatrix); 13679 source_height, false, false, false, kIdentityMatrix);
13668 } else { 13680 } else {
13669 copy_texture_CHROMIUM_->DoCopyTexture( 13681 copy_texture_CHROMIUM_->DoCopyTexture(
13670 this, source_texture->target(), source_texture->service_id(), 13682 this, source_texture->target(), source_texture->service_id(),
13671 source_internal_format, dest_texture->service_id(), GL_RGBA, 13683 source_internal_format, dest_texture->target(),
13672 source_width, source_height, false, false, false); 13684 dest_texture->service_id(), GL_RGBA, source_width, source_height, false,
13685 false, false);
13673 } 13686 }
13674 } 13687 }
13675 13688
13676 void GLES2DecoderImpl::DoCompressedCopySubTextureCHROMIUM(GLenum target, 13689 void GLES2DecoderImpl::DoCompressedCopySubTextureCHROMIUM(GLenum target,
13677 GLuint source_id, 13690 GLuint source_id,
13678 GLuint dest_id, 13691 GLuint dest_id,
13679 GLint xoffset, 13692 GLint xoffset,
13680 GLint yoffset, 13693 GLint yoffset,
13681 GLint x, 13694 GLint x,
13682 GLint y, 13695 GLint y,
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
13834 } 13847 }
13835 13848
13836 TRACE_EVENT0( 13849 TRACE_EVENT0(
13837 "gpu", 13850 "gpu",
13838 "GLES2DecoderImpl::DoCompressedCopySubTextureCHROMIUM, fallback"); 13851 "GLES2DecoderImpl::DoCompressedCopySubTextureCHROMIUM, fallback");
13839 13852
13840 DoCopyTexImageIfNeeded(source_texture, source_texture->target()); 13853 DoCopyTexImageIfNeeded(source_texture, source_texture->target());
13841 13854
13842 // As a fallback, copy into a non-compressed GL_RGBA texture. 13855 // As a fallback, copy into a non-compressed GL_RGBA texture.
13843 if (dest_internal_format != GL_RGBA) { 13856 if (dest_internal_format != GL_RGBA) {
13857 DCHECK_EQ(static_cast<GLenum>(GL_TEXTURE_2D), dest_texture->target());
13858
13844 // To preserve the contents of the original destination texture we must 13859 // To preserve the contents of the original destination texture we must
13845 // first copy the original destination texture to a temporary storage, then 13860 // first copy the original destination texture to a temporary storage, then
13846 // copy it back to the original destination texture. 13861 // copy it back to the original destination texture.
13862 GLenum tmp_target = GL_TEXTURE_2D;
13847 GLuint tmp_service_id; 13863 GLuint tmp_service_id;
13848 glGenTextures(1, &tmp_service_id); 13864 glGenTextures(1, &tmp_service_id);
13849 DCHECK_NE(0u, tmp_service_id); 13865 DCHECK_NE(0u, tmp_service_id);
13850 13866
13851 glBindTexture(GL_TEXTURE_2D, tmp_service_id); 13867 glBindTexture(tmp_target, tmp_service_id);
13852 13868
13853 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("glCompressedCopyTextureCHROMIUM"); 13869 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("glCompressedCopyTextureCHROMIUM");
13854 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, dest_width, dest_height, 0, GL_RGBA, 13870 glTexImage2D(tmp_target, 0, GL_RGBA, dest_width, dest_height, 0, GL_RGBA,
13855 GL_UNSIGNED_BYTE, NULL); 13871 GL_UNSIGNED_BYTE, NULL);
13856 GLenum error = LOCAL_PEEK_GL_ERROR("glCompressedCopySubTextureCHROMIUM"); 13872 GLenum error = LOCAL_PEEK_GL_ERROR("glCompressedCopySubTextureCHROMIUM");
13857 if (error != GL_NO_ERROR) 13873 if (error != GL_NO_ERROR)
13858 return; 13874 return;
13859 13875
13860 copy_texture_CHROMIUM_->DoCopyTexture( 13876 copy_texture_CHROMIUM_->DoCopyTexture(
13861 this, dest_texture->target(), dest_texture->service_id(), 13877 this, dest_texture->target(), dest_texture->service_id(),
13862 dest_internal_format, tmp_service_id, GL_RGBA, 13878 dest_internal_format, tmp_target, tmp_service_id, GL_RGBA,
13863 dest_width, dest_height, false, false, false); 13879 dest_width, dest_height, false, false, false);
13864 13880
13865 // Redefine destination texture to use RGBA. 13881 // Redefine destination texture to use RGBA.
13866 glBindTexture(GL_TEXTURE_2D, dest_texture->service_id()); 13882 glBindTexture(dest_texture->target(), dest_texture->service_id());
13867 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("glCompressedCopyTextureCHROMIUM"); 13883 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("glCompressedCopyTextureCHROMIUM");
13868 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, dest_width, dest_height, 0, GL_RGBA, 13884 glTexImage2D(dest_texture->target(), 0, GL_RGBA, dest_width, dest_height, 0,
13869 GL_UNSIGNED_BYTE, NULL); 13885 GL_RGBA, GL_UNSIGNED_BYTE, NULL);
13870 error = LOCAL_PEEK_GL_ERROR("glCompressedCopySubTextureCHROMIUM"); 13886 error = LOCAL_PEEK_GL_ERROR("glCompressedCopySubTextureCHROMIUM");
13871 if (error != GL_NO_ERROR) 13887 if (error != GL_NO_ERROR)
13872 return; 13888 return;
13873 13889
13874 texture_manager()->SetLevelInfo( 13890 texture_manager()->SetLevelInfo(dest_texture_ref, dest_texture->target(), 0,
13875 dest_texture_ref, GL_TEXTURE_2D, 0, GL_RGBA, dest_width, dest_height, 13891 GL_RGBA, dest_width, dest_height, 1, 0,
13876 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, gfx::Rect(dest_width, dest_height)); 13892 GL_RGBA, GL_UNSIGNED_BYTE,
13893 gfx::Rect(dest_width, dest_height));
13877 13894
13878 copy_texture_CHROMIUM_->DoCopyTexture( 13895 copy_texture_CHROMIUM_->DoCopyTexture(
13879 this, GL_TEXTURE_2D, tmp_service_id, GL_RGBA, 13896 this, tmp_target, tmp_service_id, GL_RGBA,
13880 dest_texture->service_id(), GL_RGBA, 13897 dest_texture->target(), dest_texture->service_id(), GL_RGBA,
13881 dest_width, dest_height, false, false, false); 13898 dest_width, dest_height, false, false, false);
13882 13899
13883 glDeleteTextures(1, &tmp_service_id); 13900 glDeleteTextures(1, &tmp_service_id);
13884 } 13901 }
13885 13902
13886 // TODO(hkuang): get the StreamTexture transform matrix in GPU process. 13903 // TODO(hkuang): get the StreamTexture transform matrix in GPU process.
13887 // crbug.com/226218. 13904 // crbug.com/226218.
13888 copy_texture_CHROMIUM_->DoCopySubTexture( 13905 copy_texture_CHROMIUM_->DoCopySubTexture(
13889 this, source_texture->target(), source_texture->service_id(), 13906 this, source_texture->target(), source_texture->service_id(),
13890 source_internal_format, dest_texture->service_id(), GL_RGBA, 13907 source_internal_format, dest_texture->target(),
13891 xoffset, yoffset, x, y, width, height, dest_width, dest_height, 13908 dest_texture->service_id(), GL_RGBA, xoffset, yoffset, x, y, width,
Zhenyao Mo 2016/01/05 00:52:16 OK, sorry for raising all the questions. This is
erikchen 2016/01/05 01:46:39 I moved this discussion to https://code.google.com
13892 source_width, source_height, false, false, false); 13909 height, dest_width, dest_height, source_width, source_height, false,
13910 false, false);
13893 } 13911 }
13894 13912
13895 void GLES2DecoderImpl::DoTexStorage2DEXT( 13913 void GLES2DecoderImpl::DoTexStorage2DEXT(
13896 GLenum target, 13914 GLenum target,
13897 GLint levels, 13915 GLint levels,
13898 GLenum internal_format, 13916 GLenum internal_format,
13899 GLsizei width, 13917 GLsizei width,
13900 GLsizei height) { 13918 GLsizei height) {
13901 TRACE_EVENT2("gpu", "GLES2DecoderImpl::DoTexStorage2DEXT", 13919 TRACE_EVENT2("gpu", "GLES2DecoderImpl::DoTexStorage2DEXT",
13902 "width", width, "height", height); 13920 "width", width, "height", height);
(...skipping 1874 matching lines...) Expand 10 before | Expand all | Expand 10 after
15777 } 15795 }
15778 15796
15779 // Include the auto-generated part of this file. We split this because it means 15797 // 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 15798 // 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. 15799 // instead of having to edit some template or the code generator.
15782 #include "base/macros.h" 15800 #include "base/macros.h"
15783 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" 15801 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h"
15784 15802
15785 } // namespace gles2 15803 } // namespace gles2
15786 } // namespace gpu 15804 } // namespace gpu
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698