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

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

Issue 19522006: GLInProcessContext: support async flushes and dedicated GPU thread (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 5 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 | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef GPU_COMMAND_BUFFER_SERVICE_IN_PROCESS_COMMAND_BUFFER_H_
6 #define GPU_COMMAND_BUFFER_SERVICE_IN_PROCESS_COMMAND_BUFFER_H_
7
8 #include "base/callback.h"
9 #include "base/compiler_specific.h"
10 #include "base/synchronization/lock.h"
11 #include "gpu/command_buffer/common/command_buffer.h"
12 #include "gpu/gpu_export.h"
13 #include "ui/gfx/native_widget_types.h"
14 #include "ui/gl/gpu_preference.h"
15
16 namespace gfx {
17 class GLContext;
18 class GLImage;
19 class GLSurface;
20 class Size;
21 }
22
23 namespace gpu {
24
25 namespace gles2 {
26 class GLES2Decoder;
27 }
28
29 class GpuScheduler;
30 class TransferBufferManagerInterface;
31
32 // This class provides a thread-safe interface to the global GPU service (for
33 // example GPU thread) when being run in single process mode.
34 // However, the behavior for accessing one context (i.e. one instance of this
35 // class) from different client threads is undefined.
36 class GPU_EXPORT InProcessCommandBuffer : public CommandBuffer {
37 public:
38 InProcessCommandBuffer();
39 virtual ~InProcessCommandBuffer();
40
41 // Used to override the GPU thread with explicit scheduling.
42 // (By default an internal GPU thread will be spawned to handle all GL work
43 // and the two functions are unused.)
44 // The callback will be called from different client threads. After the
45 // callback is issued, the client is expected to eventually call
46 // ProcessGpuWorkOnCurrentThread(). The latter cannot be called from different
47 // threads.
48 static void SetScheduleCallback(const base::Closure& callback);
49 static void ProcessGpuWorkOnCurrentThread();
50
51 static void EnableVirtualizedContext();
52
53 bool Initialize(bool is_offscreen,
54 bool share_resources,
55 gfx::AcceleratedWidget window,
56 const gfx::Size& size,
57 const char* allowed_extensions,
58 const std::vector<int32>& attribs,
59 gfx::GpuPreference gpu_preference,
60 const base::Closure& context_lost_callback);
61 void Destroy();
62 void SignalSyncPoint(unsigned sync_point,
63 const base::Closure& callback);
64 unsigned int AddImage(scoped_refptr<gfx::GLImage> image);
65 void RemoveImage(unsigned int image_id);
66
67 // CommandBuffer implementation:
68 virtual bool Initialize() OVERRIDE;
69 virtual State GetState() OVERRIDE;
70 virtual State GetLastState() OVERRIDE;
71 virtual int32 GetLastToken() OVERRIDE;
72 virtual void Flush(int32 put_offset) OVERRIDE;
73 virtual State FlushSync(int32 put_offset, int32 last_known_get) OVERRIDE;
74 virtual void SetGetBuffer(int32 shm_id) OVERRIDE;
75 virtual void SetGetOffset(int32 get_offset) OVERRIDE;
76 virtual gpu::Buffer CreateTransferBuffer(size_t size, int32* id) OVERRIDE;
77 virtual void DestroyTransferBuffer(int32 id) OVERRIDE;
78 virtual gpu::Buffer GetTransferBuffer(int32 id) OVERRIDE;
79 virtual void SetToken(int32 token) OVERRIDE;
80 virtual void SetParseError(gpu::error::Error error) OVERRIDE;
81 virtual void SetContextLostReason(
82 gpu::error::ContextLostReason reason) OVERRIDE;
83 virtual uint32 InsertSyncPoint() OVERRIDE;
84 virtual gpu::error::Error GetLastError() OVERRIDE;
85
86 private:
87 bool InitializeOnGpuThread(bool is_offscreen,
88 gfx::AcceleratedWidget window,
89 const gfx::Size& size,
90 const char* allowed_extensions,
91 const std::vector<int32>& attribs,
92 gfx::GpuPreference gpu_preference);
93 bool DestroyOnGpuThread();
94 bool MakeCurrent();
95 bool IsContextLost();
96 base::Closure WrapCallback(const base::Closure& callback);
97 State GetStateFast();
98
99 // Callbacks:
100 void OnContextLost();
101 void OnResizeView(gfx::Size size, float scale_factor);
102 bool GetBufferChanged(int32 transfer_buffer_id);
103 void PumpCommands();
104
105 bool context_lost_;
106 bool share_resources_;
107 scoped_ptr<TransferBufferManagerInterface> transfer_buffer_manager_;
108 scoped_ptr<CommandBuffer> command_buffer_;
109 scoped_ptr<GpuScheduler> gpu_scheduler_;
110 scoped_ptr<gles2::GLES2Decoder> decoder_;
111 scoped_refptr<gfx::GLContext> context_;
112 scoped_refptr<gfx::GLSurface> surface_;
113 base::Closure context_lost_callback_;
114 State last_state_;
115 int32 last_put_offset_;
116 base::Lock service_lock_;
piman 2013/07/23 01:57:14 Can you document what exactly this lock protects?
no sievers 2013/07/25 00:41:23 Done.
117
118 DISALLOW_COPY_AND_ASSIGN(InProcessCommandBuffer);
119 };
120
121 } // namespace gpu
122
123 #endif // GPU_COMMAND_BUFFER_SERVICE_IN_PROCESS_COMMAND_BUFFER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698