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 gfx::Size surface_size; | 228 gpu::gles2::ContextCreationAttribHelper attrib_helper; |
229 std::vector<int32_t> attribs; | 229 std::vector<int32_t> attribs; |
230 gl::GpuPreference gpu_preference = gl::PreferDiscreteGpu; | 230 attrib_helper.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 surface_size.set_width(attr[1]); | 239 attrib_helper.offscreen_framebuffer_size.set_width(attr[1]); |
240 break; | 240 break; |
241 case PP_GRAPHICS3DATTRIB_HEIGHT: | 241 case PP_GRAPHICS3DATTRIB_HEIGHT: |
242 surface_size.set_height(attr[1]); | 242 attrib_helper.offscreen_framebuffer_size.set_height(attr[1]); |
243 break; | 243 break; |
244 case PP_GRAPHICS3DATTRIB_GPU_PREFERENCE: | 244 case PP_GRAPHICS3DATTRIB_GPU_PREFERENCE: |
245 gpu_preference = | 245 attrib_helper.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; | |
262 if (!attrib_helper.Parse(attribs)) | 261 if (!attrib_helper.Parse(attribs)) |
263 return false; | 262 return false; |
264 | 263 |
265 gpu::CommandBufferProxyImpl* share_buffer = NULL; | 264 gpu::CommandBufferProxyImpl* share_buffer = NULL; |
266 if (share_context) { | 265 if (share_context) { |
267 PPB_Graphics3D_Impl* share_graphics = | 266 PPB_Graphics3D_Impl* share_graphics = |
268 static_cast<PPB_Graphics3D_Impl*>(share_context); | 267 static_cast<PPB_Graphics3D_Impl*>(share_context); |
269 share_buffer = share_graphics->GetCommandBufferProxy(); | 268 share_buffer = share_graphics->GetCommandBufferProxy(); |
270 } | 269 } |
271 | 270 |
272 command_buffer_ = gpu::CommandBufferProxyImpl::Create( | 271 command_buffer_ = gpu::CommandBufferProxyImpl::Create( |
273 std::move(channel), gpu::kNullSurfaceHandle, surface_size, share_buffer, | 272 std::move(channel), gpu::kNullSurfaceHandle, share_buffer, |
274 gpu::GPU_STREAM_DEFAULT, gpu::GpuStreamPriority::NORMAL, | 273 gpu::GPU_STREAM_DEFAULT, gpu::GpuStreamPriority::NORMAL, attrib_helper, |
275 attrib_helper, GURL::EmptyGURL(), gpu_preference, | 274 GURL::EmptyGURL(), base::ThreadTaskRunnerHandle::Get()); |
276 base::ThreadTaskRunnerHandle::Get()); | |
277 if (!command_buffer_) | 275 if (!command_buffer_) |
278 return false; | 276 return false; |
279 | 277 |
280 command_buffer_->SetGpuControlClient(this); | 278 command_buffer_->SetGpuControlClient(this); |
281 | 279 |
282 if (shared_state_handle) | 280 if (shared_state_handle) |
283 *shared_state_handle = command_buffer_->GetSharedStateHandle(); | 281 *shared_state_handle = command_buffer_->GetSharedStateHandle(); |
284 if (capabilities) | 282 if (capabilities) |
285 *capabilities = command_buffer_->GetCapabilities(); | 283 *capabilities = command_buffer_->GetCapabilities(); |
286 if (command_buffer_id) | 284 if (command_buffer_id) |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
367 if (!mailboxes_to_reuse_.empty()) { | 365 if (!mailboxes_to_reuse_.empty()) { |
368 gpu::Mailbox mailbox = mailboxes_to_reuse_.back(); | 366 gpu::Mailbox mailbox = mailboxes_to_reuse_.back(); |
369 mailboxes_to_reuse_.pop_back(); | 367 mailboxes_to_reuse_.pop_back(); |
370 return mailbox; | 368 return mailbox; |
371 } | 369 } |
372 | 370 |
373 return gpu::Mailbox::Generate(); | 371 return gpu::Mailbox::Generate(); |
374 } | 372 } |
375 | 373 |
376 } // namespace content | 374 } // namespace content |
OLD | NEW |