GPU workaround to simulate Out of Memory errors with large textures
[chromium-blink-merge.git] / cc / resources / bitmap_tile_task_worker_pool.h
blob3f03c2db9f65d82cbf376a4dce6a75f2b87d1483
1 // Copyright 2014 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 #ifndef CC_RESOURCES_BITMAP_TILE_TASK_WORKER_POOL_H_
6 #define CC_RESOURCES_BITMAP_TILE_TASK_WORKER_POOL_H_
8 #include "base/memory/weak_ptr.h"
9 #include "base/values.h"
10 #include "cc/resources/tile_task_runner.h"
11 #include "cc/resources/tile_task_worker_pool.h"
13 namespace base {
14 namespace trace_event {
15 class ConvertableToTraceFormat;
19 namespace cc {
20 class ResourceProvider;
22 class CC_EXPORT BitmapTileTaskWorkerPool : public TileTaskWorkerPool,
23 public TileTaskRunner,
24 public TileTaskClient {
25 public:
26 ~BitmapTileTaskWorkerPool() override;
28 static scoped_ptr<TileTaskWorkerPool> Create(
29 base::SequencedTaskRunner* task_runner,
30 TaskGraphRunner* task_graph_runner,
31 ResourceProvider* resource_provider);
33 // Overridden from TileTaskWorkerPool:
34 TileTaskRunner* AsTileTaskRunner() override;
36 // Overridden from TileTaskRunner:
37 void SetClient(TileTaskRunnerClient* client) override;
38 void Shutdown() override;
39 void ScheduleTasks(TileTaskQueue* queue) override;
40 void CheckForCompletedTasks() override;
41 ResourceFormat GetResourceFormat() override;
43 // Overridden from TileTaskClient:
44 scoped_ptr<RasterBuffer> AcquireBufferForRaster(
45 const Resource* resource) override;
46 void ReleaseBufferForRaster(scoped_ptr<RasterBuffer> buffer) override;
48 protected:
49 BitmapTileTaskWorkerPool(base::SequencedTaskRunner* task_runner,
50 TaskGraphRunner* task_graph_runner,
51 ResourceProvider* resource_provider);
53 private:
54 void OnTaskSetFinished(TaskSet task_set);
55 scoped_refptr<base::trace_event::ConvertableToTraceFormat> StateAsValue()
56 const;
58 scoped_refptr<base::SequencedTaskRunner> task_runner_;
59 TaskGraphRunner* task_graph_runner_;
60 const NamespaceToken namespace_token_;
61 TileTaskRunnerClient* client_;
62 ResourceProvider* resource_provider_;
64 TaskSetCollection tasks_pending_;
66 scoped_refptr<TileTask> task_set_finished_tasks_[kNumberOfTaskSets];
68 // Task graph used when scheduling tasks and vector used to gather
69 // completed tasks.
70 TaskGraph graph_;
71 Task::Vector completed_tasks_;
73 base::WeakPtrFactory<BitmapTileTaskWorkerPool>
74 task_set_finished_weak_ptr_factory_;
76 DISALLOW_COPY_AND_ASSIGN(BitmapTileTaskWorkerPool);
79 } // namespace cc
81 #endif // CC_RESOURCES_BITMAP_TILE_TASK_WORKER_POOL_H_