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

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 kbr. 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 13067 matching lines...) Expand 10 before | Expand all | Expand 10 after
13078 } 13078 }
13079 13079
13080 Texture* source_texture = source_texture_ref->texture(); 13080 Texture* source_texture = source_texture_ref->texture();
13081 Texture* dest_texture = dest_texture_ref->texture(); 13081 Texture* dest_texture = dest_texture_ref->texture();
13082 if (source_texture == dest_texture) { 13082 if (source_texture == dest_texture) {
13083 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, function_name, 13083 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, function_name,
13084 "source and destination textures are the same"); 13084 "source and destination textures are the same");
13085 return false; 13085 return false;
13086 } 13086 }
13087 13087
13088 if (dest_texture->target() != GL_TEXTURE_2D || 13088 switch (dest_texture->target()) {
13089 (source_texture->target() != GL_TEXTURE_2D && 13089 case GL_TEXTURE_2D:
13090 source_texture->target() != GL_TEXTURE_RECTANGLE_ARB && 13090 case GL_TEXTURE_RECTANGLE_ARB:
13091 source_texture->target() != GL_TEXTURE_EXTERNAL_OES)) { 13091 break;
13092 default:
13092 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, function_name, 13093 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, function_name,
13093 "invalid texture target binding"); 13094 "invalid dest texture target binding");
13095 return false;
13096 }
13097
13098 switch (source_texture->target()) {
13099 case GL_TEXTURE_2D:
13100 case GL_TEXTURE_RECTANGLE_ARB:
13101 case GL_TEXTURE_EXTERNAL_OES:
13102 break;
13103 default:
13104 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, function_name,
13105 "invalid source texture target binding");
13094 return false; 13106 return false;
13095 } 13107 }
13096 return true; 13108 return true;
13097 } 13109 }
13098 13110
13099 bool GLES2DecoderImpl::ValidateCopyTextureCHROMIUMInternalFormats( 13111 bool GLES2DecoderImpl::ValidateCopyTextureCHROMIUMInternalFormats(
13100 const char* function_name, 13112 const char* function_name,
13101 TextureRef* source_texture_ref, 13113 TextureRef* source_texture_ref,
13102 GLenum dest_internal_format) { 13114 GLenum dest_internal_format) {
13103 GLenum source_type = 0; 13115 GLenum source_type = 0;
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
13318 13330
13319 DoCopyTexImageIfNeeded(source_texture, source_target); 13331 DoCopyTexImageIfNeeded(source_texture, source_target);
13320 13332
13321 // GL_TEXTURE_EXTERNAL_OES texture requires apply a transform matrix 13333 // GL_TEXTURE_EXTERNAL_OES texture requires apply a transform matrix
13322 // before presenting. 13334 // before presenting.
13323 if (source_target == GL_TEXTURE_EXTERNAL_OES) { 13335 if (source_target == GL_TEXTURE_EXTERNAL_OES) {
13324 // TODO(hkuang): get the StreamTexture transform matrix in GPU process 13336 // TODO(hkuang): get the StreamTexture transform matrix in GPU process
13325 // instead of using kIdentityMatrix crbug.com/226218. 13337 // instead of using kIdentityMatrix crbug.com/226218.
13326 copy_texture_CHROMIUM_->DoCopyTextureWithTransform( 13338 copy_texture_CHROMIUM_->DoCopyTextureWithTransform(
13327 this, source_target, source_texture->service_id(), 13339 this, source_target, source_texture->service_id(),
13328 dest_texture->service_id(), source_width, source_height, 13340 dest_target, dest_texture->service_id(), 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 kIdentityMatrix); 13344 kIdentityMatrix);
13333 } else { 13345 } else {
13334 copy_texture_CHROMIUM_->DoCopyTexture( 13346 copy_texture_CHROMIUM_->DoCopyTexture(
13335 this, source_target, source_texture->service_id(), 13347 this, source_target, source_texture->service_id(),
13336 source_internal_format, dest_texture->service_id(), internal_format, 13348 source_internal_format, dest_target, dest_texture->service_id(),
13337 source_width, source_height, 13349 internal_format, source_width, source_height,
13338 unpack_flip_y == GL_TRUE, 13350 unpack_flip_y == GL_TRUE,
13339 unpack_premultiply_alpha == GL_TRUE, 13351 unpack_premultiply_alpha == GL_TRUE,
13340 unpack_unmultiply_alpha == GL_TRUE); 13352 unpack_unmultiply_alpha == GL_TRUE);
13341 } 13353 }
13342 } 13354 }
13343 13355
13344 void GLES2DecoderImpl::DoCopySubTextureCHROMIUM( 13356 void GLES2DecoderImpl::DoCopySubTextureCHROMIUM(
13345 GLuint source_id, 13357 GLuint source_id,
13346 GLuint dest_id, 13358 GLuint dest_id,
13347 GLint xoffset, 13359 GLint xoffset,
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
13489 gfx::Rect(x, y, width, height))) { 13501 gfx::Rect(x, y, width, height))) {
13490 return; 13502 return;
13491 } 13503 }
13492 } 13504 }
13493 13505
13494 DoCopyTexImageIfNeeded(source_texture, source_target); 13506 DoCopyTexImageIfNeeded(source_texture, source_target);
13495 13507
13496 // TODO(hkuang): get the StreamTexture transform matrix in GPU process. 13508 // TODO(hkuang): get the StreamTexture transform matrix in GPU process.
13497 // crbug.com/226218. 13509 // crbug.com/226218.
13498 copy_texture_CHROMIUM_->DoCopySubTexture( 13510 copy_texture_CHROMIUM_->DoCopySubTexture(
13499 this, source_target, source_texture->service_id(), 13511 this, source_target, source_texture->service_id(), source_internal_format,
13500 source_internal_format, dest_texture->service_id(), dest_internal_format, 13512 dest_target, dest_texture->service_id(), dest_internal_format,
13501 xoffset, yoffset, x, y, width, height, dest_width, dest_height, 13513 xoffset, yoffset, x, y, width, height, dest_width, dest_height,
13502 source_width, source_height, 13514 source_width, source_height,
13503 unpack_flip_y == GL_TRUE, 13515 unpack_flip_y == GL_TRUE,
13504 unpack_premultiply_alpha == GL_TRUE, 13516 unpack_premultiply_alpha == GL_TRUE,
13505 unpack_unmultiply_alpha == GL_TRUE); 13517 unpack_unmultiply_alpha == GL_TRUE);
13506 } 13518 }
13507 13519
13508 void GLES2DecoderImpl::DoCompressedCopyTextureCHROMIUM(GLenum target, 13520 void GLES2DecoderImpl::DoCompressedCopyTextureCHROMIUM(GLenum target,
13509 GLuint source_id, 13521 GLuint source_id,
13510 GLuint dest_id) { 13522 GLuint dest_id) {
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
13664 source_height, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 13676 source_height, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE,
13665 gfx::Rect(source_width, source_height)); 13677 gfx::Rect(source_width, source_height));
13666 13678
13667 // GL_TEXTURE_EXTERNAL_OES texture requires apply a transform matrix 13679 // GL_TEXTURE_EXTERNAL_OES texture requires apply a transform matrix
13668 // before presenting. 13680 // before presenting.
13669 if (source_texture->target() == GL_TEXTURE_EXTERNAL_OES) { 13681 if (source_texture->target() == GL_TEXTURE_EXTERNAL_OES) {
13670 // TODO(hkuang): get the StreamTexture transform matrix in GPU process 13682 // TODO(hkuang): get the StreamTexture transform matrix in GPU process
13671 // instead of using kIdentityMatrix crbug.com/226218. 13683 // instead of using kIdentityMatrix crbug.com/226218.
13672 copy_texture_CHROMIUM_->DoCopyTextureWithTransform( 13684 copy_texture_CHROMIUM_->DoCopyTextureWithTransform(
13673 this, source_texture->target(), source_texture->service_id(), 13685 this, source_texture->target(), source_texture->service_id(),
13674 dest_texture->service_id(), source_width, source_height, 13686 dest_texture->target(), dest_texture->service_id(), source_width,
13675 false, false, false, kIdentityMatrix); 13687 source_height, false, false, false, kIdentityMatrix);
13676 } else { 13688 } else {
13677 copy_texture_CHROMIUM_->DoCopyTexture( 13689 copy_texture_CHROMIUM_->DoCopyTexture(
13678 this, source_texture->target(), source_texture->service_id(), 13690 this, source_texture->target(), source_texture->service_id(),
13679 source_internal_format, dest_texture->service_id(), GL_RGBA, 13691 source_internal_format, dest_texture->target(),
13680 source_width, source_height, false, false, false); 13692 dest_texture->service_id(), GL_RGBA, source_width, source_height, false,
13693 false, false);
13681 } 13694 }
13682 } 13695 }
13683 13696
13684 void GLES2DecoderImpl::DoCompressedCopySubTextureCHROMIUM(GLenum target, 13697 void GLES2DecoderImpl::DoCompressedCopySubTextureCHROMIUM(GLenum target,
13685 GLuint source_id, 13698 GLuint source_id,
13686 GLuint dest_id, 13699 GLuint dest_id,
13687 GLint xoffset, 13700 GLint xoffset,
13688 GLint yoffset, 13701 GLint yoffset,
13689 GLint x, 13702 GLint x,
13690 GLint y, 13703 GLint y,
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
13842 } 13855 }
13843 13856
13844 TRACE_EVENT0( 13857 TRACE_EVENT0(
13845 "gpu", 13858 "gpu",
13846 "GLES2DecoderImpl::DoCompressedCopySubTextureCHROMIUM, fallback"); 13859 "GLES2DecoderImpl::DoCompressedCopySubTextureCHROMIUM, fallback");
13847 13860
13848 DoCopyTexImageIfNeeded(source_texture, source_texture->target()); 13861 DoCopyTexImageIfNeeded(source_texture, source_texture->target());
13849 13862
13850 // As a fallback, copy into a non-compressed GL_RGBA texture. 13863 // As a fallback, copy into a non-compressed GL_RGBA texture.
13851 if (dest_internal_format != GL_RGBA) { 13864 if (dest_internal_format != GL_RGBA) {
13865 DCHECK_EQ(static_cast<GLenum>(GL_TEXTURE_2D), dest_texture->target());
13866
13852 // To preserve the contents of the original destination texture we must 13867 // To preserve the contents of the original destination texture we must
13853 // first copy the original destination texture to a temporary storage, then 13868 // first copy the original destination texture to a temporary storage, then
13854 // copy it back to the original destination texture. 13869 // copy it back to the original destination texture.
13870 GLenum tmp_target = GL_TEXTURE_2D;
13855 GLuint tmp_service_id; 13871 GLuint tmp_service_id;
13856 glGenTextures(1, &tmp_service_id); 13872 glGenTextures(1, &tmp_service_id);
13857 DCHECK_NE(0u, tmp_service_id); 13873 DCHECK_NE(0u, tmp_service_id);
13858 13874
13859 glBindTexture(GL_TEXTURE_2D, tmp_service_id); 13875 glBindTexture(tmp_target, tmp_service_id);
13860 13876
13861 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("glCompressedCopyTextureCHROMIUM"); 13877 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("glCompressedCopyTextureCHROMIUM");
13862 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, dest_width, dest_height, 0, GL_RGBA, 13878 glTexImage2D(tmp_target, 0, GL_RGBA, dest_width, dest_height, 0, GL_RGBA,
13863 GL_UNSIGNED_BYTE, NULL); 13879 GL_UNSIGNED_BYTE, NULL);
13864 GLenum error = LOCAL_PEEK_GL_ERROR("glCompressedCopySubTextureCHROMIUM"); 13880 GLenum error = LOCAL_PEEK_GL_ERROR("glCompressedCopySubTextureCHROMIUM");
13865 if (error != GL_NO_ERROR) 13881 if (error != GL_NO_ERROR)
13866 return; 13882 return;
13867 13883
13868 copy_texture_CHROMIUM_->DoCopyTexture( 13884 copy_texture_CHROMIUM_->DoCopyTexture(
13869 this, dest_texture->target(), dest_texture->service_id(), 13885 this, dest_texture->target(), dest_texture->service_id(),
13870 dest_internal_format, tmp_service_id, GL_RGBA, 13886 dest_internal_format, tmp_target, tmp_service_id, GL_RGBA,
13871 dest_width, dest_height, false, false, false); 13887 dest_width, dest_height, false, false, false);
13872 13888
13873 // Redefine destination texture to use RGBA. 13889 // Redefine destination texture to use RGBA.
13874 glBindTexture(GL_TEXTURE_2D, dest_texture->service_id()); 13890 glBindTexture(dest_texture->target(), dest_texture->service_id());
13875 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("glCompressedCopyTextureCHROMIUM"); 13891 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("glCompressedCopyTextureCHROMIUM");
13876 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, dest_width, dest_height, 0, GL_RGBA, 13892 glTexImage2D(dest_texture->target(), 0, GL_RGBA, dest_width, dest_height, 0,
13877 GL_UNSIGNED_BYTE, NULL); 13893 GL_RGBA, GL_UNSIGNED_BYTE, NULL);
13878 error = LOCAL_PEEK_GL_ERROR("glCompressedCopySubTextureCHROMIUM"); 13894 error = LOCAL_PEEK_GL_ERROR("glCompressedCopySubTextureCHROMIUM");
13879 if (error != GL_NO_ERROR) 13895 if (error != GL_NO_ERROR)
13880 return; 13896 return;
13881 13897
13882 texture_manager()->SetLevelInfo( 13898 texture_manager()->SetLevelInfo(dest_texture_ref, dest_texture->target(), 0,
13883 dest_texture_ref, GL_TEXTURE_2D, 0, GL_RGBA, dest_width, dest_height, 13899 GL_RGBA, dest_width, dest_height, 1, 0,
13884 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, gfx::Rect(dest_width, dest_height)); 13900 GL_RGBA, GL_UNSIGNED_BYTE,
13901 gfx::Rect(dest_width, dest_height));
13885 13902
13886 copy_texture_CHROMIUM_->DoCopyTexture( 13903 copy_texture_CHROMIUM_->DoCopyTexture(
13887 this, GL_TEXTURE_2D, tmp_service_id, GL_RGBA, 13904 this, tmp_target, tmp_service_id, GL_RGBA,
13888 dest_texture->service_id(), GL_RGBA, 13905 dest_texture->target(), dest_texture->service_id(), GL_RGBA,
13889 dest_width, dest_height, false, false, false); 13906 dest_width, dest_height, false, false, false);
13890 13907
13891 glDeleteTextures(1, &tmp_service_id); 13908 glDeleteTextures(1, &tmp_service_id);
13892 } 13909 }
13893 13910
13894 // TODO(hkuang): get the StreamTexture transform matrix in GPU process. 13911 // TODO(hkuang): get the StreamTexture transform matrix in GPU process.
13895 // crbug.com/226218. 13912 // crbug.com/226218.
13896 copy_texture_CHROMIUM_->DoCopySubTexture( 13913 copy_texture_CHROMIUM_->DoCopySubTexture(
13897 this, source_texture->target(), source_texture->service_id(), 13914 this, source_texture->target(), source_texture->service_id(),
13898 source_internal_format, dest_texture->service_id(), GL_RGBA, 13915 source_internal_format, dest_texture->target(),
13899 xoffset, yoffset, x, y, width, height, dest_width, dest_height, 13916 dest_texture->service_id(), GL_RGBA, xoffset, yoffset, x, y, width,
13900 source_width, source_height, false, false, false); 13917 height, dest_width, dest_height, source_width, source_height, false,
13918 false, false);
13901 } 13919 }
13902 13920
13903 void GLES2DecoderImpl::DoTexStorage2DEXT( 13921 void GLES2DecoderImpl::DoTexStorage2DEXT(
13904 GLenum target, 13922 GLenum target,
13905 GLint levels, 13923 GLint levels,
13906 GLenum internal_format, 13924 GLenum internal_format,
13907 GLsizei width, 13925 GLsizei width,
13908 GLsizei height) { 13926 GLsizei height) {
13909 TRACE_EVENT2("gpu", "GLES2DecoderImpl::DoTexStorage2DEXT", 13927 TRACE_EVENT2("gpu", "GLES2DecoderImpl::DoTexStorage2DEXT",
13910 "width", width, "height", height); 13928 "width", width, "height", height);
(...skipping 1874 matching lines...) Expand 10 before | Expand all | Expand 10 after
15785 } 15803 }
15786 15804
15787 // Include the auto-generated part of this file. We split this because it means 15805 // Include the auto-generated part of this file. We split this because it means
15788 // we can easily edit the non-auto generated parts right here in this file 15806 // we can easily edit the non-auto generated parts right here in this file
15789 // instead of having to edit some template or the code generator. 15807 // instead of having to edit some template or the code generator.
15790 #include "base/macros.h" 15808 #include "base/macros.h"
15791 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" 15809 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h"
15792 15810
15793 } // namespace gles2 15811 } // namespace gles2
15794 } // namespace gpu 15812 } // namespace gpu
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698