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

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

Issue 331123003: Revert 277208 "[PPAPI] Compositor API implementation." (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 6 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 | Annotate | Revision Log
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/pepper_plugin_instance_impl.h" 5 #include "content/renderer/pepper/pepper_plugin_instance_impl.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/callback_helpers.h" 8 #include "base/callback_helpers.h"
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/debug/trace_event.h" 10 #include "base/debug/trace_event.h"
(...skipping 17 matching lines...) Expand all
28 #include "content/renderer/pepper/common.h" 28 #include "content/renderer/pepper/common.h"
29 #include "content/renderer/pepper/content_decryptor_delegate.h" 29 #include "content/renderer/pepper/content_decryptor_delegate.h"
30 #include "content/renderer/pepper/event_conversion.h" 30 #include "content/renderer/pepper/event_conversion.h"
31 #include "content/renderer/pepper/fullscreen_container.h" 31 #include "content/renderer/pepper/fullscreen_container.h"
32 #include "content/renderer/pepper/gfx_conversion.h" 32 #include "content/renderer/pepper/gfx_conversion.h"
33 #include "content/renderer/pepper/host_dispatcher_wrapper.h" 33 #include "content/renderer/pepper/host_dispatcher_wrapper.h"
34 #include "content/renderer/pepper/host_globals.h" 34 #include "content/renderer/pepper/host_globals.h"
35 #include "content/renderer/pepper/message_channel.h" 35 #include "content/renderer/pepper/message_channel.h"
36 #include "content/renderer/pepper/npapi_glue.h" 36 #include "content/renderer/pepper/npapi_glue.h"
37 #include "content/renderer/pepper/pepper_browser_connection.h" 37 #include "content/renderer/pepper/pepper_browser_connection.h"
38 #include "content/renderer/pepper/pepper_compositor_host.h"
39 #include "content/renderer/pepper/pepper_file_ref_renderer_host.h" 38 #include "content/renderer/pepper/pepper_file_ref_renderer_host.h"
40 #include "content/renderer/pepper/pepper_graphics_2d_host.h" 39 #include "content/renderer/pepper/pepper_graphics_2d_host.h"
41 #include "content/renderer/pepper/pepper_in_process_router.h" 40 #include "content/renderer/pepper/pepper_in_process_router.h"
42 #include "content/renderer/pepper/pepper_url_loader_host.h" 41 #include "content/renderer/pepper/pepper_url_loader_host.h"
43 #include "content/renderer/pepper/plugin_module.h" 42 #include "content/renderer/pepper/plugin_module.h"
44 #include "content/renderer/pepper/plugin_object.h" 43 #include "content/renderer/pepper/plugin_object.h"
45 #include "content/renderer/pepper/ppb_buffer_impl.h" 44 #include "content/renderer/pepper/ppb_buffer_impl.h"
46 #include "content/renderer/pepper/ppb_graphics_3d_impl.h" 45 #include "content/renderer/pepper/ppb_graphics_3d_impl.h"
47 #include "content/renderer/pepper/ppb_image_data_impl.h" 46 #include "content/renderer/pepper/ppb_image_data_impl.h"
48 #include "content/renderer/pepper/renderer_ppapi_host_impl.h" 47 #include "content/renderer/pepper/renderer_ppapi_host_impl.h"
(...skipping 469 matching lines...) Expand 10 before | Expand all | Expand 10 after
518 module_(module), 517 module_(module),
519 instance_interface_(instance_interface), 518 instance_interface_(instance_interface),
520 pp_instance_(0), 519 pp_instance_(0),
521 container_(container), 520 container_(container),
522 layer_bound_to_fullscreen_(false), 521 layer_bound_to_fullscreen_(false),
523 layer_is_hardware_(false), 522 layer_is_hardware_(false),
524 plugin_url_(plugin_url), 523 plugin_url_(plugin_url),
525 full_frame_(false), 524 full_frame_(false),
526 sent_initial_did_change_view_(false), 525 sent_initial_did_change_view_(false),
527 bound_graphics_2d_platform_(NULL), 526 bound_graphics_2d_platform_(NULL),
528 bound_compositor_(NULL),
529 has_webkit_focus_(false), 527 has_webkit_focus_(false),
530 has_content_area_focus_(false), 528 has_content_area_focus_(false),
531 find_identifier_(-1), 529 find_identifier_(-1),
532 plugin_find_interface_(NULL), 530 plugin_find_interface_(NULL),
533 plugin_input_event_interface_(NULL), 531 plugin_input_event_interface_(NULL),
534 plugin_mouse_lock_interface_(NULL), 532 plugin_mouse_lock_interface_(NULL),
535 plugin_pdf_interface_(NULL), 533 plugin_pdf_interface_(NULL),
536 plugin_private_interface_(NULL), 534 plugin_private_interface_(NULL),
537 plugin_selection_interface_(NULL), 535 plugin_selection_interface_(NULL),
538 plugin_textinput_interface_(NULL), 536 plugin_textinput_interface_(NULL),
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
726 fullscreen_container_->InvalidateRect(rect); 724 fullscreen_container_->InvalidateRect(rect);
727 } else { 725 } else {
728 if (!container_ || view_data_.rect.size.width == 0 || 726 if (!container_ || view_data_.rect.size.width == 0 ||
729 view_data_.rect.size.height == 0) 727 view_data_.rect.size.height == 0)
730 return; // Nothing to do. 728 return; // Nothing to do.
731 if (rect.IsEmpty()) 729 if (rect.IsEmpty())
732 container_->invalidate(); 730 container_->invalidate();
733 else 731 else
734 container_->invalidateRect(rect); 732 container_->invalidateRect(rect);
735 } 733 }
736 734 if (texture_layer_) {
737 cc::Layer* layer =
738 texture_layer_ ? texture_layer_.get() : compositor_layer_.get();
739 if (layer) {
740 if (rect.IsEmpty()) { 735 if (rect.IsEmpty()) {
741 layer->SetNeedsDisplay(); 736 texture_layer_->SetNeedsDisplay();
742 } else { 737 } else {
743 layer->SetNeedsDisplayRect(rect); 738 texture_layer_->SetNeedsDisplayRect(rect);
744 } 739 }
745 } 740 }
746 } 741 }
747 742
748 void PepperPluginInstanceImpl::ScrollRect(int dx, 743 void PepperPluginInstanceImpl::ScrollRect(int dx,
749 int dy, 744 int dy,
750 const gfx::Rect& rect) { 745 const gfx::Rect& rect) {
751 cc::Layer* layer = 746 if (texture_layer_) {
752 texture_layer_ ? texture_layer_.get() : compositor_layer_.get();
753 if (layer) {
754 InvalidateRect(rect); 747 InvalidateRect(rect);
755 } else if (fullscreen_container_) { 748 } else if (fullscreen_container_) {
756 fullscreen_container_->ScrollRect(dx, dy, rect); 749 fullscreen_container_->ScrollRect(dx, dy, rect);
757 } else { 750 } else {
758 if (full_frame_ && !IsViewAccelerated()) { 751 if (full_frame_ && !IsViewAccelerated()) {
759 container_->scrollRect(dx, dy, rect); 752 container_->scrollRect(dx, dy, rect);
760 } else { 753 } else {
761 // Can't do optimized scrolling since there could be other elements on top 754 // Can't do optimized scrolling since there could be other elements on top
762 // of us or the view renders via the accelerated compositor which is 755 // of us or the view renders via the accelerated compositor which is
763 // incompatible with the move and backfill scrolling model. 756 // incompatible with the move and backfill scrolling model.
(...skipping 513 matching lines...) Expand 10 before | Expand all | Expand 10 after
1277 // |view_data_| haven't been properly initialized. 1270 // |view_data_| haven't been properly initialized.
1278 if (sent_initial_did_change_view_) 1271 if (sent_initial_did_change_view_)
1279 SendDidChangeView(); 1272 SendDidChangeView();
1280 } 1273 }
1281 1274
1282 void PepperPluginInstanceImpl::ViewInitiatedPaint() { 1275 void PepperPluginInstanceImpl::ViewInitiatedPaint() {
1283 if (bound_graphics_2d_platform_) 1276 if (bound_graphics_2d_platform_)
1284 bound_graphics_2d_platform_->ViewInitiatedPaint(); 1277 bound_graphics_2d_platform_->ViewInitiatedPaint();
1285 else if (bound_graphics_3d_.get()) 1278 else if (bound_graphics_3d_.get())
1286 bound_graphics_3d_->ViewInitiatedPaint(); 1279 bound_graphics_3d_->ViewInitiatedPaint();
1287 else if (bound_compositor_)
1288 bound_compositor_->ViewInitiatedPaint();
1289 } 1280 }
1290 1281
1291 void PepperPluginInstanceImpl::ViewFlushedPaint() { 1282 void PepperPluginInstanceImpl::ViewFlushedPaint() {
1292 // Keep a reference on the stack. See NOTE above. 1283 // Keep a reference on the stack. See NOTE above.
1293 scoped_refptr<PepperPluginInstanceImpl> ref(this); 1284 scoped_refptr<PepperPluginInstanceImpl> ref(this);
1294 if (bound_graphics_2d_platform_) 1285 if (bound_graphics_2d_platform_)
1295 bound_graphics_2d_platform_->ViewFlushedPaint(); 1286 bound_graphics_2d_platform_->ViewFlushedPaint();
1296 else if (bound_graphics_3d_.get()) 1287 else if (bound_graphics_3d_.get())
1297 bound_graphics_3d_->ViewFlushedPaint(); 1288 bound_graphics_3d_->ViewFlushedPaint();
1298 else if (bound_compositor_)
1299 bound_compositor_->ViewFlushedPaint();
1300 } 1289 }
1301 1290
1302 void PepperPluginInstanceImpl::SetSelectedText( 1291 void PepperPluginInstanceImpl::SetSelectedText(
1303 const base::string16& selected_text) { 1292 const base::string16& selected_text) {
1304 selected_text_ = selected_text; 1293 selected_text_ = selected_text;
1305 } 1294 }
1306 1295
1307 void PepperPluginInstanceImpl::SetLinkUnderCursor(const std::string& url) { 1296 void PepperPluginInstanceImpl::SetLinkUnderCursor(const std::string& url) {
1308 link_under_cursor_ = base::UTF8ToUTF16(url); 1297 link_under_cursor_ = base::UTF8ToUTF16(url);
1309 } 1298 }
(...skipping 680 matching lines...) Expand 10 before | Expand all | Expand 10 after
1990 return; 1979 return;
1991 1980
1992 gpu::Mailbox mailbox; 1981 gpu::Mailbox mailbox;
1993 uint32 sync_point = 0; 1982 uint32 sync_point = 0;
1994 if (bound_graphics_3d_.get()) { 1983 if (bound_graphics_3d_.get()) {
1995 bound_graphics_3d_->GetBackingMailbox(&mailbox, &sync_point); 1984 bound_graphics_3d_->GetBackingMailbox(&mailbox, &sync_point);
1996 DCHECK_EQ(mailbox.IsZero(), sync_point == 0); 1985 DCHECK_EQ(mailbox.IsZero(), sync_point == 0);
1997 } 1986 }
1998 bool want_3d_layer = !mailbox.IsZero(); 1987 bool want_3d_layer = !mailbox.IsZero();
1999 bool want_2d_layer = !!bound_graphics_2d_platform_; 1988 bool want_2d_layer = !!bound_graphics_2d_platform_;
2000 bool want_texture_layer = want_3d_layer || want_2d_layer; 1989 bool want_layer = want_3d_layer || want_2d_layer;
2001 bool want_compositor_layer = !!bound_compositor_;
2002 1990
2003 if ((want_texture_layer == !!texture_layer_.get()) && 1991 if ((want_layer == !!texture_layer_.get()) &&
2004 (want_3d_layer == layer_is_hardware_) && 1992 (want_3d_layer == layer_is_hardware_) &&
2005 (want_compositor_layer == !!compositor_layer_) &&
2006 layer_bound_to_fullscreen_ == !!fullscreen_container_) { 1993 layer_bound_to_fullscreen_ == !!fullscreen_container_) {
2007 UpdateLayerTransform(); 1994 UpdateLayerTransform();
2008 return; 1995 return;
2009 } 1996 }
2010 1997
2011 if (texture_layer_ || compositor_layer_) { 1998 if (texture_layer_) {
2012 if (!layer_bound_to_fullscreen_) 1999 if (!layer_bound_to_fullscreen_)
2013 container_->setWebLayer(NULL); 2000 container_->setWebLayer(NULL);
2014 else if (fullscreen_container_) 2001 else if (fullscreen_container_)
2015 fullscreen_container_->SetLayer(NULL); 2002 fullscreen_container_->SetLayer(NULL);
2016 web_layer_.reset(); 2003 web_layer_.reset();
2017 texture_layer_ = NULL; 2004 texture_layer_ = NULL;
2018 compositor_layer_ = NULL;
2019 } 2005 }
2020 2006 if (want_layer) {
2021 if (want_texture_layer) {
2022 bool opaque = false; 2007 bool opaque = false;
2023 if (want_3d_layer) { 2008 if (want_3d_layer) {
2024 DCHECK(bound_graphics_3d_.get()); 2009 DCHECK(bound_graphics_3d_.get());
2025 texture_layer_ = cc::TextureLayer::CreateForMailbox(NULL); 2010 texture_layer_ = cc::TextureLayer::CreateForMailbox(NULL);
2026 opaque = bound_graphics_3d_->IsOpaque(); 2011 opaque = bound_graphics_3d_->IsOpaque();
2027 texture_layer_->SetTextureMailboxWithoutReleaseCallback( 2012 texture_layer_->SetTextureMailboxWithoutReleaseCallback(
2028 cc::TextureMailbox(mailbox, GL_TEXTURE_2D, sync_point)); 2013 cc::TextureMailbox(mailbox, GL_TEXTURE_2D, sync_point));
2029 } else { 2014 } else {
2030 DCHECK(bound_graphics_2d_platform_); 2015 DCHECK(bound_graphics_2d_platform_);
2031 texture_layer_ = cc::TextureLayer::CreateForMailbox(this); 2016 texture_layer_ = cc::TextureLayer::CreateForMailbox(this);
2032 bound_graphics_2d_platform_->AttachedToNewLayer(); 2017 bound_graphics_2d_platform_->AttachedToNewLayer();
2033 opaque = bound_graphics_2d_platform_->IsAlwaysOpaque(); 2018 opaque = bound_graphics_2d_platform_->IsAlwaysOpaque();
2034 texture_layer_->SetFlipped(false); 2019 texture_layer_->SetFlipped(false);
2035 } 2020 }
2036
2037 // Ignore transparency in fullscreen, since that's what Flash always
2038 // wants to do, and that lets it not recreate a context if
2039 // wmode=transparent was specified.
2040 opaque = opaque || fullscreen_container_;
2041 texture_layer_->SetContentsOpaque(opaque);
2042 web_layer_.reset(new webkit::WebLayerImpl(texture_layer_)); 2021 web_layer_.reset(new webkit::WebLayerImpl(texture_layer_));
2043 } else if (want_compositor_layer) {
2044 compositor_layer_ = bound_compositor_->layer();
2045 web_layer_.reset(new webkit::WebLayerImpl(compositor_layer_));
2046 }
2047
2048 if (web_layer_) {
2049 if (fullscreen_container_) { 2022 if (fullscreen_container_) {
2050 fullscreen_container_->SetLayer(web_layer_.get()); 2023 fullscreen_container_->SetLayer(web_layer_.get());
2024 // Ignore transparency in fullscreen, since that's what Flash always
2025 // wants to do, and that lets it not recreate a context if
2026 // wmode=transparent was specified.
2027 texture_layer_->SetContentsOpaque(true);
2051 } else { 2028 } else {
2052 container_->setWebLayer(web_layer_.get()); 2029 container_->setWebLayer(web_layer_.get());
2030 texture_layer_->SetContentsOpaque(opaque);
2053 } 2031 }
2054 } 2032 }
2055
2056 layer_bound_to_fullscreen_ = !!fullscreen_container_; 2033 layer_bound_to_fullscreen_ = !!fullscreen_container_;
2057 layer_is_hardware_ = want_3d_layer; 2034 layer_is_hardware_ = want_3d_layer;
2058 UpdateLayerTransform(); 2035 UpdateLayerTransform();
2059 } 2036 }
2060 2037
2061 bool PepperPluginInstanceImpl::PrepareTextureMailbox( 2038 bool PepperPluginInstanceImpl::PrepareTextureMailbox(
2062 cc::TextureMailbox* mailbox, 2039 cc::TextureMailbox* mailbox,
2063 scoped_ptr<cc::SingleReleaseCallback>* release_callback, 2040 scoped_ptr<cc::SingleReleaseCallback>* release_callback,
2064 bool use_shared_memory) { 2041 bool use_shared_memory) {
2065 if (!bound_graphics_2d_platform_) 2042 if (!bound_graphics_2d_platform_)
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
2227 // UpdateLayer(). 2204 // UpdateLayer().
2228 scoped_refptr<ppapi::Resource> old_graphics = bound_graphics_3d_.get(); 2205 scoped_refptr<ppapi::Resource> old_graphics = bound_graphics_3d_.get();
2229 if (bound_graphics_3d_.get()) { 2206 if (bound_graphics_3d_.get()) {
2230 bound_graphics_3d_->BindToInstance(false); 2207 bound_graphics_3d_->BindToInstance(false);
2231 bound_graphics_3d_ = NULL; 2208 bound_graphics_3d_ = NULL;
2232 } 2209 }
2233 if (bound_graphics_2d_platform_) { 2210 if (bound_graphics_2d_platform_) {
2234 bound_graphics_2d_platform_->BindToInstance(NULL); 2211 bound_graphics_2d_platform_->BindToInstance(NULL);
2235 bound_graphics_2d_platform_ = NULL; 2212 bound_graphics_2d_platform_ = NULL;
2236 } 2213 }
2237 if (bound_compositor_) {
2238 bound_compositor_->BindToInstance(NULL);
2239 bound_compositor_ = NULL;
2240 }
2241 2214
2242 // Special-case clearing the current device. 2215 // Special-case clearing the current device.
2243 if (!device) { 2216 if (!device) {
2244 UpdateLayer(); 2217 UpdateLayer();
2245 InvalidateRect(gfx::Rect()); 2218 InvalidateRect(gfx::Rect());
2246 return PP_TRUE; 2219 return PP_TRUE;
2247 } 2220 }
2248 2221
2249 // Refuse to bind if in transition to fullscreen with PPB_FlashFullscreen or 2222 // Refuse to bind if in transition to fullscreen with PPB_FlashFullscreen or
2250 // to/from fullscreen with PPB_Fullscreen. 2223 // to/from fullscreen with PPB_Fullscreen.
2251 if ((fullscreen_container_ && !flash_fullscreen_) || 2224 if ((fullscreen_container_ && !flash_fullscreen_) ||
2252 desired_fullscreen_state_ != view_data_.is_fullscreen) 2225 desired_fullscreen_state_ != view_data_.is_fullscreen)
2253 return PP_FALSE; 2226 return PP_FALSE;
2254 2227
2255 const ppapi::host::PpapiHost* ppapi_host = 2228 const ppapi::host::PpapiHost* ppapi_host =
2256 RendererPpapiHost::GetForPPInstance(instance)->GetPpapiHost(); 2229 RendererPpapiHost::GetForPPInstance(instance)->GetPpapiHost();
2257 ppapi::host::ResourceHost* host = ppapi_host->GetResourceHost(device); 2230 ppapi::host::ResourceHost* host = ppapi_host->GetResourceHost(device);
2258 PepperGraphics2DHost* graphics_2d = NULL; 2231 PepperGraphics2DHost* graphics_2d = NULL;
2259 PepperCompositorHost* compositor = NULL;
2260 if (host) { 2232 if (host) {
2261 if (host->IsGraphics2DHost()) { 2233 if (host->IsGraphics2DHost())
2262 graphics_2d = static_cast<PepperGraphics2DHost*>(host); 2234 graphics_2d = static_cast<PepperGraphics2DHost*>(host);
2263 } else if (host->IsCompositorHost()) { 2235 DLOG_IF(ERROR, !graphics_2d) << "Resource is not PepperGraphics2DHost.";
2264 compositor = static_cast<PepperCompositorHost*>(host);
2265 } else {
2266 DLOG(ERROR) <<
2267 "Resource is not PepperCompositorHost or PepperGraphics2DHost.";
2268 }
2269 } 2236 }
2270 2237
2271 EnterResourceNoLock<PPB_Graphics3D_API> enter_3d(device, false); 2238 EnterResourceNoLock<PPB_Graphics3D_API> enter_3d(device, false);
2272 PPB_Graphics3D_Impl* graphics_3d = 2239 PPB_Graphics3D_Impl* graphics_3d =
2273 enter_3d.succeeded() 2240 enter_3d.succeeded()
2274 ? static_cast<PPB_Graphics3D_Impl*>(enter_3d.object()) 2241 ? static_cast<PPB_Graphics3D_Impl*>(enter_3d.object())
2275 : NULL; 2242 : NULL;
2276 2243
2277 if (compositor) { 2244 if (graphics_2d) {
2278 if (compositor->BindToInstance(this)) {
2279 bound_compositor_ = compositor;
2280 UpdateLayer();
2281 return PP_TRUE;
2282 }
2283 } else if (graphics_2d) {
2284 if (graphics_2d->BindToInstance(this)) { 2245 if (graphics_2d->BindToInstance(this)) {
2285 bound_graphics_2d_platform_ = graphics_2d; 2246 bound_graphics_2d_platform_ = graphics_2d;
2286 UpdateLayer(); 2247 UpdateLayer();
2287 return PP_TRUE; 2248 return PP_TRUE;
2288 } 2249 }
2289 } else if (graphics_3d) { 2250 } else if (graphics_3d) {
2290 // Make sure graphics can only be bound to the instance it is 2251 // Make sure graphics can only be bound to the instance it is
2291 // associated with. 2252 // associated with.
2292 if (graphics_3d->pp_instance() == pp_instance() && 2253 if (graphics_3d->pp_instance() == pp_instance() &&
2293 graphics_3d->BindToInstance(true)) { 2254 graphics_3d->BindToInstance(true)) {
(...skipping 978 matching lines...) Expand 10 before | Expand all | Expand 10 after
3272 // Running out-of-process. Initiate an IPC call to notify the plugin 3233 // Running out-of-process. Initiate an IPC call to notify the plugin
3273 // process. 3234 // process.
3274 ppapi::proxy::HostDispatcher* dispatcher = 3235 ppapi::proxy::HostDispatcher* dispatcher =
3275 ppapi::proxy::HostDispatcher::GetForInstance(pp_instance()); 3236 ppapi::proxy::HostDispatcher::GetForInstance(pp_instance());
3276 dispatcher->Send(new PpapiMsg_PPPInstance_HandleDocumentLoad( 3237 dispatcher->Send(new PpapiMsg_PPPInstance_HandleDocumentLoad(
3277 ppapi::API_ID_PPP_INSTANCE, pp_instance(), pending_host_id, data)); 3238 ppapi::API_ID_PPP_INSTANCE, pp_instance(), pending_host_id, data));
3278 } 3239 }
3279 } 3240 }
3280 3241
3281 } // namespace content 3242 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/pepper/pepper_plugin_instance_impl.h ('k') | ppapi/examples/compositor/compositor.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698