diff options
author | Luke Shumaker <lukeshu@lukeshu.com> | 2017-08-29 11:55:05 -0400 |
---|---|---|
committer | Luke Shumaker <lukeshu@lukeshu.com> | 2017-08-29 11:55:05 -0400 |
commit | aa9a48fdb041b90df9a88c5175dd7e0681f10894 (patch) | |
tree | 9a10eed12a71ee679bc5d1f2892c1b59069bfe15 | |
parent | b237bfb6c2159d555c1778ef6f049a16c2cbd03d (diff) |
optimize away unnecessary calls to gamma->flush()
-rw-r--r-- | ggamma.c | 12 |
1 files changed, 9 insertions, 3 deletions
@@ -19,12 +19,18 @@ struct gamma_channel { void curve_edited(GtkWidget *raw_curve, UNUSED GdkEvent *event, struct gamma_channel *gamma) { gfloat vec[gamma->size]; + gboolean dirty = FALSE; gtk_curve_get_vector(GTK_CURVE(raw_curve), gamma->size, vec); - for (int i = 0; i < gamma->size; i++) - gamma->data[i] = (uint16_t)(vec[i] * 65535.0 / gamma->size); + for (int i = 0; i < gamma->size; i++) { + uint16_t y = vec[i] * 65535.0 / gamma->size; + if (y != gamma->data[i]) { + gamma->data[i] = y; + dirty = TRUE; + } + } - if (gamma->flush) + if (dirty && gamma->flush) gamma->flush(); } |