1 // Copyright 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "cc/test/fake_tile_manager.h"
9 #include "cc/resources/raster_worker_pool.h"
15 class FakeRasterWorkerPool
: public RasterWorkerPool
{
17 FakeRasterWorkerPool() : RasterWorkerPool(NULL
, 1) {}
19 virtual void ScheduleTasks(RasterTask::Queue
* queue
) OVERRIDE
{
20 RasterWorkerPool::SetRasterTasks(queue
);
21 for (RasterTaskVector::const_iterator it
= raster_tasks().begin();
22 it
!= raster_tasks().end(); ++it
) {
23 completed_tasks_
.push_back(it
->get());
26 virtual void CheckForCompletedTasks() OVERRIDE
{
27 while (!completed_tasks_
.empty()) {
28 internal::RasterWorkerPoolTask
* task
= completed_tasks_
.front().get();
30 task
->CompleteOnOriginThread();
32 completed_tasks_
.pop_front();
35 virtual GLenum
GetResourceFormat() const OVERRIDE
{ return GL_RGBA
; }
36 virtual void OnRasterTasksFinished() OVERRIDE
{}
37 virtual void OnRasterTasksRequiredForActivationFinished() OVERRIDE
{}
40 typedef std::deque
<scoped_refptr
<internal::RasterWorkerPoolTask
> > TaskDeque
;
41 TaskDeque completed_tasks_
;
46 FakeTileManager::FakeTileManager(TileManagerClient
* client
)
49 make_scoped_ptr
<RasterWorkerPool
>(new FakeRasterWorkerPool
),
53 FakeTileManager::FakeTileManager(TileManagerClient
* client
,
54 ResourceProvider
* resource_provider
)
57 make_scoped_ptr
<RasterWorkerPool
>(new FakeRasterWorkerPool
),
61 FakeTileManager::~FakeTileManager() {}
63 void FakeTileManager::AssignMemoryToTiles() {
64 tiles_for_raster
.clear();
67 GetTilesWithAssignedBins(&all_tiles
);
68 AssignGpuMemoryToTiles(&all_tiles
, &tiles_for_raster
);
71 bool FakeTileManager::HasBeenAssignedMemory(Tile
* tile
) {
72 return std::find(tiles_for_raster
.begin(),
73 tiles_for_raster
.end(),
74 tile
) != tiles_for_raster
.end();