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_RASTER_BUFFER_PROVIDER_H_ |
6 #define CC_RASTER_TILE_TASK_WORKER_POOL_H_ | 6 #define CC_RASTER_RASTER_BUFFER_PROVIDER_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; | 23 class Resource; |
24 | 24 |
25 // This class provides the wrapper over TaskGraphRunner for scheduling and | 25 class CC_EXPORT RasterBufferProvider { |
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: | 26 public: |
31 TileTaskWorkerPool(); | 27 RasterBufferProvider(); |
32 virtual ~TileTaskWorkerPool(); | 28 virtual ~RasterBufferProvider(); |
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 | 29 |
39 // Utility function that will create a temporary bitmap and copy pixels to | 30 // 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 | 31 // |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 | 32 // 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 | 33 // 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 | 34 // 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. | 35 // already partially complete, and only the subrect needs to be played back. |
45 static void PlaybackToMemory( | 36 static void PlaybackToMemory( |
46 void* memory, | 37 void* memory, |
47 ResourceFormat format, | 38 ResourceFormat format, |
48 const gfx::Size& size, | 39 const gfx::Size& size, |
49 size_t stride, | 40 size_t stride, |
50 const RasterSource* raster_source, | 41 const RasterSource* raster_source, |
51 const gfx::Rect& canvas_bitmap_rect, | 42 const gfx::Rect& canvas_bitmap_rect, |
52 const gfx::Rect& canvas_playback_rect, | 43 const gfx::Rect& canvas_playback_rect, |
53 float scale, | 44 float scale, |
54 const RasterSource::PlaybackSettings& playback_settings); | 45 const RasterSource::PlaybackSettings& playback_settings); |
55 | 46 |
56 // Tells the worker pool to shutdown after canceling all previously scheduled | 47 // Acquire raster buffer. |
57 // tasks. Reply callbacks are still guaranteed to run when | 48 virtual std::unique_ptr<RasterBuffer> AcquireBufferForRaster( |
58 // CheckForCompletedTasks() is called. | 49 const Resource* resource, |
59 virtual void Shutdown() = 0; | 50 uint64_t resource_content_id, |
| 51 uint64_t previous_content_id) = 0; |
60 | 52 |
61 // Schedule running of tile tasks in |graph| and all dependencies. | 53 // Release raster buffer. |
62 // Previously scheduled tasks that are not in |graph| will be canceled unless | 54 virtual void ReleaseBufferForRaster(std::unique_ptr<RasterBuffer> buffer) = 0; |
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 | 55 |
68 // Check for completed tasks and dispatch reply callbacks. | 56 // Barrier to sync resources to the worker context. |
69 virtual void CheckForCompletedTasks() = 0; | 57 virtual void OrderingBarrier() = 0; |
70 | 58 |
71 // Returns the format to use for the tiles. | 59 // Returns the format to use for the tiles. |
72 virtual ResourceFormat GetResourceFormat(bool must_support_alpha) const = 0; | 60 virtual ResourceFormat GetResourceFormat(bool must_support_alpha) const = 0; |
73 | 61 |
74 // Determine if the resource requires swizzling. | 62 // Determine if the resource requires swizzling. |
75 virtual bool GetResourceRequiresSwizzle(bool must_support_alpha) const = 0; | 63 virtual bool GetResourceRequiresSwizzle(bool must_support_alpha) const = 0; |
76 | 64 |
77 // Downcasting routine for RasterBufferProvider interface. | 65 // Shutdown for doing cleanup. |
78 virtual RasterBufferProvider* AsRasterBufferProvider() = 0; | 66 virtual void Shutdown() = 0; |
79 | 67 |
80 protected: | 68 protected: |
81 // Check if resource format matches output format. | 69 // Check if resource format matches output format. |
82 static bool ResourceFormatRequiresSwizzle(ResourceFormat format); | 70 static bool ResourceFormatRequiresSwizzle(ResourceFormat format); |
83 }; | 71 }; |
84 | 72 |
85 } // namespace cc | 73 } // namespace cc |
86 | 74 |
87 #endif // CC_RASTER_TILE_TASK_WORKER_POOL_H_ | 75 #endif // CC_RASTER_RASTER_BUFFER_PROVIDER_H_ |
OLD | NEW |