OLD | NEW |
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/test/fake_tile_task_manager.h" | 5 #include "cc/test/fake_tile_task_manager.h" |
6 | 6 |
7 #include "base/memory/ptr_util.h" | 7 #include "base/memory/ptr_util.h" |
8 | 8 |
9 namespace cc { | 9 namespace cc { |
10 | 10 |
11 FakeTileTaskManagerImpl::FakeTileTaskManagerImpl() | 11 FakeTileTaskManagerImpl::FakeTileTaskManagerImpl() {} |
12 : raster_buffer_provider_(base::WrapUnique<RasterBufferProvider>( | |
13 new FakeRasterBufferProviderImpl)) {} | |
14 | |
15 FakeTileTaskManagerImpl::FakeTileTaskManagerImpl( | |
16 std::unique_ptr<RasterBufferProvider> raster_buffer_provider) | |
17 : raster_buffer_provider_(std::move(raster_buffer_provider)) {} | |
18 | 12 |
19 FakeTileTaskManagerImpl::~FakeTileTaskManagerImpl() { | 13 FakeTileTaskManagerImpl::~FakeTileTaskManagerImpl() { |
20 DCHECK_EQ(0u, completed_tasks_.size()); | 14 DCHECK_EQ(0u, completed_tasks_.size()); |
21 } | 15 } |
22 | 16 |
23 void FakeTileTaskManagerImpl::ScheduleTasks(TaskGraph* graph) { | 17 void FakeTileTaskManagerImpl::ScheduleTasks(TaskGraph* graph) { |
24 for (const auto& node : graph->nodes) { | 18 for (const auto& node : graph->nodes) { |
25 TileTask* task = static_cast<TileTask*>(node.task); | 19 TileTask* task = static_cast<TileTask*>(node.task); |
26 // Cancel the task and append to |completed_tasks_|. | 20 // Cancel the task and append to |completed_tasks_|. |
27 task->state().DidCancel(); | 21 task->state().DidCancel(); |
28 completed_tasks_.push_back(task); | 22 completed_tasks_.push_back(task); |
29 } | 23 } |
30 } | 24 } |
31 | 25 |
32 void FakeTileTaskManagerImpl::CheckForCompletedTasks() { | 26 void FakeTileTaskManagerImpl::CheckForCompletedTasks() { |
33 for (auto& task : completed_tasks_) { | 27 for (auto& task : completed_tasks_) { |
34 DCHECK(task->state().IsFinished() || task->state().IsCanceled()); | 28 DCHECK(task->state().IsFinished() || task->state().IsCanceled()); |
35 TileTask* tile_task = static_cast<TileTask*>(task.get()); | 29 TileTask* tile_task = static_cast<TileTask*>(task.get()); |
36 tile_task->OnTaskCompleted(); | 30 tile_task->OnTaskCompleted(); |
37 tile_task->DidComplete(); | 31 tile_task->DidComplete(); |
38 } | 32 } |
39 | 33 |
40 completed_tasks_.clear(); | 34 completed_tasks_.clear(); |
41 } | 35 } |
42 | 36 |
43 void FakeTileTaskManagerImpl::Shutdown() {} | 37 void FakeTileTaskManagerImpl::Shutdown() {} |
44 | 38 |
45 RasterBufferProvider* FakeTileTaskManagerImpl::GetRasterBufferProvider() const { | |
46 return raster_buffer_provider_.get(); | |
47 } | |
48 | |
49 } // namespace cc | 39 } // namespace cc |
OLD | NEW |