OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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_TESTS_GL_MANAGER_H_ | 5 #ifndef GPU_COMMAND_BUFFER_TESTS_GL_MANAGER_H_ |
6 #define GPU_COMMAND_BUFFER_TESTS_GL_MANAGER_H_ | 6 #define GPU_COMMAND_BUFFER_TESTS_GL_MANAGER_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 | 10 |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 class GLES2CmdHelper; | 47 class GLES2CmdHelper; |
48 class GLES2Implementation; | 48 class GLES2Implementation; |
49 | 49 |
50 }; | 50 }; |
51 | 51 |
52 class GLManager : private GpuControl { | 52 class GLManager : private GpuControl { |
53 public: | 53 public: |
54 struct Options { | 54 struct Options { |
55 Options(); | 55 Options(); |
56 // The size of the backbuffer. | 56 // The size of the backbuffer. |
57 gfx::Size size; | 57 gfx::Size size = gfx::Size(4, 4); |
58 // If not null will have a corresponding sync point manager. | 58 // If not null will have a corresponding sync point manager. |
59 SyncPointManager* sync_point_manager; | 59 SyncPointManager* sync_point_manager = nullptr; |
60 // If not null will share resources with this context. | 60 // If not null will share resources with this context. |
61 GLManager* share_group_manager; | 61 GLManager* share_group_manager = nullptr; |
62 // If not null will share a mailbox manager with this context. | 62 // If not null will share a mailbox manager with this context. |
63 GLManager* share_mailbox_manager; | 63 GLManager* share_mailbox_manager = nullptr; |
64 // If not null will create a virtual manager based on this context. | 64 // If not null will create a virtual manager based on this context. |
65 GLManager* virtual_manager; | 65 GLManager* virtual_manager = nullptr; |
66 // Whether or not glBindXXX generates a resource. | 66 // Whether or not glBindXXX generates a resource. |
67 bool bind_generates_resource; | 67 bool bind_generates_resource = false; |
68 // Whether or not the context is auto-lost when GL_OUT_OF_MEMORY occurs. | 68 // Whether or not the context is auto-lost when GL_OUT_OF_MEMORY occurs. |
69 bool lose_context_when_out_of_memory; | 69 bool lose_context_when_out_of_memory = false; |
70 // Whether or not it's ok to lose the context. | 70 // Whether or not it's ok to lose the context. |
71 bool context_lost_allowed; | 71 bool context_lost_allowed = false; |
72 gles2::ContextType context_type; | 72 gles2::ContextType context_type = gles2::CONTEXT_TYPE_OPENGLES2; |
73 // Force shader name hashing for all context types. | 73 // Force shader name hashing for all context types. |
74 bool force_shader_name_hashing; | 74 bool force_shader_name_hashing = false; |
75 // Whether the buffer is multisampled. | 75 // Whether the buffer is multisampled. |
76 bool multisampled; | 76 bool multisampled = false; |
77 // Whether the backbuffer has an alpha channel. | 77 // Whether the backbuffer has an alpha channel. |
78 bool backbuffer_alpha; | 78 bool backbuffer_alpha = true; |
79 // The ImageFactory to use to generate images for the backbuffer. | 79 // The ImageFactory to use to generate images for the backbuffer. |
80 gpu::ImageFactory* image_factory; | 80 gpu::ImageFactory* image_factory = nullptr; |
81 // Whether to preserve the backbuffer after a call to SwapBuffers(). | 81 // Whether to preserve the backbuffer after a call to SwapBuffers(). |
82 bool preserve_backbuffer; | 82 bool preserve_backbuffer = false; |
83 }; | 83 }; |
84 GLManager(); | 84 GLManager(); |
85 ~GLManager() override; | 85 ~GLManager() override; |
86 | 86 |
87 std::unique_ptr<gfx::GpuMemoryBuffer> CreateGpuMemoryBuffer( | 87 std::unique_ptr<gfx::GpuMemoryBuffer> CreateGpuMemoryBuffer( |
88 const gfx::Size& size, | 88 const gfx::Size& size, |
89 gfx::BufferFormat format); | 89 gfx::BufferFormat format); |
90 | 90 |
91 void Initialize(const Options& options); | 91 void Initialize(const Options& options); |
92 void InitializeWithCommandLine(const Options& options, | 92 void InitializeWithCommandLine(const Options& options, |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 bool IsFenceSyncReleased(uint64_t release) override; | 146 bool IsFenceSyncReleased(uint64_t release) override; |
147 void SignalSyncToken(const gpu::SyncToken& sync_token, | 147 void SignalSyncToken(const gpu::SyncToken& sync_token, |
148 const base::Closure& callback) override; | 148 const base::Closure& callback) override; |
149 bool CanWaitUnverifiedSyncToken(const gpu::SyncToken* sync_token) override; | 149 bool CanWaitUnverifiedSyncToken(const gpu::SyncToken* sync_token) override; |
150 | 150 |
151 private: | 151 private: |
152 void PumpCommands(); | 152 void PumpCommands(); |
153 bool GetBufferChanged(int32_t transfer_buffer_id); | 153 bool GetBufferChanged(int32_t transfer_buffer_id); |
154 void SetupBaseContext(); | 154 void SetupBaseContext(); |
155 void OnFenceSyncRelease(uint64_t release); | 155 void OnFenceSyncRelease(uint64_t release); |
156 bool OnWaitFenceSync(gpu::CommandBufferNamespace namespace_id, | 156 bool OnWaitSyncToken(const SyncToken& sync_token); |
157 gpu::CommandBufferId command_buffer_id, | |
158 uint64_t release); | |
159 | 157 |
160 gpu::GpuPreferences gpu_preferences_; | 158 gpu::GpuPreferences gpu_preferences_; |
161 | 159 |
162 SyncPointManager* sync_point_manager_; // Non-owning. | 160 SyncPointManager* sync_point_manager_ = nullptr; // Non-owning. |
163 | 161 |
164 scoped_refptr<SyncPointOrderData> sync_point_order_data_; | 162 scoped_refptr<SyncPointOrderData> sync_point_order_data_; |
165 std::unique_ptr<SyncPointClient> sync_point_client_; | 163 std::unique_ptr<SyncPointClient> sync_point_client_; |
166 scoped_refptr<gles2::MailboxManager> mailbox_manager_; | 164 scoped_refptr<gles2::MailboxManager> mailbox_manager_; |
167 scoped_refptr<gl::GLShareGroup> share_group_; | 165 scoped_refptr<gl::GLShareGroup> share_group_; |
168 std::unique_ptr<CommandBufferService> command_buffer_; | 166 std::unique_ptr<CommandBufferService> command_buffer_; |
169 std::unique_ptr<gles2::GLES2Decoder> decoder_; | 167 std::unique_ptr<gles2::GLES2Decoder> decoder_; |
170 std::unique_ptr<CommandExecutor> executor_; | 168 std::unique_ptr<CommandExecutor> executor_; |
171 scoped_refptr<gl::GLSurface> surface_; | 169 scoped_refptr<gl::GLSurface> surface_; |
172 scoped_refptr<gl::GLContext> context_; | 170 scoped_refptr<gl::GLContext> context_; |
173 std::unique_ptr<gles2::GLES2CmdHelper> gles2_helper_; | 171 std::unique_ptr<gles2::GLES2CmdHelper> gles2_helper_; |
174 std::unique_ptr<TransferBuffer> transfer_buffer_; | 172 std::unique_ptr<TransferBuffer> transfer_buffer_; |
175 std::unique_ptr<gles2::GLES2Implementation> gles2_implementation_; | 173 std::unique_ptr<gles2::GLES2Implementation> gles2_implementation_; |
176 bool context_lost_allowed_; | 174 bool context_lost_allowed_ = false; |
177 bool pause_commands_; | 175 bool pause_commands_ = false; |
178 uint32_t paused_order_num_; | 176 uint32_t paused_order_num_ = 0; |
179 | 177 |
180 const CommandBufferId command_buffer_id_; | 178 const CommandBufferId command_buffer_id_; |
181 uint64_t next_fence_sync_release_; | 179 uint64_t next_fence_sync_release_ = 1; |
182 | 180 |
183 bool use_iosurface_memory_buffers_ = false; | 181 bool use_iosurface_memory_buffers_ = false; |
184 | 182 |
185 // Used on Android to virtualize GL for all contexts. | 183 // Used on Android to virtualize GL for all contexts. |
186 static int use_count_; | 184 static int use_count_; |
187 static scoped_refptr<gl::GLShareGroup>* base_share_group_; | 185 static scoped_refptr<gl::GLShareGroup>* base_share_group_; |
188 static scoped_refptr<gl::GLSurface>* base_surface_; | 186 static scoped_refptr<gl::GLSurface>* base_surface_; |
189 static scoped_refptr<gl::GLContext>* base_context_; | 187 static scoped_refptr<gl::GLContext>* base_context_; |
190 }; | 188 }; |
191 | 189 |
192 } // namespace gpu | 190 } // namespace gpu |
193 | 191 |
194 #endif // GPU_COMMAND_BUFFER_TESTS_GL_MANAGER_H_ | 192 #endif // GPU_COMMAND_BUFFER_TESTS_GL_MANAGER_H_ |
OLD | NEW |