diff options
author | pinkerton@chromium.org <pinkerton@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-10 14:36:51 +0000 |
---|---|---|
committer | pinkerton@chromium.org <pinkerton@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-10 14:36:51 +0000 |
commit | 4ac0a0958a86c3310f36745cf9bb08ced79f7336 (patch) | |
tree | 2a2a2192048478df67beb18e841c904a9c95d989 /webkit/glue | |
parent | f8ee26e45e8a04bb75a3e7b0449b8acf3efb04e2 (diff) | |
download | chromium_src-4ac0a0958a86c3310f36745cf9bb08ced79f7336.zip chromium_src-4ac0a0958a86c3310f36745cf9bb08ced79f7336.tar.gz chromium_src-4ac0a0958a86c3310f36745cf9bb08ced79f7336.tar.bz2 |
Revert 41158 - Implement the CoreAnimation drawing model for plugins, sharing IPC and some rendering code with the GPU Plugin. The drawing model negotiation is currently disabled so this should have no visible impact to plugins.
BUG=32012
TEST=make sure the pepper GPU plugins still work.
Review URL: http://codereview.chromium.org/673001
TBR=pinkerton@chromium.org
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@41159 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/glue')
-rw-r--r-- | webkit/glue/plugins/plugin_host.cc | 42 | ||||
-rw-r--r-- | webkit/glue/plugins/webplugin_delegate_impl.h | 39 | ||||
-rw-r--r-- | webkit/glue/plugins/webplugin_delegate_impl_mac.mm | 93 | ||||
-rw-r--r-- | webkit/glue/webplugin.h | 20 |
4 files changed, 15 insertions, 179 deletions
diff --git a/webkit/glue/plugins/plugin_host.cc b/webkit/glue/plugins/plugin_host.cc index 4cd5b3b..0db965c 100644 --- a/webkit/glue/plugins/plugin_host.cc +++ b/webkit/glue/plugins/plugin_host.cc @@ -9,9 +9,6 @@ #include "base/scoped_ptr.h" #include "base/string_piece.h" #include "base/string_util.h" -#if defined(OS_MACOSX) -#include "base/sys_info.h" -#endif #include "base/sys_string_conversions.h" #include "net/base/net_util.h" #include "third_party/WebKit/WebKit/chromium/public/WebBindings.h" @@ -39,21 +36,6 @@ static NPAPI::PluginInstance* FindInstance(NPP id) { return reinterpret_cast<NPAPI::PluginInstance*>(id->ndata); } -#if defined(OS_MACOSX) -// Returns true if the OS supports shared accelerated surfaces via IOSurface. -// This is true on Snow Leopard and higher. -static bool SupportsSharingAcceleratedSurfaces() { - int32 major, minor, bugfix; - base::SysInfo::OperatingSystemVersionNumbers(&major, &minor, &bugfix); -#if PINK_USE_COREANIMATION - // TODO(pinkerton): enable this, http://crbug.com/32012 - return major > 10 || (major == 10 && minor > 5); -#else - return false; -#endif -} -#endif - namespace NPAPI { scoped_refptr<PluginHost> PluginHost::singleton_; @@ -775,10 +757,7 @@ NPError NPN_GetValue(NPP id, NPNVariable variable, void* value) { } #ifndef NP_NO_QUICKDRAW case NPNVsupportsQuickDrawBool: { - // We do not admit to supporting the QuickDraw drawing model. The logic - // here is that our QuickDraw plugin support is so rudimentary that we - // only want to use it as a fallback to keep plugins from crashing: if a - // plugin knows enough to ask, we want them to use CoreGraphics. + // we do not admit to supporting the QuickDraw drawing model. NPBool* supports_qd = reinterpret_cast<NPBool*>(value); *supports_qd = FALSE; rv = NPERR_NO_ERROR; @@ -796,16 +775,9 @@ NPError NPN_GetValue(NPP id, NPNVariable variable, void* value) { rv = NPERR_NO_ERROR; break; } + case NPNVsupportsOpenGLBool: case NPNVsupportsCoreAnimationBool: { - // We only support the Core Animation model on 10.6 and higher - NPBool* supports_model = reinterpret_cast<NPBool*>(value); - *supports_model = SupportsSharingAcceleratedSurfaces() ? TRUE : FALSE; - rv = NPERR_NO_ERROR; - break; - } - case NPNVsupportsOpenGLBool: { - // This drawing model was never widely supported, and we don't plan to - // support it. + // we do not support these drawing and event models. NPBool* supports_model = reinterpret_cast<NPBool*>(value); *supports_model = FALSE; rv = NPERR_NO_ERROR; @@ -866,14 +838,14 @@ NPError NPN_SetValue(NPP id, NPPVariable variable, void* value) { return NPERR_GENERIC_ERROR; #if defined(OS_MACOSX) case NPPVpluginDrawingModel: { + // We only admit to supporting the CoreGraphics drawing model. The logic + // here is that our QuickDraw plugin support is so rudimentary that we + // only want to use it as a fallback to keep plugins from crashing: if + // a plugin knows enough to ask, we want them to use CoreGraphics. int model = reinterpret_cast<int>(value); if (model == NPDrawingModelCoreGraphics) { plugin->set_drawing_model(model); return NPERR_NO_ERROR; - } else if (model == NPDrawingModelCoreAnimation && - SupportsSharingAcceleratedSurfaces()) { - plugin->set_drawing_model(model); - return NPERR_NO_ERROR; } return NPERR_GENERIC_ERROR; } diff --git a/webkit/glue/plugins/webplugin_delegate_impl.h b/webkit/glue/plugins/webplugin_delegate_impl.h index 8cf0d03..1327464 100644 --- a/webkit/glue/plugins/webplugin_delegate_impl.h +++ b/webkit/glue/plugins/webplugin_delegate_impl.h @@ -16,15 +16,10 @@ #include "base/gfx/rect.h" #include "base/ref_counted.h" #include "base/task.h" -#include "base/timer.h" #include "third_party/npapi/bindings/npapi.h" #include "webkit/glue/webcursor.h" #include "webkit/glue/webplugin_delegate.h" -#if defined(OS_MACOSX) -#include "chrome/common/accelerated_surface_mac.h" -#endif - #if defined(USE_X11) typedef struct _GdkDrawable GdkPixmap; #endif @@ -37,19 +32,8 @@ namespace WebKit { class WebMouseEvent; } -#if defined(OS_MACOSX) -class CoreAnimationRedrawTimerSource; -#ifdef __OBJC__ -@class CALayer; -@class CARenderer; -#else -class CALayer; -class CARenderer; -#endif -#endif - -// An implementation of WebPluginDelegate that runs in the plugin process, -// proxied from the renderer by WebPluginDelegateProxy. +// An implementation of WebPluginDelegate that proxies all calls to +// the plugin process. class WebPluginDelegateImpl : public webkit_glue::WebPluginDelegate { public: enum PluginQuirks { @@ -162,12 +146,6 @@ class WebPluginDelegateImpl : public webkit_glue::WebPluginDelegate { // Informs the delegate that the plugin set a Cocoa NSCursor. void SetNSCursor(NSCursor* cursor); - // Informs the browser about the updated accelerated drawing surface. - void UpdateAcceleratedSurface(); - - // Uses a CARenderer to draw the plug-in's layer in our OpenGL surface. - void DrawLayerInSurface(); - #ifndef NP_NO_CARBON // Indicates that it's time to send the plugin a null event. void FireIdleEvent(); @@ -179,11 +157,10 @@ class WebPluginDelegateImpl : public webkit_glue::WebPluginDelegate { } #if defined(OS_MACOSX) - // Allow setting a "fake" window handle to associate this plug-in with - // an IOSurface in the browser. Used for accelerated drawing surfaces. + // On Mac OS X and for the GPU plugin only, this handle is a fake + // one and comes in from the outside world. void set_windowed_handle(gfx::PluginWindowHandle handle) { windowed_handle_ = handle; - UpdateAcceleratedSurface(); } #endif @@ -267,7 +244,7 @@ class WebPluginDelegateImpl : public webkit_glue::WebPluginDelegate { // used for windowed plugins // Note: on Mac OS X, the only time the windowed handle is non-zero - // is the case of accelerated rendering, which uses a fake window handle to + // is the case of the GPU plugin, which uses a fake window handle to // identify itself back to the browser. It still performs all of its // work offscreen. gfx::PluginWindowHandle windowed_handle_; @@ -324,10 +301,6 @@ class WebPluginDelegateImpl : public webkit_glue::WebPluginDelegate { #ifndef NP_NO_QUICKDRAW NP_Port qd_port_; #endif - CALayer* layer_; // Used for CA drawing mode. Weak, retained by plug-in. - AcceleratedSurface surface_; - CARenderer* renderer_; // Renders layer_ to surface_. - scoped_ptr<base::RepeatingTimer<WebPluginDelegateImpl> > redraw_timer_; #endif gfx::Rect window_rect_; gfx::Rect clip_rect_; @@ -383,7 +356,7 @@ class WebPluginDelegateImpl : public webkit_glue::WebPluginDelegate { #ifndef NP_NO_CARBON // Moves our dummy window to match the current screen location of the plugin. void UpdateDummyWindowBounds(const gfx::Point& plugin_origin); - + #ifndef NP_NO_QUICKDRAW // Scrapes the contents of our dummy window into the given context. void ScrapeDummyWindowIntoContext(CGContextRef context); diff --git a/webkit/glue/plugins/webplugin_delegate_impl_mac.mm b/webkit/glue/plugins/webplugin_delegate_impl_mac.mm index c944c64..0a1e84e 100644 --- a/webkit/glue/plugins/webplugin_delegate_impl_mac.mm +++ b/webkit/glue/plugins/webplugin_delegate_impl_mac.mm @@ -3,7 +3,6 @@ // found in the LICENSE file. #import <Cocoa/Cocoa.h> -#import <QuartzCore/QuartzCore.h> #include "webkit/glue/plugins/webplugin_delegate_impl.h" @@ -17,6 +16,7 @@ #include "base/scoped_ptr.h" #include "base/stats_counters.h" #include "base/string_util.h" +#include "base/timer.h" #include "third_party/WebKit/WebKit/chromium/public/WebInputEvent.h" #include "webkit/default_plugin/plugin_impl.h" #include "webkit/glue/webplugin.h" @@ -49,8 +49,6 @@ using WebKit::WebInputEvent; using WebKit::WebMouseEvent; using WebKit::WebMouseWheelEvent; -const int kCoreAnimationRedrawPeriodMs = 20; // 50fps - // Important implementation notes: The Mac definition of NPAPI, particularly // the distinction between windowed and windowless modes, differs from the // Windows and Linux definitions. Most of those differences are @@ -171,21 +169,16 @@ class CarbonIdleEventSource { } // namespace -#pragma mark - - WebPluginDelegateImpl::WebPluginDelegateImpl( gfx::PluginWindowHandle containing_view, NPAPI::PluginInstance *instance) - : windowed_handle_(NULL), - windowless_needs_set_window_(true), + : windowless_needs_set_window_(true), // all Mac plugins are "windowless" in the Windows/X11 sense windowless_(true), plugin_(NULL), instance_(instance), parent_(containing_view), buffer_context_(NULL), - layer_(nil), - renderer_(nil), quirks_(0), have_focus_(false), focus_notifier_(NULL), @@ -263,31 +256,6 @@ void WebPluginDelegateImpl::PlatformInitialize() { #endif window_.type = NPWindowTypeDrawable; break; - case NPDrawingModelCoreAnimation: { // Assumes Cocoa event model. - window_.type = NPWindowTypeDrawable; - // Ask the plug-in for the CALayer it created for rendering content. Have - // the renderer tell the browser to create a "windowed plugin" to host - // the IOSurface. The surface itself will be created when the plug-in - // is sized. - CALayer* layer = nil; - NPError err = instance()->NPP_GetValue(NPPVpluginCoreAnimationLayer, - reinterpret_cast<void*>(&layer)); - if (!err) { - layer_ = layer; - plugin_->BindFakePluginWindowHandle(); - surface_.Initialize(); - UpdateAcceleratedSurface(); - renderer_ = [[CARenderer rendererWithCGLContext:surface_.context() - options:NULL] retain]; - [renderer_ setLayer:layer_]; - redraw_timer_.reset(new base::RepeatingTimer<WebPluginDelegateImpl>); - redraw_timer_->Start( - base::TimeDelta::FromMilliseconds(kCoreAnimationRedrawPeriodMs), - this, - &WebPluginDelegateImpl::DrawLayerInSurface); - } - break; - } default: NOTREACHED(); break; @@ -318,12 +286,6 @@ void WebPluginDelegateImpl::PlatformDestroyInstance() { if (instance()->event_model() == NPEventModelCarbon) CarbonIdleEventSource::SharedInstance()->UnregisterDelegate(this); #endif - if (redraw_timer_.get()) - redraw_timer_->Stop(); - [renderer_ release]; - renderer_ = nil; - layer_ = nil; - surface_.Destroy(); } void WebPluginDelegateImpl::UpdateGeometryAndContext( @@ -417,32 +379,8 @@ void WebPluginDelegateImpl::WindowlessUpdateGeometry( WindowlessSetWindow(true); } -void WebPluginDelegateImpl::DrawLayerInSurface() { - surface_.MakeCurrent(); - - surface_.Clear(window_rect_); - - // Ensure all changes are made before rendering. Not sure where the |-begin| - // comes from, but not doing this causes nothing to render. - [CATransaction commit]; - [renderer_ beginFrameAtTime:CACurrentMediaTime() timeStamp:NULL]; - CGRect layerRect = [layer_ bounds]; - [renderer_ addUpdateRect:layerRect]; - [renderer_ render]; - [renderer_ endFrame]; - - surface_.SwapBuffers(); - plugin_->AcceleratedFrameBuffersDidSwap(windowed_handle()); -} - void WebPluginDelegateImpl::WindowlessPaint(gfx::NativeDrawingContext context, const gfx::Rect& damage_rect) { - // There is currently nothing to do for the Core Animation drawing model, - // but there have been discussions on the plugin-futures mailing list that - // might require future work. - if (instance()->drawing_model() == NPDrawingModelCoreAnimation) - return; - // If we somehow get a paint before we've set up the plugin buffer, bail. if (!buffer_context_) return; @@ -520,8 +458,6 @@ void WebPluginDelegateImpl::WindowlessSetWindow(bool force_set_window) { SetWindowHasFocus(initial_window_focus_); } - UpdateAcceleratedSurface(); - DCHECK(err == NPERR_NO_ERROR); } @@ -644,30 +580,6 @@ void WebPluginDelegateImpl::SetContainerVisibility(bool is_visible) { } } -// Generate an IOSurface for accelerated drawing (but only in the case where a -// window handle has been set). Once the surface has been updated for the -// current size of the plug-in, tell the browser host view so it can adjust its -// bookkeeping and CALayer appropriately. -void WebPluginDelegateImpl::UpdateAcceleratedSurface() { - // Will only have a window handle when using the CoreAnimation drawing model. - if (!windowed_handle() || - instance()->drawing_model() != NPDrawingModelCoreAnimation) - return; - - [layer_ setFrame:CGRectMake(0, 0, - window_rect_.width(), window_rect_.height())]; - [renderer_ setBounds:[layer_ bounds]]; - - uint64 io_surface_id = surface_.SetSurfaceSize(window_rect_.width(), - window_rect_.height()); - if (io_surface_id) { - plugin_->SetAcceleratedSurface(windowed_handle(), - window_rect_.width(), - window_rect_.height(), - io_surface_id); - } -} - void WebPluginDelegateImpl::WindowFrameChanged(gfx::Rect window_frame, gfx::Rect view_frame) { instance()->set_window_frame(window_frame); @@ -688,7 +600,6 @@ void WebPluginDelegateImpl::SetNSCursor(NSCursor* cursor) { void WebPluginDelegateImpl::SetPluginRect(const gfx::Rect& rect) { window_rect_ = rect; - UpdateAcceleratedSurface(); PluginScreenLocationChanged(); } diff --git a/webkit/glue/webplugin.h b/webkit/glue/webplugin.h index 3f9c7e5..d83601a 100644 --- a/webkit/glue/webplugin.h +++ b/webkit/glue/webplugin.h @@ -144,26 +144,6 @@ class WebPlugin { virtual void SetDeferResourceLoading(unsigned long resource_id, bool defer) = 0; -#if defined(OS_MACOSX) - // Synthesize a fake window handle for the plug-in to identify the instance - // to the browser, allowing mapping to a surface for hardware accelleration - // of plug-in content. The browser generates the handle which is then set on - // the plug-in. - virtual void BindFakePluginWindowHandle() {} - - // Tell the browser (via the renderer) to invalidate because the - // accelerated buffers have changed. - virtual void AcceleratedFrameBuffersDidSwap(gfx::PluginWindowHandle window) {} - - // Tell the renderer and browser to associate the given plugin handle with - // |accelerated_surface_identifier|. The geometry is used to resize any - // native "window" (which on the Mac is a CALayer). - virtual void SetAcceleratedSurface(gfx::PluginWindowHandle window, - int32 width, - int32 height, - uint64 accelerated_surface_identifier) {} -#endif - // Gets the WebPluginDelegate that implements the interface. // This API is only for use with Pepper, and is only overridden // by in-renderer implementations. |