Esempio n. 1
0
  /**
   * Disposes the native resources associated with the given D3DSurfaceData (referenced by the pData
   * parameter). This method is invoked from the native Dispose() method from the Disposer thread
   * when the Java-level D3DSurfaceData object is about to go away.
   */
  static void dispose(long pData) {
    D3DRenderQueue rq = D3DRenderQueue.getInstance();
    rq.lock();
    try {
      RenderBuffer buf = rq.getBuffer();
      rq.ensureCapacityAndAlignment(12, 4);
      buf.putInt(DISPOSE_SURFACE);
      buf.putLong(pData);

      // this call is expected to complete synchronously, so flush now
      rq.flushNow();
    } finally {
      rq.unlock();
    }
  }
Esempio n. 2
0
  @Override
  public void flush() {
    D3DRenderQueue rq = D3DRenderQueue.getInstance();
    rq.lock();
    try {
      RenderBuffer buf = rq.getBuffer();
      rq.ensureCapacityAndAlignment(12, 4);
      buf.putInt(FLUSH_SURFACE);
      buf.putLong(getNativeOps());

      // this call is expected to complete synchronously, so flush now
      rq.flushNow();
    } finally {
      rq.unlock();
    }
  }
Esempio n. 3
0
  public void Blit(
      SurfaceData src,
      SurfaceData dst,
      Composite comp,
      Region clip,
      int sx,
      int sy,
      int dx,
      int dy,
      int w,
      int h) {
    D3DRenderQueue rq = D3DRenderQueue.getInstance();
    rq.lock();
    try {
      // make sure the RenderQueue keeps a hard reference to the
      // destination (sysmem) SurfaceData to prevent it from being
      // disposed while the operation is processed on the QFT
      rq.addReference(dst);

      RenderBuffer buf = rq.getBuffer();
      D3DContext.setScratchSurface(((D3DSurfaceData) src).getContext());

      rq.ensureCapacityAndAlignment(48, 32);
      buf.putInt(SURFACE_TO_SW_BLIT);
      buf.putInt(sx).putInt(sy);
      buf.putInt(dx).putInt(dy);
      buf.putInt(w).putInt(h);
      buf.putInt(typeval);
      buf.putLong(src.getNativeOps());
      buf.putLong(dst.getNativeOps());

      // always flush immediately
      rq.flushNow();
    } finally {
      rq.unlock();
    }
  }
Esempio n. 4
0
 static void swapBuffers(
     D3DSurfaceData sd, final int x1, final int y1, final int x2, final int y2) {
   long pData = sd.getNativeOps();
   D3DRenderQueue rq = D3DRenderQueue.getInstance();
   // swapBuffers can be called from the toolkit thread by swing, we
   // should detect this and prevent the deadlocks
   if (rq.isRenderQueueThread()) {
     if (!rq.tryLock()) {
       // if we could not obtain the lock, repaint the area
       // that was supposed to be swapped, and no-op this swap
       final Component target = (Component) sd.getPeer().getTarget();
       SunToolkit.executeOnEventHandlerThread(
           target,
           new Runnable() {
             public void run() {
               target.repaint(x1, y1, x2, y2);
             }
           });
       return;
     }
   } else {
     rq.lock();
   }
   try {
     RenderBuffer buf = rq.getBuffer();
     rq.ensureCapacityAndAlignment(28, 4);
     buf.putInt(SWAP_BUFFERS);
     buf.putLong(pData);
     buf.putInt(x1);
     buf.putInt(y1);
     buf.putInt(x2);
     buf.putInt(y2);
     rq.flushNow();
   } finally {
     rq.unlock();
   }
 }