OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_IN_PROCESS_COMMAND_BUFFER_H_ | 5 #ifndef GPU_COMMAND_BUFFER_SERVICE_IN_PROCESS_COMMAND_BUFFER_H_ |
6 #define GPU_COMMAND_BUFFER_SERVICE_IN_PROCESS_COMMAND_BUFFER_H_ | 6 #define GPU_COMMAND_BUFFER_SERVICE_IN_PROCESS_COMMAND_BUFFER_H_ |
7 | 7 |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
(...skipping 10 matching lines...) Expand all Loading... |
21 #include "ui/gfx/native_widget_types.h" | 21 #include "ui/gfx/native_widget_types.h" |
22 #include "ui/gl/gl_surface.h" | 22 #include "ui/gl/gl_surface.h" |
23 #include "ui/gl/gpu_preference.h" | 23 #include "ui/gl/gpu_preference.h" |
24 | 24 |
25 namespace base { | 25 namespace base { |
26 class SequenceChecker; | 26 class SequenceChecker; |
27 } | 27 } |
28 | 28 |
29 namespace gfx { | 29 namespace gfx { |
30 class GLContext; | 30 class GLContext; |
| 31 class GLShareGroup; |
31 class GLSurface; | 32 class GLSurface; |
32 class Size; | 33 class Size; |
33 } | 34 } |
34 | 35 |
35 #if defined(OS_ANDROID) | 36 #if defined(OS_ANDROID) |
36 namespace gfx { | 37 namespace gfx { |
37 class SurfaceTexture; | 38 class SurfaceTexture; |
38 } | 39 } |
39 namespace gpu { | 40 namespace gpu { |
40 class StreamTextureManagerInProcess; | 41 class StreamTextureManagerInProcess; |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 static void ProcessGpuWorkOnCurrentThread(); | 74 static void ProcessGpuWorkOnCurrentThread(); |
74 | 75 |
75 static void EnableVirtualizedContext(); | 76 static void EnableVirtualizedContext(); |
76 static void SetGpuMemoryBufferFactory(GpuMemoryBufferFactory* factory); | 77 static void SetGpuMemoryBufferFactory(GpuMemoryBufferFactory* factory); |
77 | 78 |
78 // If |surface| is not NULL, use it directly; in this case, the command | 79 // If |surface| is not NULL, use it directly; in this case, the command |
79 // buffer gpu thread must be the same as the client thread. Otherwise create | 80 // buffer gpu thread must be the same as the client thread. Otherwise create |
80 // a new GLSurface. | 81 // a new GLSurface. |
81 bool Initialize(scoped_refptr<gfx::GLSurface> surface, | 82 bool Initialize(scoped_refptr<gfx::GLSurface> surface, |
82 bool is_offscreen, | 83 bool is_offscreen, |
83 bool share_resources, | |
84 gfx::AcceleratedWidget window, | 84 gfx::AcceleratedWidget window, |
85 const gfx::Size& size, | 85 const gfx::Size& size, |
86 const std::vector<int32>& attribs, | 86 const std::vector<int32>& attribs, |
87 gfx::GpuPreference gpu_preference, | 87 gfx::GpuPreference gpu_preference, |
88 const base::Closure& context_lost_callback, | 88 const base::Closure& context_lost_callback, |
89 unsigned int share_group_id); | 89 InProcessCommandBuffer* share_group); |
90 void Destroy(); | 90 void Destroy(); |
91 | 91 |
92 // CommandBuffer implementation: | 92 // CommandBuffer implementation: |
93 virtual bool Initialize() OVERRIDE; | 93 virtual bool Initialize() OVERRIDE; |
94 virtual State GetState() OVERRIDE; | 94 virtual State GetState() OVERRIDE; |
95 virtual State GetLastState() OVERRIDE; | 95 virtual State GetLastState() OVERRIDE; |
96 virtual int32 GetLastToken() OVERRIDE; | 96 virtual int32 GetLastToken() OVERRIDE; |
97 virtual void Flush(int32 put_offset) OVERRIDE; | 97 virtual void Flush(int32 put_offset) OVERRIDE; |
98 virtual State FlushSync(int32 put_offset, int32 last_known_get) OVERRIDE; | 98 virtual State FlushSync(int32 put_offset, int32 last_known_get) OVERRIDE; |
99 virtual void SetGetBuffer(int32 shm_id) OVERRIDE; | 99 virtual void SetGetBuffer(int32 shm_id) OVERRIDE; |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 #endif | 147 #endif |
148 | 148 |
149 private: | 149 private: |
150 struct InitializeOnGpuThreadParams { | 150 struct InitializeOnGpuThreadParams { |
151 bool is_offscreen; | 151 bool is_offscreen; |
152 gfx::AcceleratedWidget window; | 152 gfx::AcceleratedWidget window; |
153 const gfx::Size& size; | 153 const gfx::Size& size; |
154 const std::vector<int32>& attribs; | 154 const std::vector<int32>& attribs; |
155 gfx::GpuPreference gpu_preference; | 155 gfx::GpuPreference gpu_preference; |
156 gpu::Capabilities* capabilities; // Ouptut. | 156 gpu::Capabilities* capabilities; // Ouptut. |
| 157 InProcessCommandBuffer* context_group; |
157 | 158 |
158 InitializeOnGpuThreadParams(bool is_offscreen, | 159 InitializeOnGpuThreadParams(bool is_offscreen, |
159 gfx::AcceleratedWidget window, | 160 gfx::AcceleratedWidget window, |
160 const gfx::Size& size, | 161 const gfx::Size& size, |
161 const std::vector<int32>& attribs, | 162 const std::vector<int32>& attribs, |
162 gfx::GpuPreference gpu_preference, | 163 gfx::GpuPreference gpu_preference, |
163 gpu::Capabilities* capabilities) | 164 gpu::Capabilities* capabilities, |
| 165 InProcessCommandBuffer* share_group) |
164 : is_offscreen(is_offscreen), | 166 : is_offscreen(is_offscreen), |
165 window(window), | 167 window(window), |
166 size(size), | 168 size(size), |
167 attribs(attribs), | 169 attribs(attribs), |
168 gpu_preference(gpu_preference), | 170 gpu_preference(gpu_preference), |
169 capabilities(capabilities) {} | 171 capabilities(capabilities), |
| 172 context_group(share_group) {} |
170 }; | 173 }; |
171 | 174 |
172 bool InitializeOnGpuThread(const InitializeOnGpuThreadParams& params); | 175 bool InitializeOnGpuThread(const InitializeOnGpuThreadParams& params); |
173 bool DestroyOnGpuThread(); | 176 bool DestroyOnGpuThread(); |
174 void FlushOnGpuThread(int32 put_offset); | 177 void FlushOnGpuThread(int32 put_offset); |
175 uint32 CreateStreamTextureOnGpuThread(uint32 client_texture_id); | 178 uint32 CreateStreamTextureOnGpuThread(uint32 client_texture_id); |
176 bool MakeCurrent(); | 179 bool MakeCurrent(); |
177 bool IsContextLost(); | |
178 base::Closure WrapCallback(const base::Closure& callback); | 180 base::Closure WrapCallback(const base::Closure& callback); |
179 State GetStateFast(); | 181 State GetStateFast(); |
180 void QueueTask(const base::Closure& task) { queue_->QueueTask(task); } | 182 void QueueTask(const base::Closure& task) { queue_->QueueTask(task); } |
181 void CheckSequencedThread(); | 183 void CheckSequencedThread(); |
182 | 184 |
183 // Callbacks: | 185 // Callbacks: |
184 void OnContextLost(); | 186 void OnContextLost(); |
185 void OnResizeView(gfx::Size size, float scale_factor); | 187 void OnResizeView(gfx::Size size, float scale_factor); |
186 bool GetBufferChanged(int32 transfer_buffer_id); | 188 bool GetBufferChanged(int32 transfer_buffer_id); |
187 void PumpCommands(); | 189 void PumpCommands(); |
188 void ScheduleMoreIdleWork(); | 190 void ScheduleMoreIdleWork(); |
189 | 191 |
190 // Members accessed on the gpu thread (possibly with the exception of | 192 // Members accessed on the gpu thread (possibly with the exception of |
191 // creation): | 193 // creation): |
192 bool context_lost_; | 194 bool context_lost_; |
193 bool share_resources_; | |
194 scoped_ptr<TransferBufferManagerInterface> transfer_buffer_manager_; | 195 scoped_ptr<TransferBufferManagerInterface> transfer_buffer_manager_; |
195 scoped_ptr<GpuScheduler> gpu_scheduler_; | 196 scoped_ptr<GpuScheduler> gpu_scheduler_; |
196 scoped_ptr<gles2::GLES2Decoder> decoder_; | 197 scoped_ptr<gles2::GLES2Decoder> decoder_; |
197 scoped_refptr<gfx::GLContext> context_; | 198 scoped_refptr<gfx::GLContext> context_; |
198 scoped_refptr<gfx::GLSurface> surface_; | 199 scoped_refptr<gfx::GLSurface> surface_; |
199 base::Closure context_lost_callback_; | 200 base::Closure context_lost_callback_; |
200 unsigned int share_group_id_; | |
201 | 201 |
202 // Members accessed on the client thread: | 202 // Members accessed on the client thread: |
203 State last_state_; | 203 State last_state_; |
204 int32 last_put_offset_; | 204 int32 last_put_offset_; |
205 gpu::Capabilities capabilities_; | 205 gpu::Capabilities capabilities_; |
206 | 206 |
207 // Accessed on both threads: | 207 // Accessed on both threads: |
208 scoped_ptr<CommandBuffer> command_buffer_; | 208 scoped_ptr<CommandBuffer> command_buffer_; |
209 base::Lock command_buffer_lock_; | 209 base::Lock command_buffer_lock_; |
210 base::WaitableEvent flush_event_; | 210 base::WaitableEvent flush_event_; |
211 scoped_ptr<SchedulerClient> queue_; | 211 scoped_ptr<SchedulerClient> queue_; |
212 State state_after_last_flush_; | 212 State state_after_last_flush_; |
213 base::Lock state_after_last_flush_lock_; | 213 base::Lock state_after_last_flush_lock_; |
214 scoped_ptr<GpuControl> gpu_control_; | 214 scoped_ptr<GpuControl> gpu_control_; |
| 215 scoped_refptr<gfx::GLShareGroup> gl_share_group_; |
215 | 216 |
216 #if defined(OS_ANDROID) | 217 #if defined(OS_ANDROID) |
217 scoped_ptr<StreamTextureManagerInProcess> stream_texture_manager_; | 218 scoped_ptr<StreamTextureManagerInProcess> stream_texture_manager_; |
218 #endif | 219 #endif |
219 | 220 |
220 // Only used with explicit scheduling and the gpu thread is the same as | 221 // Only used with explicit scheduling and the gpu thread is the same as |
221 // the client thread. | 222 // the client thread. |
222 scoped_ptr<base::SequenceChecker> sequence_checker_; | 223 scoped_ptr<base::SequenceChecker> sequence_checker_; |
223 | 224 |
224 base::WeakPtr<InProcessCommandBuffer> gpu_thread_weak_ptr_; | 225 base::WeakPtr<InProcessCommandBuffer> gpu_thread_weak_ptr_; |
225 base::WeakPtrFactory<InProcessCommandBuffer> gpu_thread_weak_ptr_factory_; | 226 base::WeakPtrFactory<InProcessCommandBuffer> gpu_thread_weak_ptr_factory_; |
226 | 227 |
227 DISALLOW_COPY_AND_ASSIGN(InProcessCommandBuffer); | 228 DISALLOW_COPY_AND_ASSIGN(InProcessCommandBuffer); |
228 }; | 229 }; |
229 | 230 |
230 } // namespace gpu | 231 } // namespace gpu |
231 | 232 |
232 #endif // GPU_COMMAND_BUFFER_SERVICE_IN_PROCESS_COMMAND_BUFFER_H_ | 233 #endif // GPU_COMMAND_BUFFER_SERVICE_IN_PROCESS_COMMAND_BUFFER_H_ |
OLD | NEW |