From e986310e3e3eb882285da30bcf41ef0d2aaf37ea Mon Sep 17 00:00:00 2001 From: Rupert Weber Date: Mon, 20 Sep 2010 17:27:56 +0200 Subject: [PATCH] Bug 630201 - remove unused layer-modes.c in app/paint-funcs The compositing functions in layer-modes.c have been obsolete for seven years now, since gimp-composite was made default by 1b33a15e036e4d in 2003. --- app/composite/gimp-composite.c | 6 +- app/composite/gimp-composite.h | 1 - app/paint-funcs/Makefile.am | 2 - app/paint-funcs/layer-modes.c | 1111 ------------------------------- app/paint-funcs/layer-modes.h | 80 --- app/paint-funcs/paint-funcs.c | 212 ++---- devel-docs/app/app-sections.txt | 1 - 7 files changed, 66 insertions(+), 1347 deletions(-) delete mode 100644 app/paint-funcs/layer-modes.c delete mode 100644 app/paint-funcs/layer-modes.h diff --git a/app/composite/gimp-composite.c b/app/composite/gimp-composite.c index 99525d1ad0..92e65fe00f 100644 --- a/app/composite/gimp-composite.c +++ b/app/composite/gimp-composite.c @@ -153,7 +153,7 @@ struct GimpCompositeOperationEffects gimp_composite_operation_effects[] = struct GimpCompositeOptions gimp_composite_options = { - GIMP_COMPOSITE_OPTION_USE + 0 }; const gchar * gimp_composite_function_name[GIMP_COMPOSITE_N][GIMP_PIXELFORMAT_N][GIMP_PIXELFORMAT_N][GIMP_PIXELFORMAT_N]; @@ -338,9 +338,7 @@ gimp_composite_init (gboolean be_verbose, gimp_composite_options.bits |= GIMP_COMPOSITE_OPTION_NOEXTENSIONS; if (be_verbose) - g_printerr ("gimp_composite: use=%s, verbose=%s\n", - (gimp_composite_options.bits & GIMP_COMPOSITE_OPTION_USE) ? - "yes" : "no", + g_printerr ("gimp_composite: verbose=%s\n", (gimp_composite_options.bits & GIMP_COMPOSITE_OPTION_VERBOSE) ? "yes" : "no"); diff --git a/app/composite/gimp-composite.h b/app/composite/gimp-composite.h index 85df9b1286..f3329b249a 100644 --- a/app/composite/gimp-composite.h +++ b/app/composite/gimp-composite.h @@ -148,7 +148,6 @@ struct GimpCompositeOptions gulong bits; }; -#define GIMP_COMPOSITE_OPTION_USE 0x1 #define GIMP_COMPOSITE_OPTION_NOEXTENSIONS 0x2 #define GIMP_COMPOSITE_OPTION_VERBOSE 0x4 diff --git a/app/paint-funcs/Makefile.am b/app/paint-funcs/Makefile.am index cefc93a51d..e897a4b459 100644 --- a/app/paint-funcs/Makefile.am +++ b/app/paint-funcs/Makefile.am @@ -19,8 +19,6 @@ INCLUDES = \ noinst_LIBRARIES = libapppaint-funcs.a libapppaint_funcs_a_SOURCES = \ - layer-modes.c \ - layer-modes.h \ paint-funcs.c \ paint-funcs.h \ paint-funcs-generic.h \ diff --git a/app/paint-funcs/layer-modes.c b/app/paint-funcs/layer-modes.c deleted file mode 100644 index 50b6bc314f..0000000000 --- a/app/paint-funcs/layer-modes.c +++ /dev/null @@ -1,1111 +0,0 @@ -/* GIMP - The GNU Image Manipulation Program - * Copyright (C) 1995 Spencer Kimball and Peter Mattis - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#include "config.h" - -#include - -#include "libgimpcolor/gimpcolor.h" - -#include "paint-funcs-types.h" - -#include "layer-modes.h" -#include "paint-funcs-utils.h" - - -#define RANDOM_SEED 314159265 -#define RANDOM_TABLE_SIZE 4096 - -static guchar add_lut[511]; -static gint32 random_table[RANDOM_TABLE_SIZE]; - - -/** FIXME: should be static inline **/ -void -dissolve_pixels (const guchar *src, - const guchar *mask, - guchar *dest, - gint x, - gint y, - gint opacity, - gint length, - gint sb, - gint db, - gboolean has_alpha) -{ - const gint alpha = db - 1; - gint b; - GRand *gr; - - gr = g_rand_new_with_seed (random_table[y % RANDOM_TABLE_SIZE]); - - /* Ignore x random values so we get a deterministic result */ - for (b = 0; b < x; b ++) - g_rand_int (gr); - - while (length--) - { - gint combined_opacity; - gint32 rand_val; - - /* preserve the intensity values */ - for (b = 0; b < alpha; b++) - dest[b] = src[b]; - - /* dissolve if random value is >= opacity */ - rand_val = g_rand_int_range (gr, 0, 255); - - if (mask) - { - if (has_alpha) - combined_opacity = opacity * src[alpha] * *mask / (255 * 255); - else - combined_opacity = opacity * *mask / 255; - - mask++; - } - else - { - if (has_alpha) - combined_opacity = opacity * src[alpha] / 255; - else - combined_opacity = opacity; - } - - dest[alpha] = (rand_val >= combined_opacity) ? 0 : OPAQUE_OPACITY; - - src += sb; - dest += db; - } - - g_rand_free (gr); - -} - -static inline void -multiply_pixels (const guchar *src1, - const guchar *src2, - guchar *dest, - guint length, - guint bytes1, - guint bytes2) -{ - const guint has_alpha1 = HAS_ALPHA (bytes1); - const guint has_alpha2 = HAS_ALPHA (bytes2); - const guint alpha = ((has_alpha1 || has_alpha2) ? - MAX (bytes1, bytes2) - 1 : bytes1); - - if (has_alpha1 && has_alpha2) - { - while (length --) - { - guint b; - - for (b = 0; b < alpha; b++) - { - guint tmp; - - dest[b] = INT_MULT(src1[b], src2[b], tmp); - } - - dest[alpha] = MIN (src1[alpha], src2[alpha]); - - src1 += bytes1; - src2 += bytes2; - dest += bytes2; - } - } - else if (has_alpha2) - { - while (length --) - { - guint b; - - for (b = 0; b < alpha; b++) - { - guint tmp; - - dest[b] = INT_MULT(src1[b], src2[b], tmp); - } - - dest[alpha] = src2[alpha]; - - src1 += bytes1; - src2 += bytes2; - dest += bytes2; - } - } - else - { - while (length --) - { - guint b; - - for (b = 0; b < alpha; b++) - { - guint tmp; - - dest[b] = INT_MULT (src1[b], src2[b], tmp); - } - - src1 += bytes1; - src2 += bytes2; - dest += bytes2; - } - } -} - -static inline void -divide_pixels (const guchar *src1, - const guchar *src2, - guchar *dest, - guint length, - guint bytes1, - guint bytes2) -{ - const guint has_alpha1 = HAS_ALPHA (bytes1); - const guint has_alpha2 = HAS_ALPHA (bytes2); - const guint alpha = ((has_alpha1 || has_alpha2) ? - MAX (bytes1, bytes2) - 1 : bytes1); - while (length--) - { - guint b; - - for (b = 0; b < alpha; b++) - { - guint result = ((src1[b] * 256) / (1 + src2[b])); - - dest[b] = MIN (result, 255); - } - - if (has_alpha1 && has_alpha2) - dest[alpha] = MIN (src1[alpha], src2[alpha]); - else if (has_alpha2) - dest[alpha] = src2[alpha]; - - src1 += bytes1; - src2 += bytes2; - dest += bytes2; - } -} - - -static inline void -screen_pixels (const guchar *src1, - const guchar *src2, - guchar *dest, - guint length, - guint bytes1, - guint bytes2) -{ - const guint has_alpha1 = HAS_ALPHA (bytes1); - const guint has_alpha2 = HAS_ALPHA (bytes2); - const guint alpha = ((has_alpha1 || has_alpha2) ? - MAX (bytes1, bytes2) - 1 : bytes1); - - while (length --) - { - guint b; - - for (b = 0; b < alpha; b++) - { - guint tmp; - - dest[b] = 255 - INT_MULT((255 - src1[b]), (255 - src2[b]), tmp); - } - - if (has_alpha1 && has_alpha2) - dest[alpha] = MIN (src1[alpha], src2[alpha]); - else if (has_alpha2) - dest[alpha] = src2[alpha]; - - src1 += bytes1; - src2 += bytes2; - dest += bytes2; - } -} - - -static inline void -overlay_pixels (const guchar *src1, - const guchar *src2, - guchar *dest, - guint length, - guint bytes1, - guint bytes2) -{ - const guint has_alpha1 = HAS_ALPHA (bytes1); - const guint has_alpha2 = HAS_ALPHA (bytes2); - const guint alpha = ((has_alpha1 || has_alpha2) ? - MAX (bytes1, bytes2) - 1 : bytes1); - - while (length --) - { - guint b; - - for (b = 0; b < alpha; b++) - { - guint tmp, tmpM; - - dest[b] = INT_MULT(src1[b], src1[b] + INT_MULT (2 * src2[b], - 255 - src1[b], - tmpM), tmp); - } - - if (has_alpha1 && has_alpha2) - dest[alpha] = MIN (src1[alpha], src2[alpha]); - else if (has_alpha2) - dest[alpha] = src2[alpha]; - - src1 += bytes1; - src2 += bytes2; - dest += bytes2; - } -} - -static inline void -difference_pixels (const guchar *src1, - const guchar *src2, - guchar *dest, - guint length, - guint bytes1, - guint bytes2) -{ - const guint has_alpha1 = HAS_ALPHA (bytes1); - const guint has_alpha2 = HAS_ALPHA (bytes2); - const guint alpha = ((has_alpha1 || has_alpha2) ? - MAX (bytes1, bytes2) - 1 : bytes1); - - while (length --) - { - guint b; - - for (b = 0; b < alpha; b++) - { - gint diff = src1[b] - src2[b]; - - dest[b] = (diff < 0) ? -diff : diff; - } - - if (has_alpha1 && has_alpha2) - dest[alpha] = MIN (src1[alpha], src2[alpha]); - else if (has_alpha2) - dest[alpha] = src2[alpha]; - - src1 += bytes1; - src2 += bytes2; - dest += bytes2; - } -} - -static inline void -add_pixels (const guchar *src1, - const guchar *src2, - guchar *dest, - guint length, - guint bytes1, - guint bytes2) -{ - const guint has_alpha1 = HAS_ALPHA (bytes1); - const guint has_alpha2 = HAS_ALPHA (bytes2); - const guint alpha = ((has_alpha1 || has_alpha2) ? - MAX (bytes1, bytes2) - 1 : bytes1); - - while (length --) - { - guint b; - - for (b = 0; b < alpha; b++) - dest[b] = add_lut[src1[b] + src2[b]]; - - if (has_alpha1 && has_alpha2) - dest[alpha] = MIN (src1[alpha], src2[alpha]); - else if (has_alpha2) - dest[alpha] = src2[alpha]; - - src1 += bytes1; - src2 += bytes2; - dest += bytes2; - } -} - - -static inline void -subtract_pixels (const guchar *src1, - const guchar *src2, - guchar *dest, - guint length, - guint bytes1, - guint bytes2) -{ - const guint has_alpha1 = HAS_ALPHA (bytes1); - const guint has_alpha2 = HAS_ALPHA (bytes2); - const guint alpha = ((has_alpha1 || has_alpha2) ? - MAX (bytes1, bytes2) - 1 : bytes1); - - while (length --) - { - guint b; - - for (b = 0; b < alpha; b++) - { - gint diff = src1[b] - src2[b]; - - dest[b] = (diff < 0) ? 0 : diff; - } - - if (has_alpha1 && has_alpha2) - dest[alpha] = MIN (src1[alpha], src2[alpha]); - else if (has_alpha2) - dest[alpha] = src2[alpha]; - - src1 += bytes1; - src2 += bytes2; - dest += bytes2; - } -} - -static inline void -darken_pixels (const guchar *src1, - const guchar *src2, - guchar *dest, - guint length, - guint bytes1, - guint bytes2) -{ - const guint has_alpha1 = HAS_ALPHA (bytes1); - const guint has_alpha2 = HAS_ALPHA (bytes2); - const guint alpha = ((has_alpha1 || has_alpha2) ? - MAX (bytes1, bytes2) - 1 : bytes1); - - while (length--) - { - guint b; - - for (b = 0; b < alpha; b++) - { - guchar s1 = src1[b]; - guchar s2 = src2[b]; - - dest[b] = (s1 < s2) ? s1 : s2; - } - - if (has_alpha1 && has_alpha2) - dest[alpha] = MIN (src1[alpha], src2[alpha]); - else if (has_alpha2) - dest[alpha] = src2[alpha]; - - src1 += bytes1; - src2 += bytes2; - dest += bytes2; - } -} - - -static inline void -lighten_pixels (const guchar *src1, - const guchar *src2, - guchar *dest, - guint length, - guint bytes1, - guint bytes2) -{ - const guint has_alpha1 = HAS_ALPHA (bytes1); - const guint has_alpha2 = HAS_ALPHA (bytes2); - const guint alpha = ((has_alpha1 || has_alpha2) ? - MAX (bytes1, bytes2) - 1 : bytes1); - - while (length--) - { - guint b; - - for (b = 0; b < alpha; b++) - { - guchar s1 = src1[b]; - guchar s2 = src2[b]; - - dest[b] = (s1 < s2) ? s2 : s1; - } - - if (has_alpha1 && has_alpha2) - dest[alpha] = MIN (src1[alpha], src2[alpha]); - else if (has_alpha2) - dest[alpha] = src2[alpha]; - - src1 += bytes1; - src2 += bytes2; - dest += bytes2; - } -} - - -static inline void -hue_only_pixels (const guchar *src1, - const guchar *src2, - guchar *dest, - guint length, - guint bytes1, - guint bytes2) -{ - const guint has_alpha1 = HAS_ALPHA (bytes1); - const guint has_alpha2 = HAS_ALPHA (bytes2); - - /* assumes inputs are only 4 byte RGBA pixels */ - while (length--) - { - gint r1, g1, b1; - gint r2, g2, b2; - - r1 = src1[0]; g1 = src1[1]; b1 = src1[2]; - r2 = src2[0]; g2 = src2[1]; b2 = src2[2]; - - gimp_rgb_to_hsv_int (&r1, &g1, &b1); - gimp_rgb_to_hsv_int (&r2, &g2, &b2); - - r1 = r2; - - /* set the destination */ - gimp_hsv_to_rgb_int (&r1, &g1, &b1); - - dest[0] = r1; dest[1] = g1; dest[2] = b1; - - if (has_alpha1 && has_alpha2) - dest[3] = MIN (src1[3], src2[3]); - else if (has_alpha2) - dest[3] = src2[3]; - - src1 += bytes1; - src2 += bytes2; - dest += bytes2; - } -} - - -static inline void -saturation_only_pixels (const guchar *src1, - const guchar *src2, - guchar *dest, - guint length, - guint bytes1, - guint bytes2) -{ - const guint has_alpha1 = HAS_ALPHA (bytes1); - const guint has_alpha2 = HAS_ALPHA (bytes2); - - /* assumes inputs are only 4 byte RGBA pixels */ - while (length--) - { - gint r1, g1, b1; - gint r2, g2, b2; - - r1 = src1[0]; g1 = src1[1]; b1 = src1[2]; - r2 = src2[0]; g2 = src2[1]; b2 = src2[2]; - - gimp_rgb_to_hsv_int (&r1, &g1, &b1); - gimp_rgb_to_hsv_int (&r2, &g2, &b2); - - g1 = g2; - - /* set the destination */ - gimp_hsv_to_rgb_int (&r1, &g1, &b1); - - dest[0] = r1; dest[1] = g1; dest[2] = b1; - - if (has_alpha1 && has_alpha2) - dest[3] = MIN (src1[3], src2[3]); - else if (has_alpha2) - dest[3] = src2[3]; - - src1 += bytes1; - src2 += bytes2; - dest += bytes2; - } -} - - -static inline void -value_only_pixels (const guchar *src1, - const guchar *src2, - guchar *dest, - guint length, - guint bytes1, - guint bytes2) -{ - const guint has_alpha1 = HAS_ALPHA (bytes1); - const guint has_alpha2 = HAS_ALPHA (bytes2); - - /* assumes inputs are only 4 byte RGBA pixels */ - while (length--) - { - gint r1, g1, b1; - gint r2, g2, b2; - - r1 = src1[0]; g1 = src1[1]; b1 = src1[2]; - r2 = src2[0]; g2 = src2[1]; b2 = src2[2]; - - gimp_rgb_to_hsv_int (&r1, &g1, &b1); - gimp_rgb_to_hsv_int (&r2, &g2, &b2); - - b1 = b2; - - /* set the destination */ - gimp_hsv_to_rgb_int (&r1, &g1, &b1); - - dest[0] = r1; dest[1] = g1; dest[2] = b1; - - if (has_alpha1 && has_alpha2) - dest[3] = MIN (src1[3], src2[3]); - else if (has_alpha2) - dest[3] = src2[3]; - - src1 += bytes1; - src2 += bytes2; - dest += bytes2; - } -} - - -static inline void -color_only_pixels (const guchar *src1, - const guchar *src2, - guchar *dest, - guint length, - guint bytes1, - guint bytes2) -{ - const guint has_alpha1 = HAS_ALPHA (bytes1); - const guint has_alpha2 = HAS_ALPHA (bytes2); - - /* assumes inputs are only 4 byte RGBA pixels */ - while (length--) - { - gint r1, g1, b1; - gint r2, g2, b2; - - r1 = src1[0]; g1 = src1[1]; b1 = src1[2]; - r2 = src2[0]; g2 = src2[1]; b2 = src2[2]; - - gimp_rgb_to_hsl_int (&r1, &g1, &b1); - gimp_rgb_to_hsl_int (&r2, &g2, &b2); - - /* transfer hue and saturation to the source pixel */ - r1 = r2; - g1 = g2; - - /* set the destination */ - gimp_hsl_to_rgb_int (&r1, &g1, &b1); - - dest[0] = r1; dest[1] = g1; dest[2] = b1; - - if (has_alpha1 && has_alpha2) - dest[3] = MIN (src1[3], src2[3]); - else if (has_alpha2) - dest[3] = src2[3]; - - src1 += bytes1; - src2 += bytes2; - dest += bytes2; - } -} - -static inline void -dodge_pixels (const guchar *src1, - const guchar *src2, - guchar *dest, - guint length, - guint bytes1, - guint bytes2) -{ - const guint has_alpha1 = HAS_ALPHA (bytes1); - const guint has_alpha2 = HAS_ALPHA (bytes2); - const guint alpha = ((has_alpha1 || has_alpha2) ? - MAX (bytes1, bytes2) - 1 : bytes1); - while (length --) - { - guint b; - - for (b = 0; b < alpha; b++) - { - guint tmp; - - tmp = src1[b] << 8; - tmp /= 256 - src2[b]; - - dest[b] = (guchar) MIN (tmp, 255); - } - - if (has_alpha1 && has_alpha2) - dest[alpha] = MIN (src1[alpha], src2[alpha]); - else if (has_alpha2) - dest[alpha] = src2[alpha]; - - src1 += bytes1; - src2 += bytes2; - dest += bytes2; - } -} - - -static inline void -burn_pixels (const guchar *src1, - const guchar *src2, - guchar *dest, - guint length, - guint bytes1, - guint bytes2) -{ - const guint has_alpha1 = HAS_ALPHA (bytes1); - const guint has_alpha2 = HAS_ALPHA (bytes2); - const guint alpha = ((has_alpha1 || has_alpha2) ? - MAX (bytes1, bytes2) - 1 : bytes1); - - while (length --) - { - guint b; - - for (b = 0; b < alpha; b++) - { - /* FIXME: Is the burn effect supposed to be dependant on the sign - * of this temporary variable? - */ - gint tmp; - - tmp = (255 - src1[b]) << 8; - tmp /= src2[b] + 1; - - dest[b] = (guchar) CLAMP (255 - tmp, 0, 255); - } - - if (has_alpha1 && has_alpha2) - dest[alpha] = MIN (src1[alpha], src2[alpha]); - else if (has_alpha2) - dest[alpha] = src2[alpha]; - - src1 += bytes1; - src2 += bytes2; - dest += bytes2; - } -} - - -static inline void -hardlight_pixels (const guchar *src1, - const guchar *src2, - guchar *dest, - guint length, - guint bytes1, - guint bytes2) -{ - const guint has_alpha1 = HAS_ALPHA (bytes1); - const guint has_alpha2 = HAS_ALPHA (bytes2); - const guint alpha = ((has_alpha1 || has_alpha2) ? - MAX (bytes1, bytes2) - 1 : bytes1); - - while (length --) - { - guint b; - - for (b = 0; b < alpha; b++) - { - guint tmp; - - if (src2[b] > 128) - { - tmp = (((gint)255 - src1[b]) * - ((gint)255 - ((src2[b] - 128) << 1))); - dest[b] = (guchar) MIN (255 - (tmp >> 8), 255); - } - else - { - tmp = (gint) src1[b] * ((gint)src2[b] << 1); - dest[b] = (guchar) MIN (tmp >> 8, 255); - } - } - - if (has_alpha1 && has_alpha2) - dest[alpha] = MIN (src1[alpha], src2[alpha]); - else if (has_alpha2) - dest[alpha] = src2[alpha]; - - src1 += bytes1; - src2 += bytes2; - dest += bytes2; - } -} - - -static inline void -softlight_pixels (const guchar *src1, - const guchar *src2, - guchar *dest, - guint length, - guint bytes1, - guint bytes2) -{ - const guint has_alpha1 = HAS_ALPHA (bytes1); - const guint has_alpha2 = HAS_ALPHA (bytes2); - const guint alpha = ((has_alpha1 || has_alpha2) ? - MAX (bytes1, bytes2) - 1 : bytes1); - - while (length --) - { - guint b; - - for (b = 0; b < alpha; b++) - { - guint tmp1, tmp2, tmp3; - - /* Mix multiply and screen */ - guint tmpM = INT_MULT (src1[b], src2[b], tmpM); - guint tmpS = 255 - INT_MULT((255 - src1[b]), (255 - src2[b]), tmp1); - - dest[b] = INT_MULT ((255 - src1[b]), tmpM, tmp2) + - INT_MULT (src1[b], tmpS, tmp3); - } - - if (has_alpha1 && has_alpha2) - dest[alpha] = MIN (src1[alpha], src2[alpha]); - else if (has_alpha2) - dest[alpha] = src2[alpha]; - - src1 += bytes1; - src2 += bytes2; - dest += bytes2; - } -} - - -static inline void -grain_extract_pixels (const guchar *src1, - const guchar *src2, - guchar *dest, - guint length, - guint bytes1, - guint bytes2) -{ - const guint has_alpha1 = HAS_ALPHA (bytes1); - const guint has_alpha2 = HAS_ALPHA (bytes2); - const guint alpha = ((has_alpha1 || has_alpha2) ? - MAX (bytes1, bytes2) - 1 : bytes1); - - while (length --) - { - guint b; - - for (b = 0; b < alpha; b++) - { - gint diff = src1[b] - src2[b] + 128; - - dest[b] = (guchar) CLAMP (diff, 0, 255); - } - - if (has_alpha1 && has_alpha2) - dest[alpha] = MIN (src1[alpha], src2[alpha]); - else if (has_alpha2) - dest[alpha] = src2[alpha]; - - src1 += bytes1; - src2 += bytes2; - dest += bytes2; - } -} - - -static inline void -grain_merge_pixels (const guchar *src1, - const guchar *src2, - guchar *dest, - guint length, - guint bytes1, - guint bytes2) -{ - const guint has_alpha1 = HAS_ALPHA (bytes1); - const guint has_alpha2 = HAS_ALPHA (bytes2); - const guint alpha = ((has_alpha1 || has_alpha2) ? - MAX (bytes1, bytes2) - 1 : bytes1); - - while (length --) - { - guint b; - - for (b = 0; b < alpha; b++) - { - /* Add, re-center and clip. */ - gint sum = src1[b] + src2[b] - 128; - - dest[b] = (guchar) CLAMP (sum, 0, 255); - } - - if (has_alpha1 && has_alpha2) - dest[alpha] = MIN (src1[alpha], src2[alpha]); - else if (has_alpha2) - dest[alpha] = src2[alpha]; - - src1 += bytes1; - src2 += bytes2; - dest += bytes2; - } -} - - - -/********************************** - * Layer mode interface functions * - **********************************/ - -void -layer_modes_setup (void) -{ - GRand *gr; - gint i; - - /* generate a table of random seeds */ - gr = g_rand_new_with_seed (RANDOM_SEED); - - for (i = 0; i < RANDOM_TABLE_SIZE; i++) - random_table[i] = g_rand_int (gr); - - for (i = 0; i < 256; i++) - add_lut[i] = i; - - for (i = 256; i <= 510; i++) - add_lut[i] = 255; - - g_rand_free (gr); -} - -void -layer_normal_mode (struct apply_layer_mode_struct *alms) -{ - /* assumes we're applying src2 TO src1 */ - *(alms->dest) = alms->src2; -} - -void -layer_dissolve_mode (struct apply_layer_mode_struct *alms) -{ - const guint has_alpha1 = HAS_ALPHA (alms->bytes1); - const guint has_alpha2 = HAS_ALPHA (alms->bytes2); - guint dest_bytes; - - /* Since dissolve requires an alpha channel... */ - if (has_alpha2) - dest_bytes = alms->bytes2; - else - dest_bytes = alms->bytes2 + 1; - - dissolve_pixels (alms->src2, alms->mask, *(alms->dest), - alms->x, alms->y, - alms->opacity, alms->length, - alms->bytes2, dest_bytes, - has_alpha2); - - alms->combine = has_alpha1 ? COMBINE_INTEN_A_INTEN_A : COMBINE_INTEN_INTEN_A; -} - -void -layer_multiply_mode (struct apply_layer_mode_struct *alms) -{ - multiply_pixels (alms->src1, alms->src2, *(alms->dest), alms->length, - alms->bytes1, alms->bytes2); -} - -void -layer_divide_mode (struct apply_layer_mode_struct *alms) -{ - divide_pixels (alms->src1, alms->src2, *(alms->dest), alms->length, - alms->bytes1, alms->bytes2); -} - -void -layer_screen_mode (struct apply_layer_mode_struct *alms) -{ - screen_pixels (alms->src1, alms->src2, *(alms->dest), alms->length, - alms->bytes1, alms->bytes2); -} - -void -layer_overlay_mode (struct apply_layer_mode_struct *alms) -{ - overlay_pixels (alms->src1, alms->src2, *(alms->dest), alms->length, - alms->bytes1, alms->bytes2); -} - -void -layer_difference_mode (struct apply_layer_mode_struct *alms) -{ - difference_pixels (alms->src1, alms->src2, *(alms->dest), alms->length, - alms->bytes1, alms->bytes2); -} - -void -layer_addition_mode (struct apply_layer_mode_struct *alms) -{ - add_pixels (alms->src1, alms->src2, *(alms->dest), alms->length, - alms->bytes1, alms->bytes2); -} - -void -layer_subtract_mode (struct apply_layer_mode_struct *alms) -{ - subtract_pixels (alms->src1, alms->src2, *(alms->dest), alms->length, - alms->bytes1, alms->bytes2); -} - -void -layer_darken_only_mode (struct apply_layer_mode_struct *alms) -{ - darken_pixels (alms->src1, alms->src2, *(alms->dest), alms->length, - alms->bytes1, alms->bytes2); -} - -void -layer_lighten_only_mode (struct apply_layer_mode_struct *alms) -{ - lighten_pixels (alms->src1, alms->src2, *(alms->dest), alms->length, - alms->bytes1, alms->bytes2); -} - -void -layer_hue_mode (struct apply_layer_mode_struct *alms) -{ - /* only works on RGB color images */ - if (alms->bytes1 > 2) - hue_only_pixels (alms->src1, alms->src2, *(alms->dest), alms->length, - alms->bytes1, alms->bytes2); - else - *(alms->dest) = alms->src2; -} - -void -layer_saturation_mode (struct apply_layer_mode_struct *alms) -{ - /* only works on RGB color images */ - if (alms->bytes1 > 2) - saturation_only_pixels (alms->src1, alms->src2, *(alms->dest), - alms->length, alms->bytes1, alms->bytes2); - else - *(alms->dest) = alms->src2; -} - -void -layer_value_mode (struct apply_layer_mode_struct *alms) -{ - /* only works on RGB color images */ - if (alms->bytes1 > 2) - value_only_pixels (alms->src1, alms->src2, *(alms->dest), alms->length, - alms->bytes1, alms->bytes2); - else - *(alms->dest) = alms->src2; -} - -void -layer_color_mode (struct apply_layer_mode_struct *alms) -{ - /* only works on RGB color images */ - if (alms->bytes1 > 2) - color_only_pixels (alms->src1, alms->src2, *(alms->dest), alms->length, - alms->bytes1, alms->bytes2); - else - *(alms->dest) = alms->src2; -} - -void -layer_behind_mode (struct apply_layer_mode_struct *alms) -{ - *(alms->dest) = alms->src2; - if (HAS_ALPHA (alms->bytes1)) - alms->combine = BEHIND_INTEN; - else - alms->combine = NO_COMBINATION; -} - -void -layer_replace_mode (struct apply_layer_mode_struct *alms) -{ - *(alms->dest) = alms->src2; - alms->combine = REPLACE_INTEN; -} - -void -layer_erase_mode (struct apply_layer_mode_struct *alms) -{ - *(alms->dest) = alms->src2; - /* If both sources have alpha channels, call erase function. - * Otherwise, just combine in the normal manner - */ - alms->combine = - (HAS_ALPHA (alms->bytes1) && HAS_ALPHA (alms->bytes2)) ? ERASE_INTEN : 0; -} - -void -layer_anti_erase_mode (struct apply_layer_mode_struct *alms) -{ - *(alms->dest) = alms->src2; - alms->combine = - (HAS_ALPHA (alms->bytes1) && HAS_ALPHA (alms->bytes2)) ? ANTI_ERASE_INTEN : 0; -} - -void -layer_color_erase_mode (struct apply_layer_mode_struct *alms) -{ - *(alms->dest) = alms->src2; - alms->combine = - (HAS_ALPHA (alms->bytes1) && HAS_ALPHA (alms->bytes2)) ? COLOR_ERASE_INTEN : 0; -} - -void -layer_dodge_mode (struct apply_layer_mode_struct *alms) -{ - dodge_pixels (alms->src1, alms->src2, *(alms->dest), alms->length, - alms->bytes1, alms->bytes2); -} - -void -layer_burn_mode (struct apply_layer_mode_struct *alms) -{ - burn_pixels (alms->src1, alms->src2, *(alms->dest), alms->length, - alms->bytes1, alms->bytes2); -} - -void -layer_hardlight_mode (struct apply_layer_mode_struct *alms) -{ - hardlight_pixels (alms->src1, alms->src2, *(alms->dest), alms->length, - alms->bytes1, alms->bytes2); -} - -void -layer_softlight_mode (struct apply_layer_mode_struct *alms) -{ - softlight_pixels (alms->src1, alms->src2, *(alms->dest), alms->length, - alms->bytes1, alms->bytes2); -} - -void -layer_grain_extract_mode (struct apply_layer_mode_struct *alms) -{ - grain_extract_pixels (alms->src1, alms->src2, *(alms->dest), alms->length, - alms->bytes1, alms->bytes2); -} - -void -layer_grain_merge_mode (struct apply_layer_mode_struct *alms) -{ - grain_merge_pixels (alms->src1, alms->src2, *(alms->dest), alms->length, - alms->bytes1, alms->bytes2); -} diff --git a/app/paint-funcs/layer-modes.h b/app/paint-funcs/layer-modes.h deleted file mode 100644 index df513bca11..0000000000 --- a/app/paint-funcs/layer-modes.h +++ /dev/null @@ -1,80 +0,0 @@ -/* GIMP - The GNU Image Manipulation Program - * Copyright (C); 1995 Spencer Kimball and Peter Mattis - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option); any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#ifndef __LAYER_MODES_H__ -#define __LAYER_MODES_H__ - -/* FIXME: This function should not be called directly but - * through layer_dissolve_mode function - */ -void dissolve_pixels (const guchar *src, - const guchar *mask, - guchar *dest, - gint x, - gint y, - gint opacity, - gint length, - gint sb, - gint db, - gboolean has_alpha); - -struct apply_layer_mode_struct -{ - guint bytes1 : 3; - guint bytes2 : 3; - guchar *src1; - guchar *src2; - const guchar *mask; - guchar **dest; - gint x; - gint y; - guint opacity; - guint length; - CombinationMode combine; -}; - -void layer_modes_setup (void); - -void layer_normal_mode (struct apply_layer_mode_struct *alms); -void layer_dissolve_mode (struct apply_layer_mode_struct *alms); -void layer_multiply_mode (struct apply_layer_mode_struct *alms); -void layer_divide_mode (struct apply_layer_mode_struct *alms); -void layer_screen_mode (struct apply_layer_mode_struct *alms); -void layer_overlay_mode (struct apply_layer_mode_struct *alms); -void layer_difference_mode (struct apply_layer_mode_struct *alms); -void layer_addition_mode (struct apply_layer_mode_struct *alms); -void layer_subtract_mode (struct apply_layer_mode_struct *alms); -void layer_darken_only_mode (struct apply_layer_mode_struct *alms); -void layer_lighten_only_mode (struct apply_layer_mode_struct *alms); -void layer_hue_mode (struct apply_layer_mode_struct *alms); -void layer_saturation_mode (struct apply_layer_mode_struct *alms); -void layer_value_mode (struct apply_layer_mode_struct *alms); -void layer_color_mode (struct apply_layer_mode_struct *alms); -void layer_behind_mode (struct apply_layer_mode_struct *alms); -void layer_replace_mode (struct apply_layer_mode_struct *alms); -void layer_erase_mode (struct apply_layer_mode_struct *alms); -void layer_anti_erase_mode (struct apply_layer_mode_struct *alms); -void layer_color_erase_mode (struct apply_layer_mode_struct *alms); -void layer_dodge_mode (struct apply_layer_mode_struct *alms); -void layer_burn_mode (struct apply_layer_mode_struct *alms); -void layer_hardlight_mode (struct apply_layer_mode_struct *alms); -void layer_softlight_mode (struct apply_layer_mode_struct *alms); -void layer_grain_extract_mode (struct apply_layer_mode_struct *alms); -void layer_grain_merge_mode (struct apply_layer_mode_struct *alms); - -#endif - diff --git a/app/paint-funcs/paint-funcs.c b/app/paint-funcs/paint-funcs.c index da9558ee64..0853c2ac89 100644 --- a/app/paint-funcs/paint-funcs.c +++ b/app/paint-funcs/paint-funcs.c @@ -36,7 +36,6 @@ #include "composite/gimp-composite.h" #include "paint-funcs.h" -#include "layer-modes.h" #include "paint-funcs-utils.h" #include "paint-funcs-generic.h" @@ -90,39 +89,6 @@ static const LayerMode layer_modes[] = }; -typedef void (* LayerModeFunc) (struct apply_layer_mode_struct *); - -static const LayerModeFunc layer_mode_funcs[] = -{ - layer_normal_mode, - layer_dissolve_mode, - layer_behind_mode, - layer_multiply_mode, - layer_screen_mode, - layer_overlay_mode, - layer_difference_mode, - layer_addition_mode, - layer_subtract_mode, - layer_darken_only_mode, - layer_lighten_only_mode, - layer_hue_mode, - layer_saturation_mode, - layer_color_mode, - layer_value_mode, - layer_divide_mode, - layer_dodge_mode, - layer_burn_mode, - layer_hardlight_mode, - layer_softlight_mode, - layer_grain_extract_mode, - layer_grain_merge_mode, - layer_color_erase_mode, - layer_erase_mode, - layer_replace_mode, - layer_anti_erase_mode -}; - - static const guchar no_mask = OPAQUE_OPACITY; @@ -248,7 +214,6 @@ cubic (gdouble dx, void paint_funcs_setup (void) { - layer_modes_setup (); } void @@ -3984,38 +3949,28 @@ initial_sub_region (struct initial_regions_struct *st, case INITIAL_INTENSITY: if (mode == GIMP_DISSOLVE_MODE) { - if (gimp_composite_options.bits & GIMP_COMPOSITE_OPTION_USE) - { - GimpCompositeContext ctx; + GimpCompositeContext ctx; - ctx.A = NULL; - ctx.pixelformat_A = GIMP_PIXELFORMAT_RGBA8; + ctx.A = NULL; + ctx.pixelformat_A = GIMP_PIXELFORMAT_RGBA8; - ctx.B = s; - ctx.pixelformat_B = (src->bytes == 1 ? GIMP_PIXELFORMAT_V8 - : src->bytes == 2 ? GIMP_PIXELFORMAT_VA8 - : src->bytes == 3 ? GIMP_PIXELFORMAT_RGB8 - : src->bytes == 4 ? GIMP_PIXELFORMAT_RGBA8 - : GIMP_PIXELFORMAT_ANY); - ctx.D = buf; - ctx.pixelformat_D = ctx.pixelformat_B; + ctx.B = s; + ctx.pixelformat_B = (src->bytes == 1 ? GIMP_PIXELFORMAT_V8 + : src->bytes == 2 ? GIMP_PIXELFORMAT_VA8 + : src->bytes == 3 ? GIMP_PIXELFORMAT_RGB8 + : src->bytes == 4 ? GIMP_PIXELFORMAT_RGBA8 + : GIMP_PIXELFORMAT_ANY); + ctx.D = buf; + ctx.pixelformat_D = ctx.pixelformat_B; - ctx.M = m; + ctx.M = m; - ctx.n_pixels = src->w; - ctx.op = GIMP_COMPOSITE_DISSOLVE; - ctx.dissolve.x = src->x; - ctx.dissolve.y = src->y + h; - ctx.dissolve.opacity = opacity; - gimp_composite_dispatch (&ctx); - } - else - { - dissolve_pixels (s, m, buf, src->x, src->y + h, - opacity, src->w, - src->bytes, src->bytes + 1, - FALSE); - } + ctx.n_pixels = src->w; + ctx.op = GIMP_COMPOSITE_DISSOLVE; + ctx.dissolve.x = src->x; + ctx.dissolve.y = src->y + h; + ctx.dissolve.opacity = opacity; + gimp_composite_dispatch (&ctx); initial_inten_a_pixels (buf, d, NULL, OPAQUE_OPACITY, affect, src->w, src->bytes + 1); @@ -4030,38 +3985,28 @@ initial_sub_region (struct initial_regions_struct *st, case INITIAL_INTENSITY_ALPHA: if (mode == GIMP_DISSOLVE_MODE) { - if (gimp_composite_options.bits & GIMP_COMPOSITE_OPTION_USE) - { - GimpCompositeContext ctx; + GimpCompositeContext ctx; - ctx.A = NULL; - ctx.pixelformat_A = GIMP_PIXELFORMAT_RGBA8; + ctx.A = NULL; + ctx.pixelformat_A = GIMP_PIXELFORMAT_RGBA8; - ctx.B = s; - ctx.pixelformat_B = (src->bytes == 1 ? GIMP_PIXELFORMAT_V8 - : src->bytes == 2 ? GIMP_PIXELFORMAT_VA8 - : src->bytes == 3 ? GIMP_PIXELFORMAT_RGB8 - : src->bytes == 4 ? GIMP_PIXELFORMAT_RGBA8 - : GIMP_PIXELFORMAT_ANY); - ctx.D = buf; - ctx.pixelformat_D = ctx.pixelformat_B; + ctx.B = s; + ctx.pixelformat_B = (src->bytes == 1 ? GIMP_PIXELFORMAT_V8 + : src->bytes == 2 ? GIMP_PIXELFORMAT_VA8 + : src->bytes == 3 ? GIMP_PIXELFORMAT_RGB8 + : src->bytes == 4 ? GIMP_PIXELFORMAT_RGBA8 + : GIMP_PIXELFORMAT_ANY); + ctx.D = buf; + ctx.pixelformat_D = ctx.pixelformat_B; - ctx.M = m; + ctx.M = m; - ctx.n_pixels = src->w; - ctx.op = GIMP_COMPOSITE_DISSOLVE; - ctx.dissolve.x = src->x; - ctx.dissolve.y = src->y + h; - ctx.dissolve.opacity = opacity; - gimp_composite_dispatch (&ctx); - } - else - { - dissolve_pixels (s, m, buf, src->x, src->y + h, - opacity, src->w, - src->bytes, src->bytes, - TRUE); - } + ctx.n_pixels = src->w; + ctx.op = GIMP_COMPOSITE_DISSOLVE; + ctx.dissolve.x = src->x; + ctx.dissolve.y = src->y + h; + ctx.dissolve.opacity = opacity; + gimp_composite_dispatch (&ctx); initial_inten_a_pixels (buf, d, NULL, OPAQUE_OPACITY, affect, src->w, src->bytes); @@ -4270,73 +4215,44 @@ combine_sub_region (struct combine_regions_struct *st, { /* Now, apply the paint mode */ - if (gimp_composite_options.bits & GIMP_COMPOSITE_OPTION_USE) - { - GimpCompositeContext ctx; + GimpCompositeContext ctx; - ctx.A = s1; - ctx.pixelformat_A = (src1->bytes == 1 ? GIMP_PIXELFORMAT_V8 : - src1->bytes == 2 ? GIMP_PIXELFORMAT_VA8 : - src1->bytes == 3 ? GIMP_PIXELFORMAT_RGB8 : - src1->bytes == 4 ? GIMP_PIXELFORMAT_RGBA8 : - GIMP_PIXELFORMAT_ANY); + ctx.A = s1; + ctx.pixelformat_A = (src1->bytes == 1 ? GIMP_PIXELFORMAT_V8 : + src1->bytes == 2 ? GIMP_PIXELFORMAT_VA8 : + src1->bytes == 3 ? GIMP_PIXELFORMAT_RGB8 : + src1->bytes == 4 ? GIMP_PIXELFORMAT_RGBA8 : + GIMP_PIXELFORMAT_ANY); - ctx.B = s2; - ctx.pixelformat_B = (src2->bytes == 1 ? GIMP_PIXELFORMAT_V8 : - src2->bytes == 2 ? GIMP_PIXELFORMAT_VA8 : - src2->bytes == 3 ? GIMP_PIXELFORMAT_RGB8 : - src2->bytes == 4 ? GIMP_PIXELFORMAT_RGBA8 : - GIMP_PIXELFORMAT_ANY); + ctx.B = s2; + ctx.pixelformat_B = (src2->bytes == 1 ? GIMP_PIXELFORMAT_V8 : + src2->bytes == 2 ? GIMP_PIXELFORMAT_VA8 : + src2->bytes == 3 ? GIMP_PIXELFORMAT_RGB8 : + src2->bytes == 4 ? GIMP_PIXELFORMAT_RGBA8 : + GIMP_PIXELFORMAT_ANY); - ctx.D = s; - ctx.pixelformat_D = ctx.pixelformat_A; + ctx.D = s; + ctx.pixelformat_D = ctx.pixelformat_A; - ctx.M = layer_mode_mask; - ctx.pixelformat_M = GIMP_PIXELFORMAT_ANY; + ctx.M = layer_mode_mask; + ctx.pixelformat_M = GIMP_PIXELFORMAT_ANY; - ctx.n_pixels = src1->w; - ctx.combine = combine; - ctx.op = mode; + ctx.n_pixels = src1->w; + ctx.combine = combine; + ctx.op = mode; - ctx.dissolve.x = src1->x; - ctx.dissolve.y = src1->y + h; - ctx.dissolve.opacity = layer_mode_opacity; + ctx.dissolve.x = src1->x; + ctx.dissolve.y = src1->y + h; + ctx.dissolve.opacity = layer_mode_opacity; - mode_affect = - gimp_composite_operation_effects[mode].affect_opacity; + mode_affect = + gimp_composite_operation_effects[mode].affect_opacity; - gimp_composite_dispatch (&ctx); + gimp_composite_dispatch (&ctx); - s = ctx.D; - combine = (ctx.combine == NO_COMBINATION) ? type : ctx.combine; - } - else - { - struct apply_layer_mode_struct alms; + s = ctx.D; + combine = (ctx.combine == NO_COMBINATION) ? type : ctx.combine; - alms.src1 = s1; - alms.src2 = s2; - alms.mask = layer_mode_mask; - alms.dest = &s; - alms.x = src1->x; - alms.y = src1->y + h; - alms.opacity = layer_mode_opacity; - alms.combine = combine; - alms.length = src1->w; - alms.bytes1 = src1->bytes; - alms.bytes2 = src2->bytes; - - /* Determine whether the alpha channel of the destination - * can be affected by the specified mode. -- This keeps - * consistency with varying opacities. - */ - mode_affect = layer_modes[mode].affect_alpha; - - layer_mode_funcs[mode] (&alms); - - combine = (alms.combine == NO_COMBINATION ? - type : alms.combine); - } } break; diff --git a/devel-docs/app/app-sections.txt b/devel-docs/app/app-sections.txt index 470e618c39..87b8fc4d0c 100644 --- a/devel-docs/app/app-sections.txt +++ b/devel-docs/app/app-sections.txt @@ -8873,7 +8873,6 @@ gimp_composite_pixelformat_astext gimp_composite_mode_astext gimp_composite_use_cpu_accel GIMP_COMPOSITE_OPTION_NOEXTENSIONS -GIMP_COMPOSITE_OPTION_USE GIMP_COMPOSITE_OPTION_VERBOSE