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 |
799 bool premultiply_alpha_change = premultiply_alpha ^ unpremultiply_alpha; | 807 bool premultiply_alpha_change = premultiply_alpha ^ unpremultiply_alpha; |
800 GLenum dest_binding_target = | 808 GLenum dest_binding_target = |
801 gpu::gles2::GLES2Util::GLFaceTargetToTextureTarget(dest_target); | 809 gpu::gles2::GLES2Util::GLFaceTargetToTextureTarget(dest_target); |
802 | 810 |
803 // GL_TEXTURE_RECTANGLE_ARB on FBO is supported by OpenGL, not GLES2, | 811 // 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. | 812 // so restrict this to GL_TEXTURE_2D and GL_TEXTURE_CUBE_MAP. |
805 if (source_target == GL_TEXTURE_2D && | 813 if (use_gl_copy_tex_sub_image_2d && source_target == GL_TEXTURE_2D && |
806 (dest_binding_target == GL_TEXTURE_2D || | 814 (dest_binding_target == GL_TEXTURE_2D || |
807 dest_binding_target == GL_TEXTURE_CUBE_MAP) && | 815 dest_binding_target == GL_TEXTURE_CUBE_MAP) && |
808 !flip_y && !premultiply_alpha_change && method == DIRECT_COPY) { | 816 !flip_y && !premultiply_alpha_change && method == DIRECT_COPY) { |
809 DoCopyTexSubImage2D(decoder, source_target, source_id, source_level, | 817 DoCopyTexSubImage2D(decoder, source_target, source_id, source_level, |
810 dest_target, dest_id, dest_level, xoffset, yoffset, x, | 818 dest_target, dest_id, dest_level, xoffset, yoffset, x, |
811 y, width, height, framebuffer_); | 819 y, width, height, framebuffer_); |
812 return; | 820 return; |
813 } | 821 } |
814 | 822 |
815 // Draw to level 0 of an intermediate GL_TEXTURE_2D texture. | 823 // Draw to level 0 of an intermediate GL_TEXTURE_2D texture. |
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1147 decoder->RestoreTextureUnitBindings(0); | 1155 decoder->RestoreTextureUnitBindings(0); |
1148 decoder->RestoreActiveTexture(); | 1156 decoder->RestoreActiveTexture(); |
1149 decoder->RestoreProgramBindings(); | 1157 decoder->RestoreProgramBindings(); |
1150 decoder->RestoreBufferBindings(); | 1158 decoder->RestoreBufferBindings(); |
1151 decoder->RestoreFramebufferBindings(); | 1159 decoder->RestoreFramebufferBindings(); |
1152 decoder->RestoreGlobalState(); | 1160 decoder->RestoreGlobalState(); |
1153 } | 1161 } |
1154 | 1162 |
1155 } // namespace gles2 | 1163 } // namespace gles2 |
1156 } // namespace gpu | 1164 } // namespace gpu |
OLD | NEW |