| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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_TILES_TILE_TASK_MANAGER_H_ | 5 #ifndef CC_TILES_TILE_TASK_MANAGER_H_ |
| 6 #define CC_TILES_TILE_TASK_MANAGER_H_ | 6 #define CC_TILES_TILE_TASK_MANAGER_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 | 9 |
| 10 #include "cc/raster/raster_buffer_provider.h" | 10 #include "cc/raster/raster_buffer_provider.h" |
| 11 #include "cc/raster/task_graph_runner.h" | 11 #include "cc/raster/task_graph_runner.h" |
| 12 #include "cc/raster/tile_task.h" | 12 #include "cc/raster/tile_task.h" |
| 13 | 13 |
| 14 namespace cc { | 14 namespace cc { |
| 15 // This interface provides the wrapper over TaskGraphRunner for scheduling and | 15 // This interface provides the wrapper over TaskGraphRunner for scheduling and |
| 16 // collecting tasks. The client can call CheckForCompletedTasks() at any time to | 16 // collecting tasks. The client can call CheckForCompletedTasks() at any time to |
| 17 // process all completed tasks at the moment that have finished running or | 17 // process all completed tasks at the moment that have finished running or |
| 18 // cancelled. | 18 // cancelled. |
| 19 class CC_EXPORT TileTaskManager { | 19 class CC_EXPORT TileTaskManager { |
| 20 public: | 20 public: |
| 21 TileTaskManager(); | 21 TileTaskManager(); |
| 22 virtual ~TileTaskManager(); | 22 virtual ~TileTaskManager(); |
| 23 | 23 |
| 24 // Schedule running of tile tasks in |graph| and all dependencies. | 24 // Schedule running of tile tasks in |graph| and all dependencies. |
| 25 // Previously scheduled tasks that are not in |graph| will be canceled unless | 25 // Previously scheduled tasks that are not in |graph| will be canceled unless |
| 26 // already running. Once scheduled, reply callbacks are guaranteed to run for | 26 // already running. Once scheduled and if not canceled by next scheduling, |
| 27 // all tasks even if they later get canceled by another call to | 27 // tasks are guaranteed to run. |
| 28 // ScheduleTasks(). | |
| 29 virtual void ScheduleTasks(TaskGraph* graph) = 0; | 28 virtual void ScheduleTasks(TaskGraph* graph) = 0; |
| 30 | 29 |
| 31 // Check for completed tasks and dispatch reply callbacks. | 30 // Check for completed tasks and call OnTaskCompleted() on them. |
| 32 virtual void CheckForCompletedTasks() = 0; | 31 virtual void CheckForCompletedTasks() = 0; |
| 33 | 32 |
| 34 // Shutdown after canceling all previously scheduled tasks. Reply callbacks | 33 // Shutdown after canceling all previously scheduled tasks. |
| 35 // are still guaranteed to run when CheckForCompletedTasks() is called. | |
| 36 virtual void Shutdown() = 0; | 34 virtual void Shutdown() = 0; |
| 37 | 35 |
| 38 // Get RasterBufferProvider. | 36 // Get RasterBufferProvider. |
| 39 virtual RasterBufferProvider* GetRasterBufferProvider() const = 0; | 37 virtual RasterBufferProvider* GetRasterBufferProvider() const = 0; |
| 40 }; | 38 }; |
| 41 | 39 |
| 42 class CC_EXPORT TileTaskManagerImpl : public TileTaskManager { | 40 class CC_EXPORT TileTaskManagerImpl : public TileTaskManager { |
| 43 public: | 41 public: |
| 44 ~TileTaskManagerImpl() override; | 42 ~TileTaskManagerImpl() override; |
| 45 | 43 |
| 46 static std::unique_ptr<TileTaskManagerImpl> Create( | 44 static std::unique_ptr<TileTaskManagerImpl> Create( |
| 47 std::unique_ptr<RasterBufferProvider> raster_buffer_provider, | 45 std::unique_ptr<RasterBufferProvider> raster_buffer_provider, |
| 48 TaskGraphRunner* task_graph_runner); | 46 TaskGraphRunner* task_graph_runner); |
| 49 | 47 |
| 50 // Overridden from TileTaskManager: | 48 // Overridden from TileTaskManager: |
| 51 void ScheduleTasks(TaskGraph* graph) override; | 49 void ScheduleTasks(TaskGraph* graph) override; |
| 52 void CheckForCompletedTasks() override; | 50 void CheckForCompletedTasks() override; |
| 53 void Shutdown() override; | 51 void Shutdown() override; |
| 54 RasterBufferProvider* GetRasterBufferProvider() const override; | 52 RasterBufferProvider* GetRasterBufferProvider() const override; |
| 55 | 53 |
| 56 protected: | 54 protected: |
| 57 TileTaskManagerImpl( | 55 TileTaskManagerImpl( |
| 58 std::unique_ptr<RasterBufferProvider> raster_buffer_provider, | 56 std::unique_ptr<RasterBufferProvider> raster_buffer_provider, |
| 59 TaskGraphRunner* task_graph_runner); | 57 TaskGraphRunner* task_graph_runner); |
| 60 | 58 |
| 61 std::unique_ptr<RasterBufferProvider> raster_buffer_provider_; | 59 std::unique_ptr<RasterBufferProvider> raster_buffer_provider_; |
| 62 TaskGraphRunner* task_graph_runner_; | 60 TaskGraphRunner* task_graph_runner_; |
| 63 const NamespaceToken namespace_token_; | 61 const NamespaceToken namespace_token_; |
| 64 Task::Vector completed_tasks_; | |
| 65 | 62 |
| 66 private: | 63 private: |
| 67 DISALLOW_COPY_AND_ASSIGN(TileTaskManagerImpl); | 64 DISALLOW_COPY_AND_ASSIGN(TileTaskManagerImpl); |
| 68 }; | 65 }; |
| 69 | 66 |
| 70 } // namespace cc | 67 } // namespace cc |
| 71 | 68 |
| 72 #endif // CC_TILES_TILE_TASK_MANAGER_H_ | 69 #endif // CC_TILES_TILE_TASK_MANAGER_H_ |
| OLD | NEW |