Confirmed users, Bureaucrats and Sysops emeriti
1,680
edits
Line 46: | Line 46: | ||
Once the plugin finds a supported drawing model, it calls NPN_SetValue() to tell the browser which drawing model it will use. We're adding a new NPNVariable for this: | Once the plugin finds a supported drawing model, it calls NPN_SetValue() to tell the browser which drawing model it will use. We're adding a new NPNVariable for this: | ||
NPNVpluginDrawingModel = 1000 /* The NPDrawingModel specified by the plugin */ | NPNVpluginDrawingModel = 1000 /* The NPDrawingModel specified by the plugin */ | ||
The value for the NPNVpluginDrawingModel is an NPDrawingModel, a new enumeration we're adding: | The value for the NPNVpluginDrawingModel is an NPDrawingModel, a new enumeration we're adding: | ||
Line 66: | Line 66: | ||
Here is an example of a CoreGraphics-only plugin negotiating the drawing model: | Here is an example of a CoreGraphics-only plugin negotiating the drawing model: | ||
static NPError NPP_New(NPMIMEType pluginType, NPP instance, uint16 mode, int16 argc, char* argn[], char* argv[], NPSavedData* saved) | static NPError NPP_New(NPMIMEType pluginType, NPP instance, uint16 mode, | ||
{ | int16 argc, char* argn[], char* argv[], NPSavedData* saved) | ||
{ | |||
// Check if the browser supports the CoreGraphics drawing model | // Check if the browser supports the CoreGraphics drawing model | ||
NPBool supportsCoreGraphics = FALSE; | NPBool supportsCoreGraphics = FALSE; | ||
if (browser->getvalue(instance, NPNVsupportsCoreGraphicsBool, &supportsCoreGraphics) != NPERR_NO_ERROR || !supportsCoreGraphics) | if (browser->getvalue(instance, NPNVsupportsCoreGraphicsBool, &supportsCoreGraphics) != NPERR_NO_ERROR || !supportsCoreGraphics) | ||
return NPERR_INCOMPATIBLE_VERSION_ERROR; | return NPERR_INCOMPATIBLE_VERSION_ERROR; | ||
// Set the drawing model | // Set the drawing model | ||
if (browser->setvalue(instance, NPNVpluginDrawingModel, (void *)NPDrawingModelCoreGraphics) != NPERR_NO_ERROR) | if (browser->setvalue(instance, NPNVpluginDrawingModel, (void *)NPDrawingModelCoreGraphics) != NPERR_NO_ERROR) | ||
return NPERR_INCOMPATIBLE_VERSION_ERROR; | return NPERR_INCOMPATIBLE_VERSION_ERROR; | ||
return NPERR_NO_ERROR; | return NPERR_NO_ERROR; | ||
} | } |