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 <map> | 8 #include <map> |
9 #include <queue> | 9 #include <queue> |
10 #include <vector> | 10 #include <vector> |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 virtual TransportDIB::Handle SetWindowSizeForTransportDIB( | 120 virtual TransportDIB::Handle SetWindowSizeForTransportDIB( |
121 const gfx::Size& size); | 121 const gfx::Size& size); |
122 virtual void SetTransportDIBAllocAndFree( | 122 virtual void SetTransportDIBAllocAndFree( |
123 Callback2<size_t, TransportDIB::Handle*>::Type* allocator, | 123 Callback2<size_t, TransportDIB::Handle*>::Type* allocator, |
124 Callback1<TransportDIB::Id>::Type* deallocator); | 124 Callback1<TransportDIB::Id>::Type* deallocator); |
125 // Returns the id of the current surface that is being rendered to | 125 // Returns the id of the current surface that is being rendered to |
126 // (or 0 if no such surface has been created). | 126 // (or 0 if no such surface has been created). |
127 virtual uint64 GetSurfaceId(); | 127 virtual uint64 GetSurfaceId(); |
128 | 128 |
129 void DidDestroySurface(); | 129 void DidDestroySurface(); |
| 130 |
| 131 // Sets a callback which is called when a SwapBuffers command is processed. |
| 132 // Must be called after Initialize(). |
| 133 // It is not defined on which thread this callback is called. |
| 134 void SetSwapBuffersCallback(Callback0::Type* callback); |
130 #endif | 135 #endif |
131 | 136 |
132 // Sets a callback that is called when a glResizeCHROMIUM command | 137 // Sets a callback that is called when a glResizeCHROMIUM command |
133 // is processed. | 138 // is processed. |
134 void SetResizeCallback(Callback1<gfx::Size>::Type* callback); | 139 void SetResizeCallback(Callback1<gfx::Size>::Type* callback); |
135 | 140 |
136 // Sets a callback which is called when a SwapBuffers command is processed. | |
137 // Must be called after Initialize(). | |
138 // It is not defined on which thread this callback is called. | |
139 void SetSwapBuffersCallback(Callback0::Type* callback); | |
140 | |
141 void SetCommandProcessedCallback(Callback0::Type* callback); | 141 void SetCommandProcessedCallback(Callback0::Type* callback); |
142 | 142 |
143 // Get the GLES2Decoder associated with this scheduler. | 143 // Get the GLES2Decoder associated with this scheduler. |
144 gles2::GLES2Decoder* decoder() const { return decoder_.get(); } | 144 gles2::GLES2Decoder* decoder() const { return decoder_.get(); } |
145 | 145 |
146 private: | 146 private: |
147 // If a group is not passed in one will be created. | 147 // If a group is not passed in one will be created. |
148 GpuScheduler(CommandBuffer* command_buffer, | 148 GpuScheduler(CommandBuffer* command_buffer, |
149 gles2::GLES2Decoder* decoder, | 149 gles2::GLES2Decoder* decoder, |
150 CommandParser* parser); | 150 CommandParser* parser); |
151 | 151 |
| 152 #if defined(OS_MACOSX) |
152 // Called via a callback just before we are supposed to call the | 153 // Called via a callback just before we are supposed to call the |
153 // user's swap buffers callback. | 154 // user's swap buffers callback. |
154 void WillSwapBuffers(); | 155 void WillSwapBuffers(); |
| 156 #endif |
155 | 157 |
156 // The GpuScheduler holds a weak reference to the CommandBuffer. The | 158 // The GpuScheduler holds a weak reference to the CommandBuffer. The |
157 // CommandBuffer owns the GpuScheduler and holds a strong reference to it | 159 // CommandBuffer owns the GpuScheduler and holds a strong reference to it |
158 // through the ProcessCommands callback. | 160 // through the ProcessCommands callback. |
159 CommandBuffer* command_buffer_; | 161 CommandBuffer* command_buffer_; |
160 | 162 |
161 scoped_ptr<gles2::GLES2Decoder> decoder_; | 163 scoped_ptr<gles2::GLES2Decoder> decoder_; |
162 scoped_ptr<CommandParser> parser_; | 164 scoped_ptr<CommandParser> parser_; |
163 | 165 |
164 // Greater than zero if this is waiting to be rescheduled before continuing. | 166 // Greater than zero if this is waiting to be rescheduled before continuing. |
165 int unscheduled_count_; | 167 int unscheduled_count_; |
166 | 168 |
167 scoped_ptr<Callback0::Type> scheduled_callback_; | 169 scoped_ptr<Callback0::Type> scheduled_callback_; |
168 | 170 |
169 #if defined(OS_MACOSX) | 171 #if defined(OS_MACOSX) |
170 uint64 swap_buffers_count_; | 172 uint64 swap_buffers_count_; |
171 uint64 acknowledged_swap_buffers_count_; | 173 uint64 acknowledged_swap_buffers_count_; |
172 scoped_ptr<AcceleratedSurface> surface_; | 174 scoped_ptr<AcceleratedSurface> surface_; |
| 175 scoped_ptr<Callback0::Type> wrapped_swap_buffers_callback_; |
173 #endif | 176 #endif |
174 | 177 |
175 ScopedRunnableMethodFactory<GpuScheduler> method_factory_; | 178 ScopedRunnableMethodFactory<GpuScheduler> method_factory_; |
176 scoped_ptr<Callback0::Type> wrapped_swap_buffers_callback_; | |
177 scoped_ptr<Callback0::Type> command_processed_callback_; | 179 scoped_ptr<Callback0::Type> command_processed_callback_; |
178 }; | 180 }; |
179 | 181 |
180 } // namespace gpu | 182 } // namespace gpu |
181 | 183 |
182 #endif // GPU_COMMAND_BUFFER_SERVICE_GPU_SCHEDULER_H_ | 184 #endif // GPU_COMMAND_BUFFER_SERVICE_GPU_SCHEDULER_H_ |
OLD | NEW |