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