| OLD | NEW |
| 1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 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 "cc/trees/thread_proxy.h" | 5 #include "cc/trees/thread_proxy.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/auto_reset.h" | 10 #include "base/auto_reset.h" |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 ThreadProxy* proxy, | 100 ThreadProxy* proxy, |
| 101 int layer_tree_host_id, | 101 int layer_tree_host_id, |
| 102 RenderingStatsInstrumentation* rendering_stats_instrumentation) | 102 RenderingStatsInstrumentation* rendering_stats_instrumentation) |
| 103 : layer_tree_host_id(layer_tree_host_id), | 103 : layer_tree_host_id(layer_tree_host_id), |
| 104 contents_texture_manager(NULL), | 104 contents_texture_manager(NULL), |
| 105 commit_completion_event(NULL), | 105 commit_completion_event(NULL), |
| 106 completion_event_for_commit_held_on_tree_activation(NULL), | 106 completion_event_for_commit_held_on_tree_activation(NULL), |
| 107 next_frame_is_newly_committed_frame(false), | 107 next_frame_is_newly_committed_frame(false), |
| 108 inside_draw(false), | 108 inside_draw(false), |
| 109 input_throttled_until_commit(false), | 109 input_throttled_until_commit(false), |
| 110 animations_frozen_until_next_draw(false), | |
| 111 did_commit_after_animating(false), | 110 did_commit_after_animating(false), |
| 112 smoothness_priority_expiration_notifier( | 111 smoothness_priority_expiration_notifier( |
| 113 proxy->ImplThreadTaskRunner(), | 112 proxy->ImplThreadTaskRunner(), |
| 114 base::Bind(&ThreadProxy::RenewTreePriority, base::Unretained(proxy)), | 113 base::Bind(&ThreadProxy::RenewTreePriority, base::Unretained(proxy)), |
| 115 base::TimeDelta::FromMilliseconds( | 114 base::TimeDelta::FromMilliseconds( |
| 116 kSmoothnessTakesPriorityExpirationDelay * 1000)), | 115 kSmoothnessTakesPriorityExpirationDelay * 1000)), |
| 117 timing_history(rendering_stats_instrumentation), | 116 timing_history(rendering_stats_instrumentation), |
| 118 weak_factory(proxy) { | 117 weak_factory(proxy) { |
| 119 } | 118 } |
| 120 | 119 |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 181 UpdateBackgroundAnimateTicking(); | 180 UpdateBackgroundAnimateTicking(); |
| 182 completion->Signal(); | 181 completion->Signal(); |
| 183 } | 182 } |
| 184 | 183 |
| 185 void ThreadProxy::UpdateBackgroundAnimateTicking() { | 184 void ThreadProxy::UpdateBackgroundAnimateTicking() { |
| 186 bool should_background_tick = | 185 bool should_background_tick = |
| 187 !impl().scheduler->WillDrawIfNeeded() && | 186 !impl().scheduler->WillDrawIfNeeded() && |
| 188 impl().layer_tree_host_impl->active_tree()->root_layer(); | 187 impl().layer_tree_host_impl->active_tree()->root_layer(); |
| 189 impl().layer_tree_host_impl->UpdateBackgroundAnimateTicking( | 188 impl().layer_tree_host_impl->UpdateBackgroundAnimateTicking( |
| 190 should_background_tick); | 189 should_background_tick); |
| 191 if (should_background_tick) | |
| 192 impl().animations_frozen_until_next_draw = false; | |
| 193 } | 190 } |
| 194 | 191 |
| 195 void ThreadProxy::DidLoseOutputSurface() { | 192 void ThreadProxy::DidLoseOutputSurface() { |
| 196 TRACE_EVENT0("cc", "ThreadProxy::DidLoseOutputSurface"); | 193 TRACE_EVENT0("cc", "ThreadProxy::DidLoseOutputSurface"); |
| 197 DCHECK(IsMainThread()); | 194 DCHECK(IsMainThread()); |
| 198 layer_tree_host()->DidLoseOutputSurface(); | 195 layer_tree_host()->DidLoseOutputSurface(); |
| 199 | 196 |
| 200 { | 197 { |
| 201 DebugScopedSetMainThreadBlocked main_thread_blocked(this); | 198 DebugScopedSetMainThreadBlocked main_thread_blocked(this); |
| 202 | 199 |
| (...skipping 557 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 760 main().commit_request_sent_to_impl_thread = true; | 757 main().commit_request_sent_to_impl_thread = true; |
| 761 | 758 |
| 762 layer_tree_host()->ApplyScrollAndScale( | 759 layer_tree_host()->ApplyScrollAndScale( |
| 763 begin_main_frame_state->scroll_info.get()); | 760 begin_main_frame_state->scroll_info.get()); |
| 764 | 761 |
| 765 layer_tree_host()->WillBeginMainFrame(); | 762 layer_tree_host()->WillBeginMainFrame(); |
| 766 | 763 |
| 767 layer_tree_host()->BeginMainFrame(begin_main_frame_state->begin_frame_args); | 764 layer_tree_host()->BeginMainFrame(begin_main_frame_state->begin_frame_args); |
| 768 layer_tree_host()->AnimateLayers( | 765 layer_tree_host()->AnimateLayers( |
| 769 begin_main_frame_state->begin_frame_args.frame_time); | 766 begin_main_frame_state->begin_frame_args.frame_time); |
| 770 blocked_main().last_monotonic_frame_begin_time = | |
| 771 begin_main_frame_state->begin_frame_args.frame_time; | |
| 772 | 767 |
| 773 // Unlink any backings that the impl thread has evicted, so that we know to | 768 // Unlink any backings that the impl thread has evicted, so that we know to |
| 774 // re-paint them in UpdateLayers. | 769 // re-paint them in UpdateLayers. |
| 775 if (blocked_main().contents_texture_manager()) { | 770 if (blocked_main().contents_texture_manager()) { |
| 776 blocked_main().contents_texture_manager()->UnlinkAndClearEvictedBackings(); | 771 blocked_main().contents_texture_manager()->UnlinkAndClearEvictedBackings(); |
| 777 | 772 |
| 778 blocked_main().contents_texture_manager()->SetMaxMemoryLimitBytes( | 773 blocked_main().contents_texture_manager()->SetMaxMemoryLimitBytes( |
| 779 begin_main_frame_state->memory_allocation_limit_bytes); | 774 begin_main_frame_state->memory_allocation_limit_bytes); |
| 780 blocked_main().contents_texture_manager()->SetExternalPriorityCutoff( | 775 blocked_main().contents_texture_manager()->SetExternalPriorityCutoff( |
| 781 begin_main_frame_state->memory_allocation_priority_cutoff); | 776 begin_main_frame_state->memory_allocation_priority_cutoff); |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 932 if (did_handle) | 927 if (did_handle) |
| 933 SetInputThrottledUntilCommitOnImplThread(false); | 928 SetInputThrottledUntilCommitOnImplThread(false); |
| 934 impl().layer_tree_host_impl->BeginMainFrameAborted(did_handle); | 929 impl().layer_tree_host_impl->BeginMainFrameAborted(did_handle); |
| 935 impl().scheduler->BeginMainFrameAborted(did_handle); | 930 impl().scheduler->BeginMainFrameAborted(did_handle); |
| 936 } | 931 } |
| 937 | 932 |
| 938 void ThreadProxy::ScheduledActionAnimate() { | 933 void ThreadProxy::ScheduledActionAnimate() { |
| 939 TRACE_EVENT0("cc", "ThreadProxy::ScheduledActionAnimate"); | 934 TRACE_EVENT0("cc", "ThreadProxy::ScheduledActionAnimate"); |
| 940 DCHECK(IsImplThread()); | 935 DCHECK(IsImplThread()); |
| 941 | 936 |
| 942 if (!impl().animations_frozen_until_next_draw) { | 937 impl().animation_time = |
| 943 impl().animation_time = | 938 impl().layer_tree_host_impl->CurrentBeginFrameArgs().frame_time; |
| 944 impl().layer_tree_host_impl->CurrentBeginFrameArgs().frame_time; | |
| 945 } | |
| 946 impl().layer_tree_host_impl->Animate(impl().animation_time); | 939 impl().layer_tree_host_impl->Animate(impl().animation_time); |
| 947 impl().did_commit_after_animating = false; | 940 impl().did_commit_after_animating = false; |
| 948 } | 941 } |
| 949 | 942 |
| 950 void ThreadProxy::ScheduledActionCommit() { | 943 void ThreadProxy::ScheduledActionCommit() { |
| 951 TRACE_EVENT0("cc", "ThreadProxy::ScheduledActionCommit"); | 944 TRACE_EVENT0("cc", "ThreadProxy::ScheduledActionCommit"); |
| 952 DCHECK(IsImplThread()); | 945 DCHECK(IsImplThread()); |
| 953 DCHECK(IsMainThreadBlocked()); | 946 DCHECK(IsMainThreadBlocked()); |
| 954 DCHECK(impl().commit_completion_event); | 947 DCHECK(impl().commit_completion_event); |
| 955 DCHECK(impl().current_resource_update_controller); | 948 DCHECK(impl().current_resource_update_controller); |
| 956 | 949 |
| 957 // Complete all remaining texture updates. | 950 // Complete all remaining texture updates. |
| 958 impl().current_resource_update_controller->Finalize(); | 951 impl().current_resource_update_controller->Finalize(); |
| 959 impl().current_resource_update_controller = nullptr; | 952 impl().current_resource_update_controller = nullptr; |
| 960 | 953 |
| 961 if (impl().animations_frozen_until_next_draw) { | |
| 962 impl().animation_time = std::max( | |
| 963 impl().animation_time, blocked_main().last_monotonic_frame_begin_time); | |
| 964 } | |
| 965 impl().did_commit_after_animating = true; | 954 impl().did_commit_after_animating = true; |
| 966 | 955 |
| 967 blocked_main().main_thread_inside_commit = true; | 956 blocked_main().main_thread_inside_commit = true; |
| 968 impl().layer_tree_host_impl->BeginCommit(); | 957 impl().layer_tree_host_impl->BeginCommit(); |
| 969 layer_tree_host()->BeginCommitOnImplThread(impl().layer_tree_host_impl.get()); | 958 layer_tree_host()->BeginCommitOnImplThread(impl().layer_tree_host_impl.get()); |
| 970 layer_tree_host()->FinishCommitOnImplThread( | 959 layer_tree_host()->FinishCommitOnImplThread( |
| 971 impl().layer_tree_host_impl.get()); | 960 impl().layer_tree_host_impl.get()); |
| 972 blocked_main().main_thread_inside_commit = false; | 961 blocked_main().main_thread_inside_commit = false; |
| 973 | 962 |
| 974 bool hold_commit = layer_tree_host()->settings().impl_side_painting && | 963 bool hold_commit = layer_tree_host()->settings().impl_side_painting && |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1057 result = impl().layer_tree_host_impl->PrepareToDraw(&frame); | 1046 result = impl().layer_tree_host_impl->PrepareToDraw(&frame); |
| 1058 draw_frame = forced_draw || result == DRAW_SUCCESS; | 1047 draw_frame = forced_draw || result == DRAW_SUCCESS; |
| 1059 } else { | 1048 } else { |
| 1060 result = DRAW_ABORTED_CANT_DRAW; | 1049 result = DRAW_ABORTED_CANT_DRAW; |
| 1061 } | 1050 } |
| 1062 | 1051 |
| 1063 if (draw_frame) { | 1052 if (draw_frame) { |
| 1064 impl().layer_tree_host_impl->DrawLayers( | 1053 impl().layer_tree_host_impl->DrawLayers( |
| 1065 &frame, impl().scheduler->LastBeginImplFrameTime()); | 1054 &frame, impl().scheduler->LastBeginImplFrameTime()); |
| 1066 result = DRAW_SUCCESS; | 1055 result = DRAW_SUCCESS; |
| 1067 impl().animations_frozen_until_next_draw = false; | |
| 1068 } else if (result == DRAW_ABORTED_CHECKERBOARD_ANIMATIONS && | |
| 1069 !impl().layer_tree_host_impl->settings().impl_side_painting) { | |
| 1070 // Without impl-side painting, the animated layer that is checkerboarding | |
| 1071 // will continue to checkerboard until the next commit. If this layer | |
| 1072 // continues to move during the commit, it may continue to checkerboard | |
| 1073 // after the commit since the region rasterized during the commit will not | |
| 1074 // match the region that is currently visible; eventually this | |
| 1075 // checkerboarding will be displayed when we force a draw. To avoid this, | |
| 1076 // we freeze animations until we successfully draw. | |
| 1077 impl().animations_frozen_until_next_draw = true; | |
| 1078 } else { | 1056 } else { |
| 1079 DCHECK_NE(DRAW_SUCCESS, result); | 1057 DCHECK_NE(DRAW_SUCCESS, result); |
| 1080 } | 1058 } |
| 1081 impl().layer_tree_host_impl->DidDrawAllLayers(frame); | 1059 impl().layer_tree_host_impl->DidDrawAllLayers(frame); |
| 1082 | 1060 |
| 1083 bool start_ready_animations = draw_frame; | 1061 bool start_ready_animations = draw_frame; |
| 1084 impl().layer_tree_host_impl->UpdateAnimationState(start_ready_animations); | 1062 impl().layer_tree_host_impl->UpdateAnimationState(start_ready_animations); |
| 1085 | 1063 |
| 1086 if (draw_frame) { | 1064 if (draw_frame) { |
| 1087 bool did_request_swap = impl().layer_tree_host_impl->SwapBuffers(frame); | 1065 bool did_request_swap = impl().layer_tree_host_impl->SwapBuffers(frame); |
| (...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1395 | 1373 |
| 1396 impl().timing_history.DidActivateSyncTree(); | 1374 impl().timing_history.DidActivateSyncTree(); |
| 1397 } | 1375 } |
| 1398 | 1376 |
| 1399 void ThreadProxy::DidManageTiles() { | 1377 void ThreadProxy::DidManageTiles() { |
| 1400 DCHECK(IsImplThread()); | 1378 DCHECK(IsImplThread()); |
| 1401 impl().scheduler->DidManageTiles(); | 1379 impl().scheduler->DidManageTiles(); |
| 1402 } | 1380 } |
| 1403 | 1381 |
| 1404 } // namespace cc | 1382 } // namespace cc |
| OLD | NEW |