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

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

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