| 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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 // class should not know about the decoder. Do not add additional dependencies | 49 // class should not know about the decoder. Do not add additional dependencies |
| 50 // on it. | 50 // on it. |
| 51 class GPU_EXPORT GpuScheduler | 51 class GPU_EXPORT GpuScheduler |
| 52 : NON_EXPORTED_BASE(public CommandBufferEngine), | 52 : NON_EXPORTED_BASE(public CommandBufferEngine), |
| 53 public base::SupportsWeakPtr<GpuScheduler> { | 53 public base::SupportsWeakPtr<GpuScheduler> { |
| 54 public: | 54 public: |
| 55 GpuScheduler(CommandBufferServiceBase* command_buffer, | 55 GpuScheduler(CommandBufferServiceBase* command_buffer, |
| 56 AsyncAPIInterface* handler, | 56 AsyncAPIInterface* handler, |
| 57 gles2::GLES2Decoder* decoder); | 57 gles2::GLES2Decoder* decoder); |
| 58 | 58 |
| 59 virtual ~GpuScheduler(); | 59 ~GpuScheduler() override; |
| 60 | 60 |
| 61 void PutChanged(); | 61 void PutChanged(); |
| 62 | 62 |
| 63 void SetPreemptByFlag(scoped_refptr<PreemptionFlag> flag) { | 63 void SetPreemptByFlag(scoped_refptr<PreemptionFlag> flag) { |
| 64 preemption_flag_ = flag; | 64 preemption_flag_ = flag; |
| 65 } | 65 } |
| 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. |
| 77 bool HasMoreWork(); | 77 bool HasMoreWork(); |
| 78 | 78 |
| 79 typedef base::Callback<void(bool /* scheduled */)> SchedulingChangedCallback; | 79 typedef base::Callback<void(bool /* scheduled */)> SchedulingChangedCallback; |
| 80 | 80 |
| 81 // Sets a callback that is invoked just before scheduler is rescheduled | 81 // Sets a callback that is invoked just before scheduler is rescheduled |
| 82 // or descheduled. Takes ownership of callback object. | 82 // or descheduled. Takes ownership of callback object. |
| 83 void SetSchedulingChangedCallback(const SchedulingChangedCallback& callback); | 83 void SetSchedulingChangedCallback(const SchedulingChangedCallback& callback); |
| 84 | 84 |
| 85 // Implementation of CommandBufferEngine. | 85 // Implementation of CommandBufferEngine. |
| 86 virtual scoped_refptr<Buffer> GetSharedMemoryBuffer(int32 shm_id) override; | 86 scoped_refptr<Buffer> GetSharedMemoryBuffer(int32 shm_id) override; |
| 87 virtual void set_token(int32 token) override; | 87 void set_token(int32 token) override; |
| 88 virtual bool SetGetBuffer(int32 transfer_buffer_id) override; | 88 bool SetGetBuffer(int32 transfer_buffer_id) override; |
| 89 virtual bool SetGetOffset(int32 offset) override; | 89 bool SetGetOffset(int32 offset) override; |
| 90 virtual int32 GetGetOffset() override; | 90 int32 GetGetOffset() override; |
| 91 | 91 |
| 92 void SetCommandProcessedCallback(const base::Closure& callback); | 92 void SetCommandProcessedCallback(const base::Closure& callback); |
| 93 | 93 |
| 94 void DeferToFence(base::Closure task); | 94 void DeferToFence(base::Closure task); |
| 95 | 95 |
| 96 // Polls the fences, invoking callbacks that were waiting to be triggered | 96 // Polls the fences, invoking callbacks that were waiting to be triggered |
| 97 // by them and returns whether all fences were complete. | 97 // by them and returns whether all fences were complete. |
| 98 bool PollUnscheduleFences(); | 98 bool PollUnscheduleFences(); |
| 99 | 99 |
| 100 bool HasMoreIdleWork(); | 100 bool HasMoreIdleWork(); |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 159 // A factory for outstanding rescheduling tasks that is invalidated whenever | 159 // A factory for outstanding rescheduling tasks that is invalidated whenever |
| 160 // the scheduler is rescheduled. | 160 // the scheduler is rescheduled. |
| 161 base::WeakPtrFactory<GpuScheduler> reschedule_task_factory_; | 161 base::WeakPtrFactory<GpuScheduler> reschedule_task_factory_; |
| 162 | 162 |
| 163 DISALLOW_COPY_AND_ASSIGN(GpuScheduler); | 163 DISALLOW_COPY_AND_ASSIGN(GpuScheduler); |
| 164 }; | 164 }; |
| 165 | 165 |
| 166 } // namespace gpu | 166 } // namespace gpu |
| 167 | 167 |
| 168 #endif // GPU_COMMAND_BUFFER_SERVICE_GPU_SCHEDULER_H_ | 168 #endif // GPU_COMMAND_BUFFER_SERVICE_GPU_SCHEDULER_H_ |
| OLD | NEW |