Explicitly add python-numpy dependency to install-build-deps.
[chromium-blink-merge.git] / cc / resources / raster_worker_pool.h
blob5259f835492abbc7934363b3d99ce054c5b9ef89
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"
12 namespace base {
13 class SequencedTaskRunner;
16 namespace cc {
17 class RasterSource;
18 class RenderingStatsInstrumentation;
20 class CC_EXPORT RasterWorkerPool {
21 public:
22 static unsigned kBenchmarkRasterTaskPriority;
23 static unsigned kRasterFinishedTaskPriority;
24 static unsigned kRasterTaskPriorityBase;
26 RasterWorkerPool();
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,
49 TaskGraph* graph);
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);
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);
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);
77 // Type-checking downcast routine.
78 virtual Rasterizer* AsRasterizer() = 0;
81 } // namespace cc
83 #endif // CC_RESOURCES_RASTER_WORKER_POOL_H_