diff options
-rw-r--r-- | content/renderer/pepper/pepper_plugin_delegate_impl.cc | 7 | ||||
-rw-r--r-- | content/renderer/render_widget_fullscreen_pepper.cc | 5 | ||||
-rw-r--r-- | webkit/plugins/ppapi/ppapi_plugin_instance.cc | 27 | ||||
-rw-r--r-- | webkit/plugins/ppapi/ppapi_plugin_instance.h | 7 | ||||
-rw-r--r-- | webkit/plugins/ppapi/ppapi_webplugin_impl.cc | 8 | ||||
-rw-r--r-- | webkit/plugins/ppapi/ppb_graphics_2d_impl.cc | 23 |
6 files changed, 54 insertions, 23 deletions
diff --git a/content/renderer/pepper/pepper_plugin_delegate_impl.cc b/content/renderer/pepper/pepper_plugin_delegate_impl.cc index 77ced16..d36c8f4 100644 --- a/content/renderer/pepper/pepper_plugin_delegate_impl.cc +++ b/content/renderer/pepper/pepper_plugin_delegate_impl.cc @@ -542,8 +542,11 @@ PepperPluginDelegateImpl::GetBitmapForOptimizedPluginPaint( active_instances_.begin(); i != active_instances_.end(); ++i) { webkit::ppapi::PluginInstance* instance = *i; - if (instance->GetBitmapForOptimizedPluginPaint( - paint_bounds, dib, location, clip, scale_factor)) + // In Flash fullscreen , the plugin contents should be painted onto the + // fullscreen widget instead of the web page. + if (!instance->FlashIsFullscreenOrPending() && + instance->GetBitmapForOptimizedPluginPaint(paint_bounds, dib, location, + clip, scale_factor)) return *i; } return NULL; diff --git a/content/renderer/render_widget_fullscreen_pepper.cc b/content/renderer/render_widget_fullscreen_pepper.cc index f3a6fad..a6caf84 100644 --- a/content/renderer/render_widget_fullscreen_pepper.cc +++ b/content/renderer/render_widget_fullscreen_pepper.cc @@ -4,6 +4,8 @@ #include "content/renderer/render_widget_fullscreen_pepper.h" +#include <vector> + #include "base/bind.h" #include "base/command_line.h" #include "base/message_loop.h" @@ -97,7 +99,8 @@ class PepperWidget : public WebWidget { size_ = size; WebRect plugin_rect(0, 0, size_.width, size_.height); - widget_->plugin()->ViewChanged(plugin_rect, plugin_rect); + widget_->plugin()->ViewChanged(plugin_rect, plugin_rect, + std::vector<gfx::Rect>()); widget_->Invalidate(); } diff --git a/webkit/plugins/ppapi/ppapi_plugin_instance.cc b/webkit/plugins/ppapi/ppapi_plugin_instance.cc index 7cbedf0..a2cec8f 100644 --- a/webkit/plugins/ppapi/ppapi_plugin_instance.cc +++ b/webkit/plugins/ppapi/ppapi_plugin_instance.cc @@ -877,7 +877,8 @@ PP_Var PluginInstance::GetInstanceObject() { } void PluginInstance::ViewChanged(const gfx::Rect& position, - const gfx::Rect& clip) { + const gfx::Rect& clip, + const std::vector<gfx::Rect>& cut_outs_rects) { // WebKit can give weird (x,y) positions for empty clip rects (since the // position technically doesn't matter). But we want to make these // consistent since this is given to the plugin, so force everything to 0 @@ -886,6 +887,8 @@ void PluginInstance::ViewChanged(const gfx::Rect& position, if (!clip.IsEmpty()) new_clip = clip; + cut_outs_rects_ = cut_outs_rects; + ViewData previous_view = view_data_; view_data_.rect = PP_FromGfxRect(position); @@ -997,18 +1000,32 @@ bool PluginInstance::GetBitmapForOptimizedPluginPaint( // optimized this way. if (!image_data->PlatformImage()) return false; + + gfx::Point plugin_origin = PP_ToGfxPoint(view_data_.rect.point); + // Convert |paint_bounds| to be relative to the left-top corner of the plugin. + gfx::Rect relative_paint_bounds(paint_bounds); + relative_paint_bounds.Offset(-plugin_origin.x(), -plugin_origin.y()); + gfx::Rect plugin_backing_store_rect( - PP_ToGfxPoint(view_data_.rect.point), - gfx::Size(image_data->width(), image_data->height())); + 0, 0, image_data->width(), image_data->height()); gfx::Rect clip_page = PP_ToGfxRect(view_data_.clip_rect); - clip_page.Offset(PP_ToGfxPoint(view_data_.rect.point)); gfx::Rect plugin_paint_rect = plugin_backing_store_rect.Intersect(clip_page); - if (!plugin_paint_rect.Contains(paint_bounds)) + if (!plugin_paint_rect.Contains(relative_paint_bounds)) return false; + // Don't do optimized painting if the area to paint intersects with the + // cut-out rects, otherwise we will paint over them. + for (std::vector<gfx::Rect>::const_iterator iter = cut_outs_rects_.begin(); + iter != cut_outs_rects_.end(); ++iter) { + if (relative_paint_bounds.Intersects(*iter)) + return false; + } + *dib = image_data->PlatformImage()->GetTransportDIB(); + plugin_backing_store_rect.Offset(plugin_origin); *location = plugin_backing_store_rect; + clip_page.Offset(plugin_origin); *clip = clip_page; *scale_factor = GetBoundGraphics2D()->GetScale(); return true; diff --git a/webkit/plugins/ppapi/ppapi_plugin_instance.h b/webkit/plugins/ppapi/ppapi_plugin_instance.h index a221851..9594331 100644 --- a/webkit/plugins/ppapi/ppapi_plugin_instance.h +++ b/webkit/plugins/ppapi/ppapi_plugin_instance.h @@ -181,7 +181,8 @@ class WEBKIT_PLUGINS_EXPORT PluginInstance : bool HandleInputEvent(const WebKit::WebInputEvent& event, WebKit::WebCursorInfo* cursor_info); PP_Var GetInstanceObject(); - void ViewChanged(const gfx::Rect& position, const gfx::Rect& clip); + void ViewChanged(const gfx::Rect& position, const gfx::Rect& clip, + const std::vector<gfx::Rect>& cut_outs_rects); // Handlers for composition events. bool HandleCompositionStart(const string16& text); @@ -675,6 +676,10 @@ class WEBKIT_PLUGINS_EXPORT PluginInstance : // Set to true if this plugin thinks it will always be on top. This allows us // to use a more optimized painting path in some cases. bool always_on_top_; + // Even if |always_on_top_| is true, the plugin is not fully visible if there + // are some cut-out areas (occupied by iframes higher in the stacking order). + // This information is used in the optimized painting path. + std::vector<gfx::Rect> cut_outs_rects_; // Implementation of PPB_FlashFullscreen. diff --git a/webkit/plugins/ppapi/ppapi_webplugin_impl.cc b/webkit/plugins/ppapi/ppapi_webplugin_impl.cc index 298c14b..0416140 100644 --- a/webkit/plugins/ppapi/ppapi_webplugin_impl.cc +++ b/webkit/plugins/ppapi/ppapi_webplugin_impl.cc @@ -159,8 +159,12 @@ void WebPluginImpl::updateGeometry( const WebVector<WebRect>& cut_outs_rects, bool is_visible) { plugin_rect_ = window_rect; - if (!instance_->FlashIsFullscreenOrPending()) - instance_->ViewChanged(plugin_rect_, clip_rect); + if (!instance_->FlashIsFullscreenOrPending()) { + std::vector<gfx::Rect> cut_outs; + for (size_t i = 0; i < cut_outs_rects.size(); ++i) + cut_outs.push_back(cut_outs_rects[i]); + instance_->ViewChanged(plugin_rect_, clip_rect, cut_outs); + } } void WebPluginImpl::updateFocus(bool focused) { diff --git a/webkit/plugins/ppapi/ppb_graphics_2d_impl.cc b/webkit/plugins/ppapi/ppb_graphics_2d_impl.cc index d492363..5c37b95 100644 --- a/webkit/plugins/ppapi/ppb_graphics_2d_impl.cc +++ b/webkit/plugins/ppapi/ppb_graphics_2d_impl.cc @@ -544,7 +544,7 @@ void PPB_Graphics2D_Impl::Paint(WebKit::WebCanvas* canvas, plugin_rect.height(); bounds.size.width = plugin_rect.width(); bounds.size.height = plugin_rect.height(); - + // TODO(yzshen): We should take |paint_rect| into consideration as well. CGContextClipToRect(canvas, bounds); // TODO(jhorwich) Figure out if this code is even active anymore, and if so @@ -556,13 +556,14 @@ void PPB_Graphics2D_Impl::Paint(WebKit::WebCanvas* canvas, CGContextDrawImage(canvas, bitmap_rect, image); #else - SkRect sk_plugin_rect = SkRect::MakeXYWH( - SkIntToScalar(plugin_rect.origin().x()), - SkIntToScalar(plugin_rect.origin().y()), - SkIntToScalar(plugin_rect.width()), - SkIntToScalar(plugin_rect.height())); - canvas->save(); - canvas->clipRect(sk_plugin_rect); + gfx::Rect invalidate_rect = plugin_rect.Intersect(paint_rect); + SkRect sk_invalidate_rect = SkRect::MakeXYWH( + SkIntToScalar(invalidate_rect.origin().x()), + SkIntToScalar(invalidate_rect.origin().y()), + SkIntToScalar(invalidate_rect.width()), + SkIntToScalar(invalidate_rect.height())); + SkAutoCanvasRestore auto_restore(canvas, true); + canvas->clipRect(sk_invalidate_rect); PluginInstance* plugin_instance = ResourceHelper::GetPluginInstance(this); if (!plugin_instance) @@ -574,7 +575,7 @@ void PPB_Graphics2D_Impl::Paint(WebKit::WebCanvas* canvas, // show white (typically less jarring) rather than black or uninitialized. // We don't do this for non-full-frame plugins since we specifically want // the page background to show through. - canvas->save(); + SkAutoCanvasRestore auto_restore(canvas, true); SkRect image_data_rect = SkRect::MakeXYWH( SkIntToScalar(plugin_rect.origin().x()), SkIntToScalar(plugin_rect.origin().y()), @@ -585,8 +586,7 @@ void PPB_Graphics2D_Impl::Paint(WebKit::WebCanvas* canvas, SkPaint paint; paint.setXfermodeMode(SkXfermode::kSrc_Mode); paint.setColor(SK_ColorWHITE); - canvas->drawRect(sk_plugin_rect, paint); - canvas->restore(); + canvas->drawRect(sk_invalidate_rect, paint); } SkBitmap image; @@ -612,7 +612,6 @@ void PPB_Graphics2D_Impl::Paint(WebKit::WebCanvas* canvas, canvas->scale(scale_, scale_); } canvas->drawBitmap(image, origin.x(), origin.y(), &paint); - canvas->restore(); #endif } |