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

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

Issue 608263002: gpu: Remove in-process GPU service support for CHROMIUM_image. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: more build fixes Created 6 years, 2 months 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/callback.h" 11 #include "base/callback.h"
12 #include "base/compiler_specific.h" 12 #include "base/compiler_specific.h"
13 #include "base/containers/scoped_ptr_hash_map.h" 13 #include "base/containers/scoped_ptr_hash_map.h"
14 #include "base/memory/ref_counted.h" 14 #include "base/memory/ref_counted.h"
15 #include "base/memory/scoped_ptr.h" 15 #include "base/memory/scoped_ptr.h"
16 #include "base/memory/weak_ptr.h" 16 #include "base/memory/weak_ptr.h"
17 #include "base/synchronization/lock.h" 17 #include "base/synchronization/lock.h"
18 #include "base/synchronization/waitable_event.h" 18 #include "base/synchronization/waitable_event.h"
19 #include "gpu/command_buffer/client/gpu_control.h" 19 #include "gpu/command_buffer/client/gpu_control.h"
20 #include "gpu/command_buffer/common/command_buffer.h" 20 #include "gpu/command_buffer/common/command_buffer.h"
21 #include "gpu/gpu_export.h" 21 #include "gpu/gpu_export.h"
22 #include "ui/gfx/gpu_memory_buffer.h"
23 #include "ui/gfx/native_widget_types.h" 22 #include "ui/gfx/native_widget_types.h"
24 #include "ui/gl/gl_surface.h" 23 #include "ui/gl/gl_surface.h"
25 #include "ui/gl/gpu_preference.h" 24 #include "ui/gl/gpu_preference.h"
26 25
27 namespace base { 26 namespace base {
28 class SequenceChecker; 27 class SequenceChecker;
29 } 28 }
30 29
31 namespace gfx { 30 namespace gfx {
32 class GLContext; 31 class GLContext;
(...skipping 16 matching lines...) Expand all
49 namespace gles2 { 48 namespace gles2 {
50 class GLES2Decoder; 49 class GLES2Decoder;
51 class MailboxManager; 50 class MailboxManager;
52 class ShaderTranslatorCache; 51 class ShaderTranslatorCache;
53 } 52 }
54 53
55 class CommandBufferServiceBase; 54 class CommandBufferServiceBase;
56 class GpuScheduler; 55 class GpuScheduler;
57 class TransferBufferManagerInterface; 56 class TransferBufferManagerInterface;
58 57
59 // TODO(reveman): Remove this interface when InProcessCommandBuffer doesn't need
60 // a custom factory interface and android_webview implementation of GPU memory
61 // buffers can use the same mechanism for buffer allocation as what's used for
62 // out of process GPU service.
63 class GPU_EXPORT InProcessGpuMemoryBufferFactory {
64 public:
65 virtual scoped_ptr<gfx::GpuMemoryBuffer> AllocateGpuMemoryBuffer(
66 size_t width,
67 size_t height,
68 unsigned internalformat,
69 unsigned usage) = 0;
70 virtual scoped_refptr<gfx::GLImage> CreateImageForGpuMemoryBuffer(
71 const gfx::GpuMemoryBufferHandle& handle,
72 const gfx::Size& size,
73 unsigned internalformat) = 0;
74
75 protected:
76 virtual ~InProcessGpuMemoryBufferFactory() {}
77 };
78
79 // This class provides a thread-safe interface to the global GPU service (for 58 // This class provides a thread-safe interface to the global GPU service (for
80 // example GPU thread) when being run in single process mode. 59 // example GPU thread) when being run in single process mode.
81 // However, the behavior for accessing one context (i.e. one instance of this 60 // However, the behavior for accessing one context (i.e. one instance of this
82 // class) from different client threads is undefined. 61 // class) from different client threads is undefined.
83 class GPU_EXPORT InProcessCommandBuffer : public CommandBuffer, 62 class GPU_EXPORT InProcessCommandBuffer : public CommandBuffer,
84 public GpuControl { 63 public GpuControl {
85 public: 64 public:
86 class Service; 65 class Service;
87 explicit InProcessCommandBuffer(const scoped_refptr<Service>& service); 66 explicit InProcessCommandBuffer(const scoped_refptr<Service>& service);
88 virtual ~InProcessCommandBuffer(); 67 virtual ~InProcessCommandBuffer();
89 68
90 static void SetGpuMemoryBufferFactory(
91 InProcessGpuMemoryBufferFactory* factory);
92
93 // If |surface| is not NULL, use it directly; in this case, the command 69 // If |surface| is not NULL, use it directly; in this case, the command
94 // buffer gpu thread must be the same as the client thread. Otherwise create 70 // buffer gpu thread must be the same as the client thread. Otherwise create
95 // a new GLSurface. 71 // a new GLSurface.
96 bool Initialize(scoped_refptr<gfx::GLSurface> surface, 72 bool Initialize(scoped_refptr<gfx::GLSurface> surface,
97 bool is_offscreen, 73 bool is_offscreen,
98 gfx::AcceleratedWidget window, 74 gfx::AcceleratedWidget window,
99 const gfx::Size& size, 75 const gfx::Size& size,
100 const std::vector<int32>& attribs, 76 const std::vector<int32>& attribs,
101 gfx::GpuPreference gpu_preference, 77 gfx::GpuPreference gpu_preference,
102 const base::Closure& context_lost_callback, 78 const base::Closure& context_lost_callback,
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 bool MakeCurrent(); 175 bool MakeCurrent();
200 base::Closure WrapCallback(const base::Closure& callback); 176 base::Closure WrapCallback(const base::Closure& callback);
201 State GetStateFast(); 177 State GetStateFast();
202 void QueueTask(const base::Closure& task) { service_->ScheduleTask(task); } 178 void QueueTask(const base::Closure& task) { service_->ScheduleTask(task); }
203 void CheckSequencedThread(); 179 void CheckSequencedThread();
204 void RetireSyncPointOnGpuThread(uint32 sync_point); 180 void RetireSyncPointOnGpuThread(uint32 sync_point);
205 void SignalSyncPointOnGpuThread(uint32 sync_point, 181 void SignalSyncPointOnGpuThread(uint32 sync_point,
206 const base::Closure& callback); 182 const base::Closure& callback);
207 void SignalQueryOnGpuThread(unsigned query_id, const base::Closure& callback); 183 void SignalQueryOnGpuThread(unsigned query_id, const base::Closure& callback);
208 void DestroyTransferBufferOnGpuThread(int32 id); 184 void DestroyTransferBufferOnGpuThread(int32 id);
209 void RegisterGpuMemoryBufferOnGpuThread(
210 int32 id,
211 const gfx::GpuMemoryBufferHandle& handle,
212 size_t width,
213 size_t height,
214 unsigned internalformat);
215 void UnregisterGpuMemoryBufferOnGpuThread(int32 id);
216 185
217 // Callbacks: 186 // Callbacks:
218 void OnContextLost(); 187 void OnContextLost();
219 void OnResizeView(gfx::Size size, float scale_factor); 188 void OnResizeView(gfx::Size size, float scale_factor);
220 bool GetBufferChanged(int32 transfer_buffer_id); 189 bool GetBufferChanged(int32 transfer_buffer_id);
221 void PumpCommands(); 190 void PumpCommands();
222 void PerformIdleWork(); 191 void PerformIdleWork();
223 192
224 static scoped_refptr<Service> GetDefaultService(); 193 static scoped_refptr<Service> GetDefaultService();
225 194
226 // Members accessed on the gpu thread (possibly with the exception of 195 // Members accessed on the gpu thread (possibly with the exception of
227 // creation): 196 // creation):
228 bool context_lost_; 197 bool context_lost_;
229 scoped_ptr<TransferBufferManagerInterface> transfer_buffer_manager_; 198 scoped_ptr<TransferBufferManagerInterface> transfer_buffer_manager_;
230 scoped_ptr<GpuScheduler> gpu_scheduler_; 199 scoped_ptr<GpuScheduler> gpu_scheduler_;
231 scoped_ptr<gles2::GLES2Decoder> decoder_; 200 scoped_ptr<gles2::GLES2Decoder> decoder_;
232 scoped_refptr<gfx::GLContext> context_; 201 scoped_refptr<gfx::GLContext> context_;
233 scoped_refptr<gfx::GLSurface> surface_; 202 scoped_refptr<gfx::GLSurface> surface_;
234 base::Closure context_lost_callback_; 203 base::Closure context_lost_callback_;
235 bool idle_work_pending_; // Used to throttle PerformIdleWork. 204 bool idle_work_pending_; // Used to throttle PerformIdleWork.
236 205
237 // Members accessed on the client thread: 206 // Members accessed on the client thread:
238 State last_state_; 207 State last_state_;
239 int32 last_put_offset_; 208 int32 last_put_offset_;
240 gpu::Capabilities capabilities_; 209 gpu::Capabilities capabilities_;
241 typedef base::ScopedPtrHashMap<int32, gfx::GpuMemoryBuffer>
242 GpuMemoryBufferMap;
243 GpuMemoryBufferMap gpu_memory_buffers_;
244 210
245 // Accessed on both threads: 211 // Accessed on both threads:
246 scoped_ptr<CommandBufferServiceBase> command_buffer_; 212 scoped_ptr<CommandBufferServiceBase> command_buffer_;
247 base::Lock command_buffer_lock_; 213 base::Lock command_buffer_lock_;
248 base::WaitableEvent flush_event_; 214 base::WaitableEvent flush_event_;
249 scoped_refptr<Service> service_; 215 scoped_refptr<Service> service_;
250 State state_after_last_flush_; 216 State state_after_last_flush_;
251 base::Lock state_after_last_flush_lock_; 217 base::Lock state_after_last_flush_lock_;
252 scoped_refptr<gfx::GLShareGroup> gl_share_group_; 218 scoped_refptr<gfx::GLShareGroup> gl_share_group_;
253 219
254 #if defined(OS_ANDROID) 220 #if defined(OS_ANDROID)
255 scoped_ptr<StreamTextureManagerInProcess> stream_texture_manager_; 221 scoped_ptr<StreamTextureManagerInProcess> stream_texture_manager_;
256 #endif 222 #endif
257 223
258 // Only used with explicit scheduling and the gpu thread is the same as 224 // Only used with explicit scheduling and the gpu thread is the same as
259 // the client thread. 225 // the client thread.
260 scoped_ptr<base::SequenceChecker> sequence_checker_; 226 scoped_ptr<base::SequenceChecker> sequence_checker_;
261 227
262 base::WeakPtr<InProcessCommandBuffer> gpu_thread_weak_ptr_; 228 base::WeakPtr<InProcessCommandBuffer> gpu_thread_weak_ptr_;
263 base::WeakPtrFactory<InProcessCommandBuffer> gpu_thread_weak_ptr_factory_; 229 base::WeakPtrFactory<InProcessCommandBuffer> gpu_thread_weak_ptr_factory_;
264 230
265 DISALLOW_COPY_AND_ASSIGN(InProcessCommandBuffer); 231 DISALLOW_COPY_AND_ASSIGN(InProcessCommandBuffer);
266 }; 232 };
267 233
268 } // namespace gpu 234 } // namespace gpu
269 235
270 #endif // GPU_COMMAND_BUFFER_SERVICE_IN_PROCESS_COMMAND_BUFFER_H_ 236 #endif // GPU_COMMAND_BUFFER_SERVICE_IN_PROCESS_COMMAND_BUFFER_H_
OLDNEW
« no previous file with comments | « android_webview/native/aw_contents.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