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 ContextProvider
;
15 class ResourceProvider
;
17 class CC_EXPORT GpuTileTaskWorkerPool
: public TileTaskWorkerPool
,
18 public TileTaskRunner
,
19 public TileTaskClient
{
21 ~GpuTileTaskWorkerPool() override
;
23 static scoped_ptr
<TileTaskWorkerPool
> Create(
24 base::SequencedTaskRunner
* task_runner
,
25 TaskGraphRunner
* task_graph_runner
,
26 ContextProvider
* context_provider
,
27 ResourceProvider
* resource_provider
,
28 bool use_distance_field_text
,
29 int gpu_rasterization_msaa_sample_count
);
31 // Overridden from TileTaskWorkerPool:
32 TileTaskRunner
* AsTileTaskRunner() override
;
34 // Overridden from TileTaskRunner:
35 void SetClient(TileTaskRunnerClient
* client
) override
;
36 void Shutdown() override
;
37 void ScheduleTasks(TileTaskQueue
* queue
) override
;
38 void CheckForCompletedTasks() override
;
39 ResourceFormat
GetResourceFormat() override
;
41 // Overridden from TileTaskClient:
42 scoped_ptr
<RasterBuffer
> AcquireBufferForRaster(
43 const Resource
* resource
) override
;
44 void ReleaseBufferForRaster(scoped_ptr
<RasterBuffer
> buffer
) override
;
47 GpuTileTaskWorkerPool(base::SequencedTaskRunner
* task_runner
,
48 TaskGraphRunner
* task_graph_runner
,
49 ContextProvider
* context_provider
,
50 ResourceProvider
* resource_provider
,
51 bool use_distance_field_text
,
52 int gpu_rasterization_msaa_sample_count
);
54 void OnTaskSetFinished(TaskSet task_set
);
55 void CompleteTasks(const Task::Vector
& tasks
);
57 scoped_refptr
<base::SequencedTaskRunner
> task_runner_
;
58 TaskGraphRunner
* task_graph_runner_
;
59 const NamespaceToken namespace_token_
;
60 TileTaskRunnerClient
* client_
;
61 scoped_ptr
<GpuRasterizer
> rasterizer_
;
63 TaskSetCollection tasks_pending_
;
65 scoped_refptr
<TileTask
> task_set_finished_tasks_
[kNumberOfTaskSets
];
67 // Task graph used when scheduling tasks and vector used to gather
70 Task::Vector completed_tasks_
;
72 base::WeakPtrFactory
<GpuTileTaskWorkerPool
>
73 task_set_finished_weak_ptr_factory_
;
75 base::WeakPtrFactory
<GpuTileTaskWorkerPool
> weak_ptr_factory_
;
77 DISALLOW_COPY_AND_ASSIGN(GpuTileTaskWorkerPool
);
82 #endif // CC_RESOURCES_GPU_TILE_TASK_WORKER_POOL_H_