Chromium Code Reviews| 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" | 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_interface.h" | 23 #include "gpu/command_buffer/client/gles2_interface.h" |
| 24 #include "gpu/command_buffer/common/gles2_cmd_utils.h" | |
| 24 #include "ppapi/c/ppp_graphics_3d.h" | 25 #include "ppapi/c/ppp_graphics_3d.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; |
| 35 using blink::WebConsoleMessage; | 36 using blink::WebConsoleMessage; |
| 36 using blink::WebLocalFrame; | 37 using blink::WebLocalFrame; |
| 37 using blink::WebPluginContainer; | 38 using blink::WebPluginContainer; |
| 38 using blink::WebString; | 39 using blink::WebString; |
| 39 | 40 |
| 40 namespace content { | 41 namespace content { |
| 41 | 42 |
| 42 namespace { | 43 namespace { |
| 43 | 44 |
| 44 const int32_t kCommandBufferSize = 1024 * 1024; | 45 const int32_t kCommandBufferSize = 1024 * 1024; |
| 45 const int32_t kTransferBufferSize = 1024 * 1024; | 46 const int32_t kTransferBufferSize = 1024 * 1024; |
| 46 | 47 |
| 48 // Chromium specific attributes. | |
| 49 const int32_t kContextType = 0x10003; | |
|
no sievers
2016/03/16 00:46:58
Can you just move it from gles2_cmd_utils.cc to .h
ericrk
2016/03/16 16:53:20
Done.
| |
| 50 | |
| 47 } // namespace | 51 } // namespace |
| 48 | 52 |
| 49 PPB_Graphics3D_Impl::PPB_Graphics3D_Impl(PP_Instance instance) | 53 PPB_Graphics3D_Impl::PPB_Graphics3D_Impl(PP_Instance instance) |
| 50 : PPB_Graphics3D_Shared(instance), | 54 : PPB_Graphics3D_Shared(instance), |
| 51 bound_to_instance_(false), | 55 bound_to_instance_(false), |
| 52 commit_pending_(false), | 56 commit_pending_(false), |
| 53 has_alpha_(false), | 57 has_alpha_(false), |
| 54 weak_ptr_factory_(this) {} | 58 weak_ptr_factory_(this) {} |
| 55 | 59 |
| 56 PPB_Graphics3D_Impl::~PPB_Graphics3D_Impl() {} | 60 PPB_Graphics3D_Impl::~PPB_Graphics3D_Impl() {} |
| (...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 252 gfx::Size surface_size; | 256 gfx::Size surface_size; |
| 253 std::vector<int32_t> attribs; | 257 std::vector<int32_t> attribs; |
| 254 gfx::GpuPreference gpu_preference = gfx::PreferDiscreteGpu; | 258 gfx::GpuPreference gpu_preference = gfx::PreferDiscreteGpu; |
| 255 // TODO(alokp): Change GpuChannelHost::CreateOffscreenCommandBuffer() | 259 // TODO(alokp): Change GpuChannelHost::CreateOffscreenCommandBuffer() |
| 256 // interface to accept width and height in the attrib_list so that | 260 // interface to accept width and height in the attrib_list so that |
| 257 // we do not need to filter for width and height here. | 261 // we do not need to filter for width and height here. |
| 258 if (attrib_list) { | 262 if (attrib_list) { |
| 259 for (const int32_t* attr = attrib_list; attr[0] != PP_GRAPHICS3DATTRIB_NONE; | 263 for (const int32_t* attr = attrib_list; attr[0] != PP_GRAPHICS3DATTRIB_NONE; |
| 260 attr += 2) { | 264 attr += 2) { |
| 261 switch (attr[0]) { | 265 switch (attr[0]) { |
| 266 case kContextType: | |
| 267 // kContextType is chromium internal, no caller should set this. | |
| 268 DCHECK(false); | |
| 269 break; | |
| 262 case PP_GRAPHICS3DATTRIB_WIDTH: | 270 case PP_GRAPHICS3DATTRIB_WIDTH: |
| 263 surface_size.set_width(attr[1]); | 271 surface_size.set_width(attr[1]); |
| 264 break; | 272 break; |
| 265 case PP_GRAPHICS3DATTRIB_HEIGHT: | 273 case PP_GRAPHICS3DATTRIB_HEIGHT: |
| 266 surface_size.set_height(attr[1]); | 274 surface_size.set_height(attr[1]); |
| 267 break; | 275 break; |
| 268 case PP_GRAPHICS3DATTRIB_GPU_PREFERENCE: | 276 case PP_GRAPHICS3DATTRIB_GPU_PREFERENCE: |
| 269 gpu_preference = | 277 gpu_preference = |
| 270 (attr[1] == PP_GRAPHICS3DATTRIB_GPU_PREFERENCE_LOW_POWER) | 278 (attr[1] == PP_GRAPHICS3DATTRIB_GPU_PREFERENCE_LOW_POWER) |
| 271 ? gfx::PreferIntegratedGpu | 279 ? gfx::PreferIntegratedGpu |
| 272 : gfx::PreferDiscreteGpu; | 280 : gfx::PreferDiscreteGpu; |
| 273 break; | 281 break; |
| 274 case PP_GRAPHICS3DATTRIB_ALPHA_SIZE: | 282 case PP_GRAPHICS3DATTRIB_ALPHA_SIZE: |
| 275 has_alpha_ = attr[1] > 0; | 283 has_alpha_ = attr[1] > 0; |
| 276 // fall-through | 284 // fall-through |
| 277 default: | 285 default: |
| 278 attribs.push_back(attr[0]); | 286 attribs.push_back(attr[0]); |
| 279 attribs.push_back(attr[1]); | 287 attribs.push_back(attr[1]); |
| 280 break; | 288 break; |
| 281 } | 289 } |
| 282 } | 290 } |
| 283 attribs.push_back(PP_GRAPHICS3DATTRIB_NONE); | |
| 284 } | 291 } |
| 285 | 292 |
| 293 attribs.push_back(kContextType); | |
| 294 attribs.push_back(gpu::gles2::CONTEXT_TYPE_OPENGLES2_PEPPER); | |
| 295 attribs.push_back(PP_GRAPHICS3DATTRIB_NONE); | |
| 296 | |
| 286 CommandBufferProxyImpl* share_buffer = NULL; | 297 CommandBufferProxyImpl* share_buffer = NULL; |
| 287 if (share_context) { | 298 if (share_context) { |
| 288 PPB_Graphics3D_Impl* share_graphics = | 299 PPB_Graphics3D_Impl* share_graphics = |
| 289 static_cast<PPB_Graphics3D_Impl*>(share_context); | 300 static_cast<PPB_Graphics3D_Impl*>(share_context); |
| 290 share_buffer = share_graphics->GetCommandBufferProxy(); | 301 share_buffer = share_graphics->GetCommandBufferProxy(); |
| 291 } | 302 } |
| 292 | 303 |
| 293 command_buffer_ = channel_->CreateOffscreenCommandBuffer( | 304 command_buffer_ = channel_->CreateOffscreenCommandBuffer( |
| 294 surface_size, share_buffer, GpuChannelHost::kDefaultStreamId, | 305 surface_size, share_buffer, GpuChannelHost::kDefaultStreamId, |
| 295 GpuChannelHost::kDefaultStreamPriority, attribs, GURL::EmptyGURL(), | 306 GpuChannelHost::kDefaultStreamPriority, attribs, GURL::EmptyGURL(), |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 373 instance->module()->GetPluginInterface(PPP_GRAPHICS_3D_INTERFACE)); | 384 instance->module()->GetPluginInterface(PPP_GRAPHICS_3D_INTERFACE)); |
| 374 // We have to check *again* that the instance exists, because it could have | 385 // We have to check *again* that the instance exists, because it could have |
| 375 // been deleted during GetPluginInterface(). Even the PluginModule could be | 386 // been deleted during GetPluginInterface(). Even the PluginModule could be |
| 376 // deleted, but in that case, the instance should also be gone, so the | 387 // deleted, but in that case, the instance should also be gone, so the |
| 377 // GetInstance check covers both cases. | 388 // GetInstance check covers both cases. |
| 378 if (ppp_graphics_3d && HostGlobals::Get()->GetInstance(this_pp_instance)) | 389 if (ppp_graphics_3d && HostGlobals::Get()->GetInstance(this_pp_instance)) |
| 379 ppp_graphics_3d->Graphics3DContextLost(this_pp_instance); | 390 ppp_graphics_3d->Graphics3DContextLost(this_pp_instance); |
| 380 } | 391 } |
| 381 | 392 |
| 382 } // namespace content | 393 } // namespace content |
| OLD | NEW |