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

Side by Side Diff: cc/tiles/tile_task_manager.cc

Issue 1951193002: cc: Add mailbox support to ResourceProvider write locks. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@worker_context_stream
Patch Set: cleanup tasks if ordering barrier fails Created 4 years, 6 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/tiles/tile_task_manager.h" 5 #include "cc/tiles/tile_task_manager.h"
6 6
7 #include "base/memory/ptr_util.h" 7 #include "base/memory/ptr_util.h"
8 #include "base/trace_event/trace_event.h" 8 #include "base/trace_event/trace_event.h"
9 9
10 namespace cc { 10 namespace cc {
11 11
12 TileTaskManager::TileTaskManager() {} 12 TileTaskManager::TileTaskManager() {}
13 13
14 TileTaskManager::~TileTaskManager() {} 14 TileTaskManager::~TileTaskManager() {}
15 15
16 // static 16 // static
17 std::unique_ptr<TileTaskManagerImpl> TileTaskManagerImpl::Create( 17 std::unique_ptr<TileTaskManagerImpl> TileTaskManagerImpl::Create(
18 std::unique_ptr<RasterBufferProvider> raster_buffer_provider,
19 TaskGraphRunner* task_graph_runner) { 18 TaskGraphRunner* task_graph_runner) {
20 return base::WrapUnique<TileTaskManagerImpl>(new TileTaskManagerImpl( 19 return base::WrapUnique<TileTaskManagerImpl>(
21 std::move(raster_buffer_provider), task_graph_runner)); 20 new TileTaskManagerImpl(task_graph_runner));
22 } 21 }
23 22
24 TileTaskManagerImpl::TileTaskManagerImpl( 23 TileTaskManagerImpl::TileTaskManagerImpl(TaskGraphRunner* task_graph_runner)
25 std::unique_ptr<RasterBufferProvider> raster_buffer_provider, 24 : task_graph_runner_(task_graph_runner),
26 TaskGraphRunner* task_graph_runner)
27 : raster_buffer_provider_(std::move(raster_buffer_provider)),
28 task_graph_runner_(task_graph_runner),
29 namespace_token_(task_graph_runner->GetNamespaceToken()) {} 25 namespace_token_(task_graph_runner->GetNamespaceToken()) {}
30 26
31 TileTaskManagerImpl::~TileTaskManagerImpl() {} 27 TileTaskManagerImpl::~TileTaskManagerImpl() {}
32 28
33 void TileTaskManagerImpl::ScheduleTasks(TaskGraph* graph) { 29 void TileTaskManagerImpl::ScheduleTasks(TaskGraph* graph) {
34 TRACE_EVENT0("cc", "TileTaskManagerImpl::ScheduleTasks"); 30 TRACE_EVENT0("cc", "TileTaskManagerImpl::ScheduleTasks");
35
36 raster_buffer_provider_->OrderingBarrier();
37 task_graph_runner_->ScheduleTasks(namespace_token_, graph); 31 task_graph_runner_->ScheduleTasks(namespace_token_, graph);
38 } 32 }
39 33
40 void TileTaskManagerImpl::CheckForCompletedTasks() { 34 void TileTaskManagerImpl::CheckForCompletedTasks() {
41 TRACE_EVENT0("cc", "TileTaskManagerImpl::CheckForCompletedTasks"); 35 TRACE_EVENT0("cc", "TileTaskManagerImpl::CheckForCompletedTasks");
42 Task::Vector completed_tasks; 36 Task::Vector completed_tasks;
43 task_graph_runner_->CollectCompletedTasks(namespace_token_, &completed_tasks); 37 task_graph_runner_->CollectCompletedTasks(namespace_token_, &completed_tasks);
44 38
45 for (auto& task : completed_tasks) { 39 for (auto& task : completed_tasks) {
46 DCHECK(task->state().IsFinished() || task->state().IsCanceled()); 40 DCHECK(task->state().IsFinished() || task->state().IsCanceled());
47 TileTask* tile_task = static_cast<TileTask*>(task.get()); 41 TileTask* tile_task = static_cast<TileTask*>(task.get());
48 tile_task->OnTaskCompleted(); 42 tile_task->OnTaskCompleted();
49 tile_task->DidComplete(); 43 tile_task->DidComplete();
50 } 44 }
51 } 45 }
52 46
53 void TileTaskManagerImpl::Shutdown() { 47 void TileTaskManagerImpl::Shutdown() {
54 TRACE_EVENT0("cc", "TileTaskManagerImpl::Shutdown"); 48 TRACE_EVENT0("cc", "TileTaskManagerImpl::Shutdown");
55 49
56 // Cancel non-scheduled tasks and wait for running tasks to finish. 50 // Cancel non-scheduled tasks and wait for running tasks to finish.
57 TaskGraph empty; 51 TaskGraph empty;
58 task_graph_runner_->ScheduleTasks(namespace_token_, &empty); 52 task_graph_runner_->ScheduleTasks(namespace_token_, &empty);
59 task_graph_runner_->WaitForTasksToFinishRunning(namespace_token_); 53 task_graph_runner_->WaitForTasksToFinishRunning(namespace_token_);
60
61 raster_buffer_provider_->Shutdown();
62 }
63
64 RasterBufferProvider* TileTaskManagerImpl::GetRasterBufferProvider() const {
65 return raster_buffer_provider_.get();
66 } 54 }
67 55
68 } // namespace cc 56 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698