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 ec4091e848c0502aeb5b0afdc42267359f3a06b1..aab50783fd836f861219e1dd49d42b1bf7a49aa6 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" |
@@ -524,6 +525,7 @@ PepperPluginInstanceImpl::PepperPluginInstanceImpl( |
full_frame_(false), |
sent_initial_did_change_view_(false), |
bound_graphics_2d_platform_(NULL), |
+ bound_compositor_(NULL), |
has_webkit_focus_(false), |
has_content_area_focus_(false), |
find_identifier_(-1), |
@@ -731,11 +733,14 @@ void PepperPluginInstanceImpl::InvalidateRect(const gfx::Rect& rect) { |
else |
container_->invalidateRect(rect); |
} |
- if (texture_layer_) { |
+ |
+ cc::Layer* layer = |
+ texture_layer_ ? texture_layer_.get() : compositor_layer_.get(); |
+ if (layer) { |
if (rect.IsEmpty()) { |
- texture_layer_->SetNeedsDisplay(); |
+ layer->SetNeedsDisplay(); |
} else { |
- texture_layer_->SetNeedsDisplayRect(rect); |
+ layer->SetNeedsDisplayRect(rect); |
} |
} |
} |
@@ -743,7 +748,9 @@ void PepperPluginInstanceImpl::InvalidateRect(const gfx::Rect& rect) { |
void PepperPluginInstanceImpl::ScrollRect(int dx, |
int dy, |
const gfx::Rect& rect) { |
- if (texture_layer_) { |
+ cc::Layer* layer = |
+ texture_layer_ ? texture_layer_.get() : compositor_layer_.get(); |
+ if (layer) { |
InvalidateRect(rect); |
} else if (fullscreen_container_) { |
fullscreen_container_->ScrollRect(dx, dy, rect); |
@@ -1277,6 +1284,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() { |
@@ -1286,6 +1295,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( |
@@ -1986,24 +1997,28 @@ 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_) && |
+ (want_compositor_layer == !!compositor_layer_) && |
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()); |
@@ -2018,18 +2033,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(); |
@@ -2211,6 +2234,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) { |
@@ -2229,10 +2256,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); |
+ } else { |
+ DLOG(ERROR) << |
+ "Resource is not PepperCompositorHost or PepperGraphics2DHost."; |
+ } |
} |
EnterResourceNoLock<PPB_Graphics3D_API> enter_3d(device, false); |
@@ -2241,7 +2274,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(); |