Пример #1
0
 @Override
 protected final ProxySurface createMutableSurfaceImpl(
     AbstractGraphicsDevice deviceReq,
     boolean createNewDevice,
     GLCapabilitiesImmutable capsChosen,
     GLCapabilitiesImmutable capsRequested,
     GLCapabilitiesChooser chooser,
     UpstreamSurfaceHook upstreamHook) {
   final X11GraphicsDevice device;
   if (createNewDevice || !(deviceReq instanceof X11GraphicsDevice)) {
     device =
         new X11GraphicsDevice(
             X11Util.openDisplay(deviceReq.getConnection()),
             deviceReq.getUnitID(),
             true /* owner */);
   } else {
     device = (X11GraphicsDevice) deviceReq;
   }
   final X11GraphicsScreen screen = new X11GraphicsScreen(device, device.getDefaultScreen());
   final X11GLXGraphicsConfiguration config =
       X11GLXGraphicsConfigurationFactory.chooseGraphicsConfigurationStatic(
           capsChosen, capsRequested, chooser, screen, VisualIDHolder.VID_UNDEFINED);
   if (null == config) {
     throw new GLException(
         "Choosing GraphicsConfiguration failed w/ " + capsChosen + " on " + screen);
   }
   return new WrappedSurface(config, 0, upstreamHook, createNewDevice);
 }
Пример #2
0
 @Override
 protected ProxySurface createMutableSurfaceImpl(
     AbstractGraphicsDevice deviceReq,
     boolean createNewDevice,
     GLCapabilitiesImmutable capsChosen,
     GLCapabilitiesImmutable capsRequested,
     GLCapabilitiesChooser chooser,
     UpstreamSurfaceHook upstreamHook) {
   final boolean ownDevice;
   final EGLGraphicsDevice device;
   if (createNewDevice || !(deviceReq instanceof EGLGraphicsDevice)) {
     final long nativeDisplayID =
         (deviceReq instanceof EGLGraphicsDevice)
             ? ((EGLGraphicsDevice) deviceReq).getNativeDisplayID()
             : deviceReq.getHandle();
     device =
         EGLDisplayUtil.eglCreateEGLGraphicsDevice(
             nativeDisplayID, deviceReq.getConnection(), deviceReq.getUnitID());
     ownDevice = true;
   } else {
     device = (EGLGraphicsDevice) deviceReq;
     ownDevice = false;
   }
   final DefaultGraphicsScreen screen = new DefaultGraphicsScreen(device, 0);
   final EGLGraphicsConfiguration config =
       EGLGraphicsConfigurationFactory.chooseGraphicsConfigurationStatic(
           capsChosen, capsRequested, chooser, screen, VisualIDHolder.VID_UNDEFINED, false);
   if (null == config) {
     throw new GLException(
         "Choosing GraphicsConfiguration failed w/ " + capsChosen + " on " + screen);
   }
   return new WrappedSurface(config, 0, upstreamHook, ownDevice);
 }
Пример #3
0
 @Override
 protected ProxySurface createProxySurfaceImpl(
     AbstractGraphicsDevice deviceReq,
     int screenIdx,
     long windowHandle,
     GLCapabilitiesImmutable capsRequested,
     GLCapabilitiesChooser chooser,
     UpstreamSurfaceHook upstream) {
   final EGLGraphicsDevice eglDeviceReq = (EGLGraphicsDevice) deviceReq;
   final EGLGraphicsDevice device =
       EGLDisplayUtil.eglCreateEGLGraphicsDevice(
           eglDeviceReq.getNativeDisplayID(), deviceReq.getConnection(), deviceReq.getUnitID());
   final DefaultGraphicsScreen screen = new DefaultGraphicsScreen(device, screenIdx);
   final EGLGraphicsConfiguration cfg =
       EGLGraphicsConfigurationFactory.chooseGraphicsConfigurationStatic(
           capsRequested, capsRequested, chooser, screen, VisualIDHolder.VID_UNDEFINED, false);
   return new WrappedSurface(cfg, windowHandle, upstream, true);
 }
Пример #4
0
 @Override
 protected final ProxySurface createProxySurfaceImpl(
     AbstractGraphicsDevice deviceReq,
     int screenIdx,
     long windowHandle,
     GLCapabilitiesImmutable capsRequested,
     GLCapabilitiesChooser chooser,
     UpstreamSurfaceHook upstream) {
   final X11GraphicsDevice device =
       new X11GraphicsDevice(
           X11Util.openDisplay(deviceReq.getConnection()),
           deviceReq.getUnitID(),
           true /* owner */);
   final X11GraphicsScreen screen = new X11GraphicsScreen(device, screenIdx);
   final int xvisualID = X11Lib.GetVisualIDFromWindow(device.getHandle(), windowHandle);
   if (VisualIDHolder.VID_UNDEFINED == xvisualID) {
     throw new GLException(
         "Undefined VisualID of window 0x"
             + Long.toHexString(windowHandle)
             + ", window probably invalid");
   }
   if (DEBUG) {
     System.err.println(
         "X11GLXDrawableFactory.createProxySurfaceImpl 0x"
             + Long.toHexString(windowHandle)
             + ": visualID 0x"
             + Integer.toHexString(xvisualID));
   }
   final X11GLXGraphicsConfiguration cfg =
       X11GLXGraphicsConfigurationFactory.chooseGraphicsConfigurationStatic(
           capsRequested, capsRequested, chooser, screen, xvisualID);
   if (DEBUG) {
     System.err.println(
         "X11GLXDrawableFactory.createProxySurfaceImpl 0x"
             + Long.toHexString(windowHandle)
             + ": "
             + cfg);
   }
   return new WrappedSurface(cfg, windowHandle, upstream, true);
 }
Пример #5
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");
    }
  }