NPAPI:AsyncDrawing: Difference between revisions

Jump to navigation Jump to search
no edit summary
No edit summary
Line 136: Line 136:
  while (painting) {
  while (painting) {
   // Draw to backBuffer texture
   // Draw to backBuffer texture
  pDevice10->Flush();
   NPN_SetCurrentAsyncSurface(instance, npBackBuffer);
   NPN_SetCurrentAsyncSurface(instance, npBackBuffer);
   ID3D10Texture2D *tmp = frontBuffer;
   ID3D10Texture2D *tmp = frontBuffer;
Line 143: Line 144:
   backBuffer = tmp;
   backBuffer = tmp;
   npBackBuffer = npTmp;
   npBackBuffer = npTmp;
  pDevice10->Flush();
  }
  }
   
   
Line 166: Line 166:
Plugins should finalize surfaces by calling <code>NPN_FinalizeAsyncSurface</code>.
Plugins should finalize surfaces by calling <code>NPN_FinalizeAsyncSurface</code>.


(Code sample coming soon)
 
IDirect3DDevice9Ex *pDevice9;
// Initialize device.
NPAsyncSurface *npFrontBuffer = new NPAsyncSurface;
NPAsyncSurface *npBackBuffer = new NPAsyncSurface;
IDirect3DTexture9 *frontBuffer;
IDirect3DTexture9 *backBuffer;
NPSize size;
size.width = pluginwidth;
size.height = pluginheight;
 
HANDLE frontBufferHandle = NULL;
HANDLE backBufferHandle = NULL;
 
pDevice9->CreateTexture(pluginWidth, pluginHeight, 0,
                        D3DUSAGE_RENDERTARGET,
                        D3DFMT_X8R8G8B8, D3DPOOL_DEFAULT,
                        &frontBuffer, &frontBufferHandle);
pDevice9->CreateTexture(pluginWidth, pluginHeight, 0,
                        D3DUSAGE_RENDERTARGET,
                        D3DFMT_X8R8G8B8, D3DPOOL_DEFAULT,
                        &backBuffer, &backBufferHandle);
 
NPN_InitAsyncSurface(instance, size, NPImageFormatBGRX32, frontBufferHandle, npFrontBuffer);
NPN_InitAsyncSurface(instance, size, NPImageFormatBGRX32, backBufferHandle, npBackBuffer);
while (painting) {
  // Draw to backBuffer texture
 
  // Synchronize by one of the methods described above
  NPN_SetCurrentAsyncSurface(instance, npBackBuffer);
  IDirect3DDevice9 *tmp = frontBuffer;
  NPAsyncSurface *npTmp = npFrontBuffer;
  frontBuffer = backBuffer;
  npFrontBuffer = npBackBuffer;
  backBuffer = tmp;
  npBackBuffer = npTmp;
}
frontBuffer->Release();
backBuffer->Release();
NPN_SetCurrentAsyncSurface(instance, NULL);
NPN_FinalizeAsyncSurface(instance, npFrontBuffer);
NPN_FinalizeAsyncSurface(instance, npBackBuffer);
delete npFrontBuffer;
delete npBackBuffer;


= Open Issues =
= Open Issues =
Confirmed users
138

edits

Navigation menu