OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 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 | 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_manager.h" | 5 #include "cc/test/fake_tile_manager.h" |
6 | 6 |
7 #include <deque> | 7 #include <deque> |
8 #include <limits> | 8 #include <limits> |
9 | 9 |
| 10 #include "cc/resources/gpu_rasterizer.h" |
10 #include "cc/resources/raster_worker_pool.h" | 11 #include "cc/resources/raster_worker_pool.h" |
11 | 12 |
12 namespace cc { | 13 namespace cc { |
13 | 14 |
| 15 class FakeGpuRasterizer : public GpuRasterizer { |
| 16 public: |
| 17 FakeGpuRasterizer() |
| 18 : GpuRasterizer(NULL, NULL), completed_tiles_(0) {} |
| 19 virtual ~FakeGpuRasterizer() {} |
| 20 |
| 21 virtual void Rasterize( |
| 22 const Queue& queue, |
| 23 RenderingStatsInstrumentation* rendering_stats_instrumentation) OVERRIDE { |
| 24 for (RasterTaskVector::const_iterator it = queue.raster_tasks_.begin(); |
| 25 it != queue.raster_tasks_.end(); ++it) { |
| 26 RasterTask* task = *it; |
| 27 Tile* tile = task->tile_; |
| 28 client_->OnGpuRasterTaskCompleted(tile, task->resource_.Pass()); |
| 29 completed_tiles_++; |
| 30 } |
| 31 } |
| 32 |
| 33 int completed_tiles_; |
| 34 }; |
| 35 |
14 namespace { | 36 namespace { |
15 | 37 |
16 class FakeRasterWorkerPool : public RasterWorkerPool { | 38 class FakeRasterWorkerPool : public RasterWorkerPool { |
17 public: | 39 public: |
18 FakeRasterWorkerPool() : RasterWorkerPool(NULL, 1) {} | 40 FakeRasterWorkerPool() : RasterWorkerPool(NULL, 1) {} |
19 | 41 |
20 virtual void ScheduleTasks(RasterTask::Queue* queue) OVERRIDE { | 42 virtual void ScheduleTasks(RasterTask::Queue* queue) OVERRIDE { |
21 RasterWorkerPool::SetRasterTasks(queue); | 43 RasterWorkerPool::SetRasterTasks(queue); |
22 for (RasterTaskVector::const_iterator it = raster_tasks().begin(); | 44 for (RasterTaskVector::const_iterator it = raster_tasks().begin(); |
23 it != raster_tasks().end(); ++it) { | 45 it != raster_tasks().end(); ++it) { |
(...skipping 21 matching lines...) Expand all Loading... |
45 private: | 67 private: |
46 typedef std::deque<scoped_refptr<internal::RasterWorkerPoolTask> > TaskDeque; | 68 typedef std::deque<scoped_refptr<internal::RasterWorkerPoolTask> > TaskDeque; |
47 TaskDeque completed_tasks_; | 69 TaskDeque completed_tasks_; |
48 }; | 70 }; |
49 | 71 |
50 } // namespace | 72 } // namespace |
51 | 73 |
52 FakeTileManager::FakeTileManager(TileManagerClient* client) | 74 FakeTileManager::FakeTileManager(TileManagerClient* client) |
53 : TileManager(client, | 75 : TileManager(client, |
54 NULL, | 76 NULL, |
| 77 make_scoped_ptr<GpuRasterizer>(new FakeGpuRasterizer), |
55 make_scoped_ptr<RasterWorkerPool>(new FakeRasterWorkerPool), | 78 make_scoped_ptr<RasterWorkerPool>(new FakeRasterWorkerPool), |
56 1, | 79 1, |
57 std::numeric_limits<unsigned>::max(), | 80 std::numeric_limits<unsigned>::max(), |
58 NULL), | 81 NULL), |
59 in_bundle_cleanup_(false) {} | 82 in_bundle_cleanup_(false) {} |
60 | 83 |
61 FakeTileManager::FakeTileManager(TileManagerClient* client, | 84 FakeTileManager::FakeTileManager(TileManagerClient* client, |
62 ResourceProvider* resource_provider) | 85 ResourceProvider* resource_provider) |
63 : TileManager(client, | 86 : TileManager(client, |
64 resource_provider, | 87 resource_provider, |
| 88 make_scoped_ptr<GpuRasterizer>(new FakeGpuRasterizer), |
65 make_scoped_ptr<RasterWorkerPool>(new FakeRasterWorkerPool), | 89 make_scoped_ptr<RasterWorkerPool>(new FakeRasterWorkerPool), |
66 1, | 90 1, |
67 std::numeric_limits<unsigned>::max(), | 91 std::numeric_limits<unsigned>::max(), |
68 NULL), | 92 NULL), |
69 in_bundle_cleanup_(false) {} | 93 in_bundle_cleanup_(false) {} |
70 | 94 |
71 FakeTileManager::FakeTileManager(TileManagerClient* client, | 95 FakeTileManager::FakeTileManager(TileManagerClient* client, |
72 ResourceProvider* resource_provider, | 96 ResourceProvider* resource_provider, |
73 size_t raster_task_limit_bytes) | 97 size_t raster_task_limit_bytes) |
74 : TileManager(client, | 98 : TileManager(client, |
75 resource_provider, | 99 resource_provider, |
| 100 make_scoped_ptr<GpuRasterizer>(new FakeGpuRasterizer), |
76 make_scoped_ptr<RasterWorkerPool>(new FakeRasterWorkerPool), | 101 make_scoped_ptr<RasterWorkerPool>(new FakeRasterWorkerPool), |
77 1, | 102 1, |
78 raster_task_limit_bytes, | 103 raster_task_limit_bytes, |
79 NULL), | 104 NULL), |
80 in_bundle_cleanup_(false) {} | 105 in_bundle_cleanup_(false) {} |
81 | 106 |
82 FakeTileManager::~FakeTileManager() {} | 107 FakeTileManager::~FakeTileManager() {} |
83 | 108 |
84 void FakeTileManager::AssignMemoryToTiles( | 109 void FakeTileManager::AssignMemoryToTiles( |
85 const GlobalStateThatImpactsTilePriority& state) { | 110 const GlobalStateThatImpactsTilePriority& state) { |
(...skipping 21 matching lines...) Expand all Loading... |
107 CleanUpReleasedTiles(); | 132 CleanUpReleasedTiles(); |
108 } | 133 } |
109 | 134 |
110 void FakeTileManager::Release(TileBundle* bundle) { | 135 void FakeTileManager::Release(TileBundle* bundle) { |
111 TileManager::Release(bundle); | 136 TileManager::Release(bundle); |
112 in_bundle_cleanup_ = true; | 137 in_bundle_cleanup_ = true; |
113 CleanUpReleasedTiles(); | 138 CleanUpReleasedTiles(); |
114 in_bundle_cleanup_ = false; | 139 in_bundle_cleanup_ = false; |
115 } | 140 } |
116 | 141 |
| 142 int FakeTileManager::CompletedGpuRasterizedTiles() { |
| 143 FakeGpuRasterizer* gpu_rasterizer = |
| 144 static_cast<FakeGpuRasterizer*>(GetGpuRasterizerForTest()); |
| 145 return gpu_rasterizer->completed_tiles_; |
| 146 } |
| 147 |
117 } // namespace cc | 148 } // namespace cc |
OLD | NEW |