aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/colorramp.c15
-rw-r--r--src/gamma-drm.c10
-rw-r--r--src/gamma-quartz.c8
-rw-r--r--src/gamma-randr.c8
-rw-r--r--src/gamma-vidmode.c8
-rw-r--r--src/gamma-w32gdi.c8
6 files changed, 51 insertions, 6 deletions
diff --git a/src/colorramp.c b/src/colorramp.c
index d732a18..fda75f2 100644
--- a/src/colorramp.c
+++ b/src/colorramp.c
@@ -297,9 +297,12 @@ colorramp_fill(uint16_t *gamma_r, uint16_t *gamma_g, uint16_t *gamma_b,
&blackbody_color[temp_index+3], white_point);
for (int i = 0; i < size; i++) {
- gamma_r[i] = F((float)i/size, 0) * (UINT16_MAX+1);
- gamma_g[i] = F((float)i/size, 1) * (UINT16_MAX+1);
- gamma_b[i] = F((float)i/size, 2) * (UINT16_MAX+1);
+ gamma_r[i] = F((double)gamma_r[i]/(UINT16_MAX+1), 0) *
+ (UINT16_MAX+1);
+ gamma_g[i] = F((double)gamma_g[i]/(UINT16_MAX+1), 1) *
+ (UINT16_MAX+1);
+ gamma_b[i] = F((double)gamma_b[i]/(UINT16_MAX+1), 2) *
+ (UINT16_MAX+1);
}
}
@@ -315,9 +318,9 @@ colorramp_fill_float(float *gamma_r, float *gamma_g, float *gamma_b,
&blackbody_color[temp_index+3], white_point);
for (int i = 0; i < size; i++) {
- gamma_r[i] = F((float)i/size, 0);
- gamma_g[i] = F((float)i/size, 1);
- gamma_b[i] = F((float)i/size, 2);
+ gamma_r[i] = F((double)gamma_r[i], 0);
+ gamma_g[i] = F((double)gamma_g[i], 1);
+ gamma_b[i] = F((double)gamma_b[i], 2);
}
}
diff --git a/src/gamma-drm.c b/src/gamma-drm.c
index cbdafe5..d431395 100644
--- a/src/gamma-drm.c
+++ b/src/gamma-drm.c
@@ -268,6 +268,16 @@ drm_set_temperature(drm_state_t *state, const color_setting_t *setting)
}
last_gamma_size = crtcs->gamma_size;
}
+
+ /* Initialize gamma ramps to pure state */
+ int ramp_size = crtcs->gamma_size;
+ for (int i = 0; i < ramp_size; i++) {
+ uint16_t value = (double)i/ramp_size * (UINT16_MAX+1);
+ r_gamma[i] = value;
+ g_gamma[i] = value;
+ b_gamma[i] = value;
+ }
+
colorramp_fill(r_gamma, g_gamma, b_gamma, crtcs->gamma_size,
setting);
drmModeCrtcSetGamma(state->fd, crtcs->crtc_id, crtcs->gamma_size,
diff --git a/src/gamma-quartz.c b/src/gamma-quartz.c
index f28955f..4eeac4d 100644
--- a/src/gamma-quartz.c
+++ b/src/gamma-quartz.c
@@ -96,6 +96,14 @@ quartz_set_temperature_for_display(CGDirectDisplayID display,
float *gamma_g = &gamma_ramps[1*ramp_size];
float *gamma_b = &gamma_ramps[2*ramp_size];
+ /* Initialize gamma ramps to pure state */
+ for (int i = 0; i < ramp_size; i++) {
+ float value = (double)i/ramp_size;
+ gamma_r[i] = value;
+ gamma_g[i] = value;
+ gamma_b[i] = value;
+ }
+
colorramp_fill_float(gamma_r, gamma_g, gamma_b, ramp_size,
setting);
diff --git a/src/gamma-randr.c b/src/gamma-randr.c
index 4f6b0f0..5ef7a4f 100644
--- a/src/gamma-randr.c
+++ b/src/gamma-randr.c
@@ -327,6 +327,14 @@ randr_set_temperature_for_crtc(randr_state_t *state, int crtc_num,
uint16_t *gamma_g = &gamma_ramps[1*ramp_size];
uint16_t *gamma_b = &gamma_ramps[2*ramp_size];
+ /* Initialize gamma ramps to pure state */
+ for (int i = 0; i < ramp_size; i++) {
+ uint16_t value = (double)i/ramp_size * (UINT16_MAX+1);
+ gamma_r[i] = value;
+ gamma_g[i] = value;
+ gamma_b[i] = value;
+ }
+
colorramp_fill(gamma_r, gamma_g, gamma_b, ramp_size,
setting);
diff --git a/src/gamma-vidmode.c b/src/gamma-vidmode.c
index 58a552f..a25b06e 100644
--- a/src/gamma-vidmode.c
+++ b/src/gamma-vidmode.c
@@ -180,6 +180,14 @@ vidmode_set_temperature(vidmode_state_t *state,
uint16_t *gamma_g = &gamma_ramps[1*state->ramp_size];
uint16_t *gamma_b = &gamma_ramps[2*state->ramp_size];
+ /* Initialize gamma ramps to pure state */
+ for (int i = 0; i < state->ramp_size; i++) {
+ uint16_t value = (double)i/state->ramp_size * (UINT16_MAX+1);
+ gamma_r[i] = value;
+ gamma_g[i] = value;
+ gamma_b[i] = value;
+ }
+
colorramp_fill(gamma_r, gamma_g, gamma_b, state->ramp_size,
setting);
diff --git a/src/gamma-w32gdi.c b/src/gamma-w32gdi.c
index ee603e6..c07ce91 100644
--- a/src/gamma-w32gdi.c
+++ b/src/gamma-w32gdi.c
@@ -153,6 +153,14 @@ w32gdi_set_temperature(w32gdi_state_t *state,
WORD *gamma_g = &gamma_ramps[1*GAMMA_RAMP_SIZE];
WORD *gamma_b = &gamma_ramps[2*GAMMA_RAMP_SIZE];
+ /* Initialize gamma ramps to pure state */
+ for (int i = 0; i < GAMMA_RAMP_SIZE; i++) {
+ WORD value = (double)i/GAMMA_RAMP_SIZE * (UINT16_MAX+1);
+ gamma_r[i] = value;
+ gamma_g[i] = value;
+ gamma_b[i] = value;
+ }
+
colorramp_fill(gamma_r, gamma_g, gamma_b, GAMMA_RAMP_SIZE,
setting);