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

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

Issue 2728343002: Refactor CopyTexture method determination (Closed)
Patch Set: fix windows build Created 3 years, 9 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
« no previous file with comments | « no previous file | gpu/command_buffer/service/gles2_cmd_decoder.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_copy_texture_chromium.h" 5 #include "gpu/command_buffer/service/gles2_cmd_copy_texture_chromium.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 10
(...skipping 700 matching lines...) Expand 10 before | Expand all | Expand 10 after
711 GLenum dest_target, 711 GLenum dest_target,
712 GLuint dest_id, 712 GLuint dest_id,
713 GLint dest_level, 713 GLint dest_level,
714 GLenum dest_internal_format, 714 GLenum dest_internal_format,
715 GLsizei width, 715 GLsizei width,
716 GLsizei height, 716 GLsizei height,
717 bool flip_y, 717 bool flip_y,
718 bool premultiply_alpha, 718 bool premultiply_alpha,
719 bool unpremultiply_alpha, 719 bool unpremultiply_alpha,
720 CopyTextureMethod method) { 720 CopyTextureMethod method) {
721 bool premultiply_alpha_change = premultiply_alpha ^ unpremultiply_alpha; 721 if (method == DIRECT_COPY) {
722 GLenum dest_binding_target =
723 gpu::gles2::GLES2Util::GLFaceTargetToTextureTarget(dest_target);
724
725 // GL_TEXTURE_RECTANGLE_ARB on FBO is supported by OpenGL, not GLES2,
726 // so restrict this to GL_TEXTURE_2D and GL_TEXTURE_CUBE_MAP.
727 if (source_target == GL_TEXTURE_2D &&
728 (dest_binding_target == GL_TEXTURE_2D ||
729 dest_binding_target == GL_TEXTURE_CUBE_MAP) &&
730 !flip_y && !premultiply_alpha_change && method == DIRECT_COPY) {
731 DoCopyTexImage2D(decoder, source_target, source_id, source_level, 722 DoCopyTexImage2D(decoder, source_target, source_id, source_level,
732 dest_target, dest_id, dest_level, dest_internal_format, 723 dest_target, dest_id, dest_level, dest_internal_format,
733 width, height, framebuffer_); 724 width, height, framebuffer_);
734 return; 725 return;
735 } 726 }
736 727
737 // Draw to level 0 of an intermediate GL_TEXTURE_2D texture. 728 // Draw to level 0 of an intermediate GL_TEXTURE_2D texture.
738 GLuint dest_texture = dest_id; 729 GLuint dest_texture = dest_id;
739 GLuint intermediate_texture = 0; 730 GLuint intermediate_texture = 0;
740 GLint original_dest_level = dest_level; 731 GLint original_dest_level = dest_level;
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
789 GLsizei width, 780 GLsizei width,
790 GLsizei height, 781 GLsizei height,
791 GLsizei dest_width, 782 GLsizei dest_width,
792 GLsizei dest_height, 783 GLsizei dest_height,
793 GLsizei source_width, 784 GLsizei source_width,
794 GLsizei source_height, 785 GLsizei source_height,
795 bool flip_y, 786 bool flip_y,
796 bool premultiply_alpha, 787 bool premultiply_alpha,
797 bool unpremultiply_alpha, 788 bool unpremultiply_alpha,
798 CopyTextureMethod method) { 789 CopyTextureMethod method) {
799 bool premultiply_alpha_change = premultiply_alpha ^ unpremultiply_alpha; 790 if (method == DIRECT_COPY) {
800 GLenum dest_binding_target =
801 gpu::gles2::GLES2Util::GLFaceTargetToTextureTarget(dest_target);
802
803 // GL_TEXTURE_RECTANGLE_ARB on FBO is supported by OpenGL, not GLES2,
804 // so restrict this to GL_TEXTURE_2D and GL_TEXTURE_CUBE_MAP.
805 if (source_target == GL_TEXTURE_2D &&
806 (dest_binding_target == GL_TEXTURE_2D ||
807 dest_binding_target == GL_TEXTURE_CUBE_MAP) &&
808 !flip_y && !premultiply_alpha_change && method == DIRECT_COPY) {
809 DoCopyTexSubImage2D(decoder, source_target, source_id, source_level, 791 DoCopyTexSubImage2D(decoder, source_target, source_id, source_level,
810 dest_target, dest_id, dest_level, xoffset, yoffset, x, 792 dest_target, dest_id, dest_level, xoffset, yoffset, x,
811 y, width, height, framebuffer_); 793 y, width, height, framebuffer_);
812 return; 794 return;
813 } 795 }
814 796
815 // Draw to level 0 of an intermediate GL_TEXTURE_2D texture. 797 // Draw to level 0 of an intermediate GL_TEXTURE_2D texture.
816 GLint dest_xoffset = xoffset; 798 GLint dest_xoffset = xoffset;
817 GLint dest_yoffset = yoffset; 799 GLint dest_yoffset = yoffset;
818 GLuint dest_texture = dest_id; 800 GLuint dest_texture = dest_id;
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after
1147 decoder->RestoreTextureUnitBindings(0); 1129 decoder->RestoreTextureUnitBindings(0);
1148 decoder->RestoreActiveTexture(); 1130 decoder->RestoreActiveTexture();
1149 decoder->RestoreProgramBindings(); 1131 decoder->RestoreProgramBindings();
1150 decoder->RestoreBufferBindings(); 1132 decoder->RestoreBufferBindings();
1151 decoder->RestoreFramebufferBindings(); 1133 decoder->RestoreFramebufferBindings();
1152 decoder->RestoreGlobalState(); 1134 decoder->RestoreGlobalState();
1153 } 1135 }
1154 1136
1155 } // namespace gles2 1137 } // namespace gles2
1156 } // namespace gpu 1138 } // namespace gpu
OLDNEW
« no previous file with comments | « no previous file | gpu/command_buffer/service/gles2_cmd_decoder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698