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_RASTER_WORKER_POOL_H_
6 #define CC_RESOURCES_RASTER_WORKER_POOL_H_
8 #include "cc/resources/rasterizer.h"
9 #include "ui/gfx/geometry/rect.h"
10 #include "ui/gfx/geometry/size.h"
13 class SequencedTaskRunner
;
18 class RenderingStatsInstrumentation
;
20 class CC_EXPORT RasterWorkerPool
{
22 static unsigned kBenchmarkRasterTaskPriority
;
23 static unsigned kRasterFinishedTaskPriority
;
24 static unsigned kRasterTaskPriorityBase
;
27 virtual ~RasterWorkerPool();
29 // Set the number of threads to use for the global TaskGraphRunner instance.
30 // This can only be called once and must be called prior to
31 // GetNumRasterThreads().
32 static void SetNumRasterThreads(int num_threads
);
34 // Returns the number of threads used for the global TaskGraphRunner instance.
35 static int GetNumRasterThreads();
37 // Returns a pointer to the global TaskGraphRunner instance.
38 static TaskGraphRunner
* GetTaskGraphRunner();
40 // Utility function that can be used to create a "raster finished" task that
41 // posts |callback| to |task_runner| when run.
42 static scoped_refptr
<RasterizerTask
> CreateRasterFinishedTask(
43 base::SequencedTaskRunner
* task_runner
,
44 const base::Closure
& callback
);
46 // Utility function that can be used to call ::ScheduleOnOriginThread() for
47 // each task in |graph|.
48 static void ScheduleTasksOnOriginThread(RasterizerTaskClient
* client
,
51 // Utility function that can be used to build a task graph. Inserts a node
52 // that represents |task| in |graph|. See TaskGraph definition for valid
54 static void InsertNodeForTask(TaskGraph
* graph
,
59 // Utility function that can be used to build a task graph. Inserts nodes that
60 // represent |task| and all its image decode dependencies in |graph|.
61 static void InsertNodesForRasterTask(
64 const ImageDecodeTask::Vector
& decode_tasks
,
67 // Utility function that will create a temporary bitmap and copy pixels to
68 // |memory| when necessary.
69 static void PlaybackToMemory(void* memory
,
70 ResourceFormat format
,
71 const gfx::Size
& size
,
73 const RasterSource
* raster_source
,
74 const gfx::Rect
& rect
,
77 // Type-checking downcast routine.
78 virtual Rasterizer
* AsRasterizer() = 0;
83 #endif // CC_RESOURCES_RASTER_WORKER_POOL_H_