Esempio n. 1
0
 public final synchronized void setRealized(boolean realizedArg) {
   if (realized != realizedArg) {
     if (DEBUG) {
       System.err.println(
           "setRealized: " + getClass().getName() + " " + realized + " -> " + realizedArg);
     }
     realized = realizedArg;
     AbstractGraphicsDevice aDevice = surface.getGraphicsConfiguration().getScreen().getDevice();
     if (realizedArg) {
       if (NativeSurface.LOCK_SURFACE_NOT_READY >= lockSurface()) {
         throw new GLException(
             "GLDrawableImpl.setRealized(true): already realized, but surface not ready (lockSurface)");
       }
     } else {
       aDevice.lock();
     }
     try {
       setRealizedImpl();
       if (realizedArg) {
         updateHandle();
       } else {
         destroyHandle();
       }
     } finally {
       if (realizedArg) {
         unlockSurface();
       } else {
         aDevice.unlock();
       }
     }
   } else if (DEBUG) {
     System.err.println(
         "setRealized: " + getClass().getName() + " " + this.realized + " == " + realizedArg);
   }
 }
Esempio n. 2
0
 protected void closeNativeImpl() {
   if (0 != windowHandleClose && null != getScreen()) {
     DisplayDriver display = (DisplayDriver) getScreen().getDisplay();
     final AbstractGraphicsDevice edtDevice = display.getGraphicsDevice();
     edtDevice.lock();
     try {
       CloseWindow0(
           edtDevice.getHandle(),
           windowHandleClose,
           display.getJavaObjectAtom(),
           display.getWindowDeleteAtom());
     } catch (Throwable t) {
       if (DEBUG_IMPLEMENTATION) {
         Exception e =
             new Exception(
                 "Warning: closeNativeImpl failed - " + Thread.currentThread().getName(), t);
         e.printStackTrace();
       }
     } finally {
       edtDevice.unlock();
       windowHandleClose = 0;
     }
   }
   if (null != renderDevice) {
     renderDevice.close(); // closes X11 display
     renderDevice = null;
   }
 }
Esempio n. 3
0
 @Override
 public final synchronized void setRealized(boolean realizedArg) {
   if (realized != realizedArg) {
     if (DEBUG) {
       System.err.println(
           getThreadName()
               + ": setRealized: "
               + getClass().getSimpleName()
               + " "
               + realized
               + " -> "
               + realizedArg);
     }
     realized = realizedArg;
     AbstractGraphicsDevice aDevice = surface.getGraphicsConfiguration().getScreen().getDevice();
     if (realizedArg) {
       if (surface instanceof ProxySurface) {
         ((ProxySurface) surface).createNotify();
       }
       if (NativeSurface.LOCK_SURFACE_NOT_READY >= lockSurface()) {
         throw new GLException(
             "GLDrawableImpl.setRealized(true): Surface not ready (lockSurface)");
       }
     } else {
       aDevice.lock();
     }
     try {
       if (realizedArg) {
         setRealizedImpl();
         updateHandle();
       } else {
         destroyHandle();
         setRealizedImpl();
       }
     } finally {
       if (realizedArg) {
         unlockSurface();
       } else {
         aDevice.unlock();
         if (surface instanceof ProxySurface) {
           ((ProxySurface) surface).destroyNotify();
         }
       }
     }
   } else if (DEBUG) {
     System.err.println(
         getThreadName()
             + ": setRealized: "
             + getClass().getName()
             + " "
             + this.realized
             + " == "
             + realizedArg);
   }
 }
Esempio n. 4
0
  protected void createNativeImpl() {
    final ScreenDriver screen = (ScreenDriver) getScreen();
    final DisplayDriver display = (DisplayDriver) screen.getDisplay();
    final AbstractGraphicsDevice edtDevice = display.getGraphicsDevice();

    // Decoupled X11 Device/Screen allowing X11 display lock-free off-thread rendering
    final long renderDeviceHandle = X11Util.openDisplay(edtDevice.getConnection());
    if (0 == renderDeviceHandle) {
      throw new RuntimeException("Error creating display(EDT): " + edtDevice.getConnection());
    }
    renderDevice =
        new X11GraphicsDevice(
            renderDeviceHandle, AbstractGraphicsDevice.DEFAULT_UNIT, true /* owner */);
    final AbstractGraphicsScreen renderScreen =
        new X11GraphicsScreen(renderDevice, screen.getIndex());

    final GraphicsConfigurationFactory factory =
        GraphicsConfigurationFactory.getFactory(display.getGraphicsDevice(), capsRequested);
    final AbstractGraphicsConfiguration cfg =
        factory.chooseGraphicsConfiguration(
            capsRequested,
            capsRequested,
            capabilitiesChooser,
            renderScreen,
            VisualIDHolder.VID_UNDEFINED);
    if (DEBUG_IMPLEMENTATION) {
      System.err.println(
          "X11Window.createNativeImpl() factory: " + factory + ", chosen config: " + cfg);
    }
    if (null == cfg) {
      throw new NativeWindowException(
          "Error choosing GraphicsConfiguration creating window: " + this);
    }
    final int visualID = cfg.getVisualID(VIDType.NATIVE);
    if (VisualIDHolder.VID_UNDEFINED == visualID) {
      throw new NativeWindowException("Chosen Configuration w/o native visual ID: " + cfg);
    }
    setGraphicsConfiguration(cfg);
    final int flags = getReconfigureFlags(0, true) & (FLAG_IS_ALWAYSONTOP | FLAG_IS_UNDECORATED);
    edtDevice.lock();
    try {
      setWindowHandle(
          CreateWindow0(
              getParentWindowHandle(),
              edtDevice.getHandle(),
              screen.getIndex(),
              visualID,
              display.getJavaObjectAtom(),
              display.getWindowDeleteAtom(),
              getX(),
              getY(),
              getWidth(),
              getHeight(),
              autoPosition(),
              flags));
    } finally {
      edtDevice.unlock();
    }
    windowHandleClose = getWindowHandle();
    if (0 == windowHandleClose) {
      throw new NativeWindowException("Error creating window");
    }
  }