| 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/layer_tree_host.h" | 5 #include "cc/trees/layer_tree_host.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <stack> | 8 #include <stack> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 174 } | 174 } |
| 175 | 175 |
| 176 LayerTreeHost::~LayerTreeHost() { | 176 LayerTreeHost::~LayerTreeHost() { |
| 177 TRACE_EVENT0("cc", "LayerTreeHost::~LayerTreeHost"); | 177 TRACE_EVENT0("cc", "LayerTreeHost::~LayerTreeHost"); |
| 178 | 178 |
| 179 if (root_layer_.get()) | 179 if (root_layer_.get()) |
| 180 root_layer_->SetLayerTreeHost(NULL); | 180 root_layer_->SetLayerTreeHost(NULL); |
| 181 | 181 |
| 182 DCHECK(swap_promise_monitor_.empty()); | 182 DCHECK(swap_promise_monitor_.empty()); |
| 183 | 183 |
| 184 BreakSwapPromises(SwapPromise::COMMIT_FAILS); | 184 promises_.OnDidNotActivate(Promise::DidNotActivate::COMMIT_FAILS); |
| 185 promises_.OnDidNotSwap(Promise::DidNotSwap::COMMIT_FAILS); |
| 185 | 186 |
| 186 if (proxy_) { | 187 if (proxy_) { |
| 187 DCHECK(proxy_->IsMainThread()); | 188 DCHECK(proxy_->IsMainThread()); |
| 188 proxy_->Stop(); | 189 proxy_->Stop(); |
| 189 } | 190 } |
| 190 | 191 |
| 191 // We must clear any pointers into the layer tree prior to destroying it. | 192 // We must clear any pointers into the layer tree prior to destroying it. |
| 192 RegisterViewportLayers(NULL, NULL, NULL, NULL); | 193 RegisterViewportLayers(NULL, NULL, NULL, NULL); |
| 193 | 194 |
| 194 if (root_layer_.get()) { | 195 if (root_layer_.get()) { |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 326 } | 327 } |
| 327 | 328 |
| 328 sync_tree->RegisterSelection(selection_); | 329 sync_tree->RegisterSelection(selection_); |
| 329 | 330 |
| 330 sync_tree->PushPageScaleFromMainThread( | 331 sync_tree->PushPageScaleFromMainThread( |
| 331 page_scale_factor_, min_page_scale_factor_, max_page_scale_factor_); | 332 page_scale_factor_, min_page_scale_factor_, max_page_scale_factor_); |
| 332 sync_tree->elastic_overscroll()->PushFromMainThread(elastic_overscroll_); | 333 sync_tree->elastic_overscroll()->PushFromMainThread(elastic_overscroll_); |
| 333 if (sync_tree->IsActiveTree()) | 334 if (sync_tree->IsActiveTree()) |
| 334 sync_tree->elastic_overscroll()->PushPendingToActive(); | 335 sync_tree->elastic_overscroll()->PushPendingToActive(); |
| 335 | 336 |
| 336 sync_tree->PassSwapPromises(&swap_promise_list_); | 337 sync_tree->PassPromises(&promises_); |
| 337 | 338 |
| 338 sync_tree->set_top_controls_shrink_blink_size( | 339 sync_tree->set_top_controls_shrink_blink_size( |
| 339 top_controls_shrink_blink_size_); | 340 top_controls_shrink_blink_size_); |
| 340 sync_tree->set_top_controls_height(top_controls_height_); | 341 sync_tree->set_top_controls_height(top_controls_height_); |
| 341 sync_tree->PushTopControlsFromMainThread(top_controls_shown_ratio_); | 342 sync_tree->PushTopControlsFromMainThread(top_controls_shown_ratio_); |
| 342 | 343 |
| 343 host_impl->set_has_gpu_rasterization_trigger(has_gpu_rasterization_trigger_); | 344 host_impl->set_has_gpu_rasterization_trigger(has_gpu_rasterization_trigger_); |
| 344 host_impl->set_content_is_suitable_for_gpu_rasterization( | 345 host_impl->set_content_is_suitable_for_gpu_rasterization( |
| 345 content_is_suitable_for_gpu_rasterization_); | 346 content_is_suitable_for_gpu_rasterization_); |
| 346 RecordGpuRasterizationHistogram(); | 347 RecordGpuRasterizationHistogram(); |
| (...skipping 632 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 979 } | 980 } |
| 980 | 981 |
| 981 void LayerTreeHost::ApplyScrollAndScale(ScrollAndScaleSet* info) { | 982 void LayerTreeHost::ApplyScrollAndScale(ScrollAndScaleSet* info) { |
| 982 ScopedPtrVector<SwapPromise>::iterator it = info->swap_promises.begin(); | 983 ScopedPtrVector<SwapPromise>::iterator it = info->swap_promises.begin(); |
| 983 for (; it != info->swap_promises.end(); ++it) { | 984 for (; it != info->swap_promises.end(); ++it) { |
| 984 scoped_ptr<SwapPromise> swap_promise(info->swap_promises.take(it)); | 985 scoped_ptr<SwapPromise> swap_promise(info->swap_promises.take(it)); |
| 985 TRACE_EVENT_FLOW_STEP0("input", | 986 TRACE_EVENT_FLOW_STEP0("input", |
| 986 "LatencyInfo.Flow", | 987 "LatencyInfo.Flow", |
| 987 TRACE_ID_DONT_MANGLE(swap_promise->TraceId()), | 988 TRACE_ID_DONT_MANGLE(swap_promise->TraceId()), |
| 988 "Main thread scroll update"); | 989 "Main thread scroll update"); |
| 989 QueueSwapPromise(swap_promise.Pass()); | 990 QueuePromise(swap_promise.Pass()); |
| 990 } | 991 } |
| 991 | 992 |
| 992 gfx::Vector2dF inner_viewport_scroll_delta; | 993 gfx::Vector2dF inner_viewport_scroll_delta; |
| 993 gfx::Vector2dF outer_viewport_scroll_delta; | 994 gfx::Vector2dF outer_viewport_scroll_delta; |
| 994 | 995 |
| 995 if (root_layer_.get()) { | 996 if (root_layer_.get()) { |
| 996 for (size_t i = 0; i < info->scrolls.size(); ++i) { | 997 for (size_t i = 0; i < info->scrolls.size(); ++i) { |
| 997 Layer* layer = LayerTreeHostCommon::FindLayerInSubtree( | 998 Layer* layer = LayerTreeHostCommon::FindLayerInSubtree( |
| 998 root_layer_.get(), info->scrolls[i].layer_id); | 999 root_layer_.get(), info->scrolls[i].layer_id); |
| 999 if (!layer) | 1000 if (!layer) |
| (...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1227 void LayerTreeHost::RemoveSwapPromiseMonitor(SwapPromiseMonitor* monitor) { | 1228 void LayerTreeHost::RemoveSwapPromiseMonitor(SwapPromiseMonitor* monitor) { |
| 1228 swap_promise_monitor_.erase(monitor); | 1229 swap_promise_monitor_.erase(monitor); |
| 1229 } | 1230 } |
| 1230 | 1231 |
| 1231 void LayerTreeHost::NotifySwapPromiseMonitorsOfSetNeedsCommit() { | 1232 void LayerTreeHost::NotifySwapPromiseMonitorsOfSetNeedsCommit() { |
| 1232 std::set<SwapPromiseMonitor*>::iterator it = swap_promise_monitor_.begin(); | 1233 std::set<SwapPromiseMonitor*>::iterator it = swap_promise_monitor_.begin(); |
| 1233 for (; it != swap_promise_monitor_.end(); it++) | 1234 for (; it != swap_promise_monitor_.end(); it++) |
| 1234 (*it)->OnSetNeedsCommitOnMain(); | 1235 (*it)->OnSetNeedsCommitOnMain(); |
| 1235 } | 1236 } |
| 1236 | 1237 |
| 1237 void LayerTreeHost::QueueSwapPromise(scoped_ptr<SwapPromise> swap_promise) { | 1238 void LayerTreeHost::QueuePromise(scoped_ptr<Promise> promise) { |
| 1238 DCHECK(swap_promise); | 1239 promises_.QueuePromise(promise.Pass()); |
| 1239 swap_promise_list_.push_back(swap_promise.Pass()); | |
| 1240 } | 1240 } |
| 1241 | 1241 |
| 1242 void LayerTreeHost::BreakSwapPromises(SwapPromise::DidNotSwapReason reason) { | 1242 void LayerTreeHost::BreakSwapPromises(Promise::DidNotSwap::Reason reason) { |
| 1243 for (size_t i = 0; i < swap_promise_list_.size(); i++) | 1243 promises_.OnDidNotSwap(reason); |
| 1244 swap_promise_list_[i]->DidNotSwap(reason); | 1244 } |
| 1245 swap_promise_list_.clear(); | 1245 |
| 1246 void LayerTreeHost::BreakActivationPromises( |
| 1247 Promise::DidNotActivate::Reason reason) { |
| 1248 promises_.OnDidNotActivate(reason); |
| 1246 } | 1249 } |
| 1247 | 1250 |
| 1248 void LayerTreeHost::set_surface_id_namespace(uint32_t id_namespace) { | 1251 void LayerTreeHost::set_surface_id_namespace(uint32_t id_namespace) { |
| 1249 surface_id_namespace_ = id_namespace; | 1252 surface_id_namespace_ = id_namespace; |
| 1250 } | 1253 } |
| 1251 | 1254 |
| 1252 SurfaceSequence LayerTreeHost::CreateSurfaceSequence() { | 1255 SurfaceSequence LayerTreeHost::CreateSurfaceSequence() { |
| 1253 return SurfaceSequence(surface_id_namespace_, next_surface_sequence_++); | 1256 return SurfaceSequence(surface_id_namespace_, next_surface_sequence_++); |
| 1254 } | 1257 } |
| 1255 | 1258 |
| 1256 void LayerTreeHost::SetChildrenNeedBeginFrames( | 1259 void LayerTreeHost::SetChildrenNeedBeginFrames( |
| 1257 bool children_need_begin_frames) const { | 1260 bool children_need_begin_frames) const { |
| 1258 proxy_->SetChildrenNeedBeginFrames(children_need_begin_frames); | 1261 proxy_->SetChildrenNeedBeginFrames(children_need_begin_frames); |
| 1259 } | 1262 } |
| 1260 | 1263 |
| 1261 void LayerTreeHost::SendBeginFramesToChildren( | 1264 void LayerTreeHost::SendBeginFramesToChildren( |
| 1262 const BeginFrameArgs& args) const { | 1265 const BeginFrameArgs& args) const { |
| 1263 client_->SendBeginFramesToChildren(args); | 1266 client_->SendBeginFramesToChildren(args); |
| 1264 } | 1267 } |
| 1265 | 1268 |
| 1266 void LayerTreeHost::SetAuthoritativeVSyncInterval( | 1269 void LayerTreeHost::SetAuthoritativeVSyncInterval( |
| 1267 const base::TimeDelta& interval) { | 1270 const base::TimeDelta& interval) { |
| 1268 proxy_->SetAuthoritativeVSyncInterval(interval); | 1271 proxy_->SetAuthoritativeVSyncInterval(interval); |
| 1269 } | 1272 } |
| 1270 | 1273 |
| 1271 } // namespace cc | 1274 } // namespace cc |
| OLD | NEW |