1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
|
// Copyright 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "cc/test/fake_tile_manager.h"
#include <deque>
#include "cc/resources/raster_worker_pool.h"
namespace cc {
namespace {
class FakeRasterWorkerPool : public RasterWorkerPool {
public:
FakeRasterWorkerPool() : RasterWorkerPool(NULL, 1) {}
virtual void ScheduleTasks(RasterTask::Queue* queue) OVERRIDE {
RasterWorkerPool::SetRasterTasks(queue);
for (RasterTaskVector::const_iterator it = raster_tasks().begin();
it != raster_tasks().end(); ++it) {
completed_tasks_.push_back(it->get());
}
}
virtual void CheckForCompletedTasks() OVERRIDE {
while (!completed_tasks_.empty()) {
internal::RasterWorkerPoolTask* task = completed_tasks_.front().get();
task->WillComplete();
task->CompleteOnOriginThread();
task->DidComplete();
completed_tasks_.pop_front();
}
}
virtual ResourceFormat GetResourceFormat() const OVERRIDE {
return RGBA_8888;
}
virtual void OnRasterTasksFinished() OVERRIDE {}
virtual void OnRasterTasksRequiredForActivationFinished() OVERRIDE {}
private:
typedef std::deque<scoped_refptr<internal::RasterWorkerPoolTask> > TaskDeque;
TaskDeque completed_tasks_;
};
} // namespace
FakeTileManager::FakeTileManager(TileManagerClient* client)
: TileManager(client,
NULL,
make_scoped_ptr<RasterWorkerPool>(new FakeRasterWorkerPool),
1,
NULL) {}
FakeTileManager::FakeTileManager(TileManagerClient* client,
ResourceProvider* resource_provider)
: TileManager(client,
resource_provider,
make_scoped_ptr<RasterWorkerPool>(new FakeRasterWorkerPool),
1,
NULL) {}
FakeTileManager::~FakeTileManager() {}
void FakeTileManager::AssignMemoryToTiles() {
tiles_for_raster.clear();
all_tiles.Clear();
GetTilesWithAssignedBins(&all_tiles);
AssignGpuMemoryToTiles(&all_tiles, &tiles_for_raster);
}
bool FakeTileManager::HasBeenAssignedMemory(Tile* tile) {
return std::find(tiles_for_raster.begin(),
tiles_for_raster.end(),
tile) != tiles_for_raster.end();
}
void FakeTileManager::CheckForCompletedTasks() {
RasterWorkerPoolForTesting()->CheckForCompletedTasks();
}
} // namespace cc
|