summaryrefslogtreecommitdiffstats
path: root/webkit/glue/plugins/plugin_host.cc
diff options
context:
space:
mode:
authorpinkerton@chromium.org <pinkerton@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-10 20:01:35 +0000
committerpinkerton@chromium.org <pinkerton@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-10 20:01:35 +0000
commit3d1e89df95d421bcedec406019b3a9dbbf94b8c1 (patch)
tree2ed165930ca9f7520e94d49911a8245d54502478 /webkit/glue/plugins/plugin_host.cc
parentcb0ce1e02b7d16ab9024da9335ab7c70c493aa4e (diff)
downloadchromium_src-3d1e89df95d421bcedec406019b3a9dbbf94b8c1.zip
chromium_src-3d1e89df95d421bcedec406019b3a9dbbf94b8c1.tar.gz
chromium_src-3d1e89df95d421bcedec406019b3a9dbbf94b8c1.tar.bz2
Implement the CoreAnimation drawing model for plug-ins, sharing IPC and some rendering code with the GPU Plug-in. The drawing model negotiation is currently disabled so this should have no visible impact to plug-ins.
BUG=32012 TEST=make sure the pepper GPU plug-ins still work. git-svn-id: svn://svn.chromium.org/chrome/trunk/src@41194 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/glue/plugins/plugin_host.cc')
-rw-r--r--webkit/glue/plugins/plugin_host.cc42
1 files changed, 35 insertions, 7 deletions
diff --git a/webkit/glue/plugins/plugin_host.cc b/webkit/glue/plugins/plugin_host.cc
index 0db965c..4cd5b3b 100644
--- a/webkit/glue/plugins/plugin_host.cc
+++ b/webkit/glue/plugins/plugin_host.cc
@@ -9,6 +9,9 @@
#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"
@@ -36,6 +39,21 @@ 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_;
@@ -757,7 +775,10 @@ 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.
+ // 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.
NPBool* supports_qd = reinterpret_cast<NPBool*>(value);
*supports_qd = FALSE;
rv = NPERR_NO_ERROR;
@@ -775,9 +796,16 @@ NPError NPN_GetValue(NPP id, NPNVariable variable, void* value) {
rv = NPERR_NO_ERROR;
break;
}
- case NPNVsupportsOpenGLBool:
case NPNVsupportsCoreAnimationBool: {
- // we do not support these drawing and event models.
+ // 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.
NPBool* supports_model = reinterpret_cast<NPBool*>(value);
*supports_model = FALSE;
rv = NPERR_NO_ERROR;
@@ -838,14 +866,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;
}