Confirmed users
138
edits
No edit summary |
|||
| Line 34: | Line 34: | ||
<pre> | <pre> | ||
/* "P" suffix means pre-multiplied alpha. */ | |||
typedef enum { | |||
NPImageFormatARGB32P = 0x1, | |||
NPImageFormatARGB32 = 0x2, | |||
NPImageFormatXRGB32 = 0x4 | |||
} NPImageFormat; | |||
typedef struct _NPAsyncSurface | typedef struct _NPAsyncSurface | ||
{ | { | ||
uint32_t version; | uint32_t version; | ||
NPSize size; | NPSize size; | ||
NPImageFormat format; | |||
uint32_t stride; | |||
struct { | struct { | ||
void * | void *data; | ||
} | } | ||
} NPAsyncSurface; | } NPAsyncSurface; | ||
| Line 51: | Line 60: | ||
</pre> | </pre> | ||
The <code> | The <code>size</code> member of the <code>NPAsyncSurface</code> should be set to the desired width and height of the surface. The <code>format</code> field of the <code>NPAsyncSurface</code> should reflect the format of the surface that is to be created. Upon return the <code>data</code> pointer should point to a valid surface data. The exact content depends on the type of surface requested, it will be set to NULL in the failure case. | ||
Surfaces can be destroyed via a new function called <code>NPN_DestroyAsyncSurface</code>: | Surfaces can be destroyed via a new function called <code>NPN_DestroyAsyncSurface</code>: | ||
| Line 75: | Line 84: | ||
This model should be available on all platforms. | This model should be available on all platforms. | ||
On succesful return the <code>data</code> pointer of the <code>NPAsyncSurface</code> will point to the data in memory for the surface. The <code>stride</code> member will reflect the stride of the returned image surface. | |||
If an <code>NPImageFormat</code> is not supported then surface creation will fail. | If an <code>NPImageFormat</code> is not supported then surface creation will fail. | ||
| Line 99: | Line 92: | ||
This drawing model will only be valid on Windows Vista and higher in order to simplify hardware accelerated surface sharing. | This drawing model will only be valid on Windows Vista and higher in order to simplify hardware accelerated surface sharing. | ||
The <code> | The <code>data</code> pointer of the <code>NPAsyncSurface</code> will be a HANDLE that can be used, for example, through [http://msdn.microsoft.com/en-us/library/bb173598%28v=VS.85%29.aspx OpenSharedResource] in order to create a texture for the user. In order to allow fast drawing to any hardware surfaces the host will acquire the handle from [http://msdn.microsoft.com/en-us/library/bb174562%28v=VS.85%29.aspx IDXGISurface::GetSharedHandle]. This shared handle will represent a texture which is usable as a render target and is valid as a shader resource. The plugin can open this shared handle as a texture and then use it as a render target for any drawing operations. | ||
This sample code illustrates usage of this drawing model: | This sample code illustrates usage of this drawing model: | ||
| Line 111: | Line 104: | ||
ID3D10Texture2D *backBuffer; | ID3D10Texture2D *backBuffer; | ||
npFrontBuffer->width = npBackBuffer->width = pluginwidth; | npFrontBuffer->size.width = npBackBuffer->size.width = pluginwidth; | ||
npFrontBuffer->height = npBackBuffer->height = pluginheight; | npFrontBuffer->size.height = npBackBuffer->size.height = pluginheight; | ||
npFrontBuffer-> | npFrontBuffer->format = npBackBuffer->format = NPImageFormatXRGB32; | ||
NPN_CreateAsyncSurface(instance, npFrontBuffer); | NPN_CreateAsyncSurface(instance, npFrontBuffer); | ||