From 7f805ad80cd8a73464d929388bdb0182fdaf4265 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Thu, 4 Sep 2014 21:56:31 +0200 Subject: set and get gamma MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- src/libgamma/CRTC.java | 150 +++++++++++++++++++++++++++++++++++++++++++ src/libgamma/GammaRamps.java | 2 +- 2 files changed, 151 insertions(+), 1 deletion(-) 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 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 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 /** * The address of the native object. */ - private final long address; + final long address; /** -- cgit v1.2.3-70-g09d2