aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMattias Andrée <maandree@operamail.com>2014-08-28 15:32:01 +0200
committerMattias Andrée <maandree@operamail.com>2014-08-28 15:32:01 +0200
commit5a9b82bc5b9c5973ac9bda6c0ec4701c7fb88271 (patch)
tree20524d8a1fd61ef466b792e335434727fa352016 /src
parentinfo: ramps => ramps16 (diff)
downloadlibgamma-5a9b82bc5b9c5973ac9bda6c0ec4701c7fb88271.tar.gz
libgamma-5a9b82bc5b9c5973ac9bda6c0ec4701c7fb88271.tar.bz2
libgamma-5a9b82bc5b9c5973ac9bda6c0ec4701c7fb88271.tar.xz
add 8-bit ramps (good for software gamma)
Signed-off-by: Mattias Andrée <maandree@operamail.com>
Diffstat (limited to '')
-rw-r--r--src/lib/gamma-dummy.c29
-rw-r--r--src/lib/gamma-dummy.h23
-rw-r--r--src/lib/gamma-helper.h5
-rw-r--r--src/lib/libgamma-facade.c.gpp40
-rw-r--r--src/lib/libgamma-facade.h48
-rw-r--r--src/lib/libgamma-method.c49
-rw-r--r--src/lib/libgamma-method.h74
7 files changed, 265 insertions, 3 deletions
diff --git a/src/lib/gamma-dummy.c b/src/lib/gamma-dummy.c
index ccde8cc..84e6df0 100644
--- a/src/lib/gamma-dummy.c
+++ b/src/lib/gamma-dummy.c
@@ -722,6 +722,35 @@ int libgamma_dummy_get_crtc_information(libgamma_crtc_information_t* restrict th
/**
+ * Get current the gamma ramps for a CRTC, 8-bit gamma-depth version.
+ *
+ * @param this The CRTC state.
+ * @param ramps The gamma ramps to fill with the current values.
+ * @return Zero on success, otherwise (negative) the value of an
+ * error identifier provided by this library.
+ */
+int libgamma_dummy_crtc_get_gamma_ramps8(libgamma_crtc_state_t* restrict this,
+ libgamma_gamma_ramps8_t* restrict ramps)
+{
+}
+
+
+/**
+ * Set the gamma ramps for a CRTC, 8-bit gamma-depth version.
+ *
+ * @param this The CRTC state.
+ * @param ramps The gamma ramps to apply.
+ * @return Zero on success, otherwise (negative) the value of an
+ * error identifier provided by this library.
+ */
+int libgamma_dummy_crtc_set_gamma_ramps8(libgamma_crtc_state_t* restrict this,
+ libgamma_gamma_ramps8_t ramps)
+{
+}
+
+
+
+/**
* Get current the gamma ramps for a CRTC, 16-bit gamma-depth version.
*
* @param this The CRTC state.
diff --git a/src/lib/gamma-dummy.h b/src/lib/gamma-dummy.h
index e64dc02..931e0ff 100644
--- a/src/lib/gamma-dummy.h
+++ b/src/lib/gamma-dummy.h
@@ -136,6 +136,29 @@ int libgamma_dummy_get_crtc_information(libgamma_crtc_information_t* restrict th
libgamma_crtc_state_t* restrict crtc, int32_t fields);
/**
+ * Get current the gamma ramps for a CRTC, 8-bit gamma-depth version.
+ *
+ * @param this The CRTC state.
+ * @param ramps The gamma ramps to fill with the current values.
+ * @return Zero on success, otherwise (negative) the value of an
+ * error identifier provided by this library.
+ */
+int libgamma_dummy_crtc_get_gamma_ramps8(libgamma_crtc_state_t* restrict this,
+ libgamma_gamma_ramps8_t* restrict ramps);
+
+/**
+ * Set the gamma ramps for a CRTC, 8-bit gamma-depth version.
+ *
+ * @param this The CRTC state.
+ * @param ramps The gamma ramps to apply.
+ * @return Zero on success, otherwise (negative) the value of an
+ * error identifier provided by this library.
+ */
+int libgamma_dummy_crtc_set_gamma_ramps8(libgamma_crtc_state_t* restrict this,
+ libgamma_gamma_ramps8_t ramps);
+
+
+/**
* Get current the gamma ramps for a CRTC, 16-bit gamma-depth version.
*
* @param this The CRTC state.
diff --git a/src/lib/gamma-helper.h b/src/lib/gamma-helper.h
index 48f4de5..6bc8fd2 100644
--- a/src/lib/gamma-helper.h
+++ b/src/lib/gamma-helper.h
@@ -28,6 +28,11 @@
typedef union libgamma_gamma_ramps_any
{
/**
+ * 8-bit gamma ramps.
+ */
+ libgamma_gamma_ramps8_t bits8;
+
+ /**
* 16-bit gamma ramps.
*/
libgamma_gamma_ramps16_t bits16;
diff --git a/src/lib/libgamma-facade.c.gpp b/src/lib/libgamma-facade.c.gpp
index 8527b3b..a1e8538 100644
--- a/src/lib/libgamma-facade.c.gpp
+++ b/src/lib/libgamma-facade.c.gpp
@@ -762,7 +762,7 @@ $>done
*
* @param 1 Either `get` or `set`, for the action that the name of value implies.
* @param 2 The `ramp*` pattern for the ramp structure and function to call.
- * @param 3 Either of `bit16`, `bit32`, `bit64`, `float_single`, `float_double`;
+ * @param 3 Either of `bit8`, `bit16`, `bit32`, `bit64`, `float_single`, `float_double`;
* rather self-explanatory.
* @param 4 The number of bits in the gamma depth, -1 for single precision float,
* (`float`) and -2 for double percition float (`double`).
@@ -820,6 +820,29 @@ $>}
/**
+ * Get current the gamma ramps for a CRTC, 8-bit gamma-depth version.
+ *
+ * @param this The CRTC state.
+ * @param ramps The gamma ramps to fill with the current values.
+ * @return Zero on success, otherwise (negative) the value of an
+ * error identifier provided by this library.
+ */
+$>crtc_set_get_gamma_ramps get ramps8 bits8 8
+
+
+/**
+ * Set the gamma ramps for a CRTC, 32-bit gamma-depth version.
+ *
+ * @param this The CRTC state.
+ * @param ramps The gamma ramps to apply.
+ * @return Zero on success, otherwise (negative) the value of an
+ * error identifier provided by this library.
+ */
+$>crtc_set_get_gamma_ramps set ramps8 bits8 8
+
+
+
+/**
* Get current the gamma ramps for a CRTC, 32-bit gamma-depth version.
*
* @param this The CRTC state.
@@ -977,6 +1000,21 @@ $>}
/**
+ * Set the gamma ramps for a CRTC, 8-bit gamma-depth function version.
+ *
+ * Note that this will probably involve the library allocating temporary data.
+ *
+ * @param this The CRTC state.
+ * @param red_function The function that generates the the gamma ramp for the red channel.
+ * @param green_function The function that generates the the gamma ramp for the green channel.
+ * @param blue_function The function that generates the the gamma ramp for the blue channel.
+ * @return Zero on success, otherwise (negative) the value of an
+ * error identifier provided by this library.
+ */
+$>crtc_set_gamma_ramps_f uint8_t ramps8
+
+
+/**
* Set the gamma ramps for a CRTC, 16-bit gamma-depth function version.
*
* Note that this will probably involve the library allocating temporary data.
diff --git a/src/lib/libgamma-facade.h b/src/lib/libgamma-facade.h
index cfcf085..92a2b42 100644
--- a/src/lib/libgamma-facade.h
+++ b/src/lib/libgamma-facade.h
@@ -31,6 +31,14 @@
/**
+ * Mapping function from [0, 1] float encoding value to [0, 2⁸ − 1] integer output value.
+ *
+ * @param encoding [0, 1] float encoding value.
+ * @return [0, 2⁸ − 1] integer output value.
+ */
+typedef uint8_t libgamma_gamma_ramps8_fun(float encoding);
+
+/**
* Mapping function from [0, 1] float encoding value to [0, 2¹⁶ − 1] integer output value.
*
* @param encoding [0, 1] float encoding value.
@@ -316,6 +324,29 @@ unsigned char* libgamma_unhex_edid(const char* restrict edid);
/**
+ * Get current the gamma ramps for a CRTC, 8-bit gamma-depth version.
+ *
+ * @param this The CRTC state.
+ * @param ramps The gamma ramps to fill with the current values
+ * @return Zero on success, otherwise (negative) the value of an
+ * error identifier provided by this library.
+ */
+int libgamma_crtc_get_gamma_ramps8(libgamma_crtc_state_t* restrict this,
+ libgamma_gamma_ramps8_t* restrict ramps);
+
+/**
+ * Set the gamma ramps for a CRTC, 8-bit gamma-depth version.
+ *
+ * @param this The CRTC state.
+ * @param ramps The gamma ramps to apply.
+ * @return Zero on success, otherwise (negative) the value of an
+ * error identifier provided by this library.
+ */
+int libgamma_crtc_set_gamma_ramps8(libgamma_crtc_state_t* restrict this,
+ libgamma_gamma_ramps8_t ramps) __attribute__((hot));
+
+
+/**
* Get current the gamma ramps for a CRTC, 16-bit gamma-depth version.
*
* @param this The CRTC state.
@@ -431,6 +462,23 @@ int libgamma_crtc_set_gamma_rampsd(libgamma_crtc_state_t* restrict this,
/**
+ * Set the gamma ramps for a CRTC, 8-bit gamma-depth function version.
+ *
+ * Note that this will probably involve the library allocating temporary data.
+ *
+ * @param this The CRTC state.
+ * @param red_function The function that generates the the gamma ramp for the red channel.
+ * @param green_function The function that generates the the gamma ramp for the green channel.
+ * @param blue_function The function that generates the the gamma ramp for the blue channel.
+ * @return Zero on success, otherwise (negative) the value of an
+ * error identifier provided by this library.
+ */
+int libgamma_crtc_set_gamma_ramps8_f(libgamma_crtc_state_t* restrict this,
+ libgamma_gamma_ramps8_fun* red_function,
+ libgamma_gamma_ramps8_fun* green_function,
+ libgamma_gamma_ramps8_fun* blue_function) __attribute__((cold));
+
+/**
* Set the gamma ramps for a CRTC, 16-bit gamma-depth function version.
*
* Note that this will probably involve the library allocating temporary data.
diff --git a/src/lib/libgamma-method.c b/src/lib/libgamma-method.c
index 7311de4..0fa76c3 100644
--- a/src/lib/libgamma-method.c
+++ b/src/lib/libgamma-method.c
@@ -34,6 +34,55 @@
* @param this The gamma ramps.
* @return Zero on success, -1 on allocation error, `errno` will be set accordingly.
*/
+int libgamma_gamma_ramps8_initialise(libgamma_gamma_ramps8_t* restrict this)
+{
+ size_t n = this->red_size + this->green_size + this->blue_size;
+ this->red = malloc(n * sizeof(uint8_t));
+ this->green = this-> red + this-> red_size;
+ this->blue = this->green + this->green_size;
+ return this->red == NULL ? -1 : 0;
+}
+
+
+/**
+ * Release resources that are held by a gamma ramp strcuture that
+ * has been allocated by `libgamma_gamma_ramps8_initialise` or otherwise
+ * initialises in the proper manner.
+ *
+ * @param this The gamma ramps.
+ */
+void libgamma_gamma_ramps8_destroy(libgamma_gamma_ramps8_t* restrict this)
+{
+ free(this->red);
+}
+
+
+/**
+ * Release resources that are held by a gamma ramp strcuture that
+ * has been allocated by `libgamma_gamma_ramps8_initialise` or otherwise
+ * initialises in the proper manner, as well as release the pointer
+ * to the structure.
+ *
+ * @param this The gamma ramps.
+ */
+void libgamma_gamma_ramps8_free(libgamma_gamma_ramps8_t* restrict this)
+{
+ free(this->red);
+ free(this);
+}
+
+
+
+/**
+ * Initialise a gamma ramp in the proper way that allows all adjustment
+ * methods to read from and write to it without causing segmentation violation.
+ *
+ * The input must have `red_size`, `green_size` and `blue_size` set to the
+ * sizes of the gamma ramps that should be allocated.
+ *
+ * @param this The gamma ramps.
+ * @return Zero on success, -1 on allocation error, `errno` will be set accordingly.
+ */
int libgamma_gamma_ramps16_initialise(libgamma_gamma_ramps16_t* restrict this)
{
size_t n = this->red_size + this->green_size + this->blue_size;
diff --git a/src/lib/libgamma-method.h b/src/lib/libgamma-method.h
index b549a5d..c342b43 100644
--- a/src/lib/libgamma-method.h
+++ b/src/lib/libgamma-method.h
@@ -862,6 +862,44 @@ typedef struct libgamma_crtc_information
/**
+ * Gamma ramp structure for 8-bit gamma ramps.
+ */
+typedef struct libgamma_gamma_ramps8
+{
+ /**
+ * The size of `red`.
+ */
+ size_t red_size;
+
+ /**
+ * The size of `green`.
+ */
+ size_t green_size;
+
+ /**
+ * The size of `blue`.
+ */
+ size_t blue_size;
+
+ /**
+ * The gamma ramp for the red channel.
+ */
+ uint8_t* red;
+
+ /**
+ * The gamma ramp for the green channel.
+ */
+ uint8_t* green;
+
+ /**
+ * The gamma ramp for the blue channel.
+ */
+ uint8_t* blue;
+
+} libgamma_gamma_ramps8_t;
+
+
+/**
* Gamma ramp structure for 16-bit gamma ramps.
*/
typedef struct libgamma_gamma_ramps16
@@ -1062,11 +1100,43 @@ typedef struct libgamma_gamma_rampsd
* @param this The gamma ramps.
* @return Zero on success, -1 on allocation error, `errno` will be set accordingly.
*/
+int libgamma_gamma_ramps8_initialise(libgamma_gamma_ramps8_t* restrict this);
+
+/**
+ * Release resources that are held by a gamma ramp strcuture that
+ * has been allocated by `libgamma_gamma_ramps8_initialise` or otherwise
+ * initialises in the proper manner.
+ *
+ * @param this The gamma ramps.
+ */
+void libgamma_gamma_ramps8_destroy(libgamma_gamma_ramps8_t* restrict this);
+
+/**
+ * Release resources that are held by a gamma ramp strcuture that
+ * has been allocated by `libgamma_gamma_ramps8_initialise` or otherwise
+ * initialises in the proper manner, as well as release the pointer
+ * to the structure.
+ *
+ * @param this The gamma ramps.
+ */
+void libgamma_gamma_ramps8_free(libgamma_gamma_ramps8_t* restrict this);
+
+
+/**
+ * Initialise a gamma ramp in the proper way that allows all adjustment
+ * methods to read from and write to it without causing segmentation violation.
+ *
+ * The input must have `red_size`, `green_size` and `blue_size` set to the
+ * sizes of the gamma ramps that should be allocated.
+ *
+ * @param this The gamma ramps.
+ * @return Zero on success, -1 on allocation error, `errno` will be set accordingly.
+ */
int libgamma_gamma_ramps16_initialise(libgamma_gamma_ramps16_t* restrict this);
/**
* Release resources that are held by a gamma ramp strcuture that
- * has been allocated by `libgamma_gamma_ramps_initialise` or otherwise
+ * has been allocated by `libgamma_gamma_ramps16_initialise` or otherwise
* initialises in the proper manner.
*
* @param this The gamma ramps.
@@ -1075,7 +1145,7 @@ void libgamma_gamma_ramps16_destroy(libgamma_gamma_ramps16_t* restrict this);
/**
* Release resources that are held by a gamma ramp strcuture that
- * has been allocated by `libgamma_gamma_ramps_initialise` or otherwise
+ * has been allocated by `libgamma_gamma_ramps16_initialise` or otherwise
* initialises in the proper manner, as well as release the pointer
* to the structure.
*