89
edits
Line 102: | Line 102: | ||
} NPRenderContext; | } NPRenderContext; | ||
</pre> | </pre> | ||
=== Getting a Context to Render === | |||
<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. | |||
=== Publishing a Context === | |||
<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 output to the user. Because the final output may be done by another process, the call is asynchronous. Return from the flush guarantees it is safe to write to the region again, but does not say that the data has reached the user. The callback is provided to add this capability. The callback should be invoked once the data has been output or an error has been detected. | |||
=== Destroying a Rendering Context === | |||
<pre> | |||
typedef NPError (*NPDestroyRenderContextPtr)(NPP instance, | |||
NPRenderContext* context); | |||
</pre> | |||
Causes the context specified to be destroyed. The memory pointed to by context may be freed and accesses are undefined. | |||
=== Optimizations and Legacy APIs === | |||
There is a possible performance opportunity that should be noted. | |||
Given the threading model we have defined, it is desirable to allow InitializeRenderContext and FlushRenderContext to be called from other plugin threads than Tp. This eliminates the need to do the associated NPN_PluginThreadAsyncCall, and avoids the context switch penalties that might be associated. | |||
=== 2D Rendering === | === 2D Rendering === | ||
Line 147: | Line 186: | ||
</pre> | </pre> | ||
=== | === Optimizations for 2D Rendering === | ||
In order to avoid drawing an entire region on the screen when only a small portion is updated, it may be useful for the plugin to use existing APIs to mark only a small region as needing to be updated by the next FlushRenderContext. | |||
<pre> | <pre> |
edits