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 "content/renderer/pepper/ppb_graphics_3d_impl.h" | 5 #include "content/renderer/pepper/ppb_graphics_3d_impl.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/location.h" | 9 #include "base/location.h" |
10 #include "base/single_thread_task_runner.h" | 10 #include "base/single_thread_task_runner.h" |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
218 RenderThreadImpl* render_thread = RenderThreadImpl::current(); | 218 RenderThreadImpl* render_thread = RenderThreadImpl::current(); |
219 if (!render_thread) | 219 if (!render_thread) |
220 return false; | 220 return false; |
221 | 221 |
222 scoped_refptr<gpu::GpuChannelHost> channel = | 222 scoped_refptr<gpu::GpuChannelHost> channel = |
223 render_thread->EstablishGpuChannelSync( | 223 render_thread->EstablishGpuChannelSync( |
224 CAUSE_FOR_GPU_LAUNCH_PEPPERPLATFORMCONTEXT3DIMPL_INITIALIZE); | 224 CAUSE_FOR_GPU_LAUNCH_PEPPERPLATFORMCONTEXT3DIMPL_INITIALIZE); |
225 if (!channel) | 225 if (!channel) |
226 return false; | 226 return false; |
227 | 227 |
228 gpu::gles2::ContextCreationAttribHelper attrib_helper; | 228 gfx::Size surface_size; |
229 std::vector<int32_t> attribs; | 229 std::vector<int32_t> attribs; |
230 attrib_helper.gpu_preference = gl::PreferDiscreteGpu; | 230 gl::GpuPreference gpu_preference = gl::PreferDiscreteGpu; |
231 // TODO(alokp): Change CommandBufferProxyImpl::Create() | 231 // TODO(alokp): Change CommandBufferProxyImpl::Create() |
232 // interface to accept width and height in the attrib_list so that | 232 // interface to accept width and height in the attrib_list so that |
233 // we do not need to filter for width and height here. | 233 // we do not need to filter for width and height here. |
234 if (attrib_list) { | 234 if (attrib_list) { |
235 for (const int32_t* attr = attrib_list; attr[0] != PP_GRAPHICS3DATTRIB_NONE; | 235 for (const int32_t* attr = attrib_list; attr[0] != PP_GRAPHICS3DATTRIB_NONE; |
236 attr += 2) { | 236 attr += 2) { |
237 switch (attr[0]) { | 237 switch (attr[0]) { |
238 case PP_GRAPHICS3DATTRIB_WIDTH: | 238 case PP_GRAPHICS3DATTRIB_WIDTH: |
239 attrib_helper.offscreen_framebuffer_size.set_width(attr[1]); | 239 surface_size.set_width(attr[1]); |
240 break; | 240 break; |
241 case PP_GRAPHICS3DATTRIB_HEIGHT: | 241 case PP_GRAPHICS3DATTRIB_HEIGHT: |
242 attrib_helper.offscreen_framebuffer_size.set_height(attr[1]); | 242 surface_size.set_height(attr[1]); |
243 break; | 243 break; |
244 case PP_GRAPHICS3DATTRIB_GPU_PREFERENCE: | 244 case PP_GRAPHICS3DATTRIB_GPU_PREFERENCE: |
245 attrib_helper.gpu_preference = | 245 gpu_preference = |
246 (attr[1] == PP_GRAPHICS3DATTRIB_GPU_PREFERENCE_LOW_POWER) | 246 (attr[1] == PP_GRAPHICS3DATTRIB_GPU_PREFERENCE_LOW_POWER) |
247 ? gl::PreferIntegratedGpu | 247 ? gl::PreferIntegratedGpu |
248 : gl::PreferDiscreteGpu; | 248 : gl::PreferDiscreteGpu; |
249 break; | 249 break; |
250 case PP_GRAPHICS3DATTRIB_ALPHA_SIZE: | 250 case PP_GRAPHICS3DATTRIB_ALPHA_SIZE: |
251 has_alpha_ = attr[1] > 0; | 251 has_alpha_ = attr[1] > 0; |
252 // fall-through | 252 // fall-through |
253 default: | 253 default: |
254 attribs.push_back(attr[0]); | 254 attribs.push_back(attr[0]); |
255 attribs.push_back(attr[1]); | 255 attribs.push_back(attr[1]); |
256 break; | 256 break; |
257 } | 257 } |
258 } | 258 } |
259 attribs.push_back(PP_GRAPHICS3DATTRIB_NONE); | 259 attribs.push_back(PP_GRAPHICS3DATTRIB_NONE); |
260 } | 260 } |
| 261 gpu::gles2::ContextCreationAttribHelper attrib_helper; |
261 if (!attrib_helper.Parse(attribs)) | 262 if (!attrib_helper.Parse(attribs)) |
262 return false; | 263 return false; |
263 | 264 |
264 gpu::CommandBufferProxyImpl* share_buffer = NULL; | 265 gpu::CommandBufferProxyImpl* share_buffer = NULL; |
265 if (share_context) { | 266 if (share_context) { |
266 PPB_Graphics3D_Impl* share_graphics = | 267 PPB_Graphics3D_Impl* share_graphics = |
267 static_cast<PPB_Graphics3D_Impl*>(share_context); | 268 static_cast<PPB_Graphics3D_Impl*>(share_context); |
268 share_buffer = share_graphics->GetCommandBufferProxy(); | 269 share_buffer = share_graphics->GetCommandBufferProxy(); |
269 } | 270 } |
270 | 271 |
271 command_buffer_ = gpu::CommandBufferProxyImpl::Create( | 272 command_buffer_ = gpu::CommandBufferProxyImpl::Create( |
272 std::move(channel), gpu::kNullSurfaceHandle, share_buffer, | 273 std::move(channel), gpu::kNullSurfaceHandle, surface_size, share_buffer, |
273 gpu::GPU_STREAM_DEFAULT, gpu::GpuStreamPriority::NORMAL, attrib_helper, | 274 gpu::GPU_STREAM_DEFAULT, gpu::GpuStreamPriority::NORMAL, |
274 GURL::EmptyGURL(), base::ThreadTaskRunnerHandle::Get()); | 275 attrib_helper, GURL::EmptyGURL(), gpu_preference, |
| 276 base::ThreadTaskRunnerHandle::Get()); |
275 if (!command_buffer_) | 277 if (!command_buffer_) |
276 return false; | 278 return false; |
277 | 279 |
278 command_buffer_->SetGpuControlClient(this); | 280 command_buffer_->SetGpuControlClient(this); |
279 | 281 |
280 if (shared_state_handle) | 282 if (shared_state_handle) |
281 *shared_state_handle = command_buffer_->GetSharedStateHandle(); | 283 *shared_state_handle = command_buffer_->GetSharedStateHandle(); |
282 if (capabilities) | 284 if (capabilities) |
283 *capabilities = command_buffer_->GetCapabilities(); | 285 *capabilities = command_buffer_->GetCapabilities(); |
284 if (command_buffer_id) | 286 if (command_buffer_id) |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
365 if (!mailboxes_to_reuse_.empty()) { | 367 if (!mailboxes_to_reuse_.empty()) { |
366 gpu::Mailbox mailbox = mailboxes_to_reuse_.back(); | 368 gpu::Mailbox mailbox = mailboxes_to_reuse_.back(); |
367 mailboxes_to_reuse_.pop_back(); | 369 mailboxes_to_reuse_.pop_back(); |
368 return mailbox; | 370 return mailbox; |
369 } | 371 } |
370 | 372 |
371 return gpu::Mailbox::Generate(); | 373 return gpu::Mailbox::Generate(); |
372 } | 374 } |
373 | 375 |
374 } // namespace content | 376 } // namespace content |
OLD | NEW |