Enable right clicking on the applist doodle web contents and log the data.
[chromium-blink-merge.git] / cc / resources / tile_task_worker_pool.h
blob915a3fa0a8ca2afe9e07644fb13e6cb906a40323
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_TILE_TASK_WORKER_POOL_H_
6 #define CC_RESOURCES_TILE_TASK_WORKER_POOL_H_
8 #include "base/threading/platform_thread.h"
9 #include "cc/resources/tile_task_runner.h"
10 #include "ui/gfx/geometry/rect.h"
11 #include "ui/gfx/geometry/size.h"
13 namespace base {
14 class SequencedTaskRunner;
17 namespace cc {
18 class RasterSource;
19 class RenderingStatsInstrumentation;
21 class CC_EXPORT TileTaskWorkerPool {
22 public:
23 static unsigned kBenchmarkTaskPriority;
24 static unsigned kTaskSetFinishedTaskPriorityBase;
25 static unsigned kTileTaskPriorityBase;
27 TileTaskWorkerPool();
28 virtual ~TileTaskWorkerPool();
30 // Set the number of threads to use for the global TaskGraphRunner instance.
31 // This can only be called once and must be called prior to
32 // GetNumWorkerThreads().
33 static void SetNumWorkerThreads(int num_threads);
35 // Returns the number of threads used for the global TaskGraphRunner instance.
36 static int GetNumWorkerThreads();
38 // Set the priority of worker threads.
39 static void SetWorkerThreadPriority(base::ThreadPriority priority);
41 // Returns a pointer to the global TaskGraphRunner instance.
42 static TaskGraphRunner* GetTaskGraphRunner();
44 // Utility function that can be used to create a "Task set finished" task that
45 // posts |callback| to |task_runner| when run.
46 static scoped_refptr<TileTask> CreateTaskSetFinishedTask(
47 base::SequencedTaskRunner* task_runner,
48 const base::Closure& callback);
50 // Utility function that can be used to call ::ScheduleOnOriginThread() for
51 // each task in |graph|.
52 static void ScheduleTasksOnOriginThread(TileTaskClient* client,
53 TaskGraph* graph);
55 // Utility function that can be used to build a task graph. Inserts a node
56 // that represents |task| in |graph|. See TaskGraph definition for valid
57 // |priority| values.
58 static void InsertNodeForTask(TaskGraph* graph,
59 TileTask* task,
60 unsigned priority,
61 size_t dependencies);
63 // Utility function that can be used to build a task graph. Inserts nodes that
64 // represent |task| and all its image decode dependencies in |graph|.
65 static void InsertNodesForRasterTask(
66 TaskGraph* graph,
67 RasterTask* task,
68 const ImageDecodeTask::Vector& decode_tasks,
69 unsigned priority);
71 // Utility function that will create a temporary bitmap and copy pixels to
72 // |memory| when necessary.
73 static void PlaybackToMemory(void* memory,
74 ResourceFormat format,
75 const gfx::Size& size,
76 int stride,
77 const RasterSource* raster_source,
78 const gfx::Rect& rect,
79 float scale);
81 // Type-checking downcast routine.
82 virtual TileTaskRunner* AsTileTaskRunner() = 0;
85 } // namespace cc
87 #endif // CC_RESOURCES_TILE_TASK_WORKER_POOL_H_