Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(35)

Side by Side Diff: cc/trees/thread_proxy.cc

Issue 619843002: cc: Make separate interface for BeginFrame ipc from OutputSurface (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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"
(...skipping 30 matching lines...) Expand all
41 } // namespace 41 } // namespace
42 42
43 struct ThreadProxy::SchedulerStateRequest { 43 struct ThreadProxy::SchedulerStateRequest {
44 CompletionEvent completion; 44 CompletionEvent completion;
45 scoped_ptr<base::Value> state; 45 scoped_ptr<base::Value> state;
46 }; 46 };
47 47
48 scoped_ptr<Proxy> ThreadProxy::Create( 48 scoped_ptr<Proxy> ThreadProxy::Create(
49 LayerTreeHost* layer_tree_host, 49 LayerTreeHost* layer_tree_host,
50 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, 50 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner,
51 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner) { 51 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner,
52 return make_scoped_ptr( 52 scoped_ptr<BeginFrameSource> external_begin_frame_source) {
53 new ThreadProxy(layer_tree_host, main_task_runner, impl_task_runner)); 53 return make_scoped_ptr(new ThreadProxy(layer_tree_host,
54 main_task_runner,
55 impl_task_runner,
56 external_begin_frame_source.Pass()));
54 } 57 }
55 58
56 ThreadProxy::ThreadProxy( 59 ThreadProxy::ThreadProxy(
57 LayerTreeHost* layer_tree_host, 60 LayerTreeHost* layer_tree_host,
58 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, 61 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner,
59 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner) 62 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner,
63 scoped_ptr<BeginFrameSource> external_begin_frame_source)
60 : Proxy(main_task_runner, impl_task_runner), 64 : Proxy(main_task_runner, impl_task_runner),
61 main_thread_only_vars_unsafe_(this, layer_tree_host->id()), 65 main_thread_only_vars_unsafe_(this, layer_tree_host->id()),
62 main_thread_or_blocked_vars_unsafe_(layer_tree_host), 66 main_thread_or_blocked_vars_unsafe_(layer_tree_host),
63 compositor_thread_vars_unsafe_( 67 compositor_thread_vars_unsafe_(
64 this, 68 this,
65 layer_tree_host->id(), 69 layer_tree_host->id(),
66 layer_tree_host->rendering_stats_instrumentation()) { 70 layer_tree_host->rendering_stats_instrumentation(),
71 external_begin_frame_source.Pass()) {
67 TRACE_EVENT0("cc", "ThreadProxy::ThreadProxy"); 72 TRACE_EVENT0("cc", "ThreadProxy::ThreadProxy");
68 DCHECK(IsMainThread()); 73 DCHECK(IsMainThread());
69 DCHECK(this->layer_tree_host()); 74 DCHECK(this->layer_tree_host());
70 } 75 }
71 76
72 ThreadProxy::MainThreadOnly::MainThreadOnly(ThreadProxy* proxy, 77 ThreadProxy::MainThreadOnly::MainThreadOnly(ThreadProxy* proxy,
73 int layer_tree_host_id) 78 int layer_tree_host_id)
74 : layer_tree_host_id(layer_tree_host_id), 79 : layer_tree_host_id(layer_tree_host_id),
75 animate_requested(false), 80 animate_requested(false),
76 commit_requested(false), 81 commit_requested(false),
(...skipping 15 matching lines...) Expand all
92 ThreadProxy::MainThreadOrBlockedMainThread::~MainThreadOrBlockedMainThread() {} 97 ThreadProxy::MainThreadOrBlockedMainThread::~MainThreadOrBlockedMainThread() {}
93 98
94 PrioritizedResourceManager* 99 PrioritizedResourceManager*
95 ThreadProxy::MainThreadOrBlockedMainThread::contents_texture_manager() { 100 ThreadProxy::MainThreadOrBlockedMainThread::contents_texture_manager() {
96 return layer_tree_host->contents_texture_manager(); 101 return layer_tree_host->contents_texture_manager();
97 } 102 }
98 103
99 ThreadProxy::CompositorThreadOnly::CompositorThreadOnly( 104 ThreadProxy::CompositorThreadOnly::CompositorThreadOnly(
100 ThreadProxy* proxy, 105 ThreadProxy* proxy,
101 int layer_tree_host_id, 106 int layer_tree_host_id,
102 RenderingStatsInstrumentation* rendering_stats_instrumentation) 107 RenderingStatsInstrumentation* rendering_stats_instrumentation,
108 scoped_ptr<BeginFrameSource> external_begin_frame_source)
103 : layer_tree_host_id(layer_tree_host_id), 109 : layer_tree_host_id(layer_tree_host_id),
104 contents_texture_manager(NULL), 110 contents_texture_manager(NULL),
105 commit_completion_event(NULL), 111 commit_completion_event(NULL),
106 completion_event_for_commit_held_on_tree_activation(NULL), 112 completion_event_for_commit_held_on_tree_activation(NULL),
107 next_frame_is_newly_committed_frame(false), 113 next_frame_is_newly_committed_frame(false),
108 inside_draw(false), 114 inside_draw(false),
109 input_throttled_until_commit(false), 115 input_throttled_until_commit(false),
110 smoothness_priority_expiration_notifier( 116 smoothness_priority_expiration_notifier(
111 proxy->ImplThreadTaskRunner(), 117 proxy->ImplThreadTaskRunner(),
112 base::Bind(&ThreadProxy::RenewTreePriority, base::Unretained(proxy)), 118 base::Bind(&ThreadProxy::RenewTreePriority, base::Unretained(proxy)),
113 base::TimeDelta::FromMilliseconds( 119 base::TimeDelta::FromMilliseconds(
114 kSmoothnessTakesPriorityExpirationDelay * 1000)), 120 kSmoothnessTakesPriorityExpirationDelay * 1000)),
115 timing_history(rendering_stats_instrumentation), 121 timing_history(rendering_stats_instrumentation),
122 external_begin_frame_source(external_begin_frame_source.Pass()),
116 weak_factory(proxy) { 123 weak_factory(proxy) {
117 } 124 }
118 125
119 ThreadProxy::CompositorThreadOnly::~CompositorThreadOnly() {} 126 ThreadProxy::CompositorThreadOnly::~CompositorThreadOnly() {}
120 127
121 ThreadProxy::~ThreadProxy() { 128 ThreadProxy::~ThreadProxy() {
122 TRACE_EVENT0("cc", "ThreadProxy::~ThreadProxy"); 129 TRACE_EVENT0("cc", "ThreadProxy::~ThreadProxy");
123 DCHECK(IsMainThread()); 130 DCHECK(IsMainThread());
124 DCHECK(!main().started); 131 DCHECK(!main().started);
125 } 132 }
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
329 336
330 void ThreadProxy::DidSwapBuffersCompleteOnImplThread() { 337 void ThreadProxy::DidSwapBuffersCompleteOnImplThread() {
331 TRACE_EVENT0("cc", "ThreadProxy::DidSwapBuffersCompleteOnImplThread"); 338 TRACE_EVENT0("cc", "ThreadProxy::DidSwapBuffersCompleteOnImplThread");
332 DCHECK(IsImplThread()); 339 DCHECK(IsImplThread());
333 impl().scheduler->DidSwapBuffersComplete(); 340 impl().scheduler->DidSwapBuffersComplete();
334 Proxy::MainThreadTaskRunner()->PostTask( 341 Proxy::MainThreadTaskRunner()->PostTask(
335 FROM_HERE, 342 FROM_HERE,
336 base::Bind(&ThreadProxy::DidCompleteSwapBuffers, main_thread_weak_ptr_)); 343 base::Bind(&ThreadProxy::DidCompleteSwapBuffers, main_thread_weak_ptr_));
337 } 344 }
338 345
339 BeginFrameSource* ThreadProxy::ExternalBeginFrameSource() {
340 return impl().layer_tree_host_impl.get();
341 }
342
343 void ThreadProxy::WillBeginImplFrame(const BeginFrameArgs& args) { 346 void ThreadProxy::WillBeginImplFrame(const BeginFrameArgs& args) {
344 impl().layer_tree_host_impl->WillBeginImplFrame(args); 347 impl().layer_tree_host_impl->WillBeginImplFrame(args);
345 } 348 }
346 349
347 void ThreadProxy::OnCanDrawStateChanged(bool can_draw) { 350 void ThreadProxy::OnCanDrawStateChanged(bool can_draw) {
348 TRACE_EVENT1( 351 TRACE_EVENT1(
349 "cc", "ThreadProxy::OnCanDrawStateChanged", "can_draw", can_draw); 352 "cc", "ThreadProxy::OnCanDrawStateChanged", "can_draw", can_draw);
350 DCHECK(IsImplThread()); 353 DCHECK(IsImplThread());
351 impl().scheduler->SetCanDraw(can_draw); 354 impl().scheduler->SetCanDraw(can_draw);
352 } 355 }
(...skipping 784 matching lines...) Expand 10 before | Expand all | Expand 10 after
1137 DCHECK(IsMainThread()); 1140 DCHECK(IsMainThread());
1138 layer_tree_host()->SetAnimationEvents(events.Pass()); 1141 layer_tree_host()->SetAnimationEvents(events.Pass());
1139 } 1142 }
1140 1143
1141 void ThreadProxy::InitializeImplOnImplThread(CompletionEvent* completion) { 1144 void ThreadProxy::InitializeImplOnImplThread(CompletionEvent* completion) {
1142 TRACE_EVENT0("cc", "ThreadProxy::InitializeImplOnImplThread"); 1145 TRACE_EVENT0("cc", "ThreadProxy::InitializeImplOnImplThread");
1143 DCHECK(IsImplThread()); 1146 DCHECK(IsImplThread());
1144 impl().layer_tree_host_impl = 1147 impl().layer_tree_host_impl =
1145 layer_tree_host()->CreateLayerTreeHostImpl(this); 1148 layer_tree_host()->CreateLayerTreeHostImpl(this);
1146 SchedulerSettings scheduler_settings(layer_tree_host()->settings()); 1149 SchedulerSettings scheduler_settings(layer_tree_host()->settings());
1147 impl().scheduler = Scheduler::Create(this, 1150 impl().scheduler = Scheduler::Create(
1148 scheduler_settings, 1151 this,
1149 impl().layer_tree_host_id, 1152 scheduler_settings,
1150 ImplThreadTaskRunner(), 1153 impl().layer_tree_host_id,
1151 base::PowerMonitor::Get()); 1154 ImplThreadTaskRunner(),
1155 base::PowerMonitor::Get(),
1156 impl().external_begin_frame_source.Pass());
1152 impl().scheduler->SetVisible(impl().layer_tree_host_impl->visible()); 1157 impl().scheduler->SetVisible(impl().layer_tree_host_impl->visible());
1153
1154 impl_thread_weak_ptr_ = impl().weak_factory.GetWeakPtr(); 1158 impl_thread_weak_ptr_ = impl().weak_factory.GetWeakPtr();
1155 completion->Signal(); 1159 completion->Signal();
1156 } 1160 }
1157 1161
1158 void ThreadProxy::DeleteContentsTexturesOnImplThread( 1162 void ThreadProxy::DeleteContentsTexturesOnImplThread(
1159 CompletionEvent* completion) { 1163 CompletionEvent* completion) {
1160 TRACE_EVENT0("cc", "ThreadProxy::DeleteContentsTexturesOnImplThread"); 1164 TRACE_EVENT0("cc", "ThreadProxy::DeleteContentsTexturesOnImplThread");
1161 DCHECK(IsImplThread()); 1165 DCHECK(IsImplThread());
1162 DCHECK(IsMainThreadBlocked()); 1166 DCHECK(IsMainThreadBlocked());
1163 layer_tree_host()->DeleteContentsTexturesOnImplThread( 1167 layer_tree_host()->DeleteContentsTexturesOnImplThread(
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
1201 completion->Signal(); 1205 completion->Signal();
1202 } 1206 }
1203 1207
1204 void ThreadProxy::LayerTreeHostClosedOnImplThread(CompletionEvent* completion) { 1208 void ThreadProxy::LayerTreeHostClosedOnImplThread(CompletionEvent* completion) {
1205 TRACE_EVENT0("cc", "ThreadProxy::LayerTreeHostClosedOnImplThread"); 1209 TRACE_EVENT0("cc", "ThreadProxy::LayerTreeHostClosedOnImplThread");
1206 DCHECK(IsImplThread()); 1210 DCHECK(IsImplThread());
1207 DCHECK(IsMainThreadBlocked()); 1211 DCHECK(IsMainThreadBlocked());
1208 layer_tree_host()->DeleteContentsTexturesOnImplThread( 1212 layer_tree_host()->DeleteContentsTexturesOnImplThread(
1209 impl().layer_tree_host_impl->resource_provider()); 1213 impl().layer_tree_host_impl->resource_provider());
1210 impl().current_resource_update_controller = nullptr; 1214 impl().current_resource_update_controller = nullptr;
1211 impl().layer_tree_host_impl->SetNeedsBeginFrames(false);
1212 impl().scheduler = nullptr; 1215 impl().scheduler = nullptr;
1213 impl().layer_tree_host_impl = nullptr; 1216 impl().layer_tree_host_impl = nullptr;
1214 impl().weak_factory.InvalidateWeakPtrs(); 1217 impl().weak_factory.InvalidateWeakPtrs();
1215 // We need to explicitly shutdown the notifier to destroy any weakptrs it is 1218 // We need to explicitly shutdown the notifier to destroy any weakptrs it is
1216 // holding while still on the compositor thread. This also ensures any 1219 // holding while still on the compositor thread. This also ensures any
1217 // callbacks holding a ThreadProxy pointer are cancelled. 1220 // callbacks holding a ThreadProxy pointer are cancelled.
1218 impl().smoothness_priority_expiration_notifier.Shutdown(); 1221 impl().smoothness_priority_expiration_notifier.Shutdown();
1219 impl().contents_texture_manager = NULL; 1222 impl().contents_texture_manager = NULL;
1220 completion->Signal(); 1223 completion->Signal();
1221 } 1224 }
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
1355 1358
1356 impl().timing_history.DidActivateSyncTree(); 1359 impl().timing_history.DidActivateSyncTree();
1357 } 1360 }
1358 1361
1359 void ThreadProxy::DidManageTiles() { 1362 void ThreadProxy::DidManageTiles() {
1360 DCHECK(IsImplThread()); 1363 DCHECK(IsImplThread());
1361 impl().scheduler->DidManageTiles(); 1364 impl().scheduler->DidManageTiles();
1362 } 1365 }
1363 1366
1364 } // namespace cc 1367 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/thread_proxy.h ('k') | content/browser/android/in_process/synchronous_compositor_external_begin_frame_source.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698