OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CC_RASTER_TILE_TASK_WORKER_POOL_H_ | 5 #ifndef CC_RASTER_TILE_TASK_WORKER_POOL_H_ |
6 #define CC_RASTER_TILE_TASK_WORKER_POOL_H_ | 6 #define CC_RASTER_TILE_TASK_WORKER_POOL_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 | 9 |
10 #include "cc/playback/raster_source.h" | 10 #include "cc/playback/raster_source.h" |
| 11 #include "cc/raster/raster_buffer.h" |
11 #include "cc/raster/task_graph_runner.h" | 12 #include "cc/raster/task_graph_runner.h" |
12 #include "cc/raster/tile_task_runner.h" | 13 #include "cc/raster/tile_task.h" |
| 14 #include "cc/resources/resource_format.h" |
13 #include "ui/gfx/geometry/rect.h" | 15 #include "ui/gfx/geometry/rect.h" |
14 #include "ui/gfx/geometry/size.h" | 16 #include "ui/gfx/geometry/size.h" |
15 | 17 |
16 namespace base { | 18 namespace base { |
17 class SequencedTaskRunner; | 19 class SequencedTaskRunner; |
18 } | 20 } |
19 | 21 |
20 namespace cc { | 22 namespace cc { |
21 class RenderingStatsInstrumentation; | 23 class RenderingStatsInstrumentation; |
22 | 24 |
| 25 // This class provides the wrapper over TaskGraphRunner for scheduling and |
| 26 // collecting tasks. The client can call CheckForCompletedTasks() at any time to |
| 27 // process all completed tasks at the moment that have finished running or |
| 28 // cancelled. |
23 class CC_EXPORT TileTaskWorkerPool { | 29 class CC_EXPORT TileTaskWorkerPool { |
24 public: | 30 public: |
25 TileTaskWorkerPool(); | 31 TileTaskWorkerPool(); |
26 virtual ~TileTaskWorkerPool(); | 32 virtual ~TileTaskWorkerPool(); |
27 | 33 |
28 // Utility function that can be used to call ::ScheduleOnOriginThread() for | 34 // Utility function that can be used to call ::ScheduleOnOriginThread() for |
29 // each task in |graph|. | 35 // each task in |graph|. |
30 static void ScheduleTasksOnOriginThread(RasterBufferProvider* provider, | 36 static void ScheduleTasksOnOriginThread(RasterBufferProvider* provider, |
31 TaskGraph* graph); | 37 TaskGraph* graph); |
32 | 38 |
33 // Utility function that will create a temporary bitmap and copy pixels to | 39 // Utility function that will create a temporary bitmap and copy pixels to |
34 // |memory| when necessary. The |canvas_bitmap_rect| is the rect of the bitmap | 40 // |memory| when necessary. The |canvas_bitmap_rect| is the rect of the bitmap |
35 // being played back in the pixel space of the source, ie a rect in the source | 41 // being played back in the pixel space of the source, ie a rect in the source |
36 // that will cover the resulting |memory|. The |canvas_playback_rect| can be a | 42 // that will cover the resulting |memory|. The |canvas_playback_rect| can be a |
37 // smaller contained rect inside the |canvas_bitmap_rect| if the |memory| is | 43 // smaller contained rect inside the |canvas_bitmap_rect| if the |memory| is |
38 // already partially complete, and only the subrect needs to be played back. | 44 // already partially complete, and only the subrect needs to be played back. |
39 static void PlaybackToMemory( | 45 static void PlaybackToMemory( |
40 void* memory, | 46 void* memory, |
41 ResourceFormat format, | 47 ResourceFormat format, |
42 const gfx::Size& size, | 48 const gfx::Size& size, |
43 size_t stride, | 49 size_t stride, |
44 const RasterSource* raster_source, | 50 const RasterSource* raster_source, |
45 const gfx::Rect& canvas_bitmap_rect, | 51 const gfx::Rect& canvas_bitmap_rect, |
46 const gfx::Rect& canvas_playback_rect, | 52 const gfx::Rect& canvas_playback_rect, |
47 float scale, | 53 float scale, |
48 const RasterSource::PlaybackSettings& playback_settings); | 54 const RasterSource::PlaybackSettings& playback_settings); |
49 | 55 |
50 // Type-checking downcast routine. | 56 // Tells the worker pool to shutdown after canceling all previously scheduled |
51 virtual TileTaskRunner* AsTileTaskRunner() = 0; | 57 // tasks. Reply callbacks are still guaranteed to run when |
| 58 // CheckForCompletedTasks() is called. |
| 59 virtual void Shutdown() = 0; |
| 60 |
| 61 // Schedule running of tile tasks in |graph| and all dependencies. |
| 62 // Previously scheduled tasks that are not in |graph| will be canceled unless |
| 63 // already running. Once scheduled, reply callbacks are guaranteed to run for |
| 64 // all tasks even if they later get canceled by another call to |
| 65 // ScheduleTasks(). |
| 66 virtual void ScheduleTasks(TaskGraph* graph) = 0; |
| 67 |
| 68 // Check for completed tasks and dispatch reply callbacks. |
| 69 virtual void CheckForCompletedTasks() = 0; |
| 70 |
| 71 // Returns the format to use for the tiles. |
| 72 virtual ResourceFormat GetResourceFormat(bool must_support_alpha) const = 0; |
| 73 |
| 74 // Determine if the resource requires swizzling. |
| 75 virtual bool GetResourceRequiresSwizzle(bool must_support_alpha) const = 0; |
| 76 |
| 77 // Downcasting routine for RasterBufferProvider interface. |
| 78 virtual RasterBufferProvider* AsRasterBufferProvider() = 0; |
| 79 |
| 80 protected: |
| 81 // Check if resource format matches output format. |
| 82 static bool ResourceFormatRequiresSwizzle(ResourceFormat format); |
52 }; | 83 }; |
53 | 84 |
54 } // namespace cc | 85 } // namespace cc |
55 | 86 |
56 #endif // CC_RASTER_TILE_TASK_WORKER_POOL_H_ | 87 #endif // CC_RASTER_TILE_TASK_WORKER_POOL_H_ |
OLD | NEW |