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

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

Issue 267783004: Refactoring the way begin frame sources inside scheduler work. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Scheduler now uses frame sources, working on scheduler_unittests. Created 6 years, 7 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 | Annotate | Revision Log
« cc/trees/single_thread_proxy.cc ('K') | « cc/trees/thread_proxy.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 248 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 &completion, 259 &completion,
260 visible)); 260 visible));
261 completion.Wait(); 261 completion.Wait();
262 } 262 }
263 263
264 void ThreadProxy::SetVisibleOnImplThread(CompletionEvent* completion, 264 void ThreadProxy::SetVisibleOnImplThread(CompletionEvent* completion,
265 bool visible) { 265 bool visible) {
266 TRACE_EVENT0("cc", "ThreadProxy::SetVisibleOnImplThread"); 266 TRACE_EVENT0("cc", "ThreadProxy::SetVisibleOnImplThread");
267 impl().layer_tree_host_impl->SetVisible(visible); 267 impl().layer_tree_host_impl->SetVisible(visible);
268 impl().scheduler->SetVisible(visible); 268 impl().scheduler->SetVisible(visible);
269 UpdateBackgroundAnimateTicking();
270 completion->Signal(); 269 completion->Signal();
271 } 270 }
272 271
273 void ThreadProxy::UpdateBackgroundAnimateTicking() {
274 bool should_background_tick =
275 !impl().scheduler->WillDrawIfNeeded() &&
276 impl().layer_tree_host_impl->active_tree()->root_layer();
277 impl().layer_tree_host_impl->UpdateBackgroundAnimateTicking(
278 should_background_tick);
279 if (should_background_tick)
280 impl().animations_frozen_until_next_draw = false;
281 }
282
283 void ThreadProxy::DoCreateAndInitializeOutputSurface() { 272 void ThreadProxy::DoCreateAndInitializeOutputSurface() {
284 TRACE_EVENT0("cc", "ThreadProxy::DoCreateAndInitializeOutputSurface"); 273 TRACE_EVENT0("cc", "ThreadProxy::DoCreateAndInitializeOutputSurface");
285 DCHECK(IsMainThread()); 274 DCHECK(IsMainThread());
286 275
287 scoped_ptr<OutputSurface> output_surface = 276 scoped_ptr<OutputSurface> output_surface =
288 layer_tree_host()->CreateOutputSurface(); 277 layer_tree_host()->CreateOutputSurface();
289 278
290 RendererCapabilities capabilities; 279 RendererCapabilities capabilities;
291 bool success = !!output_surface; 280 bool success = !!output_surface;
292 if (success) { 281 if (success) {
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
390 } 379 }
391 380
392 void ThreadProxy::CheckOutputSurfaceStatusOnImplThread() { 381 void ThreadProxy::CheckOutputSurfaceStatusOnImplThread() {
393 TRACE_EVENT0("cc", "ThreadProxy::CheckOutputSurfaceStatusOnImplThread"); 382 TRACE_EVENT0("cc", "ThreadProxy::CheckOutputSurfaceStatusOnImplThread");
394 DCHECK(IsImplThread()); 383 DCHECK(IsImplThread());
395 if (!impl().layer_tree_host_impl->IsContextLost()) 384 if (!impl().layer_tree_host_impl->IsContextLost())
396 return; 385 return;
397 impl().scheduler->DidLoseOutputSurface(); 386 impl().scheduler->DidLoseOutputSurface();
398 } 387 }
399 388
400 void ThreadProxy::CommitVSyncParameters(base::TimeTicks timebase,
401 base::TimeDelta interval) {
402 impl().scheduler->CommitVSyncParameters(timebase, interval);
403 }
404
405 void ThreadProxy::SetEstimatedParentDrawTime(base::TimeDelta draw_time) { 389 void ThreadProxy::SetEstimatedParentDrawTime(base::TimeDelta draw_time) {
406 impl().scheduler->SetEstimatedParentDrawTime(draw_time); 390 impl().scheduler->SetEstimatedParentDrawTime(draw_time);
407 } 391 }
408 392
409 void ThreadProxy::SetMaxSwapsPendingOnImplThread(int max) { 393 void ThreadProxy::SetMaxSwapsPendingOnImplThread(int max) {
410 impl().scheduler->SetMaxSwapsPending(max); 394 impl().scheduler->SetMaxSwapsPending(max);
411 } 395 }
412 396
413 void ThreadProxy::DidSwapBuffersOnImplThread() { 397 void ThreadProxy::DidSwapBuffersOnImplThread() {
414 impl().scheduler->DidSwapBuffers(); 398 impl().scheduler->DidSwapBuffers();
415 } 399 }
416 400
417 void ThreadProxy::DidSwapBuffersCompleteOnImplThread() { 401 void ThreadProxy::DidSwapBuffersCompleteOnImplThread() {
418 TRACE_EVENT0("cc", "ThreadProxy::DidSwapBuffersCompleteOnImplThread"); 402 TRACE_EVENT0("cc", "ThreadProxy::DidSwapBuffersCompleteOnImplThread");
419 DCHECK(IsImplThread());
420 impl().scheduler->DidSwapBuffersComplete(); 403 impl().scheduler->DidSwapBuffersComplete();
421 Proxy::MainThreadTaskRunner()->PostTask( 404 Proxy::MainThreadTaskRunner()->PostTask(
422 FROM_HERE, 405 FROM_HERE,
423 base::Bind(&ThreadProxy::DidCompleteSwapBuffers, main_thread_weak_ptr_)); 406 base::Bind(&ThreadProxy::DidCompleteSwapBuffers, main_thread_weak_ptr_));
424 } 407 }
425 408
426 void ThreadProxy::SetNeedsBeginFrame(bool enable) {
427 TRACE_EVENT1("cc", "ThreadProxy::SetNeedsBeginFrame", "enable", enable);
428 impl().layer_tree_host_impl->SetNeedsBeginFrame(enable);
429 UpdateBackgroundAnimateTicking();
430 }
431
432 void ThreadProxy::BeginFrame(const BeginFrameArgs& args) {
433 impl().scheduler->BeginFrame(args);
434 }
435
436 void ThreadProxy::WillBeginImplFrame(const BeginFrameArgs& args) { 409 void ThreadProxy::WillBeginImplFrame(const BeginFrameArgs& args) {
437 impl().layer_tree_host_impl->WillBeginImplFrame(args); 410 impl().layer_tree_host_impl->WillBeginImplFrame(args);
438 } 411 }
439 412
440 void ThreadProxy::OnCanDrawStateChanged(bool can_draw) { 413 void ThreadProxy::OnCanDrawStateChanged(bool can_draw) {
441 TRACE_EVENT1( 414 TRACE_EVENT1(
442 "cc", "ThreadProxy::OnCanDrawStateChanged", "can_draw", can_draw); 415 "cc", "ThreadProxy::OnCanDrawStateChanged", "can_draw", can_draw);
443 DCHECK(IsImplThread()); 416 DCHECK(IsImplThread());
444 impl().scheduler->SetCanDraw(can_draw); 417 impl().scheduler->SetCanDraw(can_draw);
445 UpdateBackgroundAnimateTicking();
446 } 418 }
447 419
448 void ThreadProxy::NotifyReadyToActivate() { 420 void ThreadProxy::NotifyReadyToActivate() {
449 TRACE_EVENT0("cc", "ThreadProxy::NotifyReadyToActivate"); 421 TRACE_EVENT0("cc", "ThreadProxy::NotifyReadyToActivate");
450 impl().scheduler->NotifyReadyToActivate(); 422 impl().scheduler->NotifyReadyToActivate();
451 } 423 }
452 424
453 void ThreadProxy::SetNeedsCommitOnImplThread() { 425 void ThreadProxy::SetNeedsCommitOnImplThread() {
454 TRACE_EVENT0("cc", "ThreadProxy::SetNeedsCommitOnImplThread"); 426 TRACE_EVENT0("cc", "ThreadProxy::SetNeedsCommitOnImplThread");
455 DCHECK(IsImplThread()); 427 DCHECK(IsImplThread());
(...skipping 624 matching lines...) Expand 10 before | Expand all | Expand 10 after
1080 impl().commit_completion_event->Signal(); 1052 impl().commit_completion_event->Signal();
1081 impl().commit_completion_event = NULL; 1053 impl().commit_completion_event = NULL;
1082 } 1054 }
1083 1055
1084 // Delay this step until afer the main thread has been released as it's 1056 // Delay this step until afer the main thread has been released as it's
1085 // often a good bit of work to update the tree and prepare the new frame. 1057 // often a good bit of work to update the tree and prepare the new frame.
1086 impl().layer_tree_host_impl->CommitComplete(); 1058 impl().layer_tree_host_impl->CommitComplete();
1087 1059
1088 SetInputThrottledUntilCommitOnImplThread(false); 1060 SetInputThrottledUntilCommitOnImplThread(false);
1089 1061
1090 UpdateBackgroundAnimateTicking();
1091
1092 impl().next_frame_is_newly_committed_frame = true; 1062 impl().next_frame_is_newly_committed_frame = true;
1093 1063
1094 impl().timing_history.DidCommit(); 1064 impl().timing_history.DidCommit();
1095 } 1065 }
1096 1066
1097 void ThreadProxy::ScheduledActionUpdateVisibleTiles() { 1067 void ThreadProxy::ScheduledActionUpdateVisibleTiles() {
1098 TRACE_EVENT0("cc", "ThreadProxy::ScheduledActionUpdateVisibleTiles"); 1068 TRACE_EVENT0("cc", "ThreadProxy::ScheduledActionUpdateVisibleTiles");
1099 DCHECK(IsImplThread()); 1069 DCHECK(IsImplThread());
1100 impl().layer_tree_host_impl->UpdateVisibleTiles(); 1070 impl().layer_tree_host_impl->UpdateVisibleTiles();
1101 } 1071 }
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after
1406 settings.timeout_and_draw_when_animation_checkerboards; 1376 settings.timeout_and_draw_when_animation_checkerboards;
1407 scheduler_settings.maximum_number_of_failed_draws_before_draw_is_forced_ = 1377 scheduler_settings.maximum_number_of_failed_draws_before_draw_is_forced_ =
1408 settings.maximum_number_of_failed_draws_before_draw_is_forced_; 1378 settings.maximum_number_of_failed_draws_before_draw_is_forced_;
1409 scheduler_settings.using_synchronous_renderer_compositor = 1379 scheduler_settings.using_synchronous_renderer_compositor =
1410 settings.using_synchronous_renderer_compositor; 1380 settings.using_synchronous_renderer_compositor;
1411 scheduler_settings.throttle_frame_production = 1381 scheduler_settings.throttle_frame_production =
1412 settings.throttle_frame_production; 1382 settings.throttle_frame_production;
1413 impl().scheduler = Scheduler::Create(this, 1383 impl().scheduler = Scheduler::Create(this,
1414 scheduler_settings, 1384 scheduler_settings,
1415 impl().layer_tree_host_id, 1385 impl().layer_tree_host_id,
1386 impl().layer_tree_host_impl.get(),
1416 ImplThreadTaskRunner()); 1387 ImplThreadTaskRunner());
1417 impl().scheduler->SetVisible(impl().layer_tree_host_impl->visible()); 1388 impl().scheduler->SetVisible(impl().layer_tree_host_impl->visible());
1418 1389
1419 impl_thread_weak_ptr_ = impl().weak_factory.GetWeakPtr(); 1390 impl_thread_weak_ptr_ = impl().weak_factory.GetWeakPtr();
1420 completion->Signal(); 1391 completion->Signal();
1421 } 1392 }
1422 1393
1423 void ThreadProxy::InitializeOutputSurfaceOnImplThread( 1394 void ThreadProxy::InitializeOutputSurfaceOnImplThread(
1424 CompletionEvent* completion, 1395 CompletionEvent* completion,
1425 scoped_ptr<OutputSurface> output_surface, 1396 scoped_ptr<OutputSurface> output_surface,
(...skipping 28 matching lines...) Expand all
1454 impl().layer_tree_host_impl->resource_provider()->Finish(); 1425 impl().layer_tree_host_impl->resource_provider()->Finish();
1455 completion->Signal(); 1426 completion->Signal();
1456 } 1427 }
1457 1428
1458 void ThreadProxy::LayerTreeHostClosedOnImplThread(CompletionEvent* completion) { 1429 void ThreadProxy::LayerTreeHostClosedOnImplThread(CompletionEvent* completion) {
1459 TRACE_EVENT0("cc", "ThreadProxy::LayerTreeHostClosedOnImplThread"); 1430 TRACE_EVENT0("cc", "ThreadProxy::LayerTreeHostClosedOnImplThread");
1460 DCHECK(IsImplThread()); 1431 DCHECK(IsImplThread());
1461 layer_tree_host()->DeleteContentsTexturesOnImplThread( 1432 layer_tree_host()->DeleteContentsTexturesOnImplThread(
1462 impl().layer_tree_host_impl->resource_provider()); 1433 impl().layer_tree_host_impl->resource_provider());
1463 impl().current_resource_update_controller.reset(); 1434 impl().current_resource_update_controller.reset();
1464 impl().layer_tree_host_impl->SetNeedsBeginFrame(false);
1465 impl().scheduler.reset(); 1435 impl().scheduler.reset();
1466 impl().layer_tree_host_impl.reset(); 1436 impl().layer_tree_host_impl.reset();
1467 impl().weak_factory.InvalidateWeakPtrs(); 1437 impl().weak_factory.InvalidateWeakPtrs();
1468 impl().contents_texture_manager = NULL; 1438 impl().contents_texture_manager = NULL;
1469 completion->Signal(); 1439 completion->Signal();
1470 } 1440 }
1471 1441
1472 size_t ThreadProxy::MaxPartialTextureUpdates() const { 1442 size_t ThreadProxy::MaxPartialTextureUpdates() const {
1473 return ResourceUpdateController::MaxPartialTextureUpdates(); 1443 return ResourceUpdateController::MaxPartialTextureUpdates();
1474 } 1444 }
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
1642 DCHECK(!impl().layer_tree_host_impl->pending_tree()); 1612 DCHECK(!impl().layer_tree_host_impl->pending_tree());
1643 1613
1644 if (impl().completion_event_for_commit_held_on_tree_activation) { 1614 if (impl().completion_event_for_commit_held_on_tree_activation) {
1645 TRACE_EVENT_INSTANT0( 1615 TRACE_EVENT_INSTANT0(
1646 "cc", "ReleaseCommitbyActivation", TRACE_EVENT_SCOPE_THREAD); 1616 "cc", "ReleaseCommitbyActivation", TRACE_EVENT_SCOPE_THREAD);
1647 DCHECK(impl().layer_tree_host_impl->settings().impl_side_painting); 1617 DCHECK(impl().layer_tree_host_impl->settings().impl_side_painting);
1648 impl().completion_event_for_commit_held_on_tree_activation->Signal(); 1618 impl().completion_event_for_commit_held_on_tree_activation->Signal();
1649 impl().completion_event_for_commit_held_on_tree_activation = NULL; 1619 impl().completion_event_for_commit_held_on_tree_activation = NULL;
1650 } 1620 }
1651 1621
1652 UpdateBackgroundAnimateTicking();
1653
1654 impl().timing_history.DidActivatePendingTree(); 1622 impl().timing_history.DidActivatePendingTree();
1655 } 1623 }
1656 1624
1657 void ThreadProxy::DidManageTiles() { 1625 void ThreadProxy::DidManageTiles() {
1658 DCHECK(IsImplThread()); 1626 DCHECK(IsImplThread());
1659 impl().scheduler->DidManageTiles(); 1627 impl().scheduler->DidManageTiles();
1660 } 1628 }
1661 1629
1662 } // namespace cc 1630 } // namespace cc
OLDNEW
« cc/trees/single_thread_proxy.cc ('K') | « cc/trees/thread_proxy.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698