NPAPI:DrawImage: Difference between revisions

From MozillaWiki
Jump to navigation Jump to search
Line 59: Line 59:
= NPImageFormat Type Negotiation =
= NPImageFormat Type Negotiation =


* NPNVSupportedImageFormats (NPNVariable = ?)
* NPNVsupportedImageFormats (NPNVariable = 19)
* NPPVImageFormat (NPPVariable = ?)
* NPPVpluginImageFormat (NPPVariable = 22)


Negotiating the image format will work similarly to [[NPAPI:Models|drawing and event model negotiation]], but the value of NPNVsupportsImageFormat will be a bitmap of supported types. Based on the browser's supported formats, the plugin should select a subset which it can handle. The format for any given event will be specified in the event, and will be from the plugin's supported subset.
Negotiating the image format will work similarly to [[NPAPI:Models|drawing and event model negotiation]], but the value of NPNVsupportsImageFormat will be a bitmap of supported types. Based on the browser's supported formats, the plugin should select a subset which it can handle. The format for any given event will be specified in the event, and will be from the plugin's supported subset.

Revision as of 03:55, 28 April 2010

Status

Under consideration.

Contributors

  • Last modified: April 27, 2010
  • Authors: Oleg Romashin (Nokia), Josh Aas (Mozilla)
  • Contributors: Robert O'Callahan (Mozilla)

Overview

This drawing model allows plugins to draw into a buffer.

Event Model Requirements

This drawing model is currently compatible with the following event models:

While this is currently only compatible with the extended X event model, this could change. This drawing model was designed to work on any platform.

NPDrawingModelX

As this will be the first alternative to the default X drawing model, we'll designate the original model:

  • NPDrawingModelX (NPDrawingModel = 4)
  • NPNVsupportsXDrawingBool (NPNVariable = 2004)

NPDrawingModelDrawImage

For documentation on negotiating drawing models, see NPAPI:Models. The drawing model variables for draw image events are:

  • NPDrawingModelDrawImage (NPDrawingModel = 5)
  • NPNVsupportsDrawImageBool (NPNVariable = 3005)

Event Structure

 typedef enum {
   NPImageFormatARGB32     = 0x1,  /* a8r8g8b8 */
   NPImageFormatRGB24      = 0x2,  /* x8r8g8b8 */
   NPImageFormatRGB16_565  = 0x4   /* r5g6b5   */
   /* can be extended */
 } NPImageFormat;
 
 typedef struct _NPImageData
 {
   /* Image data parameters */
   char*         data;       /* image pointer */
   int32_t       stride;     /* Stride of data image pointer */
   NPImageFormat format;     /* Format of image pointer */
   NPSize        dataSize;   /* Data buffer size */
   /* Plugin window area rectangle relative to 0,0 beginning of buffer image */
   NPRect        pluginArea; 
   /* Clip rectangle relative to pluginArea rectangle */
   NPRect        clip;
 } NPImageData;

NPImageFormat Type Negotiation

  • NPNVsupportedImageFormats (NPNVariable = 19)
  • NPPVpluginImageFormat (NPPVariable = 22)

Negotiating the image format will work similarly to drawing and event model negotiation, but the value of NPNVsupportsImageFormat will be a bitmap of supported types. Based on the browser's supported formats, the plugin should select a subset which it can handle. The format for any given event will be specified in the event, and will be from the plugin's supported subset.

 NPImageFormat supportedFormats;
 browserFuncs->getvalue(instance, NPNVsupportsImageFormat, &supportedFormats);
 ...
 browserFuncs->setvalue(instance, NPPVImageFormat, (void*)supportedSubset);