From 9b96fc8e4c1e086044386488562a47e2a955827b Mon Sep 17 00:00:00 2001 From: Sven Neumann Date: Mon, 23 Jul 2007 20:14:28 +0000 Subject: [PATCH] minor code cleanup. 2007-07-23 Sven Neumann * app/core/gimpprojection-construct.c: minor code cleanup. svn path=/trunk/; revision=22976 --- ChangeLog | 4 + app/core/gimpprojection-construct.c | 138 ++++++++++++++++------------ 2 files changed, 81 insertions(+), 61 deletions(-) diff --git a/ChangeLog b/ChangeLog index 3231104192..0bf36dd5d7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2007-07-23 Sven Neumann + + * app/core/gimpprojection-construct.c: minor code cleanup. + 2007-07-23 Sven Neumann * plug-ins/print/print.c (print_image): only delete the image if diff --git a/app/core/gimpprojection-construct.c b/app/core/gimpprojection-construct.c index 7fa3bfcc78..a7aa329c44 100644 --- a/app/core/gimpprojection-construct.c +++ b/app/core/gimpprojection-construct.c @@ -217,10 +217,13 @@ gimp_projection_construct_layers (GimpProjection *proj, /* If we're showing the layer mask instead of the layer... */ if (layer->mask && layer->mask->show_mask) { + GimpDrawable *drawable = GIMP_DRAWABLE (layer->mask); + pixel_region_init (&src2PR, - gimp_drawable_get_tiles (GIMP_DRAWABLE (layer->mask)), - (x1 - off_x), (y1 - off_y), - (x2 - x1), (y2 - y1), FALSE); + gimp_drawable_get_tiles (drawable), + x1 - off_x, y1 - off_y, + x2 - x1, y2 - y1, + FALSE); copy_gray_to_region (&src2PR, &src1PR); } @@ -231,15 +234,19 @@ gimp_projection_construct_layers (GimpProjection *proj, pixel_region_init (&src2PR, gimp_drawable_get_tiles (GIMP_DRAWABLE (layer)), - (x1 - off_x), (y1 - off_y), - (x2 - x1), (y2 - y1), FALSE); + x1 - off_x, y1 - off_y, + x2 - x1, y2 - y1, + FALSE); if (layer->mask && layer->mask->apply_mask) { + GimpDrawable *drawable = GIMP_DRAWABLE (layer->mask); + pixel_region_init (&maskPR, - gimp_drawable_get_tiles (GIMP_DRAWABLE (layer->mask)), - (x1 - off_x), (y1 - off_y), - (x2 - x1), (y2 - y1), FALSE); + gimp_drawable_get_tiles (drawable), + x1 - off_x, y1 - off_y, + x2 - x1, y2 - y1, + FALSE); mask = &maskPR; } @@ -368,7 +375,7 @@ gimp_projection_initialize (GimpProjection *proj, } } - if (!coverage) + if (! coverage) { PixelRegion PR; guchar clear[4] = { 0, 0, 0, 0 }; @@ -407,18 +414,22 @@ project_intensity_alpha (GimpProjection *proj, PixelRegion *dest, PixelRegion *mask) { - if (! proj->construct_flag) - initial_region (src, dest, mask, NULL, - layer->opacity * 255.999, - layer->mode, - proj->image->visible, - INITIAL_INTENSITY_ALPHA); + if (proj->construct_flag) + { + combine_regions (dest, src, dest, mask, NULL, + layer->opacity * 255.999, + layer->mode, + proj->image->visible, + COMBINE_INTEN_A_INTEN_A); + } else - combine_regions (dest, src, dest, mask, NULL, - layer->opacity * 255.999, - layer->mode, - proj->image->visible, - COMBINE_INTEN_A_INTEN_A); + { + initial_region (src, dest, mask, NULL, + layer->opacity * 255.999, + layer->mode, + proj->image->visible, + INITIAL_INTENSITY_ALPHA); + } } static void @@ -430,18 +441,22 @@ project_indexed (GimpProjection *proj, { g_return_if_fail (proj->image->cmap != NULL); - if (! proj->construct_flag) - initial_region (src, dest, mask, proj->image->cmap, - layer->opacity * 255.999, - layer->mode, - proj->image->visible, - INITIAL_INDEXED); + if (proj->construct_flag) + { + combine_regions (dest, src, dest, mask, proj->image->cmap, + layer->opacity * 255.999, + layer->mode, + proj->image->visible, + COMBINE_INTEN_A_INDEXED); + } else - combine_regions (dest, src, dest, mask, proj->image->cmap, - layer->opacity * 255.999, - layer->mode, - proj->image->visible, - COMBINE_INTEN_A_INDEXED); + { + initial_region (src, dest, mask, proj->image->cmap, + layer->opacity * 255.999, + layer->mode, + proj->image->visible, + INITIAL_INDEXED); + } } static void @@ -453,18 +468,22 @@ project_indexed_alpha (GimpProjection *proj, { g_return_if_fail (proj->image->cmap != NULL); - if (! proj->construct_flag) - initial_region (src, dest, mask, proj->image->cmap, - layer->opacity * 255.999, - layer->mode, - proj->image->visible, - INITIAL_INDEXED_ALPHA); + if (proj->construct_flag) + { + combine_regions (dest, src, dest, mask, proj->image->cmap, + layer->opacity * 255.999, + layer->mode, + proj->image->visible, + COMBINE_INTEN_A_INDEXED_A); + } else - combine_regions (dest, src, dest, mask, proj->image->cmap, - layer->opacity * 255.999, - layer->mode, - proj->image->visible, - COMBINE_INTEN_A_INDEXED_A); + { + initial_region (src, dest, mask, proj->image->cmap, + layer->opacity * 255.999, + layer->mode, + proj->image->visible, + INITIAL_INDEXED_ALPHA); + } } static void @@ -473,33 +492,30 @@ project_channel (GimpProjection *proj, PixelRegion *src, PixelRegion *src2) { - guchar col[3]; - guchar opacity; - gint type; + guchar col[3]; + guchar opacity; gimp_rgba_get_uchar (&channel->color, &col[0], &col[1], &col[2], &opacity); - if (! proj->construct_flag) + if (proj->construct_flag) { - type = (channel->show_masked) ? - INITIAL_CHANNEL_MASK : INITIAL_CHANNEL_SELECTION; - - initial_region (src2, src, NULL, col, - opacity, - GIMP_NORMAL_MODE, - NULL, - type); - } - else - { - type = (channel->show_masked) ? - COMBINE_INTEN_A_CHANNEL_MASK : COMBINE_INTEN_A_CHANNEL_SELECTION; - combine_regions (src, src2, src, NULL, col, opacity, GIMP_NORMAL_MODE, NULL, - type); + (channel->show_masked ? + COMBINE_INTEN_A_CHANNEL_MASK : + COMBINE_INTEN_A_CHANNEL_SELECTION)); + } + else + { + initial_region (src2, src, NULL, col, + opacity, + GIMP_NORMAL_MODE, + NULL, + (channel->show_masked ? + INITIAL_CHANNEL_MASK : + INITIAL_CHANNEL_SELECTION)); } }