89
edits
Line 126: | Line 126: | ||
NPWindowType type; // UNUSED | NPWindowType type; // UNUSED | ||
} NPWindow; | } NPWindow; | ||
</pre> | |||
A plugin will request rendering contexts using the following structure. | |||
<pre> | |||
typedef struct _NPRenderContext | |||
{ | |||
union { | |||
struct { | |||
void* region; | |||
int32 stride; | |||
} graphicsRgba; | |||
} u; | |||
} NPRenderContext; | |||
</pre> | |||
We expect to use the term renderer in a more general sense than just graphics, so we present NPAPI with a structure that can be extended as other interfaces are added (e.g., audio, 3D graphics, hardware accelerators). | |||
=== The 2D Graphics API === | |||
The 2D graphics API provides the following methods | |||
==== Initialization ==== | |||
<pre> | |||
typedef NPError (*NPInitializeRenderContextPtr)(NPP instance, | |||
NPRenderType type, | |||
NPRenderContext* context); | |||
</pre> | |||
Causes the creation of a render context of the specified type for use by the specified instance. At this moment, only 2D rendering contexts are defined. Geometry information will be conveyed to the plugin by subsequent NPP_SetWindow calls. | |||
==== Flushing ==== | |||
<pre> | |||
typedef void (*NPFlushRenderContextCallbackPtr)(NPRenderContext* context, | |||
NPError err, | |||
void* userData); | |||
typedef NPError (*NPFlushRenderContextPtr)(NPP instance, | |||
NPRenderContext* context, | |||
NPFlushRenderContextCallbackPtr callback, | |||
void* userData); | |||
</pre> | |||
Causes the contents of the region to be presented to the renderer for display. Because the final rendering may be done by another process (the browser), the call is asynchronous. Return from the flush guarantees it is safe to write to the region again, but does not say that the bits have reached the screen. The callback is provided to add this capability. The callback should be invoked once the bits have been displayed to the screen or an error has been detected. | |||
The regions to be updated can be narrowed by calls to NPN_InvalidateRect, or we should add a rectangle to the context. | |||
==== Destroy ==== | |||
<pre> | |||
typedef NPError (*NPDestroyRenderContextPtr)(NPP instance, | |||
NPRenderContext* context); | |||
</pre> | </pre> | ||
Causes the context specified to be destroyed. The memory pointed to by context may be freed and accesses are undefined. | |||
=== Getting a Device Context to Draw Into === | === Getting a Device Context to Draw Into === |
edits