OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 const gfx::Size& size, | 54 const gfx::Size& size, |
55 const gles2::DisallowedExtensions& disallowed_extensions, | 55 const gles2::DisallowedExtensions& disallowed_extensions, |
56 const char* allowed_extensions, | 56 const char* allowed_extensions, |
57 const std::vector<int32>& attribs, | 57 const std::vector<int32>& attribs, |
58 GpuScheduler* parent, | 58 GpuScheduler* parent, |
59 uint32 parent_texture_id); | 59 uint32 parent_texture_id); |
60 | 60 |
61 void Destroy(); | 61 void Destroy(); |
62 void DestroyCommon(); | 62 void DestroyCommon(); |
63 | 63 |
64 virtual void ProcessCommands(); | 64 void PutChanged(bool sync); |
65 | 65 |
66 // Sets whether commands should be processed by this scheduler. Setting to | 66 // Sets whether commands should be processed by this scheduler. Setting to |
67 // false unschedules. Setting to true reschedules. Whether or not the | 67 // false unschedules. Setting to true reschedules. Whether or not the |
68 // scheduler is currently scheduled is "reference counted". Every call with | 68 // scheduler is currently scheduled is "reference counted". Every call with |
69 // false must eventually be paired by a call with true. | 69 // false must eventually be paired by a call with true. |
70 void SetScheduled(bool is_scheduled); | 70 void SetScheduled(bool is_scheduled); |
71 | 71 |
72 // Implementation of CommandBufferEngine. | 72 // Implementation of CommandBufferEngine. |
73 virtual Buffer GetSharedMemoryBuffer(int32 shm_id); | 73 virtual Buffer GetSharedMemoryBuffer(int32 shm_id); |
74 virtual void set_token(int32 token); | 74 virtual void set_token(int32 token); |
(...skipping 26 matching lines...) Expand all Loading... |
101 // renderer and GPU processes. | 101 // renderer and GPU processes. |
102 uint64 swap_buffers_count() const; | 102 uint64 swap_buffers_count() const; |
103 void set_acknowledged_swap_buffers_count( | 103 void set_acknowledged_swap_buffers_count( |
104 uint64 acknowledged_swap_buffers_count); | 104 uint64 acknowledged_swap_buffers_count); |
105 | 105 |
106 void DidDestroySurface(); | 106 void DidDestroySurface(); |
107 #endif | 107 #endif |
108 | 108 |
109 // Sets a callback that is called when a glResizeCHROMIUM command | 109 // Sets a callback that is called when a glResizeCHROMIUM command |
110 // is processed. | 110 // is processed. |
111 virtual void SetResizeCallback(Callback1<gfx::Size>::Type* callback); | 111 void SetResizeCallback(Callback1<gfx::Size>::Type* callback); |
112 | 112 |
113 // Sets a callback which is called when a SwapBuffers command is processed. | 113 // Sets a callback which is called when a SwapBuffers command is processed. |
114 // Must be called after Initialize(). | 114 // Must be called after Initialize(). |
115 // It is not defined on which thread this callback is called. | 115 // It is not defined on which thread this callback is called. |
116 virtual void SetSwapBuffersCallback(Callback0::Type* callback); | 116 void SetSwapBuffersCallback(Callback0::Type* callback); |
117 | 117 |
118 virtual void SetCommandProcessedCallback(Callback0::Type* callback); | 118 void SetCommandProcessedCallback(Callback0::Type* callback); |
119 | 119 |
120 // Sets a callback which is called after a Set/WaitLatch command is processed. | 120 // Sets a callback which is called after a Set/WaitLatch command is processed. |
121 // The bool parameter will be true for SetLatch, and false for a WaitLatch | 121 // The bool parameter will be true for SetLatch, and false for a WaitLatch |
122 // that is blocked. An unblocked WaitLatch will not trigger a callback. | 122 // that is blocked. An unblocked WaitLatch will not trigger a callback. |
123 void SetLatchCallback(const base::Callback<void(bool)>& callback) { | 123 void SetLatchCallback(const base::Callback<void(bool)>& callback) { |
124 decoder_->SetLatchCallback(callback); | 124 decoder_->SetLatchCallback(callback); |
125 } | 125 } |
126 | 126 |
127 // Get the GLES2Decoder associated with this scheduler. | 127 // Get the GLES2Decoder associated with this scheduler. |
128 gles2::GLES2Decoder* decoder() const { return decoder_.get(); } | 128 gles2::GLES2Decoder* decoder() const { return decoder_.get(); } |
129 | 129 |
130 protected: | 130 protected: |
131 // Perform common initialization. Takes ownership of GLContext. | 131 // Perform common initialization. Takes ownership of GLContext. |
132 bool InitializeCommon( | 132 bool InitializeCommon( |
133 gfx::GLContext* context, | 133 gfx::GLContext* context, |
134 const gfx::Size& size, | 134 const gfx::Size& size, |
135 const gles2::DisallowedExtensions& disallowed_extensions, | 135 const gles2::DisallowedExtensions& disallowed_extensions, |
136 const char* allowed_extensions, | 136 const char* allowed_extensions, |
137 const std::vector<int32>& attribs, | 137 const std::vector<int32>& attribs, |
138 gles2::GLES2Decoder* parent_decoder, | 138 gles2::GLES2Decoder* parent_decoder, |
139 uint32 parent_texture_id); | 139 uint32 parent_texture_id); |
140 | 140 |
141 | 141 |
142 private: | 142 private: |
143 // Helper which causes a call to ProcessCommands to be scheduled later. | 143 // Helper which causes a call to ProcessCommands to be scheduled later. |
144 void ScheduleProcessCommands(); | 144 void ScheduleProcessCommands(); |
145 | 145 |
146 // Called via a callback just before we are supposed to call the | 146 // Called via a callback just before we are supposed to call the |
147 // user's swap buffers callback. | 147 // user's swap buffers callback. |
148 virtual void WillSwapBuffers(); | 148 void WillSwapBuffers(); |
| 149 void ProcessCommands(); |
149 | 150 |
150 // The GpuScheduler holds a weak reference to the CommandBuffer. The | 151 // The GpuScheduler holds a weak reference to the CommandBuffer. The |
151 // CommandBuffer owns the GpuScheduler and holds a strong reference to it | 152 // CommandBuffer owns the GpuScheduler and holds a strong reference to it |
152 // through the ProcessCommands callback. | 153 // through the ProcessCommands callback. |
153 CommandBuffer* command_buffer_; | 154 CommandBuffer* command_buffer_; |
154 | 155 |
155 int commands_per_update_; | 156 int commands_per_update_; |
156 | 157 |
157 scoped_ptr<gles2::GLES2Decoder> decoder_; | 158 scoped_ptr<gles2::GLES2Decoder> decoder_; |
158 scoped_ptr<CommandParser> parser_; | 159 scoped_ptr<CommandParser> parser_; |
159 | 160 |
160 // Greater than zero if this is waiting to be rescheduled before continuing. | 161 // Greater than zero if this is waiting to be rescheduled before continuing. |
161 int unscheduled_count_; | 162 int unscheduled_count_; |
162 | 163 |
163 #if defined(OS_MACOSX) | 164 #if defined(OS_MACOSX) |
164 scoped_ptr<AcceleratedSurface> surface_; | 165 scoped_ptr<AcceleratedSurface> surface_; |
165 uint64 swap_buffers_count_; | 166 uint64 swap_buffers_count_; |
166 uint64 acknowledged_swap_buffers_count_; | 167 uint64 acknowledged_swap_buffers_count_; |
167 #endif | 168 #endif |
168 | 169 |
169 ScopedRunnableMethodFactory<GpuScheduler> method_factory_; | 170 ScopedRunnableMethodFactory<GpuScheduler> method_factory_; |
170 scoped_ptr<Callback0::Type> wrapped_swap_buffers_callback_; | 171 scoped_ptr<Callback0::Type> wrapped_swap_buffers_callback_; |
171 scoped_ptr<Callback0::Type> command_processed_callback_; | 172 scoped_ptr<Callback0::Type> command_processed_callback_; |
172 }; | 173 }; |
173 | 174 |
174 } // namespace gpu | 175 } // namespace gpu |
175 | 176 |
176 #endif // GPU_COMMAND_BUFFER_SERVICE_GPU_SCHEDULER_H_ | 177 #endif // GPU_COMMAND_BUFFER_SERVICE_GPU_SCHEDULER_H_ |
OLD | NEW |