diff --git a/dom/plugins/base/nsNPAPIPlugin.cpp b/dom/plugins/base/nsNPAPIPlugin.cpp index 8045de7d64e3..bc0374d9d8ae 100644 --- a/dom/plugins/base/nsNPAPIPlugin.cpp +++ b/dom/plugins/base/nsNPAPIPlugin.cpp @@ -2528,7 +2528,8 @@ _setvalue(NPP npp, NPPVariable variable, void *result) return inst->SetUsesDOMForCursor(useDOMForCursor); } -#ifdef XP_MACOSX +#ifndef MOZ_WIDGET_ANDROID + // On android, their 'drawing model' uses the same constant! case NPPVpluginDrawingModel: { if (inst) { inst->SetDrawingModel((NPDrawingModel)NS_PTR_TO_INT32(result)); @@ -2538,7 +2539,9 @@ _setvalue(NPP npp, NPPVariable variable, void *result) return NPERR_GENERIC_ERROR; } } +#endif +#ifdef XP_MACOSX case NPPVpluginEventModel: { if (inst) { inst->SetEventModel((NPEventModel)NS_PTR_TO_INT32(result)); diff --git a/dom/plugins/base/nsNPAPIPluginInstance.cpp b/dom/plugins/base/nsNPAPIPluginInstance.cpp index 4a535d439016..313ca03ee844 100644 --- a/dom/plugins/base/nsNPAPIPluginInstance.cpp +++ b/dom/plugins/base/nsNPAPIPluginInstance.cpp @@ -80,13 +80,7 @@ NS_IMPL_THREADSAFE_ISUPPORTS0(nsNPAPIPluginInstance) nsNPAPIPluginInstance::nsNPAPIPluginInstance(nsNPAPIPlugin* plugin) : -#ifdef XP_MACOSX -#ifdef NP_NO_QUICKDRAW - mDrawingModel(NPDrawingModelCoreGraphics), -#else - mDrawingModel(NPDrawingModelQuickDraw), -#endif -#endif + mDrawingModel(kDefaultDrawingModel), #ifdef MOZ_WIDGET_ANDROID mSurface(nsnull), mANPDrawingModel(0), @@ -704,12 +698,12 @@ nsNPAPIPluginInstance::UsesDOMForCursor() return mUsesDOMForCursor; } -#if defined(XP_MACOSX) void nsNPAPIPluginInstance::SetDrawingModel(NPDrawingModel aModel) { mDrawingModel = aModel; } +#if defined(XP_MACOSX) void nsNPAPIPluginInstance::SetEventModel(NPEventModel aModel) { // the event model needs to be set for the object frame immediately diff --git a/dom/plugins/base/nsNPAPIPluginInstance.h b/dom/plugins/base/nsNPAPIPluginInstance.h index 5d9963baf648..f5152c8ceff8 100644 --- a/dom/plugins/base/nsNPAPIPluginInstance.h +++ b/dom/plugins/base/nsNPAPIPluginInstance.h @@ -64,6 +64,18 @@ class nsIPluginInstanceOwner; class nsIPluginStreamListener; class nsIOutputStream; +#if defined(OS_WIN) +const NPDrawingModel kDefaultDrawingModel = NPDrawingModelSyncWin; +#elif defined(MOZ_X11) +const NPDrawingModel kDefaultDrawingModel = NPDrawingModelSyncX; +#else +#ifndef NP_NO_QUICKDRAW +const NPDrawingModel kDefaultDrawingModel = NPDrawingModelQuickDraw; +#else +const NPDrawingModel kDefaultDrawingModel = NPDrawingModelCoreGraphics; +#endif +#endif + class nsNPAPITimer { public: @@ -141,8 +153,8 @@ public: NPError SetUsesDOMForCursor(bool aUsesDOMForCursor); bool UsesDOMForCursor(); -#ifdef XP_MACOSX void SetDrawingModel(NPDrawingModel aModel); +#ifdef XP_MACOSX void SetEventModel(NPEventModel aModel); #endif @@ -237,9 +249,7 @@ protected: // the browser. NPP_t mNPP; -#ifdef XP_MACOSX NPDrawingModel mDrawingModel; -#endif #ifdef MOZ_WIDGET_ANDROID PRUint32 mANPDrawingModel; diff --git a/dom/plugins/ipc/PPluginModule.ipdl b/dom/plugins/ipc/PPluginModule.ipdl index 8fc56c6604b8..18afca5b5bcb 100644 --- a/dom/plugins/ipc/PPluginModule.ipdl +++ b/dom/plugins/ipc/PPluginModule.ipdl @@ -87,7 +87,7 @@ child: rpc NP_GetEntryPoints() returns (NPError rv); - rpc NP_Initialize() + rpc NP_Initialize(uint32_t aFlags) returns (NPError rv); rpc PPluginInstance(nsCString aMimeType, diff --git a/dom/plugins/ipc/PluginInstanceChild.cpp b/dom/plugins/ipc/PluginInstanceChild.cpp index 6c88645cbce7..6fc1c030d5c9 100644 --- a/dom/plugins/ipc/PluginInstanceChild.cpp +++ b/dom/plugins/ipc/PluginInstanceChild.cpp @@ -54,6 +54,7 @@ #include "PluginProcessChild.h" #include "gfxASurface.h" #include "gfxContext.h" +#include "nsNPAPIPluginInstance.h" #ifdef MOZ_X11 #include "gfxXlibSurface.h" #endif @@ -131,6 +132,7 @@ struct RunnableMethodTraits PluginInstanceChild::PluginInstanceChild(const NPPluginFuncs* aPluginIface) : mPluginIface(aPluginIface) + , mDrawingModel(kDefaultDrawingModel) , mCachedWindowActor(nsnull) , mCachedElementActor(nsnull) #if defined(OS_WIN) @@ -149,7 +151,6 @@ PluginInstanceChild::PluginInstanceChild(const NPPluginFuncs* aPluginIface) #endif , mShColorSpace(nsnull) , mShContext(nsnull) - , mDrawingModel(NPDrawingModelCoreGraphics) , mCGLayer(nsnull) , mCurrentEvent(nsnull) #endif @@ -414,6 +415,16 @@ PluginInstanceChild::NPN_GetValue(NPNVariable aVar, #endif } + case NPNVsupportsAsyncBitmapSurfaceBool: { +#ifdef XP_WIN + *((NPBool*)aValue) = PluginModuleChild::current()->AsyncDrawingAllowed(); +#else + // We do not support non-windows yet. + *((NPBool*)aValue) = false; +#endif + return NPERR_NO_ERROR; + } + #ifdef XP_MACOSX case NPNVsupportsCoreGraphicsBool: { *((NPBool*)aValue) = true; @@ -519,18 +530,27 @@ PluginInstanceChild::NPN_SetValue(NPPVariable aVar, void* aValue) return rv; } -#ifdef XP_MACOSX case NPPVpluginDrawingModel: { NPError rv; int drawingModel = (int16) (intptr_t) aValue; + if (!PluginModuleChild::current()->AsyncDrawingAllowed()) { + if (drawingModel == NPDrawingModelAsyncBitmapSurface || + drawingModel == NPDrawingModelAsyncWindowsDXGISurface || + drawingModel == NPDrawingModelAsyncWindowsDX9ExSurface) { + return NPERR_GENERIC_ERROR; + } + } + if (!CallNPN_SetValue_NPPVpluginDrawingModel(drawingModel, &rv)) return NPERR_GENERIC_ERROR; mDrawingModel = drawingModel; +#ifdef XP_MACOSX if (drawingModel == NPDrawingModelCoreAnimation) { mCARefreshTimer = ScheduleTimer(DEFAULT_REFRESH_MS, true, CAUpdate); } +#endif PLUGIN_LOG_DEBUG((" Plugin requested drawing model id #%i\n", mDrawingModel)); @@ -538,6 +558,7 @@ PluginInstanceChild::NPN_SetValue(NPPVariable aVar, void* aValue) return rv; } +#ifdef XP_MACOSX case NPPVpluginEventModel: { NPError rv; int eventModel = (int16) (intptr_t) aValue; diff --git a/dom/plugins/ipc/PluginInstanceChild.h b/dom/plugins/ipc/PluginInstanceChild.h index 53a4a23a15de..12b65b2ab636 100644 --- a/dom/plugins/ipc/PluginInstanceChild.h +++ b/dom/plugins/ipc/PluginInstanceChild.h @@ -364,6 +364,7 @@ private: const NPPluginFuncs* mPluginIface; NPP_t mData; NPWindow mWindow; + int16_t mDrawingModel; // Cached scriptable actors to avoid IPC churn PluginScriptableObjectChild* mCachedWindowActor; @@ -426,7 +427,6 @@ private: #endif CGColorSpaceRef mShColorSpace; CGContextRef mShContext; - int16_t mDrawingModel; nsCARenderer mCARenderer; void *mCGLayer; diff --git a/dom/plugins/ipc/PluginInstanceParent.cpp b/dom/plugins/ipc/PluginInstanceParent.cpp index 3dfab216e3a9..ce8341bfedfd 100644 --- a/dom/plugins/ipc/PluginInstanceParent.cpp +++ b/dom/plugins/ipc/PluginInstanceParent.cpp @@ -50,6 +50,7 @@ #include "gfxContext.h" #include "gfxPlatform.h" #include "gfxSharedImageSurface.h" +#include "nsNPAPIPluginInstance.h" #ifdef MOZ_X11 #include "gfxXlibSurface.h" #endif @@ -91,6 +92,7 @@ PluginInstanceParent::PluginInstanceParent(PluginModuleParent* parent, , mNPP(npp) , mNPNIface(npniface) , mWindowType(NPWindowTypeWindow) + , mDrawingModel(kDefaultDrawingModel) #if defined(OS_WIN) , mPluginHWND(NULL) , mPluginWndProc(NULL) @@ -100,7 +102,6 @@ PluginInstanceParent::PluginInstanceParent(PluginModuleParent* parent, , mShWidth(0) , mShHeight(0) , mShColorSpace(nsnull) - , mDrawingModel(NPDrawingModelCoreGraphics) #endif { } @@ -362,16 +363,18 @@ PluginInstanceParent::AnswerNPN_SetValue_NPPVpluginDrawingModel( mDrawingModel = drawingModel; *result = mNPNIface->setvalue(mNPP, NPPVpluginDrawingModel, (void*)NPDrawingModelCoreGraphics); - } else { + } else +#endif + { + if (!GetImageContainer()) { + return false; + } + mDrawingModel = drawingModel; *result = mNPNIface->setvalue(mNPP, NPPVpluginDrawingModel, - (void*)drawingModel); + (void*)drawingModel); } return true; -#else - *result = NPERR_GENERIC_ERROR; - return true; -#endif } bool diff --git a/dom/plugins/ipc/PluginInstanceParent.h b/dom/plugins/ipc/PluginInstanceParent.h index 42a785977814..9209847a29a6 100644 --- a/dom/plugins/ipc/PluginInstanceParent.h +++ b/dom/plugins/ipc/PluginInstanceParent.h @@ -321,6 +321,7 @@ private: NPP mNPP; const NPNetscapeFuncs* mNPNIface; NPWindowType mWindowType; + int16_t mDrawingModel; nsDataHashtable mScriptableObjects; @@ -351,7 +352,6 @@ private: uint16_t mShWidth; uint16_t mShHeight; CGColorSpaceRef mShColorSpace; - int16_t mDrawingModel; nsRefPtr mIOSurface; nsRefPtr mFrontIOSurface; #endif // definied(MOZ_WIDGET_COCOA) diff --git a/dom/plugins/ipc/PluginMessageUtils.h b/dom/plugins/ipc/PluginMessageUtils.h index ad7527a1f698..98797c4aaff1 100644 --- a/dom/plugins/ipc/PluginMessageUtils.h +++ b/dom/plugins/ipc/PluginMessageUtils.h @@ -86,6 +86,8 @@ UnmungePluginDsoPath(const std::string& munged); extern PRLogModuleInfo* gPluginLog; +const uint32_t kAllowAsyncDrawing = 0x1; + #if defined(_MSC_VER) #define FULLFUNCTION __FUNCSIG__ #elif (__GNUC__ >= 4) diff --git a/dom/plugins/ipc/PluginModuleChild.cpp b/dom/plugins/ipc/PluginModuleChild.cpp index 6adcca96ec6d..4136fc8f752a 100644 --- a/dom/plugins/ipc/PluginModuleChild.cpp +++ b/dom/plugins/ipc/PluginModuleChild.cpp @@ -1832,11 +1832,13 @@ PluginModuleChild::AnswerNP_GetEntryPoints(NPError* _retval) } bool -PluginModuleChild::AnswerNP_Initialize(NPError* _retval) +PluginModuleChild::AnswerNP_Initialize(const uint32_t& aFlags, NPError* _retval) { PLUGIN_LOG_DEBUG_METHOD; AssertPluginThread(); + mAsyncDrawingAllowed = aFlags & kAllowAsyncDrawing; + #ifdef OS_WIN SetEventHooks(); #endif diff --git a/dom/plugins/ipc/PluginModuleChild.h b/dom/plugins/ipc/PluginModuleChild.h index b8244bfbdbf7..7654c582e55c 100644 --- a/dom/plugins/ipc/PluginModuleChild.h +++ b/dom/plugins/ipc/PluginModuleChild.h @@ -123,7 +123,7 @@ protected: // Implement the PPluginModuleChild interface virtual bool AnswerNP_GetEntryPoints(NPError* rv); - virtual bool AnswerNP_Initialize(NPError* rv); + virtual bool AnswerNP_Initialize(const uint32_t& aFlags, NPError* rv); virtual PPluginIdentifierChild* AllocPPluginIdentifier(const nsCString& aString, @@ -228,6 +228,8 @@ public: bool NPObjectIsRegistered(NPObject* aObject); #endif + bool AsyncDrawingAllowed() { return mAsyncDrawingAllowed; } + /** * The child implementation of NPN_CreateObject. */ @@ -357,6 +359,7 @@ private: nsCString mPluginFilename; // UTF8 nsCString mUserAgent; int mQuirks; + bool mAsyncDrawingAllowed; // we get this from the plugin NP_PLUGINSHUTDOWN mShutdownFunc; diff --git a/dom/plugins/ipc/PluginModuleParent.cpp b/dom/plugins/ipc/PluginModuleParent.cpp index 952a8b80aae1..1fa1adb2a7cf 100644 --- a/dom/plugins/ipc/PluginModuleParent.cpp +++ b/dom/plugins/ipc/PluginModuleParent.cpp @@ -749,7 +749,12 @@ PluginModuleParent::NP_Initialize(NPNetscapeFuncs* bFuncs, NPPluginFuncs* pFuncs return NS_ERROR_FAILURE; } - if (!CallNP_Initialize(error)) { + uint32_t flags = 0; + if (mozilla::Preferences::GetBool("plugin.allow.asyncdrawing", false)) { + flags |= kAllowAsyncDrawing; + } + + if (!CallNP_Initialize(flags, error)) { return NS_ERROR_FAILURE; } else if (*error != NPERR_NO_ERROR) { @@ -773,7 +778,12 @@ PluginModuleParent::NP_Initialize(NPNetscapeFuncs* bFuncs, NPError* error) return NS_ERROR_FAILURE; } - if (!CallNP_Initialize(error)) + uint32_t flags = 0; + if (mozilla::Preferences::GetBool("plugin.allow.asyncdrawing", false)) { + flags |= kAllowAsyncDrawing; + } + + if (!CallNP_Initialize(flags, error)) return NS_ERROR_FAILURE; #if defined XP_WIN diff --git a/modules/libpref/src/init/all.js b/modules/libpref/src/init/all.js index d9330258e3e1..970a63a99469 100644 --- a/modules/libpref/src/init/all.js +++ b/modules/libpref/src/init/all.js @@ -2020,6 +2020,9 @@ pref("plugin.scan.WindowsMediaPlayer", "7.0"); // Which is currently HKLM\Software\MozillaPlugins\xxxPLIDxxx\Path pref("plugin.scan.plid.all", true); +// Allow the new AsyncDrawing mode to be used for plugins. +pref("plugin.allow.asyncdrawing", false); + // Help Windows NT, 2000, and XP dialup a RAS connection // when a network address is unreachable. pref("network.autodial-helper.enabled", true);