NPAPI:AsyncDrawing
Status
Under consideration.
Contributors
- Last modified: September 16, 2010
- Authors: Bas Schouten (Mozilla Corporation), Josh Aas (Mozilla Corporation)
- Contributors: Robert O'Callahan (Mozilla Corporation)
Overview
In order to support asynchronous drawing of plugins directly to a hardware drawing API, we are proposing to extend the NPAPI in order to allow asynchronous to surfaces potentially located in video memory. This drawing model will only be valid on Windows Vista and higher in order to simplify hardware accelerated surface sharing.
Negotiating Windows Async Drawing
For documentation on negotiating drawing models, see NPAPI:Models. The drawing model variables for Windows Async are:
- NPDrawingModelWindowsAsync (NPDrawingModel = 555)
- NPNVsupportsWindowsAsyncBool (NPNVariable = 556)
The Windows Asynchronous Drawing Model
The Windows Asynchronous drawing model essentially means a plugin will request one or more surfaces from the host that it can draw to. This drawing is allowed to be completely asynchronous. The plugin will tell the host which surface is current at any given time, and the host will display the plugin surface for as long as it is current. While a surface is current the plugin is not allowed to modify it.
Using Hardware Surfaces
In order to allow fast drawing to any hardware surfaces the plugins will receive a HANDLE that was acquired by the host from IDXGISurface::GetSharedHandle (http://msdn.microsoft.com/en-us/library/bb174562%28v=VS.85%29.aspx). 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.
While the plugin has the surface set as current it is not allowed to bind it to the graphics pipeline or update it in any way.
The plugin is allowed to create multiple surfaces and make them current in an alternating way, making it possible to for example double or triple buffer.
Surface usage API
The following new variable types are added:
NPNVCreateSurface (NPNVariable = 557) NPPVDestroySurface (NPNVariable = 558) NPPVCurrentSurface (NPNVariable = 559)
typedef enum { NPSurfaceTypeSharedHandle = 1 } NPSurfaceType;
typedef struct _NPAsyncSurface { NPSurfaceType type; uint32_t version; struct { void *handle; } }
The NPN_GetValueProcPtr is called with