45
edits
Line 85: | Line 85: | ||
== Plugins and Rendering == | == Plugins and Rendering == | ||
We | We will use device context to refer to platform independent devices (e.g., audio, 3D graphics, hardware accelerators). To facilitate this, we propose the addition of a new struct type. | ||
A plugin will request | A plugin will request device contexts using the following structure. | ||
<pre> | <pre> | ||
typedef struct | typedef struct _NPDeviceContext | ||
{ | { | ||
NPDeviceQueryCapabilityPtr queryCapability; | |||
NPDeviceQueryConfigPtr queryConfig; | |||
NPDeviceInitializeContextPtr initializeContext; | |||
NPDeviceSetStateContextPtr setStateContext; | |||
NPDeviceGetStateContextPtr getStateContext; | |||
NPDeviceFlushContextPtr flushContext; | |||
NPDeviceDestroyContextPtr destroyContext; | |||
} NPDeviceContext; | |||
} | |||
</pre> | </pre> | ||
=== | === Query a Device for Capabilities and Configurations === | ||
<pre> | <pre> | ||
typedef NPError (* | typedef NPError (*NPDeviceQueryCapabilityPtr(NPP instance, | ||
int32 capability, | |||
int32 *value); | |||
typedef NPError (*NPDeviceQueryConfigPtr(NPP instance, | |||
const NPDeviceConfig* request, | |||
NPDeviceConfig* obtain); | |||
</pre> | </pre> | ||
Causes the creation of a | Use queryCapability to ask a device about a specific capability. Use queryConfig to ask a device about a set of capabilities. The obtained configuration is the closest match to the requested configuration. | ||
=== Getting a Device Context === | |||
<pre> | |||
typedef NPError (*NPDeviceInitializeContextPtr)(NPP instance, | |||
const NPDeviceConfig *config, | |||
NPDeviceContext* context); | |||
</pre> | |||
Causes the creation of a device context for use by the specified instance. | |||
=== Publishing a Context === | === Publishing a Context === | ||
<pre> | <pre> | ||
typedef void (* | typedef void (*NPDeviceFlushRenderContextCallbackPtr)(NPP instance, | ||
NPDeviceContext* context, | |||
NPError err, | |||
void* userData); | |||
typedef NPError (* | typedef NPError (*NPDeviceFlushRenderContextPtr)(NPP instance, | ||
NPDeviceContext* context, | |||
NPFlushRenderContextCallbackPtr callback, | |||
void* userData); | |||
</pre> | </pre> | ||
Causes the contents of the | Causes the contents of the context to be presented to the device for input/output to the user. Because the final input/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. | ||
If no callback is specified, the flush becomes a blocking call. | |||
=== Destroying a Rendering Context === | === Destroying a Rendering Context === | ||
<pre> | <pre> | ||
typedef NPError (* | typedef NPError (*NPDeviceDestroyContextPtr)(NPP instance, | ||
NPDeviceContext* context); | |||
</pre> | </pre> | ||
edits