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_impl.h" | 5 #include "cc/trees/layer_tree_host_impl.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <limits> | 8 #include <limits> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
274 DestroyTileManager(); | 274 DestroyTileManager(); |
275 } | 275 } |
276 | 276 |
277 void LayerTreeHostImpl::BeginMainFrameAborted(CommitEarlyOutReason reason) { | 277 void LayerTreeHostImpl::BeginMainFrameAborted(CommitEarlyOutReason reason) { |
278 // If the begin frame data was handled, then scroll and scale set was applied | 278 // If the begin frame data was handled, then scroll and scale set was applied |
279 // by the main thread, so the active tree needs to be updated as if these sent | 279 // by the main thread, so the active tree needs to be updated as if these sent |
280 // values were applied and committed. | 280 // values were applied and committed. |
281 if (CommitEarlyOutHandledCommit(reason)) { | 281 if (CommitEarlyOutHandledCommit(reason)) { |
282 active_tree_->ApplySentScrollAndScaleDeltasFromAbortedCommit(); | 282 active_tree_->ApplySentScrollAndScaleDeltasFromAbortedCommit(); |
283 active_tree_->ResetContentsTexturesPurged(); | 283 active_tree_->ResetContentsTexturesPurged(); |
284 RecordMainFrameTiming(); | |
284 } | 285 } |
285 } | 286 } |
286 | 287 |
287 void LayerTreeHostImpl::BeginCommit() { | 288 void LayerTreeHostImpl::BeginCommit() { |
288 TRACE_EVENT0("cc", "LayerTreeHostImpl::BeginCommit"); | 289 TRACE_EVENT0("cc", "LayerTreeHostImpl::BeginCommit"); |
289 | 290 |
290 // Ensure all textures are returned so partial texture updates can happen | 291 // Ensure all textures are returned so partial texture updates can happen |
291 // during the commit. Impl-side-painting doesn't upload during commits, so | 292 // during the commit. Impl-side-painting doesn't upload during commits, so |
292 // is unaffected. | 293 // is unaffected. |
293 if (!settings_.impl_side_painting && output_surface_) | 294 if (!settings_.impl_side_painting && output_surface_) |
294 output_surface_->ForceReclaimResources(); | 295 output_surface_->ForceReclaimResources(); |
295 | 296 |
296 if (settings_.impl_side_painting && !proxy_->CommitToActiveTree()) | 297 if (settings_.impl_side_painting && !proxy_->CommitToActiveTree()) |
297 CreatePendingTree(); | 298 CreatePendingTree(); |
298 } | 299 } |
299 | 300 |
300 void LayerTreeHostImpl::CommitComplete() { | 301 void LayerTreeHostImpl::CommitComplete() { |
301 TRACE_EVENT0("cc", "LayerTreeHostImpl::CommitComplete"); | 302 TRACE_EVENT0("cc", "LayerTreeHostImpl::CommitComplete"); |
302 | 303 |
303 sync_tree()->set_needs_update_draw_properties(); | 304 sync_tree()->set_needs_update_draw_properties(); |
304 | 305 |
306 // If we don't have a pending tree, it means we've committed directly to the | |
307 // active tree. In that case, record frame timing information immediately. | |
308 if (!pending_tree_) | |
309 RecordMainFrameTiming(); | |
enne (OOO)
2015/03/06 21:27:55
Is it possible to just do this unconditionally in
| |
310 | |
305 if (settings_.impl_side_painting) { | 311 if (settings_.impl_side_painting) { |
306 // Impl-side painting needs an update immediately post-commit to have the | 312 // Impl-side painting needs an update immediately post-commit to have the |
307 // opportunity to create tilings. Other paths can call UpdateDrawProperties | 313 // opportunity to create tilings. Other paths can call UpdateDrawProperties |
308 // more lazily when needed prior to drawing. Because invalidations may | 314 // more lazily when needed prior to drawing. Because invalidations may |
309 // be coming from the main thread, it's safe to do an update for lcd text | 315 // be coming from the main thread, it's safe to do an update for lcd text |
310 // at this point and see if lcd text needs to be disabled on any layers. | 316 // at this point and see if lcd text needs to be disabled on any layers. |
311 bool update_lcd_text = true; | 317 bool update_lcd_text = true; |
312 sync_tree()->UpdateDrawProperties(update_lcd_text); | 318 sync_tree()->UpdateDrawProperties(update_lcd_text); |
313 // Start working on newly created tiles immediately if needed. | 319 // Start working on newly created tiles immediately if needed. |
314 if (tile_manager_ && tile_priorities_dirty_) | 320 if (tile_manager_ && tile_priorities_dirty_) |
(...skipping 1471 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1786 // Now that we've synced everything from the pending tree to the active | 1792 // Now that we've synced everything from the pending tree to the active |
1787 // tree, rename the pending tree the recycle tree so we can reuse it on the | 1793 // tree, rename the pending tree the recycle tree so we can reuse it on the |
1788 // next sync. | 1794 // next sync. |
1789 DCHECK(!recycle_tree_); | 1795 DCHECK(!recycle_tree_); |
1790 pending_tree_.swap(recycle_tree_); | 1796 pending_tree_.swap(recycle_tree_); |
1791 | 1797 |
1792 active_tree_->SetRootLayerScrollOffsetDelegate( | 1798 active_tree_->SetRootLayerScrollOffsetDelegate( |
1793 root_layer_scroll_offset_delegate_); | 1799 root_layer_scroll_offset_delegate_); |
1794 | 1800 |
1795 UpdateViewportContainerSizes(); | 1801 UpdateViewportContainerSizes(); |
1802 | |
1803 // If we had a pending tree, now is when we should record main frame timing | |
1804 // information. | |
1805 RecordMainFrameTiming(); | |
1796 } else { | 1806 } else { |
1797 active_tree_->ProcessUIResourceRequestQueue(); | 1807 active_tree_->ProcessUIResourceRequestQueue(); |
1798 } | 1808 } |
1799 | 1809 |
1800 active_tree_->DidBecomeActive(); | 1810 active_tree_->DidBecomeActive(); |
1801 ActivateAnimations(); | 1811 ActivateAnimations(); |
1802 if (settings_.impl_side_painting) { | 1812 if (settings_.impl_side_painting) { |
1803 client_->RenewTreePriority(); | 1813 client_->RenewTreePriority(); |
1804 // If we have any picture layers, then by activating we also modified tile | 1814 // If we have any picture layers, then by activating we also modified tile |
1805 // priorities. | 1815 // priorities. |
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2060 *resource_pool = ResourcePool::Create( | 2070 *resource_pool = ResourcePool::Create( |
2061 resource_provider_.get(), GL_TEXTURE_2D); | 2071 resource_provider_.get(), GL_TEXTURE_2D); |
2062 | 2072 |
2063 *tile_task_worker_pool = PixelBufferTileTaskWorkerPool::Create( | 2073 *tile_task_worker_pool = PixelBufferTileTaskWorkerPool::Create( |
2064 task_runner, TileTaskWorkerPool::GetTaskGraphRunner(), context_provider, | 2074 task_runner, TileTaskWorkerPool::GetTaskGraphRunner(), context_provider, |
2065 resource_provider_.get(), | 2075 resource_provider_.get(), |
2066 GetMaxTransferBufferUsageBytes(context_provider->ContextCapabilities(), | 2076 GetMaxTransferBufferUsageBytes(context_provider->ContextCapabilities(), |
2067 settings_.renderer_settings.refresh_rate)); | 2077 settings_.renderer_settings.refresh_rate)); |
2068 } | 2078 } |
2069 | 2079 |
2080 void LayerTreeHostImpl::SetBeginMainFrameTime(base::TimeTicks frame_time) { | |
2081 main_frame_time_ = frame_time; | |
2082 } | |
2083 | |
2084 void LayerTreeHostImpl::RecordMainFrameTiming() { | |
2085 std::vector<int64_t> request_ids; | |
2086 active_tree_->GatherFrameTimingRequestIds(&request_ids); | |
2087 if (request_ids.empty()) | |
2088 return; | |
2089 | |
2090 base::TimeTicks end_time = client_->GetNextBeginImplFrameTimeIfRequested(); | |
2091 frame_timing_tracker_->SaveMainFrameTimeStamps( | |
2092 request_ids, main_frame_time_, end_time, | |
2093 active_tree_->source_frame_number()); | |
2094 } | |
2095 | |
2070 void LayerTreeHostImpl::DestroyTileManager() { | 2096 void LayerTreeHostImpl::DestroyTileManager() { |
2071 tile_manager_ = nullptr; | 2097 tile_manager_ = nullptr; |
2072 resource_pool_ = nullptr; | 2098 resource_pool_ = nullptr; |
2073 staging_resource_pool_ = nullptr; | 2099 staging_resource_pool_ = nullptr; |
2074 tile_task_worker_pool_ = nullptr; | 2100 tile_task_worker_pool_ = nullptr; |
2075 rasterizer_ = nullptr; | 2101 rasterizer_ = nullptr; |
2076 single_thread_synchronous_task_graph_runner_ = nullptr; | 2102 single_thread_synchronous_task_graph_runner_ = nullptr; |
2077 } | 2103 } |
2078 | 2104 |
2079 bool LayerTreeHostImpl::IsSynchronousSingleThreaded() const { | 2105 bool LayerTreeHostImpl::IsSynchronousSingleThreaded() const { |
(...skipping 1370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3450 (*it)->OnSetNeedsRedrawOnImpl(); | 3476 (*it)->OnSetNeedsRedrawOnImpl(); |
3451 } | 3477 } |
3452 | 3478 |
3453 void LayerTreeHostImpl::NotifySwapPromiseMonitorsOfForwardingToMainThread() { | 3479 void LayerTreeHostImpl::NotifySwapPromiseMonitorsOfForwardingToMainThread() { |
3454 std::set<SwapPromiseMonitor*>::iterator it = swap_promise_monitor_.begin(); | 3480 std::set<SwapPromiseMonitor*>::iterator it = swap_promise_monitor_.begin(); |
3455 for (; it != swap_promise_monitor_.end(); it++) | 3481 for (; it != swap_promise_monitor_.end(); it++) |
3456 (*it)->OnForwardScrollUpdateToMainThreadOnImpl(); | 3482 (*it)->OnForwardScrollUpdateToMainThreadOnImpl(); |
3457 } | 3483 } |
3458 | 3484 |
3459 } // namespace cc | 3485 } // namespace cc |
OLD | NEW |