summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMattias Andrée <maandree@operamail.com>2014-04-16 00:30:22 +0200
committerMattias Andrée <maandree@operamail.com>2014-04-16 00:30:22 +0200
commit9204b84ecdc1905cf03534223f5cb5f392104ef5 (patch)
tree94d294f0a0dbdfae14fdf2f2f5c53da164118719 /src
parentadd dummy c code for quartz (diff)
downloadblueshift-9204b84ecdc1905cf03534223f5cb5f392104ef5.tar.gz
blueshift-9204b84ecdc1905cf03534223f5cb5f392104ef5.tar.bz2
blueshift-9204b84ecdc1905cf03534223f5cb5f392104ef5.tar.xz
change quartz functions to utilize that quarts expects floats rather than uint16_t
Signed-off-by: Mattias Andrée <maandree@operamail.com>
Diffstat (limited to 'src')
-rw-r--r--src/blueshift_quartz.pyx52
-rw-r--r--src/blueshift_quartz_c.c10
-rw-r--r--src/blueshift_quartz_c.h10
-rw-r--r--src/monitor.py4
4 files changed, 47 insertions, 29 deletions
diff --git a/src/blueshift_quartz.pyx b/src/blueshift_quartz.pyx
index 8ca17de..e9d424e 100644
--- a/src/blueshift_quartz.pyx
+++ b/src/blueshift_quartz.pyx
@@ -44,13 +44,15 @@ Gets the current colour curves
needs to be free:d. `NULL` on error.
'''
-cdef extern int blueshift_quartz_apply(int use_crtc, uint16_t* rgb_curves)
+cdef extern int blueshift_quartz_apply(int use_crtc, float* r_curves, float* g_curves, float* b_curves)
'''
Apply stage of colour curve control
-@param use_crtc The CRTC to use, -1 for all
-@param rgb_curve The concatenation of the red, the green and the blue colour curves
-@return Zero on success
+@param use_crtc The CRTC to use, -1 for all
+@param r_curve The red colour curve
+@param g_curve The green colour curve
+@param b_curve The blue colour curve
+@return Zero on success
'''
cdef extern void blueshift_quartz_close()
@@ -60,9 +62,19 @@ Resource freeing stage of colour curve control
-cdef uint16_t* rgb_c
+cdef float* r_c
'''
-Storage space for the colour curves in C native data structure
+Storage space for the red colour curve in C native data structure
+'''
+
+cdef float* g_c
+'''
+Storage space for the green colour curve in C native data structure
+'''
+
+cdef float* b_c
+'''
+Storage space for the blue colour curve in C native data structure
'''
@@ -73,11 +85,13 @@ def quartz_open():
@return :int Zero on success
'''
- global rgb_c
+ global r_c, g_c, b_c
# Allocate the storage space for the C native colour curves
- rgb_c = <uint16_t*>malloc(3 * 256 * sizeof(uint16_t))
+ r_c = <float*>malloc(256 * sizeof(float))
+ g_c = <float*>malloc(256 * sizeof(float))
+ b_c = <float*>malloc(256 * sizeof(float))
# Check for out-of-memory error
- if (rgb_c is NULL):
+ if (r_c is NULL) or (g_c is NULL) or (b_c is NULL):
raise MemoryError()
# Start using Quartz
return blueshift_quartz_open()
@@ -122,21 +136,21 @@ def quartz_apply(crtc_indices, r_curve, g_curve, b_curve):
Apply stage of colour curve control
@param crtc_indices:list<int> The indices of the CRTC:s to control, -1 for all
- @param r_curve:list<int> The red colour curve
- @param g_curve:list<int> The green colour curve
- @param b_curve:list<int> The blue colour curve
+ @param r_curve:list<float> The red colour curve
+ @param g_curve:list<float> The green colour curve
+ @param b_curve:list<float> The blue colour curve
@return Zero on success
'''
- # Convert curves to 16-bit C integers
+ # Convert curves to C floats
for i in range(256):
- rgb_c[0 * 256 + i] = r_curve[i] & 0xFFFF
- rgb_c[1 * 256 + i] = g_curve[i] & 0xFFFF
- rgb_c[2 * 256 + i] = b_curve[i] & 0xFFFF
+ r_c[i] = r_curve[i]
+ g_c[i] = g_curve[i]
+ b_c[i] = b_curve[i]
rc = 0
# For each selected CRTC,
for crtc_index in crtc_indices:
# apply curves.
- rc |= blueshift_quartz_apply(crtc_index, rgb_c)
+ rc |= blueshift_quartz_apply(crtc_index, r_c, g_c, b_c)
return rc
@@ -145,7 +159,9 @@ def quartz_close():
Resource freeing stage of colour curve control
'''
# Free the storage space for the colour curves
- free(rgb_c)
+ free(r_c)
+ free(g_c)
+ free(b_c)
# Close free all resources in the native code
blueshift_quartz_close()
diff --git a/src/blueshift_quartz_c.c b/src/blueshift_quartz_c.c
index 0943c76..a74b219 100644
--- a/src/blueshift_quartz_c.c
+++ b/src/blueshift_quartz_c.c
@@ -57,11 +57,13 @@ uint16_t* blueshift_quartz_read(int use_crtc)
/**
* Apply stage of colour curve control
*
- * @param use_crtc The CRTC to use, -1 for all
- * @param rgb_curve The concatenation of the red, the green and the blue colour curves
- * @return Zero on success
+ * @param use_crtc The CRTC to use, -1 for all
+ * @param r_curve The red colour curve
+ * @param g_curve The green colour curve
+ * @param b_curve The blue colour curve
+ * @return Zero on success
*/
-int blueshift_quartz_apply(int use_crtc, uint16_t* rgb_curves)
+int blueshift_quartz_apply(int use_crtc, float* r_curves, float* g_curves, float* b_curves)
{
return -1;
}
diff --git a/src/blueshift_quartz_c.h b/src/blueshift_quartz_c.h
index 4177121..f8ea783 100644
--- a/src/blueshift_quartz_c.h
+++ b/src/blueshift_quartz_c.h
@@ -56,11 +56,13 @@ uint16_t* blueshift_quartz_read(int use_crtc);
/**
* Apply stage of colour curve control
*
- * @param use_crtc The CRTC to use, -1 for all
- * @param rgb_curve The concatenation of the red, the green and the blue colour curves
- * @return Zero on success
+ * @param use_crtc The CRTC to use, -1 for all
+ * @param r_curve The red colour curve
+ * @param g_curve The green colour curve
+ * @param b_curve The blue colour curve
+ * @return Zero on success
*/
-int blueshift_quartz_apply(int use_crtc, uint16_t* rgb_curves);
+int blueshift_quartz_apply(int use_crtc, float* r_curves, float* g_curves, float* b_curves);
/**
* Resource freeing stage of colour curve control
diff --git a/src/monitor.py b/src/monitor.py
index 93c6d93..6f28da4 100644
--- a/src/monitor.py
+++ b/src/monitor.py
@@ -337,14 +337,12 @@ def quartz(*crtcs, screen = 0, display = None):
quartz_opened = True
if (not quartz_open() == 0):
raise Exception("Could not open Quartz connection")
- # Convert curves to [0, 0xFFFF] integer lists
- (R_curve, G_curve, B_curve) = translate_to_integers()
try:
# Select all CRTC:s if none have been selected
if len(crtcs) == 0:
crtcs = range(quartz_crtc_count())
# Apply adjustments
- quartz_apply(list(crtcs), R_curve, G_curve, B_curve)
+ quartz_apply(list(crtcs), r_curve, g_curve, b_curve)
except OverflowError:
pass # Happens on exit by TERM signal