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_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 778 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
789 GLsizei width, | 789 GLsizei width, |
790 GLsizei height, | 790 GLsizei height, |
791 GLsizei dest_width, | 791 GLsizei dest_width, |
792 GLsizei dest_height, | 792 GLsizei dest_height, |
793 GLsizei source_width, | 793 GLsizei source_width, |
794 GLsizei source_height, | 794 GLsizei source_height, |
795 bool flip_y, | 795 bool flip_y, |
796 bool premultiply_alpha, | 796 bool premultiply_alpha, |
797 bool unpremultiply_alpha, | 797 bool unpremultiply_alpha, |
798 CopyTextureMethod method) { | 798 CopyTextureMethod method) { |
799 bool use_gl_copy_tex_sub_image_2d = true; | |
800 #if defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY) | |
801 // glDrawArrays is faster than glCopyTexSubImage2D on IA Mesa driver, | |
802 // although opposite in Android. | |
803 // TODO(dshwang): After Mesa fixes this issue, remove this hack. | |
804 // https://bugs.freedesktop.org/show_bug.cgi?id=98478 crbug.com/535198 | |
805 use_gl_copy_tex_sub_image_2d = false; | |
806 #endif | |
807 bool premultiply_alpha_change = premultiply_alpha ^ unpremultiply_alpha; | 799 bool premultiply_alpha_change = premultiply_alpha ^ unpremultiply_alpha; |
808 GLenum dest_binding_target = | 800 GLenum dest_binding_target = |
809 gpu::gles2::GLES2Util::GLFaceTargetToTextureTarget(dest_target); | 801 gpu::gles2::GLES2Util::GLFaceTargetToTextureTarget(dest_target); |
810 | 802 |
811 // GL_TEXTURE_RECTANGLE_ARB on FBO is supported by OpenGL, not GLES2, | 803 // GL_TEXTURE_RECTANGLE_ARB on FBO is supported by OpenGL, not GLES2, |
812 // so restrict this to GL_TEXTURE_2D and GL_TEXTURE_CUBE_MAP. | 804 // so restrict this to GL_TEXTURE_2D and GL_TEXTURE_CUBE_MAP. |
813 if (use_gl_copy_tex_sub_image_2d && source_target == GL_TEXTURE_2D && | 805 if (source_target == GL_TEXTURE_2D && |
814 (dest_binding_target == GL_TEXTURE_2D || | 806 (dest_binding_target == GL_TEXTURE_2D || |
815 dest_binding_target == GL_TEXTURE_CUBE_MAP) && | 807 dest_binding_target == GL_TEXTURE_CUBE_MAP) && |
816 !flip_y && !premultiply_alpha_change && method == DIRECT_COPY) { | 808 !flip_y && !premultiply_alpha_change && method == DIRECT_COPY) { |
817 DoCopyTexSubImage2D(decoder, source_target, source_id, source_level, | 809 DoCopyTexSubImage2D(decoder, source_target, source_id, source_level, |
818 dest_target, dest_id, dest_level, xoffset, yoffset, x, | 810 dest_target, dest_id, dest_level, xoffset, yoffset, x, |
819 y, width, height, framebuffer_); | 811 y, width, height, framebuffer_); |
820 return; | 812 return; |
821 } | 813 } |
822 | 814 |
823 // Draw to level 0 of an intermediate GL_TEXTURE_2D texture. | 815 // Draw to level 0 of an intermediate GL_TEXTURE_2D texture. |
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1155 decoder->RestoreTextureUnitBindings(0); | 1147 decoder->RestoreTextureUnitBindings(0); |
1156 decoder->RestoreActiveTexture(); | 1148 decoder->RestoreActiveTexture(); |
1157 decoder->RestoreProgramBindings(); | 1149 decoder->RestoreProgramBindings(); |
1158 decoder->RestoreBufferBindings(); | 1150 decoder->RestoreBufferBindings(); |
1159 decoder->RestoreFramebufferBindings(); | 1151 decoder->RestoreFramebufferBindings(); |
1160 decoder->RestoreGlobalState(); | 1152 decoder->RestoreGlobalState(); |
1161 } | 1153 } |
1162 | 1154 |
1163 } // namespace gles2 | 1155 } // namespace gles2 |
1164 } // namespace gpu | 1156 } // namespace gpu |
OLD | NEW |