diff options
-rw-r--r-- | chrome/renderer/render_widget_fullscreen_pepper.cc | 4 | ||||
-rw-r--r-- | webkit/glue/plugins/pepper_fullscreen_container.h | 3 | ||||
-rw-r--r-- | webkit/glue/plugins/pepper_graphics_2d.cc | 36 | ||||
-rw-r--r-- | webkit/glue/plugins/pepper_plugin_instance.cc | 14 | ||||
-rw-r--r-- | webkit/glue/plugins/pepper_plugin_instance.h | 5 |
5 files changed, 48 insertions, 14 deletions
diff --git a/chrome/renderer/render_widget_fullscreen_pepper.cc b/chrome/renderer/render_widget_fullscreen_pepper.cc index 8ab647e..a16d0b8 100644 --- a/chrome/renderer/render_widget_fullscreen_pepper.cc +++ b/chrome/renderer/render_widget_fullscreen_pepper.cc @@ -145,6 +145,10 @@ class WidgetFullscreenContainer : public pepper::FullscreenContainer { widget_->didInvalidateRect(rect); } + virtual void ScrollRect(int dx, int dy, const WebKit::WebRect& rect) { + widget_->didScrollRect(dx, dy, rect); + } + virtual void Destroy() { widget_->SendClose(); } diff --git a/webkit/glue/plugins/pepper_fullscreen_container.h b/webkit/glue/plugins/pepper_fullscreen_container.h index 5f67538..7d86320 100644 --- a/webkit/glue/plugins/pepper_fullscreen_container.h +++ b/webkit/glue/plugins/pepper_fullscreen_container.h @@ -23,6 +23,9 @@ class FullscreenContainer { // Invalidates a partial region of the plugin. virtual void InvalidateRect(const WebKit::WebRect&) = 0; + // Scrolls a partial region of the plugin in the given direction. + virtual void ScrollRect(int dx, int dy, const WebKit::WebRect&) = 0; + // Destroys the fullscreen window. This also destroys the FullscreenContainer // instance. virtual void Destroy() = 0; diff --git a/webkit/glue/plugins/pepper_graphics_2d.cc b/webkit/glue/plugins/pepper_graphics_2d.cc index af6bc57..720d1d8 100644 --- a/webkit/glue/plugins/pepper_graphics_2d.cc +++ b/webkit/glue/plugins/pepper_graphics_2d.cc @@ -334,7 +334,7 @@ int32_t Graphics2D::Flush(const PP_CompletionCallback& callback) { if (!callback.func) return PP_ERROR_BADARGUMENT; - gfx::Rect changed_rect; + bool nothing_visible = true; for (size_t i = 0; i < queued_operations_.size(); i++) { QueuedOperation& operation = queued_operations_[i]; gfx::Rect op_rect; @@ -354,26 +354,34 @@ int32_t Graphics2D::Flush(const PP_CompletionCallback& callback) { ExecuteReplaceContents(operation.replace_image, &op_rect); break; } - changed_rect = changed_rect.Union(op_rect); + + // We need the rect to be in terms of the current clip rect of the plugin + // since that's what will actually be painted. If we issue an invalidate + // for a clipped-out region, WebKit will do nothing and we won't get any + // ViewInitiatedPaint/ViewFlushedPaint calls, leaving our callback stranded. + gfx::Rect visible_changed_rect; + if (bound_instance_ && !op_rect.IsEmpty()) + visible_changed_rect = bound_instance_->clip().Intersect(op_rect); + + if (bound_instance_ && !visible_changed_rect.IsEmpty()) { + if (operation.type == QueuedOperation::SCROLL) { + bound_instance_->ScrollRect(operation.scroll_dx, operation.scroll_dy, + visible_changed_rect); + } else { + bound_instance_->InvalidateRect(visible_changed_rect); + } + nothing_visible = false; + } } queued_operations_.clear(); flushed_any_data_ = true; - // We need the rect to be in terms of the current clip rect of the plugin - // since that's what will actually be painted. If we issue an invalidate - // for a clipped-out region, WebKit will do nothing and we won't get any - // ViewInitiatedPaint/ViewFlushedPaint calls, leaving our callback stranded. - gfx::Rect visible_changed_rect; - if (bound_instance_ && !changed_rect.IsEmpty()) - visible_changed_rect = bound_instance_->clip().Intersect(changed_rect); - - if (bound_instance_ && !visible_changed_rect.IsEmpty()) { - unpainted_flush_callback_.Set(callback); - bound_instance_->InvalidateRect(visible_changed_rect); - } else { + if (nothing_visible) { // There's nothing visible to invalidate so just schedule the callback to // execute in the next round of the message loop. ScheduleOffscreenCallback(FlushCallbackData(callback)); + } else { + unpainted_flush_callback_.Set(callback); } return PP_ERROR_WOULDBLOCK; } diff --git a/webkit/glue/plugins/pepper_plugin_instance.cc b/webkit/glue/plugins/pepper_plugin_instance.cc index 9267e81..f735591 100644 --- a/webkit/glue/plugins/pepper_plugin_instance.cc +++ b/webkit/glue/plugins/pepper_plugin_instance.cc @@ -358,6 +358,20 @@ void PluginInstance::InvalidateRect(const gfx::Rect& rect) { } } +void PluginInstance::ScrollRect(int dx, int dy, const gfx::Rect& rect) { + if (fullscreen_container_) { + fullscreen_container_->ScrollRect(dx, dy, rect); + } else { + if (full_frame_) { + container_->scrollRect(dx, dy, rect); + } else { + // Can't do optimized scrolling since there could be other elements on top + // of us. + InvalidateRect(rect); + } + } +} + PP_Var PluginInstance::GetWindowObject() { if (!container_) return PP_MakeUndefined(); diff --git a/webkit/glue/plugins/pepper_plugin_instance.h b/webkit/glue/plugins/pepper_plugin_instance.h index fd0bbde..c348f66 100644 --- a/webkit/glue/plugins/pepper_plugin_instance.h +++ b/webkit/glue/plugins/pepper_plugin_instance.h @@ -100,6 +100,11 @@ class PluginInstance : public base::RefCounted<PluginInstance> { // invalidate the entire plugin. void InvalidateRect(const gfx::Rect& rect); + // Schedules a scroll of the plugin. This uses optimized scrolling only for + // full-frame plugins, as otherwise there could be other elements on top. The + // slow path can also be triggered if there is an overlapping frame. + void ScrollRect(int dx, int dy, const gfx::Rect& rect); + // PPB_Instance implementation. PP_Var GetWindowObject(); PP_Var GetOwnerElementObject(); |