| 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" |
| 11 #include "base/bind.h" | 11 #include "base/bind.h" |
| 12 #include "base/debug/trace_event.h" | 12 #include "base/debug/trace_event.h" |
| 13 #include "base/debug/trace_event_synthetic_delay.h" | 13 #include "base/debug/trace_event_synthetic_delay.h" |
| 14 #include "base/metrics/histogram.h" | 14 #include "base/metrics/histogram.h" |
| 15 #include "cc/base/swap_promise.h" | 15 #include "cc/base/swap_promise.h" |
| 16 #include "cc/debug/benchmark_instrumentation.h" | 16 #include "cc/debug/benchmark_instrumentation.h" |
| 17 #include "cc/debug/devtools_instrumentation.h" | 17 #include "cc/debug/devtools_instrumentation.h" |
| 18 #include "cc/input/input_handler.h" | 18 #include "cc/input/input_handler.h" |
| 19 #include "cc/output/context_provider.h" | 19 #include "cc/output/context_provider.h" |
| 20 #include "cc/output/output_surface.h" | 20 #include "cc/output/output_surface.h" |
| 21 #include "cc/quads/draw_quad.h" | 21 #include "cc/quads/draw_quad.h" |
| 22 #include "cc/resources/prioritized_resource_manager.h" | 22 #include "cc/resources/prioritized_resource_manager.h" |
| 23 #include "cc/scheduler/delay_based_time_source.h" | 23 #include "cc/scheduler/delay_based_time_source.h" |
| 24 #include "cc/scheduler/scheduler.h" | 24 #include "cc/scheduler/scheduler.h" |
| 25 #include "cc/trees/blocking_task_runner.h" | 25 #include "cc/trees/blocking_task_runner.h" |
| 26 #include "cc/trees/layer_tree_host.h" | 26 #include "cc/trees/layer_tree_host.h" |
| 27 #include "cc/trees/layer_tree_impl.h" | 27 #include "cc/trees/layer_tree_impl.h" |
| 28 #include "ui/gfx/frame_time.h" | 28 #include "ui/gfx/frame_time.h" |
| 29 | 29 |
| 30 namespace cc { |
| 31 |
| 30 namespace { | 32 namespace { |
| 31 | 33 |
| 32 // Measured in seconds. | 34 // Measured in seconds. |
| 33 const double kSmoothnessTakesPriorityExpirationDelay = 0.25; | 35 const double kSmoothnessTakesPriorityExpirationDelay = 0.25; |
| 34 | 36 |
| 35 class SwapPromiseChecker { | 37 class SwapPromiseChecker { |
| 36 public: | 38 public: |
| 37 explicit SwapPromiseChecker(cc::LayerTreeHost* layer_tree_host) | 39 explicit SwapPromiseChecker(LayerTreeHost* layer_tree_host) |
| 38 : layer_tree_host_(layer_tree_host) {} | 40 : layer_tree_host_(layer_tree_host) {} |
| 39 | 41 |
| 40 ~SwapPromiseChecker() { | 42 ~SwapPromiseChecker() { |
| 41 layer_tree_host_->BreakSwapPromises(cc::SwapPromise::COMMIT_FAILS); | 43 layer_tree_host_->BreakSwapPromises(SwapPromise::COMMIT_FAILS); |
| 42 } | 44 } |
| 43 | 45 |
| 44 private: | 46 private: |
| 45 cc::LayerTreeHost* layer_tree_host_; | 47 LayerTreeHost* layer_tree_host_; |
| 46 }; | 48 }; |
| 47 | 49 |
| 48 } // namespace | 50 } // namespace |
| 49 | 51 |
| 50 namespace cc { | |
| 51 | |
| 52 struct ThreadProxy::CommitPendingRequest { | 52 struct ThreadProxy::CommitPendingRequest { |
| 53 CompletionEvent completion; | 53 CompletionEvent completion; |
| 54 bool commit_pending; | 54 bool commit_pending; |
| 55 }; | 55 }; |
| 56 | 56 |
| 57 struct ThreadProxy::SchedulerStateRequest { | 57 struct ThreadProxy::SchedulerStateRequest { |
| 58 CompletionEvent completion; | 58 CompletionEvent completion; |
| 59 scoped_ptr<base::Value> state; | 59 scoped_ptr<base::Value> state; |
| 60 }; | 60 }; |
| 61 | 61 |
| (...skipping 680 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 742 base::Bind(&ThreadProxy::BeginMainFrameAbortedOnImplThread, | 742 base::Bind(&ThreadProxy::BeginMainFrameAbortedOnImplThread, |
| 743 impl_thread_weak_ptr_, | 743 impl_thread_weak_ptr_, |
| 744 did_handle)); | 744 did_handle)); |
| 745 return; | 745 return; |
| 746 } | 746 } |
| 747 | 747 |
| 748 if (layer_tree_host()->output_surface_lost()) { | 748 if (layer_tree_host()->output_surface_lost()) { |
| 749 TRACE_EVENT_INSTANT0( | 749 TRACE_EVENT_INSTANT0( |
| 750 "cc", "EarlyOut_OutputSurfaceLost", TRACE_EVENT_SCOPE_THREAD); | 750 "cc", "EarlyOut_OutputSurfaceLost", TRACE_EVENT_SCOPE_THREAD); |
| 751 bool did_handle = false; | 751 bool did_handle = false; |
| 752 DCHECK(false); |
| 752 Proxy::ImplThreadTaskRunner()->PostTask( | 753 Proxy::ImplThreadTaskRunner()->PostTask( |
| 753 FROM_HERE, | 754 FROM_HERE, |
| 754 base::Bind(&ThreadProxy::BeginMainFrameAbortedOnImplThread, | 755 base::Bind(&ThreadProxy::BeginMainFrameAbortedOnImplThread, |
| 755 impl_thread_weak_ptr_, | 756 impl_thread_weak_ptr_, |
| 756 did_handle)); | 757 did_handle)); |
| 757 return; | 758 return; |
| 758 } | 759 } |
| 759 | 760 |
| 760 // Do not notify the impl thread of commit requests that occur during | 761 // Do not notify the impl thread of commit requests that occur during |
| 761 // the apply/animate/layout part of the BeginMainFrameAndCommit process since | 762 // the apply/animate/layout part of the BeginMainFrameAndCommit process since |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 832 FROM_HERE, | 833 FROM_HERE, |
| 833 base::Bind(&ThreadProxy::BeginMainFrameAbortedOnImplThread, | 834 base::Bind(&ThreadProxy::BeginMainFrameAbortedOnImplThread, |
| 834 impl_thread_weak_ptr_, | 835 impl_thread_weak_ptr_, |
| 835 did_handle)); | 836 did_handle)); |
| 836 | 837 |
| 837 // Although the commit is internally aborted, this is because it has been | 838 // Although the commit is internally aborted, this is because it has been |
| 838 // detected to be a no-op. From the perspective of an embedder, this commit | 839 // detected to be a no-op. From the perspective of an embedder, this commit |
| 839 // went through, and input should no longer be throttled, etc. | 840 // went through, and input should no longer be throttled, etc. |
| 840 layer_tree_host()->CommitComplete(); | 841 layer_tree_host()->CommitComplete(); |
| 841 layer_tree_host()->DidBeginMainFrame(); | 842 layer_tree_host()->DidBeginMainFrame(); |
| 843 layer_tree_host()->BreakSwapPromises(SwapPromise::COMMIT_NO_UPDATE); |
| 842 return; | 844 return; |
| 843 } | 845 } |
| 844 | 846 |
| 845 // Notify the impl thread that the main thread is ready to commit. This will | 847 // Notify the impl thread that the main thread is ready to commit. This will |
| 846 // begin the commit process, which is blocking from the main thread's | 848 // begin the commit process, which is blocking from the main thread's |
| 847 // point of view, but asynchronously performed on the impl thread, | 849 // point of view, but asynchronously performed on the impl thread, |
| 848 // coordinated by the Scheduler. | 850 // coordinated by the Scheduler. |
| 849 { | 851 { |
| 850 TRACE_EVENT0("cc", "ThreadProxy::BeginMainFrame::commit"); | 852 TRACE_EVENT0("cc", "ThreadProxy::BeginMainFrame::commit"); |
| 851 | 853 |
| (...skipping 584 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1436 | 1438 |
| 1437 impl().timing_history.DidActivatePendingTree(); | 1439 impl().timing_history.DidActivatePendingTree(); |
| 1438 } | 1440 } |
| 1439 | 1441 |
| 1440 void ThreadProxy::DidManageTiles() { | 1442 void ThreadProxy::DidManageTiles() { |
| 1441 DCHECK(IsImplThread()); | 1443 DCHECK(IsImplThread()); |
| 1442 impl().scheduler->DidManageTiles(); | 1444 impl().scheduler->DidManageTiles(); |
| 1443 } | 1445 } |
| 1444 | 1446 |
| 1445 } // namespace cc | 1447 } // namespace cc |
| OLD | NEW |