colorramp: Use supplied gamma ramps as initial value
This changes colorramp_fill() to base the ramp calculations on the existing values in the supplied tables, instead of basing it on a pure `i/size` value computed on the fly. All gamma adjustment methods are changed to explicitly initialize the ramps to the `i/size` value before calls to colorramp_fill().
This commit is contained in:
+9
-6
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user