Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(29)

Side by Side Diff: cc/raster/tile_task_runner.h

Issue 1854723002: cc: Simplify task and its derived classes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Corrected scope of dependencies. Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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_RUNNER_H_ 5 #ifndef CC_RASTER_TILE_TASK_RUNNER_H_
6 #define CC_RASTER_TILE_TASK_RUNNER_H_ 6 #define CC_RASTER_TILE_TASK_RUNNER_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/callback.h" 12 #include "base/callback.h"
13 #include "cc/raster/raster_buffer.h"
14 #include "cc/raster/task.h"
13 #include "cc/raster/task_graph_runner.h" 15 #include "cc/raster/task_graph_runner.h"
14 #include "cc/resources/resource_format.h" 16 #include "cc/resources/resource_format.h"
15 17
16 namespace cc { 18 namespace cc {
17 class ImageDecodeTask;
18 class RasterTask;
19 class Resource;
20 class RasterBuffer;
21
22 class CC_EXPORT TileTaskClient {
23 public:
24 virtual scoped_ptr<RasterBuffer> AcquireBufferForRaster(
25 const Resource* resource,
26 uint64_t resource_content_id,
27 uint64_t previous_content_id) = 0;
28 virtual void ReleaseBufferForRaster(scoped_ptr<RasterBuffer> buffer) = 0;
29
30 protected:
31 virtual ~TileTaskClient() {}
32 };
33
34 class CC_EXPORT TileTask : public Task {
35 public:
36 typedef std::vector<scoped_refptr<TileTask>> Vector;
37
38 virtual void ScheduleOnOriginThread(TileTaskClient* client) = 0;
39 virtual void CompleteOnOriginThread(TileTaskClient* client) = 0;
40
41 void WillSchedule();
42 void DidSchedule();
43 bool HasBeenScheduled() const;
44
45 void WillComplete();
46 void DidComplete();
47 bool HasCompleted() const;
48
49 protected:
50 TileTask();
51 ~TileTask() override;
52
53 bool did_schedule_;
54 bool did_complete_;
55 };
56
57 class CC_EXPORT ImageDecodeTask : public TileTask {
58 public:
59 typedef std::vector<scoped_refptr<ImageDecodeTask>> Vector;
60
61 protected:
62 ImageDecodeTask();
63 ~ImageDecodeTask() override;
64 };
65
66 class CC_EXPORT RasterTask : public TileTask {
67 public:
68 typedef std::vector<scoped_refptr<RasterTask>> Vector;
69
70 const ImageDecodeTask::Vector& dependencies() const { return dependencies_; }
71
72 protected:
73 explicit RasterTask(ImageDecodeTask::Vector* dependencies);
74 ~RasterTask() override;
75
76 private:
77 ImageDecodeTask::Vector dependencies_;
78 };
79 19
80 // This interface can be used to schedule and run tile tasks. 20 // This interface can be used to schedule and run tile tasks.
81 // The client can call CheckForCompletedTasks() at any time to dispatch 21 // The client can call CheckForCompletedTasks() at any time to dispatch
82 // pending completion callbacks for all tasks that have finished running. 22 // pending completion callbacks for all tasks that have finished running.
83 class CC_EXPORT TileTaskRunner { 23 class CC_EXPORT TileTaskRunner : public RasterBufferProvider {
84 public: 24 public:
85 // Tells the worker pool to shutdown after canceling all previously scheduled 25 // Tells the worker pool to shutdown after canceling all previously scheduled
86 // tasks. Reply callbacks are still guaranteed to run when 26 // tasks. Reply callbacks are still guaranteed to run when
87 // CheckForCompletedTasks() is called. 27 // CheckForCompletedTasks() is called.
88 virtual void Shutdown() = 0; 28 virtual void Shutdown() = 0;
89 29
90 // Schedule running of tile tasks in |graph| and all dependencies. 30 // Schedule running of tile tasks in |graph| and all dependencies.
91 // Previously scheduled tasks that are not in |graph| will be canceled unless 31 // Previously scheduled tasks that are not in |graph| will be canceled unless
92 // already running. Once scheduled, reply callbacks are guaranteed to run for 32 // already running. Once scheduled, reply callbacks are guaranteed to run for
93 // all tasks even if they later get canceled by another call to 33 // all tasks even if they later get canceled by another call to
94 // ScheduleTasks(). 34 // ScheduleTasks().
95 virtual void ScheduleTasks(TaskGraph* graph) = 0; 35 virtual void ScheduleTasks(TaskGraph* graph) = 0;
96 36
97 // Check for completed tasks and dispatch reply callbacks. 37 // Check for completed tasks and dispatch reply callbacks.
98 virtual void CheckForCompletedTasks() = 0; 38 virtual void CheckForCompletedTasks() = 0;
99 39
100 // Returns the format to use for the tiles. 40 // Returns the format to use for the tiles.
101 virtual ResourceFormat GetResourceFormat(bool must_support_alpha) const = 0; 41 virtual ResourceFormat GetResourceFormat(bool must_support_alpha) const = 0;
102 42
103 // Determine if the resource requires swizzling. 43 // Determine if the resource requires swizzling.
104 virtual bool GetResourceRequiresSwizzle(bool must_support_alpha) const = 0; 44 virtual bool GetResourceRequiresSwizzle(bool must_support_alpha) const = 0;
105 45
106 protected: 46 protected:
107 // Check if resource format matches output format. 47 // Check if resource format matches output format.
108 static bool ResourceFormatRequiresSwizzle(ResourceFormat format); 48 static bool ResourceFormatRequiresSwizzle(ResourceFormat format);
109 49
110 virtual ~TileTaskRunner() {} 50 ~TileTaskRunner() override {}
111 }; 51 };
112 52
113 } // namespace cc 53 } // namespace cc
114 54
115 #endif // CC_RASTER_TILE_TASK_RUNNER_H_ 55 #endif // CC_RASTER_TILE_TASK_RUNNER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698