예제 #1
0
  private void replaceSurfaceData(
      int newBackBufferCount, BufferCapabilities newBackBufferCaps, boolean blit) {
    synchronized (surfaceDataLock) {
      final SurfaceData oldData = getSurfaceData();
      surfaceData = platformWindow.replaceSurfaceData();
      // TODO: volatile image
      //        VolatileImage oldBB = backBuffer;
      BufferedImage oldBB = backBuffer;
      backBufferCount = newBackBufferCount;
      backBufferCaps = newBackBufferCaps;
      final Rectangle size = getSize();
      if (getSurfaceData() != null && oldData != getSurfaceData()) {
        clearBackground(size.width, size.height);
      }

      if (blit) {
        blitSurfaceData(oldData, getSurfaceData());
      }

      if (oldData != null && oldData != getSurfaceData()) {
        // TODO: drop oldData for D3D/WGL pipelines
        // This can only happen when this peer is being created
        oldData.flush();
      }

      // TODO: volatile image
      //        backBuffer = (VolatileImage)delegate.createBackBuffer();
      backBuffer = (BufferedImage) platformWindow.createBackBuffer();
      if (backBuffer != null) {
        Graphics g = backBuffer.getGraphics();
        try {
          Rectangle r = getBounds();
          if (g instanceof Graphics2D) {
            ((Graphics2D) g).setComposite(AlphaComposite.Src);
          }
          g.setColor(nonOpaqueBackground);
          g.fillRect(0, 0, r.width, r.height);
          if (g instanceof SunGraphics2D) {
            ((SunGraphics2D) g).constrain(0, 0, r.width, r.height, getRegion());
          }
          if (!isTextured()) {
            g.setColor(getBackground());
            g.fillRect(0, 0, r.width, r.height);
          }
          if (oldBB != null) {
            // Draw the old back buffer to the new one
            g.drawImage(oldBB, 0, 0, null);
            oldBB.flush();
          }
        } finally {
          g.dispose();
        }
      }
    }
    flushOnscreenGraphics();
  }
예제 #2
0
  @Override
  protected void disposeImpl() {
    deactivateDisplayListener();
    SurfaceData oldData = getSurfaceData();
    synchronized (surfaceDataLock) {
      surfaceData = null;
    }
    if (oldData != null) {
      oldData.invalidate();
    }
    if (isGrabbing()) {
      ungrab();
    }
    if (warningWindow != null) {
      warningWindow.dispose();
    }

    platformWindow.dispose();
    super.disposeImpl();
  }
예제 #3
0
  private void replaceSurfaceData(final boolean blit) {
    synchronized (surfaceDataLock) {
      final SurfaceData oldData = getSurfaceData();
      surfaceData = platformWindow.replaceSurfaceData();
      final Rectangle size = getSize();
      if (getSurfaceData() != null && oldData != getSurfaceData()) {
        clearBackground(size.width, size.height);
      }

      if (blit) {
        blitSurfaceData(oldData, getSurfaceData());
      }

      if (oldData != null && oldData != getSurfaceData()) {
        // TODO: drop oldData for D3D/WGL pipelines
        // This can only happen when this peer is being created
        oldData.flush();
      }
    }
    flushOnscreenGraphics();
  }
예제 #4
0
 private void blitSurfaceData(final SurfaceData src, final SurfaceData dst) {
   // TODO blit. proof-of-concept
   if (src != dst
       && src != null
       && dst != null
       && !(dst instanceof NullSurfaceData)
       && !(src instanceof NullSurfaceData)
       && src.getSurfaceType().equals(dst.getSurfaceType())
       && src.getDefaultScale() == dst.getDefaultScale()) {
     final Rectangle size = src.getBounds();
     final Blit blit = Blit.locate(src.getSurfaceType(), CompositeType.Src, dst.getSurfaceType());
     if (blit != null) {
       blit.Blit(src, dst, AlphaComposite.Src, null, 0, 0, 0, 0, size.width, size.height);
     }
   }
 }