Chromium Code Reviews| Index: content/renderer/pepper/pepper_plugin_instance_impl.cc |
| diff --git a/content/renderer/pepper/pepper_plugin_instance_impl.cc b/content/renderer/pepper/pepper_plugin_instance_impl.cc |
| index c1bc651ca3a128eccc9af186294680e5c88f15f9..736de25e6033f5d797474210f75fa308502b16f4 100644 |
| --- a/content/renderer/pepper/pepper_plugin_instance_impl.cc |
| +++ b/content/renderer/pepper/pepper_plugin_instance_impl.cc |
| @@ -35,6 +35,7 @@ |
| #include "content/renderer/pepper/message_channel.h" |
| #include "content/renderer/pepper/npapi_glue.h" |
| #include "content/renderer/pepper/pepper_browser_connection.h" |
| +#include "content/renderer/pepper/pepper_compositor_host.h" |
| #include "content/renderer/pepper/pepper_file_ref_renderer_host.h" |
| #include "content/renderer/pepper/pepper_graphics_2d_host.h" |
| #include "content/renderer/pepper/pepper_in_process_router.h" |
| @@ -522,7 +523,9 @@ PepperPluginInstanceImpl::PepperPluginInstanceImpl( |
| plugin_url_(plugin_url), |
| full_frame_(false), |
| sent_initial_did_change_view_(false), |
| + bound_graphics_3d_(NULL), |
|
piman
2014/06/04 13:19:43
nit: it's a scoped_refptr, no need to initialize e
Peng
2014/06/05 00:50:38
Done.
|
| bound_graphics_2d_platform_(NULL), |
| + bound_compositor_(NULL), |
| has_webkit_focus_(false), |
| has_content_area_focus_(false), |
| find_identifier_(-1), |
| @@ -730,11 +733,14 @@ void PepperPluginInstanceImpl::InvalidateRect(const gfx::Rect& rect) { |
| else |
| container_->invalidateRect(rect); |
| } |
| - if (texture_layer_) { |
| + scoped_refptr<cc::Layer> layer = texture_layer_ ? |
| + static_cast<scoped_refptr<cc::Layer> >(texture_layer_) : |
| + static_cast<scoped_refptr<cc::Layer> >(compositor_layer_); |
|
piman
2014/06/04 13:19:43
no need for static_cast in either case.
cc::Layer*
Peng
2014/06/05 00:50:38
Done.
|
| + if (layer) { |
| if (rect.IsEmpty()) { |
| - texture_layer_->SetNeedsDisplay(); |
| + layer->SetNeedsDisplay(); |
| } else { |
| - texture_layer_->SetNeedsDisplayRect(rect); |
| + layer->SetNeedsDisplayRect(rect); |
| } |
| } |
| } |
| @@ -742,7 +748,10 @@ void PepperPluginInstanceImpl::InvalidateRect(const gfx::Rect& rect) { |
| void PepperPluginInstanceImpl::ScrollRect(int dx, |
| int dy, |
| const gfx::Rect& rect) { |
| - if (texture_layer_) { |
| + scoped_refptr<cc::Layer> layer = texture_layer_ ? |
| + static_cast<scoped_refptr<cc::Layer> >(texture_layer_) : |
| + static_cast<scoped_refptr<cc::Layer> >(compositor_layer_); |
|
piman
2014/06/04 13:19:43
ditto
Peng
2014/06/05 00:50:38
Done.
|
| + if (layer) { |
| InvalidateRect(rect); |
| } else if (fullscreen_container_) { |
| fullscreen_container_->ScrollRect(dx, dy, rect); |
| @@ -1276,6 +1285,8 @@ void PepperPluginInstanceImpl::ViewInitiatedPaint() { |
| bound_graphics_2d_platform_->ViewInitiatedPaint(); |
| else if (bound_graphics_3d_.get()) |
| bound_graphics_3d_->ViewInitiatedPaint(); |
| + else if (bound_compositor_) |
| + bound_compositor_->ViewInitiatedPaint(); |
| } |
| void PepperPluginInstanceImpl::ViewFlushedPaint() { |
| @@ -1285,6 +1296,8 @@ void PepperPluginInstanceImpl::ViewFlushedPaint() { |
| bound_graphics_2d_platform_->ViewFlushedPaint(); |
| else if (bound_graphics_3d_.get()) |
| bound_graphics_3d_->ViewFlushedPaint(); |
| + else if (bound_compositor_) |
| + bound_compositor_->ViewFlushedPaint(); |
| } |
| void PepperPluginInstanceImpl::SetSelectedText( |
| @@ -1970,24 +1983,27 @@ void PepperPluginInstanceImpl::UpdateLayer() { |
| } |
| bool want_3d_layer = !mailbox.IsZero(); |
| bool want_2d_layer = !!bound_graphics_2d_platform_; |
| - bool want_layer = want_3d_layer || want_2d_layer; |
| + bool want_texture_layer = want_3d_layer || want_2d_layer; |
| + bool want_compositor_layer = !!bound_compositor_; |
| - if ((want_layer == !!texture_layer_.get()) && |
| + if ((want_texture_layer == !!texture_layer_.get()) && |
| (want_3d_layer == layer_is_hardware_) && |
|
piman
2014/06/04 13:19:43
you want another early out for want_compositor_lay
Peng
2014/06/05 00:50:38
Done.
|
| layer_bound_to_fullscreen_ == !!fullscreen_container_) { |
| UpdateLayerTransform(); |
| return; |
| } |
| - if (texture_layer_) { |
| + if (texture_layer_ || compositor_layer_) { |
| if (!layer_bound_to_fullscreen_) |
| container_->setWebLayer(NULL); |
| else if (fullscreen_container_) |
| fullscreen_container_->SetLayer(NULL); |
| web_layer_.reset(); |
| texture_layer_ = NULL; |
| + compositor_layer_ = NULL; |
| } |
| - if (want_layer) { |
| + |
| + if (want_texture_layer) { |
| bool opaque = false; |
| if (want_3d_layer) { |
| DCHECK(bound_graphics_3d_.get()); |
| @@ -2002,18 +2018,26 @@ void PepperPluginInstanceImpl::UpdateLayer() { |
| opaque = bound_graphics_2d_platform_->IsAlwaysOpaque(); |
| texture_layer_->SetFlipped(false); |
| } |
| + |
| + // Ignore transparency in fullscreen, since that's what Flash always |
| + // wants to do, and that lets it not recreate a context if |
| + // wmode=transparent was specified. |
| + opaque = opaque || fullscreen_container_; |
| + texture_layer_->SetContentsOpaque(opaque); |
| web_layer_.reset(new webkit::WebLayerImpl(texture_layer_)); |
| + } else if (want_compositor_layer) { |
| + compositor_layer_ = bound_compositor_->layer(); |
| + web_layer_.reset(new webkit::WebLayerImpl(compositor_layer_)); |
| + } |
| + |
| + if (web_layer_) { |
| if (fullscreen_container_) { |
| fullscreen_container_->SetLayer(web_layer_.get()); |
| - // Ignore transparency in fullscreen, since that's what Flash always |
| - // wants to do, and that lets it not recreate a context if |
| - // wmode=transparent was specified. |
| - texture_layer_->SetContentsOpaque(true); |
| } else { |
| container_->setWebLayer(web_layer_.get()); |
| - texture_layer_->SetContentsOpaque(opaque); |
| } |
| } |
| + |
| layer_bound_to_fullscreen_ = !!fullscreen_container_; |
| layer_is_hardware_ = want_3d_layer; |
| UpdateLayerTransform(); |
| @@ -2195,6 +2219,10 @@ PP_Bool PepperPluginInstanceImpl::BindGraphics(PP_Instance instance, |
| bound_graphics_2d_platform_->BindToInstance(NULL); |
| bound_graphics_2d_platform_ = NULL; |
| } |
| + if (bound_compositor_) { |
| + bound_compositor_->BindToInstance(NULL); |
| + bound_compositor_ = NULL; |
| + } |
| // Special-case clearing the current device. |
| if (!device) { |
| @@ -2213,10 +2241,16 @@ PP_Bool PepperPluginInstanceImpl::BindGraphics(PP_Instance instance, |
| RendererPpapiHost::GetForPPInstance(instance)->GetPpapiHost(); |
| ppapi::host::ResourceHost* host = ppapi_host->GetResourceHost(device); |
| PepperGraphics2DHost* graphics_2d = NULL; |
| + PepperCompositorHost* compositor = NULL; |
| if (host) { |
| - if (host->IsGraphics2DHost()) |
| + if (host->IsGraphics2DHost()) { |
| graphics_2d = static_cast<PepperGraphics2DHost*>(host); |
| - DLOG_IF(ERROR, !graphics_2d) << "Resource is not PepperGraphics2DHost."; |
| + } else if (host->IsCompositorHost()) { |
| + compositor = static_cast <PepperCompositorHost*>(host); |
|
piman
2014/06/04 13:19:43
nit: no space after static_cast
Peng
2014/06/05 00:50:38
Done.
|
| + } else { |
| + DLOG(ERROR) << |
| + "Resource is not PepperCompositorHost or PepperGraphics2DHost."; |
| + } |
| } |
| EnterResourceNoLock<PPB_Graphics3D_API> enter_3d(device, false); |
| @@ -2225,7 +2259,13 @@ PP_Bool PepperPluginInstanceImpl::BindGraphics(PP_Instance instance, |
| ? static_cast<PPB_Graphics3D_Impl*>(enter_3d.object()) |
| : NULL; |
| - if (graphics_2d) { |
| + if (compositor) { |
| + if (compositor->BindToInstance(this)) { |
| + bound_compositor_ = compositor; |
| + UpdateLayer(); |
| + return PP_TRUE; |
| + } |
| + } else if (graphics_2d) { |
| if (graphics_2d->BindToInstance(this)) { |
| bound_graphics_2d_platform_ = graphics_2d; |
| UpdateLayer(); |