[gimp] app: gimp:desaturate, improve indentation and reduce overhead
- From: Øyvind "pippin" Kolås <ok src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] app: gimp:desaturate, improve indentation and reduce overhead
- Date: Thu, 6 Jun 2019 13:11:12 +0000 (UTC)
commit 5428e5e384f272269de0892d2ea0a65e02821ced
Author: Øyvind Kolås <pippin gimp org>
Date: Thu Jun 6 15:07:15 2019 +0200
app: gimp:desaturate, improve indentation and reduce overhead
Fetch the red, green and blue luminance factors only in the desaturate
modes that use them.
app/operations/gimpoperationdesaturate.c | 35 ++++++++++++++++----------------
1 file changed, 18 insertions(+), 17 deletions(-)
---
diff --git a/app/operations/gimpoperationdesaturate.c b/app/operations/gimpoperationdesaturate.c
index e7cc2d2e5a..b9353e6c54 100644
--- a/app/operations/gimpoperationdesaturate.c
+++ b/app/operations/gimpoperationdesaturate.c
@@ -167,12 +167,8 @@ gimp_operation_desaturate_process (GeglOperation *operation,
gint level)
{
GimpOperationDesaturate *desaturate = GIMP_OPERATION_DESATURATE (operation);
-
gfloat *src = in_buf;
gfloat *dest = out_buf;
- double red_luminance, green_luminance, blue_luminance;
- const Babl *space = gegl_operation_get_source_space (operation, "input");
- babl_space_get_rgb_luminance (space, &red_luminance, &green_luminance, &blue_luminance);
switch (desaturate->mode)
{
@@ -203,19 +199,24 @@ gimp_operation_desaturate_process (GeglOperation *operation,
case GIMP_DESATURATE_LUMA:
case GIMP_DESATURATE_LUMINANCE:
- while (samples--)
- {
- gfloat value = (src[0] * red_luminance) +
- (src[1] * green_luminance) +
- (src[2] * blue_luminance);
- dest[0] = value;
- dest[1] = value;
- dest[2] = value;
- dest[3] = src[3];
-
- src += 4;
- dest += 4;
- }
+ {
+ const Babl *space = gegl_operation_get_source_space (operation, "input");
+ double red_luminance, green_luminance, blue_luminance;
+ babl_space_get_rgb_luminance (space, &red_luminance, &green_luminance, &blue_luminance);
+ while (samples--)
+ {
+ gfloat value = (src[0] * red_luminance) +
+ (src[1] * green_luminance) +
+ (src[2] * blue_luminance);
+ dest[0] = value;
+ dest[1] = value;
+ dest[2] = value;
+ dest[3] = src[3];
+
+ src += 4;
+ dest += 4;
+ }
+ }
break;
case GIMP_DESATURATE_AVERAGE:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]