OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 GPU_COMMAND_BUFFER_SERVICE_GPU_SCHEDULER_H_ | 5 #ifndef GPU_COMMAND_BUFFER_SERVICE_GPU_SCHEDULER_H_ |
6 #define GPU_COMMAND_BUFFER_SERVICE_GPU_SCHEDULER_H_ | 6 #define GPU_COMMAND_BUFFER_SERVICE_GPU_SCHEDULER_H_ |
7 | 7 |
8 #include <queue> | 8 #include <queue> |
9 | 9 |
10 #include "base/atomic_ref_count.h" | 10 #include "base/atomic_ref_count.h" |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 | 66 |
67 // Sets whether commands should be processed by this scheduler. Setting to | 67 // Sets whether commands should be processed by this scheduler. Setting to |
68 // false unschedules. Setting to true reschedules. Whether or not the | 68 // false unschedules. Setting to true reschedules. Whether or not the |
69 // scheduler is currently scheduled is "reference counted". Every call with | 69 // scheduler is currently scheduled is "reference counted". Every call with |
70 // false must eventually be paired by a call with true. | 70 // false must eventually be paired by a call with true. |
71 void SetScheduled(bool is_scheduled); | 71 void SetScheduled(bool is_scheduled); |
72 | 72 |
73 // Returns whether the scheduler is currently able to process more commands. | 73 // Returns whether the scheduler is currently able to process more commands. |
74 bool IsScheduled(); | 74 bool IsScheduled(); |
75 | 75 |
76 // Returns whether the scheduler needs to be polled again in the future. | 76 // Returns whether the scheduler needs to be polled again in the future to |
77 bool HasMoreWork(); | 77 // process pending queries. |
| 78 bool HasPendingQueries() const; |
| 79 |
| 80 // Process pending queries and return. HasPendingQueries() can be used to |
| 81 // determine if there's more pending queries after this has been called. |
| 82 void ProcessPendingQueries(); |
78 | 83 |
79 typedef base::Callback<void(bool /* scheduled */)> SchedulingChangedCallback; | 84 typedef base::Callback<void(bool /* scheduled */)> SchedulingChangedCallback; |
80 | 85 |
81 // Sets a callback that is invoked just before scheduler is rescheduled | 86 // Sets a callback that is invoked just before scheduler is rescheduled |
82 // or descheduled. Takes ownership of callback object. | 87 // or descheduled. Takes ownership of callback object. |
83 void SetSchedulingChangedCallback(const SchedulingChangedCallback& callback); | 88 void SetSchedulingChangedCallback(const SchedulingChangedCallback& callback); |
84 | 89 |
85 // Implementation of CommandBufferEngine. | 90 // Implementation of CommandBufferEngine. |
86 scoped_refptr<Buffer> GetSharedMemoryBuffer(int32 shm_id) override; | 91 scoped_refptr<Buffer> GetSharedMemoryBuffer(int32 shm_id) override; |
87 void set_token(int32 token) override; | 92 void set_token(int32 token) override; |
88 bool SetGetBuffer(int32 transfer_buffer_id) override; | 93 bool SetGetBuffer(int32 transfer_buffer_id) override; |
89 bool SetGetOffset(int32 offset) override; | 94 bool SetGetOffset(int32 offset) override; |
90 int32 GetGetOffset() override; | 95 int32 GetGetOffset() override; |
91 | 96 |
92 void SetCommandProcessedCallback(const base::Closure& callback); | 97 void SetCommandProcessedCallback(const base::Closure& callback); |
93 | 98 |
94 bool HasMoreIdleWork(); | 99 // Returns whether the scheduler needs to be polled again in the future to |
| 100 // process idle work. |
| 101 bool HasMoreIdleWork() const; |
| 102 |
| 103 // Perform some idle work and return. HasMoreIdleWork() can be used to |
| 104 // determine if there's more idle work do be done after this has been called. |
95 void PerformIdleWork(); | 105 void PerformIdleWork(); |
96 | 106 |
97 CommandParser* parser() const { | 107 CommandParser* parser() const { |
98 return parser_.get(); | 108 return parser_.get(); |
99 } | 109 } |
100 | 110 |
101 bool IsPreempted(); | 111 bool IsPreempted(); |
102 | 112 |
103 private: | 113 private: |
104 // Artificially reschedule if the scheduler is still unscheduled after a | 114 // Artificially reschedule if the scheduler is still unscheduled after a |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 // A factory for outstanding rescheduling tasks that is invalidated whenever | 151 // A factory for outstanding rescheduling tasks that is invalidated whenever |
142 // the scheduler is rescheduled. | 152 // the scheduler is rescheduled. |
143 base::WeakPtrFactory<GpuScheduler> reschedule_task_factory_; | 153 base::WeakPtrFactory<GpuScheduler> reschedule_task_factory_; |
144 | 154 |
145 DISALLOW_COPY_AND_ASSIGN(GpuScheduler); | 155 DISALLOW_COPY_AND_ASSIGN(GpuScheduler); |
146 }; | 156 }; |
147 | 157 |
148 } // namespace gpu | 158 } // namespace gpu |
149 | 159 |
150 #endif // GPU_COMMAND_BUFFER_SERVICE_GPU_SCHEDULER_H_ | 160 #endif // GPU_COMMAND_BUFFER_SERVICE_GPU_SCHEDULER_H_ |
OLD | NEW |