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_decoder.h" | 5 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" |
6 | 6 |
7 #include <stdio.h> | 7 #include <stdio.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <list> | 10 #include <list> |
(...skipping 1672 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1683 const char* filename, int line, const std::string& msg); | 1683 const char* filename, int line, const std::string& msg); |
1684 | 1684 |
1685 const FeatureInfo::FeatureFlags& features() const { | 1685 const FeatureInfo::FeatureFlags& features() const { |
1686 return feature_info_->feature_flags(); | 1686 return feature_info_->feature_flags(); |
1687 } | 1687 } |
1688 | 1688 |
1689 const FeatureInfo::Workarounds& workarounds() const { | 1689 const FeatureInfo::Workarounds& workarounds() const { |
1690 return feature_info_->workarounds(); | 1690 return feature_info_->workarounds(); |
1691 } | 1691 } |
1692 | 1692 |
| 1693 const gfx::GLVersionInfo& gl_version() const { |
| 1694 return feature_info_->gl_version_info(); |
| 1695 } |
| 1696 |
1693 bool ShouldDeferDraws() { | 1697 bool ShouldDeferDraws() { |
1694 return !offscreen_target_frame_buffer_.get() && | 1698 return !offscreen_target_frame_buffer_.get() && |
1695 framebuffer_state_.bound_draw_framebuffer.get() == NULL && | 1699 framebuffer_state_.bound_draw_framebuffer.get() == NULL && |
1696 surface_->DeferDraws(); | 1700 surface_->DeferDraws(); |
1697 } | 1701 } |
1698 | 1702 |
1699 bool ShouldDeferReads() { | 1703 bool ShouldDeferReads() { |
1700 return !offscreen_target_frame_buffer_.get() && | 1704 return !offscreen_target_frame_buffer_.get() && |
1701 framebuffer_state_.bound_read_framebuffer.get() == NULL && | 1705 framebuffer_state_.bound_read_framebuffer.get() == NULL && |
1702 surface_->DeferDraws(); | 1706 surface_->DeferDraws(); |
(...skipping 1029 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2732 // make it appear RGB. If on the other hand we ask for RGBA nd get RGB we | 2736 // make it appear RGB. If on the other hand we ask for RGBA nd get RGB we |
2733 // can't do anything about that. | 2737 // can't do anything about that. |
2734 | 2738 |
2735 if (!surfaceless_) { | 2739 if (!surfaceless_) { |
2736 GLint alpha_bits = 0; | 2740 GLint alpha_bits = 0; |
2737 GLint depth_bits = 0; | 2741 GLint depth_bits = 0; |
2738 GLint stencil_bits = 0; | 2742 GLint stencil_bits = 0; |
2739 | 2743 |
2740 bool default_fb = (GetBackbufferServiceId() == 0); | 2744 bool default_fb = (GetBackbufferServiceId() == 0); |
2741 | 2745 |
2742 if (feature_info_->gl_version_info().is_desktop_core_profile) { | 2746 if (gl_version().is_desktop_core_profile) { |
2743 glGetFramebufferAttachmentParameterivEXT( | 2747 glGetFramebufferAttachmentParameterivEXT( |
2744 GL_FRAMEBUFFER, | 2748 GL_FRAMEBUFFER, |
2745 default_fb ? GL_BACK_LEFT : GL_COLOR_ATTACHMENT0, | 2749 default_fb ? GL_BACK_LEFT : GL_COLOR_ATTACHMENT0, |
2746 GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE, &alpha_bits); | 2750 GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE, &alpha_bits); |
2747 glGetFramebufferAttachmentParameterivEXT( | 2751 glGetFramebufferAttachmentParameterivEXT( |
2748 GL_FRAMEBUFFER, | 2752 GL_FRAMEBUFFER, |
2749 default_fb ? GL_DEPTH : GL_DEPTH_ATTACHMENT, | 2753 default_fb ? GL_DEPTH : GL_DEPTH_ATTACHMENT, |
2750 GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE, &depth_bits); | 2754 GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE, &depth_bits); |
2751 glGetFramebufferAttachmentParameterivEXT( | 2755 glGetFramebufferAttachmentParameterivEXT( |
2752 GL_FRAMEBUFFER, | 2756 GL_FRAMEBUFFER, |
(...skipping 18 matching lines...) Expand all Loading... |
2771 state_.viewport_width = surface->GetSize().width(); | 2775 state_.viewport_width = surface->GetSize().width(); |
2772 state_.viewport_height = surface->GetSize().height(); | 2776 state_.viewport_height = surface->GetSize().height(); |
2773 } | 2777 } |
2774 | 2778 |
2775 // OpenGL ES 2.0 implicitly enables the desktop GL capability | 2779 // OpenGL ES 2.0 implicitly enables the desktop GL capability |
2776 // VERTEX_PROGRAM_POINT_SIZE and doesn't expose this enum. This fact | 2780 // VERTEX_PROGRAM_POINT_SIZE and doesn't expose this enum. This fact |
2777 // isn't well documented; it was discovered in the Khronos OpenGL ES | 2781 // isn't well documented; it was discovered in the Khronos OpenGL ES |
2778 // mailing list archives. It also implicitly enables the desktop GL | 2782 // mailing list archives. It also implicitly enables the desktop GL |
2779 // capability GL_POINT_SPRITE to provide access to the gl_PointCoord | 2783 // capability GL_POINT_SPRITE to provide access to the gl_PointCoord |
2780 // variable in fragment shaders. | 2784 // variable in fragment shaders. |
2781 if (!feature_info_->gl_version_info().BehavesLikeGLES()) { | 2785 if (!gl_version().BehavesLikeGLES()) { |
2782 glEnable(GL_VERTEX_PROGRAM_POINT_SIZE); | 2786 glEnable(GL_VERTEX_PROGRAM_POINT_SIZE); |
2783 glEnable(GL_POINT_SPRITE); | 2787 glEnable(GL_POINT_SPRITE); |
2784 } | 2788 } |
2785 | 2789 |
2786 has_robustness_extension_ = | 2790 has_robustness_extension_ = |
2787 context->HasExtension("GL_ARB_robustness") || | 2791 context->HasExtension("GL_ARB_robustness") || |
2788 context->HasExtension("GL_KHR_robustness") || | 2792 context->HasExtension("GL_KHR_robustness") || |
2789 context->HasExtension("GL_EXT_robustness"); | 2793 context->HasExtension("GL_EXT_robustness"); |
2790 | 2794 |
2791 if (!InitializeShaderTranslator()) { | 2795 if (!InitializeShaderTranslator()) { |
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3009 } else { | 3013 } else { |
3010 shader_spec = unsafe_es3_apis_enabled() ? SH_GLES3_SPEC : SH_GLES2_SPEC; | 3014 shader_spec = unsafe_es3_apis_enabled() ? SH_GLES3_SPEC : SH_GLES2_SPEC; |
3011 } | 3015 } |
3012 | 3016 |
3013 if ((shader_spec == SH_WEBGL_SPEC || shader_spec == SH_WEBGL2_SPEC) && | 3017 if ((shader_spec == SH_WEBGL_SPEC || shader_spec == SH_WEBGL2_SPEC) && |
3014 features().enable_shader_name_hashing) | 3018 features().enable_shader_name_hashing) |
3015 resources.HashFunction = &CityHash64; | 3019 resources.HashFunction = &CityHash64; |
3016 else | 3020 else |
3017 resources.HashFunction = NULL; | 3021 resources.HashFunction = NULL; |
3018 ShaderTranslatorInterface::GlslImplementationType implementation_type = | 3022 ShaderTranslatorInterface::GlslImplementationType implementation_type = |
3019 gfx::GetGLImplementation() == gfx::kGLImplementationEGLGLES2 ? | 3023 ShaderTranslatorInterface::kGlsl; |
3020 ShaderTranslatorInterface::kGlslES : ShaderTranslatorInterface::kGlsl; | 3024 if (gl_version().is_es) |
| 3025 implementation_type = ShaderTranslatorInterface::kGlslES; |
| 3026 else if (gl_version().is_desktop_core_profile) |
| 3027 implementation_type = ShaderTranslatorInterface::kGlslCoreProfile; |
3021 int driver_bug_workarounds = 0; | 3028 int driver_bug_workarounds = 0; |
3022 if (workarounds().needs_glsl_built_in_function_emulation) | 3029 if (workarounds().needs_glsl_built_in_function_emulation) |
3023 driver_bug_workarounds |= SH_EMULATE_BUILT_IN_FUNCTIONS; | 3030 driver_bug_workarounds |= SH_EMULATE_BUILT_IN_FUNCTIONS; |
3024 if (workarounds().init_gl_position_in_vertex_shader) | 3031 if (workarounds().init_gl_position_in_vertex_shader) |
3025 driver_bug_workarounds |= SH_INIT_GL_POSITION; | 3032 driver_bug_workarounds |= SH_INIT_GL_POSITION; |
3026 if (workarounds().unfold_short_circuit_as_ternary_operation) | 3033 if (workarounds().unfold_short_circuit_as_ternary_operation) |
3027 driver_bug_workarounds |= SH_UNFOLD_SHORT_CIRCUIT; | 3034 driver_bug_workarounds |= SH_UNFOLD_SHORT_CIRCUIT; |
3028 if (workarounds().init_varyings_without_static_use) | 3035 if (workarounds().init_varyings_without_static_use) |
3029 driver_bug_workarounds |= SH_INIT_VARYINGS_WITHOUT_STATIC_USE; | 3036 driver_bug_workarounds |= SH_INIT_VARYINGS_WITHOUT_STATIC_USE; |
3030 if (workarounds().unroll_for_loop_with_sampler_array_index) | 3037 if (workarounds().unroll_for_loop_with_sampler_array_index) |
(...skipping 1551 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4582 break; | 4589 break; |
4583 default: | 4590 default: |
4584 NOTREACHED(); | 4591 NOTREACHED(); |
4585 return; | 4592 return; |
4586 } | 4593 } |
4587 } | 4594 } |
4588 translated_attachments[i] = attachment; | 4595 translated_attachments[i] = attachment; |
4589 } | 4596 } |
4590 | 4597 |
4591 ScopedRenderTo do_render(framebuffer); | 4598 ScopedRenderTo do_render(framebuffer); |
4592 if (feature_info_->gl_version_info().is_es3) { | 4599 if (gl_version().is_es3) { |
4593 glInvalidateFramebuffer( | 4600 glInvalidateFramebuffer( |
4594 target, numAttachments, translated_attachments.get()); | 4601 target, numAttachments, translated_attachments.get()); |
4595 } else { | 4602 } else { |
4596 glDiscardFramebufferEXT( | 4603 glDiscardFramebufferEXT( |
4597 target, numAttachments, translated_attachments.get()); | 4604 target, numAttachments, translated_attachments.get()); |
4598 } | 4605 } |
4599 } | 4606 } |
4600 | 4607 |
4601 void GLES2DecoderImpl::DoEnableVertexAttribArray(GLuint index) { | 4608 void GLES2DecoderImpl::DoEnableVertexAttribArray(GLuint index) { |
4602 if (state_.vertex_attrib_manager->Enable(index, true)) { | 4609 if (state_.vertex_attrib_manager->Enable(index, true)) { |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4764 case GL_MAX_DRAW_BUFFERS_ARB: | 4771 case GL_MAX_DRAW_BUFFERS_ARB: |
4765 *num_written = 1; | 4772 *num_written = 1; |
4766 if (params) { | 4773 if (params) { |
4767 params[0] = group_->max_draw_buffers(); | 4774 params[0] = group_->max_draw_buffers(); |
4768 } | 4775 } |
4769 return true; | 4776 return true; |
4770 case GL_ALPHA_BITS: | 4777 case GL_ALPHA_BITS: |
4771 *num_written = 1; | 4778 *num_written = 1; |
4772 if (params) { | 4779 if (params) { |
4773 GLint v = 0; | 4780 GLint v = 0; |
4774 if (feature_info_->gl_version_info().is_desktop_core_profile) { | 4781 if (gl_version().is_desktop_core_profile) { |
4775 Framebuffer* framebuffer = | 4782 Framebuffer* framebuffer = |
4776 GetFramebufferInfoForTarget(GL_DRAW_FRAMEBUFFER_EXT); | 4783 GetFramebufferInfoForTarget(GL_DRAW_FRAMEBUFFER_EXT); |
4777 if (framebuffer) { | 4784 if (framebuffer) { |
4778 glGetFramebufferAttachmentParameterivEXT( | 4785 glGetFramebufferAttachmentParameterivEXT( |
4779 GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, | 4786 GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, |
4780 GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE, &v); | 4787 GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE, &v); |
4781 } else { | 4788 } else { |
4782 v = (back_buffer_color_format_ == GL_RGBA ? 8 : 0); | 4789 v = (back_buffer_color_format_ == GL_RGBA ? 8 : 0); |
4783 } | 4790 } |
4784 } else { | 4791 } else { |
4785 glGetIntegerv(GL_ALPHA_BITS, &v); | 4792 glGetIntegerv(GL_ALPHA_BITS, &v); |
4786 } | 4793 } |
4787 params[0] = | 4794 params[0] = |
4788 BoundFramebufferHasColorAttachmentWithAlpha(false) ? v : 0; | 4795 BoundFramebufferHasColorAttachmentWithAlpha(false) ? v : 0; |
4789 } | 4796 } |
4790 return true; | 4797 return true; |
4791 case GL_DEPTH_BITS: | 4798 case GL_DEPTH_BITS: |
4792 *num_written = 1; | 4799 *num_written = 1; |
4793 if (params) { | 4800 if (params) { |
4794 GLint v = 0; | 4801 GLint v = 0; |
4795 if (feature_info_->gl_version_info().is_desktop_core_profile) { | 4802 if (gl_version().is_desktop_core_profile) { |
4796 Framebuffer* framebuffer = | 4803 Framebuffer* framebuffer = |
4797 GetFramebufferInfoForTarget(GL_DRAW_FRAMEBUFFER_EXT); | 4804 GetFramebufferInfoForTarget(GL_DRAW_FRAMEBUFFER_EXT); |
4798 if (framebuffer) { | 4805 if (framebuffer) { |
4799 glGetFramebufferAttachmentParameterivEXT( | 4806 glGetFramebufferAttachmentParameterivEXT( |
4800 GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, | 4807 GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, |
4801 GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE, &v); | 4808 GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE, &v); |
4802 } else { | 4809 } else { |
4803 v = (back_buffer_has_depth_ ? 24 : 0); | 4810 v = (back_buffer_has_depth_ ? 24 : 0); |
4804 } | 4811 } |
4805 } else { | 4812 } else { |
4806 glGetIntegerv(GL_DEPTH_BITS, &v); | 4813 glGetIntegerv(GL_DEPTH_BITS, &v); |
4807 } | 4814 } |
4808 params[0] = BoundFramebufferHasDepthAttachment() ? v : 0; | 4815 params[0] = BoundFramebufferHasDepthAttachment() ? v : 0; |
4809 } | 4816 } |
4810 return true; | 4817 return true; |
4811 case GL_RED_BITS: | 4818 case GL_RED_BITS: |
4812 case GL_GREEN_BITS: | 4819 case GL_GREEN_BITS: |
4813 case GL_BLUE_BITS: | 4820 case GL_BLUE_BITS: |
4814 *num_written = 1; | 4821 *num_written = 1; |
4815 if (params) { | 4822 if (params) { |
4816 GLint v = 0; | 4823 GLint v = 0; |
4817 if (feature_info_->gl_version_info().is_desktop_core_profile) { | 4824 if (gl_version().is_desktop_core_profile) { |
4818 Framebuffer* framebuffer = | 4825 Framebuffer* framebuffer = |
4819 GetFramebufferInfoForTarget(GL_DRAW_FRAMEBUFFER_EXT); | 4826 GetFramebufferInfoForTarget(GL_DRAW_FRAMEBUFFER_EXT); |
4820 if (framebuffer) { | 4827 if (framebuffer) { |
4821 GLenum framebuffer_enum = 0; | 4828 GLenum framebuffer_enum = 0; |
4822 switch (pname) { | 4829 switch (pname) { |
4823 case GL_RED_BITS: | 4830 case GL_RED_BITS: |
4824 framebuffer_enum = GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE; | 4831 framebuffer_enum = GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE; |
4825 break; | 4832 break; |
4826 case GL_GREEN_BITS: | 4833 case GL_GREEN_BITS: |
4827 framebuffer_enum = GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE; | 4834 framebuffer_enum = GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE; |
(...skipping 10 matching lines...) Expand all Loading... |
4838 } else { | 4845 } else { |
4839 glGetIntegerv(pname, &v); | 4846 glGetIntegerv(pname, &v); |
4840 } | 4847 } |
4841 params[0] = v; | 4848 params[0] = v; |
4842 } | 4849 } |
4843 return true; | 4850 return true; |
4844 case GL_STENCIL_BITS: | 4851 case GL_STENCIL_BITS: |
4845 *num_written = 1; | 4852 *num_written = 1; |
4846 if (params) { | 4853 if (params) { |
4847 GLint v = 0; | 4854 GLint v = 0; |
4848 if (feature_info_->gl_version_info().is_desktop_core_profile) { | 4855 if (gl_version().is_desktop_core_profile) { |
4849 Framebuffer* framebuffer = | 4856 Framebuffer* framebuffer = |
4850 GetFramebufferInfoForTarget(GL_DRAW_FRAMEBUFFER_EXT); | 4857 GetFramebufferInfoForTarget(GL_DRAW_FRAMEBUFFER_EXT); |
4851 if (framebuffer) { | 4858 if (framebuffer) { |
4852 glGetFramebufferAttachmentParameterivEXT( | 4859 glGetFramebufferAttachmentParameterivEXT( |
4853 GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, | 4860 GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, |
4854 GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE, &v); | 4861 GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE, &v); |
4855 } else { | 4862 } else { |
4856 v = (back_buffer_has_stencil_ ? 8 : 0); | 4863 v = (back_buffer_has_stencil_ ? 8 : 0); |
4857 } | 4864 } |
4858 } else { | 4865 } else { |
(...skipping 823 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5682 GLint srcX1, | 5689 GLint srcX1, |
5683 GLint srcY1, | 5690 GLint srcY1, |
5684 GLint dstX0, | 5691 GLint dstX0, |
5685 GLint dstY0, | 5692 GLint dstY0, |
5686 GLint dstX1, | 5693 GLint dstX1, |
5687 GLint dstY1, | 5694 GLint dstY1, |
5688 GLbitfield mask, | 5695 GLbitfield mask, |
5689 GLenum filter) { | 5696 GLenum filter) { |
5690 // TODO(sievers): This could be resolved at the GL binding level, but the | 5697 // TODO(sievers): This could be resolved at the GL binding level, but the |
5691 // binding process is currently a bit too 'brute force'. | 5698 // binding process is currently a bit too 'brute force'. |
5692 if (feature_info_->gl_version_info().is_angle) { | 5699 if (gl_version().is_angle) { |
5693 glBlitFramebufferANGLE( | 5700 glBlitFramebufferANGLE( |
5694 srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter); | 5701 srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter); |
5695 } else if (feature_info_->feature_flags().use_core_framebuffer_multisample) { | 5702 } else if (feature_info_->feature_flags().use_core_framebuffer_multisample) { |
5696 glBlitFramebuffer( | 5703 glBlitFramebuffer( |
5697 srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter); | 5704 srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter); |
5698 } else { | 5705 } else { |
5699 glBlitFramebufferEXT( | 5706 glBlitFramebufferEXT( |
5700 srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter); | 5707 srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter); |
5701 } | 5708 } |
5702 } | 5709 } |
(...skipping 994 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6697 max_vertex_accessed, | 6704 max_vertex_accessed, |
6698 instanced, | 6705 instanced, |
6699 primcount); | 6706 primcount); |
6700 } | 6707 } |
6701 | 6708 |
6702 bool GLES2DecoderImpl::SimulateAttrib0( | 6709 bool GLES2DecoderImpl::SimulateAttrib0( |
6703 const char* function_name, GLuint max_vertex_accessed, bool* simulated) { | 6710 const char* function_name, GLuint max_vertex_accessed, bool* simulated) { |
6704 DCHECK(simulated); | 6711 DCHECK(simulated); |
6705 *simulated = false; | 6712 *simulated = false; |
6706 | 6713 |
6707 if (feature_info_->gl_version_info().BehavesLikeGLES()) | 6714 if (gl_version().BehavesLikeGLES()) |
6708 return true; | 6715 return true; |
6709 | 6716 |
6710 const VertexAttrib* attrib = | 6717 const VertexAttrib* attrib = |
6711 state_.vertex_attrib_manager->GetVertexAttrib(0); | 6718 state_.vertex_attrib_manager->GetVertexAttrib(0); |
6712 // If it's enabled or it's not used then we don't need to do anything. | 6719 // If it's enabled or it's not used then we don't need to do anything. |
6713 bool attrib_0_used = | 6720 bool attrib_0_used = |
6714 state_.current_program->GetAttribInfoByLocation(0) != NULL; | 6721 state_.current_program->GetAttribInfoByLocation(0) != NULL; |
6715 if (attrib->enabled() && attrib_0_used) { | 6722 if (attrib->enabled() && attrib_0_used) { |
6716 return true; | 6723 return true; |
6717 } | 6724 } |
(...skipping 1336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8054 read_x, ry, read_width, 1, format, type, dst + dest_row_offset); | 8061 read_x, ry, read_width, 1, format, type, dst + dest_row_offset); |
8055 } | 8062 } |
8056 dst += padded_row_size; | 8063 dst += padded_row_size; |
8057 } | 8064 } |
8058 } else { | 8065 } else { |
8059 if (async && features().use_async_readpixels) { | 8066 if (async && features().use_async_readpixels) { |
8060 GLuint buffer = 0; | 8067 GLuint buffer = 0; |
8061 glGenBuffersARB(1, &buffer); | 8068 glGenBuffersARB(1, &buffer); |
8062 glBindBuffer(GL_PIXEL_PACK_BUFFER_ARB, buffer); | 8069 glBindBuffer(GL_PIXEL_PACK_BUFFER_ARB, buffer); |
8063 // For ANGLE client version 2, GL_STREAM_READ is not available. | 8070 // For ANGLE client version 2, GL_STREAM_READ is not available. |
8064 const GLenum usage_hint = feature_info_->gl_version_info().is_angle ? | 8071 const GLenum usage_hint = gl_version().is_angle ? |
8065 GL_STATIC_DRAW : GL_STREAM_READ; | 8072 GL_STATIC_DRAW : GL_STREAM_READ; |
8066 glBufferData(GL_PIXEL_PACK_BUFFER_ARB, pixels_size, NULL, usage_hint); | 8073 glBufferData(GL_PIXEL_PACK_BUFFER_ARB, pixels_size, NULL, usage_hint); |
8067 GLenum error = glGetError(); | 8074 GLenum error = glGetError(); |
8068 if (error == GL_NO_ERROR) { | 8075 if (error == GL_NO_ERROR) { |
8069 glReadPixels(x, y, width, height, format, type, 0); | 8076 glReadPixels(x, y, width, height, format, type, 0); |
8070 pending_readpixel_fences_.push(linked_ptr<FenceCallback>( | 8077 pending_readpixel_fences_.push(linked_ptr<FenceCallback>( |
8071 new FenceCallback())); | 8078 new FenceCallback())); |
8072 WaitForReadPixels(base::Bind( | 8079 WaitForReadPixels(base::Bind( |
8073 &GLES2DecoderImpl::FinishReadPixels, | 8080 &GLES2DecoderImpl::FinishReadPixels, |
8074 base::internal::SupportsWeakPtrBase::StaticAsWeakPtr | 8081 base::internal::SupportsWeakPtrBase::StaticAsWeakPtr |
(...skipping 2211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10286 SetServiceId(offscreen_target_color_texture_->id()); | 10293 SetServiceId(offscreen_target_color_texture_->id()); |
10287 | 10294 |
10288 offscreen_saved_color_texture_.swap(offscreen_target_color_texture_); | 10295 offscreen_saved_color_texture_.swap(offscreen_target_color_texture_); |
10289 offscreen_target_frame_buffer_->AttachRenderTexture( | 10296 offscreen_target_frame_buffer_->AttachRenderTexture( |
10290 offscreen_target_color_texture_.get()); | 10297 offscreen_target_color_texture_.get()); |
10291 } | 10298 } |
10292 | 10299 |
10293 // Ensure the side effects of the copy are visible to the parent | 10300 // Ensure the side effects of the copy are visible to the parent |
10294 // context. There is no need to do this for ANGLE because it uses a | 10301 // context. There is no need to do this for ANGLE because it uses a |
10295 // single D3D device for all contexts. | 10302 // single D3D device for all contexts. |
10296 if (!feature_info_->gl_version_info().is_angle) | 10303 if (!gl_version().is_angle) |
10297 glFlush(); | 10304 glFlush(); |
10298 } | 10305 } |
10299 } else { | 10306 } else { |
10300 if (!surface_->SwapBuffers()) { | 10307 if (!surface_->SwapBuffers()) { |
10301 LOG(ERROR) << "Context lost because SwapBuffers failed."; | 10308 LOG(ERROR) << "Context lost because SwapBuffers failed."; |
10302 LoseContext(GL_UNKNOWN_CONTEXT_RESET_ARB); | 10309 LoseContext(GL_UNKNOWN_CONTEXT_RESET_ARB); |
10303 } | 10310 } |
10304 } | 10311 } |
10305 | 10312 |
10306 // This may be a slow command. Exit command processing to allow for | 10313 // This may be a slow command. Exit command processing to allow for |
(...skipping 2229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12536 } | 12543 } |
12537 } | 12544 } |
12538 | 12545 |
12539 // Include the auto-generated part of this file. We split this because it means | 12546 // Include the auto-generated part of this file. We split this because it means |
12540 // we can easily edit the non-auto generated parts right here in this file | 12547 // we can easily edit the non-auto generated parts right here in this file |
12541 // instead of having to edit some template or the code generator. | 12548 // instead of having to edit some template or the code generator. |
12542 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" | 12549 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" |
12543 | 12550 |
12544 } // namespace gles2 | 12551 } // namespace gles2 |
12545 } // namespace gpu | 12552 } // namespace gpu |
OLD | NEW |