Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(58)

Side by Side Diff: gpu/command_buffer/service/in_process_command_buffer.h

Issue 683113005: Update from chromium https://crrev.com/302282 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 <map> 8 #include <map>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/atomic_sequence_num.h"
11 #include "base/callback.h" 12 #include "base/callback.h"
12 #include "base/compiler_specific.h" 13 #include "base/compiler_specific.h"
13 #include "base/containers/scoped_ptr_hash_map.h" 14 #include "base/containers/scoped_ptr_hash_map.h"
14 #include "base/memory/ref_counted.h" 15 #include "base/memory/ref_counted.h"
15 #include "base/memory/scoped_ptr.h" 16 #include "base/memory/scoped_ptr.h"
16 #include "base/memory/weak_ptr.h" 17 #include "base/memory/weak_ptr.h"
17 #include "base/synchronization/lock.h" 18 #include "base/synchronization/lock.h"
18 #include "base/synchronization/waitable_event.h" 19 #include "base/synchronization/waitable_event.h"
19 #include "gpu/command_buffer/client/gpu_control.h" 20 #include "gpu/command_buffer/client/gpu_control.h"
20 #include "gpu/command_buffer/common/command_buffer.h" 21 #include "gpu/command_buffer/common/command_buffer.h"
21 #include "gpu/gpu_export.h" 22 #include "gpu/gpu_export.h"
23 #include "ui/gfx/gpu_memory_buffer.h"
22 #include "ui/gfx/native_widget_types.h" 24 #include "ui/gfx/native_widget_types.h"
23 #include "ui/gl/gl_surface.h" 25 #include "ui/gl/gl_surface.h"
24 #include "ui/gl/gpu_preference.h" 26 #include "ui/gl/gpu_preference.h"
25 27
26 namespace base { 28 namespace base {
27 class SequenceChecker; 29 class SequenceChecker;
28 } 30 }
29 31
30 namespace gfx { 32 namespace gfx {
31 class GLContext; 33 class GLContext;
(...skipping 13 matching lines...) Expand all
45 47
46 namespace gpu { 48 namespace gpu {
47 49
48 namespace gles2 { 50 namespace gles2 {
49 class GLES2Decoder; 51 class GLES2Decoder;
50 class MailboxManager; 52 class MailboxManager;
51 class ShaderTranslatorCache; 53 class ShaderTranslatorCache;
52 } 54 }
53 55
54 class CommandBufferServiceBase; 56 class CommandBufferServiceBase;
57 class GpuMemoryBufferManager;
55 class GpuScheduler; 58 class GpuScheduler;
59 class ImageFactory;
56 class TransferBufferManagerInterface; 60 class TransferBufferManagerInterface;
57 61
58 // This class provides a thread-safe interface to the global GPU service (for 62 // This class provides a thread-safe interface to the global GPU service (for
59 // example GPU thread) when being run in single process mode. 63 // example GPU thread) when being run in single process mode.
60 // However, the behavior for accessing one context (i.e. one instance of this 64 // However, the behavior for accessing one context (i.e. one instance of this
61 // class) from different client threads is undefined. 65 // class) from different client threads is undefined.
62 class GPU_EXPORT InProcessCommandBuffer : public CommandBuffer, 66 class GPU_EXPORT InProcessCommandBuffer : public CommandBuffer,
63 public GpuControl { 67 public GpuControl {
64 public: 68 public:
65 class Service; 69 class Service;
66 explicit InProcessCommandBuffer(const scoped_refptr<Service>& service); 70 explicit InProcessCommandBuffer(const scoped_refptr<Service>& service);
67 ~InProcessCommandBuffer() override; 71 ~InProcessCommandBuffer() override;
68 72
69 // If |surface| is not NULL, use it directly; in this case, the command 73 // If |surface| is not NULL, use it directly; in this case, the command
70 // buffer gpu thread must be the same as the client thread. Otherwise create 74 // buffer gpu thread must be the same as the client thread. Otherwise create
71 // a new GLSurface. 75 // a new GLSurface.
72 bool Initialize(scoped_refptr<gfx::GLSurface> surface, 76 bool Initialize(scoped_refptr<gfx::GLSurface> surface,
73 bool is_offscreen, 77 bool is_offscreen,
74 gfx::AcceleratedWidget window, 78 gfx::AcceleratedWidget window,
75 const gfx::Size& size, 79 const gfx::Size& size,
76 const std::vector<int32>& attribs, 80 const std::vector<int32>& attribs,
77 gfx::GpuPreference gpu_preference, 81 gfx::GpuPreference gpu_preference,
78 const base::Closure& context_lost_callback, 82 const base::Closure& context_lost_callback,
79 InProcessCommandBuffer* share_group); 83 InProcessCommandBuffer* share_group,
84 GpuMemoryBufferManager* gpu_memory_buffer_manager,
85 ImageFactory* image_factory);
80 void Destroy(); 86 void Destroy();
81 87
82 // CommandBuffer implementation: 88 // CommandBuffer implementation:
83 bool Initialize() override; 89 bool Initialize() override;
84 State GetLastState() override; 90 State GetLastState() override;
85 int32 GetLastToken() override; 91 int32 GetLastToken() override;
86 void Flush(int32 put_offset) override; 92 void Flush(int32 put_offset) override;
87 void WaitForTokenInRange(int32 start, int32 end) override; 93 void WaitForTokenInRange(int32 start, int32 end) override;
88 void WaitForGetOffsetInRange(int32 start, int32 end) override; 94 void WaitForGetOffsetInRange(int32 start, int32 end) override;
89 void SetGetBuffer(int32 shm_id) override; 95 void SetGetBuffer(int32 shm_id) override;
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 150
145 private: 151 private:
146 struct InitializeOnGpuThreadParams { 152 struct InitializeOnGpuThreadParams {
147 bool is_offscreen; 153 bool is_offscreen;
148 gfx::AcceleratedWidget window; 154 gfx::AcceleratedWidget window;
149 const gfx::Size& size; 155 const gfx::Size& size;
150 const std::vector<int32>& attribs; 156 const std::vector<int32>& attribs;
151 gfx::GpuPreference gpu_preference; 157 gfx::GpuPreference gpu_preference;
152 gpu::Capabilities* capabilities; // Ouptut. 158 gpu::Capabilities* capabilities; // Ouptut.
153 InProcessCommandBuffer* context_group; 159 InProcessCommandBuffer* context_group;
160 ImageFactory* image_factory;
154 161
155 InitializeOnGpuThreadParams(bool is_offscreen, 162 InitializeOnGpuThreadParams(bool is_offscreen,
156 gfx::AcceleratedWidget window, 163 gfx::AcceleratedWidget window,
157 const gfx::Size& size, 164 const gfx::Size& size,
158 const std::vector<int32>& attribs, 165 const std::vector<int32>& attribs,
159 gfx::GpuPreference gpu_preference, 166 gfx::GpuPreference gpu_preference,
160 gpu::Capabilities* capabilities, 167 gpu::Capabilities* capabilities,
161 InProcessCommandBuffer* share_group) 168 InProcessCommandBuffer* share_group,
169 ImageFactory* image_factory)
162 : is_offscreen(is_offscreen), 170 : is_offscreen(is_offscreen),
163 window(window), 171 window(window),
164 size(size), 172 size(size),
165 attribs(attribs), 173 attribs(attribs),
166 gpu_preference(gpu_preference), 174 gpu_preference(gpu_preference),
167 capabilities(capabilities), 175 capabilities(capabilities),
168 context_group(share_group) {} 176 context_group(share_group),
177 image_factory(image_factory) {}
169 }; 178 };
170 179
171 bool InitializeOnGpuThread(const InitializeOnGpuThreadParams& params); 180 bool InitializeOnGpuThread(const InitializeOnGpuThreadParams& params);
172 bool DestroyOnGpuThread(); 181 bool DestroyOnGpuThread();
173 void FlushOnGpuThread(int32 put_offset); 182 void FlushOnGpuThread(int32 put_offset);
174 void ScheduleIdleWorkOnGpuThread(); 183 void ScheduleIdleWorkOnGpuThread();
175 uint32 CreateStreamTextureOnGpuThread(uint32 client_texture_id); 184 uint32 CreateStreamTextureOnGpuThread(uint32 client_texture_id);
176 bool MakeCurrent(); 185 bool MakeCurrent();
177 base::Closure WrapCallback(const base::Closure& callback); 186 base::Closure WrapCallback(const base::Closure& callback);
178 State GetStateFast(); 187 State GetStateFast();
179 void QueueTask(const base::Closure& task) { service_->ScheduleTask(task); } 188 void QueueTask(const base::Closure& task) { service_->ScheduleTask(task); }
180 void CheckSequencedThread(); 189 void CheckSequencedThread();
181 void RetireSyncPointOnGpuThread(uint32 sync_point); 190 void RetireSyncPointOnGpuThread(uint32 sync_point);
182 void SignalSyncPointOnGpuThread(uint32 sync_point, 191 void SignalSyncPointOnGpuThread(uint32 sync_point,
183 const base::Closure& callback); 192 const base::Closure& callback);
184 bool WaitSyncPointOnGpuThread(uint32 sync_point); 193 bool WaitSyncPointOnGpuThread(uint32 sync_point);
185 void SignalQueryOnGpuThread(unsigned query_id, const base::Closure& callback); 194 void SignalQueryOnGpuThread(unsigned query_id, const base::Closure& callback);
186 void DestroyTransferBufferOnGpuThread(int32 id); 195 void DestroyTransferBufferOnGpuThread(int32 id);
196 void CreateImageOnGpuThread(int32 id,
197 const gfx::GpuMemoryBufferHandle& handle,
198 const gfx::Size& size,
199 gfx::GpuMemoryBuffer::Format format,
200 uint32 internalformat);
201 void DestroyImageOnGpuThread(int32 id);
187 202
188 // Callbacks: 203 // Callbacks:
189 void OnContextLost(); 204 void OnContextLost();
190 void OnResizeView(gfx::Size size, float scale_factor); 205 void OnResizeView(gfx::Size size, float scale_factor);
191 bool GetBufferChanged(int32 transfer_buffer_id); 206 bool GetBufferChanged(int32 transfer_buffer_id);
192 void PumpCommands(); 207 void PumpCommands();
193 void PerformIdleWork(); 208 void PerformIdleWork();
194 209
195 static scoped_refptr<Service> GetDefaultService(); 210 static scoped_refptr<Service> GetDefaultService();
196 211
197 // Members accessed on the gpu thread (possibly with the exception of 212 // Members accessed on the gpu thread (possibly with the exception of
198 // creation): 213 // creation):
199 bool context_lost_; 214 bool context_lost_;
200 scoped_ptr<TransferBufferManagerInterface> transfer_buffer_manager_; 215 scoped_ptr<TransferBufferManagerInterface> transfer_buffer_manager_;
201 scoped_ptr<GpuScheduler> gpu_scheduler_; 216 scoped_ptr<GpuScheduler> gpu_scheduler_;
202 scoped_ptr<gles2::GLES2Decoder> decoder_; 217 scoped_ptr<gles2::GLES2Decoder> decoder_;
203 scoped_refptr<gfx::GLContext> context_; 218 scoped_refptr<gfx::GLContext> context_;
204 scoped_refptr<gfx::GLSurface> surface_; 219 scoped_refptr<gfx::GLSurface> surface_;
205 base::Closure context_lost_callback_; 220 base::Closure context_lost_callback_;
206 bool idle_work_pending_; // Used to throttle PerformIdleWork. 221 bool idle_work_pending_; // Used to throttle PerformIdleWork.
222 ImageFactory* image_factory_;
207 223
208 // Members accessed on the client thread: 224 // Members accessed on the client thread:
209 State last_state_; 225 State last_state_;
210 int32 last_put_offset_; 226 int32 last_put_offset_;
211 gpu::Capabilities capabilities_; 227 gpu::Capabilities capabilities_;
228 GpuMemoryBufferManager* gpu_memory_buffer_manager_;
229 base::AtomicSequenceNumber next_image_id_;
212 230
213 // Accessed on both threads: 231 // Accessed on both threads:
214 scoped_ptr<CommandBufferServiceBase> command_buffer_; 232 scoped_ptr<CommandBufferServiceBase> command_buffer_;
215 base::Lock command_buffer_lock_; 233 base::Lock command_buffer_lock_;
216 base::WaitableEvent flush_event_; 234 base::WaitableEvent flush_event_;
217 scoped_refptr<Service> service_; 235 scoped_refptr<Service> service_;
218 State state_after_last_flush_; 236 State state_after_last_flush_;
219 base::Lock state_after_last_flush_lock_; 237 base::Lock state_after_last_flush_lock_;
220 scoped_refptr<gfx::GLShareGroup> gl_share_group_; 238 scoped_refptr<gfx::GLShareGroup> gl_share_group_;
221 239
222 #if defined(OS_ANDROID) 240 #if defined(OS_ANDROID)
223 scoped_ptr<StreamTextureManagerInProcess> stream_texture_manager_; 241 scoped_ptr<StreamTextureManagerInProcess> stream_texture_manager_;
224 #endif 242 #endif
225 243
226 // Only used with explicit scheduling and the gpu thread is the same as 244 // Only used with explicit scheduling and the gpu thread is the same as
227 // the client thread. 245 // the client thread.
228 scoped_ptr<base::SequenceChecker> sequence_checker_; 246 scoped_ptr<base::SequenceChecker> sequence_checker_;
229 247
230 base::WeakPtr<InProcessCommandBuffer> gpu_thread_weak_ptr_; 248 base::WeakPtr<InProcessCommandBuffer> gpu_thread_weak_ptr_;
231 base::WeakPtrFactory<InProcessCommandBuffer> gpu_thread_weak_ptr_factory_; 249 base::WeakPtrFactory<InProcessCommandBuffer> gpu_thread_weak_ptr_factory_;
232 250
233 DISALLOW_COPY_AND_ASSIGN(InProcessCommandBuffer); 251 DISALLOW_COPY_AND_ASSIGN(InProcessCommandBuffer);
234 }; 252 };
235 253
236 } // namespace gpu 254 } // namespace gpu
237 255
238 #endif // GPU_COMMAND_BUFFER_SERVICE_IN_PROCESS_COMMAND_BUFFER_H_ 256 #endif // GPU_COMMAND_BUFFER_SERVICE_IN_PROCESS_COMMAND_BUFFER_H_
OLDNEW
« no previous file with comments | « gpu/command_buffer/service/image_factory.cc ('k') | gpu/command_buffer/service/in_process_command_buffer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698