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/atomicops.h" | 10 #include "base/atomicops.h" |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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. |
77 bool HasMoreWork(); | 77 bool HasMoreWork(); |
78 | 78 |
79 // Sets a callback that is invoked just before scheduler is rescheduled. | 79 typedef base::Callback<void(bool /* scheduled */)> SchedulingChangedCallback; |
80 // Takes ownership of callback object. | 80 |
81 void SetScheduledCallback(const base::Closure& scheduled_callback); | 81 // Sets a callback that is invoked just before scheduler is rescheduled |
| 82 // or descheduled. Takes ownership of callback object. |
| 83 void SetSchedulingChangedCallback(const SchedulingChangedCallback& callback); |
82 | 84 |
83 // Implementation of CommandBufferEngine. | 85 // Implementation of CommandBufferEngine. |
84 virtual Buffer GetSharedMemoryBuffer(int32 shm_id) OVERRIDE; | 86 virtual Buffer GetSharedMemoryBuffer(int32 shm_id) OVERRIDE; |
85 virtual void set_token(int32 token) OVERRIDE; | 87 virtual void set_token(int32 token) OVERRIDE; |
86 virtual bool SetGetBuffer(int32 transfer_buffer_id) OVERRIDE; | 88 virtual bool SetGetBuffer(int32 transfer_buffer_id) OVERRIDE; |
87 virtual bool SetGetOffset(int32 offset) OVERRIDE; | 89 virtual bool SetGetOffset(int32 offset) OVERRIDE; |
88 virtual int32 GetGetOffset() OVERRIDE; | 90 virtual int32 GetGetOffset() OVERRIDE; |
89 | 91 |
90 void SetCommandProcessedCallback(const base::Closure& callback); | 92 void SetCommandProcessedCallback(const base::Closure& callback); |
91 | 93 |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
139 // are issued to it before all these fences have been crossed by the GPU. | 141 // are issued to it before all these fences have been crossed by the GPU. |
140 struct UnscheduleFence { | 142 struct UnscheduleFence { |
141 UnscheduleFence(gfx::GLFence* fence, base::Closure task); | 143 UnscheduleFence(gfx::GLFence* fence, base::Closure task); |
142 ~UnscheduleFence(); | 144 ~UnscheduleFence(); |
143 | 145 |
144 scoped_ptr<gfx::GLFence> fence; | 146 scoped_ptr<gfx::GLFence> fence; |
145 base::Closure task; | 147 base::Closure task; |
146 }; | 148 }; |
147 std::queue<linked_ptr<UnscheduleFence> > unschedule_fences_; | 149 std::queue<linked_ptr<UnscheduleFence> > unschedule_fences_; |
148 | 150 |
149 base::Closure scheduled_callback_; | 151 SchedulingChangedCallback scheduling_changed_callback_; |
| 152 base::Closure descheduled_callback_; |
150 base::Closure command_processed_callback_; | 153 base::Closure command_processed_callback_; |
151 | 154 |
152 // If non-NULL and |preemption_flag_->IsSet()|, exit PutChanged early. | 155 // If non-NULL and |preemption_flag_->IsSet()|, exit PutChanged early. |
153 scoped_refptr<PreemptionFlag> preemption_flag_; | 156 scoped_refptr<PreemptionFlag> preemption_flag_; |
154 bool was_preempted_; | 157 bool was_preempted_; |
155 | 158 |
156 DISALLOW_COPY_AND_ASSIGN(GpuScheduler); | 159 DISALLOW_COPY_AND_ASSIGN(GpuScheduler); |
157 }; | 160 }; |
158 | 161 |
159 } // namespace gpu | 162 } // namespace gpu |
160 | 163 |
161 #endif // GPU_COMMAND_BUFFER_SERVICE_GPU_SCHEDULER_H_ | 164 #endif // GPU_COMMAND_BUFFER_SERVICE_GPU_SCHEDULER_H_ |
OLD | NEW |