diff options
author | stuartmorgan@chromium.org <stuartmorgan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-06-20 18:28:54 +0000 |
---|---|---|
committer | stuartmorgan@chromium.org <stuartmorgan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-06-20 18:28:54 +0000 |
commit | 779f27e3865c5edda2bdaff1615596bfd472f27a (patch) | |
tree | 95fa12543fcbb3988e2d8e2e52e2f6b774fdf867 /webkit | |
parent | 30f0aab9a914784445191d6fdd4265155323c5b9 (diff) | |
download | chromium_src-779f27e3865c5edda2bdaff1615596bfd472f27a.zip chromium_src-779f27e3865c5edda2bdaff1615596bfd472f27a.tar.gz chromium_src-779f27e3865c5edda2bdaff1615596bfd472f27a.tar.bz2 |
Remove the fast path for QD plugins
This only ever ended up being useful for QuickTime on 10.5, so it's now useless.
BUG=125909
TEST=None
Review URL: https://chromiumcodereview.appspot.com/10579038
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@143209 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit')
-rw-r--r-- | webkit/plugins/npapi/quickdraw_drawing_manager_mac.cc | 106 | ||||
-rw-r--r-- | webkit/plugins/npapi/quickdraw_drawing_manager_mac.h | 33 | ||||
-rw-r--r-- | webkit/plugins/npapi/webplugin_delegate_impl.h | 11 | ||||
-rw-r--r-- | webkit/plugins/npapi/webplugin_delegate_impl_mac.mm | 113 |
4 files changed, 9 insertions, 254 deletions
diff --git a/webkit/plugins/npapi/quickdraw_drawing_manager_mac.cc b/webkit/plugins/npapi/quickdraw_drawing_manager_mac.cc index 26db55d..0772777 100644 --- a/webkit/plugins/npapi/quickdraw_drawing_manager_mac.cc +++ b/webkit/plugins/npapi/quickdraw_drawing_manager_mac.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -17,99 +17,28 @@ namespace webkit { namespace npapi { QuickDrawDrawingManager::QuickDrawDrawingManager() - : plugin_window_(NULL), target_context_(NULL), fast_path_enabled_(false), - current_port_(NULL), target_world_(NULL), plugin_world_(NULL) {} + : plugin_window_(NULL), target_context_(NULL), current_port_(NULL) {} QuickDrawDrawingManager::~QuickDrawDrawingManager() { - DestroyGWorlds(); -} - -void QuickDrawDrawingManager::SetFastPathEnabled(bool enabled) { - if (fast_path_enabled_ == enabled) - return; - - fast_path_enabled_ = enabled; - if (enabled) { - if (!target_world_) - UpdateGWorlds(); - // Copy our last window snapshot into our new source, since the plugin - // may not repaint everything. - CopyGWorldBits(target_world_, plugin_world_, plugin_size_); - current_port_ = plugin_world_; - } else { - current_port_ = GetWindowPort(plugin_window_); - } } void QuickDrawDrawingManager::SetTargetContext(CGContextRef context, const gfx::Size& plugin_size) { target_context_ = context; - if (plugin_size != plugin_size_) { - plugin_size_ = plugin_size; - // Pitch the old GWorlds, since they are the wrong size now. - DestroyGWorlds(); - if (fast_path_enabled_) - UpdateGWorlds(); - } + plugin_size_ = plugin_size; } void QuickDrawDrawingManager::SetPluginWindow(WindowRef window) { plugin_window_ = window; - if (!fast_path_enabled_) - current_port_ = GetWindowPort(window); + current_port_ = GetWindowPort(window); } void QuickDrawDrawingManager::UpdateContext() { - if (fast_path_enabled_) - CopyGWorldBits(plugin_world_, target_world_, plugin_size_); - else - ScrapeWindow(plugin_window_, target_context_, plugin_size_); -} - -bool QuickDrawDrawingManager::IsFastPathEnabled() { - return fast_path_enabled_; + ScrapeWindow(plugin_window_, target_context_, plugin_size_); } void QuickDrawDrawingManager::MakePortCurrent() { - if (fast_path_enabled_) - SetGWorld(current_port_, NULL); - else - SetPort(current_port_); -} - -void QuickDrawDrawingManager::DestroyGWorlds() { - if (plugin_world_) { - DisposeGWorld(plugin_world_); - plugin_world_ = NULL; - } - if (target_world_) { - DisposeGWorld(target_world_); - target_world_ = NULL; - } -} - -void QuickDrawDrawingManager::UpdateGWorlds() { - DestroyGWorlds(); - if (!target_context_) - return; - - Rect window_bounds = { - 0, 0, plugin_size_.height(), plugin_size_.width() - }; - // Create a GWorld pointing at the same bits as our target context. - if (target_context_) { - NewGWorldFromPtr( - &target_world_, k32BGRAPixelFormat, &window_bounds, NULL, NULL, 0, - static_cast<Ptr>(CGBitmapContextGetData(target_context_)), - static_cast<SInt32>(CGBitmapContextGetBytesPerRow(target_context_))); - } - // Create a GWorld for the plugin to paint into whenever it wants; since - // QuickDraw plugins don't draw at known times, they can't be allowed to draw - // directly into the shared memory. - NewGWorld(&plugin_world_, k32ARGBPixelFormat, &window_bounds, - NULL, NULL, kNativeEndianPixMap); - if (fast_path_enabled_) - current_port_ = plugin_world_; + SetPort(current_port_); } void QuickDrawDrawingManager::ScrapeWindow(WindowRef window, @@ -131,29 +60,6 @@ void QuickDrawDrawingManager::ScrapeWindow(WindowRef window, CGContextRestoreGState(target_context); } -void QuickDrawDrawingManager::CopyGWorldBits(GWorldPtr source, GWorldPtr dest, - const gfx::Size& plugin_size) { - if (!(source && dest)) - return; - - Rect window_bounds = { 0, 0, plugin_size.height(), plugin_size.width() }; - PixMapHandle source_pixmap = GetGWorldPixMap(source); - if (LockPixels(source_pixmap)) { - PixMapHandle dest_pixmap = GetGWorldPixMap(dest); - if (LockPixels(dest_pixmap)) { - SetGWorld(dest, NULL); - // Set foreground and background colors to avoid "colorizing" the image. - ForeColor(blackColor); - BackColor(whiteColor); - CopyBits(reinterpret_cast<BitMap*>(*source_pixmap), - reinterpret_cast<BitMap*>(*dest_pixmap), - &window_bounds, &window_bounds, srcCopy, NULL); - UnlockPixels(dest_pixmap); - } - UnlockPixels(source_pixmap); - } -} - } // namespace npapi } // namespace webkit diff --git a/webkit/plugins/npapi/quickdraw_drawing_manager_mac.h b/webkit/plugins/npapi/quickdraw_drawing_manager_mac.h index d574607..ba791c2 100644 --- a/webkit/plugins/npapi/quickdraw_drawing_manager_mac.h +++ b/webkit/plugins/npapi/quickdraw_drawing_manager_mac.h @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -21,21 +21,9 @@ class QuickDrawDrawingManager { QuickDrawDrawingManager(); ~QuickDrawDrawingManager(); - // Sets the mode used for plugin drawing. If enabled is true the plugin draws - // into a GWorld that's not connected to a window, otherwise the plugin draws - // into our the plugin's dummy window (which is slower, since the call we use - // to scrape the window contents is much more expensive than copying between - // GWorlds). - void SetFastPathEnabled(bool enabled); - - // Returns true if the fast path is currently enabled. - bool IsFastPathEnabled(); - // Sets the context that the plugin bits should be copied into when // UpdateContext is called. This object does not retain |context|, so the // caller must call SetTargetContext again if the context changes. - // If the fast path is currently enabled, this call will cause the port to - // change. void SetTargetContext(CGContextRef context, const gfx::Size& plugin_size); // Sets the window that is used by the plugin. This object does not own the @@ -46,8 +34,7 @@ class QuickDrawDrawingManager { void UpdateContext(); // Returns the port that the plugin should draw into. This returned port is - // only valid until the next call to SetFastPathEnabled (or SetTargetContext - // while the fast path is enabled). + // only valid until the next call to SetPluginWindow. CGrafPtr port() { return current_port_; } // Makes the QuickDraw port current; should be called before calls where the @@ -55,30 +42,14 @@ class QuickDrawDrawingManager { void MakePortCurrent(); private: - // Updates the GWorlds used by the faster path. - void UpdateGWorlds(); - - // Deletes the GWorlds used by the faster path. - void DestroyGWorlds(); - // Scrapes the contents of the window into the given context. - // Used for the slower path. static void ScrapeWindow(WindowRef window, CGContextRef target_context, const gfx::Size& plugin_size); - // Copies the source GWorld's bits into the target GWorld. - // Used for the faster path. - static void CopyGWorldBits(GWorldPtr source, GWorldPtr dest, - const gfx::Size& plugin_size); - WindowRef plugin_window_; // Weak reference. CGContextRef target_context_; // Weak reference. gfx::Size plugin_size_; - bool fast_path_enabled_; CGrafPtr current_port_; - // Variables used for the faster path: - GWorldPtr target_world_; // Created lazily; may be NULL. - GWorldPtr plugin_world_; // Created lazily; may be NULL. }; } // namespace npapi diff --git a/webkit/plugins/npapi/webplugin_delegate_impl.h b/webkit/plugins/npapi/webplugin_delegate_impl.h index c916775..ca74b1d 100644 --- a/webkit/plugins/npapi/webplugin_delegate_impl.h +++ b/webkit/plugins/npapi/webplugin_delegate_impl.h @@ -78,7 +78,6 @@ class WEBKIT_PLUGINS_EXPORT WebPluginDelegateImpl : public WebPluginDelegate { PLUGIN_QUIRK_NO_WINDOWLESS = 1024, // Windows PLUGIN_QUIRK_PATCH_REGENUMKEYEXW = 2048, // Windows PLUGIN_QUIRK_ALWAYS_NOTIFY_SUCCESS = 4096, // Windows - PLUGIN_QUIRK_ALLOW_FASTER_QUICKDRAW_PATH = 8192, // Mac PLUGIN_QUIRK_HANDLE_MOUSE_CAPTURE = 16384, // Windows PLUGIN_QUIRK_WINDOWLESS_NO_RIGHT_CLICK = 32768, // Linux PLUGIN_QUIRK_IGNORE_FIRST_SETWINDOW_CALL = 65536, // Windows. @@ -460,15 +459,6 @@ class WEBKIT_PLUGINS_EXPORT WebPluginDelegateImpl : public WebPluginDelegate { // Moves our dummy window to match the current screen location of the plugin. void UpdateDummyWindowBounds(const gfx::Point& plugin_origin); -#ifndef NP_NO_QUICKDRAW - // Sets the mode used for QuickDraw plugin drawing. If enabled is true the - // plugin draws into a GWorld that's not connected to a window (the faster - // path), otherwise the plugin draws into our invisible dummy window (which is - // slower, since the call we use to scrape the window contents is much more - // expensive than copying between GWorlds). - void SetQuickDrawFastPathEnabled(bool enabled); -#endif - // Adjusts the idle event rate for a Carbon plugin based on its current // visibility. void UpdateIdleEventRate(); @@ -483,7 +473,6 @@ class WEBKIT_PLUGINS_EXPORT WebPluginDelegateImpl : public WebPluginDelegate { #ifndef NP_NO_QUICKDRAW NP_Port qd_port_; scoped_ptr<QuickDrawDrawingManager> qd_manager_; - base::TimeTicks fast_path_enable_tick_; #endif CALayer* layer_; // Used for CA drawing mode. Weak, retained by plug-in. diff --git a/webkit/plugins/npapi/webplugin_delegate_impl_mac.mm b/webkit/plugins/npapi/webplugin_delegate_impl_mac.mm index 23f5373..65d43d5 100644 --- a/webkit/plugins/npapi/webplugin_delegate_impl_mac.mm +++ b/webkit/plugins/npapi/webplugin_delegate_impl_mac.mm @@ -314,27 +314,6 @@ bool WebPluginDelegateImpl::PlatformInitialize() { // cleanly, so don't unload them at shutdown. instance()->plugin_lib()->PreventLibraryUnload(); -#ifndef NP_NO_QUICKDRAW - if (instance()->drawing_model() == NPDrawingModelQuickDraw) { - // For some QuickDraw plugins, we can sometimes get away with giving them - // a port pointing to a pixel buffer instead of a our actual dummy window. - // This gives us much better frame rates, because the window scraping we - // normally use is very slow. - // This breaks down if the plugin does anything complicated with the port - // (as QuickTime seems to during event handling, and sometimes when painting - // its controls), so we switch on the fly as necessary. (It might be - // possible to interpose sufficiently that we wouldn't have to switch back - // and forth, but the current approach gets us most of the benefit.) - // We can't do this at all with plugins that bypass the port entirely and - // attaches their own surface to the window. - // TODO(stuartmorgan): Test other QuickDraw plugins that we support and - // see if any others can use the fast path. - const WebPluginInfo& plugin_info = instance_->plugin_lib()->plugin_info(); - if (plugin_info.name.find(ASCIIToUTF16("QuickTime")) != string16::npos) - quirks_ |= PLUGIN_QUIRK_ALLOW_FASTER_QUICKDRAW_PATH; - } -#endif - #ifndef NP_NO_CARBON if (instance()->event_model() == NPEventModelCarbon) { // Create a stand-in for the browser window so that the plugin will have @@ -569,30 +548,8 @@ bool WebPluginDelegateImpl::PlatformHandleInputEvent( #ifndef NP_NO_CARBON if (instance()->event_model() == NPEventModelCarbon) { #ifndef NP_NO_QUICKDRAW - if (instance()->drawing_model() == NPDrawingModelQuickDraw) { - if (quirks_ & PLUGIN_QUIRK_ALLOW_FASTER_QUICKDRAW_PATH) { - // Mouse event handling doesn't work correctly in the fast path mode, - // so any time we get a mouse event turn the fast path off, but set a - // time to switch it on again (we don't rely just on MouseLeave because - // we don't want poor performance in the case of clicking the play - // button and then leaving the mouse there). - // This isn't perfect (specifically, click-and-hold doesn't seem to work - // if the fast path is on), but the slight regression is worthwhile - // for the improved framerates. - if (WebInputEvent::isMouseEventType(event.type)) { - if (event.type == WebInputEvent::MouseLeave) { - SetQuickDrawFastPathEnabled(true); - } else { - SetQuickDrawFastPathEnabled(false); - } - // Make sure the plugin wasn't destroyed during the switch. - if (!instance()) - return false; - } - } - + if (instance()->drawing_model() == NPDrawingModelQuickDraw) qd_manager_->MakePortCurrent(); - } #endif if (event.type == WebInputEvent::MouseMove) { @@ -702,16 +659,6 @@ void WebPluginDelegateImpl::WindowlessUpdateGeometry( SetPluginRect(window_rect); -#ifndef NP_NO_QUICKDRAW - if (window_size_changed && qd_manager_.get() && - qd_manager_->IsFastPathEnabled()) { - // If the window size has changed, we need to turn off the fast path so that - // the full redraw goes to the window and we get a correct baseline paint. - SetQuickDrawFastPathEnabled(false); - return; // SetQuickDrawFastPathEnabled will call SetWindow for us. - } -#endif - if (window_size_changed || clip_rect_changed || force_set_window) WindowlessSetWindow(); } @@ -812,16 +759,6 @@ void WebPluginDelegateImpl::WindowlessSetWindow() { SetWindowHasFocus(initial_window_focus_); } -#ifndef NP_NO_QUICKDRAW - if ((quirks_ & PLUGIN_QUIRK_ALLOW_FASTER_QUICKDRAW_PATH) && - !qd_manager_->IsFastPathEnabled() && !clip_rect_.IsEmpty()) { - // Give the plugin a few seconds to stabilize so we get a good initial paint - // to use as a baseline, then switch to the fast path. - fast_path_enable_tick_ = base::TimeTicks::Now() + - base::TimeDelta::FromSeconds(3); - } -#endif - DCHECK(err == NPERR_NO_ERROR); } @@ -870,12 +807,6 @@ void WebPluginDelegateImpl::SetWindowHasFocus(bool has_focus) { return; containing_window_has_focus_ = has_focus; -#ifndef NP_NO_QUICKDRAW - // Make sure controls repaint with the correct look. - if (quirks_ & PLUGIN_QUIRK_ALLOW_FASTER_QUICKDRAW_PATH) - SetQuickDrawFastPathEnabled(false); -#endif - ScopedActiveDelegate active_delegate(this); switch (instance()->event_model()) { #ifndef NP_NO_CARBON @@ -1184,15 +1115,6 @@ void WebPluginDelegateImpl::FireIdleEvent() { if (!have_called_set_window_) return; -#ifndef NP_NO_QUICKDRAW - // Check whether it's time to turn the QuickDraw fast path back on. - if (!fast_path_enable_tick_.is_null() && - (base::TimeTicks::Now() > fast_path_enable_tick_)) { - SetQuickDrawFastPathEnabled(true); - fast_path_enable_tick_ = base::TimeTicks(); - } -#endif - ScopedActiveDelegate active_delegate(this); #ifndef NP_NO_QUICKDRAW @@ -1222,38 +1144,5 @@ void WebPluginDelegateImpl::FireIdleEvent() { } #endif // !NP_NO_CARBON -#pragma mark - -#pragma mark QuickDraw Support - -#ifndef NP_NO_QUICKDRAW -void WebPluginDelegateImpl::SetQuickDrawFastPathEnabled(bool enabled) { - if (!enabled) { - // Wait a couple of seconds, then turn the fast path back on. If we're - // turning it off for event handling, that ensures that the common case of - // move-mouse-then-click works (as well as making it likely that a second - // click attempt will work if the first one fails). If we're turning it - // off to force a new baseline image, this leaves plenty of time for the - // plugin to draw. - fast_path_enable_tick_ = base::TimeTicks::Now() + - base::TimeDelta::FromSeconds(2); - } - - if (enabled == qd_manager_->IsFastPathEnabled()) - return; - if (enabled && clip_rect_.IsEmpty()) { - // Don't switch to the fast path while the plugin is completely clipped; - // we can only switch when the window has an up-to-date image for us to - // scrape. We'll automatically switch after we become visible again. - return; - } - - qd_manager_->SetFastPathEnabled(enabled); - qd_port_.port = qd_manager_->port(); - WindowlessSetWindow(); - // Send a paint event so that the new buffer gets updated immediately. - WindowlessPaint(buffer_context_, clip_rect_); -} -#endif // !NP_NO_QUICKDRAW - } // namespace npapi } // namespace webkit |