| 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/raster_buffer.h" |
| 12 #include "cc/raster/task_graph_runner.h" | 12 #include "cc/raster/task_graph_runner.h" |
| 13 #include "cc/raster/tile_task.h" | 13 #include "cc/raster/tile_task.h" |
| 14 #include "cc/resources/resource_format.h" | 14 #include "cc/resources/resource_format.h" |
| 15 #include "ui/gfx/geometry/rect.h" | 15 #include "ui/gfx/geometry/rect.h" |
| 16 #include "ui/gfx/geometry/size.h" | 16 #include "ui/gfx/geometry/size.h" |
| 17 | 17 |
| 18 namespace base { | 18 namespace base { |
| 19 class SequencedTaskRunner; | 19 class SequencedTaskRunner; |
| 20 } | 20 } |
| 21 | 21 |
| 22 namespace cc { | 22 namespace cc { |
| 23 class RenderingStatsInstrumentation; | |
| 24 | 23 |
| 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. | |
| 29 class CC_EXPORT TileTaskWorkerPool { | 24 class CC_EXPORT TileTaskWorkerPool { |
| 30 public: | 25 public: |
| 31 TileTaskWorkerPool(); | 26 TileTaskWorkerPool(); |
| 32 virtual ~TileTaskWorkerPool(); | 27 virtual ~TileTaskWorkerPool(); |
| 33 | 28 |
| 34 // Utility function that can be used to call ::ScheduleOnOriginThread() for | |
| 35 // each task in |graph|. | |
| 36 static void ScheduleTasksOnOriginThread(RasterBufferProvider* provider, | |
| 37 TaskGraph* graph); | |
| 38 | |
| 39 // Utility function that will create a temporary bitmap and copy pixels to | 29 // Utility function that will create a temporary bitmap and copy pixels to |
| 40 // |memory| when necessary. The |canvas_bitmap_rect| is the rect of the bitmap | 30 // |memory| when necessary. The |canvas_bitmap_rect| is the rect of the bitmap |
| 41 // being played back in the pixel space of the source, ie a rect in the source | 31 // being played back in the pixel space of the source, ie a rect in the source |
| 42 // that will cover the resulting |memory|. The |canvas_playback_rect| can be a | 32 // that will cover the resulting |memory|. The |canvas_playback_rect| can be a |
| 43 // smaller contained rect inside the |canvas_bitmap_rect| if the |memory| is | 33 // smaller contained rect inside the |canvas_bitmap_rect| if the |memory| is |
| 44 // already partially complete, and only the subrect needs to be played back. | 34 // already partially complete, and only the subrect needs to be played back. |
| 45 static void PlaybackToMemory( | 35 static void PlaybackToMemory( |
| 46 void* memory, | 36 void* memory, |
| 47 ResourceFormat format, | 37 ResourceFormat format, |
| 48 const gfx::Size& size, | 38 const gfx::Size& size, |
| 49 size_t stride, | 39 size_t stride, |
| 50 const RasterSource* raster_source, | 40 const RasterSource* raster_source, |
| 51 const gfx::Rect& canvas_bitmap_rect, | 41 const gfx::Rect& canvas_bitmap_rect, |
| 52 const gfx::Rect& canvas_playback_rect, | 42 const gfx::Rect& canvas_playback_rect, |
| 53 float scale, | 43 float scale, |
| 54 const RasterSource::PlaybackSettings& playback_settings); | 44 const RasterSource::PlaybackSettings& playback_settings); |
| 55 | 45 |
| 56 // Tells the worker pool to shutdown after canceling all previously scheduled | 46 // Barrier to sync any new resources to the worker context. |
| 57 // tasks. Reply callbacks are still guaranteed to run when | 47 virtual void BarrierToSyncResources() = 0; |
| 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 | 48 |
| 71 // Returns the format to use for the tiles. | 49 // Returns the format to use for the tiles. |
| 72 virtual ResourceFormat GetResourceFormat(bool must_support_alpha) const = 0; | 50 virtual ResourceFormat GetResourceFormat(bool must_support_alpha) const = 0; |
| 73 | 51 |
| 74 // Determine if the resource requires swizzling. | 52 // Determine if the resource requires swizzling. |
| 75 virtual bool GetResourceRequiresSwizzle(bool must_support_alpha) const = 0; | 53 virtual bool GetResourceRequiresSwizzle(bool must_support_alpha) const = 0; |
| 76 | 54 |
| 77 // Downcasting routine for RasterBufferProvider interface. | 55 // Downcasting routine for RasterBufferProvider interface. |
| 78 virtual RasterBufferProvider* AsRasterBufferProvider() = 0; | 56 virtual RasterBufferProvider* AsRasterBufferProvider() = 0; |
| 79 | 57 |
| 80 protected: | 58 protected: |
| 81 // Check if resource format matches output format. | 59 // Check if resource format matches output format. |
| 82 static bool ResourceFormatRequiresSwizzle(ResourceFormat format); | 60 static bool ResourceFormatRequiresSwizzle(ResourceFormat format); |
| 83 }; | 61 }; |
| 84 | 62 |
| 85 } // namespace cc | 63 } // namespace cc |
| 86 | 64 |
| 87 #endif // CC_RASTER_TILE_TASK_WORKER_POOL_H_ | 65 #endif // CC_RASTER_TILE_TASK_WORKER_POOL_H_ |
| OLD | NEW |