1 // Copyright 2013 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_RASTER_ZERO_COPY_TILE_TASK_WORKER_POOL_H_
6 #define CC_RASTER_ZERO_COPY_TILE_TASK_WORKER_POOL_H_
8 #include "base/memory/weak_ptr.h"
9 #include "base/values.h"
10 #include "cc/raster/tile_task_runner.h"
11 #include "cc/raster/tile_task_worker_pool.h"
14 namespace trace_event
{
15 class ConvertableToTraceFormat
;
20 class ResourceProvider
;
22 class CC_EXPORT ZeroCopyTileTaskWorkerPool
: public TileTaskWorkerPool
,
23 public TileTaskRunner
,
24 public TileTaskClient
{
26 ~ZeroCopyTileTaskWorkerPool() 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
;
49 ZeroCopyTileTaskWorkerPool(base::SequencedTaskRunner
* task_runner
,
50 TaskGraphRunner
* task_graph_runner
,
51 ResourceProvider
* resource_provider
);
54 void OnTaskSetFinished(TaskSet task_set
);
55 scoped_refptr
<base::trace_event::ConvertableToTraceFormat
> StateAsValue()
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
71 Task::Vector completed_tasks_
;
73 base::WeakPtrFactory
<ZeroCopyTileTaskWorkerPool
>
74 task_set_finished_weak_ptr_factory_
;
76 DISALLOW_COPY_AND_ASSIGN(ZeroCopyTileTaskWorkerPool
);
81 #endif // CC_RASTER_ZERO_COPY_TILE_TASK_WORKER_POOL_H_