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

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

Issue 849723002: Plugin Power Saver: Make PepperPluginInstanceThrottler interface public. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 11 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/pepper/ppb_audio_impl.cc ('k') | content/renderer/render_frame_impl.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/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
11 #include "content/common/gpu/client/command_buffer_proxy_impl.h" 11 #include "content/common/gpu/client/command_buffer_proxy_impl.h"
12 #include "content/common/gpu/client/gpu_channel_host.h" 12 #include "content/common/gpu/client/gpu_channel_host.h"
13 #include "content/public/common/content_switches.h" 13 #include "content/public/common/content_switches.h"
14 #include "content/public/common/web_preferences.h" 14 #include "content/public/common/web_preferences.h"
15 #include "content/renderer/pepper/host_globals.h" 15 #include "content/renderer/pepper/host_globals.h"
16 #include "content/renderer/pepper/pepper_plugin_instance_impl.h" 16 #include "content/renderer/pepper/pepper_plugin_instance_impl.h"
17 #include "content/renderer/pepper/pepper_plugin_instance_throttler.h" 17 #include "content/renderer/pepper/plugin_instance_throttler_impl.h"
18 #include "content/renderer/pepper/plugin_module.h" 18 #include "content/renderer/pepper/plugin_module.h"
19 #include "content/renderer/render_thread_impl.h" 19 #include "content/renderer/render_thread_impl.h"
20 #include "content/renderer/render_view_impl.h" 20 #include "content/renderer/render_view_impl.h"
21 #include "gpu/command_buffer/client/gles2_implementation.h" 21 #include "gpu/command_buffer/client/gles2_implementation.h"
22 #include "ppapi/c/ppp_graphics_3d.h" 22 #include "ppapi/c/ppp_graphics_3d.h"
23 #include "ppapi/thunk/enter.h" 23 #include "ppapi/thunk/enter.h"
24 #include "third_party/WebKit/public/platform/WebString.h" 24 #include "third_party/WebKit/public/platform/WebString.h"
25 #include "third_party/WebKit/public/web/WebConsoleMessage.h" 25 #include "third_party/WebKit/public/web/WebConsoleMessage.h"
26 #include "third_party/WebKit/public/web/WebDocument.h" 26 #include "third_party/WebKit/public/web/WebDocument.h"
27 #include "third_party/WebKit/public/web/WebElement.h" 27 #include "third_party/WebKit/public/web/WebElement.h"
28 #include "third_party/WebKit/public/web/WebLocalFrame.h" 28 #include "third_party/WebKit/public/web/WebLocalFrame.h"
29 #include "third_party/WebKit/public/web/WebPluginContainer.h" 29 #include "third_party/WebKit/public/web/WebPluginContainer.h"
30 30
31 using ppapi::thunk::EnterResourceNoLock; 31 using ppapi::thunk::EnterResourceNoLock;
32 using ppapi::thunk::PPB_Graphics3D_API; 32 using ppapi::thunk::PPB_Graphics3D_API;
33 using blink::WebConsoleMessage; 33 using blink::WebConsoleMessage;
34 using blink::WebLocalFrame; 34 using blink::WebLocalFrame;
35 using blink::WebPluginContainer; 35 using blink::WebPluginContainer;
36 using blink::WebString; 36 using blink::WebString;
37 37
38 namespace content { 38 namespace content {
39 39
40 namespace { 40 namespace {
41
41 const int32 kCommandBufferSize = 1024 * 1024; 42 const int32 kCommandBufferSize = 1024 * 1024;
42 const int32 kTransferBufferSize = 1024 * 1024; 43 const int32 kTransferBufferSize = 1024 * 1024;
43 44
44 } // namespace. 45 } // namespace
45 46
46 PPB_Graphics3D_Impl::PPB_Graphics3D_Impl(PP_Instance instance) 47 PPB_Graphics3D_Impl::PPB_Graphics3D_Impl(PP_Instance instance)
47 : PPB_Graphics3D_Shared(instance), 48 : PPB_Graphics3D_Shared(instance),
48 bound_to_instance_(false), 49 bound_to_instance_(false),
49 commit_pending_(false), 50 commit_pending_(false),
50 sync_point_(0), 51 sync_point_(0),
51 has_alpha_(false), 52 has_alpha_(false),
52 command_buffer_(NULL), 53 command_buffer_(NULL),
53 weak_ptr_factory_(this) {} 54 weak_ptr_factory_(this) {}
54 55
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 return false; 236 return false;
236 237
237 const WebPreferences& prefs = 238 const WebPreferences& prefs =
238 static_cast<RenderViewImpl*>(plugin_instance->GetRenderView()) 239 static_cast<RenderViewImpl*>(plugin_instance->GetRenderView())
239 ->webkit_preferences(); 240 ->webkit_preferences();
240 // 3D access might be disabled or blacklisted. 241 // 3D access might be disabled or blacklisted.
241 if (!prefs.pepper_3d_enabled) 242 if (!prefs.pepper_3d_enabled)
242 return false; 243 return false;
243 244
244 // Force SW rendering for keyframe extraction to avoid pixel reads from VRAM. 245 // Force SW rendering for keyframe extraction to avoid pixel reads from VRAM.
245 PepperPluginInstanceThrottler* throttler = plugin_instance->throttler(); 246 PluginInstanceThrottlerImpl* throttler = plugin_instance->throttler();
246 if (throttler && throttler->needs_representative_keyframe()) 247 if (throttler && throttler->needs_representative_keyframe())
247 return false; 248 return false;
248 249
249 RenderThreadImpl* render_thread = RenderThreadImpl::current(); 250 RenderThreadImpl* render_thread = RenderThreadImpl::current();
250 if (!render_thread) 251 if (!render_thread)
251 return false; 252 return false;
252 253
253 channel_ = render_thread->EstablishGpuChannelSync( 254 channel_ = render_thread->EstablishGpuChannelSync(
254 CAUSE_FOR_GPU_LAUNCH_PEPPERPLATFORMCONTEXT3DIMPL_INITIALIZE); 255 CAUSE_FOR_GPU_LAUNCH_PEPPERPLATFORMCONTEXT3DIMPL_INITIALIZE);
255 if (!channel_.get()) 256 if (!channel_.get())
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
377 instance->module()->GetPluginInterface(PPP_GRAPHICS_3D_INTERFACE)); 378 instance->module()->GetPluginInterface(PPP_GRAPHICS_3D_INTERFACE));
378 // 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
379 // been deleted during GetPluginInterface(). Even the PluginModule could be 380 // been deleted during GetPluginInterface(). Even the PluginModule could be
380 // 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
381 // GetInstance check covers both cases. 382 // GetInstance check covers both cases.
382 if (ppp_graphics_3d && HostGlobals::Get()->GetInstance(this_pp_instance)) 383 if (ppp_graphics_3d && HostGlobals::Get()->GetInstance(this_pp_instance))
383 ppp_graphics_3d->Graphics3DContextLost(this_pp_instance); 384 ppp_graphics_3d->Graphics3DContextLost(this_pp_instance);
384 } 385 }
385 386
386 } // namespace content 387 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/pepper/ppb_audio_impl.cc ('k') | content/renderer/render_frame_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698