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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 virtual void ProcessCommands(); |
65 | 65 |
66 // Helper which causes a call to ProcessCommands to be scheduled later. | 66 // Sets whether commands should be processed by this scheduler. Setting to |
67 void ScheduleProcessCommands(); | 67 // false unschedules. Setting to true reschedules. Whether or not the |
| 68 // scheduler is currently scheduled is "reference counted". Every call with |
| 69 // false must eventually be paired by a call with true. |
| 70 void SetScheduled(bool is_scheduled); |
68 | 71 |
69 // Implementation of CommandBufferEngine. | 72 // Implementation of CommandBufferEngine. |
70 virtual Buffer GetSharedMemoryBuffer(int32 shm_id); | 73 virtual Buffer GetSharedMemoryBuffer(int32 shm_id); |
71 virtual void set_token(int32 token); | 74 virtual void set_token(int32 token); |
72 virtual bool SetGetOffset(int32 offset); | 75 virtual bool SetGetOffset(int32 offset); |
73 virtual int32 GetGetOffset(); | 76 virtual int32 GetGetOffset(); |
74 | 77 |
75 // Asynchronously resizes an offscreen frame buffer. | 78 // Asynchronously resizes an offscreen frame buffer. |
76 void ResizeOffscreenFrameBuffer(const gfx::Size& size); | 79 void ResizeOffscreenFrameBuffer(const gfx::Size& size); |
77 | 80 |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 gfx::GLContext* context, | 133 gfx::GLContext* context, |
131 const gfx::Size& size, | 134 const gfx::Size& size, |
132 const gles2::DisallowedExtensions& disallowed_extensions, | 135 const gles2::DisallowedExtensions& disallowed_extensions, |
133 const char* allowed_extensions, | 136 const char* allowed_extensions, |
134 const std::vector<int32>& attribs, | 137 const std::vector<int32>& attribs, |
135 gles2::GLES2Decoder* parent_decoder, | 138 gles2::GLES2Decoder* parent_decoder, |
136 uint32 parent_texture_id); | 139 uint32 parent_texture_id); |
137 | 140 |
138 | 141 |
139 private: | 142 private: |
| 143 // Helper which causes a call to ProcessCommands to be scheduled later. |
| 144 void ScheduleProcessCommands(); |
| 145 |
140 // 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 |
141 // user's swap buffers callback. | 147 // user's swap buffers callback. |
142 virtual void WillSwapBuffers(); | 148 virtual void WillSwapBuffers(); |
143 | 149 |
144 // The GpuScheduler holds a weak reference to the CommandBuffer. The | 150 // The GpuScheduler holds a weak reference to the CommandBuffer. The |
145 // CommandBuffer owns the GpuScheduler and holds a strong reference to it | 151 // CommandBuffer owns the GpuScheduler and holds a strong reference to it |
146 // through the ProcessCommands callback. | 152 // through the ProcessCommands callback. |
147 CommandBuffer* command_buffer_; | 153 CommandBuffer* command_buffer_; |
148 | 154 |
149 int commands_per_update_; | 155 int commands_per_update_; |
150 | 156 |
151 scoped_ptr<gles2::GLES2Decoder> decoder_; | 157 scoped_ptr<gles2::GLES2Decoder> decoder_; |
152 scoped_ptr<CommandParser> parser_; | 158 scoped_ptr<CommandParser> parser_; |
153 | 159 |
| 160 // Greater than zero if this is waiting to be rescheduled before continuing. |
| 161 int unscheduled_count_; |
| 162 |
154 #if defined(OS_MACOSX) | 163 #if defined(OS_MACOSX) |
155 scoped_ptr<AcceleratedSurface> surface_; | 164 scoped_ptr<AcceleratedSurface> surface_; |
156 uint64 swap_buffers_count_; | 165 uint64 swap_buffers_count_; |
157 uint64 acknowledged_swap_buffers_count_; | 166 uint64 acknowledged_swap_buffers_count_; |
158 #endif | 167 #endif |
159 | 168 |
160 ScopedRunnableMethodFactory<GpuScheduler> method_factory_; | 169 ScopedRunnableMethodFactory<GpuScheduler> method_factory_; |
161 scoped_ptr<Callback0::Type> wrapped_swap_buffers_callback_; | 170 scoped_ptr<Callback0::Type> wrapped_swap_buffers_callback_; |
162 scoped_ptr<Callback0::Type> command_processed_callback_; | 171 scoped_ptr<Callback0::Type> command_processed_callback_; |
163 }; | 172 }; |
164 | 173 |
165 } // namespace gpu | 174 } // namespace gpu |
166 | 175 |
167 #endif // GPU_COMMAND_BUFFER_SERVICE_GPU_SCHEDULER_H_ | 176 #endif // GPU_COMMAND_BUFFER_SERVICE_GPU_SCHEDULER_H_ |
OLD | NEW |