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

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, 2 months 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_(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 265 matching lines...) Expand 10 before | Expand all | Expand 10 after
342 347
343 void ThreadProxy::DidSwapBuffersCompleteOnImplThread() { 348 void ThreadProxy::DidSwapBuffersCompleteOnImplThread() {
344 TRACE_EVENT0("cc", "ThreadProxy::DidSwapBuffersCompleteOnImplThread"); 349 TRACE_EVENT0("cc", "ThreadProxy::DidSwapBuffersCompleteOnImplThread");
345 DCHECK(IsImplThread()); 350 DCHECK(IsImplThread());
346 impl().scheduler->DidSwapBuffersComplete(); 351 impl().scheduler->DidSwapBuffersComplete();
347 Proxy::MainThreadTaskRunner()->PostTask( 352 Proxy::MainThreadTaskRunner()->PostTask(
348 FROM_HERE, 353 FROM_HERE,
349 base::Bind(&ThreadProxy::DidCompleteSwapBuffers, main_thread_weak_ptr_)); 354 base::Bind(&ThreadProxy::DidCompleteSwapBuffers, main_thread_weak_ptr_));
350 } 355 }
351 356
352 BeginFrameSource* ThreadProxy::ExternalBeginFrameSource() {
353 return impl().layer_tree_host_impl.get();
354 }
355
356 void ThreadProxy::WillBeginImplFrame(const BeginFrameArgs& args) { 357 void ThreadProxy::WillBeginImplFrame(const BeginFrameArgs& args) {
357 impl().layer_tree_host_impl->WillBeginImplFrame(args); 358 impl().layer_tree_host_impl->WillBeginImplFrame(args);
358 } 359 }
359 360
360 void ThreadProxy::OnCanDrawStateChanged(bool can_draw) { 361 void ThreadProxy::OnCanDrawStateChanged(bool can_draw) {
361 TRACE_EVENT1( 362 TRACE_EVENT1(
362 "cc", "ThreadProxy::OnCanDrawStateChanged", "can_draw", can_draw); 363 "cc", "ThreadProxy::OnCanDrawStateChanged", "can_draw", can_draw);
363 DCHECK(IsImplThread()); 364 DCHECK(IsImplThread());
364 impl().scheduler->SetCanDraw(can_draw); 365 impl().scheduler->SetCanDraw(can_draw);
365 UpdateBackgroundAnimateTicking(); 366 UpdateBackgroundAnimateTicking();
(...skipping 811 matching lines...) Expand 10 before | Expand all | Expand 10 after
1177 void ThreadProxy::InitializeImplOnImplThread(CompletionEvent* completion) { 1178 void ThreadProxy::InitializeImplOnImplThread(CompletionEvent* completion) {
1178 TRACE_EVENT0("cc", "ThreadProxy::InitializeImplOnImplThread"); 1179 TRACE_EVENT0("cc", "ThreadProxy::InitializeImplOnImplThread");
1179 DCHECK(IsImplThread()); 1180 DCHECK(IsImplThread());
1180 impl().layer_tree_host_impl = 1181 impl().layer_tree_host_impl =
1181 layer_tree_host()->CreateLayerTreeHostImpl(this); 1182 layer_tree_host()->CreateLayerTreeHostImpl(this);
1182 SchedulerSettings scheduler_settings(layer_tree_host()->settings()); 1183 SchedulerSettings scheduler_settings(layer_tree_host()->settings());
1183 impl().scheduler = Scheduler::Create(this, 1184 impl().scheduler = Scheduler::Create(this,
1184 scheduler_settings, 1185 scheduler_settings,
1185 impl().layer_tree_host_id, 1186 impl().layer_tree_host_id,
1186 ImplThreadTaskRunner(), 1187 ImplThreadTaskRunner(),
1187 base::PowerMonitor::Get()); 1188 base::PowerMonitor::Get(),
1189 external_begin_frame_source_.Pass());
1188 impl().scheduler->SetVisible(impl().layer_tree_host_impl->visible()); 1190 impl().scheduler->SetVisible(impl().layer_tree_host_impl->visible());
1189
1190 impl_thread_weak_ptr_ = impl().weak_factory.GetWeakPtr(); 1191 impl_thread_weak_ptr_ = impl().weak_factory.GetWeakPtr();
1191 completion->Signal(); 1192 completion->Signal();
1192 } 1193 }
1193 1194
1194 void ThreadProxy::DeleteContentsTexturesOnImplThread( 1195 void ThreadProxy::DeleteContentsTexturesOnImplThread(
1195 CompletionEvent* completion) { 1196 CompletionEvent* completion) {
1196 TRACE_EVENT0("cc", "ThreadProxy::DeleteContentsTexturesOnImplThread"); 1197 TRACE_EVENT0("cc", "ThreadProxy::DeleteContentsTexturesOnImplThread");
1197 DCHECK(IsImplThread()); 1198 DCHECK(IsImplThread());
1198 DCHECK(IsMainThreadBlocked()); 1199 DCHECK(IsMainThreadBlocked());
1199 layer_tree_host()->DeleteContentsTexturesOnImplThread( 1200 layer_tree_host()->DeleteContentsTexturesOnImplThread(
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
1237 completion->Signal(); 1238 completion->Signal();
1238 } 1239 }
1239 1240
1240 void ThreadProxy::LayerTreeHostClosedOnImplThread(CompletionEvent* completion) { 1241 void ThreadProxy::LayerTreeHostClosedOnImplThread(CompletionEvent* completion) {
1241 TRACE_EVENT0("cc", "ThreadProxy::LayerTreeHostClosedOnImplThread"); 1242 TRACE_EVENT0("cc", "ThreadProxy::LayerTreeHostClosedOnImplThread");
1242 DCHECK(IsImplThread()); 1243 DCHECK(IsImplThread());
1243 DCHECK(IsMainThreadBlocked()); 1244 DCHECK(IsMainThreadBlocked());
1244 layer_tree_host()->DeleteContentsTexturesOnImplThread( 1245 layer_tree_host()->DeleteContentsTexturesOnImplThread(
1245 impl().layer_tree_host_impl->resource_provider()); 1246 impl().layer_tree_host_impl->resource_provider());
1246 impl().current_resource_update_controller = nullptr; 1247 impl().current_resource_update_controller = nullptr;
1247 impl().layer_tree_host_impl->SetNeedsBeginFrames(false);
1248 impl().scheduler = nullptr; 1248 impl().scheduler = nullptr;
1249 impl().layer_tree_host_impl = nullptr; 1249 impl().layer_tree_host_impl = nullptr;
1250 impl().weak_factory.InvalidateWeakPtrs(); 1250 impl().weak_factory.InvalidateWeakPtrs();
1251 // We need to explicitly cancel the notifier, since it isn't using weak ptrs. 1251 // We need to explicitly cancel the notifier, since it isn't using weak ptrs.
1252 // TODO(vmpstr): We should see if we can make it use weak ptrs and still keep 1252 // TODO(vmpstr): We should see if we can make it use weak ptrs and still keep
1253 // the convention of having a weak ptr factory initialized last. Alternatively 1253 // the convention of having a weak ptr factory initialized last. Alternatively
1254 // we should moved the notifier (and RenewTreePriority) to LTHI. See 1254 // we should moved the notifier (and RenewTreePriority) to LTHI. See
1255 // crbug.com/411972 1255 // crbug.com/411972
1256 impl().smoothness_priority_expiration_notifier.Cancel(); 1256 impl().smoothness_priority_expiration_notifier.Cancel();
1257 impl().contents_texture_manager = NULL; 1257 impl().contents_texture_manager = NULL;
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
1395 1395
1396 impl().timing_history.DidActivateSyncTree(); 1396 impl().timing_history.DidActivateSyncTree();
1397 } 1397 }
1398 1398
1399 void ThreadProxy::DidManageTiles() { 1399 void ThreadProxy::DidManageTiles() {
1400 DCHECK(IsImplThread()); 1400 DCHECK(IsImplThread());
1401 impl().scheduler->DidManageTiles(); 1401 impl().scheduler->DidManageTiles();
1402 } 1402 }
1403 1403
1404 } // namespace cc 1404 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698