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

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

Issue 1781093002: Add CONTEXT_TYPE_OPENGLES2_PEPPER (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: move kContextType to header Created 4 years, 9 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
« no previous file with comments | « content/renderer/BUILD.gn ('k') | gpu/command_buffer/common/gles2_cmd_utils.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_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;
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 gfx::Size surface_size; 253 gfx::Size surface_size;
253 std::vector<int32_t> attribs; 254 std::vector<int32_t> attribs;
254 gfx::GpuPreference gpu_preference = gfx::PreferDiscreteGpu; 255 gfx::GpuPreference gpu_preference = gfx::PreferDiscreteGpu;
255 // TODO(alokp): Change GpuChannelHost::CreateOffscreenCommandBuffer() 256 // TODO(alokp): Change GpuChannelHost::CreateOffscreenCommandBuffer()
256 // interface to accept width and height in the attrib_list so that 257 // interface to accept width and height in the attrib_list so that
257 // we do not need to filter for width and height here. 258 // we do not need to filter for width and height here.
258 if (attrib_list) { 259 if (attrib_list) {
259 for (const int32_t* attr = attrib_list; attr[0] != PP_GRAPHICS3DATTRIB_NONE; 260 for (const int32_t* attr = attrib_list; attr[0] != PP_GRAPHICS3DATTRIB_NONE;
260 attr += 2) { 261 attr += 2) {
261 switch (attr[0]) { 262 switch (attr[0]) {
263 case gpu::gles2::kContextType:
264 // kContextType is chromium internal, no caller should set this.
265 DCHECK(false);
piman 2016/03/16 23:55:04 The attrib list comes from an untrusted side (e.g.
266 break;
262 case PP_GRAPHICS3DATTRIB_WIDTH: 267 case PP_GRAPHICS3DATTRIB_WIDTH:
263 surface_size.set_width(attr[1]); 268 surface_size.set_width(attr[1]);
264 break; 269 break;
265 case PP_GRAPHICS3DATTRIB_HEIGHT: 270 case PP_GRAPHICS3DATTRIB_HEIGHT:
266 surface_size.set_height(attr[1]); 271 surface_size.set_height(attr[1]);
267 break; 272 break;
268 case PP_GRAPHICS3DATTRIB_GPU_PREFERENCE: 273 case PP_GRAPHICS3DATTRIB_GPU_PREFERENCE:
269 gpu_preference = 274 gpu_preference =
270 (attr[1] == PP_GRAPHICS3DATTRIB_GPU_PREFERENCE_LOW_POWER) 275 (attr[1] == PP_GRAPHICS3DATTRIB_GPU_PREFERENCE_LOW_POWER)
271 ? gfx::PreferIntegratedGpu 276 ? gfx::PreferIntegratedGpu
272 : gfx::PreferDiscreteGpu; 277 : gfx::PreferDiscreteGpu;
273 break; 278 break;
274 case PP_GRAPHICS3DATTRIB_ALPHA_SIZE: 279 case PP_GRAPHICS3DATTRIB_ALPHA_SIZE:
275 has_alpha_ = attr[1] > 0; 280 has_alpha_ = attr[1] > 0;
276 // fall-through 281 // fall-through
277 default: 282 default:
278 attribs.push_back(attr[0]); 283 attribs.push_back(attr[0]);
279 attribs.push_back(attr[1]); 284 attribs.push_back(attr[1]);
280 break; 285 break;
281 } 286 }
282 } 287 }
283 attribs.push_back(PP_GRAPHICS3DATTRIB_NONE);
284 } 288 }
285 289
290 attribs.push_back(gpu::gles2::kContextType);
291 attribs.push_back(gpu::gles2::CONTEXT_TYPE_OPENGLES2_PEPPER);
292 attribs.push_back(PP_GRAPHICS3DATTRIB_NONE);
293
286 CommandBufferProxyImpl* share_buffer = NULL; 294 CommandBufferProxyImpl* share_buffer = NULL;
287 if (share_context) { 295 if (share_context) {
288 PPB_Graphics3D_Impl* share_graphics = 296 PPB_Graphics3D_Impl* share_graphics =
289 static_cast<PPB_Graphics3D_Impl*>(share_context); 297 static_cast<PPB_Graphics3D_Impl*>(share_context);
290 share_buffer = share_graphics->GetCommandBufferProxy(); 298 share_buffer = share_graphics->GetCommandBufferProxy();
291 } 299 }
292 300
293 command_buffer_ = channel_->CreateOffscreenCommandBuffer( 301 command_buffer_ = channel_->CreateOffscreenCommandBuffer(
294 surface_size, share_buffer, GpuChannelHost::kDefaultStreamId, 302 surface_size, share_buffer, GpuChannelHost::kDefaultStreamId,
295 GpuChannelHost::kDefaultStreamPriority, attribs, GURL::EmptyGURL(), 303 GpuChannelHost::kDefaultStreamPriority, attribs, GURL::EmptyGURL(),
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
373 instance->module()->GetPluginInterface(PPP_GRAPHICS_3D_INTERFACE)); 381 instance->module()->GetPluginInterface(PPP_GRAPHICS_3D_INTERFACE));
374 // We have to check *again* that the instance exists, because it could have 382 // We have to check *again* that the instance exists, because it could have
375 // been deleted during GetPluginInterface(). Even the PluginModule could be 383 // been deleted during GetPluginInterface(). Even the PluginModule could be
376 // deleted, but in that case, the instance should also be gone, so the 384 // deleted, but in that case, the instance should also be gone, so the
377 // GetInstance check covers both cases. 385 // GetInstance check covers both cases.
378 if (ppp_graphics_3d && HostGlobals::Get()->GetInstance(this_pp_instance)) 386 if (ppp_graphics_3d && HostGlobals::Get()->GetInstance(this_pp_instance))
379 ppp_graphics_3d->Graphics3DContextLost(this_pp_instance); 387 ppp_graphics_3d->Graphics3DContextLost(this_pp_instance);
380 } 388 }
381 389
382 } // namespace content 390 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/BUILD.gn ('k') | gpu/command_buffer/common/gles2_cmd_utils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698