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

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

Issue 1866043006: cc: Remove ScheduleOnOriginThread() and CompleteOnOriginThread(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: nits 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/task_graph_runner.h" 13 #include "cc/raster/task_graph_runner.h"
14 #include "cc/resources/resource_format.h" 14 #include "cc/resources/resource_format.h"
15 15
16 namespace cc { 16 namespace cc {
17 class ImageDecodeTask; 17 class ImageDecodeTask;
18 class RasterTask; 18 class RasterTask;
19 class Resource; 19 class Resource;
20 class RasterBuffer; 20 class RasterBuffer;
21 21
22 enum TaskType : TaskTypeId {
23 TASK_TYPE_DEFAULT = kDefaultTaskTypeId,
24 TASK_TYPE_RASTER,
25 TASK_TYPE_IMAGE_DECODE,
26 TASK_TYPE_IMAGE_UPLOAD
27 };
28
22 class CC_EXPORT TileTaskClient { 29 class CC_EXPORT TileTaskClient {
23 public: 30 public:
24 virtual std::unique_ptr<RasterBuffer> AcquireBufferForRaster( 31 virtual std::unique_ptr<RasterBuffer> AcquireBufferForRaster(
25 const Resource* resource, 32 const Resource* resource,
26 uint64_t resource_content_id, 33 uint64_t resource_content_id,
27 uint64_t previous_content_id) = 0; 34 uint64_t previous_content_id) = 0;
28 virtual void ReleaseBufferForRaster(std::unique_ptr<RasterBuffer> buffer) = 0; 35 virtual void ReleaseBufferForRaster(std::unique_ptr<RasterBuffer> buffer) = 0;
29 36
30 protected: 37 protected:
31 virtual ~TileTaskClient() {} 38 virtual ~TileTaskClient() {}
32 }; 39 };
33 40
34 class CC_EXPORT TileTask : public Task { 41 class CC_EXPORT TileTask : public Task {
35 public: 42 public:
36 typedef std::vector<scoped_refptr<TileTask>> Vector; 43 typedef std::vector<scoped_refptr<TileTask>> Vector;
37 44
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(); 45 void DidComplete();
47 bool HasCompleted() const; 46 bool HasCompleted() const;
48 47
49 protected: 48 protected:
50 TileTask(); 49 TileTask();
51 ~TileTask() override; 50 ~TileTask() override;
52 51
53 bool did_schedule_;
54 bool did_complete_; 52 bool did_complete_;
55 }; 53 };
56 54
57 class CC_EXPORT ImageDecodeTask : public TileTask { 55 class CC_EXPORT ImageDecodeTask : public TileTask {
58 public: 56 public:
59 typedef std::vector<scoped_refptr<ImageDecodeTask>> Vector; 57 typedef std::vector<scoped_refptr<ImageDecodeTask>> Vector;
60 58
61 // Indicates whether this ImageDecodeTask can be run at the same time as 59 // Indicates whether this ImageDecodeTask can be run at the same time as
62 // other tasks in the task graph. If false, this task will be scheduled with 60 // other tasks in the task graph. If false, this task will be scheduled with
63 // TASK_CATEGORY_NONCONCURRENT_FOREGROUND. The base implementation always 61 // TASK_CATEGORY_NONCONCURRENT_FOREGROUND. The base implementation always
(...skipping 20 matching lines...) Expand all
84 82
85 protected: 83 protected:
86 explicit RasterTask(ImageDecodeTask::Vector* dependencies); 84 explicit RasterTask(ImageDecodeTask::Vector* dependencies);
87 ~RasterTask() override; 85 ~RasterTask() override;
88 86
89 private: 87 private:
90 ImageDecodeTask::Vector dependencies_; 88 ImageDecodeTask::Vector dependencies_;
91 }; 89 };
92 90
93 // This interface can be used to schedule and run tile tasks. 91 // This interface can be used to schedule and run tile tasks.
94 // The client can call CheckForCompletedTasks() at any time to dispatch 92 // The client can call CollectCompletedTasks() at any time to process
95 // pending completion callbacks for all tasks that have finished running. 93 // all completed tasks at the moment that have finished running or cancelled.
96 class CC_EXPORT TileTaskRunner { 94 class CC_EXPORT TileTaskRunner {
97 public: 95 public:
98 // Tells the worker pool to shutdown after canceling all previously scheduled 96 // Tells the worker pool to shutdown after canceling all previously scheduled
99 // tasks. Reply callbacks are still guaranteed to run when 97 // tasks. Reply callbacks are still guaranteed to run when
100 // CheckForCompletedTasks() is called. 98 // CollectCompletedTasks() is called.
101 virtual void Shutdown() = 0; 99 virtual void Shutdown() = 0;
102 100
103 // Schedule running of tile tasks in |graph| and all dependencies. 101 // Schedule running of tile tasks in |graph| and all dependencies.
104 // Previously scheduled tasks that are not in |graph| will be canceled unless 102 // Previously scheduled tasks that are not in |graph| will be canceled unless
105 // already running. Once scheduled, reply callbacks are guaranteed to run for 103 // already running. Once scheduled, reply callbacks are guaranteed to run for
106 // all tasks even if they later get canceled by another call to 104 // all tasks even if they later get canceled by another call to
107 // ScheduleTasks(). 105 // ScheduleTasks().
108 virtual void ScheduleTasks(TaskGraph* graph) = 0; 106 virtual void ScheduleTasks(TaskGraph* graph) = 0;
109 107
110 // Check for completed tasks and dispatch reply callbacks. 108 // Collect completed tasks.
111 virtual void CheckForCompletedTasks() = 0; 109 virtual void CollectCompletedTasks(Task::Vector* completed_tasks) = 0;
112 110
113 // Returns the format to use for the tiles. 111 // Returns the format to use for the tiles.
114 virtual ResourceFormat GetResourceFormat(bool must_support_alpha) const = 0; 112 virtual ResourceFormat GetResourceFormat(bool must_support_alpha) const = 0;
115 113
116 // Determine if the resource requires swizzling. 114 // Determine if the resource requires swizzling.
117 virtual bool GetResourceRequiresSwizzle(bool must_support_alpha) const = 0; 115 virtual bool GetResourceRequiresSwizzle(bool must_support_alpha) const = 0;
118 116
117 // TODO(prashant.n): This will be removed soon. Don't use this.
118 virtual TileTaskClient* AsTileTaskClient() = 0;
119
119 protected: 120 protected:
120 // Check if resource format matches output format. 121 // Check if resource format matches output format.
121 static bool ResourceFormatRequiresSwizzle(ResourceFormat format); 122 static bool ResourceFormatRequiresSwizzle(ResourceFormat format);
122 123
123 virtual ~TileTaskRunner() {} 124 virtual ~TileTaskRunner() {}
124 }; 125 };
125 126
126 } // namespace cc 127 } // namespace cc
127 128
128 #endif // CC_RASTER_TILE_TASK_RUNNER_H_ 129 #endif // CC_RASTER_TILE_TASK_RUNNER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698