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_GPU_TILE_TASK_WORKER_POOL_H_
6 #define CC_RESOURCES_GPU_TILE_TASK_WORKER_POOL_H_
8 #include "base/memory/weak_ptr.h"
9 #include "cc/resources/tile_task_runner.h"
10 #include "cc/resources/tile_task_worker_pool.h"
13 class ResourceProvider
;
15 class CC_EXPORT GpuTileTaskWorkerPool
: public TileTaskWorkerPool
,
16 public TileTaskRunner
,
17 public TileTaskClient
{
19 ~GpuTileTaskWorkerPool() override
;
21 static scoped_ptr
<TileTaskWorkerPool
> Create(
22 base::SequencedTaskRunner
* task_runner
,
23 TaskGraphRunner
* task_graph_runner
,
24 ResourceProvider
* resource_provider
);
26 // Overridden from TileTaskWorkerPool:
27 TileTaskRunner
* AsTileTaskRunner() override
;
29 // Overridden from TileTaskRunner:
30 void SetClient(TileTaskRunnerClient
* client
) override
;
31 void Shutdown() override
;
32 void ScheduleTasks(TileTaskQueue
* queue
) override
;
33 void CheckForCompletedTasks() override
;
34 ResourceFormat
GetResourceFormat() override
;
36 // Overridden from TileTaskClient:
37 scoped_ptr
<RasterBuffer
> AcquireBufferForRaster(
38 const Resource
* resource
) override
;
39 void ReleaseBufferForRaster(scoped_ptr
<RasterBuffer
> buffer
) override
;
42 GpuTileTaskWorkerPool(base::SequencedTaskRunner
* task_runner
,
43 TaskGraphRunner
* task_graph_runner
,
44 ResourceProvider
* resource_provider
);
46 void OnTaskSetFinished(TaskSet task_set
);
47 void CompleteTasks(const Task::Vector
& tasks
);
49 scoped_refptr
<base::SequencedTaskRunner
> task_runner_
;
50 TaskGraphRunner
* task_graph_runner_
;
51 const NamespaceToken namespace_token_
;
52 TileTaskRunnerClient
* client_
;
53 ResourceProvider
* resource_provider_
;
55 TaskSetCollection tasks_pending_
;
57 scoped_refptr
<TileTask
> task_set_finished_tasks_
[kNumberOfTaskSets
];
59 // Task graph used when scheduling tasks and vector used to gather
62 Task::Vector completed_tasks_
;
64 base::WeakPtrFactory
<GpuTileTaskWorkerPool
>
65 task_set_finished_weak_ptr_factory_
;
67 base::WeakPtrFactory
<GpuTileTaskWorkerPool
> weak_ptr_factory_
;
69 DISALLOW_COPY_AND_ASSIGN(GpuTileTaskWorkerPool
);
74 #endif // CC_RESOURCES_GPU_TILE_TASK_WORKER_POOL_H_