Chromium Code Reviews| 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 <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 895 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 906 GLenum internal_format, | 906 GLenum internal_format, |
| 907 GLint x, | 907 GLint x, |
| 908 GLint y, | 908 GLint y, |
| 909 GLsizei width, | 909 GLsizei width, |
| 910 GLsizei height, | 910 GLsizei height, |
| 911 GLint border); | 911 GLint border); |
| 912 | 912 |
| 913 // Wrapper for SwapBuffers. | 913 // Wrapper for SwapBuffers. |
| 914 void DoSwapBuffers(); | 914 void DoSwapBuffers(); |
| 915 | 915 |
| 916 // Wrapper for SwapBuffersWithBoundsCHROMIUM | |
|
meacer
2017/02/02 21:42:33
nit: missing period at the end.
halliwell
2017/02/03 20:17:00
Done.
| |
| 917 void DoSwapBuffersWithBoundsCHROMIUM(GLsizei count, | |
| 918 const volatile GLint* rects); | |
| 919 | |
| 916 // Callback for async SwapBuffers. | 920 // Callback for async SwapBuffers. |
| 917 void FinishSwapBuffers(gfx::SwapResult result); | 921 void FinishSwapBuffers(gfx::SwapResult result); |
| 918 | 922 |
| 919 void DoCommitOverlayPlanes(); | 923 void DoCommitOverlayPlanes(); |
| 920 | 924 |
| 921 // Wrapper for SwapInterval. | 925 // Wrapper for SwapInterval. |
| 922 void DoSwapInterval(int interval); | 926 void DoSwapInterval(int interval); |
| 923 | 927 |
| 924 // Wrapper for CopyTexSubImage2D. | 928 // Wrapper for CopyTexSubImage2D. |
| 925 void DoCopyTexSubImage2D( | 929 void DoCopyTexSubImage2D( |
| (...skipping 1408 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2334 int frame_number_; | 2338 int frame_number_; |
| 2335 | 2339 |
| 2336 // Number of commands remaining to be processed in DoCommands(). | 2340 // Number of commands remaining to be processed in DoCommands(). |
| 2337 int commands_to_process_; | 2341 int commands_to_process_; |
| 2338 | 2342 |
| 2339 bool has_robustness_extension_; | 2343 bool has_robustness_extension_; |
| 2340 error::ContextLostReason context_lost_reason_; | 2344 error::ContextLostReason context_lost_reason_; |
| 2341 bool context_was_lost_; | 2345 bool context_was_lost_; |
| 2342 bool reset_by_robustness_extension_; | 2346 bool reset_by_robustness_extension_; |
| 2343 bool supports_post_sub_buffer_; | 2347 bool supports_post_sub_buffer_; |
| 2344 bool supports_swap_buffers_with_damage_; | 2348 bool supports_swap_buffers_with_bounds_; |
| 2345 bool supports_commit_overlay_planes_; | 2349 bool supports_commit_overlay_planes_; |
| 2346 bool supports_async_swap_; | 2350 bool supports_async_swap_; |
| 2347 | 2351 |
| 2348 // These flags are used to override the state of the shared feature_info_ | 2352 // These flags are used to override the state of the shared feature_info_ |
| 2349 // member. Because the same FeatureInfo instance may be shared among many | 2353 // member. Because the same FeatureInfo instance may be shared among many |
| 2350 // contexts, the assumptions on the availablity of extensions in WebGL | 2354 // contexts, the assumptions on the availablity of extensions in WebGL |
| 2351 // contexts may be broken. These flags override the shared state to preserve | 2355 // contexts may be broken. These flags override the shared state to preserve |
| 2352 // WebGL semantics. | 2356 // WebGL semantics. |
| 2353 bool derivatives_explicitly_enabled_; | 2357 bool derivatives_explicitly_enabled_; |
| 2354 bool frag_depth_explicitly_enabled_; | 2358 bool frag_depth_explicitly_enabled_; |
| (...skipping 670 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3025 swaps_since_resize_(0), | 3029 swaps_since_resize_(0), |
| 3026 current_decoder_error_(error::kNoError), | 3030 current_decoder_error_(error::kNoError), |
| 3027 validators_(group_->feature_info()->validators()), | 3031 validators_(group_->feature_info()->validators()), |
| 3028 feature_info_(group_->feature_info()), | 3032 feature_info_(group_->feature_info()), |
| 3029 frame_number_(0), | 3033 frame_number_(0), |
| 3030 has_robustness_extension_(false), | 3034 has_robustness_extension_(false), |
| 3031 context_lost_reason_(error::kUnknown), | 3035 context_lost_reason_(error::kUnknown), |
| 3032 context_was_lost_(false), | 3036 context_was_lost_(false), |
| 3033 reset_by_robustness_extension_(false), | 3037 reset_by_robustness_extension_(false), |
| 3034 supports_post_sub_buffer_(false), | 3038 supports_post_sub_buffer_(false), |
| 3035 supports_swap_buffers_with_damage_(false), | 3039 supports_swap_buffers_with_bounds_(false), |
| 3036 supports_commit_overlay_planes_(false), | 3040 supports_commit_overlay_planes_(false), |
| 3037 supports_async_swap_(false), | 3041 supports_async_swap_(false), |
| 3038 derivatives_explicitly_enabled_(false), | 3042 derivatives_explicitly_enabled_(false), |
| 3039 frag_depth_explicitly_enabled_(false), | 3043 frag_depth_explicitly_enabled_(false), |
| 3040 draw_buffers_explicitly_enabled_(false), | 3044 draw_buffers_explicitly_enabled_(false), |
| 3041 shader_texture_lod_explicitly_enabled_(false), | 3045 shader_texture_lod_explicitly_enabled_(false), |
| 3042 compile_shader_always_succeeds_(false), | 3046 compile_shader_always_succeeds_(false), |
| 3043 lose_context_when_out_of_memory_(false), | 3047 lose_context_when_out_of_memory_(false), |
| 3044 should_use_native_gmb_for_backbuffer_(false), | 3048 should_use_native_gmb_for_backbuffer_(false), |
| 3045 service_logging_( | 3049 service_logging_( |
| (...skipping 489 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3535 glClearColor(0.0f, 0.0f, 0.0f, 0.0f); | 3539 glClearColor(0.0f, 0.0f, 0.0f, 0.0f); |
| 3536 } | 3540 } |
| 3537 } | 3541 } |
| 3538 | 3542 |
| 3539 supports_post_sub_buffer_ = surface->SupportsPostSubBuffer(); | 3543 supports_post_sub_buffer_ = surface->SupportsPostSubBuffer(); |
| 3540 if (workarounds() | 3544 if (workarounds() |
| 3541 .disable_post_sub_buffers_for_onscreen_surfaces && | 3545 .disable_post_sub_buffers_for_onscreen_surfaces && |
| 3542 !surface->IsOffscreen()) | 3546 !surface->IsOffscreen()) |
| 3543 supports_post_sub_buffer_ = false; | 3547 supports_post_sub_buffer_ = false; |
| 3544 | 3548 |
| 3545 supports_swap_buffers_with_damage_ = surface->SupportsSwapBuffersWithDamage(); | 3549 supports_swap_buffers_with_bounds_ = surface->SupportsSwapBuffersWithBounds(); |
| 3546 | 3550 |
| 3547 supports_commit_overlay_planes_ = surface->SupportsCommitOverlayPlanes(); | 3551 supports_commit_overlay_planes_ = surface->SupportsCommitOverlayPlanes(); |
| 3548 | 3552 |
| 3549 supports_async_swap_ = surface->SupportsAsyncSwap(); | 3553 supports_async_swap_ = surface->SupportsAsyncSwap(); |
| 3550 | 3554 |
| 3551 if (workarounds().reverse_point_sprite_coord_origin) { | 3555 if (workarounds().reverse_point_sprite_coord_origin) { |
| 3552 glPointParameteri(GL_POINT_SPRITE_COORD_ORIGIN, GL_LOWER_LEFT); | 3556 glPointParameteri(GL_POINT_SPRITE_COORD_ORIGIN, GL_LOWER_LEFT); |
| 3553 } | 3557 } |
| 3554 | 3558 |
| 3555 if (workarounds().unbind_fbo_on_context_switch) { | 3559 if (workarounds().unbind_fbo_on_context_switch) { |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3707 feature_info_->feature_flags().ext_discard_framebuffer; | 3711 feature_info_->feature_flags().ext_discard_framebuffer; |
| 3708 caps.sync_query = feature_info_->feature_flags().chromium_sync_query; | 3712 caps.sync_query = feature_info_->feature_flags().chromium_sync_query; |
| 3709 | 3713 |
| 3710 caps.chromium_image_rgb_emulation = ChromiumImageNeedsRGBEmulation(); | 3714 caps.chromium_image_rgb_emulation = ChromiumImageNeedsRGBEmulation(); |
| 3711 #if defined(OS_MACOSX) | 3715 #if defined(OS_MACOSX) |
| 3712 // This is unconditionally true on mac, no need to test for it at runtime. | 3716 // This is unconditionally true on mac, no need to test for it at runtime. |
| 3713 caps.iosurface = true; | 3717 caps.iosurface = true; |
| 3714 #endif | 3718 #endif |
| 3715 | 3719 |
| 3716 caps.post_sub_buffer = supports_post_sub_buffer_; | 3720 caps.post_sub_buffer = supports_post_sub_buffer_; |
| 3717 caps.swap_buffers_with_damage = supports_swap_buffers_with_damage_; | 3721 caps.swap_buffers_with_bounds = supports_swap_buffers_with_bounds_; |
| 3718 caps.commit_overlay_planes = supports_commit_overlay_planes_; | 3722 caps.commit_overlay_planes = supports_commit_overlay_planes_; |
| 3719 caps.surfaceless = surfaceless_; | 3723 caps.surfaceless = surfaceless_; |
| 3720 bool is_offscreen = !!offscreen_target_frame_buffer_.get(); | 3724 bool is_offscreen = !!offscreen_target_frame_buffer_.get(); |
| 3721 caps.flips_vertically = !is_offscreen && surface_->FlipsVertically(); | 3725 caps.flips_vertically = !is_offscreen && surface_->FlipsVertically(); |
| 3722 caps.msaa_is_slow = workarounds().msaa_is_slow; | 3726 caps.msaa_is_slow = workarounds().msaa_is_slow; |
| 3723 | 3727 |
| 3724 caps.blend_equation_advanced = | 3728 caps.blend_equation_advanced = |
| 3725 feature_info_->feature_flags().blend_equation_advanced; | 3729 feature_info_->feature_flags().blend_equation_advanced; |
| 3726 caps.blend_equation_advanced_coherent = | 3730 caps.blend_equation_advanced_coherent = |
| 3727 feature_info_->feature_flags().blend_equation_advanced_coherent; | 3731 feature_info_->feature_flags().blend_equation_advanced_coherent; |
| (...skipping 7973 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 11701 state_.unpack_image_height = param; | 11705 state_.unpack_image_height = param; |
| 11702 break; | 11706 break; |
| 11703 default: | 11707 default: |
| 11704 // Validation should have prevented us from getting here. | 11708 // Validation should have prevented us from getting here. |
| 11705 NOTREACHED(); | 11709 NOTREACHED(); |
| 11706 break; | 11710 break; |
| 11707 } | 11711 } |
| 11708 return error::kNoError; | 11712 return error::kNoError; |
| 11709 } | 11713 } |
| 11710 | 11714 |
| 11711 error::Error GLES2DecoderImpl::HandleSwapBuffersWithDamageCHROMIUM( | 11715 void GLES2DecoderImpl::DoSwapBuffersWithBoundsCHROMIUM( |
| 11712 uint32_t immediate_data_size, | 11716 GLsizei count, |
| 11713 const volatile void* cmd_data) { | 11717 const volatile GLint* rects) { |
| 11714 const volatile gles2::cmds::SwapBuffersWithDamageCHROMIUM& c = | 11718 TRACE_EVENT0("gpu", "GLES2DecoderImpl::SwapBuffersWithBoundsCHROMIUM"); |
| 11715 *static_cast<const volatile gles2::cmds::SwapBuffersWithDamageCHROMIUM*>( | |
| 11716 cmd_data); | |
| 11717 TRACE_EVENT0("gpu", "GLES2DecoderImpl::SwapBuffersWithDamageCHROMIUM"); | |
| 11718 { TRACE_EVENT_SYNTHETIC_DELAY("gpu.PresentingFrame"); } | 11719 { TRACE_EVENT_SYNTHETIC_DELAY("gpu.PresentingFrame"); } |
| 11719 if (!supports_swap_buffers_with_damage_) { | 11720 if (!supports_swap_buffers_with_bounds_) { |
| 11720 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, "glSwapBuffersWithDamageCHROMIUM", | 11721 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, "glSwapBuffersWithBoundsCHROMIUM", |
| 11721 "command not supported by surface"); | 11722 "command not supported by surface"); |
| 11722 return error::kNoError; | 11723 return; |
| 11723 } | 11724 } |
| 11724 bool is_tracing; | 11725 bool is_tracing; |
| 11725 TRACE_EVENT_CATEGORY_GROUP_ENABLED(TRACE_DISABLED_BY_DEFAULT("gpu.debug"), | 11726 TRACE_EVENT_CATEGORY_GROUP_ENABLED(TRACE_DISABLED_BY_DEFAULT("gpu.debug"), |
| 11726 &is_tracing); | 11727 &is_tracing); |
| 11727 if (is_tracing) { | 11728 if (is_tracing) { |
| 11728 bool is_offscreen = !!offscreen_target_frame_buffer_.get(); | 11729 bool is_offscreen = !!offscreen_target_frame_buffer_.get(); |
| 11729 ScopedFramebufferBinder binder(this, GetBoundDrawFramebufferServiceId()); | 11730 ScopedFramebufferBinder binder(this, GetBoundDrawFramebufferServiceId()); |
| 11730 gpu_state_tracer_->TakeSnapshotWithCurrentFramebuffer( | 11731 gpu_state_tracer_->TakeSnapshotWithCurrentFramebuffer( |
| 11731 is_offscreen ? offscreen_size_ : surface_->GetSize()); | 11732 is_offscreen ? offscreen_size_ : surface_->GetSize()); |
| 11732 } | 11733 } |
| 11733 | 11734 |
| 11734 ClearScheduleCALayerState(); | 11735 ClearScheduleCALayerState(); |
| 11735 | 11736 |
| 11736 FinishSwapBuffers( | 11737 std::vector<gfx::Rect> bounds(count); |
| 11737 surface_->SwapBuffersWithDamage(c.x, c.y, c.width, c.height)); | 11738 for (GLsizei i = 0; i != count; ++i) { |
| 11738 | 11739 bounds[i] = gfx::Rect(rects[i * 4 + 0], rects[i * 4 + 1], rects[i * 4 + 2], |
| 11739 return error::kNoError; | 11740 rects[i * 4 + 3]); |
| 11741 } | |
| 11742 FinishSwapBuffers(surface_->SwapBuffersWithBounds(bounds)); | |
| 11740 } | 11743 } |
| 11741 | 11744 |
| 11742 error::Error GLES2DecoderImpl::HandlePostSubBufferCHROMIUM( | 11745 error::Error GLES2DecoderImpl::HandlePostSubBufferCHROMIUM( |
| 11743 uint32_t immediate_data_size, | 11746 uint32_t immediate_data_size, |
| 11744 const volatile void* cmd_data) { | 11747 const volatile void* cmd_data) { |
| 11745 const volatile gles2::cmds::PostSubBufferCHROMIUM& c = | 11748 const volatile gles2::cmds::PostSubBufferCHROMIUM& c = |
| 11746 *static_cast<const volatile gles2::cmds::PostSubBufferCHROMIUM*>( | 11749 *static_cast<const volatile gles2::cmds::PostSubBufferCHROMIUM*>( |
| 11747 cmd_data); | 11750 cmd_data); |
| 11748 TRACE_EVENT0("gpu", "GLES2DecoderImpl::HandlePostSubBufferCHROMIUM"); | 11751 TRACE_EVENT0("gpu", "GLES2DecoderImpl::HandlePostSubBufferCHROMIUM"); |
| 11749 { | 11752 { |
| (...skipping 7479 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 19229 } | 19232 } |
| 19230 | 19233 |
| 19231 // Include the auto-generated part of this file. We split this because it means | 19234 // Include the auto-generated part of this file. We split this because it means |
| 19232 // we can easily edit the non-auto generated parts right here in this file | 19235 // we can easily edit the non-auto generated parts right here in this file |
| 19233 // instead of having to edit some template or the code generator. | 19236 // instead of having to edit some template or the code generator. |
| 19234 #include "base/macros.h" | 19237 #include "base/macros.h" |
| 19235 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" | 19238 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" |
| 19236 | 19239 |
| 19237 } // namespace gles2 | 19240 } // namespace gles2 |
| 19238 } // namespace gpu | 19241 } // namespace gpu |
| OLD | NEW |