clang/win: Try to fix 64-bit build more after https://codereview.chromium.org/1261953003.
[chromium-blink-merge.git] / cc / test / fake_tile_manager.cc
blobdedb51b7749a0894b3e301f711154e1c1c899c62
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>
8 #include <limits>
10 #include "base/lazy_instance.h"
11 #include "base/thread_task_runner_handle.h"
12 #include "cc/raster/raster_buffer.h"
13 #include "cc/raster/tile_task_runner.h"
15 namespace cc {
17 namespace {
19 class FakeTileTaskRunnerImpl : public TileTaskRunner, public TileTaskClient {
20 public:
21 // Overridden from TileTaskRunner:
22 void SetClient(TileTaskRunnerClient* client) override {}
23 void Shutdown() override {}
24 void ScheduleTasks(TileTaskQueue* queue) override {
25 for (TileTaskQueue::Item::Vector::const_iterator it = queue->items.begin();
26 it != queue->items.end(); ++it) {
27 RasterTask* task = it->task;
29 task->WillSchedule();
30 task->ScheduleOnOriginThread(this);
31 task->DidSchedule();
33 completed_tasks_.push_back(task);
36 void CheckForCompletedTasks() override {
37 for (RasterTask::Vector::iterator it = completed_tasks_.begin();
38 it != completed_tasks_.end();
39 ++it) {
40 RasterTask* task = it->get();
42 task->WillComplete();
43 task->CompleteOnOriginThread(this);
44 task->DidComplete();
46 task->RunReplyOnOriginThread();
48 completed_tasks_.clear();
50 ResourceFormat GetResourceFormat() const override { return RGBA_8888; }
51 bool GetResourceRequiresSwizzle() const override {
52 return !PlatformColor::SameComponentOrder(GetResourceFormat());
55 // Overridden from TileTaskClient:
56 scoped_ptr<RasterBuffer> AcquireBufferForRaster(
57 const Resource* resource,
58 uint64_t resource_content_id,
59 uint64_t previous_content_id) override {
60 return nullptr;
62 void ReleaseBufferForRaster(scoped_ptr<RasterBuffer> buffer) override {}
64 private:
65 RasterTask::Vector completed_tasks_;
67 base::LazyInstance<FakeTileTaskRunnerImpl> g_fake_tile_task_runner =
68 LAZY_INSTANCE_INITIALIZER;
70 } // namespace
72 FakeTileManager::FakeTileManager(TileManagerClient* client)
73 : TileManager(client,
74 base::ThreadTaskRunnerHandle::Get(),
75 std::numeric_limits<size_t>::max()) {
76 SetResources(nullptr, g_fake_tile_task_runner.Pointer(),
77 std::numeric_limits<size_t>::max());
80 FakeTileManager::FakeTileManager(TileManagerClient* client,
81 ResourcePool* resource_pool)
82 : TileManager(client,
83 base::ThreadTaskRunnerHandle::Get(),
84 std::numeric_limits<size_t>::max()) {
85 SetResources(resource_pool, g_fake_tile_task_runner.Pointer(),
86 std::numeric_limits<size_t>::max());
89 FakeTileManager::~FakeTileManager() {}
91 bool FakeTileManager::HasBeenAssignedMemory(Tile* tile) {
92 return std::find(tiles_for_raster.begin(),
93 tiles_for_raster.end(),
94 tile) != tiles_for_raster.end();
97 void FakeTileManager::Release(Tile* tile) {
98 TileManager::Release(tile);
100 FreeResourcesForReleasedTiles();
101 CleanUpReleasedTiles();
104 } // namespace cc