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

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: Fixed tests 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"
11 #include "base/strings/utf_string_conversions.h" 11 #include "base/strings/utf_string_conversions.h"
12 #include "base/thread_task_runner_handle.h" 12 #include "base/thread_task_runner_handle.h"
13 #include "content/common/gpu/client/command_buffer_proxy_impl.h" 13 #include "content/common/gpu/client/command_buffer_proxy_impl.h"
14 #include "content/common/gpu/client/gpu_channel_host.h" 14 #include "content/common/gpu/client/gpu_channel_host.h"
15 #include "content/public/common/content_switches.h" 15 #include "content/public/common/content_switches.h"
16 #include "content/public/common/web_preferences.h" 16 #include "content/public/common/web_preferences.h"
17 #include "content/renderer/pepper/host_globals.h" 17 #include "content/renderer/pepper/host_globals.h"
18 #include "content/renderer/pepper/pepper_plugin_instance_impl.h" 18 #include "content/renderer/pepper/pepper_plugin_instance_impl.h"
19 #include "content/renderer/pepper/plugin_instance_throttler_impl.h" 19 #include "content/renderer/pepper/plugin_instance_throttler_impl.h"
20 #include "content/renderer/pepper/plugin_module.h" 20 #include "content/renderer/pepper/plugin_module.h"
21 #include "content/renderer/render_thread_impl.h" 21 #include "content/renderer/render_thread_impl.h"
22 #include "content/renderer/render_view_impl.h" 22 #include "content/renderer/render_view_impl.h"
23 #include "gpu/command_buffer/client/gles2_implementation.h" 23 #include "gpu/command_buffer/client/gles2_implementation.h"
24 #include "ppapi/c/ppp_graphics_3d.h" 24 #include "ppapi/c/ppp_graphics_3d.h"
25 #include "ppapi/shared_impl/command_buffer_id_pair.h"
25 #include "ppapi/thunk/enter.h" 26 #include "ppapi/thunk/enter.h"
26 #include "third_party/WebKit/public/platform/WebString.h" 27 #include "third_party/WebKit/public/platform/WebString.h"
27 #include "third_party/WebKit/public/web/WebConsoleMessage.h" 28 #include "third_party/WebKit/public/web/WebConsoleMessage.h"
28 #include "third_party/WebKit/public/web/WebDocument.h" 29 #include "third_party/WebKit/public/web/WebDocument.h"
29 #include "third_party/WebKit/public/web/WebElement.h" 30 #include "third_party/WebKit/public/web/WebElement.h"
30 #include "third_party/WebKit/public/web/WebLocalFrame.h" 31 #include "third_party/WebKit/public/web/WebLocalFrame.h"
31 #include "third_party/WebKit/public/web/WebPluginContainer.h" 32 #include "third_party/WebKit/public/web/WebPluginContainer.h"
32 33
33 using ppapi::thunk::EnterResourceNoLock; 34 using ppapi::thunk::EnterResourceNoLock;
34 using ppapi::thunk::PPB_Graphics3D_API; 35 using ppapi::thunk::PPB_Graphics3D_API;
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 return 0; 74 return 0;
74 return graphics_3d->GetReference(); 75 return graphics_3d->GetReference();
75 } 76 }
76 77
77 // static 78 // static
78 PP_Resource PPB_Graphics3D_Impl::CreateRaw( 79 PP_Resource PPB_Graphics3D_Impl::CreateRaw(
79 PP_Instance instance, 80 PP_Instance instance,
80 PP_Resource share_context, 81 PP_Resource share_context,
81 const int32_t* attrib_list, 82 const int32_t* attrib_list,
82 gpu::Capabilities* capabilities, 83 gpu::Capabilities* capabilities,
83 base::SharedMemoryHandle* shared_state_handle) { 84 base::SharedMemoryHandle* shared_state_handle,
85 ppapi::CommandBufferIDPair* id_pair) {
84 PPB_Graphics3D_API* share_api = NULL; 86 PPB_Graphics3D_API* share_api = NULL;
85 if (share_context) { 87 if (share_context) {
86 EnterResourceNoLock<PPB_Graphics3D_API> enter(share_context, true); 88 EnterResourceNoLock<PPB_Graphics3D_API> enter(share_context, true);
87 if (enter.failed()) 89 if (enter.failed())
88 return 0; 90 return 0;
89 share_api = enter.object(); 91 share_api = enter.object();
90 } 92 }
91 scoped_refptr<PPB_Graphics3D_Impl> graphics_3d( 93 scoped_refptr<PPB_Graphics3D_Impl> graphics_3d(
92 new PPB_Graphics3D_Impl(instance)); 94 new PPB_Graphics3D_Impl(instance));
93 if (!graphics_3d->InitRaw(share_api, attrib_list, capabilities, 95 if (!graphics_3d->InitRaw(share_api, attrib_list, capabilities,
94 shared_state_handle)) 96 shared_state_handle, id_pair))
95 return 0; 97 return 0;
96 return graphics_3d->GetReference(); 98 return graphics_3d->GetReference();
97 } 99 }
98 100
99 PP_Bool PPB_Graphics3D_Impl::SetGetBuffer(int32_t transfer_buffer_id) { 101 PP_Bool PPB_Graphics3D_Impl::SetGetBuffer(int32_t transfer_buffer_id) {
100 GetCommandBuffer()->SetGetBuffer(transfer_buffer_id); 102 GetCommandBuffer()->SetGetBuffer(transfer_buffer_id);
101 return PP_TRUE; 103 return PP_TRUE;
102 } 104 }
103 105
104 scoped_refptr<gpu::Buffer> PPB_Graphics3D_Impl::CreateTransferBuffer( 106 scoped_refptr<gpu::Buffer> PPB_Graphics3D_Impl::CreateTransferBuffer(
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 sync_point_, 200 sync_point_,
199 base::Bind(&PPB_Graphics3D_Impl::OnSwapBuffers, 201 base::Bind(&PPB_Graphics3D_Impl::OnSwapBuffers,
200 weak_ptr_factory_.GetWeakPtr())); 202 weak_ptr_factory_.GetWeakPtr()));
201 } 203 }
202 204
203 return PP_OK_COMPLETIONPENDING; 205 return PP_OK_COMPLETIONPENDING;
204 } 206 }
205 207
206 bool PPB_Graphics3D_Impl::Init(PPB_Graphics3D_API* share_context, 208 bool PPB_Graphics3D_Impl::Init(PPB_Graphics3D_API* share_context,
207 const int32_t* attrib_list) { 209 const int32_t* attrib_list) {
208 if (!InitRaw(share_context, attrib_list, NULL, NULL)) 210 if (!InitRaw(share_context, attrib_list, NULL, NULL, NULL))
209 return false; 211 return false;
210 212
211 gpu::gles2::GLES2Implementation* share_gles2 = NULL; 213 gpu::gles2::GLES2Implementation* share_gles2 = NULL;
212 if (share_context) { 214 if (share_context) {
213 share_gles2 = 215 share_gles2 =
214 static_cast<PPB_Graphics3D_Shared*>(share_context)->gles2_impl(); 216 static_cast<PPB_Graphics3D_Shared*>(share_context)->gles2_impl();
215 } 217 }
216 218
217 return CreateGLES2Impl(kCommandBufferSize, kTransferBufferSize, share_gles2); 219 return CreateGLES2Impl(kCommandBufferSize, kTransferBufferSize, share_gles2);
218 } 220 }
219 221
220 bool PPB_Graphics3D_Impl::InitRaw( 222 bool PPB_Graphics3D_Impl::InitRaw(
221 PPB_Graphics3D_API* share_context, 223 PPB_Graphics3D_API* share_context,
222 const int32_t* attrib_list, 224 const int32_t* attrib_list,
223 gpu::Capabilities* capabilities, 225 gpu::Capabilities* capabilities,
224 base::SharedMemoryHandle* shared_state_handle) { 226 base::SharedMemoryHandle* shared_state_handle,
227 ppapi::CommandBufferIDPair* id_pair) {
225 PepperPluginInstanceImpl* plugin_instance = 228 PepperPluginInstanceImpl* plugin_instance =
226 HostGlobals::Get()->GetInstance(pp_instance()); 229 HostGlobals::Get()->GetInstance(pp_instance());
227 if (!plugin_instance) 230 if (!plugin_instance)
228 return false; 231 return false;
229 232
230 const WebPreferences& prefs = 233 const WebPreferences& prefs =
231 static_cast<RenderViewImpl*>(plugin_instance->GetRenderView()) 234 static_cast<RenderViewImpl*>(plugin_instance->GetRenderView())
232 ->webkit_preferences(); 235 ->webkit_preferences();
233 // 3D access might be disabled or blacklisted. 236 // 3D access might be disabled or blacklisted.
234 if (!prefs.pepper_3d_enabled) 237 if (!prefs.pepper_3d_enabled)
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
294 GpuChannelHost::kDefaultStreamPriority, attribs, GURL::EmptyGURL(), 297 GpuChannelHost::kDefaultStreamPriority, attribs, GURL::EmptyGURL(),
295 gpu_preference); 298 gpu_preference);
296 if (!command_buffer_) 299 if (!command_buffer_)
297 return false; 300 return false;
298 if (!command_buffer_->Initialize()) 301 if (!command_buffer_->Initialize())
299 return false; 302 return false;
300 if (shared_state_handle) 303 if (shared_state_handle)
301 *shared_state_handle = command_buffer_->GetSharedStateHandle(); 304 *shared_state_handle = command_buffer_->GetSharedStateHandle();
302 if (capabilities) 305 if (capabilities)
303 *capabilities = command_buffer_->GetCapabilities(); 306 *capabilities = command_buffer_->GetCapabilities();
307 if (id_pair) {
308 id_pair->namespace_id = command_buffer_->GetNamespaceID();
piman 2015/09/16 21:55:13 Arguably you could hardcode the namespace on the p
bbudge 2015/09/16 22:17:18 And that would simplify the patch significantly by
David Yen 2015/09/16 22:25:28 Done.
309 id_pair->command_buffer_id = command_buffer_->GetCommandBufferID();
310 }
304 mailbox_ = gpu::Mailbox::Generate(); 311 mailbox_ = gpu::Mailbox::Generate();
305 if (!command_buffer_->ProduceFrontBuffer(mailbox_)) 312 if (!command_buffer_->ProduceFrontBuffer(mailbox_))
306 return false; 313 return false;
307 sync_point_ = command_buffer_->InsertSyncPoint(); 314 sync_point_ = command_buffer_->InsertSyncPoint();
308 315
309 command_buffer_->SetContextLostCallback(base::Bind( 316 command_buffer_->SetContextLostCallback(base::Bind(
310 &PPB_Graphics3D_Impl::OnContextLost, weak_ptr_factory_.GetWeakPtr())); 317 &PPB_Graphics3D_Impl::OnContextLost, weak_ptr_factory_.GetWeakPtr()));
311 318
312 command_buffer_->SetOnConsoleMessageCallback(base::Bind( 319 command_buffer_->SetOnConsoleMessageCallback(base::Bind(
313 &PPB_Graphics3D_Impl::OnConsoleMessage, weak_ptr_factory_.GetWeakPtr())); 320 &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)); 378 instance->module()->GetPluginInterface(PPP_GRAPHICS_3D_INTERFACE));
372 // We have to check *again* that the instance exists, because it could have 379 // We have to check *again* that the instance exists, because it could have
373 // been deleted during GetPluginInterface(). Even the PluginModule could be 380 // been deleted during GetPluginInterface(). Even the PluginModule could be
374 // deleted, but in that case, the instance should also be gone, so the 381 // deleted, but in that case, the instance should also be gone, so the
375 // GetInstance check covers both cases. 382 // GetInstance check covers both cases.
376 if (ppp_graphics_3d && HostGlobals::Get()->GetInstance(this_pp_instance)) 383 if (ppp_graphics_3d && HostGlobals::Get()->GetInstance(this_pp_instance))
377 ppp_graphics_3d->Graphics3DContextLost(this_pp_instance); 384 ppp_graphics_3d->Graphics3DContextLost(this_pp_instance);
378 } 385 }
379 386
380 } // namespace content 387 } // 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