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 1051 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1062 bool smoothness_takes_priority = | 1062 bool smoothness_takes_priority = |
1063 impl().layer_tree_host_impl->pinch_gesture_active() || | 1063 impl().layer_tree_host_impl->pinch_gesture_active() || |
1064 impl().layer_tree_host_impl->page_scale_animation_active() || | 1064 impl().layer_tree_host_impl->page_scale_animation_active() || |
1065 impl().layer_tree_host_impl->IsActivelyScrolling(); | 1065 impl().layer_tree_host_impl->IsActivelyScrolling(); |
1066 | 1066 |
1067 // Schedule expiration if smoothness currently takes priority. | 1067 // Schedule expiration if smoothness currently takes priority. |
1068 if (smoothness_takes_priority) | 1068 if (smoothness_takes_priority) |
1069 impl().smoothness_priority_expiration_notifier.Schedule(); | 1069 impl().smoothness_priority_expiration_notifier.Schedule(); |
1070 | 1070 |
1071 // We use the same priority for both trees by default. | 1071 // We use the same priority for both trees by default. |
1072 TreePriority priority = SAME_PRIORITY_FOR_BOTH_TREES; | 1072 TreePriority tree_priority = SAME_PRIORITY_FOR_BOTH_TREES; |
1073 | 1073 |
1074 // Smoothness takes priority if we have an expiration for it scheduled. | 1074 // Smoothness takes priority if we have an expiration for it scheduled. |
1075 if (impl().smoothness_priority_expiration_notifier.HasPendingNotification()) | 1075 if (impl().smoothness_priority_expiration_notifier.HasPendingNotification()) |
1076 priority = SMOOTHNESS_TAKES_PRIORITY; | 1076 tree_priority = SMOOTHNESS_TAKES_PRIORITY; |
1077 | 1077 |
1078 // New content always takes priority when there is an invalid viewport size or | 1078 // New content always takes priority when there is an invalid viewport size or |
1079 // ui resources have been evicted. | 1079 // ui resources have been evicted. |
1080 if (impl().layer_tree_host_impl->active_tree()->ViewportSizeInvalid() || | 1080 if (impl().layer_tree_host_impl->active_tree()->ViewportSizeInvalid() || |
1081 impl().layer_tree_host_impl->EvictedUIResourcesExist() || | 1081 impl().layer_tree_host_impl->EvictedUIResourcesExist() || |
1082 impl().input_throttled_until_commit) { | 1082 impl().input_throttled_until_commit) { |
1083 // Once we enter NEW_CONTENTS_TAKES_PRIORITY mode, visible tiles on active | 1083 // Once we enter NEW_CONTENTS_TAKES_PRIORITY mode, visible tiles on active |
1084 // tree might be freed. We need to set RequiresHighResToDraw to ensure that | 1084 // tree might be freed. We need to set RequiresHighResToDraw to ensure that |
1085 // high res tiles will be required to activate pending tree. | 1085 // high res tiles will be required to activate pending tree. |
1086 impl().layer_tree_host_impl->SetRequiresHighResToDraw(); | 1086 impl().layer_tree_host_impl->SetRequiresHighResToDraw(); |
1087 priority = NEW_CONTENT_TAKES_PRIORITY; | 1087 tree_priority = NEW_CONTENT_TAKES_PRIORITY; |
1088 } | 1088 } |
1089 | 1089 |
1090 impl().layer_tree_host_impl->SetTreePriority(priority); | 1090 impl().layer_tree_host_impl->SetTreePriority(tree_priority); |
1091 | 1091 |
1092 // Only put the scheduler in impl latency prioritization mode if we don't | 1092 // Only put the scheduler in impl latency prioritization mode if we don't |
1093 // have a scroll listener. This gives the scroll listener a better chance of | 1093 // have a scroll listener. This gives the scroll listener a better chance of |
1094 // handling scroll updates within the same frame. The tree itself is still | 1094 // handling scroll updates within the same frame. The tree itself is still |
1095 // kept in prefer smoothness mode to allow checkerboarding. | 1095 // kept in prefer smoothness mode to allow checkerboarding. |
1096 impl().scheduler->SetImplLatencyTakesPriority( | 1096 ScrollHandlerState scroll_handler_state = |
1097 priority == SMOOTHNESS_TAKES_PRIORITY && | 1097 impl().layer_tree_host_impl->scroll_affects_scroll_handler() |
1098 !impl().layer_tree_host_impl->scroll_affects_scroll_handler()); | 1098 ? ScrollHandlerState::SCROLL_AFFECTS_SCROLL_HANDLER |
| 1099 : ScrollHandlerState::SCROLL_DOES_NOT_AFFECT_SCROLL_HANDLER; |
| 1100 impl().scheduler->SetTreePrioritiesAndScrollState(tree_priority, |
| 1101 scroll_handler_state); |
1099 | 1102 |
1100 // Notify the the client of this compositor via the output surface. | 1103 // Notify the the client of this compositor via the output surface. |
1101 // TODO(epenner): Route this to compositor-thread instead of output-surface | 1104 // TODO(epenner): Route this to compositor-thread instead of output-surface |
1102 // after GTFO refactor of compositor-thread (http://crbug/170828). | 1105 // after GTFO refactor of compositor-thread (http://crbug/170828). |
1103 if (impl().layer_tree_host_impl->output_surface()) { | 1106 if (impl().layer_tree_host_impl->output_surface()) { |
1104 impl() | 1107 impl() |
1105 .layer_tree_host_impl->output_surface() | 1108 .layer_tree_host_impl->output_surface() |
1106 ->UpdateSmoothnessTakesPriority(priority == SMOOTHNESS_TAKES_PRIORITY); | 1109 ->UpdateSmoothnessTakesPriority(tree_priority == |
| 1110 SMOOTHNESS_TAKES_PRIORITY); |
1107 } | 1111 } |
1108 } | 1112 } |
1109 | 1113 |
1110 void ThreadProxy::PostDelayedAnimationTaskOnImplThread( | 1114 void ThreadProxy::PostDelayedAnimationTaskOnImplThread( |
1111 const base::Closure& task, | 1115 const base::Closure& task, |
1112 base::TimeDelta delay) { | 1116 base::TimeDelta delay) { |
1113 task_runner_provider_->ImplThreadTaskRunner()->PostDelayedTask(FROM_HERE, | 1117 task_runner_provider_->ImplThreadTaskRunner()->PostDelayedTask(FROM_HERE, |
1114 task, delay); | 1118 task, delay); |
1115 } | 1119 } |
1116 | 1120 |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1184 | 1188 |
1185 base::WeakPtr<ProxyMain> ThreadProxy::GetMainWeakPtr() { | 1189 base::WeakPtr<ProxyMain> ThreadProxy::GetMainWeakPtr() { |
1186 return main_thread_weak_ptr_; | 1190 return main_thread_weak_ptr_; |
1187 } | 1191 } |
1188 | 1192 |
1189 base::WeakPtr<ProxyImpl> ThreadProxy::GetImplWeakPtr() { | 1193 base::WeakPtr<ProxyImpl> ThreadProxy::GetImplWeakPtr() { |
1190 return impl_thread_weak_ptr_; | 1194 return impl_thread_weak_ptr_; |
1191 } | 1195 } |
1192 | 1196 |
1193 } // namespace cc | 1197 } // namespace cc |
OLD | NEW |