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/single_thread_proxy.h" | 5 #include "cc/trees/single_thread_proxy.h" |
6 | 6 |
7 #include "base/auto_reset.h" | 7 #include "base/auto_reset.h" |
8 #include "base/debug/trace_event.h" | 8 #include "base/debug/trace_event.h" |
9 #include "cc/debug/benchmark_instrumentation.h" | 9 #include "cc/debug/benchmark_instrumentation.h" |
10 #include "cc/output/context_provider.h" | 10 #include "cc/output/context_provider.h" |
11 #include "cc/output/output_surface.h" | 11 #include "cc/output/output_surface.h" |
12 #include "cc/quads/draw_quad.h" | 12 #include "cc/quads/draw_quad.h" |
13 #include "cc/resources/prioritized_resource_manager.h" | 13 #include "cc/resources/prioritized_resource_manager.h" |
14 #include "cc/resources/resource_update_controller.h" | 14 #include "cc/resources/resource_update_controller.h" |
15 #include "cc/trees/blocking_task_runner.h" | 15 #include "cc/trees/blocking_task_runner.h" |
16 #include "cc/trees/layer_tree_host.h" | 16 #include "cc/trees/layer_tree_host.h" |
17 #include "cc/trees/layer_tree_host_single_thread_client.h" | 17 #include "cc/trees/layer_tree_host_single_thread_client.h" |
18 #include "cc/trees/layer_tree_impl.h" | 18 #include "cc/trees/layer_tree_impl.h" |
19 #include "ui/gfx/frame_time.h" | 19 #include "ui/gfx/frame_time.h" |
20 | 20 |
21 namespace cc { | 21 namespace cc { |
22 | 22 |
23 scoped_ptr<Proxy> SingleThreadProxy::Create( | 23 scoped_ptr<Proxy> SingleThreadProxy::Create( |
24 LayerTreeHost* layer_tree_host, | 24 LayerTreeHost* layer_tree_host, |
25 LayerTreeHostSingleThreadClient* client, | 25 LayerTreeHostSingleThreadClient* client, |
26 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner) { | 26 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, |
| 27 BeginFrameManager* begin_frame_manager) { |
27 return make_scoped_ptr( | 28 return make_scoped_ptr( |
28 new SingleThreadProxy(layer_tree_host, client, main_task_runner)) | 29 new SingleThreadProxy(layer_tree_host, |
| 30 client, |
| 31 main_task_runner, |
| 32 begin_frame_manager)) |
29 .PassAs<Proxy>(); | 33 .PassAs<Proxy>(); |
30 } | 34 } |
31 | 35 |
32 SingleThreadProxy::SingleThreadProxy( | 36 SingleThreadProxy::SingleThreadProxy( |
33 LayerTreeHost* layer_tree_host, | 37 LayerTreeHost* layer_tree_host, |
34 LayerTreeHostSingleThreadClient* client, | 38 LayerTreeHostSingleThreadClient* client, |
35 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner) | 39 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, |
| 40 BeginFrameManager* begin_frame_manager) |
36 : Proxy(main_task_runner, NULL), | 41 : Proxy(main_task_runner, NULL), |
37 layer_tree_host_(layer_tree_host), | 42 layer_tree_host_(layer_tree_host), |
38 client_(client), | 43 client_(client), |
39 timing_history_(layer_tree_host->rendering_stats_instrumentation()), | 44 timing_history_(layer_tree_host->rendering_stats_instrumentation()), |
40 next_frame_is_newly_committed_frame_(false), | 45 next_frame_is_newly_committed_frame_(false), |
41 inside_draw_(false), | 46 inside_draw_(false), |
42 defer_commits_(false), | 47 defer_commits_(false), |
43 commit_was_deferred_(false), | 48 commit_was_deferred_(false), |
44 commit_requested_(false), | 49 commit_requested_(false), |
| 50 begin_frame_manager_(begin_frame_manager), |
45 weak_factory_(this) { | 51 weak_factory_(this) { |
46 TRACE_EVENT0("cc", "SingleThreadProxy::SingleThreadProxy"); | 52 TRACE_EVENT0("cc", "SingleThreadProxy::SingleThreadProxy"); |
47 DCHECK(Proxy::IsMainThread()); | 53 DCHECK(Proxy::IsMainThread()); |
48 DCHECK(layer_tree_host); | 54 DCHECK(layer_tree_host); |
49 | 55 |
50 // Impl-side painting not supported without threaded compositing. | 56 // Impl-side painting not supported without threaded compositing. |
51 CHECK(!layer_tree_host->settings().impl_side_painting) | 57 CHECK(!layer_tree_host->settings().impl_side_painting) |
52 << "Threaded compositing must be enabled to use impl-side painting."; | 58 << "Threaded compositing must be enabled to use impl-side painting."; |
53 } | 59 } |
54 | 60 |
(...skipping 28 matching lines...) Expand all Loading... |
83 // Scheduling is controlled by the embedder in the single thread case, so | 89 // Scheduling is controlled by the embedder in the single thread case, so |
84 // nothing to do. | 90 // nothing to do. |
85 DCHECK(Proxy::IsMainThread()); | 91 DCHECK(Proxy::IsMainThread()); |
86 DebugScopedSetImplThread impl(this); | 92 DebugScopedSetImplThread impl(this); |
87 if (layer_tree_host_->settings().single_thread_proxy_scheduler && | 93 if (layer_tree_host_->settings().single_thread_proxy_scheduler && |
88 !scheduler_on_impl_thread_) { | 94 !scheduler_on_impl_thread_) { |
89 SchedulerSettings scheduler_settings(layer_tree_host_->settings()); | 95 SchedulerSettings scheduler_settings(layer_tree_host_->settings()); |
90 scheduler_on_impl_thread_ = Scheduler::Create(this, | 96 scheduler_on_impl_thread_ = Scheduler::Create(this, |
91 scheduler_settings, | 97 scheduler_settings, |
92 layer_tree_host_->id(), | 98 layer_tree_host_->id(), |
93 MainThreadTaskRunner()); | 99 MainThreadTaskRunner(), |
| 100 begin_frame_manager_); |
94 scheduler_on_impl_thread_->SetCanStart(); | 101 scheduler_on_impl_thread_->SetCanStart(); |
95 scheduler_on_impl_thread_->SetVisible(layer_tree_host_impl_->visible()); | 102 scheduler_on_impl_thread_->SetVisible(layer_tree_host_impl_->visible()); |
96 } | 103 } |
97 } | 104 } |
98 | 105 |
99 void SingleThreadProxy::SetVisible(bool visible) { | 106 void SingleThreadProxy::SetVisible(bool visible) { |
100 TRACE_EVENT0("cc", "SingleThreadProxy::SetVisible"); | 107 TRACE_EVENT0("cc", "SingleThreadProxy::SetVisible"); |
101 DebugScopedSetImplThread impl(this); | 108 DebugScopedSetImplThread impl(this); |
102 layer_tree_host_impl_->SetVisible(visible); | 109 layer_tree_host_impl_->SetVisible(visible); |
103 if (scheduler_on_impl_thread_) | 110 if (scheduler_on_impl_thread_) |
(...skipping 555 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
659 | 666 |
660 base::TimeDelta SingleThreadProxy::CommitToActivateDurationEstimate() { | 667 base::TimeDelta SingleThreadProxy::CommitToActivateDurationEstimate() { |
661 return timing_history_.CommitToActivateDurationEstimate(); | 668 return timing_history_.CommitToActivateDurationEstimate(); |
662 } | 669 } |
663 | 670 |
664 void SingleThreadProxy::DidBeginImplFrameDeadline() { | 671 void SingleThreadProxy::DidBeginImplFrameDeadline() { |
665 layer_tree_host_impl_->ResetCurrentFrameTimeForNextFrame(); | 672 layer_tree_host_impl_->ResetCurrentFrameTimeForNextFrame(); |
666 } | 673 } |
667 | 674 |
668 } // namespace cc | 675 } // namespace cc |
OLD | NEW |