npapi-vlc | branch: master | Felix Paul Kühne <[email protected]> | Tue Jan 1 12:41:54 2013 +0100| [e715626e13468a3042ab5268c8fc57d38f5f86cb] | committer: Felix Paul Kühne
npmac: set drawing model depending on run mode For Windowless, use CoreGraphics. For Windowed, use (Invaldating)CoreAnimation instead. > http://git.videolan.org/gitweb.cgi/npapi-vlc.git/?a=commit;h=e715626e13468a3042ab5268c8fc57d38f5f86cb --- npapi/support/npmac.cpp | 74 ++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 60 insertions(+), 14 deletions(-) diff --git a/npapi/support/npmac.cpp b/npapi/support/npmac.cpp index 955c385..99bc0ac 100644 --- a/npapi/support/npmac.cpp +++ b/npapi/support/npmac.cpp @@ -2,7 +2,7 @@ * npmac.cpp: Safari/Mozilla/Firefox plugin for VLC ***************************************************************************** * Copyright (C) 2009, Jean-Paul Saman <[email protected]> - * Copyright (C) 2012, Felix Paul Kühne <fkuehne # videolan # org> + * Copyright (C) 2012-2013 Felix Paul Kühne <fkuehne # videolan # org> * $Id:$ * * Authors: Jean-Paul Saman <[email protected]> @@ -410,25 +410,71 @@ void Private_Shutdown(void) NPP_Shutdown(); } +static bool boolValue(const char *value) { + return ( !strcmp(value, "1") || + !strcasecmp(value, "true") || + !strcasecmp(value, "yes") ); +} + NPError Private_New(NPMIMEType pluginType, NPP instance, uint16_t mode, int16_t argc, char* argn[], char* argv[], NPSavedData* saved) { PLUGINDEBUGSTR("\pNew;g;"); - /* - * We should negotiate and setup uniform event & drawing models, so the 32- and 64-bit plugins behave - * identically - */ - NPBool supportsCoreGraphics = FALSE; - NPError err = NPN_GetValue(instance, NPNVsupportsCoreGraphicsBool, &supportsCoreGraphics); - if (err != NPERR_NO_ERROR || !supportsCoreGraphics) { - PLUGINDEBUGSTR("\pNew: browser doesn't support CoreGraphics drawing model;g;"); - return NPERR_INCOMPATIBLE_VERSION_ERROR; + /* find out, if the plugin should run in windowless mode. + * if yes, choose the CoreGraphics drawing model */ + bool windowless = false; + for( int i = 0; i < argc; i++ ) + { + if( !strcmp( argn[i], "windowless" ) ) + { + windowless = boolValue(argv[i]); + break; + } } - err = NPN_SetValue(instance, NPPVpluginDrawingModel, (void*)NPDrawingModelCoreGraphics); - if (err != NPERR_NO_ERROR) { - PLUGINDEBUGSTR("\pNew: couldn't activate CoreGraphics drawing model;g;"); - return NPERR_INCOMPATIBLE_VERSION_ERROR; + NPError err; + if (windowless) { + NPBool supportsCoreGraphics = FALSE; + err = NPN_GetValue(instance, NPNVsupportsCoreGraphicsBool, &supportsCoreGraphics); + if (err != NPERR_NO_ERROR || !supportsCoreGraphics) { + PLUGINDEBUGSTR("\pNew: browser doesn't support CoreGraphics drawing model;g;"); + return NPERR_INCOMPATIBLE_VERSION_ERROR; + } + + err = NPN_SetValue(instance, NPPVpluginDrawingModel, (void*)NPDrawingModelCoreGraphics); + if (err != NPERR_NO_ERROR) { + PLUGINDEBUGSTR("\pNew: couldn't activate CoreGraphics drawing model;g;"); + return NPERR_INCOMPATIBLE_VERSION_ERROR; + } + } else { + NPBool supportsCoreAnimation = FALSE; + err = NPN_GetValue(instance, NPNVsupportsCoreAnimationBool, &supportsCoreAnimation); + if (err != NPERR_NO_ERROR || !supportsCoreAnimation) { + PLUGINDEBUGSTR("\pNew: browser doesn't support CoreAnimation drawing model;g;"); + return NPERR_INCOMPATIBLE_VERSION_ERROR; + } + + NPBool supportsInvalidatingCoreAnimation = FALSE; + err = NPN_GetValue(instance, NPNVsupportsInvalidatingCoreAnimationBool, &supportsInvalidatingCoreAnimation); + if (err != NPERR_NO_ERROR || !supportsInvalidatingCoreAnimation) { + PLUGINDEBUGSTR("\pNew: browser doesn't support the Invalidating CoreAnimation drawing model;g;"); + return NPERR_INCOMPATIBLE_VERSION_ERROR; + } + + if (supportsInvalidatingCoreAnimation) { + err = NPN_SetValue(instance, NPPVpluginDrawingModel, (void*)NPDrawingModelInvalidatingCoreAnimation); + if (err != NPERR_NO_ERROR) { + PLUGINDEBUGSTR("\pNew: couldn't activate Invalidating CoreAnimation drawing model;g;"); + return NPERR_INCOMPATIBLE_VERSION_ERROR; + } + } else { + PLUGINDEBUGSTR("\pNew: falling back to non-invalidating CoreAnimation drawing, since invalidation is not supported;g;"); + err = NPN_SetValue(instance, NPPVpluginDrawingModel, (void*)NPDrawingModelCoreAnimation); + if (err != NPERR_NO_ERROR) { + PLUGINDEBUGSTR("\pNew: couldn't activate CoreAnimation drawing model;g;"); + return NPERR_INCOMPATIBLE_VERSION_ERROR; + } + } } NPBool supportsCocoaEvents = FALSE; _______________________________________________ vlc-commits mailing list [email protected] http://mailman.videolan.org/listinfo/vlc-commits
