aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMattias Andrée <maandree@operamail.com>2014-09-04 21:56:31 +0200
committerMattias Andrée <maandree@operamail.com>2014-09-04 21:56:31 +0200
commit7f805ad80cd8a73464d929388bdb0182fdaf4265 (patch)
tree5346b614f19d52522d1dc1a15530b9dca779027e
parentadd gamma ramps + suppress serial warning on libgammaexception (diff)
downloadjlibgamma-7f805ad80cd8a73464d929388bdb0182fdaf4265.tar.gz
jlibgamma-7f805ad80cd8a73464d929388bdb0182fdaf4265.tar.bz2
jlibgamma-7f805ad80cd8a73464d929388bdb0182fdaf4265.tar.xz
set and get gamma
Signed-off-by: Mattias Andrée <maandree@operamail.com>
-rw-r--r--src/libgamma/CRTC.java150
-rw-r--r--src/libgamma/GammaRamps.java2
2 files changed, 151 insertions, 1 deletions
diff --git a/src/libgamma/CRTC.java b/src/libgamma/CRTC.java
index 8ae4d2a..77d7014 100644
--- a/src/libgamma/CRTC.java
+++ b/src/libgamma/CRTC.java
@@ -94,6 +94,42 @@ public class CRTC
return new CRTCInformation(edid, connector_name, gamma, ints);
}
+ /**
+ * Get the current gamma ramps for the CRTC.
+ *
+ * @param output The gamma ramp structure to fill.
+ */
+ public void get_gamma(GammaRamps<Ramp> output) throws LibgammaException
+ {
+ int r = 0;
+ if (output.depth == 8) r = libgamma_crtc_get_gamma_ramps8(this.address, output.address);
+ else if (output.depth == 16) r = libgamma_crtc_get_gamma_ramps16(this.address, output.address);
+ else if (output.depth == 32) r = libgamma_crtc_get_gamma_ramps32(this.address, output.address);
+ else if (output.depth == 64) r = libgamma_crtc_get_gamma_ramps64(this.address, output.address);
+ else if (output.depth == -1) r = libgamma_crtc_get_gamma_rampsf(this.address, output.address);
+ else if (output.depth == -2) r = libgamma_crtc_get_gamma_rampsd(this.address, output.address);
+ if (r != 0)
+ throw new LibgammaException(r);
+ }
+
+ /**
+ * Set the gamma ramps for the CRTC.
+ *
+ * @param values The gamma ramps to apply.
+ */
+ public void set_gamma(GammaRamps<Ramp> values) throws LibgammaException
+ {
+ int r = 0;
+ if (values.depth == 8) r = libgamma_crtc_set_gamma_ramps8(this.address, values.address);
+ else if (values.depth == 16) r = libgamma_crtc_set_gamma_ramps16(this.address, values.address);
+ else if (values.depth == 32) r = libgamma_crtc_set_gamma_ramps32(this.address, values.address);
+ else if (values.depth == 64) r = libgamma_crtc_set_gamma_ramps64(this.address, values.address);
+ else if (values.depth == -1) r = libgamma_crtc_set_gamma_rampsf(this.address, values.address);
+ else if (values.depth == -2) r = libgamma_crtc_set_gamma_rampsd(this.address, values.address);
+ if (r != 0)
+ throw new LibgammaException(r);
+ }
+
/**
@@ -131,5 +167,119 @@ public class CRTC
*/
private static native Object[] libgamma_get_crtc_information(long crtc, int fields);
+
+ /**
+ * Get the current gamma ramps for a CRTC, 8-bit gamma-depth version.
+ *
+ * @param address The CRTC state.
+ * @param ramps The gamma ramps to fill with the current values
+ * @return Zero on success, an error code on failure.
+ */
+ private static native int libgamma_crtc_get_gamma_ramps8(long address, long ramps);
+
+ /**
+ * Set the gamma ramps for a CRTC, 8-bit gamma-depth version.
+ *
+ * @param address The CRTC state.
+ * @param ramps The gamma ramps to apply.
+ * @return Zero on success, an error code on failure.
+ */
+ private static native int libgamma_crtc_set_gamma_ramps8(long address, long ramps);
+
+
+ /**
+ * Get the current gamma ramps for a CRTC, 16-bit gamma-depth version.
+ *
+ * @param address The CRTC state.
+ * @param ramps The gamma ramps to fill with the current values
+ * @return Zero on success, an error code on failure.
+ */
+ private static native int libgamma_crtc_get_gamma_ramps16(long address, long ramps);
+
+ /**
+ * Set the gamma ramps for a CRTC, 16-bit gamma-depth version.
+ *
+ * @param address The CRTC state.
+ * @param ramps The gamma ramps to apply.
+ * @return Zero on success, an error code on failure.
+ */
+ private static native int libgamma_crtc_set_gamma_ramps16(long address, long ramps);
+
+
+ /**
+ * Get the current gamma ramps for a CRTC, 32-bit gamma-depth version.
+ *
+ * @param address The CRTC state.
+ * @param ramps The gamma ramps to fill with the current values.
+ * @return Zero on success, an error code on failure.
+ */
+ private static native int libgamma_crtc_get_gamma_ramps32(long address, long ramps);
+
+ /**
+ * Set the gamma ramps for a CRTC, 32-bit gamma-depth version.
+ *
+ * @param address The CRTC state.
+ * @param ramps The gamma ramps to apply.
+ * @return Zero on success, an error code on failure.
+ */
+ private static native int libgamma_crtc_set_gamma_ramps32(long address, long ramps);
+
+
+ /**
+ * Get the current gamma ramps for a CRTC, 64-bit gamma-depth version.
+ *
+ * @param address The CRTC state.
+ * @param ramps The gamma ramps to fill with the current values.
+ * @return Zero on success, an error code on failure.
+ */
+ private static native int libgamma_crtc_get_gamma_ramps64(long address, long ramps);
+
+ /**
+ * Set the gamma ramps for a CRTC, 64-bit gamma-depth version.
+ *
+ * @param address The CRTC state.
+ * @param ramps The gamma ramps to apply.
+ * @return Zero on success, an error code on failure.
+ */
+ private static native int libgamma_crtc_set_gamma_ramps64(long address, long ramps);
+
+
+ /**
+ * Set the gamma ramps for a CRTC, single precision floating point version.
+ *
+ * @param address The CRTC state.
+ * @param ramps The gamma ramps to apply.
+ * @return Zero on success, an error code on failure.
+ */
+ private static native int libgamma_crtc_set_gamma_rampsf(long address, long ramps);
+
+ /**
+ * Get the current gamma ramps for a CRTC, single precision floating point version.
+ *
+ * @param address The CRTC state.
+ * @param ramps The gamma ramps to fill with the current values.
+ * @return Zero on success, an error code on failure.
+ */
+ private static native int libgamma_crtc_get_gamma_rampsf(long address, long ramps);
+
+
+ /**
+ * Get the current gamma ramps for a CRTC, double precision floating point version.
+ *
+ * @param address The CRTC state.
+ * @param ramps The gamma ramps to fill with the current values.
+ * @return Zero on success, an error code on failure.
+ */
+ private static native int libgamma_crtc_get_gamma_rampsd(long address, long ramps);
+
+ /**
+ * Set the gamma ramps for a CRTC, double precision floating point version.
+ *
+ * @param address The CRTC state.
+ * @param ramps The gamma ramps to apply.
+ * @return Zero on success, an error code on failure.
+ */
+ private static native int libgamma_crtc_set_gamma_rampsd(long address, long ramps);
+
}
diff --git a/src/libgamma/GammaRamps.java b/src/libgamma/GammaRamps.java
index 32be718..edbd490 100644
--- a/src/libgamma/GammaRamps.java
+++ b/src/libgamma/GammaRamps.java
@@ -119,7 +119,7 @@ public class GammaRamps<T extends Ramp>
/**
* The address of the native object.
*/
- private final long address;
+ final long address;
/**