cc: Added inline to Tile::IsReadyToDraw
[chromium-blink-merge.git] / cc / test / fake_tile_manager.cc
blobd35e9f7ceb0836661b430d97f15057a382e13c1d
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"
7 #include <deque>
9 #include "cc/resources/raster_worker_pool.h"
11 namespace cc {
13 namespace {
15 class FakeRasterWorkerPool : public RasterWorkerPool {
16 public:
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();
29 task->WillComplete();
30 task->CompleteOnOriginThread();
31 task->DidComplete();
32 completed_tasks_.pop_front();
35 virtual GLenum GetResourceFormat() const OVERRIDE { return GL_RGBA; }
36 virtual void OnRasterTasksFinished() OVERRIDE {}
37 virtual void OnRasterTasksRequiredForActivationFinished() OVERRIDE {}
39 private:
40 typedef std::deque<scoped_refptr<internal::RasterWorkerPoolTask> > TaskDeque;
41 TaskDeque completed_tasks_;
44 } // namespace
46 FakeTileManager::FakeTileManager(TileManagerClient* client)
47 : TileManager(client,
48 NULL,
49 make_scoped_ptr<RasterWorkerPool>(new FakeRasterWorkerPool),
51 NULL) {}
53 FakeTileManager::FakeTileManager(TileManagerClient* client,
54 ResourceProvider* resource_provider)
55 : TileManager(client,
56 resource_provider,
57 make_scoped_ptr<RasterWorkerPool>(new FakeRasterWorkerPool),
59 NULL) {}
61 FakeTileManager::~FakeTileManager() {}
63 void FakeTileManager::AssignMemoryToTiles() {
64 tiles_for_raster.clear();
65 all_tiles.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();
77 } // namespace cc