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_RESOURCES_IMAGE_RASTER_WORKER_POOL_H_
6 #define CC_RESOURCES_IMAGE_RASTER_WORKER_POOL_H_
8 #include "base/memory/weak_ptr.h"
9 #include "base/values.h"
10 #include "cc/resources/raster_worker_pool.h"
11 #include "cc/resources/rasterizer.h"
14 class ResourceProvider
;
16 class CC_EXPORT ImageRasterWorkerPool
: public RasterWorkerPool
,
18 public RasterizerTaskClient
{
20 virtual ~ImageRasterWorkerPool();
22 static scoped_ptr
<RasterWorkerPool
> Create(
23 base::SequencedTaskRunner
* task_runner
,
24 TaskGraphRunner
* task_graph_runner
,
25 ResourceProvider
* resource_provider
);
27 // Overridden from RasterWorkerPool:
28 virtual Rasterizer
* AsRasterizer() OVERRIDE
;
30 // Overridden from Rasterizer:
31 virtual void SetClient(RasterizerClient
* client
) OVERRIDE
;
32 virtual void Shutdown() OVERRIDE
;
33 virtual void ScheduleTasks(RasterTaskQueue
* queue
) OVERRIDE
;
34 virtual void CheckForCompletedTasks() OVERRIDE
;
36 // Overridden from RasterizerTaskClient:
37 virtual SkCanvas
* AcquireCanvasForRaster(RasterTask
* task
) OVERRIDE
;
38 virtual void ReleaseCanvasForRaster(RasterTask
* task
) OVERRIDE
;
41 ImageRasterWorkerPool(base::SequencedTaskRunner
* task_runner
,
42 TaskGraphRunner
* task_graph_runner
,
43 ResourceProvider
* resource_provider
);
46 void OnRasterFinished();
47 void OnRasterRequiredForActivationFinished();
48 scoped_ptr
<base::Value
> StateAsValue() const;
50 scoped_refptr
<base::SequencedTaskRunner
> task_runner_
;
51 TaskGraphRunner
* task_graph_runner_
;
52 const NamespaceToken namespace_token_
;
53 RasterizerClient
* client_
;
54 ResourceProvider
* resource_provider_
;
56 bool raster_tasks_pending_
;
57 bool raster_tasks_required_for_activation_pending_
;
59 base::WeakPtrFactory
<ImageRasterWorkerPool
> raster_finished_weak_ptr_factory_
;
61 scoped_refptr
<RasterizerTask
> raster_finished_task_
;
62 scoped_refptr
<RasterizerTask
> raster_required_for_activation_finished_task_
;
64 // Task graph used when scheduling tasks and vector used to gather
67 Task::Vector completed_tasks_
;
69 DISALLOW_COPY_AND_ASSIGN(ImageRasterWorkerPool
);
74 #endif // CC_RESOURCES_IMAGE_RASTER_WORKER_POOL_H_