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 #include "gpu/command_buffer/tests/gl_manager.h" | 5 #include "gpu/command_buffer/tests/gl_manager.h" |
6 | 6 |
7 #include <GLES2/gl2.h> | 7 #include <GLES2/gl2.h> |
8 #include <GLES2/gl2ext.h> | 8 #include <GLES2/gl2ext.h> |
9 #include <GLES2/gl2extchromium.h> | 9 #include <GLES2/gl2extchromium.h> |
10 | 10 |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 scoped_ptr<gfx::GpuMemoryBuffer> GLManager::CreateGpuMemoryBuffer( | 132 scoped_ptr<gfx::GpuMemoryBuffer> GLManager::CreateGpuMemoryBuffer( |
133 const gfx::Size& size, | 133 const gfx::Size& size, |
134 gfx::GpuMemoryBuffer::Format format) { | 134 gfx::GpuMemoryBuffer::Format format) { |
135 std::vector<unsigned char> data(size.GetArea() * BytesPerPixel(format), 0); | 135 std::vector<unsigned char> data(size.GetArea() * BytesPerPixel(format), 0); |
136 scoped_refptr<base::RefCountedBytes> bytes(new base::RefCountedBytes(data)); | 136 scoped_refptr<base::RefCountedBytes> bytes(new base::RefCountedBytes(data)); |
137 return make_scoped_ptr<gfx::GpuMemoryBuffer>( | 137 return make_scoped_ptr<gfx::GpuMemoryBuffer>( |
138 new GpuMemoryBufferImpl(bytes.get(), size, format)); | 138 new GpuMemoryBufferImpl(bytes.get(), size, format)); |
139 } | 139 } |
140 | 140 |
141 void GLManager::Initialize(const GLManager::Options& options) { | 141 void GLManager::Initialize(const GLManager::Options& options) { |
| 142 InitializeWithCommandLine(options, nullptr); |
| 143 } |
| 144 void GLManager::InitializeWithCommandLine(const GLManager::Options& options, |
| 145 base::CommandLine* command_line) { |
142 const int32 kCommandBufferSize = 1024 * 1024; | 146 const int32 kCommandBufferSize = 1024 * 1024; |
143 const size_t kStartTransferBufferSize = 4 * 1024 * 1024; | 147 const size_t kStartTransferBufferSize = 4 * 1024 * 1024; |
144 const size_t kMinTransferBufferSize = 1 * 256 * 1024; | 148 const size_t kMinTransferBufferSize = 1 * 256 * 1024; |
145 const size_t kMaxTransferBufferSize = 16 * 1024 * 1024; | 149 const size_t kMaxTransferBufferSize = 16 * 1024 * 1024; |
146 | 150 |
147 context_lost_allowed_ = options.context_lost_allowed; | 151 context_lost_allowed_ = options.context_lost_allowed; |
148 | 152 |
149 gles2::MailboxManager* mailbox_manager = NULL; | 153 gles2::MailboxManager* mailbox_manager = NULL; |
150 if (options.share_mailbox_manager) { | 154 if (options.share_mailbox_manager) { |
151 mailbox_manager = options.share_mailbox_manager->mailbox_manager(); | 155 mailbox_manager = options.share_mailbox_manager->mailbox_manager(); |
(...skipping 27 matching lines...) Expand all Loading... |
179 share_group ? share_group : new gfx::GLShareGroup; | 183 share_group ? share_group : new gfx::GLShareGroup; |
180 | 184 |
181 gfx::GpuPreference gpu_preference(gfx::PreferDiscreteGpu); | 185 gfx::GpuPreference gpu_preference(gfx::PreferDiscreteGpu); |
182 std::vector<int32> attribs; | 186 std::vector<int32> attribs; |
183 gles2::ContextCreationAttribHelper attrib_helper; | 187 gles2::ContextCreationAttribHelper attrib_helper; |
184 attrib_helper.red_size = 8; | 188 attrib_helper.red_size = 8; |
185 attrib_helper.green_size = 8; | 189 attrib_helper.green_size = 8; |
186 attrib_helper.blue_size = 8; | 190 attrib_helper.blue_size = 8; |
187 attrib_helper.alpha_size = 8; | 191 attrib_helper.alpha_size = 8; |
188 attrib_helper.depth_size = 16; | 192 attrib_helper.depth_size = 16; |
| 193 attrib_helper.stencil_size = 8; |
189 attrib_helper.Serialize(&attribs); | 194 attrib_helper.Serialize(&attribs); |
190 | 195 |
| 196 DCHECK(!command_line || !context_group); |
191 if (!context_group) { | 197 if (!context_group) { |
| 198 scoped_refptr<gles2::FeatureInfo> feature_info; |
| 199 if (command_line) |
| 200 feature_info = new gles2::FeatureInfo(*command_line); |
192 context_group = | 201 context_group = |
193 new gles2::ContextGroup(mailbox_manager_.get(), | 202 new gles2::ContextGroup(mailbox_manager_.get(), |
194 NULL, | 203 NULL, |
195 new gpu::gles2::ShaderTranslatorCache, | 204 new gpu::gles2::ShaderTranslatorCache, |
196 NULL, | 205 feature_info, |
197 options.bind_generates_resource); | 206 options.bind_generates_resource); |
198 } | 207 } |
199 | 208 |
200 decoder_.reset(::gpu::gles2::GLES2Decoder::Create(context_group)); | 209 decoder_.reset(::gpu::gles2::GLES2Decoder::Create(context_group)); |
201 | 210 |
202 command_buffer_.reset(new CommandBufferService( | 211 command_buffer_.reset(new CommandBufferService( |
203 decoder_->GetContextGroup()->transfer_buffer_manager())); | 212 decoder_->GetContextGroup()->transfer_buffer_manager())); |
204 ASSERT_TRUE(command_buffer_->Initialize()) | 213 ASSERT_TRUE(command_buffer_->Initialize()) |
205 << "could not create command buffer service"; | 214 << "could not create command buffer service"; |
206 | 215 |
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
409 void GLManager::SetSurfaceVisible(bool visible) { | 418 void GLManager::SetSurfaceVisible(bool visible) { |
410 NOTIMPLEMENTED(); | 419 NOTIMPLEMENTED(); |
411 } | 420 } |
412 | 421 |
413 uint32 GLManager::CreateStreamTexture(uint32 texture_id) { | 422 uint32 GLManager::CreateStreamTexture(uint32 texture_id) { |
414 NOTIMPLEMENTED(); | 423 NOTIMPLEMENTED(); |
415 return 0; | 424 return 0; |
416 } | 425 } |
417 | 426 |
418 } // namespace gpu | 427 } // namespace gpu |
OLD | NEW |