Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / cc / resources / raster_worker_pool.h
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.
4
5 #ifndef CC_RESOURCES_RASTER_WORKER_POOL_H_
6 #define CC_RESOURCES_RASTER_WORKER_POOL_H_
7
8 #include "cc/resources/rasterizer.h"
9 #include "ui/gfx/geometry/rect.h"
10 #include "ui/gfx/geometry/size.h"
11
12 namespace base {
13 class SequencedTaskRunner;
14 }
15
16 namespace cc {
17 class RasterSource;
18 class RenderingStatsInstrumentation;
19
20 class CC_EXPORT RasterWorkerPool {
21  public:
22   static unsigned kBenchmarkRasterTaskPriority;
23   static unsigned kRasterFinishedTaskPriority;
24   static unsigned kRasterTaskPriorityBase;
25
26   RasterWorkerPool();
27   virtual ~RasterWorkerPool();
28
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);
33
34   // Returns the number of threads used for the global TaskGraphRunner instance.
35   static int GetNumRasterThreads();
36
37   // Returns a pointer to the global TaskGraphRunner instance.
38   static TaskGraphRunner* GetTaskGraphRunner();
39
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);
45
46   // Utility function that can be used to call ::ScheduleOnOriginThread() for
47   // each task in |graph|.
48   static void ScheduleTasksOnOriginThread(RasterizerTaskClient* client,
49                                           TaskGraph* graph);
50
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
53   // |priority| values.
54   static void InsertNodeForTask(TaskGraph* graph,
55                                 RasterizerTask* task,
56                                 unsigned priority,
57                                 size_t dependencies);
58
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(
62       TaskGraph* graph,
63       RasterTask* task,
64       const ImageDecodeTask::Vector& decode_tasks,
65       unsigned priority);
66
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,
72                                int stride,
73                                const RasterSource* raster_source,
74                                const gfx::Rect& rect,
75                                float scale);
76
77   // Type-checking downcast routine.
78   virtual Rasterizer* AsRasterizer() = 0;
79 };
80
81 }  // namespace cc
82
83 #endif  // CC_RESOURCES_RASTER_WORKER_POOL_H_