NPAPI:AsyncDrawing: Difference between revisions

Line 91: Line 91:


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.
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.
When a surface is set as current the plugin is responsible for making sure all drawing calls on that surface have completed execution!


This sample code illustrates usage of this drawing model:
This sample code illustrates usage of this drawing model:
Line 118: Line 120:
  while (painting) {
  while (painting) {
   // Draw to backBuffer texture
   // Draw to backBuffer texture
   NPN_SetCurrentAsyncSurface(instance, npBackBuffer;
   NPN_SetCurrentAsyncSurface(instance, npBackBuffer);
   ID3D10Texture2D *tmp = frontBuffer;
   ID3D10Texture2D *tmp = frontBuffer;
   NPAsyncSurface *npTmp = npFrontBuffer;
   NPAsyncSurface *npTmp = npFrontBuffer;
Line 125: Line 127:
   backBuffer = tmp;
   backBuffer = tmp;
   npBackBuffer = npTmp;
   npBackBuffer = npTmp;
  pDevice10->Flush();
  }
  }
   
   
Confirmed users
138

edits