NPAPI:Pepper: Difference between revisions

Jump to navigation Jump to search
168 bytes removed ,  29 October 2009
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>


=== Getting a Context to Render ===
=== 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>
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.
 
=== 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 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.
 
=== 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 are two possible performance opportunities that should be noted.
First, given the threading model we have defined, it may be desirable to allow NPN_GetDeviceContext and NPN_PublishDeviceContext to be called from other plugin threads than Tp.  This would eliminate the need to do the associated NPN_PluginThreadAsyncCall, and avoid the context switch penalties that might be associated.
 
Second, 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 NPN_PublishDeviceContext.


<pre>
<pre>
89

edits

Navigation menu