Esempio n. 1
0
  @Override
  protected final Buffer getGammaRamp(final NativeSurface surface) {
    final long display = surface.getDisplayHandle();
    if (0 == display) {
      return null;
    }
    final int screenIdx = surface.getScreenIndex();

    final int size = getGammaRampLength(surface);

    final ShortBuffer rampData = Buffers.newDirectShortBuffer(3 * size);
    final ShortBuffer redRampData = Buffers.slice(rampData, 0 * size, size);
    final ShortBuffer greenRampData = Buffers.slice(rampData, 1 * size, size);
    final ShortBuffer blueRampData = Buffers.slice(rampData, 2 * size, size);

    final boolean res =
        X11Lib.XF86VidModeGetGammaRamp(
            display, screenIdx, size, redRampData, greenRampData, blueRampData);
    if (!res) {
      return null;
    }
    if (DEBUG) {
      dumpRamp("GET__", size, redRampData, greenRampData, blueRampData);
    }
    return rampData;
  }
Esempio n. 2
0
  @Override
  protected final void resetGammaRamp(final NativeSurface surface, final Buffer originalGammaRamp) {
    if (originalGammaRamp == null) {
      return; // getGammaRamp failed originally
    }
    final long display = surface.getDisplayHandle();
    if (0 == display) {
      return;
    }
    final int screenIdx = surface.getScreenIndex();

    resetGammaRamp(display, screenIdx, originalGammaRamp);
  }
Esempio n. 3
0
 public void setSmooth(int level) {
   pgl.reqNumSamples = level;
   GLCapabilities caps = new GLCapabilities(profile);
   caps.setAlphaBits(PGL.REQUESTED_ALPHA_BITS);
   caps.setDepthBits(PGL.REQUESTED_DEPTH_BITS);
   caps.setStencilBits(PGL.REQUESTED_STENCIL_BITS);
   caps.setSampleBuffers(true);
   caps.setNumSamples(pgl.reqNumSamples);
   caps.setBackgroundOpaque(true);
   caps.setOnscreen(true);
   NativeSurface target = window.getNativeSurface();
   MutableGraphicsConfiguration config =
       (MutableGraphicsConfiguration) target.getGraphicsConfiguration();
   config.setChosenCapabilities(caps);
 }
Esempio n. 4
0
  @Override
  protected final GLDrawableImpl createOffscreenDrawableImpl(final NativeSurface target) {
    if (target == null) {
      throw new IllegalArgumentException("Null target");
    }
    final AbstractGraphicsConfiguration config = target.getGraphicsConfiguration();
    final GLCapabilitiesImmutable caps = (GLCapabilitiesImmutable) config.getChosenCapabilities();
    if (!caps.isPBuffer()) {
      return new X11PixmapGLXDrawable(this, target);
    }

    // PBuffer GLDrawable Creation
    GLDrawableImpl pbufferDrawable;
    final AbstractGraphicsDevice device = config.getScreen().getDevice();

    /**
     * Due to the ATI Bug https://bugzilla.mozilla.org/show_bug.cgi?id=486277, we need to have a
     * context current on the same Display to create a PBuffer. The dummy context shall also use the
     * same Display, since switching Display in this regard is another ATI bug.
     */
    final SharedResource sr = (SharedResource) sharedResourceRunner.getOrCreateShared(device);
    if (null != sr && sr.isGLXVendorATI() && null == GLContext.getCurrent()) {
      sr.getContext().makeCurrent();
      try {
        pbufferDrawable = new X11PbufferGLXDrawable(this, target);
      } finally {
        sr.getContext().release();
      }
    } else {
      pbufferDrawable = new X11PbufferGLXDrawable(this, target);
    }
    return pbufferDrawable;
  }
Esempio n. 5
0
  @Override
  protected final synchronized int getGammaRampLength(final NativeSurface surface) {
    if (gotGammaRampLength) {
      return gammaRampLength;
    }
    final long display = surface.getDisplayHandle();
    if (0 == display) {
      return 0;
    }
    final int screenIdx = surface.getScreenIndex();

    final int[] size = new int[1];
    final boolean res = X11Lib.XF86VidModeGetGammaRampSize(display, screenIdx, size, 0);
    if (!res) {
      return 0;
    }
    gotGammaRampLength = true;
    gammaRampLength = size[0];
    System.err.println("XXX: Gamma ramp size: " + gammaRampLength);
    return gammaRampLength;
  }
Esempio n. 6
0
  @Override
  protected final boolean setGammaRamp(final NativeSurface surface, final float[] ramp) {
    final long display = surface.getDisplayHandle();
    if (0 == display) {
      return false;
    }
    final int screenIdx = surface.getScreenIndex();

    final int len = ramp.length;
    final short[] rampData = new short[len];
    for (int i = 0; i < len; i++) {
      rampData[i] = (short) (ramp[i] * 65535);
    }

    final boolean res =
        X11Lib.XF86VidModeSetGammaRamp(
            display, screenIdx, rampData.length, rampData, 0, rampData, 0, rampData, 0);
    if (DEBUG) {
      dumpRamp("SET__", rampData.length, rampData, rampData, rampData);
    }
    return res;
  }