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