| 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 <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/auto_reset.h" | 9 #include "base/auto_reset.h" |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| 11 #include "base/debug/trace_event.h" | 11 #include "base/debug/trace_event.h" |
| 12 #include "base/metrics/histogram.h" | 12 #include "base/metrics/histogram.h" |
| 13 #include "cc/base/swap_promise.h" |
| 13 #include "cc/debug/benchmark_instrumentation.h" | 14 #include "cc/debug/benchmark_instrumentation.h" |
| 14 #include "cc/input/input_handler.h" | 15 #include "cc/input/input_handler.h" |
| 15 #include "cc/output/context_provider.h" | 16 #include "cc/output/context_provider.h" |
| 16 #include "cc/output/output_surface.h" | 17 #include "cc/output/output_surface.h" |
| 17 #include "cc/quads/draw_quad.h" | 18 #include "cc/quads/draw_quad.h" |
| 18 #include "cc/resources/prioritized_resource_manager.h" | 19 #include "cc/resources/prioritized_resource_manager.h" |
| 19 #include "cc/scheduler/delay_based_time_source.h" | 20 #include "cc/scheduler/delay_based_time_source.h" |
| 20 #include "cc/scheduler/frame_rate_controller.h" | 21 #include "cc/scheduler/frame_rate_controller.h" |
| 21 #include "cc/scheduler/scheduler.h" | 22 #include "cc/scheduler/scheduler.h" |
| 22 #include "cc/trees/blocking_task_runner.h" | 23 #include "cc/trees/blocking_task_runner.h" |
| 23 #include "cc/trees/layer_tree_host.h" | 24 #include "cc/trees/layer_tree_host.h" |
| 24 #include "cc/trees/layer_tree_impl.h" | 25 #include "cc/trees/layer_tree_impl.h" |
| 25 #include "ui/gfx/frame_time.h" | 26 #include "ui/gfx/frame_time.h" |
| 26 | 27 |
| 28 namespace { |
| 29 |
| 27 // Measured in seconds. | 30 // Measured in seconds. |
| 28 const double kSmoothnessTakesPriorityExpirationDelay = 0.25; | 31 const double kSmoothnessTakesPriorityExpirationDelay = 0.25; |
| 29 | 32 |
| 30 const size_t kDurationHistorySize = 60; | 33 const size_t kDurationHistorySize = 60; |
| 31 const double kCommitAndActivationDurationEstimationPercentile = 50.0; | 34 const double kCommitAndActivationDurationEstimationPercentile = 50.0; |
| 32 const double kDrawDurationEstimationPercentile = 100.0; | 35 const double kDrawDurationEstimationPercentile = 100.0; |
| 33 const int kDrawDurationEstimatePaddingInMicroseconds = 0; | 36 const int kDrawDurationEstimatePaddingInMicroseconds = 0; |
| 34 | 37 |
| 38 class SwapPromiseChecker { |
| 39 public: |
| 40 explicit SwapPromiseChecker(cc::LayerTreeHost* layer_tree_host) |
| 41 : layer_tree_host_(layer_tree_host) {} |
| 42 |
| 43 ~SwapPromiseChecker() { |
| 44 layer_tree_host_->BreakSwapPromises(cc::SwapPromise::COMMIT_FAILS); |
| 45 } |
| 46 |
| 47 private: |
| 48 cc::LayerTreeHost* layer_tree_host_; |
| 49 }; |
| 50 |
| 51 } // namespace |
| 52 |
| 35 namespace cc { | 53 namespace cc { |
| 36 | 54 |
| 37 struct ThreadProxy::ReadbackRequest { | 55 struct ThreadProxy::ReadbackRequest { |
| 38 CompletionEvent completion; | 56 CompletionEvent completion; |
| 39 bool success; | 57 bool success; |
| 40 void* pixels; | 58 void* pixels; |
| 41 gfx::Rect rect; | 59 gfx::Rect rect; |
| 42 }; | 60 }; |
| 43 | 61 |
| 44 struct ThreadProxy::CommitPendingRequest { | 62 struct ThreadProxy::CommitPendingRequest { |
| (...skipping 702 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 747 if (!layer_tree_host()) | 765 if (!layer_tree_host()) |
| 748 return; | 766 return; |
| 749 | 767 |
| 750 if (defer_commits_) { | 768 if (defer_commits_) { |
| 751 pending_deferred_commit_ = begin_main_frame_state.Pass(); | 769 pending_deferred_commit_ = begin_main_frame_state.Pass(); |
| 752 layer_tree_host()->DidDeferCommit(); | 770 layer_tree_host()->DidDeferCommit(); |
| 753 TRACE_EVENT0("cc", "EarlyOut_DeferCommits"); | 771 TRACE_EVENT0("cc", "EarlyOut_DeferCommits"); |
| 754 return; | 772 return; |
| 755 } | 773 } |
| 756 | 774 |
| 775 // If the commit finishes, LayerTreeHost will transfer its swap promises to |
| 776 // LayerTreeImpl. The destructor of SwapPromiseChecker checks LayerTressHost's |
| 777 // swap promises. |
| 778 SwapPromiseChecker swap_promise_checker(layer_tree_host()); |
| 779 |
| 757 // Do not notify the impl thread of commit requests that occur during | 780 // Do not notify the impl thread of commit requests that occur during |
| 758 // the apply/animate/layout part of the BeginMainFrameAndCommit process since | 781 // the apply/animate/layout part of the BeginMainFrameAndCommit process since |
| 759 // those commit requests will get painted immediately. Once we have done | 782 // those commit requests will get painted immediately. Once we have done |
| 760 // the paint, commit_requested_ will be set to false to allow new commit | 783 // the paint, commit_requested_ will be set to false to allow new commit |
| 761 // requests to be scheduled. | 784 // requests to be scheduled. |
| 762 commit_requested_ = true; | 785 commit_requested_ = true; |
| 763 commit_request_sent_to_impl_thread_ = true; | 786 commit_request_sent_to_impl_thread_ = true; |
| 764 | 787 |
| 765 // On the other hand, the AnimationRequested flag needs to be cleared | 788 // On the other hand, the AnimationRequested flag needs to be cleared |
| 766 // here so that any animation requests generated by the apply or animate | 789 // here so that any animation requests generated by the apply or animate |
| (...skipping 859 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1626 commit_to_activate_duration_history_.InsertSample( | 1649 commit_to_activate_duration_history_.InsertSample( |
| 1627 base::TimeTicks::HighResNow() - commit_complete_time_); | 1650 base::TimeTicks::HighResNow() - commit_complete_time_); |
| 1628 } | 1651 } |
| 1629 | 1652 |
| 1630 void ThreadProxy::DidManageTiles() { | 1653 void ThreadProxy::DidManageTiles() { |
| 1631 DCHECK(IsImplThread()); | 1654 DCHECK(IsImplThread()); |
| 1632 scheduler_on_impl_thread_->DidManageTiles(); | 1655 scheduler_on_impl_thread_->DidManageTiles(); |
| 1633 } | 1656 } |
| 1634 | 1657 |
| 1635 } // namespace cc | 1658 } // namespace cc |
| OLD | NEW |