| 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" |
| 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" | |
| 14 #include "content/common/gpu/client/gpu_channel_host.h" | |
| 15 #include "content/public/common/content_switches.h" | 13 #include "content/public/common/content_switches.h" |
| 16 #include "content/public/common/web_preferences.h" | 14 #include "content/public/common/web_preferences.h" |
| 17 #include "content/renderer/pepper/host_globals.h" | 15 #include "content/renderer/pepper/host_globals.h" |
| 18 #include "content/renderer/pepper/pepper_plugin_instance_impl.h" | 16 #include "content/renderer/pepper/pepper_plugin_instance_impl.h" |
| 19 #include "content/renderer/pepper/plugin_instance_throttler_impl.h" | 17 #include "content/renderer/pepper/plugin_instance_throttler_impl.h" |
| 20 #include "content/renderer/pepper/plugin_module.h" | 18 #include "content/renderer/pepper/plugin_module.h" |
| 21 #include "content/renderer/render_thread_impl.h" | 19 #include "content/renderer/render_thread_impl.h" |
| 22 #include "content/renderer/render_view_impl.h" | 20 #include "content/renderer/render_view_impl.h" |
| 21 #include "gpu/ipc/client/command_buffer_proxy_impl.h" |
| 22 #include "gpu/ipc/client/gpu_channel_host.h" |
| 23 #include "ppapi/c/ppp_graphics_3d.h" | 23 #include "ppapi/c/ppp_graphics_3d.h" |
| 24 #include "ppapi/thunk/enter.h" | 24 #include "ppapi/thunk/enter.h" |
| 25 #include "third_party/WebKit/public/platform/WebString.h" | 25 #include "third_party/WebKit/public/platform/WebString.h" |
| 26 #include "third_party/WebKit/public/web/WebConsoleMessage.h" | 26 #include "third_party/WebKit/public/web/WebConsoleMessage.h" |
| 27 #include "third_party/WebKit/public/web/WebDocument.h" | 27 #include "third_party/WebKit/public/web/WebDocument.h" |
| 28 #include "third_party/WebKit/public/web/WebElement.h" | 28 #include "third_party/WebKit/public/web/WebElement.h" |
| 29 #include "third_party/WebKit/public/web/WebLocalFrame.h" | 29 #include "third_party/WebKit/public/web/WebLocalFrame.h" |
| 30 #include "third_party/WebKit/public/web/WebPluginContainer.h" | 30 #include "third_party/WebKit/public/web/WebPluginContainer.h" |
| 31 | 31 |
| 32 using ppapi::thunk::EnterResourceNoLock; | 32 using ppapi::thunk::EnterResourceNoLock; |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 | 116 |
| 117 bool PPB_Graphics3D_Impl::IsOpaque() { return !has_alpha_; } | 117 bool PPB_Graphics3D_Impl::IsOpaque() { return !has_alpha_; } |
| 118 | 118 |
| 119 void PPB_Graphics3D_Impl::ViewInitiatedPaint() { | 119 void PPB_Graphics3D_Impl::ViewInitiatedPaint() { |
| 120 commit_pending_ = false; | 120 commit_pending_ = false; |
| 121 | 121 |
| 122 if (HasPendingSwap()) | 122 if (HasPendingSwap()) |
| 123 SwapBuffersACK(PP_OK); | 123 SwapBuffersACK(PP_OK); |
| 124 } | 124 } |
| 125 | 125 |
| 126 CommandBufferProxyImpl* PPB_Graphics3D_Impl::GetCommandBufferProxy() { | 126 gpu::CommandBufferProxyImpl* PPB_Graphics3D_Impl::GetCommandBufferProxy() { |
| 127 DCHECK(command_buffer_); | 127 DCHECK(command_buffer_); |
| 128 return command_buffer_.get(); | 128 return command_buffer_.get(); |
| 129 } | 129 } |
| 130 | 130 |
| 131 gpu::CommandBuffer* PPB_Graphics3D_Impl::GetCommandBuffer() { | 131 gpu::CommandBuffer* PPB_Graphics3D_Impl::GetCommandBuffer() { |
| 132 return command_buffer_.get(); | 132 return command_buffer_.get(); |
| 133 } | 133 } |
| 134 | 134 |
| 135 gpu::GpuControl* PPB_Graphics3D_Impl::GetGpuControl() { | 135 gpu::GpuControl* PPB_Graphics3D_Impl::GetGpuControl() { |
| 136 return command_buffer_.get(); | 136 return command_buffer_.get(); |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 223 // fall-through | 223 // fall-through |
| 224 default: | 224 default: |
| 225 attribs.push_back(attr[0]); | 225 attribs.push_back(attr[0]); |
| 226 attribs.push_back(attr[1]); | 226 attribs.push_back(attr[1]); |
| 227 break; | 227 break; |
| 228 } | 228 } |
| 229 } | 229 } |
| 230 attribs.push_back(PP_GRAPHICS3DATTRIB_NONE); | 230 attribs.push_back(PP_GRAPHICS3DATTRIB_NONE); |
| 231 } | 231 } |
| 232 | 232 |
| 233 CommandBufferProxyImpl* share_buffer = NULL; | 233 gpu::CommandBufferProxyImpl* share_buffer = NULL; |
| 234 if (share_context) { | 234 if (share_context) { |
| 235 PPB_Graphics3D_Impl* share_graphics = | 235 PPB_Graphics3D_Impl* share_graphics = |
| 236 static_cast<PPB_Graphics3D_Impl*>(share_context); | 236 static_cast<PPB_Graphics3D_Impl*>(share_context); |
| 237 share_buffer = share_graphics->GetCommandBufferProxy(); | 237 share_buffer = share_graphics->GetCommandBufferProxy(); |
| 238 } | 238 } |
| 239 | 239 |
| 240 command_buffer_ = channel_->CreateCommandBuffer( | 240 command_buffer_ = channel_->CreateCommandBuffer( |
| 241 gpu::kNullSurfaceHandle, surface_size, share_buffer, | 241 gpu::kNullSurfaceHandle, surface_size, share_buffer, |
| 242 GpuChannelHost::kDefaultStreamId, GpuChannelHost::kDefaultStreamPriority, | 242 gpu::GpuChannelHost::kDefaultStreamId, |
| 243 attribs, GURL::EmptyGURL(), gpu_preference); | 243 gpu::GpuChannelHost::kDefaultStreamPriority, attribs, GURL::EmptyGURL(), |
| 244 gpu_preference); |
| 244 if (!command_buffer_) | 245 if (!command_buffer_) |
| 245 return false; | 246 return false; |
| 246 if (!command_buffer_->Initialize()) | 247 if (!command_buffer_->Initialize()) |
| 247 return false; | 248 return false; |
| 248 if (shared_state_handle) | 249 if (shared_state_handle) |
| 249 *shared_state_handle = command_buffer_->GetSharedStateHandle(); | 250 *shared_state_handle = command_buffer_->GetSharedStateHandle(); |
| 250 if (capabilities) | 251 if (capabilities) |
| 251 *capabilities = command_buffer_->GetCapabilities(); | 252 *capabilities = command_buffer_->GetCapabilities(); |
| 252 if (command_buffer_id) | 253 if (command_buffer_id) |
| 253 *command_buffer_id = command_buffer_->GetCommandBufferID(); | 254 *command_buffer_id = command_buffer_->GetCommandBufferID(); |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 320 instance->module()->GetPluginInterface(PPP_GRAPHICS_3D_INTERFACE)); | 321 instance->module()->GetPluginInterface(PPP_GRAPHICS_3D_INTERFACE)); |
| 321 // We have to check *again* that the instance exists, because it could have | 322 // We have to check *again* that the instance exists, because it could have |
| 322 // been deleted during GetPluginInterface(). Even the PluginModule could be | 323 // been deleted during GetPluginInterface(). Even the PluginModule could be |
| 323 // deleted, but in that case, the instance should also be gone, so the | 324 // deleted, but in that case, the instance should also be gone, so the |
| 324 // GetInstance check covers both cases. | 325 // GetInstance check covers both cases. |
| 325 if (ppp_graphics_3d && HostGlobals::Get()->GetInstance(this_pp_instance)) | 326 if (ppp_graphics_3d && HostGlobals::Get()->GetInstance(this_pp_instance)) |
| 326 ppp_graphics_3d->Graphics3DContextLost(this_pp_instance); | 327 ppp_graphics_3d->Graphics3DContextLost(this_pp_instance); |
| 327 } | 328 } |
| 328 | 329 |
| 329 } // namespace content | 330 } // namespace content |
| OLD | NEW |