Confirmed users
138
edits
Line 121: | Line 121: | ||
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. | ||
Plugins should create a Windows shared surface by calling <code>NPN_InitAsyncSurface</code> with a <code>NULL</code> value for <code>initData</code>. The resulting <code>NPAsyncSurface</code> will point to a <code>HANDLE</code> 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. | Plugins should create a Windows shared surface by calling <code>NPN_InitAsyncSurface</code> with a <code>NULL</code> value for <code>initData</code>. The resulting <code>NPAsyncSurface</code> will point to a <code>HANDLE</code> 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. In order to synchronize GPU access to the surface the resource created will support the [http://msdn.microsoft.com/en-us/library/windows/desktop/ff471339%28v=vs.85%29.aspx IDXGIKeyedMutex] interface, the key used for both acquiring and releasing sync is 0. | ||
Plugins should finalize Windows shared surfaces by calling <code>NPN_FinalizeAsyncSurface</code> when they are done with the surface. | Plugins should finalize Windows shared surfaces by calling <code>NPN_FinalizeAsyncSurface</code> when they are done with the surface. | ||
Line 155: | Line 153: | ||
void DrawFrame() { | void DrawFrame() { | ||
IDXGIKeyedMutex *mutex; | |||
backBuffer->QueryInterface(&mutex); | |||
mutex->AcquireSync(0); | |||
... Draw to backBuffer texture ... | ... Draw to backBuffer texture ... | ||
mutex->ReleaseSync(0); | |||
mutex->Release(); | |||
NPN_SetCurrentAsyncSurface(instance, npBackBuffer); | NPN_SetCurrentAsyncSurface(instance, npBackBuffer); | ||
ID3D10Texture2D *tmp = frontBuffer; | ID3D10Texture2D *tmp = frontBuffer; |