Пример #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;
  }
Пример #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);
  }
Пример #3
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;
  }
Пример #4
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;
  }