[gimp] app: improve performance of HSV hue mode
- From: N/A <ell src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] app: improve performance of HSV hue mode
- Date: Thu, 16 Mar 2017 01:50:35 +0000 (UTC)
commit ff5eb6925426c3fe03edec24feea33c4d25e2f9a
Author: Ell <ell_se yahoo com>
Date: Wed Mar 15 21:49:13 2017 -0400
app: improve performance of HSV hue mode
No need to do full back and forth RGB/HSV conversions.
.../layer-modes/gimpoperationlayermode.c | 40 +++++++++++++++-----
1 files changed, 30 insertions(+), 10 deletions(-)
---
diff --git a/app/operations/layer-modes/gimpoperationlayermode.c
b/app/operations/layer-modes/gimpoperationlayermode.c
index bbfb0cc..0bc837a 100644
--- a/app/operations/layer-modes/gimpoperationlayermode.c
+++ b/app/operations/layer-modes/gimpoperationlayermode.c
@@ -1885,19 +1885,39 @@ blendfun_hsv_hue (const float *dest,
{
if (dest[ALPHA] != 0.0f && src[ALPHA] != 0.0f)
{
- GimpRGB dest_rgb = { dest[0], dest[1], dest[2] };
- GimpRGB src_rgb = { src[0], src[1], src[2] };
- GimpHSV src_hsv, dest_hsv;
+ gfloat src_min, src_max, src_delta;
+ gfloat dest_min, dest_max, dest_delta, dest_s;
+ gint c;
- gimp_rgb_to_hsv (&dest_rgb, &dest_hsv);
- gimp_rgb_to_hsv (&src_rgb, &src_hsv);
+ src_min = MIN (src[0], src[1]);
+ src_min = MIN (src_min, src[2]);
+ src_max = MAX (src[0], src[1]);
+ src_max = MAX (src_max, src[2]);
+ src_delta = src_max - src_min;
- dest_hsv.h = src_hsv.h;
- gimp_hsv_to_rgb (&dest_hsv, &dest_rgb);
+ if (src_delta != 0.0f)
+ {
+ gfloat ratio;
+ gfloat offset;
- out[RED] = dest_rgb.r;
- out[GREEN] = dest_rgb.g;
- out[BLUE] = dest_rgb.b;
+ dest_min = MIN (dest[0], dest[1]);
+ dest_min = MIN (dest_min, dest[2]);
+ dest_max = MAX (dest[0], dest[1]);
+ dest_max = MAX (dest_max, dest[2]);
+ dest_delta = dest_max - dest_min;
+ dest_s = dest_max ? dest_delta / dest_max : 0.0f;
+
+ ratio = dest_s * dest_max / src_delta;
+ offset = dest_max - src_max * ratio;
+
+ for (c = 0; c < 3; c++)
+ out[c] = src[c] * ratio + offset;
+ }
+ else
+ {
+ for (c = 0; c < 3; c++)
+ out[c] = dest[c];
+ }
}
out[ALPHA] = src[ALPHA];
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]