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

Unified Diff: cc/tiles/tile_manager.cc

Issue 2017453004: cc: Send notification of tasks completion directly without scheduling. Base URL: https://chromium.googlesource.com/chromium/src.git@worker_origin_split_4
Patch Set: fixed implementation Created 4 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 side-by-side diff with in-line comments
Download patch
« cc/tiles/tile_manager.h ('K') | « cc/tiles/tile_manager.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/tiles/tile_manager.cc
diff --git a/cc/tiles/tile_manager.cc b/cc/tiles/tile_manager.cc
index d951514bb24913253a96025e4a0b1a8150d6d288..dfdb5db46a9440765935e23ac5c2c5ecac143924 100644
--- a/cc/tiles/tile_manager.cc
+++ b/cc/tiles/tile_manager.cc
@@ -328,13 +328,6 @@ TileManager::TileManager(TileManagerClient* client,
all_tiles_that_need_to_be_rasterized_are_scheduled_(true),
did_check_for_completed_tasks_since_last_schedule_tasks_(true),
did_oom_on_last_assign_(false),
- more_tiles_need_prepare_check_notifier_(
- task_runner_.get(),
- base::Bind(&TileManager::CheckIfMoreTilesNeedToBePrepared,
- base::Unretained(this))),
- signals_check_notifier_(task_runner_.get(),
- base::Bind(&TileManager::CheckAndIssueSignals,
- base::Unretained(this))),
has_scheduled_tile_tasks_(false),
prepare_tiles_count_(0u),
next_tile_id_(0u),
@@ -365,8 +358,6 @@ void TileManager::FinishTasksAndCleanUp() {
tile_task_manager_ = nullptr;
resource_pool_ = nullptr;
- more_tiles_need_prepare_check_notifier_.Cancel();
- signals_check_notifier_.Cancel();
task_set_finished_weak_ptr_factory_.InvalidateWeakPtrs();
}
@@ -411,45 +402,59 @@ void TileManager::CleanUpReleasedTiles() {
released_tiles_.swap(tiles_to_retain);
}
-void TileManager::DidFinishRunningTileTasksRequiredForActivation() {
+void TileManager::DidFinishRunningTileTasksRequiredForActivation(
+ uint64_t source_prepare_tiles_id) {
TRACE_EVENT0("cc",
"TileManager::DidFinishRunningTileTasksRequiredForActivation");
TRACE_EVENT_ASYNC_STEP_INTO1("cc", "ScheduledTasks", this, "running", "state",
ScheduledTasksStateAsValue());
+
+ // Check if there is another request to PrepareTiles().
+ if (prepare_tiles_count_ != source_prepare_tiles_id)
+ return;
prashant.n 2016/06/02 01:16:47 This is a separate thing which we did not take car
+
signals_.ready_to_activate = true;
- signals_check_notifier_.Schedule();
+ CheckAndNotifyReadyToActivate();
}
-void TileManager::DidFinishRunningTileTasksRequiredForDraw() {
+void TileManager::DidFinishRunningTileTasksRequiredForDraw(
+ uint64_t source_prepare_tiles_id) {
TRACE_EVENT0("cc", "TileManager::DidFinishRunningTileTasksRequiredForDraw");
TRACE_EVENT_ASYNC_STEP_INTO1("cc", "ScheduledTasks", this, "running", "state",
ScheduledTasksStateAsValue());
+
+ // Check if there is another request to PrepareTiles().
+ if (prepare_tiles_count_ != source_prepare_tiles_id)
+ return;
+
signals_.ready_to_draw = true;
- signals_check_notifier_.Schedule();
+ CheckAndNotifyReadyToDraw();
}
-void TileManager::DidFinishRunningAllTileTasks() {
+void TileManager::DidFinishRunningAllTileTasks(
+ uint64_t source_prepare_tiles_id) {
TRACE_EVENT0("cc", "TileManager::DidFinishRunningAllTileTasks");
TRACE_EVENT_ASYNC_END0("cc", "ScheduledTasks", this);
- DCHECK(resource_pool_);
- DCHECK(tile_task_manager_);
+
+ // Check if there is another request to PrepareTiles().
+ if (prepare_tiles_count_ != source_prepare_tiles_id)
+ return;
has_scheduled_tile_tasks_ = false;
+ DCHECK(resource_pool_);
+
bool memory_usage_above_limit = resource_pool_->memory_usage_bytes() >
global_state_.soft_memory_limit_in_bytes;
if (all_tiles_that_need_to_be_rasterized_are_scheduled_ &&
!memory_usage_above_limit) {
- // TODO(ericrk): We should find a better way to safely handle re-entrant
- // notifications than always having to schedule a new task.
- // http://crbug.com/498439
signals_.all_tile_tasks_completed = true;
- signals_check_notifier_.Schedule();
+ CheckAndNotifyAllTileTasksCompleted();
return;
}
- more_tiles_need_prepare_check_notifier_.Schedule();
+ CheckIfMoreTilesNeedToBePrepared();
}
bool TileManager::PrepareTiles(
@@ -1052,48 +1057,62 @@ bool TileManager::IsReadyToDraw() const {
RasterTilePriorityQueue::Type::REQUIRED_FOR_DRAW);
}
-void TileManager::CheckAndIssueSignals() {
- TRACE_EVENT0("cc", "TileManager::CheckAndIssueSignals");
+void TileManager::CheckAndNotifyReadyToActivate() {
+ TRACE_EVENT0("cc", "TileManager::CheckAndNotifyReadyToActivate");
+ DCHECK(tile_task_manager_);
+
tile_task_manager_->CheckForCompletedTasks();
did_check_for_completed_tasks_since_last_schedule_tasks_ = true;
- // Ready to activate.
- if (signals_.ready_to_activate && !signals_.did_notify_ready_to_activate) {
- signals_.ready_to_activate = false;
- if (IsReadyToActivate()) {
- TRACE_EVENT0("disabled-by-default-cc.debug",
- "TileManager::CheckAndIssueSignals - ready to activate");
- signals_.did_notify_ready_to_activate = true;
- client_->NotifyReadyToActivate();
- }
+ // Check if ready to activate and notification is not sent since
+ // PrepareTiles() requested.
+ if (!signals_.did_notify_ready_to_activate && IsReadyToActivate()) {
prashant.n 2016/06/02 01:16:46 Unique notification per prepare tiles is ensured b
+ TRACE_EVENT0(
+ "disabled-by-default-cc.debug",
+ "TileManager::CheckAndNotifyReadyToActivate - ready to activate");
+ client_->NotifyReadyToActivate();
+ signals_.did_notify_ready_to_activate = true;
}
+}
- // Ready to draw.
- if (signals_.ready_to_draw && !signals_.did_notify_ready_to_draw) {
- signals_.ready_to_draw = false;
- if (IsReadyToDraw()) {
- TRACE_EVENT0("disabled-by-default-cc.debug",
- "TileManager::CheckAndIssueSignals - ready to draw");
- signals_.did_notify_ready_to_draw = true;
- client_->NotifyReadyToDraw();
- }
+void TileManager::CheckAndNotifyReadyToDraw() {
+ TRACE_EVENT0("cc", "TileManager::CheckAndNotifyReadyToDraw");
+
+ DCHECK(tile_task_manager_);
+
+ tile_task_manager_->CheckForCompletedTasks();
+ did_check_for_completed_tasks_since_last_schedule_tasks_ = true;
+
+ // Check if ready to draw and notification is not sent since
+ // PrepareTiles() requested.
+ if (!signals_.did_notify_ready_to_draw && IsReadyToDraw()) {
+ TRACE_EVENT0("disabled-by-default-cc.debug",
+ "TileManager::CheckAndNotifyReadyToDraw - ready to draw");
+ signals_.did_notify_ready_to_draw = true;
+ client_->NotifyReadyToDraw();
}
+}
- // All tile tasks completed.
- if (signals_.all_tile_tasks_completed &&
- !signals_.did_notify_all_tile_tasks_completed) {
- signals_.all_tile_tasks_completed = false;
- if (!has_scheduled_tile_tasks_) {
- TRACE_EVENT0(
- "disabled-by-default-cc.debug",
- "TileManager::CheckAndIssueSignals - all tile tasks completed");
- signals_.did_notify_all_tile_tasks_completed = true;
- client_->NotifyAllTileTasksCompleted();
- }
+void TileManager::CheckAndNotifyAllTileTasksCompleted() {
+ TRACE_EVENT0("cc", "TileManager::CheckAndNotifyAllTileTasksCompleted");
+
+ DCHECK(tile_task_manager_);
+ tile_task_manager_->CheckForCompletedTasks();
+ did_check_for_completed_tasks_since_last_schedule_tasks_ = true;
+
+ // Check if notification is not sent since PrepareTiles() requested.
+ if (!signals_.did_notify_all_tile_tasks_completed) {
+ TRACE_EVENT0("disabled-by-default-cc.debug",
+ "TileManager::CheckAndNotifyAllTileTasksCompleted - all tile "
+ "tasks completed");
+ signals_.did_notify_all_tile_tasks_completed = true;
+ client_->NotifyAllTileTasksCompleted();
}
}
void TileManager::CheckIfMoreTilesNeedToBePrepared() {
+ DCHECK(tile_task_manager_);
+
tile_task_manager_->CheckForCompletedTasks();
did_check_for_completed_tasks_since_last_schedule_tasks_ = true;
@@ -1125,9 +1144,6 @@ void TileManager::CheckIfMoreTilesNeedToBePrepared() {
resource_pool_->ReduceResourceUsage();
image_decode_controller_->ReduceCacheUsage();
- signals_.all_tile_tasks_completed = true;
- signals_check_notifier_.Schedule();
-
// We don't reserve memory for required-for-activation tiles during
// accelerated gestures, so we just postpone activation when we don't
// have these tiles, and activate after the accelerated gesture.
@@ -1157,11 +1173,14 @@ void TileManager::CheckIfMoreTilesNeedToBePrepared() {
DCHECK(IsReadyToActivate());
DCHECK(IsReadyToDraw());
- signals_.ready_to_activate = need_to_signal_activate;
- signals_.ready_to_draw = need_to_signal_draw;
- // TODO(ericrk): Investigate why we need to schedule this (not just call it
- // inline). http://crbug.com/498439
- signals_check_notifier_.Schedule();
+
+ if (need_to_signal_activate)
+ CheckAndNotifyReadyToActivate();
+
+ if (need_to_signal_draw)
+ CheckAndNotifyReadyToDraw();
+
+ CheckAndNotifyAllTileTasksCompleted();
}
bool TileManager::MarkTilesOutOfMemory(
@@ -1206,10 +1225,11 @@ TileManager::ScheduledTasksStateAsValue() const {
// Utility function that can be used to create a "Task set finished" task that
// posts |callback| to |task_runner| when run.
scoped_refptr<TileTask> TileManager::CreateTaskSetFinishedTask(
- void (TileManager::*callback)()) {
+ void (TileManager::*callback)(uint64_t source_prepare_tiles_id)) {
return make_scoped_refptr(new TaskSetFinishedTaskImpl(
task_runner_.get(),
- base::Bind(callback, task_set_finished_weak_ptr_factory_.GetWeakPtr())));
+ base::Bind(callback, task_set_finished_weak_ptr_factory_.GetWeakPtr(),
+ prepare_tiles_count_)));
}
TileManager::MemoryUsage::MemoryUsage()
« cc/tiles/tile_manager.h ('K') | « cc/tiles/tile_manager.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698