| OLD | NEW |
| (Empty) |
| 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. | |
| 4 | |
| 5 #ifndef CC_RASTER_TILE_TASK_WORKER_POOL_H_ | |
| 6 #define CC_RASTER_TILE_TASK_WORKER_POOL_H_ | |
| 7 | |
| 8 #include <stddef.h> | |
| 9 | |
| 10 #include "cc/playback/raster_source.h" | |
| 11 #include "cc/raster/raster_buffer.h" | |
| 12 #include "cc/raster/task_graph_runner.h" | |
| 13 #include "cc/raster/tile_task.h" | |
| 14 #include "cc/resources/resource_format.h" | |
| 15 #include "ui/gfx/geometry/rect.h" | |
| 16 #include "ui/gfx/geometry/size.h" | |
| 17 | |
| 18 namespace base { | |
| 19 class SequencedTaskRunner; | |
| 20 } | |
| 21 | |
| 22 namespace cc { | |
| 23 class RenderingStatsInstrumentation; | |
| 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. | |
| 29 class CC_EXPORT TileTaskWorkerPool { | |
| 30 public: | |
| 31 TileTaskWorkerPool(); | |
| 32 virtual ~TileTaskWorkerPool(); | |
| 33 | |
| 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 | |
| 40 // |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 | |
| 42 // 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 | |
| 44 // already partially complete, and only the subrect needs to be played back. | |
| 45 static void PlaybackToMemory( | |
| 46 void* memory, | |
| 47 ResourceFormat format, | |
| 48 const gfx::Size& size, | |
| 49 size_t stride, | |
| 50 const RasterSource* raster_source, | |
| 51 const gfx::Rect& canvas_bitmap_rect, | |
| 52 const gfx::Rect& canvas_playback_rect, | |
| 53 float scale, | |
| 54 const RasterSource::PlaybackSettings& playback_settings); | |
| 55 | |
| 56 // Tells the worker pool to shutdown after canceling all previously scheduled | |
| 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); | |
| 83 }; | |
| 84 | |
| 85 } // namespace cc | |
| 86 | |
| 87 #endif // CC_RASTER_TILE_TASK_WORKER_POOL_H_ | |
| OLD | NEW |