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

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 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
338 345
339 void ThreadProxy::DidSwapBuffersCompleteOnImplThread() { 346 void ThreadProxy::DidSwapBuffersCompleteOnImplThread() {
340 TRACE_EVENT0("cc", "ThreadProxy::DidSwapBuffersCompleteOnImplThread"); 347 TRACE_EVENT0("cc", "ThreadProxy::DidSwapBuffersCompleteOnImplThread");
341 DCHECK(IsImplThread()); 348 DCHECK(IsImplThread());
342 impl().scheduler->DidSwapBuffersComplete(); 349 impl().scheduler->DidSwapBuffersComplete();
343 Proxy::MainThreadTaskRunner()->PostTask( 350 Proxy::MainThreadTaskRunner()->PostTask(
344 FROM_HERE, 351 FROM_HERE,
345 base::Bind(&ThreadProxy::DidCompleteSwapBuffers, main_thread_weak_ptr_)); 352 base::Bind(&ThreadProxy::DidCompleteSwapBuffers, main_thread_weak_ptr_));
346 } 353 }
347 354
348 BeginFrameSource* ThreadProxy::ExternalBeginFrameSource() {
349 return impl().layer_tree_host_impl.get();
350 }
351
352 void ThreadProxy::WillBeginImplFrame(const BeginFrameArgs& args) { 355 void ThreadProxy::WillBeginImplFrame(const BeginFrameArgs& args) {
353 impl().layer_tree_host_impl->WillBeginImplFrame(args); 356 impl().layer_tree_host_impl->WillBeginImplFrame(args);
354 } 357 }
355 358
356 void ThreadProxy::OnCanDrawStateChanged(bool can_draw) { 359 void ThreadProxy::OnCanDrawStateChanged(bool can_draw) {
357 TRACE_EVENT1( 360 TRACE_EVENT1(
358 "cc", "ThreadProxy::OnCanDrawStateChanged", "can_draw", can_draw); 361 "cc", "ThreadProxy::OnCanDrawStateChanged", "can_draw", can_draw);
359 DCHECK(IsImplThread()); 362 DCHECK(IsImplThread());
360 impl().scheduler->SetCanDraw(can_draw); 363 impl().scheduler->SetCanDraw(can_draw);
361 UpdateBackgroundAnimateTicking(); 364 UpdateBackgroundAnimateTicking();
(...skipping 780 matching lines...) Expand 10 before | Expand all | Expand 10 after
1142 DCHECK(IsMainThread()); 1145 DCHECK(IsMainThread());
1143 layer_tree_host()->SetAnimationEvents(events.Pass()); 1146 layer_tree_host()->SetAnimationEvents(events.Pass());
1144 } 1147 }
1145 1148
1146 void ThreadProxy::InitializeImplOnImplThread(CompletionEvent* completion) { 1149 void ThreadProxy::InitializeImplOnImplThread(CompletionEvent* completion) {
1147 TRACE_EVENT0("cc", "ThreadProxy::InitializeImplOnImplThread"); 1150 TRACE_EVENT0("cc", "ThreadProxy::InitializeImplOnImplThread");
1148 DCHECK(IsImplThread()); 1151 DCHECK(IsImplThread());
1149 impl().layer_tree_host_impl = 1152 impl().layer_tree_host_impl =
1150 layer_tree_host()->CreateLayerTreeHostImpl(this); 1153 layer_tree_host()->CreateLayerTreeHostImpl(this);
1151 SchedulerSettings scheduler_settings(layer_tree_host()->settings()); 1154 SchedulerSettings scheduler_settings(layer_tree_host()->settings());
1152 impl().scheduler = Scheduler::Create(this, 1155 impl().scheduler = Scheduler::Create(
1153 scheduler_settings, 1156 this,
1154 impl().layer_tree_host_id, 1157 scheduler_settings,
1155 ImplThreadTaskRunner(), 1158 impl().layer_tree_host_id,
1156 base::PowerMonitor::Get()); 1159 ImplThreadTaskRunner(),
1160 base::PowerMonitor::Get(),
1161 impl().external_begin_frame_source.Pass());
1157 impl().scheduler->SetVisible(impl().layer_tree_host_impl->visible()); 1162 impl().scheduler->SetVisible(impl().layer_tree_host_impl->visible());
1158
1159 impl_thread_weak_ptr_ = impl().weak_factory.GetWeakPtr(); 1163 impl_thread_weak_ptr_ = impl().weak_factory.GetWeakPtr();
1160 completion->Signal(); 1164 completion->Signal();
1161 } 1165 }
1162 1166
1163 void ThreadProxy::DeleteContentsTexturesOnImplThread( 1167 void ThreadProxy::DeleteContentsTexturesOnImplThread(
1164 CompletionEvent* completion) { 1168 CompletionEvent* completion) {
1165 TRACE_EVENT0("cc", "ThreadProxy::DeleteContentsTexturesOnImplThread"); 1169 TRACE_EVENT0("cc", "ThreadProxy::DeleteContentsTexturesOnImplThread");
1166 DCHECK(IsImplThread()); 1170 DCHECK(IsImplThread());
1167 DCHECK(IsMainThreadBlocked()); 1171 DCHECK(IsMainThreadBlocked());
1168 layer_tree_host()->DeleteContentsTexturesOnImplThread( 1172 layer_tree_host()->DeleteContentsTexturesOnImplThread(
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
1206 completion->Signal(); 1210 completion->Signal();
1207 } 1211 }
1208 1212
1209 void ThreadProxy::LayerTreeHostClosedOnImplThread(CompletionEvent* completion) { 1213 void ThreadProxy::LayerTreeHostClosedOnImplThread(CompletionEvent* completion) {
1210 TRACE_EVENT0("cc", "ThreadProxy::LayerTreeHostClosedOnImplThread"); 1214 TRACE_EVENT0("cc", "ThreadProxy::LayerTreeHostClosedOnImplThread");
1211 DCHECK(IsImplThread()); 1215 DCHECK(IsImplThread());
1212 DCHECK(IsMainThreadBlocked()); 1216 DCHECK(IsMainThreadBlocked());
1213 layer_tree_host()->DeleteContentsTexturesOnImplThread( 1217 layer_tree_host()->DeleteContentsTexturesOnImplThread(
1214 impl().layer_tree_host_impl->resource_provider()); 1218 impl().layer_tree_host_impl->resource_provider());
1215 impl().current_resource_update_controller = nullptr; 1219 impl().current_resource_update_controller = nullptr;
1216 impl().layer_tree_host_impl->SetNeedsBeginFrames(false);
1217 impl().scheduler = nullptr; 1220 impl().scheduler = nullptr;
1218 impl().layer_tree_host_impl = nullptr; 1221 impl().layer_tree_host_impl = nullptr;
1219 impl().weak_factory.InvalidateWeakPtrs(); 1222 impl().weak_factory.InvalidateWeakPtrs();
1220 // We need to explicitly cancel the notifier, since it isn't using weak ptrs. 1223 // We need to explicitly cancel the notifier, since it isn't using weak ptrs.
1221 // TODO(vmpstr): We should see if we can make it use weak ptrs and still keep 1224 // TODO(vmpstr): We should see if we can make it use weak ptrs and still keep
1222 // the convention of having a weak ptr factory initialized last. Alternatively 1225 // the convention of having a weak ptr factory initialized last. Alternatively
1223 // we should moved the notifier (and RenewTreePriority) to LTHI. See 1226 // we should moved the notifier (and RenewTreePriority) to LTHI. See
1224 // crbug.com/411972 1227 // crbug.com/411972
1225 impl().smoothness_priority_expiration_notifier.Cancel(); 1228 impl().smoothness_priority_expiration_notifier.Cancel();
1226 impl().contents_texture_manager = NULL; 1229 impl().contents_texture_manager = NULL;
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
1364 1367
1365 impl().timing_history.DidActivateSyncTree(); 1368 impl().timing_history.DidActivateSyncTree();
1366 } 1369 }
1367 1370
1368 void ThreadProxy::DidManageTiles() { 1371 void ThreadProxy::DidManageTiles() {
1369 DCHECK(IsImplThread()); 1372 DCHECK(IsImplThread());
1370 impl().scheduler->DidManageTiles(); 1373 impl().scheduler->DidManageTiles();
1371 } 1374 }
1372 1375
1373 } // namespace cc 1376 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698