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() const override
;
42 bool GetResourceRequiresSwizzle() const override
;
44 // Overridden from TileTaskClient:
45 scoped_ptr
<RasterBuffer
> AcquireBufferForRaster(
46 const Resource
* resource
,
47 uint64_t resource_content_id
,
48 uint64_t previous_content_id
) override
;
49 void ReleaseBufferForRaster(scoped_ptr
<RasterBuffer
> buffer
) override
;
52 ZeroCopyTileTaskWorkerPool(base::SequencedTaskRunner
* task_runner
,
53 TaskGraphRunner
* task_graph_runner
,
54 ResourceProvider
* resource_provider
);
57 void OnTaskSetFinished(TaskSet task_set
);
58 scoped_refptr
<base::trace_event::ConvertableToTraceFormat
> StateAsValue()
61 scoped_refptr
<base::SequencedTaskRunner
> task_runner_
;
62 TaskGraphRunner
* task_graph_runner_
;
63 const NamespaceToken namespace_token_
;
64 TileTaskRunnerClient
* client_
;
65 ResourceProvider
* resource_provider_
;
67 TaskSetCollection tasks_pending_
;
69 scoped_refptr
<TileTask
> task_set_finished_tasks_
[kNumberOfTaskSets
];
71 // Task graph used when scheduling tasks and vector used to gather
74 Task::Vector completed_tasks_
;
76 base::WeakPtrFactory
<ZeroCopyTileTaskWorkerPool
>
77 task_set_finished_weak_ptr_factory_
;
79 DISALLOW_COPY_AND_ASSIGN(ZeroCopyTileTaskWorkerPool
);
84 #endif // CC_RASTER_ZERO_COPY_TILE_TASK_WORKER_POOL_H_