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

Side by Side Diff: content/renderer/pepper/ppb_graphics_3d_impl.cc

Issue 1345813002: Added a unique command buffer ID for command buffers. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix bad merge Created 5 years, 3 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
OLDNEW
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 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 return 0; 73 return 0;
74 return graphics_3d->GetReference(); 74 return graphics_3d->GetReference();
75 } 75 }
76 76
77 // static 77 // static
78 PP_Resource PPB_Graphics3D_Impl::CreateRaw( 78 PP_Resource PPB_Graphics3D_Impl::CreateRaw(
79 PP_Instance instance, 79 PP_Instance instance,
80 PP_Resource share_context, 80 PP_Resource share_context,
81 const int32_t* attrib_list, 81 const int32_t* attrib_list,
82 gpu::Capabilities* capabilities, 82 gpu::Capabilities* capabilities,
83 base::SharedMemoryHandle* shared_state_handle) { 83 base::SharedMemoryHandle* shared_state_handle,
84 uint64_t* command_buffer_id) {
84 PPB_Graphics3D_API* share_api = NULL; 85 PPB_Graphics3D_API* share_api = NULL;
85 if (share_context) { 86 if (share_context) {
86 EnterResourceNoLock<PPB_Graphics3D_API> enter(share_context, true); 87 EnterResourceNoLock<PPB_Graphics3D_API> enter(share_context, true);
87 if (enter.failed()) 88 if (enter.failed())
88 return 0; 89 return 0;
89 share_api = enter.object(); 90 share_api = enter.object();
90 } 91 }
91 scoped_refptr<PPB_Graphics3D_Impl> graphics_3d( 92 scoped_refptr<PPB_Graphics3D_Impl> graphics_3d(
92 new PPB_Graphics3D_Impl(instance)); 93 new PPB_Graphics3D_Impl(instance));
93 if (!graphics_3d->InitRaw(share_api, attrib_list, capabilities, 94 if (!graphics_3d->InitRaw(share_api, attrib_list, capabilities,
94 shared_state_handle)) 95 shared_state_handle, command_buffer_id))
95 return 0; 96 return 0;
96 return graphics_3d->GetReference(); 97 return graphics_3d->GetReference();
97 } 98 }
98 99
99 PP_Bool PPB_Graphics3D_Impl::SetGetBuffer(int32_t transfer_buffer_id) { 100 PP_Bool PPB_Graphics3D_Impl::SetGetBuffer(int32_t transfer_buffer_id) {
100 GetCommandBuffer()->SetGetBuffer(transfer_buffer_id); 101 GetCommandBuffer()->SetGetBuffer(transfer_buffer_id);
101 return PP_TRUE; 102 return PP_TRUE;
102 } 103 }
103 104
104 scoped_refptr<gpu::Buffer> PPB_Graphics3D_Impl::CreateTransferBuffer( 105 scoped_refptr<gpu::Buffer> PPB_Graphics3D_Impl::CreateTransferBuffer(
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 sync_point_, 199 sync_point_,
199 base::Bind(&PPB_Graphics3D_Impl::OnSwapBuffers, 200 base::Bind(&PPB_Graphics3D_Impl::OnSwapBuffers,
200 weak_ptr_factory_.GetWeakPtr())); 201 weak_ptr_factory_.GetWeakPtr()));
201 } 202 }
202 203
203 return PP_OK_COMPLETIONPENDING; 204 return PP_OK_COMPLETIONPENDING;
204 } 205 }
205 206
206 bool PPB_Graphics3D_Impl::Init(PPB_Graphics3D_API* share_context, 207 bool PPB_Graphics3D_Impl::Init(PPB_Graphics3D_API* share_context,
207 const int32_t* attrib_list) { 208 const int32_t* attrib_list) {
208 if (!InitRaw(share_context, attrib_list, NULL, NULL)) 209 if (!InitRaw(share_context, attrib_list, NULL, NULL, NULL))
209 return false; 210 return false;
210 211
211 gpu::gles2::GLES2Implementation* share_gles2 = NULL; 212 gpu::gles2::GLES2Implementation* share_gles2 = NULL;
212 if (share_context) { 213 if (share_context) {
213 share_gles2 = 214 share_gles2 =
214 static_cast<PPB_Graphics3D_Shared*>(share_context)->gles2_impl(); 215 static_cast<PPB_Graphics3D_Shared*>(share_context)->gles2_impl();
215 } 216 }
216 217
217 return CreateGLES2Impl(kCommandBufferSize, kTransferBufferSize, share_gles2); 218 return CreateGLES2Impl(kCommandBufferSize, kTransferBufferSize, share_gles2);
218 } 219 }
219 220
220 bool PPB_Graphics3D_Impl::InitRaw( 221 bool PPB_Graphics3D_Impl::InitRaw(
221 PPB_Graphics3D_API* share_context, 222 PPB_Graphics3D_API* share_context,
222 const int32_t* attrib_list, 223 const int32_t* attrib_list,
223 gpu::Capabilities* capabilities, 224 gpu::Capabilities* capabilities,
224 base::SharedMemoryHandle* shared_state_handle) { 225 base::SharedMemoryHandle* shared_state_handle,
226 uint64_t* command_buffer_id) {
225 PepperPluginInstanceImpl* plugin_instance = 227 PepperPluginInstanceImpl* plugin_instance =
226 HostGlobals::Get()->GetInstance(pp_instance()); 228 HostGlobals::Get()->GetInstance(pp_instance());
227 if (!plugin_instance) 229 if (!plugin_instance)
228 return false; 230 return false;
229 231
230 const WebPreferences& prefs = 232 const WebPreferences& prefs =
231 static_cast<RenderViewImpl*>(plugin_instance->GetRenderView()) 233 static_cast<RenderViewImpl*>(plugin_instance->GetRenderView())
232 ->webkit_preferences(); 234 ->webkit_preferences();
233 // 3D access might be disabled or blacklisted. 235 // 3D access might be disabled or blacklisted.
234 if (!prefs.pepper_3d_enabled) 236 if (!prefs.pepper_3d_enabled)
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
294 GpuChannelHost::kDefaultStreamPriority, attribs, GURL::EmptyGURL(), 296 GpuChannelHost::kDefaultStreamPriority, attribs, GURL::EmptyGURL(),
295 gpu_preference); 297 gpu_preference);
296 if (!command_buffer_) 298 if (!command_buffer_)
297 return false; 299 return false;
298 if (!command_buffer_->Initialize()) 300 if (!command_buffer_->Initialize())
299 return false; 301 return false;
300 if (shared_state_handle) 302 if (shared_state_handle)
301 *shared_state_handle = command_buffer_->GetSharedStateHandle(); 303 *shared_state_handle = command_buffer_->GetSharedStateHandle();
302 if (capabilities) 304 if (capabilities)
303 *capabilities = command_buffer_->GetCapabilities(); 305 *capabilities = command_buffer_->GetCapabilities();
306 if (command_buffer_id)
307 *command_buffer_id = command_buffer_->GetCommandBufferID();
304 mailbox_ = gpu::Mailbox::Generate(); 308 mailbox_ = gpu::Mailbox::Generate();
305 if (!command_buffer_->ProduceFrontBuffer(mailbox_)) 309 if (!command_buffer_->ProduceFrontBuffer(mailbox_))
306 return false; 310 return false;
307 sync_point_ = command_buffer_->InsertSyncPoint(); 311 sync_point_ = command_buffer_->InsertSyncPoint();
308 312
309 command_buffer_->SetContextLostCallback(base::Bind( 313 command_buffer_->SetContextLostCallback(base::Bind(
310 &PPB_Graphics3D_Impl::OnContextLost, weak_ptr_factory_.GetWeakPtr())); 314 &PPB_Graphics3D_Impl::OnContextLost, weak_ptr_factory_.GetWeakPtr()));
311 315
312 command_buffer_->SetOnConsoleMessageCallback(base::Bind( 316 command_buffer_->SetOnConsoleMessageCallback(base::Bind(
313 &PPB_Graphics3D_Impl::OnConsoleMessage, weak_ptr_factory_.GetWeakPtr())); 317 &PPB_Graphics3D_Impl::OnConsoleMessage, weak_ptr_factory_.GetWeakPtr()));
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
371 instance->module()->GetPluginInterface(PPP_GRAPHICS_3D_INTERFACE)); 375 instance->module()->GetPluginInterface(PPP_GRAPHICS_3D_INTERFACE));
372 // We have to check *again* that the instance exists, because it could have 376 // We have to check *again* that the instance exists, because it could have
373 // been deleted during GetPluginInterface(). Even the PluginModule could be 377 // been deleted during GetPluginInterface(). Even the PluginModule could be
374 // deleted, but in that case, the instance should also be gone, so the 378 // deleted, but in that case, the instance should also be gone, so the
375 // GetInstance check covers both cases. 379 // GetInstance check covers both cases.
376 if (ppp_graphics_3d && HostGlobals::Get()->GetInstance(this_pp_instance)) 380 if (ppp_graphics_3d && HostGlobals::Get()->GetInstance(this_pp_instance))
377 ppp_graphics_3d->Graphics3DContextLost(this_pp_instance); 381 ppp_graphics_3d->Graphics3DContextLost(this_pp_instance);
378 } 382 }
379 383
380 } // namespace content 384 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/pepper/ppb_graphics_3d_impl.h ('k') | content/renderer/pepper/resource_creation_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698