diff options
author | stuartmorgan@google.com <stuartmorgan@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-27 19:30:32 +0000 |
---|---|---|
committer | stuartmorgan@google.com <stuartmorgan@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-27 19:30:32 +0000 |
commit | 4be98628a79d54152176eaf829916a4eb5e6777c (patch) | |
tree | b36c0db6734482cb1247d85da9c8a74afa044b71 | |
parent | 9abc1b14a6042d4575d2817b275acb6c241ec543 (diff) | |
download | chromium_src-4be98628a79d54152176eaf829916a4eb5e6777c.zip chromium_src-4be98628a79d54152176eaf829916a4eb5e6777c.tar.gz chromium_src-4be98628a79d54152176eaf829916a4eb5e6777c.tar.bz2 |
Fix partial plugin invalidate repainting on Mac.
The transport canvas and the backing store canvas are upside down relative to eachother, so the rects need some massaging.
BUG=none
TEST=YouTube videos should play without sections drawing in the wrong place, and plugins scrolled partially offscreen should draw the right section.
Review URL: http://codereview.chromium.org/159423
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@21681 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/plugin/webplugin_proxy.cc | 1 | ||||
-rw-r--r-- | chrome/renderer/webplugin_delegate_proxy.cc | 17 | ||||
-rw-r--r-- | webkit/glue/plugins/webplugin_delegate_impl_mac.mm | 27 |
3 files changed, 30 insertions, 15 deletions
diff --git a/chrome/plugin/webplugin_proxy.cc b/chrome/plugin/webplugin_proxy.cc index b98cc93..32102d3 100644 --- a/chrome/plugin/webplugin_proxy.cc +++ b/chrome/plugin/webplugin_proxy.cc @@ -540,7 +540,6 @@ void WebPluginProxy::UpdateTransform() { } #elif defined(OS_MACOSX) void WebPluginProxy::UpdateTransform() { - NOTIMPLEMENTED(); } void WebPluginProxy::SetWindowlessBuffer( diff --git a/chrome/renderer/webplugin_delegate_proxy.cc b/chrome/renderer/webplugin_delegate_proxy.cc index 03b2b57..b6ea8dd 100644 --- a/chrome/renderer/webplugin_delegate_proxy.cc +++ b/chrome/renderer/webplugin_delegate_proxy.cc @@ -498,6 +498,14 @@ bool WebPluginDelegateProxy::CreateBitmap( return true; } +#if defined(OS_MACOSX) +// Flips |rect| vertically within an enclosing rect with height |height|. +// Intended for converting rects between flipped and non-flipped contexts. +static void FlipRectVerticallyWithHeight(gfx::Rect* rect, int height) { + rect->set_y(height - rect->y() - rect->height()); +} +#endif + void WebPluginDelegateProxy::Paint(gfx::NativeDrawingContext context, const gfx::Rect& damaged_rect) { // If the plugin is no longer connected (channel crashed) draw a crashed @@ -535,6 +543,9 @@ void WebPluginDelegateProxy::Paint(gfx::NativeDrawingContext context, CopyFromTransportToBacking(offset_rect); } +#if defined(OS_MACOSX) + FlipRectVerticallyWithHeight(&offset_rect, plugin_rect_.height()); +#endif BlitCanvasToContext(context, rect, backing_store_canvas_.get(), offset_rect.origin()); @@ -906,7 +917,11 @@ void WebPluginDelegateProxy::CopyFromTransportToBacking(const gfx::Rect& rect) { } // Copy the damaged rect from the transport bitmap to the backing store. - BlitCanvasToCanvas(backing_store_canvas_.get(), rect, + gfx::Rect dest_rect = rect; +#if defined(OS_MACOSX) + FlipRectVerticallyWithHeight(&dest_rect, plugin_rect_.height()); +#endif + BlitCanvasToCanvas(backing_store_canvas_.get(), dest_rect, transport_store_canvas_.get(), rect.origin()); backing_store_painted_ = backing_store_painted_.Union(rect); } diff --git a/webkit/glue/plugins/webplugin_delegate_impl_mac.mm b/webkit/glue/plugins/webplugin_delegate_impl_mac.mm index 409122f..7a900b8 100644 --- a/webkit/glue/plugins/webplugin_delegate_impl_mac.mm +++ b/webkit/glue/plugins/webplugin_delegate_impl_mac.mm @@ -258,14 +258,14 @@ void WebPluginDelegateImpl::WindowlessUpdateGeometry( if (window_rect_ != window_rect) { window_rect_ = window_rect; - window_.clipRect.top = clip_rect_.y(); - window_.clipRect.left = clip_rect_.x(); - window_.clipRect.bottom = clip_rect_.y() + clip_rect_.height(); - window_.clipRect.right = clip_rect_.x() + clip_rect_.width(); + window_.clipRect.top = 0; + window_.clipRect.left = 0; + window_.clipRect.bottom = window_rect_.height(); + window_.clipRect.right = window_rect_.width(); window_.height = window_rect_.height(); window_.width = window_rect_.width(); - window_.x = window_rect_.x(); - window_.y = window_rect_.y(); + window_.x = 0; + window_.y = 0; window_.type = NPWindowTypeDrawable; windowless_needs_set_window_ = true; } @@ -282,8 +282,8 @@ void WebPluginDelegateImpl::WindowlessPaint(gfx::NativeDrawingContext context, [NSGraphicsContext setCurrentContext:[NSGraphicsContext graphicsContextWithGraphicsPort:context flipped:NO]]; - CGContextSaveGState(context); + cg_context_.context = context; window_.window = &cg_context_; window_.type = NPWindowTypeDrawable; @@ -322,6 +322,7 @@ void WebPluginDelegateImpl::WindowlessPaint(gfx::NativeDrawingContext context, paint_event.where.v = 0; paint_event.modifiers = 0; instance()->NPP_HandleEvent(&paint_event); + CGContextRestoreGState(context); [NSGraphicsContext restoreGraphicsState]; } @@ -333,14 +334,14 @@ void WebPluginDelegateImpl::WindowlessSetWindow(bool force_set_window) { if (window_rect_.IsEmpty()) // wait for geometry to be set. return; - window_.clipRect.top = clip_rect_.y(); - window_.clipRect.left = clip_rect_.x(); - window_.clipRect.bottom = clip_rect_.y() + clip_rect_.height(); - window_.clipRect.right = clip_rect_.x() + clip_rect_.width(); + window_.clipRect.top = 0; + window_.clipRect.left = 0; + window_.clipRect.bottom = window_rect_.height(); + window_.clipRect.right = window_rect_.width(); window_.height = window_rect_.height(); window_.width = window_rect_.width(); - window_.x = window_rect_.x(); - window_.y = window_rect_.y(); + window_.x = 0; + window_.y = 0; window_.type = NPWindowTypeDrawable; if (!force_set_window) |