NPAPI:DrawImage: Difference between revisions
No edit summary |
No edit summary |
||
Line 37: | Line 37: | ||
= Event Structure = | = Event Structure = | ||
= | typedef enum { | ||
NPImageFormatARGB32 = 0, /* a8r8g8b8 */ | |||
NPImageFormatRGB24 = 2, /* x8r8g8b8 */ | |||
NPImageFormatRGB16_565 = 3 /* r5g6b5 */ | |||
... | |||
} 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 */ | |||
/* Clip rectangle, must be used for trusted plugins */ | |||
int32_t x; /* Expose x relative to 0,0 of plugin window area*/ | |||
int32_t y; /* Expose y relative to 0,0 of plugin window area */ | |||
uint32_t width; /* Expose width */ | |||
uint32_t height; /* Expose height */ | |||
/* Position and scale values for plugin area */ | |||
float translateX; /* translate X matrix value, (x offset) */ | |||
float translateY; /* translate Y matrix value, (y offset) */ | |||
/* Defines plugin window size on scaled context, if 1 then size = window size */ | |||
float scaleX; /* scale X matrix value */ | |||
float scaleY; /* scale Y matrix value */ | |||
} NPImageData; | |||
= NPImageFormat type negotiation = | |||
<pre> | <pre> |
Revision as of 18:08, 27 April 2010
Status
Under consideration.
Contributors
- Last modified: April 27, 2010
- Authors: Oleg Romashin (Nokia), Josh Aas (Mozilla)
- Contributors:
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 = 0, /* a8r8g8b8 */ NPImageFormatRGB24 = 2, /* x8r8g8b8 */ NPImageFormatRGB16_565 = 3 /* r5g6b5 */ ... } 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 */ /* Clip rectangle, must be used for trusted plugins */ int32_t x; /* Expose x relative to 0,0 of plugin window area*/ int32_t y; /* Expose y relative to 0,0 of plugin window area */ uint32_t width; /* Expose width */ uint32_t height; /* Expose height */ /* Position and scale values for plugin area */ float translateX; /* translate X matrix value, (x offset) */ float translateY; /* translate Y matrix value, (y offset) */ /* Defines plugin window size on scaled context, if 1 then size = window size */ float scaleX; /* scale X matrix value */ float scaleY; /* scale Y matrix value */ } NPImageData;
NPImageFormat type negotiation
NPNVsupportsImageFormat = 5000,
Similar to Event types negotiation Plugins:IndependentEventModel#NPEventType_negotiation
NPImageFormat aFormats; browser->getvalue(instance, NPNVsupportsImageFormat, &aFormats)
Then the plugin should decide which formats supported by plugin and browser (remove bits which are not supported by plugin), and send a value to browser:
browser->setvalue(instance, NPNVsupportsImageFormat, commonFormats);
And then browser should use only formats enumerated in commonFormats value.
According to plugin state (transparency), and platform proffered depth/image-format browser will send event to plugin with specific format.