diff --git a/ChangeLog b/ChangeLog index 57efa0cbdf..4900163e5b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,71 @@ +2001-05-15 Michael Natterer + + * configure.in: new directory app/base/ + + * app/Makefile.am + * app/boundary.[ch] + * app/brush_scale.[ch] + * app/gimpchecks.h + * app/gimplut.[ch] + * app/pixel_processor.[ch] + * app/pixel_region.[ch] + * app/pixel_surround.[ch] + * app/temp_buf.[ch] + * app/tile.[ch] + * app/tile_cache.[ch] + * app/tile_manager.[ch] + * app/tile_manager_pvt.h + * app/tile_pvt.h + * app/tile_swap.[ch]: moved to base/ + + * app/base/Makefile.am + * app/base/base-types.h + * app/base/*: new directory for the sub-object pixel maniplation + and storage stuff. Does not include Gtk+ or anything outside + base/. Did some cleanup in all files. + + * app/appenums.h + * app/apptypes.h + * app/core/gimpimage.h: removed types which are now in + base/base-types.h. + + * app/base/base-config.[ch] + * app/gimprc.[ch]: put the config variables for base/ to their own + file so base/ doesn not have to include gimprc.h (does not yet + work, i.e. the variables are un-configurable right now) + + * app/main.c: set a log handler for "Gimp-Base". + + * app/paint-funcs/Makefile.am + * app/paint-funcs/paint-funcs.[ch]: removed the color hash which + maps RGB to color indices because it's a totally standalone system + which has nothing to do with the paint-funcs and introduced a + GimpImage dependency. + + paint-funcs/ should be considered on the same sub-object + (glib-only) level as base/, only in a different directory. + + * app/core/Makefile.am + * app/core/gimpimage-colorhash.[ch]: put the color hash here. + + * app/gimage.c: don't invalidate the color hash here... + + * app/core/gimpimage.c: ... but in the colormap_changed() default + inplementation. Initialize the hash in class_init(). + + * tools/pdbgen/Makefile.am: scan app/base/base-types.h for enums. + + * tools/pdbgen/enums.pl: regenerated. + + * app/[lots] + * app/core/[of] + * app/gui/[files] + * app/pdb/[all] + * app/tools/[over] + * app/widgets/[the] + * tools/pdbgen/pdb/[place]: changed #includes accordingly. And use + base_config->value instead of the stuff from gimprc.h. + 2001-05-14 Michael Natterer * README.patch_xinput_airbrush diff --git a/app/Makefile.am b/app/Makefile.am index 716daae3df..6a217da163 100644 --- a/app/Makefile.am +++ b/app/Makefile.am @@ -1,6 +1,6 @@ ## Process this file with automake to produce Makefile.in -SUBDIRS = paint-funcs core pdb tools widgets gui +SUBDIRS = paint-funcs base core pdb tools widgets gui scriptdata = @@ -101,36 +101,6 @@ gimp_SOURCES = \ scan_convert.c \ scan_convert.h \ ## -## lowlevel stuff for base/ -## - boundary.c \ - boundary.h \ - brush_scale.c \ - brush_scale.h \ - gimpcheck.h \ - gimplut.c \ - gimplut.h \ - lut_funcs.c \ - lut_funcs.h \ - pixel_processor.c \ - pixel_processor.h \ - pixel_region.c \ - pixel_region.h \ - pixel_surround.c \ - pixel_surround.h \ - temp_buf.c \ - temp_buf.h \ - tile.c \ - tile.h \ - tile_pvt.h \ - tile_cache.c \ - tile_cache.h \ - tile_manager.c \ - tile_manager.h \ - tile_manager_pvt.h \ - tile_swap.c \ - tile_swap.h \ -## ## stuff that needs to be sorted into yet undecided subsystems, split up, ## removed or otherwise tortured ## @@ -171,6 +141,8 @@ gimp_SOURCES = \ image_new.h \ libgimp_glue.c \ libgimp_glue.h \ + lut_funcs.c \ + lut_funcs.h \ main.c \ path.c \ path.h \ @@ -225,6 +197,7 @@ gimp_LDADD = \ gui/libappgui.la \ widgets/libappwidgets.la \ core/libappcore.la \ + base/libappbase.la \ $(top_builddir)/libgimpcolor/libgimpcolor-$(LT_RELEASE).la \ $(top_builddir)/libgimpmath/libgimpmath-$(LT_RELEASE).la \ $(top_builddir)/libgimpwidgets/libgimpwidgets-$(LT_RELEASE).la \ diff --git a/app/actions/plug-in-commands.c b/app/actions/plug-in-commands.c index 2b9b8afa01..37a596f9d2 100644 --- a/app/actions/plug-in-commands.c +++ b/app/actions/plug-in-commands.c @@ -85,6 +85,9 @@ #include "libgimp/gimpprotocol.h" #include "libgimp/gimpwire.h" +#include "base/tile.h" +#include "base/tile-manager.h" + #include "core/gimpdrawable.h" #include "core/gimpimage.h" @@ -102,8 +105,6 @@ #include "gimpprogress.h" #include "gimprc.h" #include "plug_in.h" -#include "tile.h" -#include "tile_manager.h" #include "libgimp/gimpintl.h" diff --git a/app/app_procs.c b/app/app_procs.c index 6331ed354e..3ffb32b800 100644 --- a/app/app_procs.c +++ b/app/app_procs.c @@ -46,6 +46,10 @@ #include "core/core-types.h" #include "tools/tools-types.h" +#include "base/base-config.h" +#include "base/temp-buf.h" +#include "base/tile-swap.h" + #include "paint-funcs/paint-funcs.h" #include "core/gimpdatafactory.h" @@ -75,8 +79,6 @@ #include "plug_in.h" #include "module_db.h" -#include "temp_buf.h" -#include "tile_swap.h" #include "undo.h" #include "unitrc.h" #include "xcf.h" @@ -165,7 +167,7 @@ app_init (void) g_free (filename); - if (parse_buffers_init ()) + if (gimprc_init ()) { parse_unitrc (); /* this needs to be done before gimprc loading */ parse_gimprc (); /* parse the local GIMP configuration file */ @@ -243,12 +245,13 @@ app_init (void) RESET_BAR(); /* Add the swap file */ - if (swap_path == NULL) - swap_path = g_get_tmp_dir (); + if (base_config->swap_path == NULL) + base_config->swap_path = g_get_tmp_dir (); toast_old_temp_files (); path = g_strdup_printf ("%s" G_DIR_SEPARATOR_S "gimpswap.%lu", - swap_path, (unsigned long) getpid ()); + base_config->swap_path, + (unsigned long) getpid ()); tile_swap_add (path, NULL, NULL); g_free (path); @@ -380,7 +383,7 @@ toast_old_temp_files (void) struct dirent *entry; GString *filename = g_string_new (""); - dir = opendir (swap_path); + dir = opendir (base_config->swap_path); if (!dir) return; @@ -405,7 +408,7 @@ toast_old_temp_files (void) * so no harm trying. */ g_string_sprintf (filename, "%s" G_DIR_SEPARATOR_S "%s", - swap_path, entry->d_name); + base_config->swap_path, entry->d_name); unlink (filename->str); } } diff --git a/app/appenums.h b/app/appenums.h index 90677d004a..8d466e6afa 100644 --- a/app/appenums.h +++ b/app/appenums.h @@ -30,41 +30,6 @@ typedef enum NO_FILL /*< nick=NO_IMAGE_FILL >*/ } GimpFillType; -/* Layer modes */ -typedef enum -{ - NORMAL_MODE, - DISSOLVE_MODE, - BEHIND_MODE, - MULTIPLY_MODE, - SCREEN_MODE, - OVERLAY_MODE, - DIFFERENCE_MODE, - ADDITION_MODE, - SUBTRACT_MODE, - DARKEN_ONLY_MODE, - LIGHTEN_ONLY_MODE, - HUE_MODE, - SATURATION_MODE, - COLOR_MODE, - VALUE_MODE, - DIVIDE_MODE, - DODGE_MODE, - BURN_MODE, - HARDLIGHT_MODE, - ERASE_MODE, /*< skip >*/ - REPLACE_MODE, /*< skip >*/ - ANTI_ERASE_MODE /*< skip >*/ -} LayerModeEffects; - -/* Types of convolutions */ -typedef enum -{ - NORMAL_CONVOL, /* Negative numbers truncated */ - ABSOLUTE_CONVOL, /* Absolute value */ - NEGATIVE_CONVOL /* add 127 to values */ -} ConvolutionType; - /* Brush application types */ typedef enum { @@ -99,13 +64,6 @@ typedef enum ONCE_END_COLOR /* paint once, but keep painting with the end color */ } GradientPaintMode; -typedef enum -{ - LINEAR_INTERPOLATION, - CUBIC_INTERPOLATION, - NEAREST_NEIGHBOR_INTERPOLATION -} InterpolationType; - typedef enum /*< skip >*/ { ORIENTATION_UNKNOWN, diff --git a/app/appenv.h b/app/appenv.h index b0ca0140be..d868003ea7 100644 --- a/app/appenv.h +++ b/app/appenv.h @@ -44,9 +44,4 @@ extern MessageHandlerType message_handler; extern gboolean gimp_busy; -#ifdef G_OS_WIN32 -gchar * quote_spaces (gchar *string); -#endif - - #endif /* __APPENV_H__ */ diff --git a/app/apptypes.h b/app/apptypes.h index 59207ab4f5..5fccd82d4f 100644 --- a/app/apptypes.h +++ b/app/apptypes.h @@ -25,6 +25,8 @@ #include "libgimpcolor/gimpcolortypes.h" #include "libgimpmath/gimpmathtypes.h" +#include "base/base-types.h" + #include "undo_types.h" #include "appenums.h" @@ -34,8 +36,6 @@ typedef struct _Argument Argument; -typedef struct _BoundSeg BoundSeg; - typedef struct _ColorNotebook ColorNotebook; typedef struct _GDisplay GDisplay; @@ -44,8 +44,6 @@ typedef struct _GimpHistogram GimpHistogram; typedef struct _GimpImageNewValues GimpImageNewValues; -typedef struct _GimpLut GimpLut; - typedef struct _GimpParasite GimpParasite; typedef struct _GimpProgress GimpProgress; @@ -66,23 +64,11 @@ typedef struct _PlugInProcDef PlugInProcDef; typedef struct _ParasiteList ParasiteList; -typedef struct _PixelRegionIterator PixelRegionIterator; -typedef struct _PixelRegion PixelRegion; -typedef struct _PixelRegionHolder PixelRegionHolder; - typedef struct _ProcArg ProcArg; typedef struct _ProcRecord ProcRecord; typedef guint32 Tattoo; -typedef struct _TempBuf TempBuf; -typedef struct _TempBuf MaskBuf; - -typedef struct _Tile Tile; -typedef struct _TileManager TileManager; - -typedef struct _ScanConvertPoint ScanConvertPoint; - typedef struct _Selection Selection; @@ -99,9 +85,6 @@ typedef GSList PathUndo; /* functions */ -typedef void (* TileValidateProc) (TileManager *tm, - Tile *tile); - typedef void (* ImageMapApplyFunc) (PixelRegion *srcPR, PixelRegion *destPR, gpointer data); diff --git a/app/base/Makefile.am b/app/base/Makefile.am index 0391654a3b..a1cf9cb63b 100644 --- a/app/base/Makefile.am +++ b/app/base/Makefile.am @@ -3,6 +3,9 @@ noinst_LTLIBRARIES = libappbase.la libappbase_la_SOURCES = \ + base-types.h \ + base-config.c \ + base-config.h \ boundary.c \ boundary.h \ brush-scale.c \ diff --git a/app/tile_cache.h b/app/base/base-config.c similarity index 75% rename from app/tile_cache.h rename to app/base/base-config.c index 2f6b873207..bc752e85ec 100644 --- a/app/tile_cache.h +++ b/app/base/base-config.c @@ -16,13 +16,23 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#ifndef __TILE_CACHE_H__ -#define __TILE_CACHE_H__ +#include "config.h" + +#include + +#include "base-types.h" + +#include "base-config.h" -void tile_cache_insert (Tile *tile); -void tile_cache_flush (Tile *tile); -void tile_cache_set_size (gulong cache_size); +static GimpBaseConfig static_base_config = +{ + NULL, + NULL, + 33554432, /* 32 MB */ + FALSE, + LINEAR_INTERPOLATION +}; -#endif /* __TILE_CACHE_H__ */ +GimpBaseConfig *base_config = &static_base_config; diff --git a/app/brush_scale.h b/app/base/base-config.h similarity index 68% rename from app/brush_scale.h rename to app/base/base-config.h index 3566a89f04..e0ea4970cd 100644 --- a/app/brush_scale.h +++ b/app/base/base-config.h @@ -16,23 +16,23 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#ifndef __BRUSH_SCALE_H__ -#define __BRUSH_SCALE_H__ - - -MaskBuf * brush_scale_mask (MaskBuf *brush_mask, - gint dest_width, - gint dest_height); -MaskBuf * brush_scale_pixmap (MaskBuf *pixmap, - gint dest_width, - gint dest_height); - - -#endif /* __BRUSH_SCALE_H__ */ - +#ifndef __BASE_CONFIG_H__ +#define __BASE_CONFIG_H__ +typedef struct _GimpBaseConfig GimpBaseConfig; + +struct _GimpBaseConfig +{ + gchar *temp_path; + gchar *swap_path; + guint tile_cache_size; + gboolean stingy_memory_use; + InterpolationType interpolation_type; +}; +extern GimpBaseConfig *base_config; +#endif /* __BASE_CONFIG_H__ */ diff --git a/app/base/base-types.h b/app/base/base-types.h new file mode 100644 index 0000000000..82b5081778 --- /dev/null +++ b/app/base/base-types.h @@ -0,0 +1,125 @@ +/* The GIMP -- an 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 2 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, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#ifndef __BASE_TYPES_H__ +#define __BASE_TYPES_H__ + + +/* magic constants */ + +#define MAX_CHANNELS 4 + +#define GRAY_PIX 0 +#define ALPHA_G_PIX 1 +#define RED_PIX 0 +#define GREEN_PIX 1 +#define BLUE_PIX 2 +#define ALPHA_PIX 3 +#define INDEXED_PIX 0 +#define ALPHA_I_PIX 1 + + +/* enums */ + +/* Layer modes */ +typedef enum +{ + NORMAL_MODE, + DISSOLVE_MODE, + BEHIND_MODE, + MULTIPLY_MODE, + SCREEN_MODE, + OVERLAY_MODE, + DIFFERENCE_MODE, + ADDITION_MODE, + SUBTRACT_MODE, + DARKEN_ONLY_MODE, + LIGHTEN_ONLY_MODE, + HUE_MODE, + SATURATION_MODE, + COLOR_MODE, + VALUE_MODE, + DIVIDE_MODE, + DODGE_MODE, + BURN_MODE, + HARDLIGHT_MODE, + ERASE_MODE, /*< skip >*/ + REPLACE_MODE, /*< skip >*/ + ANTI_ERASE_MODE /*< skip >*/ +} LayerModeEffects; + +/* Types of convolutions */ +typedef enum +{ + NORMAL_CONVOL, /* Negative numbers truncated */ + ABSOLUTE_CONVOL, /* Absolute value */ + NEGATIVE_CONVOL /* add 127 to values */ +} ConvolutionType; + +typedef enum +{ + LINEAR_INTERPOLATION, + CUBIC_INTERPOLATION, + NEAREST_NEIGHBOR_INTERPOLATION +} InterpolationType; + +/* Transparency representation */ +typedef enum /*< skip >*/ +{ + LIGHT_CHECKS = 0, + GRAY_CHECKS = 1, + DARK_CHECKS = 2, + WHITE_ONLY = 3, + GRAY_ONLY = 4, + BLACK_ONLY = 5 +} GimpCheckType; + +typedef enum /*< skip >*/ +{ + SMALL_CHECKS = 0, + MEDIUM_CHECKS = 1, + LARGE_CHECKS = 2 +} GimpCheckSize; + + +/* types */ + +typedef struct _BoundSeg BoundSeg; + +typedef struct _GimpLut GimpLut; + +typedef struct _PixelRegionIterator PixelRegionIterator; +typedef struct _PixelRegion PixelRegion; +typedef struct _PixelRegionHolder PixelRegionHolder; + +typedef struct _TempBuf TempBuf; +typedef struct _TempBuf MaskBuf; + +typedef struct _Tile Tile; +typedef struct _TileManager TileManager; + +typedef struct _ScanConvertPoint ScanConvertPoint; + + +/* functions */ + +typedef void (* TileValidateProc) (TileManager *tm, + Tile *tile); + + +#endif /* __BASE_TYPES_H__ */ diff --git a/app/base/boundary.c b/app/base/boundary.c index e636cfc84a..d416eadd52 100644 --- a/app/base/boundary.c +++ b/app/base/boundary.c @@ -22,13 +22,12 @@ #include -#include "apptypes.h" +#include "base-types.h" #include "boundary.h" -#include "errors.h" -#include "pixel_region.h" +#include "pixel-region.h" #include "tile.h" -#include "tile_manager.h" +#include "tile-manager.h" /* half intensity for mask */ @@ -237,9 +236,6 @@ make_seg (gint x1, tmp_segs = (BoundSeg *) g_realloc ((void *) tmp_segs, sizeof (BoundSeg) * max_segs); - - if (!tmp_segs) - gimp_fatal_error ("make_seg(): Unable to reallocate segments array for mask boundary."); } tmp_segs[num_segs].x1 = x1; @@ -280,9 +276,6 @@ allocate_empty_segs (void) empty_segs_n = (gint *) g_realloc (empty_segs_n, sizeof (gint) * max_empty_segs); empty_segs_c = (gint *) g_realloc (empty_segs_c, sizeof (gint) * max_empty_segs); empty_segs_l = (gint *) g_realloc (empty_segs_l, sizeof (gint) * max_empty_segs); - - if (!empty_segs_n || !empty_segs_l || !empty_segs_c) - gimp_fatal_error ("allocate_empty_segs(): Unable to reallocate empty segments array for mask boundary."); } } diff --git a/app/base/boundary.h b/app/base/boundary.h index 5fbebf1a80..5767b092b0 100644 --- a/app/base/boundary.h +++ b/app/base/boundary.h @@ -38,16 +38,16 @@ struct _BoundSeg }; -BoundSeg * find_mask_boundary (PixelRegion *maskPR, - gint *num_elems, - BoundaryType type, - gint x1, - gint y1, - gint x2, - gint y2); -BoundSeg * sort_boundary (BoundSeg *segs, - gint num_segs, - gint *num_groups); +BoundSeg * find_mask_boundary (PixelRegion *maskPR, + gint *num_elems, + BoundaryType type, + gint x1, + gint y1, + gint x2, + gint y2); +BoundSeg * sort_boundary (BoundSeg *segs, + gint num_segs, + gint *num_groups); #endif /* __BOUNDARY_H__ */ diff --git a/app/base/brush-scale.c b/app/base/brush-scale.c index 8420939d4c..2008b9bd32 100644 --- a/app/base/brush-scale.c +++ b/app/base/brush-scale.c @@ -20,10 +20,10 @@ #include -#include "apptypes.h" +#include "base-types.h" -#include "brush_scale.h" -#include "temp_buf.h" +#include "brush-scale.h" +#include "temp-buf.h" MaskBuf * diff --git a/app/base/brush-scale.h b/app/base/brush-scale.h index 3566a89f04..e13d000c2b 100644 --- a/app/base/brush-scale.h +++ b/app/base/brush-scale.h @@ -29,10 +29,3 @@ MaskBuf * brush_scale_pixmap (MaskBuf *pixmap, #endif /* __BRUSH_SCALE_H__ */ - - - - - - - diff --git a/app/base/gimphistogram.c b/app/base/gimphistogram.c index 0dab16f1ed..e7e6668052 100644 --- a/app/base/gimphistogram.c +++ b/app/base/gimphistogram.c @@ -27,17 +27,17 @@ #include #include "libgimpmath/gimpmath.h" -#include "libgimpwidgets/gimpwidgets.h" #include "core/core-types.h" +#include "base/pixel-processor.h" +#include "base/pixel-region.h" + #include "core/gimpdrawable.h" #include "core/gimpimage.h" #include "gimphistogram.h" #include "gimprc.h" -#include "pixel_processor.h" -#include "pixel_region.h" struct _GimpHistogram diff --git a/app/base/gimplut.c b/app/base/gimplut.c index 7bca4744db..3e5442abc0 100644 --- a/app/base/gimplut.c +++ b/app/base/gimplut.c @@ -22,25 +22,25 @@ #include -#include +#include -#include "apptypes.h" +#include "base-types.h" #include "gimplut.h" -#include "pixel_region.h" +#include "pixel-region.h" GimpLut * gimp_lut_new (void) { - GimpLut *lut; + GimpLut *lut; - lut = g_new (GimpLut, 1); + lut = g_new (GimpLut, 1); - lut->luts = NULL; - lut->nchannels = 0; + lut->luts = NULL; + lut->nchannels = 0; - return lut; + return lut; } void @@ -50,6 +50,7 @@ gimp_lut_free (GimpLut *lut) for (i = 0; i < lut->nchannels; i++) g_free (lut->luts[i]); + g_free (lut->luts); } @@ -66,17 +67,22 @@ gimp_lut_setup (GimpLut *lut, { for (i = 0; i < lut->nchannels; i++) g_free (lut->luts[i]); + g_free (lut->luts); } + lut->nchannels = nchannels; - lut->luts = g_new (guchar*, lut->nchannels); + lut->luts = g_new (guchar *, lut->nchannels); for (i = 0; i < lut->nchannels; i++) { lut->luts[i] = g_new (guchar, 256); + for (v = 0; v < 256; v++) - { /* to add gamma correction use func(v ^ g) ^ 1/g instead. */ + { + /* to add gamma correction use func(v ^ g) ^ 1/g instead. */ val = 255.0 * func (user_data, lut->nchannels, i, v/255.0) + 0.5; + if (val < 0.0) lut->luts[i][v] = 0; else if (val >= 255.0) @@ -114,11 +120,11 @@ gimp_lut_process (GimpLut *lut, if (lut->nchannels > 3) lut3 = lut->luts[3]; - h = srcPR->h; - src = srcPR->data; - dest = destPR->data; - width = srcPR->w; - src_r_i = srcPR->rowstride - (srcPR->bytes * srcPR->w); + h = srcPR->h; + src = srcPR->data; + dest = destPR->data; + width = srcPR->w; + src_r_i = srcPR->rowstride - (srcPR->bytes * srcPR->w); dest_r_i = destPR->rowstride - (destPR->bytes * srcPR->w); if (src_r_i == 0 && dest_r_i == 0) @@ -196,9 +202,9 @@ gimp_lut_process_inline (GimpLut *lut, if (lut->nchannels > 3) lut3 = lut->luts[3]; - h = srcPR->h; - src = srcPR->data; - width = srcPR->w; + h = srcPR->h; + src = srcPR->data; + width = srcPR->w; src_r_i = srcPR->rowstride - (srcPR->bytes * srcPR->w); if (src_r_i == 0) diff --git a/app/base/gimplut.h b/app/base/gimplut.h index 24f31ccf2f..f1c92da43b 100644 --- a/app/base/gimplut.h +++ b/app/base/gimplut.h @@ -29,14 +29,18 @@ struct _GimpLut }; /* TODO: the GimpLutFunc should really be passed the ColorModel of the region, - not just the number of channels */ + * not just the number of channels + */ + /* GimpLutFuncs should assume that the input and output gamma are 1.0 - and do no correction as this will be handled by gimp_lut_setup */ + * and do no correction as this will be handled by gimp_lut_setup + */ typedef gfloat (*GimpLutFunc) (gpointer user_data, gint nchannels, gint channel, gfloat value); + GimpLut * gimp_lut_new (void); void gimp_lut_free (GimpLut *lut); @@ -46,8 +50,9 @@ void gimp_lut_setup (GimpLut *lut, gint nchannels); /* gimp_lut_setup_exact is currently identical to gimp_lut_setup. It - however is guaranteed to never perform any interpolation or gamma - correction on the lut */ + * however is guaranteed to never perform any interpolation or gamma + * correction on the lut + */ void gimp_lut_setup_exact (GimpLut *lut, GimpLutFunc func, gpointer user_data, @@ -58,19 +63,20 @@ void gimp_lut_process (GimpLut *lut, PixelRegion *destPR); /* gimp_lut_process_inline is like gimp_lut_process except it uses a - single PixelRegion as both the source and destination */ + * single PixelRegion as both the source and destination + */ void gimp_lut_process_inline (GimpLut *lut, PixelRegion *src_destPR); /* gimp_lut_process_2 is the same as gimp_lut_process but the lut - perameter is last instead of first. this is necesary because - pixel_region_process_paralell sends the user_data as the 1st - parameter, and the image_map functions send user_data as the last - parameter */ + * parameter is last instead of first. this is necesary because + * pixel_region_process_paralell sends the user_data as the 1st + * parameter, and the image_map functions send user_data as the last + * parameter + */ void gimp_lut_process_2 (PixelRegion *srcPR, PixelRegion *destPR, GimpLut *lut); #endif /* __GIMP_LUT_H__ */ - diff --git a/app/base/lut-funcs.c b/app/base/lut-funcs.c index 0a5d07704a..3a101ec8ad 100644 --- a/app/base/lut-funcs.c +++ b/app/base/lut-funcs.c @@ -26,7 +26,8 @@ #include "core/core-types.h" -#include "gimplut.h" +#include "base/gimplut.h" + #include "gimphistogram.h" diff --git a/app/base/pixel-processor.c b/app/base/pixel-processor.c index 8d3cf8a2ce..ec3e0788a7 100644 --- a/app/base/pixel-processor.c +++ b/app/base/pixel-processor.c @@ -29,10 +29,10 @@ #include -#include "apptypes.h" +#include "base-types.h" -#include "pixel_processor.h" -#include "pixel_region.h" +#include "pixel-processor.h" +#include "pixel-region.h" #ifdef ENABLE_MP #include "tile.h" @@ -54,6 +54,7 @@ typedef void (* p4_func) (gpointer , PixelRegion *, PixelRegion *); + struct _PixelProcessor { gpointer data; @@ -68,23 +69,24 @@ struct _PixelProcessor ProgressReportFunc progress_report_func; }; + IF_THREAD( static void * do_parallel_regions (PixelProcessor *p_s) { PixelRegion tr[4]; - int ntiles = 0; - int i; - int cont = 1; + gint n tiles = 0; + gint i; + gint cont = 1; - pthread_mutex_lock(&p_s->mutex); + pthread_mutex_lock (&p_s->mutex); if (p_s->nthreads != 0 && p_s->PRI) p_s->PRI = (PixelRegionIterator*)pixel_regions_process(p_s->PRI); if (p_s->PRI == NULL) { - pthread_mutex_unlock(&p_s->mutex); + pthread_mutex_unlock (&p_s->mutex); return NULL; } @@ -100,7 +102,7 @@ do_parallel_regions (PixelProcessor *p_s) tile_lock(tr[i].curtile); } - pthread_mutex_unlock(&p_s->mutex); + pthread_mutex_unlock (&p_s->mutex); ntiles++; switch(p_s->n_regions) @@ -136,7 +138,7 @@ do_parallel_regions (PixelProcessor *p_s) p_s->n_regions); } - pthread_mutex_lock(&p_s->mutex); + pthread_mutex_lock (&p_s->mutex); for (i = 0; i < p_s->n_regions; i++) if (p_s->r[i]) @@ -157,7 +159,7 @@ do_parallel_regions (PixelProcessor *p_s) p_s->nthreads--; - pthread_mutex_unlock(&p_s->mutex); + pthread_mutex_unlock (&p_s->mutex); return NULL; } @@ -372,7 +374,7 @@ pixel_regions_process_parallel_progress (p_func f, va_list va; va_start (va, num_regions); - + ret = pixel_regions_real_process_parallel (f, data, progress_func, progress_data, num_regions, va); @@ -403,13 +405,13 @@ pixel_processor_cont (PixelProcessor *pp) if (pp->PRI) return pp; - + pixel_processor_free (pp); return NULL; } -void +void pixel_processor_free (PixelProcessor *pp) { if (pp->PRI) @@ -417,4 +419,3 @@ pixel_processor_free (PixelProcessor *pp) else g_free(pp); } - diff --git a/app/base/pixel-processor.h b/app/base/pixel-processor.h index b1888c36b8..3ea60a94fd 100644 --- a/app/base/pixel-processor.h +++ b/app/base/pixel-processor.h @@ -24,28 +24,29 @@ typedef struct _PixelProcessor PixelProcessor; + typedef void (* p_func) (void); -typedef gint (* ProgressReportFunc) (void *, - gint, - gint, - gint, - gint); +typedef gint (* ProgressReportFunc) (gpointer , + gint , + gint , + gint , + gint ); -void pixel_regions_process_parallel (p_func f, - gpointer data, - gint num_regions, +void pixel_regions_process_parallel (p_func f, + gpointer data, + gint num_regions, ...); -PixelProcessor * pixel_process_progress (p_func f, - gpointer data, +PixelProcessor * pixel_process_progress (p_func f, + gpointer data, ProgressReportFunc progress_func, - gpointer progress_data, - gint num_regions, + gpointer progress_data, + gint num_regions, ...); -void pixel_processor_free (PixelProcessor *); -void pixel_processor_stop (PixelProcessor *); -PixelProcessor * pixel_processor_cont (PixelProcessor *); +void pixel_processor_free (PixelProcessor *pp); +void pixel_processor_stop (PixelProcessor *pp); +PixelProcessor * pixel_processor_cont (PixelProcessor *pp); #endif /* __PIXEL_PROCESSOR_H__ */ diff --git a/app/base/pixel-region.c b/app/base/pixel-region.c index 4fdd2bc4ae..c21530aaf3 100644 --- a/app/base/pixel-region.c +++ b/app/base/pixel-region.c @@ -21,12 +21,12 @@ #include #include -#include +#include -#include "apptypes.h" +#include "base-types.h" -#include "pixel_region.h" -#include "tile_manager.h" +#include "pixel-region.h" +#include "tile-manager.h" #include "tile.h" @@ -147,7 +147,7 @@ pixel_region_get_row (PixelRegion *PR, { for (b = 0; b < tilebpp; b++) *data++ = tile_data[b]; - + tile_data += inc; } } diff --git a/app/base/pixel-region.h b/app/base/pixel-region.h index b34b197ec9..f03adf4c8e 100644 --- a/app/base/pixel-region.h +++ b/app/base/pixel-region.h @@ -19,6 +19,7 @@ #ifndef __PIXEL_REGION_H__ #define __PIXEL_REGION_H__ + struct _PixelRegion { guchar *data; /* pointer to region data */ diff --git a/app/base/pixel-surround.c b/app/base/pixel-surround.c index 2f14508566..281f7591b4 100644 --- a/app/base/pixel-surround.c +++ b/app/base/pixel-surround.c @@ -18,15 +18,13 @@ #include "config.h" -#include +#include -#include "core/core-types.h" +#include "base-types.h" -#include "core/gimpimage.h" - -#include "pixel_region.h" -#include "pixel_surround.h" -#include "tile_manager.h" +#include "pixel-region.h" +#include "pixel-surround.h" +#include "tile-manager.h" #include "tile.h" diff --git a/app/base/temp-buf.c b/app/base/temp-buf.c index 5de3444d6b..6a2a624309 100644 --- a/app/base/temp-buf.c +++ b/app/base/temp-buf.c @@ -18,7 +18,7 @@ #include "config.h" -#include +#include #include #include @@ -33,20 +33,17 @@ #ifdef G_OS_WIN32 #include /* For _getpid() */ #endif - + #include "libgimpcolor/gimpcolor.h" -#include "core/core-types.h" +#include "base-types.h" + +#include "base-config.h" +#include "pixel-region.h" +#include "temp-buf.h" #include "paint-funcs/paint-funcs.h" -#include "core/gimpimage.h" - -#include "gimprc.h" -#include "pixel_region.h" -#include "temp_buf.h" -#include "image_render.h" - static guchar * temp_buf_allocate (guint); static void temp_buf_to_color (TempBuf *src_buf, @@ -574,7 +571,9 @@ generate_unique_filename (void) pid = getpid (); return g_strdup_printf ("%s" G_DIR_SEPARATOR_S "gimp%d.%d", - temp_path, (int) pid, swap_index++); + base_config->temp_path, + (gint) pid, + swap_index++); } void @@ -592,7 +591,7 @@ temp_buf_swap (TempBuf *buf) /* Set the swapped flag */ buf->swapped = TRUE; - if (stingy_memory_use) + if (base_config->stingy_memory_use) swap = buf; else { diff --git a/app/base/temp-buf.h b/app/base/temp-buf.h index 0166d0288a..3559e96bce 100644 --- a/app/base/temp-buf.h +++ b/app/base/temp-buf.h @@ -19,7 +19,6 @@ #ifndef __TEMP_BUF_H__ #define __TEMP_BUF_H__ -#include "gimpchecks.h" struct _TempBuf { @@ -37,52 +36,52 @@ struct _TempBuf /* The temp buffer functions */ -TempBuf * temp_buf_new (gint width, - gint height, - gint bytes, - gint x, - gint y, - guchar *col); -TempBuf * temp_buf_new_check (gint width, - gint height, - GimpCheckType check_type, - GimpCheckSize check_size); -TempBuf * temp_buf_copy (TempBuf *src, - TempBuf *dest); -TempBuf * temp_buf_resize (TempBuf *buf, - gint bytes, - gint x, - gint y, - gint width, - gint height); -TempBuf * temp_buf_scale (TempBuf *buf, - gint width, - gint height); -TempBuf * temp_buf_copy_area (TempBuf *src, - TempBuf *dest, - gint x, - gint y, - gint width, - gint height, - gint dest_x, - gint dest_y); -void temp_buf_free (TempBuf *buf); -guchar * temp_buf_data (TempBuf *buf); -guchar * temp_buf_data_clear (TempBuf *buf); +TempBuf * temp_buf_new (gint width, + gint height, + gint bytes, + gint x, + gint y, + guchar *col); +TempBuf * temp_buf_new_check (gint width, + gint height, + GimpCheckType check_type, + GimpCheckSize check_size); +TempBuf * temp_buf_copy (TempBuf *src, + TempBuf *dest); +TempBuf * temp_buf_resize (TempBuf *buf, + gint bytes, + gint x, + gint y, + gint width, + gint height); +TempBuf * temp_buf_scale (TempBuf *buf, + gint width, + gint height); +TempBuf * temp_buf_copy_area (TempBuf *src, + TempBuf *dest, + gint x, + gint y, + gint width, + gint height, + gint dest_x, + gint dest_y); +void temp_buf_free (TempBuf *buf); +guchar * temp_buf_data (TempBuf *buf); +guchar * temp_buf_data_clear (TempBuf *buf); /* The mask buffer functions */ -MaskBuf * mask_buf_new (gint width, - gint height); -void mask_buf_free (MaskBuf *mask_buf); -guchar * mask_buf_data (MaskBuf *mask_buf); -guchar * mask_buf_data_clear (MaskBuf *mask_buf); +MaskBuf * mask_buf_new (gint width, + gint height); +void mask_buf_free (MaskBuf *mask_buf); +guchar * mask_buf_data (MaskBuf *mask_buf); +guchar * mask_buf_data_clear (MaskBuf *mask_buf); /* The disk caching functions */ -void temp_buf_swap (TempBuf *buf); -void temp_buf_unswap (TempBuf *buf); -void temp_buf_swap_free (TempBuf *buf); +void temp_buf_swap (TempBuf *buf); +void temp_buf_unswap (TempBuf *buf); +void temp_buf_swap_free (TempBuf *buf); /* Called by app_procs:exit() to free up the cached undo buffer */ diff --git a/app/base/tile-cache.c b/app/base/tile-cache.c index 21971651e1..60d000c24a 100644 --- a/app/base/tile-cache.c +++ b/app/base/tile-cache.c @@ -22,15 +22,15 @@ #include #endif -#include +#include -#include "apptypes.h" +#include "base-types.h" -#include "gimprc.h" +#include "base-config.h" #include "tile.h" -#include "tile_cache.h" -#include "tile_swap.h" -#include "tile_pvt.h" +#include "tile-cache.h" +#include "tile-swap.h" +#include "tile-private.h" /* This is the percentage of the maximum cache size that should be cleared @@ -48,11 +48,11 @@ static void tile_cache_flush_internal (Tile *tile); #ifdef USE_PTHREADS static gpointer tile_idle_thread (gpointer data); #else -static gint tile_idle_preswap (gpointer data); +static gboolean tile_idle_preswap (gpointer data); #endif -static int initialize = TRUE; +static gboolean initialize = TRUE; typedef struct _TileList { @@ -60,24 +60,24 @@ typedef struct _TileList Tile *last; } TileList; -static unsigned long max_tile_size = TILE_WIDTH * TILE_HEIGHT * 4; -static unsigned long cur_cache_size = 0; -static unsigned long max_cache_size = 0; -static unsigned long cur_cache_dirty = 0; +static gulong max_tile_size = TILE_WIDTH * TILE_HEIGHT * 4; +static gulong cur_cache_size = 0; +static gulong max_cache_size = 0; +static gulong cur_cache_dirty = 0; static TileList clean_list = { NULL, NULL }; static TileList dirty_list = { NULL, NULL }; #ifdef USE_PTHREADS -static pthread_t preswap_thread; +static pthread_t preswap_thread; static pthread_mutex_t dirty_mutex = PTHREAD_MUTEX_INITIALIZER; -static pthread_cond_t dirty_signal = PTHREAD_COND_INITIALIZER; +static pthread_cond_t dirty_signal = PTHREAD_COND_INITIALIZER; static pthread_mutex_t tile_mutex = PTHREAD_MUTEX_INITIALIZER; -#define CACHE_LOCK pthread_mutex_lock(&tile_mutex) +#define CACHE_LOCK pthread_mutex_lock(&tile_mutex) #define CACHE_UNLOCK pthread_mutex_unlock(&tile_mutex) #else -static gint idle_swapper = 0; -#define CACHE_LOCK /*nothing*/ -#define CACHE_UNLOCK /*nothing*/ +static guint idle_swapper = 0; +#define CACHE_LOCK /* nothing */ +#define CACHE_UNLOCK /* nothing */ #endif @@ -252,14 +252,14 @@ tile_cache_init (void) clean_list.first = clean_list.last = NULL; dirty_list.first = dirty_list.last = NULL; - max_cache_size = tile_cache_size; + max_cache_size = base_config->tile_cache_size; #ifdef USE_PTHREADS pthread_create (&preswap_thread, NULL, &tile_idle_thread, NULL); #else - idle_swapper = gtk_timeout_add (IDLE_SWAPPER_TIMEOUT, - (GtkFunction) tile_idle_preswap, - (gpointer) 0); + idle_swapper = g_timeout_add (IDLE_SWAPPER_TIMEOUT, + tile_idle_preswap, + NULL); #endif } } @@ -374,7 +374,7 @@ tile_idle_thread (gpointer data) } #else -static gint +static gboolean tile_idle_preswap (gpointer data) { Tile *tile; diff --git a/app/base/tile-manager.c b/app/base/tile-manager.c index 82980e52e5..07531ca0e0 100644 --- a/app/base/tile-manager.c +++ b/app/base/tile-manager.c @@ -22,14 +22,14 @@ #include -#include "apptypes.h" +#include "base-types.h" #include "tile.h" -#include "tile_pvt.h" -#include "tile_cache.h" -#include "tile_manager.h" -#include "tile_manager_pvt.h" -#include "tile_swap.h" +#include "tile-private.h" +#include "tile-cache.h" +#include "tile-manager.h" +#include "tile-manager-private.h" +#include "tile-swap.h" static gint tile_manager_get_tile_num (TileManager *tm, diff --git a/app/base/tile-manager.h b/app/base/tile-manager.h index e4aa1a05bc..b7a5ea357c 100644 --- a/app/base/tile-manager.h +++ b/app/base/tile-manager.h @@ -25,6 +25,7 @@ * used to compute the number of levels and there * size. Each level is 1/2 the width and height of * the level above it. + * * The toplevel is level 0. The smallest level in the * hierarchy is "nlevels - 1". That level will be smaller * than TILE_WIDTH x TILE_HEIGHT @@ -95,23 +96,23 @@ void tile_invalidate_tile (Tile **tile_ptr, /* Given a toplevel tile, this procedure will invalidate * (set the dirty bit) for this toplevel tile. */ -void tile_manager_invalidate_tiles (TileManager *tm, - Tile *toplevel_tile); +void tile_manager_invalidate_tiles (TileManager *tm, + Tile *toplevel_tile); -void tile_manager_set_user_data (TileManager *tm, - gpointer user_data); -gpointer tile_manager_get_user_data (const TileManager *tm); +void tile_manager_set_user_data (TileManager *tm, + gpointer user_data); +gpointer tile_manager_get_user_data (const TileManager *tm); -gint tile_manager_width (const TileManager *tm); -gint tile_manager_height (const TileManager *tm); -gint tile_manager_bpp (const TileManager *tm); +gint tile_manager_width (const TileManager *tm); +gint tile_manager_height (const TileManager *tm); +gint tile_manager_bpp (const TileManager *tm); -void tile_manager_get_offsets (const TileManager *tm, - gint *x, - gint *y); -void tile_manager_set_offsets (TileManager *tm, - gint x, - gint y); +void tile_manager_get_offsets (const TileManager *tm, + gint *x, + gint *y); +void tile_manager_set_offsets (TileManager *tm, + gint x, + gint y); void tile_manager_get_tile_coordinates (TileManager *tm, Tile *tile, @@ -122,4 +123,5 @@ void tile_manager_map_over_tile (TileManager *tm, Tile *tile, Tile *srctile); + #endif /* __TILE_MANAGER_H__ */ diff --git a/app/base/tile-private.h b/app/base/tile-private.h index 386696e0fa..fdb35f394f 100644 --- a/app/base/tile-private.h +++ b/app/base/tile-private.h @@ -1,6 +1,23 @@ -#ifndef __TILE_PVT_H__ -#define __TILE_PVT_H__ +/* The GIMP -- an 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 2 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, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ +#ifndef __TILE_PRIVATE_H__ +#define __TILE_PRIVATE_H__ #include "config.h" @@ -9,6 +26,7 @@ #endif #include + #include @@ -27,26 +45,26 @@ struct _TileLink struct _Tile { - gshort ref_count; /* reference count. when the reference count is - * non-zero then the "data" for this tile must - * be valid. when the reference count for a tile - * is 0 then the "data" for this tile must be - * NULL. - */ - gshort write_count; /* write count: number of references that are - for write access */ - gshort share_count; /* share count: number of tile managers that - hold this tile */ - guint dirty : 1; /* is the tile dirty? has it been modified? */ - guint valid : 1; /* is the tile valid? */ + gshort ref_count; /* reference count. when the reference count is + * non-zero then the "data" for this tile must + * be valid. when the reference count for a tile + * is 0 then the "data" for this tile must be + * NULL. + */ + gshort write_count; /* write count: number of references that are + for write access */ + gshort share_count; /* share count: number of tile managers that + hold this tile */ + guint dirty : 1; /* is the tile dirty? has it been modified? */ + guint valid : 1; /* is the tile valid? */ - guchar bpp; /* the bytes per pixel (1, 2, 3 or 4) */ - gushort ewidth; /* the effective width of the tile */ - gushort eheight; /* the effective height of the tile - * a tile's effective width and height may be smaller - * (but not larger) than TILE_WIDTH and TILE_HEIGHT. - * this is to handle edge tiles of a drawable. - */ + guchar bpp; /* the bytes per pixel (1, 2, 3 or 4) */ + gushort ewidth; /* the effective width of the tile */ + gushort eheight; /* the effective height of the tile + * a tile's effective width and height may be smaller + * (but not larger) than TILE_WIDTH and TILE_HEIGHT. + * this is to handle edge tiles of a drawable. + */ TileRowHint *rowhint; /* An array of hints for rendering purposes */ @@ -81,4 +99,4 @@ struct _Tile #endif -#endif /* __TILE_PVT_H__ */ +#endif /* __TILE_PRIVATE_H__ */ diff --git a/app/base/tile-swap.c b/app/base/tile-swap.c index 08f5ad02c2..8ebc79f3ba 100644 --- a/app/base/tile-swap.c +++ b/app/base/tile-swap.c @@ -43,11 +43,11 @@ #define _O_TEMPORARY 0 #endif -#include "apptypes.h" +#include "base-types.h" #include "tile.h" -#include "tile_pvt.h" -#include "tile_swap.h" +#include "tile-private.h" +#include "tile-swap.h" #define MAX_OPEN_SWAP_FILES 16 @@ -142,7 +142,9 @@ static GSList * async_swapin_tiles = NULL; static GSList * async_swapin_tiles_end = NULL; #endif -static gboolean seek_err_msg = TRUE, read_err_msg = TRUE, write_err_msg = TRUE; +static gboolean seek_err_msg = TRUE; +static gboolean read_err_msg = TRUE; +static gboolean write_err_msg = TRUE; static void diff --git a/app/base/tile-swap.h b/app/base/tile-swap.h index 72ead7facc..a1be110067 100644 --- a/app/base/tile-swap.h +++ b/app/base/tile-swap.h @@ -29,10 +29,11 @@ typedef enum SWAP_COMPRESS } SwapCommand; -typedef gint (*SwapFunc) (gint fd, - Tile *tile, - gint cmd, - gpointer user_data); + +typedef gint (* SwapFunc) (gint fd, + Tile *tile, + gint cmd, + gpointer user_data); void tile_swap_exit (void); diff --git a/app/base/tile.c b/app/base/tile.c index 5431b2a89c..3e8bc11a21 100644 --- a/app/base/tile.c +++ b/app/base/tile.c @@ -20,13 +20,13 @@ #include -#include "apptypes.h" +#include "base-types.h" #include "tile.h" -#include "tile_pvt.h" -#include "tile_cache.h" -#include "tile_manager.h" -#include "tile_swap.h" +#include "tile-private.h" +#include "tile-cache.h" +#include "tile-manager.h" +#include "tile-swap.h" static void tile_destroy (Tile *tile); diff --git a/app/boundary.c b/app/boundary.c deleted file mode 100644 index e636cfc84a..0000000000 --- a/app/boundary.c +++ /dev/null @@ -1,557 +0,0 @@ -/* The GIMP -- an 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 2 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, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -#include "config.h" - -#include - -#include - -#include "apptypes.h" - -#include "boundary.h" -#include "errors.h" -#include "pixel_region.h" -#include "tile.h" -#include "tile_manager.h" - - -/* half intensity for mask */ -#define HALF_WAY 127 - -/* BoundSeg array growth parameter */ -#define MAX_SEGS_INC 2048 - - -/* The array of vertical segments */ -static gint *vert_segs = NULL; - -/* The array of segments */ -static BoundSeg *tmp_segs = NULL; -static gint num_segs = 0; -static gint max_segs = 0; - -/* static empty segment arrays */ -static gint *empty_segs_n = NULL; -static gint num_empty_n = 0; -static gint *empty_segs_c = NULL; -static gint num_empty_c = 0; -static gint *empty_segs_l = NULL; -static gint num_empty_l = 0; -static gint max_empty_segs = 0; - -/* global state variables--improve parameter efficiency */ -static PixelRegion *cur_PR = NULL; - - -/* local function prototypes */ -static void find_empty_segs (PixelRegion *maskPR, - gint scanline, - gint empty_segs[], - gint max_empty, - gint *num_empty, - BoundaryType type, - gint x1, - gint y1, - gint x2, - gint y2); -static void make_seg (gint x1, - gint y1, - gint x2, - gint y2, - gboolean open); -static void allocate_vert_segs (void); -static void allocate_empty_segs (void); -static void process_horiz_seg (gint x1, - gint y1, - gint x2, - gint y2, - gboolean open); -static void make_horiz_segs (gint start, - gint end, - gint scanline, - gint empty[], - gint num_empty, - gint top); -static void generate_boundary (BoundaryType type, - gint x1, - gint y1, - gint x2, - gint y2); - - -/* Function definitions */ - -static void -find_empty_segs (PixelRegion *maskPR, - gint scanline, - gint empty_segs[], - gint max_empty, - gint *num_empty, - BoundaryType type, - gint x1, - gint y1, - gint x2, - gint y2) -{ - unsigned char *data; - int x; - int start, end; - int val, last; - int tilex; - Tile *tile = NULL; - int endx, l_num_empty, dstep = 0; - - - data = NULL; - start = 0; - end = 0; - - *num_empty = 0; - - if (scanline < maskPR->y || scanline >= (maskPR->y + maskPR->h)) - { - empty_segs[(*num_empty)++] = 0; - empty_segs[(*num_empty)++] = G_MAXINT; - return; - } - - if (type == WithinBounds) - { - if (scanline < y1 || scanline >= y2) - { - empty_segs[(*num_empty)++] = 0; - empty_segs[(*num_empty)++] = G_MAXINT; - return; - } - - start = x1; - end = x2; - } - else if (type == IgnoreBounds) - { - start = maskPR->x; - end = maskPR->x + maskPR->w; - if (scanline < y1 || scanline >= y2) - x2 = -1; - } - - tilex = -1; - empty_segs[(*num_empty)++] = 0; - last = -1; - - l_num_empty = *num_empty; - - for (x = start; x < end;) - { - /* Check to see if we must advance to next tile */ - if ((x / TILE_WIDTH) != tilex) - { - if (tile) - tile_release (tile, FALSE); - tile = tile_manager_get_tile (maskPR->tiles, x, scanline, TRUE, FALSE); - data = (guchar *) tile_data_pointer (tile, - x % TILE_WIDTH, - scanline % TILE_HEIGHT) + (tile_bpp(tile) - 1); - - tilex = x / TILE_WIDTH; - dstep = tile_bpp (tile); - } - endx = x + (TILE_WIDTH - (x%TILE_WIDTH)); - endx = MIN (end, endx); - if (type == IgnoreBounds && (endx > x1 || x < x2)) - { - for (; x < endx; x++) - { - if (*data > HALF_WAY) - if (x >= x1 && x < x2) - val = -1; - else - val = 1; - else - val = -1; - - data += dstep; - - if (last != val) - empty_segs[l_num_empty++] = x; - - last = val; - } - } - else - { - for (; x < endx; x++) - { - if (*data > HALF_WAY) - val = 1; - else - val = -1; - - data += dstep; - - if (last != val) - empty_segs[l_num_empty++] = x; - - last = val; - } - } - } - *num_empty = l_num_empty; - - if (last > 0) - empty_segs[(*num_empty)++] = x; - - empty_segs[(*num_empty)++] = G_MAXINT; - - if (tile) - tile_release (tile, FALSE); -} - - -static void -make_seg (gint x1, - gint y1, - gint x2, - gint y2, - gboolean open) -{ - if (num_segs >= max_segs) - { - max_segs += MAX_SEGS_INC; - - tmp_segs = (BoundSeg *) g_realloc ((void *) tmp_segs, - sizeof (BoundSeg) * max_segs); - - if (!tmp_segs) - gimp_fatal_error ("make_seg(): Unable to reallocate segments array for mask boundary."); - } - - tmp_segs[num_segs].x1 = x1; - tmp_segs[num_segs].y1 = y1; - tmp_segs[num_segs].x2 = x2; - tmp_segs[num_segs].y2 = y2; - tmp_segs[num_segs].open = open; - num_segs ++; -} - - -static void -allocate_vert_segs (void) -{ - gint i; - - /* allocate and initialize the vert_segs array */ - vert_segs = (gint *) g_realloc ((void *) vert_segs, - (cur_PR->w + cur_PR->x + 1) * sizeof (gint)); - - for (i = 0; i <= (cur_PR->w + cur_PR->x); i++) - vert_segs[i] = -1; -} - - -static void -allocate_empty_segs (void) -{ - gint need_num_segs; - - /* find the maximum possible number of empty segments given the current mask */ - need_num_segs = cur_PR->w + 3; - - if (need_num_segs > max_empty_segs) - { - max_empty_segs = need_num_segs; - - empty_segs_n = (gint *) g_realloc (empty_segs_n, sizeof (gint) * max_empty_segs); - empty_segs_c = (gint *) g_realloc (empty_segs_c, sizeof (gint) * max_empty_segs); - empty_segs_l = (gint *) g_realloc (empty_segs_l, sizeof (gint) * max_empty_segs); - - if (!empty_segs_n || !empty_segs_l || !empty_segs_c) - gimp_fatal_error ("allocate_empty_segs(): Unable to reallocate empty segments array for mask boundary."); - } -} - - -static void -process_horiz_seg (gint x1, - gint y1, - gint x2, - gint y2, - gboolean open) -{ - /* This procedure accounts for any vertical segments that must be - drawn to close in the horizontal segments. */ - - if (vert_segs[x1] >= 0) - { - make_seg (x1, vert_segs[x1], x1, y1, !open); - vert_segs[x1] = -1; - } - else - vert_segs[x1] = y1; - - if (vert_segs[x2] >= 0) - { - make_seg (x2, vert_segs[x2], x2, y2, open); - vert_segs[x2] = -1; - } - else - vert_segs[x2] = y2; - - make_seg (x1, y1, x2, y2, open); -} - - -static void -make_horiz_segs (gint start, - gint end, - gint scanline, - gint empty[], - gint num_empty, - gint top) -{ - gint empty_index; - gint e_s, e_e; /* empty segment start and end values */ - - for (empty_index = 0; empty_index < num_empty; empty_index += 2) - { - e_s = *empty++; - e_e = *empty++; - if (e_s <= start && e_e >= end) - process_horiz_seg (start, scanline, end, scanline, top); - else if ((e_s > start && e_s < end) || - (e_e < end && e_e > start)) - process_horiz_seg (MAX (e_s, start), scanline, - MIN (e_e, end), scanline, top); - } -} - - -static void -generate_boundary (BoundaryType type, - gint x1, - gint y1, - gint x2, - gint y2) -{ - gint scanline; - gint i; - gint start, end; - gint *tmp_segs; - - start = 0; - end = 0; - - /* array for determining the vertical line segments which must be drawn */ - allocate_vert_segs (); - - /* make sure there is enough space for the empty segment array */ - allocate_empty_segs (); - - num_segs = 0; - - if (type == WithinBounds) - { - start = y1; - end = y2; - } - else if (type == IgnoreBounds) - { - start = cur_PR->y; - end = cur_PR->y + cur_PR->h; - } - - /* Find the empty segments for the previous and current scanlines */ - find_empty_segs (cur_PR, start - 1, empty_segs_l, - max_empty_segs, &num_empty_l, - type, x1, y1, x2, y2); - find_empty_segs (cur_PR, start, empty_segs_c, - max_empty_segs, &num_empty_c, - type, x1, y1, x2, y2); - - for (scanline = start; scanline < end; scanline++) - { - /* find the empty segment list for the next scanline */ - find_empty_segs (cur_PR, scanline + 1, empty_segs_n, - max_empty_segs, &num_empty_n, - type, x1, y1, x2, y2); - - /* process the segments on the current scanline */ - for (i = 1; i < num_empty_c - 1; i += 2) - { - make_horiz_segs (empty_segs_c [i], empty_segs_c [i+1], - scanline, empty_segs_l, num_empty_l, 1); - make_horiz_segs (empty_segs_c [i], empty_segs_c [i+1], - scanline+1, empty_segs_n, num_empty_n, 0); - } - - /* get the next scanline of empty segments, swap others */ - tmp_segs = empty_segs_l; - empty_segs_l = empty_segs_c; - num_empty_l = num_empty_c; - empty_segs_c = empty_segs_n; - num_empty_c = num_empty_n; - empty_segs_n = tmp_segs; - } -} - - -BoundSeg * -find_mask_boundary (PixelRegion *maskPR, - int *num_elems, - BoundaryType type, - int x1, - int y1, - int x2, - int y2) -{ - BoundSeg * new_segs = NULL; - - /* The mask paramater can be any PixelRegion. If the region - * has more than 1 bytes/pixel, the last byte of each pixel is - * used to determine the boundary outline. - */ - cur_PR = maskPR; - - /* Calculate the boundary */ - generate_boundary (type, x1, y1, x2, y2); - - /* Set the number of X segments */ - *num_elems = num_segs; - - /* Make a copy of the boundary */ - if (num_segs) - { - new_segs = (BoundSeg *) g_malloc (sizeof (BoundSeg) * num_segs); - memcpy (new_segs, tmp_segs, (sizeof (BoundSeg) * num_segs)); - } - - /* Return the new boundary */ - return new_segs; -} - - -/************************/ -/* Sorting a Boundary */ - -static int find_segment (BoundSeg *, int, int, int); - -static int -find_segment (BoundSeg *segs, - gint ns, - gint x, - gint y) -{ - gint index; - - for (index = 0; index < ns; index++) - if (((segs[index].x1 == x && segs[index].y1 == y) || (segs[index].x2 == x && segs[index].y2 == y)) && - segs[index].visited == FALSE) - return index; - - return -1; -} - - -BoundSeg * -sort_boundary (BoundSeg *segs, - gint ns, - gint *num_groups) -{ - gint i; - gint index; - gint x, y; - gint startx, starty; - gint empty = (num_segs == 0); - BoundSeg *new_segs; - - index = 0; - new_segs = NULL; - - for (i = 0; i < ns; i++) - segs[i].visited = FALSE; - - num_segs = 0; - *num_groups = 0; - while (! empty) - { - empty = TRUE; - - /* find the index of a non-visited segment to start a group */ - for (i = 0; i < ns; i++) - if (segs[i].visited == FALSE) - { - index = i; - empty = FALSE; - i = ns; - } - - if (! empty) - { - make_seg (segs[index].x1, segs[index].y1, - segs[index].x2, segs[index].y2, - segs[index].open); - segs[index].visited = TRUE; - - startx = segs[index].x1; - starty = segs[index].y1; - x = segs[index].x2; - y = segs[index].y2; - - while ((index = find_segment (segs, ns, x, y)) != -1) - { - /* make sure ordering is correct */ - if (x == segs[index].x1 && y == segs[index].y1) - { - make_seg (segs[index].x1, segs[index].y1, - segs[index].x2, segs[index].y2, - segs[index].open); - x = segs[index].x2; - y = segs[index].y2; - } - else - { - make_seg (segs[index].x2, segs[index].y2, - segs[index].x1, segs[index].y1, - segs[index].open); - x = segs[index].x1; - y = segs[index].y1; - } - - segs[index].visited = TRUE; - } - - if (x != startx || y != starty) - g_message ("sort_boundary(): Unconnected boundary group!"); - - /* Mark the end of a group */ - *num_groups = *num_groups + 1; - make_seg (-1, -1, -1, -1, 0); - } - } - - /* Make a copy of the boundary */ - if (num_segs) - { - new_segs = (BoundSeg *) g_malloc (sizeof (BoundSeg) * num_segs); - memcpy (new_segs, tmp_segs, (sizeof (BoundSeg) * num_segs)); - } - - /* Return the new boundary */ - return new_segs; -} diff --git a/app/brush_scale.c b/app/brush_scale.c deleted file mode 100644 index 8420939d4c..0000000000 --- a/app/brush_scale.c +++ /dev/null @@ -1,350 +0,0 @@ -/* The GIMP -- an 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 2 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, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -#include "config.h" - -#include - -#include "apptypes.h" - -#include "brush_scale.h" -#include "temp_buf.h" - - -MaskBuf * -brush_scale_mask (MaskBuf *brush_mask, - gint dest_width, - gint dest_height) -{ - MaskBuf *scale_brush; - gint src_width; - gint src_height; - gint value; - gint area; - gint i, j; - gint x, x0, y, y0; - gint dx, dx0, dy, dy0; - gint fx, fx0, fy, fy0; - guchar *src, *dest; - - g_return_val_if_fail (brush_mask != NULL && - dest_width != 0 && dest_height != 0, NULL); - - src_width = brush_mask->width; - src_height = brush_mask->height; - - scale_brush = mask_buf_new (dest_width, dest_height); - g_return_val_if_fail (scale_brush != NULL, NULL); - - /* get the data */ - dest = mask_buf_data (scale_brush); - src = mask_buf_data (brush_mask); - - fx = fx0 = (256.0 * src_width) / dest_width; - fy = fy0 = (256.0 * src_height) / dest_height; - area = fx0 * fy0; - - x = x0 = 0; - y = y0 = 0; - dx = dx0 = 0; - dy = dy0 = 0; - - for (i=0; i= 256) - { - value += 256 * dy * src[x + src_width * y]; - x++; - fx -= 256; - } - if (fx) - { - value += fx * dy * src[x + src_width * y]; - dx = 256 - fx; - } - y++; - fy -= dy; - dy = 0; - } - - while (fy >= 256) - { - fx = fx0; - x = x0; - dx = dx0; - - if (dx) - { - value += dx * 256 * src[x + src_width * y]; - x++; - fx -= dx; - dx = 0; - } - while (fx >= 256) - { - value += 256 * 256 * src[x + src_width * y]; - x++; - fx -= 256; - } - if (fx) - { - value += fx * 256 * src[x + src_width * y]; - dx = 256 - fx; - } - y++; - fy -= 256; - } - - if (fy) - { - fx = fx0; - x = x0; - dx = dx0; - - if (dx) - { - value += dx * fy * src[x + src_width * y]; - x++; - fx -= dx; - dx = 0; - } - while (fx >= 256) - { - value += 256 * fy * src[x + src_width * y]; - x++; - fx -= 256; - } - if (fx) - { - value += fx * fy * src[x + src_width * y]; - dx = 256 - fx; - } - dy = 256 - fy; - } - - *dest++ = MIN ((value / area), 255); - - x0 = x; - dx0 = dx; - } - x0 = 0; - dx0 = 0; - y0 = y; - dy0 = dy; - } - - return scale_brush; -} - - -#define ADD_RGB(dest, factor, src) \ - dest[0] += factor * src[0]; \ - dest[1] += factor * src[1]; \ - dest[2] += factor * src[2]; - -MaskBuf * -brush_scale_pixmap (MaskBuf *pixmap, - gint dest_width, - gint dest_height) -{ - MaskBuf *scale_brush; - gint src_width; - gint src_height; - gint value[3]; - gint factor; - gint area; - gint i, j; - gint x, x0, y, y0; - gint dx, dx0, dy, dy0; - gint fx, fx0, fy, fy0; - guchar *src, *src_ptr, *dest; - - g_return_val_if_fail (pixmap != NULL && pixmap->bytes == 3 && - dest_width != 0 && dest_height != 0, NULL); - - src_width = pixmap->width; - src_height = pixmap->height; - - scale_brush = temp_buf_new (dest_width, dest_height, 3, 0, 0, NULL); - g_return_val_if_fail (scale_brush != NULL, NULL); - - /* get the data */ - dest = mask_buf_data (scale_brush); - src = mask_buf_data (pixmap); - - fx = fx0 = (256.0 * src_width) / dest_width; - fy = fy0 = (256.0 * src_height) / dest_height; - area = fx0 * fy0; - - x = x0 = 0; - y = y0 = 0; - dx = dx0 = 0; - dy = dy0 = 0; - - for (i=0; i= 256) - { - factor = 256 * dy; - src_ptr = src + 3 * (x + y * src_width); - ADD_RGB (value, factor, src_ptr); - x++; - fx -= 256; - } - if (fx) - { - factor = fx * dy; - src_ptr = src + 3 * (x + y * src_width); - ADD_RGB (value, factor, src_ptr); - dx = 256 - fx; - } - y++; - fy -= dy; - dy = 0; - } - - while (fy >= 256) - { - fx = fx0; - x = x0; - dx = dx0; - - if (dx) - { - factor = dx * 256; - src_ptr = src + 3 * (x + y * src_width); - ADD_RGB (value, factor, src_ptr); - x++; - fx -= dx; - dx = 0; - } - while (fx >= 256) - { - factor = 256 * 256; - src_ptr = src + 3 * (x + y * src_width); - ADD_RGB (value, factor, src_ptr); - x++; - fx -= 256; - } - if (fx) - { - factor = fx * 256; - src_ptr = src + 3 * (x + y * src_width); - ADD_RGB (value, factor, src_ptr); - dx = 256 - fx; - } - y++; - fy -= 256; - } - - if (fy) - { - fx = fx0; - x = x0; - dx = dx0; - - if (dx) - { - factor = dx * fy; - src_ptr = src + 3 * (x + y * src_width); - ADD_RGB (value, factor, src_ptr); - x++; - fx -= dx; - dx = 0; - } - while (fx >= 256) - { - factor = 256 * fy; - src_ptr = src + 3 * (x + y * src_width); - ADD_RGB (value, factor, src_ptr); - x++; - fx -= 256; - } - if (fx) - { - factor = fx * fy; - src_ptr = src + 3 * (x + y * src_width); - ADD_RGB (value, factor, src_ptr); - dx = 256 - fx; - } - dy = 256 - fy; - } - - *dest++ = MIN ((value[0] / area), 255); - *dest++ = MIN ((value[1] / area), 255); - *dest++ = MIN ((value[2] / area), 255); - - x0 = x; - dx0 = dx; - } - x0 = 0; - dx0 = 0; - y0 = y; - dy0 = dy; - } - - return scale_brush; -} - -#undef ADD_RGB diff --git a/app/core/Makefile.am b/app/core/Makefile.am index 78cc69b4d5..80d448dd0d 100644 --- a/app/core/Makefile.am +++ b/app/core/Makefile.am @@ -39,6 +39,8 @@ libappcore_la_SOURCES = \ gimpgradient.h \ gimpimage.c \ gimpimage.h \ + gimpimage-colorhash.c \ + gimpimage-colorhash.h \ gimpimage-convert.c \ gimpimage-convert.h \ gimpimage-duplicate.c \ diff --git a/app/core/gimp-edit.c b/app/core/gimp-edit.c index 4f95336cc9..48514dee88 100644 --- a/app/core/gimp-edit.c +++ b/app/core/gimp-edit.c @@ -27,6 +27,9 @@ #include "core/core-types.h" #include "tools/tools-types.h" +#include "base/pixel-region.h" +#include "base/tile-manager.h" + #include "paint-funcs/paint-funcs.h" #include "core/gimpchannel.h" @@ -44,8 +47,6 @@ #include "gimage.h" #include "global_edit.h" #include "image_new.h" -#include "pixel_region.h" -#include "tile_manager.h" #include "undo.h" #include "libgimp/gimpintl.h" diff --git a/app/core/gimp-transform-region.c b/app/core/gimp-transform-region.c index 46a88c26b6..2ea8dad5c4 100644 --- a/app/core/gimp-transform-region.c +++ b/app/core/gimp-transform-region.c @@ -27,6 +27,12 @@ #include "tools-types.h" +#include "base/base-config.h" +#include "base/pixel-region.h" +#include "base/pixel-surround.h" +#include "base/tile-manager.h" +#include "base/tile.h" + #include "paint-funcs/paint-funcs.h" #include "core/gimpchannel.h" @@ -45,13 +51,8 @@ #include "app_procs.h" #include "drawable.h" #include "floating_sel.h" -#include "gimprc.h" -#include "path_transform.h" -#include "pixel_region.h" -#include "pixel_surround.h" #include "undo.h" -#include "tile_manager.h" -#include "tile.h" +#include "path_transform.h" #include "tool_manager.h" #include "tool_options.h" @@ -1149,7 +1150,7 @@ gimp_transform_tool_do (GimpImage *gimage, /* turn interpolation off for simple transformations (e.g. rot90) */ if (gimp_matrix3_is_simple (matrix) || - interpolation_type == NEAREST_NEIGHBOR_INTERPOLATION) + base_config->interpolation_type == NEAREST_NEIGHBOR_INTERPOLATION) interpolation = FALSE; /* Get the background color */ @@ -1247,7 +1248,7 @@ gimp_transform_tool_do (GimpImage *gimage, /* initialise the pixel_surround accessor */ if (interpolation) { - if (interpolation_type == CUBIC_INTERPOLATION) + if (base_config->interpolation_type == CUBIC_INTERPOLATION) { pixel_surround_init (&surround, float_tiles, 4, 4, bg_col); } @@ -1309,7 +1310,7 @@ gimp_transform_tool_do (GimpImage *gimage, if (interpolation) { - if (interpolation_type == CUBIC_INTERPOLATION) + if (base_config->interpolation_type == CUBIC_INTERPOLATION) { /* ttx & tty are the subpixel coordinates of the point in * the original selection's floating buffer. diff --git a/app/core/gimpbrush-load.c b/app/core/gimpbrush-load.c index eb32277169..edf2da25fd 100644 --- a/app/core/gimpbrush-load.c +++ b/app/core/gimpbrush-load.c @@ -43,17 +43,17 @@ #include "core-types.h" -#include "brush_scale.h" +#include "base/base-config.h" +#include "base/brush-scale.h" +#include "base/temp-buf.h" + #include "gimpbrush.h" #include "gimpbrush-header.h" #include "gimpbrushgenerated.h" -#include "gimprc.h" -#include "temp_buf.h" /* this needs to go away */ #include "tools/tools-types.h" #include "tools/gimppainttool.h" -#include "brush_scale.h" #include "libgimp/gimpintl.h" @@ -322,7 +322,7 @@ gimp_brush_load (const gchar *filename) gimp_data_set_filename (GIMP_DATA (brush), filename); /* Swap the brush to disk (if we're being stingy with memory) */ - if (stingy_memory_use) + if (base_config->stingy_memory_use) { temp_buf_swap (brush->mask); diff --git a/app/core/gimpbrush.c b/app/core/gimpbrush.c index eb32277169..edf2da25fd 100644 --- a/app/core/gimpbrush.c +++ b/app/core/gimpbrush.c @@ -43,17 +43,17 @@ #include "core-types.h" -#include "brush_scale.h" +#include "base/base-config.h" +#include "base/brush-scale.h" +#include "base/temp-buf.h" + #include "gimpbrush.h" #include "gimpbrush-header.h" #include "gimpbrushgenerated.h" -#include "gimprc.h" -#include "temp_buf.h" /* this needs to go away */ #include "tools/tools-types.h" #include "tools/gimppainttool.h" -#include "brush_scale.h" #include "libgimp/gimpintl.h" @@ -322,7 +322,7 @@ gimp_brush_load (const gchar *filename) gimp_data_set_filename (GIMP_DATA (brush), filename); /* Swap the brush to disk (if we're being stingy with memory) */ - if (stingy_memory_use) + if (base_config->stingy_memory_use) { temp_buf_swap (brush->mask); diff --git a/app/core/gimpbrushgenerated-load.c b/app/core/gimpbrushgenerated-load.c index 94dd0ae342..83fc3d8077 100644 --- a/app/core/gimpbrushgenerated-load.c +++ b/app/core/gimpbrushgenerated-load.c @@ -34,10 +34,10 @@ #include "core-types.h" +#include "base/base-config.h" +#include "base/temp-buf.h" + #include "gimpbrushgenerated.h" -#include "gimprc.h" -#include "gimpbrush.h" -#include "temp_buf.h" /* this needs to go away */ #include "tools/gimppainttool.h" @@ -227,7 +227,7 @@ gimp_brush_generated_dirty (GimpData *data) gbrush = GIMP_BRUSH (brush); - if (stingy_memory_use && gbrush->mask) + if (base_config->stingy_memory_use && gbrush->mask) temp_buf_unswap (gbrush->mask); if (gbrush->mask) @@ -419,7 +419,7 @@ gimp_brush_generated_load (const gchar *filename) GIMP_DATA (brush)->dirty = FALSE; - if (stingy_memory_use) + if (base_config->stingy_memory_use) temp_buf_swap (GIMP_BRUSH (brush)->mask); return GIMP_DATA (brush); diff --git a/app/core/gimpbrushgenerated-save.c b/app/core/gimpbrushgenerated-save.c index 94dd0ae342..83fc3d8077 100644 --- a/app/core/gimpbrushgenerated-save.c +++ b/app/core/gimpbrushgenerated-save.c @@ -34,10 +34,10 @@ #include "core-types.h" +#include "base/base-config.h" +#include "base/temp-buf.h" + #include "gimpbrushgenerated.h" -#include "gimprc.h" -#include "gimpbrush.h" -#include "temp_buf.h" /* this needs to go away */ #include "tools/gimppainttool.h" @@ -227,7 +227,7 @@ gimp_brush_generated_dirty (GimpData *data) gbrush = GIMP_BRUSH (brush); - if (stingy_memory_use && gbrush->mask) + if (base_config->stingy_memory_use && gbrush->mask) temp_buf_unswap (gbrush->mask); if (gbrush->mask) @@ -419,7 +419,7 @@ gimp_brush_generated_load (const gchar *filename) GIMP_DATA (brush)->dirty = FALSE; - if (stingy_memory_use) + if (base_config->stingy_memory_use) temp_buf_swap (GIMP_BRUSH (brush)->mask); return GIMP_DATA (brush); diff --git a/app/core/gimpbrushgenerated.c b/app/core/gimpbrushgenerated.c index 94dd0ae342..83fc3d8077 100644 --- a/app/core/gimpbrushgenerated.c +++ b/app/core/gimpbrushgenerated.c @@ -34,10 +34,10 @@ #include "core-types.h" +#include "base/base-config.h" +#include "base/temp-buf.h" + #include "gimpbrushgenerated.h" -#include "gimprc.h" -#include "gimpbrush.h" -#include "temp_buf.h" /* this needs to go away */ #include "tools/gimppainttool.h" @@ -227,7 +227,7 @@ gimp_brush_generated_dirty (GimpData *data) gbrush = GIMP_BRUSH (brush); - if (stingy_memory_use && gbrush->mask) + if (base_config->stingy_memory_use && gbrush->mask) temp_buf_unswap (gbrush->mask); if (gbrush->mask) @@ -419,7 +419,7 @@ gimp_brush_generated_load (const gchar *filename) GIMP_DATA (brush)->dirty = FALSE; - if (stingy_memory_use) + if (base_config->stingy_memory_use) temp_buf_swap (GIMP_BRUSH (brush)->mask); return GIMP_DATA (brush); diff --git a/app/core/gimpchannel-combine.c b/app/core/gimpchannel-combine.c index 45e0221aeb..4e91c7e097 100644 --- a/app/core/gimpchannel-combine.c +++ b/app/core/gimpchannel-combine.c @@ -28,22 +28,23 @@ #include "core-types.h" +#include "base/boundary.h" +#include "base/gimplut.h" +#include "base/pixel-processor.h" +#include "base/pixel-region.h" +#include "base/temp-buf.h" +#include "base/tile.h" +#include "base/tile-manager.h" + #include "paint-funcs/paint-funcs.h" -#include "boundary.h" #include "drawable.h" #include "gimpimage.h" #include "gimpimage-mask.h" #include "gimpchannel.h" #include "gimplayer.h" -#include "gimplut.h" #include "parasitelist.h" -#include "pixel_processor.h" -#include "pixel_region.h" #include "lut_funcs.h" -#include "temp_buf.h" -#include "tile.h" -#include "tile_manager.h" #include "undo.h" #include "libgimp/gimpintl.h" diff --git a/app/core/gimpchannel.c b/app/core/gimpchannel.c index 45e0221aeb..4e91c7e097 100644 --- a/app/core/gimpchannel.c +++ b/app/core/gimpchannel.c @@ -28,22 +28,23 @@ #include "core-types.h" +#include "base/boundary.h" +#include "base/gimplut.h" +#include "base/pixel-processor.h" +#include "base/pixel-region.h" +#include "base/temp-buf.h" +#include "base/tile.h" +#include "base/tile-manager.h" + #include "paint-funcs/paint-funcs.h" -#include "boundary.h" #include "drawable.h" #include "gimpimage.h" #include "gimpimage-mask.h" #include "gimpchannel.h" #include "gimplayer.h" -#include "gimplut.h" #include "parasitelist.h" -#include "pixel_processor.h" -#include "pixel_region.h" #include "lut_funcs.h" -#include "temp_buf.h" -#include "tile.h" -#include "tile_manager.h" #include "undo.h" #include "libgimp/gimpintl.h" diff --git a/app/core/gimpcontext.c b/app/core/gimpcontext.c index c0fd9a4c40..67381c8870 100644 --- a/app/core/gimpcontext.c +++ b/app/core/gimpcontext.c @@ -27,6 +27,9 @@ #include "core-types.h" +#include "base/base-config.h" +#include "base/temp-buf.h" + /* FIXME: make a GimpToolFactory out of the tool_manager and put it here */ #include "tools/tools-types.h" @@ -46,7 +49,6 @@ #include "context_manager.h" #include "gdisplay.h" #include "gimprc.h" -#include "temp_buf.h" typedef void (* GimpContextCopyArgFunc) (GimpContext *src, @@ -1827,7 +1829,7 @@ gimp_context_real_set_brush (GimpContext *context, } /* make sure the active brush is swapped before we get a new one... */ - if (stingy_memory_use && + if (base_config->stingy_memory_use && context->brush && context->brush->mask && GTK_OBJECT (context->brush)->ref_count == 2) { @@ -1856,8 +1858,8 @@ gimp_context_real_set_brush (GimpContext *context, context); /* Make sure the active brush is unswapped... */ - if (stingy_memory_use && - brush->mask && + if (base_config->stingy_memory_use && + brush->mask && GTK_OBJECT (brush)->ref_count < 2) { temp_buf_unswap (brush->mask); @@ -1995,7 +1997,7 @@ gimp_context_real_set_pattern (GimpContext *context, } /* make sure the active pattern is swapped before we get a new one... */ - if (stingy_memory_use && + if (base_config->stingy_memory_use && context->pattern && context->pattern->mask && GTK_OBJECT (context->pattern)->ref_count == 2) { @@ -2021,8 +2023,8 @@ gimp_context_real_set_pattern (GimpContext *context, context); /* Make sure the active pattern is unswapped... */ - if (stingy_memory_use && - pattern->mask && + if (base_config->stingy_memory_use && + pattern->mask && GTK_OBJECT (pattern)->ref_count < 2) { temp_buf_unswap (pattern->mask); diff --git a/app/core/gimpdrawable-blend.c b/app/core/gimpdrawable-blend.c index 2550cf9043..32a7d9cf48 100644 --- a/app/core/gimpdrawable-blend.c +++ b/app/core/gimpdrawable-blend.c @@ -28,6 +28,10 @@ #include "tools-types.h" +#include "base/pixel-region.h" +#include "base/tile-manager.h" +#include "base/tile.h" + #include "paint-funcs/paint-funcs.h" #include "core/gimpcontext.h" @@ -45,13 +49,9 @@ #include "errors.h" #include "gdisplay.h" #include "gimpprogress.h" -#include "pixel_region.h" #include "selection.h" #include "undo.h" -#include "tile.h" -#include "tile_manager.h" - #include "gimpblendtool.h" #include "paint_options.h" #include "tool_manager.h" diff --git a/app/core/gimpdrawable-desaturate.c b/app/core/gimpdrawable-desaturate.c index f1bae5131f..18554a0a6b 100644 --- a/app/core/gimpdrawable-desaturate.c +++ b/app/core/gimpdrawable-desaturate.c @@ -22,13 +22,14 @@ #include "core-types.h" +#include "base/pixel-region.h" + #include "paint-funcs/paint-funcs.h" #include "drawable.h" #include "gimpdrawable.h" #include "gimpdrawable-desaturate.h" #include "gimpimage.h" -#include "pixel_region.h" void diff --git a/app/core/gimpdrawable-equalize.c b/app/core/gimpdrawable-equalize.c index 7b21347f52..d04c915635 100644 --- a/app/core/gimpdrawable-equalize.c +++ b/app/core/gimpdrawable-equalize.c @@ -22,15 +22,16 @@ #include "core-types.h" +#include "base/gimplut.h" +#include "base/pixel-processor.h" +#include "base/pixel-region.h" + #include "drawable.h" #include "gimpdrawable.h" #include "gimpdrawable-equalize.h" #include "gimpimage.h" -#include "gimplut.h" #include "lut_funcs.h" #include "gimphistogram.h" -#include "pixel_processor.h" -#include "pixel_region.h" void diff --git a/app/core/gimpdrawable-invert.c b/app/core/gimpdrawable-invert.c index 0cf6cd724b..60365f3961 100644 --- a/app/core/gimpdrawable-invert.c +++ b/app/core/gimpdrawable-invert.c @@ -22,13 +22,14 @@ #include "core-types.h" +#include "base/gimplut.h" +#include "base/pixel-processor.h" +#include "base/pixel-region.h" + #include "drawable.h" #include "gimpdrawable.h" #include "gimpdrawable-invert.h" -#include "gimplut.h" #include "lut_funcs.h" -#include "pixel_processor.h" -#include "pixel_region.h" void diff --git a/app/core/gimpdrawable-offset.c b/app/core/gimpdrawable-offset.c index cc04adf13c..7e59aadf1b 100644 --- a/app/core/gimpdrawable-offset.c +++ b/app/core/gimpdrawable-offset.c @@ -27,6 +27,9 @@ #include "core-types.h" +#include "base/pixel-region.h" +#include "base/tile-manager.h" + #include "paint-funcs/paint-funcs.h" #include "drawable.h" @@ -34,8 +37,6 @@ #include "gimpdrawable.h" #include "gimpdrawable-offset.h" #include "gimpimage.h" -#include "pixel_region.h" -#include "tile_manager.h" void diff --git a/app/core/gimpdrawable-preview.c b/app/core/gimpdrawable-preview.c index e3012f366e..125b864f28 100644 --- a/app/core/gimpdrawable-preview.c +++ b/app/core/gimpdrawable-preview.c @@ -26,6 +26,11 @@ #include "core-types.h" +#include "base/pixel-region.h" +#include "base/temp-buf.h" +#include "base/tile-manager.h" +#include "base/tile.h" + #include "paint-funcs/paint-funcs.h" #include "gimpchannel.h" @@ -33,10 +38,6 @@ #include "gimpdrawable.h" #include "gimplayer.h" #include "gimppreviewcache.h" -#include "pixel_region.h" -#include "temp_buf.h" -#include "tile_manager.h" -#include "tile.h" /* local function prototypes */ diff --git a/app/core/gimpdrawable-transform.c b/app/core/gimpdrawable-transform.c index 46a88c26b6..2ea8dad5c4 100644 --- a/app/core/gimpdrawable-transform.c +++ b/app/core/gimpdrawable-transform.c @@ -27,6 +27,12 @@ #include "tools-types.h" +#include "base/base-config.h" +#include "base/pixel-region.h" +#include "base/pixel-surround.h" +#include "base/tile-manager.h" +#include "base/tile.h" + #include "paint-funcs/paint-funcs.h" #include "core/gimpchannel.h" @@ -45,13 +51,8 @@ #include "app_procs.h" #include "drawable.h" #include "floating_sel.h" -#include "gimprc.h" -#include "path_transform.h" -#include "pixel_region.h" -#include "pixel_surround.h" #include "undo.h" -#include "tile_manager.h" -#include "tile.h" +#include "path_transform.h" #include "tool_manager.h" #include "tool_options.h" @@ -1149,7 +1150,7 @@ gimp_transform_tool_do (GimpImage *gimage, /* turn interpolation off for simple transformations (e.g. rot90) */ if (gimp_matrix3_is_simple (matrix) || - interpolation_type == NEAREST_NEIGHBOR_INTERPOLATION) + base_config->interpolation_type == NEAREST_NEIGHBOR_INTERPOLATION) interpolation = FALSE; /* Get the background color */ @@ -1247,7 +1248,7 @@ gimp_transform_tool_do (GimpImage *gimage, /* initialise the pixel_surround accessor */ if (interpolation) { - if (interpolation_type == CUBIC_INTERPOLATION) + if (base_config->interpolation_type == CUBIC_INTERPOLATION) { pixel_surround_init (&surround, float_tiles, 4, 4, bg_col); } @@ -1309,7 +1310,7 @@ gimp_transform_tool_do (GimpImage *gimage, if (interpolation) { - if (interpolation_type == CUBIC_INTERPOLATION) + if (base_config->interpolation_type == CUBIC_INTERPOLATION) { /* ttx & tty are the subpixel coordinates of the point in * the original selection's floating buffer. diff --git a/app/core/gimpdrawable.c b/app/core/gimpdrawable.c index 540fed51dd..9108263e33 100644 --- a/app/core/gimpdrawable.c +++ b/app/core/gimpdrawable.c @@ -29,6 +29,10 @@ #include "core-types.h" +#include "base/pixel-region.h" +#include "base/tile.h" +#include "base/tile-manager.h" + #include "paint-funcs/paint-funcs.h" #include "gimpchannel.h" @@ -41,9 +45,6 @@ #include "gimppreviewcache.h" #include "gimpparasite.h" #include "parasitelist.h" -#include "pixel_region.h" -#include "tile.h" -#include "tile_manager.h" #include "undo.h" #include "libgimp/gimpparasite.h" diff --git a/app/core/gimpedit.c b/app/core/gimpedit.c index 4f95336cc9..48514dee88 100644 --- a/app/core/gimpedit.c +++ b/app/core/gimpedit.c @@ -27,6 +27,9 @@ #include "core/core-types.h" #include "tools/tools-types.h" +#include "base/pixel-region.h" +#include "base/tile-manager.h" + #include "paint-funcs/paint-funcs.h" #include "core/gimpchannel.h" @@ -44,8 +47,6 @@ #include "gimage.h" #include "global_edit.h" #include "image_new.h" -#include "pixel_region.h" -#include "tile_manager.h" #include "undo.h" #include "libgimp/gimpintl.h" diff --git a/app/core/gimpgradient.c b/app/core/gimpgradient.c index 259523b5b8..157ef810fe 100644 --- a/app/core/gimpgradient.c +++ b/app/core/gimpgradient.c @@ -26,16 +26,17 @@ #include "libgimpcolor/gimpcolor.h" #include "libgimpmath/gimpmath.h" +#include "libgimp/gimplimits.h" #include "core-types.h" -#include "errors.h" +#include "base/temp-buf.h" + #include "gimpimage.h" #include "gimpgradient.h" -#include "gimprc.h" -#include "temp_buf.h" -#include "libgimp/gimplimits.h" +#include "errors.h" +#include "gimprc.h" #include "libgimp/gimpintl.h" diff --git a/app/core/gimpimage-colorhash.c b/app/core/gimpimage-colorhash.c new file mode 100644 index 0000000000..23aa3cc7c5 --- /dev/null +++ b/app/core/gimpimage-colorhash.c @@ -0,0 +1,157 @@ +/* The GIMP -- an 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 2 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, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#include "config.h" + +#include + +#include "core/core-types.h" + +#include "gimpimage.h" + + +#define MAXDIFF 195076 +#define HASH_TABLE_SIZE 1021 + + +typedef struct _ColorHash ColorHash; + +struct _ColorHash +{ + gint pixel; /* R << 16 | G << 8 | B */ + gint index; /* colormap index */ + GimpImage *gimage; +}; + + +static ColorHash color_hash_table[HASH_TABLE_SIZE]; +static gint color_hash_misses; +static gint color_hash_hits; + + +void +gimp_image_color_hash_init (void) +{ + gint i; + + /* initialize the color hash table--invalidate all entries */ + for (i = 0; i < HASH_TABLE_SIZE; i++) + color_hash_table[i].gimage = NULL; + + color_hash_misses = 0; + color_hash_hits = 0; +} + +void +gimp_image_color_hash_exit (void) +{ + /* print out the hash table statistics + printf ("RGB->indexed hash table lookups: %d\n", color_hash_hits + color_hash_misses); + printf ("RGB->indexed hash table hits: %d\n", color_hash_hits); + printf ("RGB->indexed hash table misses: %d\n", color_hash_misses); + printf ("RGB->indexed hash table hit rate: %f\n", + 100.0 * color_hash_hits / (color_hash_hits + color_hash_misses)); + */ +} + +void +gimp_image_color_hash_invalidate (GimpImage* gimage, + gint index) +{ + gint i; + + g_return_if_fail (gimage != NULL); + g_return_if_fail (GIMP_IS_IMAGE (gimage)); + + if (index == -1) /* invalidate all entries */ + { + for (i = 0; i < HASH_TABLE_SIZE; i++) + if (color_hash_table[i].gimage == gimage) + color_hash_table[i].gimage = NULL; + } + else + { + for (i = 0; i < HASH_TABLE_SIZE; i++) + if (color_hash_table[i].gimage == gimage && + color_hash_table[i].index == index) + color_hash_table[i].gimage = NULL; + } +} + +gint +gimp_image_color_hash_rgb_to_indexed (const GimpImage *gimage, + gint r, + gint g, + gint b) +{ + guchar *cmap; + gint num_cols; + guint pixel; + gint hash_index; + gint cmap_index; + + cmap = gimage->cmap; + num_cols = gimage->num_cols; + pixel = (r << 16) | (g << 8) | b; + hash_index = pixel % HASH_TABLE_SIZE; + + if (color_hash_table[hash_index].gimage == gimage && + color_hash_table[hash_index].pixel == pixel) + { + /* Hash table lookup hit */ + + cmap_index = color_hash_table[hash_index].index; + color_hash_hits++; + } + else + { + /* Hash table lookup miss */ + + const guchar *col; + gint diff, sum, max; + gint i; + + max = MAXDIFF; + cmap_index = 0; + col = cmap; + + for (i = 0; i < num_cols; i++) + { + diff = r - *col++; + sum = diff * diff; + diff = g - *col++; + sum += diff * diff; + diff = b - *col++; + sum += diff * diff; + + if (sum < max) + { + cmap_index = i; + max = sum; + } + } + + /* update the hash table */ + color_hash_table[hash_index].pixel = pixel; + color_hash_table[hash_index].index = cmap_index; + color_hash_table[hash_index].gimage = (GimpImage *) gimage; + color_hash_misses++; + } + + return cmap_index; +} diff --git a/app/boundary.h b/app/core/gimpimage-colorhash.h similarity index 59% rename from app/boundary.h rename to app/core/gimpimage-colorhash.h index 5fbebf1a80..b8b9647b45 100644 --- a/app/boundary.h +++ b/app/core/gimpimage-colorhash.h @@ -16,38 +16,20 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#ifndef __BOUNDARY_H__ -#define __BOUNDARY_H__ +#ifndef __GIMP_IMAGE_COLOR_HASH_H__ +#define __GIMP_IMAGE_COLOR_HASH_H__ -typedef enum -{ - WithinBounds, - IgnoreBounds -} BoundaryType; +void gimp_image_color_hash_init (void); +void gimp_image_color_hash_exit (void); + +void gimp_image_color_hash_invalidate (GimpImage *gimage, + gint index); + +gint gimp_image_color_hash_rgb_to_indexed (const GimpImage *gimage, + gint r, + gint g, + gint b); -struct _BoundSeg -{ - gint x1; - gint y1; - gint x2; - gint y2; - gboolean open; - gboolean visited; -}; - - -BoundSeg * find_mask_boundary (PixelRegion *maskPR, - gint *num_elems, - BoundaryType type, - gint x1, - gint y1, - gint x2, - gint y2); -BoundSeg * sort_boundary (BoundSeg *segs, - gint num_segs, - gint *num_groups); - - -#endif /* __BOUNDARY_H__ */ +#endif /* __GIMP_IMAGE_COLOR_HASH_H__ */ diff --git a/app/core/gimpimage-convert.c b/app/core/gimpimage-convert.c index 8c65612e4f..60de8f6fc5 100644 --- a/app/core/gimpimage-convert.c +++ b/app/core/gimpimage-convert.c @@ -104,6 +104,9 @@ #include "core-types.h" +#include "base/pixel-region.h" +#include "base/tile-manager.h" + #include "app_procs.h" #include "gdisplay.h" @@ -115,8 +118,6 @@ #include "gimplist.h" #include "gimplayer.h" #include "gimppalette.h" -#include "pixel_region.h" -#include "tile_manager.h" #include "undo.h" diff --git a/app/core/gimpimage-duplicate.c b/app/core/gimpimage-duplicate.c index 2e89f80d6f..b833ca71a6 100644 --- a/app/core/gimpimage-duplicate.c +++ b/app/core/gimpimage-duplicate.c @@ -25,14 +25,15 @@ #include "libgimpcolor/gimpcolor.h" #include "libgimpmath/gimpmath.h" -#include "apptypes.h" #include "core-types.h" +#include "base/pixel-region.h" + +#include "paint-funcs/paint-funcs.h" + /* FIXME: remove the Path <-> BezierSelect dependency */ #include "tools/tools-types.h" -#include "paint-funcs/paint-funcs.h" - #include "app_procs.h" #include "drawable.h" #include "floating_sel.h" @@ -46,8 +47,6 @@ #include "gimplist.h" #include "parasitelist.h" #include "path.h" -#include "pixel_region.h" -#include "tile_manager.h" #include "libgimp/gimpintl.h" diff --git a/app/core/gimpimage-guides.c b/app/core/gimpimage-guides.c index 6971c7a6cd..bb34c3e157 100644 --- a/app/core/gimpimage-guides.c +++ b/app/core/gimpimage-guides.c @@ -27,17 +27,23 @@ #include "core-types.h" -/* FIXME: remove the Path <-> BezierSelect dependency */ -#include "tools/tools-types.h" +#include "base/pixel-region.h" +#include "base/temp-buf.h" +#include "base/tile-manager.h" +#include "base/tile.h" #include "paint-funcs/paint-funcs.h" +/* FIXME: remove the Path <-> BezierSelect dependency */ +#include "tools/tools-types.h" + #include "app_procs.h" #include "drawable.h" #include "floating_sel.h" #include "gdisplay.h" #include "gimpcontext.h" #include "gimpimage.h" +#include "gimpimage-colorhash.h" #include "gimpimage-mask.h" #include "gimpimage-undo.h" #include "gimplayer.h" @@ -49,10 +55,6 @@ #include "gimpundostack.h" #include "parasitelist.h" #include "path.h" -#include "pixel_region.h" -#include "temp_buf.h" -#include "tile_manager.h" -#include "tile.h" #include "undo.h" #include "libgimp/gimplimits.h" @@ -74,6 +76,8 @@ static void gimp_image_init (GimpImage *gimage); static void gimp_image_destroy (GtkObject *object); static void gimp_image_name_changed (GimpObject *object); static void gimp_image_invalidate_preview (GimpViewable *viewable); +static void gimp_image_real_colormap_changed (GimpImage *gimage, + gint ncol); static TempBuf *gimp_image_get_preview (GimpViewable *gimage, gint width, gint height); @@ -368,10 +372,12 @@ gimp_image_class_init (GimpImageClass *klass) klass->clean = NULL; klass->dirty = NULL; klass->repaint = NULL; - klass->colormap_changed = NULL; + klass->colormap_changed = gimp_image_real_colormap_changed; klass->undo_event = NULL; klass->undo = gimp_image_undo; klass->redo = gimp_image_redo; + + gimp_image_color_hash_init (); } @@ -523,6 +529,14 @@ gimp_image_invalidate_preview (GimpViewable *viewable) gimage->comp_preview_valid = FALSE; } +static void +gimp_image_real_colormap_changed (GimpImage *gimage, + gint ncol) +{ + if (gimp_image_base_type (gimage) == INDEXED) + gimp_image_color_hash_invalidate (gimage, ncol); +} + static void gimp_image_allocate_projection (GimpImage *gimage) { @@ -1332,12 +1346,10 @@ gimp_image_transform_color (const GimpImage *gimage, break; case INDEXED_GIMAGE: case INDEXEDA_GIMAGE: /* Least squares method */ - *dest = map_rgb_to_indexed (gimage->cmap, - gimage->num_cols, - gimage, - src[RED_PIX], - src[GREEN_PIX], - src[BLUE_PIX]); + *dest = gimp_image_color_hash_rgb_to_indexed (gimage, + src[RED_PIX], + src[GREEN_PIX], + src[BLUE_PIX]); break; } break; @@ -1356,12 +1368,10 @@ gimp_image_transform_color (const GimpImage *gimage, break; case INDEXED_GIMAGE: case INDEXEDA_GIMAGE: /* Least squares method */ - *dest = map_rgb_to_indexed (gimage->cmap, - gimage->num_cols, - gimage, - src[GRAY_PIX], - src[GRAY_PIX], - src[GRAY_PIX]); + *dest = gimp_image_color_hash_rgb_to_indexed (gimage, + src[GRAY_PIX], + src[GRAY_PIX], + src[GRAY_PIX]); break; } break; diff --git a/app/core/gimpimage-guides.h b/app/core/gimpimage-guides.h index 399d882510..956a51cbb9 100644 --- a/app/core/gimpimage-guides.h +++ b/app/core/gimpimage-guides.h @@ -25,17 +25,6 @@ #define GIMP_IMAGE_TYPE_HAS_ALPHA(t) ((t)==RGBA_GIMAGE || (t)==GRAYA_GIMAGE || (t)==INDEXEDA_GIMAGE) -#define MAX_CHANNELS 4 - -#define GRAY_PIX 0 -#define ALPHA_G_PIX 1 -#define RED_PIX 0 -#define GREEN_PIX 1 -#define BLUE_PIX 2 -#define ALPHA_PIX 3 -#define INDEXED_PIX 0 -#define ALPHA_I_PIX 1 - #define COLORMAP_SIZE 768 typedef enum diff --git a/app/core/gimpimage-mask.c b/app/core/gimpimage-mask.c index bee4baf24f..9cfe7b64a9 100644 --- a/app/core/gimpimage-mask.c +++ b/app/core/gimpimage-mask.c @@ -22,11 +22,14 @@ #include "core-types.h" -/* FIXME: move the "stroke" stuff into the core entirely */ -#include "tools/tools-types.h" +#include "base/boundary.h" +#include "base/pixel-region.h" +#include "base/tile-manager.h" #include "paint-funcs/paint-funcs.h" +/* FIXME: move the "stroke" stuff into the core entirely */ +#include "tools/tools-types.h" #include "tools/tool_manager.h" #include "gimpchannel.h" @@ -35,13 +38,10 @@ #include "gimplayer.h" #include "gimplayermask.h" -#include "boundary.h" #include "drawable.h" #include "floating_sel.h" #include "gdisplay.h" #include "gimprc.h" -#include "pixel_region.h" -#include "tile_manager.h" #include "undo.h" #include "pdb/procedural_db.h" diff --git a/app/core/gimpimage-merge.c b/app/core/gimpimage-merge.c index 6971c7a6cd..bb34c3e157 100644 --- a/app/core/gimpimage-merge.c +++ b/app/core/gimpimage-merge.c @@ -27,17 +27,23 @@ #include "core-types.h" -/* FIXME: remove the Path <-> BezierSelect dependency */ -#include "tools/tools-types.h" +#include "base/pixel-region.h" +#include "base/temp-buf.h" +#include "base/tile-manager.h" +#include "base/tile.h" #include "paint-funcs/paint-funcs.h" +/* FIXME: remove the Path <-> BezierSelect dependency */ +#include "tools/tools-types.h" + #include "app_procs.h" #include "drawable.h" #include "floating_sel.h" #include "gdisplay.h" #include "gimpcontext.h" #include "gimpimage.h" +#include "gimpimage-colorhash.h" #include "gimpimage-mask.h" #include "gimpimage-undo.h" #include "gimplayer.h" @@ -49,10 +55,6 @@ #include "gimpundostack.h" #include "parasitelist.h" #include "path.h" -#include "pixel_region.h" -#include "temp_buf.h" -#include "tile_manager.h" -#include "tile.h" #include "undo.h" #include "libgimp/gimplimits.h" @@ -74,6 +76,8 @@ static void gimp_image_init (GimpImage *gimage); static void gimp_image_destroy (GtkObject *object); static void gimp_image_name_changed (GimpObject *object); static void gimp_image_invalidate_preview (GimpViewable *viewable); +static void gimp_image_real_colormap_changed (GimpImage *gimage, + gint ncol); static TempBuf *gimp_image_get_preview (GimpViewable *gimage, gint width, gint height); @@ -368,10 +372,12 @@ gimp_image_class_init (GimpImageClass *klass) klass->clean = NULL; klass->dirty = NULL; klass->repaint = NULL; - klass->colormap_changed = NULL; + klass->colormap_changed = gimp_image_real_colormap_changed; klass->undo_event = NULL; klass->undo = gimp_image_undo; klass->redo = gimp_image_redo; + + gimp_image_color_hash_init (); } @@ -523,6 +529,14 @@ gimp_image_invalidate_preview (GimpViewable *viewable) gimage->comp_preview_valid = FALSE; } +static void +gimp_image_real_colormap_changed (GimpImage *gimage, + gint ncol) +{ + if (gimp_image_base_type (gimage) == INDEXED) + gimp_image_color_hash_invalidate (gimage, ncol); +} + static void gimp_image_allocate_projection (GimpImage *gimage) { @@ -1332,12 +1346,10 @@ gimp_image_transform_color (const GimpImage *gimage, break; case INDEXED_GIMAGE: case INDEXEDA_GIMAGE: /* Least squares method */ - *dest = map_rgb_to_indexed (gimage->cmap, - gimage->num_cols, - gimage, - src[RED_PIX], - src[GREEN_PIX], - src[BLUE_PIX]); + *dest = gimp_image_color_hash_rgb_to_indexed (gimage, + src[RED_PIX], + src[GREEN_PIX], + src[BLUE_PIX]); break; } break; @@ -1356,12 +1368,10 @@ gimp_image_transform_color (const GimpImage *gimage, break; case INDEXED_GIMAGE: case INDEXEDA_GIMAGE: /* Least squares method */ - *dest = map_rgb_to_indexed (gimage->cmap, - gimage->num_cols, - gimage, - src[GRAY_PIX], - src[GRAY_PIX], - src[GRAY_PIX]); + *dest = gimp_image_color_hash_rgb_to_indexed (gimage, + src[GRAY_PIX], + src[GRAY_PIX], + src[GRAY_PIX]); break; } break; diff --git a/app/core/gimpimage-merge.h b/app/core/gimpimage-merge.h index 399d882510..956a51cbb9 100644 --- a/app/core/gimpimage-merge.h +++ b/app/core/gimpimage-merge.h @@ -25,17 +25,6 @@ #define GIMP_IMAGE_TYPE_HAS_ALPHA(t) ((t)==RGBA_GIMAGE || (t)==GRAYA_GIMAGE || (t)==INDEXEDA_GIMAGE) -#define MAX_CHANNELS 4 - -#define GRAY_PIX 0 -#define ALPHA_G_PIX 1 -#define RED_PIX 0 -#define GREEN_PIX 1 -#define BLUE_PIX 2 -#define ALPHA_PIX 3 -#define INDEXED_PIX 0 -#define ALPHA_I_PIX 1 - #define COLORMAP_SIZE 768 typedef enum diff --git a/app/core/gimpimage-projection.c b/app/core/gimpimage-projection.c index 6971c7a6cd..bb34c3e157 100644 --- a/app/core/gimpimage-projection.c +++ b/app/core/gimpimage-projection.c @@ -27,17 +27,23 @@ #include "core-types.h" -/* FIXME: remove the Path <-> BezierSelect dependency */ -#include "tools/tools-types.h" +#include "base/pixel-region.h" +#include "base/temp-buf.h" +#include "base/tile-manager.h" +#include "base/tile.h" #include "paint-funcs/paint-funcs.h" +/* FIXME: remove the Path <-> BezierSelect dependency */ +#include "tools/tools-types.h" + #include "app_procs.h" #include "drawable.h" #include "floating_sel.h" #include "gdisplay.h" #include "gimpcontext.h" #include "gimpimage.h" +#include "gimpimage-colorhash.h" #include "gimpimage-mask.h" #include "gimpimage-undo.h" #include "gimplayer.h" @@ -49,10 +55,6 @@ #include "gimpundostack.h" #include "parasitelist.h" #include "path.h" -#include "pixel_region.h" -#include "temp_buf.h" -#include "tile_manager.h" -#include "tile.h" #include "undo.h" #include "libgimp/gimplimits.h" @@ -74,6 +76,8 @@ static void gimp_image_init (GimpImage *gimage); static void gimp_image_destroy (GtkObject *object); static void gimp_image_name_changed (GimpObject *object); static void gimp_image_invalidate_preview (GimpViewable *viewable); +static void gimp_image_real_colormap_changed (GimpImage *gimage, + gint ncol); static TempBuf *gimp_image_get_preview (GimpViewable *gimage, gint width, gint height); @@ -368,10 +372,12 @@ gimp_image_class_init (GimpImageClass *klass) klass->clean = NULL; klass->dirty = NULL; klass->repaint = NULL; - klass->colormap_changed = NULL; + klass->colormap_changed = gimp_image_real_colormap_changed; klass->undo_event = NULL; klass->undo = gimp_image_undo; klass->redo = gimp_image_redo; + + gimp_image_color_hash_init (); } @@ -523,6 +529,14 @@ gimp_image_invalidate_preview (GimpViewable *viewable) gimage->comp_preview_valid = FALSE; } +static void +gimp_image_real_colormap_changed (GimpImage *gimage, + gint ncol) +{ + if (gimp_image_base_type (gimage) == INDEXED) + gimp_image_color_hash_invalidate (gimage, ncol); +} + static void gimp_image_allocate_projection (GimpImage *gimage) { @@ -1332,12 +1346,10 @@ gimp_image_transform_color (const GimpImage *gimage, break; case INDEXED_GIMAGE: case INDEXEDA_GIMAGE: /* Least squares method */ - *dest = map_rgb_to_indexed (gimage->cmap, - gimage->num_cols, - gimage, - src[RED_PIX], - src[GREEN_PIX], - src[BLUE_PIX]); + *dest = gimp_image_color_hash_rgb_to_indexed (gimage, + src[RED_PIX], + src[GREEN_PIX], + src[BLUE_PIX]); break; } break; @@ -1356,12 +1368,10 @@ gimp_image_transform_color (const GimpImage *gimage, break; case INDEXED_GIMAGE: case INDEXEDA_GIMAGE: /* Least squares method */ - *dest = map_rgb_to_indexed (gimage->cmap, - gimage->num_cols, - gimage, - src[GRAY_PIX], - src[GRAY_PIX], - src[GRAY_PIX]); + *dest = gimp_image_color_hash_rgb_to_indexed (gimage, + src[GRAY_PIX], + src[GRAY_PIX], + src[GRAY_PIX]); break; } break; diff --git a/app/core/gimpimage-projection.h b/app/core/gimpimage-projection.h index 399d882510..956a51cbb9 100644 --- a/app/core/gimpimage-projection.h +++ b/app/core/gimpimage-projection.h @@ -25,17 +25,6 @@ #define GIMP_IMAGE_TYPE_HAS_ALPHA(t) ((t)==RGBA_GIMAGE || (t)==GRAYA_GIMAGE || (t)==INDEXEDA_GIMAGE) -#define MAX_CHANNELS 4 - -#define GRAY_PIX 0 -#define ALPHA_G_PIX 1 -#define RED_PIX 0 -#define GREEN_PIX 1 -#define BLUE_PIX 2 -#define ALPHA_PIX 3 -#define INDEXED_PIX 0 -#define ALPHA_I_PIX 1 - #define COLORMAP_SIZE 768 typedef enum diff --git a/app/core/gimpimage-resize.c b/app/core/gimpimage-resize.c index 6971c7a6cd..bb34c3e157 100644 --- a/app/core/gimpimage-resize.c +++ b/app/core/gimpimage-resize.c @@ -27,17 +27,23 @@ #include "core-types.h" -/* FIXME: remove the Path <-> BezierSelect dependency */ -#include "tools/tools-types.h" +#include "base/pixel-region.h" +#include "base/temp-buf.h" +#include "base/tile-manager.h" +#include "base/tile.h" #include "paint-funcs/paint-funcs.h" +/* FIXME: remove the Path <-> BezierSelect dependency */ +#include "tools/tools-types.h" + #include "app_procs.h" #include "drawable.h" #include "floating_sel.h" #include "gdisplay.h" #include "gimpcontext.h" #include "gimpimage.h" +#include "gimpimage-colorhash.h" #include "gimpimage-mask.h" #include "gimpimage-undo.h" #include "gimplayer.h" @@ -49,10 +55,6 @@ #include "gimpundostack.h" #include "parasitelist.h" #include "path.h" -#include "pixel_region.h" -#include "temp_buf.h" -#include "tile_manager.h" -#include "tile.h" #include "undo.h" #include "libgimp/gimplimits.h" @@ -74,6 +76,8 @@ static void gimp_image_init (GimpImage *gimage); static void gimp_image_destroy (GtkObject *object); static void gimp_image_name_changed (GimpObject *object); static void gimp_image_invalidate_preview (GimpViewable *viewable); +static void gimp_image_real_colormap_changed (GimpImage *gimage, + gint ncol); static TempBuf *gimp_image_get_preview (GimpViewable *gimage, gint width, gint height); @@ -368,10 +372,12 @@ gimp_image_class_init (GimpImageClass *klass) klass->clean = NULL; klass->dirty = NULL; klass->repaint = NULL; - klass->colormap_changed = NULL; + klass->colormap_changed = gimp_image_real_colormap_changed; klass->undo_event = NULL; klass->undo = gimp_image_undo; klass->redo = gimp_image_redo; + + gimp_image_color_hash_init (); } @@ -523,6 +529,14 @@ gimp_image_invalidate_preview (GimpViewable *viewable) gimage->comp_preview_valid = FALSE; } +static void +gimp_image_real_colormap_changed (GimpImage *gimage, + gint ncol) +{ + if (gimp_image_base_type (gimage) == INDEXED) + gimp_image_color_hash_invalidate (gimage, ncol); +} + static void gimp_image_allocate_projection (GimpImage *gimage) { @@ -1332,12 +1346,10 @@ gimp_image_transform_color (const GimpImage *gimage, break; case INDEXED_GIMAGE: case INDEXEDA_GIMAGE: /* Least squares method */ - *dest = map_rgb_to_indexed (gimage->cmap, - gimage->num_cols, - gimage, - src[RED_PIX], - src[GREEN_PIX], - src[BLUE_PIX]); + *dest = gimp_image_color_hash_rgb_to_indexed (gimage, + src[RED_PIX], + src[GREEN_PIX], + src[BLUE_PIX]); break; } break; @@ -1356,12 +1368,10 @@ gimp_image_transform_color (const GimpImage *gimage, break; case INDEXED_GIMAGE: case INDEXEDA_GIMAGE: /* Least squares method */ - *dest = map_rgb_to_indexed (gimage->cmap, - gimage->num_cols, - gimage, - src[GRAY_PIX], - src[GRAY_PIX], - src[GRAY_PIX]); + *dest = gimp_image_color_hash_rgb_to_indexed (gimage, + src[GRAY_PIX], + src[GRAY_PIX], + src[GRAY_PIX]); break; } break; diff --git a/app/core/gimpimage-resize.h b/app/core/gimpimage-resize.h index 399d882510..956a51cbb9 100644 --- a/app/core/gimpimage-resize.h +++ b/app/core/gimpimage-resize.h @@ -25,17 +25,6 @@ #define GIMP_IMAGE_TYPE_HAS_ALPHA(t) ((t)==RGBA_GIMAGE || (t)==GRAYA_GIMAGE || (t)==INDEXEDA_GIMAGE) -#define MAX_CHANNELS 4 - -#define GRAY_PIX 0 -#define ALPHA_G_PIX 1 -#define RED_PIX 0 -#define GREEN_PIX 1 -#define BLUE_PIX 2 -#define ALPHA_PIX 3 -#define INDEXED_PIX 0 -#define ALPHA_I_PIX 1 - #define COLORMAP_SIZE 768 typedef enum diff --git a/app/core/gimpimage-scale.c b/app/core/gimpimage-scale.c index 6971c7a6cd..bb34c3e157 100644 --- a/app/core/gimpimage-scale.c +++ b/app/core/gimpimage-scale.c @@ -27,17 +27,23 @@ #include "core-types.h" -/* FIXME: remove the Path <-> BezierSelect dependency */ -#include "tools/tools-types.h" +#include "base/pixel-region.h" +#include "base/temp-buf.h" +#include "base/tile-manager.h" +#include "base/tile.h" #include "paint-funcs/paint-funcs.h" +/* FIXME: remove the Path <-> BezierSelect dependency */ +#include "tools/tools-types.h" + #include "app_procs.h" #include "drawable.h" #include "floating_sel.h" #include "gdisplay.h" #include "gimpcontext.h" #include "gimpimage.h" +#include "gimpimage-colorhash.h" #include "gimpimage-mask.h" #include "gimpimage-undo.h" #include "gimplayer.h" @@ -49,10 +55,6 @@ #include "gimpundostack.h" #include "parasitelist.h" #include "path.h" -#include "pixel_region.h" -#include "temp_buf.h" -#include "tile_manager.h" -#include "tile.h" #include "undo.h" #include "libgimp/gimplimits.h" @@ -74,6 +76,8 @@ static void gimp_image_init (GimpImage *gimage); static void gimp_image_destroy (GtkObject *object); static void gimp_image_name_changed (GimpObject *object); static void gimp_image_invalidate_preview (GimpViewable *viewable); +static void gimp_image_real_colormap_changed (GimpImage *gimage, + gint ncol); static TempBuf *gimp_image_get_preview (GimpViewable *gimage, gint width, gint height); @@ -368,10 +372,12 @@ gimp_image_class_init (GimpImageClass *klass) klass->clean = NULL; klass->dirty = NULL; klass->repaint = NULL; - klass->colormap_changed = NULL; + klass->colormap_changed = gimp_image_real_colormap_changed; klass->undo_event = NULL; klass->undo = gimp_image_undo; klass->redo = gimp_image_redo; + + gimp_image_color_hash_init (); } @@ -523,6 +529,14 @@ gimp_image_invalidate_preview (GimpViewable *viewable) gimage->comp_preview_valid = FALSE; } +static void +gimp_image_real_colormap_changed (GimpImage *gimage, + gint ncol) +{ + if (gimp_image_base_type (gimage) == INDEXED) + gimp_image_color_hash_invalidate (gimage, ncol); +} + static void gimp_image_allocate_projection (GimpImage *gimage) { @@ -1332,12 +1346,10 @@ gimp_image_transform_color (const GimpImage *gimage, break; case INDEXED_GIMAGE: case INDEXEDA_GIMAGE: /* Least squares method */ - *dest = map_rgb_to_indexed (gimage->cmap, - gimage->num_cols, - gimage, - src[RED_PIX], - src[GREEN_PIX], - src[BLUE_PIX]); + *dest = gimp_image_color_hash_rgb_to_indexed (gimage, + src[RED_PIX], + src[GREEN_PIX], + src[BLUE_PIX]); break; } break; @@ -1356,12 +1368,10 @@ gimp_image_transform_color (const GimpImage *gimage, break; case INDEXED_GIMAGE: case INDEXEDA_GIMAGE: /* Least squares method */ - *dest = map_rgb_to_indexed (gimage->cmap, - gimage->num_cols, - gimage, - src[GRAY_PIX], - src[GRAY_PIX], - src[GRAY_PIX]); + *dest = gimp_image_color_hash_rgb_to_indexed (gimage, + src[GRAY_PIX], + src[GRAY_PIX], + src[GRAY_PIX]); break; } break; diff --git a/app/core/gimpimage-scale.h b/app/core/gimpimage-scale.h index 399d882510..956a51cbb9 100644 --- a/app/core/gimpimage-scale.h +++ b/app/core/gimpimage-scale.h @@ -25,17 +25,6 @@ #define GIMP_IMAGE_TYPE_HAS_ALPHA(t) ((t)==RGBA_GIMAGE || (t)==GRAYA_GIMAGE || (t)==INDEXEDA_GIMAGE) -#define MAX_CHANNELS 4 - -#define GRAY_PIX 0 -#define ALPHA_G_PIX 1 -#define RED_PIX 0 -#define GREEN_PIX 1 -#define BLUE_PIX 2 -#define ALPHA_PIX 3 -#define INDEXED_PIX 0 -#define ALPHA_I_PIX 1 - #define COLORMAP_SIZE 768 typedef enum diff --git a/app/core/gimpimage-undo-push.c b/app/core/gimpimage-undo-push.c index 2f45b6e8e2..01396f3d98 100644 --- a/app/core/gimpimage-undo-push.c +++ b/app/core/gimpimage-undo-push.c @@ -26,6 +26,10 @@ #include "core/core-types.h" #include "tools/tools-types.h" +#include "base/pixel-region.h" +#include "base/tile-manager.h" +#include "base/tile.h" + #include "paint-funcs/paint-funcs.h" #include "core/gimpchannel.h" @@ -50,9 +54,6 @@ #include "gimprc.h" #include "parasitelist.h" #include "path_transform.h" -#include "pixel_region.h" -#include "tile_manager.h" -#include "tile.h" #include "undo.h" #include "libgimp/gimpparasite.h" diff --git a/app/core/gimpimage.c b/app/core/gimpimage.c index 6971c7a6cd..bb34c3e157 100644 --- a/app/core/gimpimage.c +++ b/app/core/gimpimage.c @@ -27,17 +27,23 @@ #include "core-types.h" -/* FIXME: remove the Path <-> BezierSelect dependency */ -#include "tools/tools-types.h" +#include "base/pixel-region.h" +#include "base/temp-buf.h" +#include "base/tile-manager.h" +#include "base/tile.h" #include "paint-funcs/paint-funcs.h" +/* FIXME: remove the Path <-> BezierSelect dependency */ +#include "tools/tools-types.h" + #include "app_procs.h" #include "drawable.h" #include "floating_sel.h" #include "gdisplay.h" #include "gimpcontext.h" #include "gimpimage.h" +#include "gimpimage-colorhash.h" #include "gimpimage-mask.h" #include "gimpimage-undo.h" #include "gimplayer.h" @@ -49,10 +55,6 @@ #include "gimpundostack.h" #include "parasitelist.h" #include "path.h" -#include "pixel_region.h" -#include "temp_buf.h" -#include "tile_manager.h" -#include "tile.h" #include "undo.h" #include "libgimp/gimplimits.h" @@ -74,6 +76,8 @@ static void gimp_image_init (GimpImage *gimage); static void gimp_image_destroy (GtkObject *object); static void gimp_image_name_changed (GimpObject *object); static void gimp_image_invalidate_preview (GimpViewable *viewable); +static void gimp_image_real_colormap_changed (GimpImage *gimage, + gint ncol); static TempBuf *gimp_image_get_preview (GimpViewable *gimage, gint width, gint height); @@ -368,10 +372,12 @@ gimp_image_class_init (GimpImageClass *klass) klass->clean = NULL; klass->dirty = NULL; klass->repaint = NULL; - klass->colormap_changed = NULL; + klass->colormap_changed = gimp_image_real_colormap_changed; klass->undo_event = NULL; klass->undo = gimp_image_undo; klass->redo = gimp_image_redo; + + gimp_image_color_hash_init (); } @@ -523,6 +529,14 @@ gimp_image_invalidate_preview (GimpViewable *viewable) gimage->comp_preview_valid = FALSE; } +static void +gimp_image_real_colormap_changed (GimpImage *gimage, + gint ncol) +{ + if (gimp_image_base_type (gimage) == INDEXED) + gimp_image_color_hash_invalidate (gimage, ncol); +} + static void gimp_image_allocate_projection (GimpImage *gimage) { @@ -1332,12 +1346,10 @@ gimp_image_transform_color (const GimpImage *gimage, break; case INDEXED_GIMAGE: case INDEXEDA_GIMAGE: /* Least squares method */ - *dest = map_rgb_to_indexed (gimage->cmap, - gimage->num_cols, - gimage, - src[RED_PIX], - src[GREEN_PIX], - src[BLUE_PIX]); + *dest = gimp_image_color_hash_rgb_to_indexed (gimage, + src[RED_PIX], + src[GREEN_PIX], + src[BLUE_PIX]); break; } break; @@ -1356,12 +1368,10 @@ gimp_image_transform_color (const GimpImage *gimage, break; case INDEXED_GIMAGE: case INDEXEDA_GIMAGE: /* Least squares method */ - *dest = map_rgb_to_indexed (gimage->cmap, - gimage->num_cols, - gimage, - src[GRAY_PIX], - src[GRAY_PIX], - src[GRAY_PIX]); + *dest = gimp_image_color_hash_rgb_to_indexed (gimage, + src[GRAY_PIX], + src[GRAY_PIX], + src[GRAY_PIX]); break; } break; diff --git a/app/core/gimpimage.h b/app/core/gimpimage.h index 399d882510..956a51cbb9 100644 --- a/app/core/gimpimage.h +++ b/app/core/gimpimage.h @@ -25,17 +25,6 @@ #define GIMP_IMAGE_TYPE_HAS_ALPHA(t) ((t)==RGBA_GIMAGE || (t)==GRAYA_GIMAGE || (t)==INDEXEDA_GIMAGE) -#define MAX_CHANNELS 4 - -#define GRAY_PIX 0 -#define ALPHA_G_PIX 1 -#define RED_PIX 0 -#define GREEN_PIX 1 -#define BLUE_PIX 2 -#define ALPHA_PIX 3 -#define INDEXED_PIX 0 -#define ALPHA_I_PIX 1 - #define COLORMAP_SIZE 768 typedef enum diff --git a/app/core/gimpimagemap.c b/app/core/gimpimagemap.c index 130eb9fda8..0130af5851 100644 --- a/app/core/gimpimagemap.c +++ b/app/core/gimpimagemap.c @@ -22,6 +22,10 @@ #include "core/core-types.h" +#include "base/pixel-region.h" +#include "base/tile-manager.h" +#include "base/tile.h" + #include "paint-funcs/paint-funcs.h" #include "core/gimpdrawable.h" @@ -30,9 +34,6 @@ #include "drawable.h" #include "gdisplay.h" #include "image_map.h" -#include "pixel_region.h" -#include "tile.h" -#include "tile_manager.h" #define WAITING 0 diff --git a/app/core/gimplayer-floating-sel.c b/app/core/gimplayer-floating-sel.c index 6c456e10d8..6dd2be2f6c 100644 --- a/app/core/gimplayer-floating-sel.c +++ b/app/core/gimplayer-floating-sel.c @@ -24,6 +24,10 @@ #include "core/core-types.h" +#include "base/boundary.h" +#include "base/pixel-region.h" +#include "base/tile-manager.h" + #include "paint-funcs/paint-funcs.h" #include "core/gimpimage.h" @@ -31,12 +35,9 @@ #include "core/gimplayer.h" #include "core/gimplayermask.h" -#include "boundary.h" #include "drawable.h" #include "floating_sel.h" #include "gdisplay.h" -#include "pixel_region.h" -#include "tile_manager.h" #include "undo.h" #include "libgimp/gimpintl.h" diff --git a/app/core/gimplayer.c b/app/core/gimplayer.c index c16db622c1..963ebeab95 100644 --- a/app/core/gimplayer.c +++ b/app/core/gimplayer.c @@ -29,9 +29,13 @@ #include "core-types.h" +#include "base/boundary.h" +#include "base/pixel-region.h" +#include "base/tile-manager.h" +#include "base/tile.h" + #include "paint-funcs/paint-funcs.h" -#include "boundary.h" #include "drawable.h" #include "floating_sel.h" #include "gdisplay.h" @@ -40,11 +44,7 @@ #include "gimplayer.h" #include "gimplayermask.h" #include "parasitelist.h" -#include "pixel_region.h" #include "undo.h" -#include "temp_buf.h" -#include "tile_manager.h" -#include "tile.h" #include "libgimp/gimpparasite.h" diff --git a/app/core/gimplayermask.c b/app/core/gimplayermask.c index b031a68136..c632f62940 100644 --- a/app/core/gimplayermask.c +++ b/app/core/gimplayermask.c @@ -27,15 +27,13 @@ #include "core-types.h" +#include "base/pixel-region.h" + #include "paint-funcs/paint-funcs.h" -#include "boundary.h" -#include "drawable.h" #include "gimplayermask.h" -#include "pixel_region.h" -#include "temp_buf.h" -#include "tile_manager.h" -#include "tile.h" + +#include "drawable.h" #include "undo.h" #include "libgimp/gimpparasite.h" diff --git a/app/core/gimppalette-import.c b/app/core/gimppalette-import.c index 59b26935c8..2df07d09e7 100644 --- a/app/core/gimppalette-import.c +++ b/app/core/gimppalette-import.c @@ -26,14 +26,13 @@ #include "core-types.h" +#include "base/pixel-region.h" + #include "gimpcontainer.h" #include "gimpgradient.h" #include "gimpimage.h" #include "gimppalette.h" -#include "pixel_region.h" -#include "temp_buf.h" - #include "libgimp/gimpintl.h" diff --git a/app/core/gimppalette-load.c b/app/core/gimppalette-load.c index a8d11e3ee2..9274b6e949 100644 --- a/app/core/gimppalette-load.c +++ b/app/core/gimppalette-load.c @@ -32,10 +32,11 @@ #include "core-types.h" +#include "base/temp-buf.h" + #include "gimppalette.h" #include "gimprc.h" -#include "temp_buf.h" #include "libgimp/gimpintl.h" diff --git a/app/core/gimppalette-save.c b/app/core/gimppalette-save.c index a8d11e3ee2..9274b6e949 100644 --- a/app/core/gimppalette-save.c +++ b/app/core/gimppalette-save.c @@ -32,10 +32,11 @@ #include "core-types.h" +#include "base/temp-buf.h" + #include "gimppalette.h" #include "gimprc.h" -#include "temp_buf.h" #include "libgimp/gimpintl.h" diff --git a/app/core/gimppalette.c b/app/core/gimppalette.c index a8d11e3ee2..9274b6e949 100644 --- a/app/core/gimppalette.c +++ b/app/core/gimppalette.c @@ -32,10 +32,11 @@ #include "core-types.h" +#include "base/temp-buf.h" + #include "gimppalette.h" #include "gimprc.h" -#include "temp_buf.h" #include "libgimp/gimpintl.h" diff --git a/app/core/gimppattern-load.c b/app/core/gimppattern-load.c index f31de287e6..7c328ff2e5 100644 --- a/app/core/gimppattern-load.c +++ b/app/core/gimppattern-load.c @@ -42,13 +42,13 @@ #include "core-types.h" +#include "base/base-config.h" +#include "base/temp-buf.h" + #include "gimpimage.h" #include "gimppattern.h" #include "gimppattern-header.h" -#include "gimprc.h" -#include "temp_buf.h" - #include "libgimp/gimpintl.h" @@ -180,7 +180,7 @@ gimp_pattern_duplicate (GimpData *data) pattern->mask = temp_buf_copy (GIMP_PATTERN (data)->mask, NULL); /* Swap the pattern to disk (if we're being stingy with memory) */ - if (stingy_memory_use) + if (base_config->stingy_memory_use) temp_buf_swap (pattern->mask); return GIMP_DATA (pattern); @@ -211,7 +211,7 @@ gimp_pattern_new (const gchar *name) } /* Swap the pattern to disk (if we're being stingy with memory) */ - if (stingy_memory_use) + if (base_config->stingy_memory_use) temp_buf_swap (pattern->mask); return GIMP_DATA (pattern); @@ -334,7 +334,7 @@ gimp_pattern_load (const gchar *filename) gimp_data_set_filename (GIMP_DATA (pattern), filename); /* Swap the pattern to disk (if we're being stingy with memory) */ - if (stingy_memory_use) + if (base_config->stingy_memory_use) temp_buf_swap (pattern->mask); return GIMP_DATA (pattern); diff --git a/app/core/gimppattern.c b/app/core/gimppattern.c index f31de287e6..7c328ff2e5 100644 --- a/app/core/gimppattern.c +++ b/app/core/gimppattern.c @@ -42,13 +42,13 @@ #include "core-types.h" +#include "base/base-config.h" +#include "base/temp-buf.h" + #include "gimpimage.h" #include "gimppattern.h" #include "gimppattern-header.h" -#include "gimprc.h" -#include "temp_buf.h" - #include "libgimp/gimpintl.h" @@ -180,7 +180,7 @@ gimp_pattern_duplicate (GimpData *data) pattern->mask = temp_buf_copy (GIMP_PATTERN (data)->mask, NULL); /* Swap the pattern to disk (if we're being stingy with memory) */ - if (stingy_memory_use) + if (base_config->stingy_memory_use) temp_buf_swap (pattern->mask); return GIMP_DATA (pattern); @@ -211,7 +211,7 @@ gimp_pattern_new (const gchar *name) } /* Swap the pattern to disk (if we're being stingy with memory) */ - if (stingy_memory_use) + if (base_config->stingy_memory_use) temp_buf_swap (pattern->mask); return GIMP_DATA (pattern); @@ -334,7 +334,7 @@ gimp_pattern_load (const gchar *filename) gimp_data_set_filename (GIMP_DATA (pattern), filename); /* Swap the pattern to disk (if we're being stingy with memory) */ - if (stingy_memory_use) + if (base_config->stingy_memory_use) temp_buf_swap (pattern->mask); return GIMP_DATA (pattern); diff --git a/app/core/gimppreviewcache.c b/app/core/gimppreviewcache.c index 08e6b90954..642e5f5914 100644 --- a/app/core/gimppreviewcache.c +++ b/app/core/gimppreviewcache.c @@ -18,9 +18,11 @@ #include "config.h" -#include +#include -#include "apptypes.h" +#include "base/base-types.h" + +#include "base/temp-buf.h" #include "gimppreviewcache.h" diff --git a/app/core/gimppreviewcache.h b/app/core/gimppreviewcache.h index 17e5e3e0c5..7e84d7806b 100644 --- a/app/core/gimppreviewcache.h +++ b/app/core/gimppreviewcache.h @@ -20,9 +20,6 @@ #define __GIMPPREVIEWCACHE_H__ -#include "temp_buf.h" - - #define PREVIEW_CACHE_PRIME_WIDTH 112 #define PREVIEW_CACHE_PRIME_HEIGHT 112 diff --git a/app/core/gimpprojection-construct.c b/app/core/gimpprojection-construct.c index 6971c7a6cd..bb34c3e157 100644 --- a/app/core/gimpprojection-construct.c +++ b/app/core/gimpprojection-construct.c @@ -27,17 +27,23 @@ #include "core-types.h" -/* FIXME: remove the Path <-> BezierSelect dependency */ -#include "tools/tools-types.h" +#include "base/pixel-region.h" +#include "base/temp-buf.h" +#include "base/tile-manager.h" +#include "base/tile.h" #include "paint-funcs/paint-funcs.h" +/* FIXME: remove the Path <-> BezierSelect dependency */ +#include "tools/tools-types.h" + #include "app_procs.h" #include "drawable.h" #include "floating_sel.h" #include "gdisplay.h" #include "gimpcontext.h" #include "gimpimage.h" +#include "gimpimage-colorhash.h" #include "gimpimage-mask.h" #include "gimpimage-undo.h" #include "gimplayer.h" @@ -49,10 +55,6 @@ #include "gimpundostack.h" #include "parasitelist.h" #include "path.h" -#include "pixel_region.h" -#include "temp_buf.h" -#include "tile_manager.h" -#include "tile.h" #include "undo.h" #include "libgimp/gimplimits.h" @@ -74,6 +76,8 @@ static void gimp_image_init (GimpImage *gimage); static void gimp_image_destroy (GtkObject *object); static void gimp_image_name_changed (GimpObject *object); static void gimp_image_invalidate_preview (GimpViewable *viewable); +static void gimp_image_real_colormap_changed (GimpImage *gimage, + gint ncol); static TempBuf *gimp_image_get_preview (GimpViewable *gimage, gint width, gint height); @@ -368,10 +372,12 @@ gimp_image_class_init (GimpImageClass *klass) klass->clean = NULL; klass->dirty = NULL; klass->repaint = NULL; - klass->colormap_changed = NULL; + klass->colormap_changed = gimp_image_real_colormap_changed; klass->undo_event = NULL; klass->undo = gimp_image_undo; klass->redo = gimp_image_redo; + + gimp_image_color_hash_init (); } @@ -523,6 +529,14 @@ gimp_image_invalidate_preview (GimpViewable *viewable) gimage->comp_preview_valid = FALSE; } +static void +gimp_image_real_colormap_changed (GimpImage *gimage, + gint ncol) +{ + if (gimp_image_base_type (gimage) == INDEXED) + gimp_image_color_hash_invalidate (gimage, ncol); +} + static void gimp_image_allocate_projection (GimpImage *gimage) { @@ -1332,12 +1346,10 @@ gimp_image_transform_color (const GimpImage *gimage, break; case INDEXED_GIMAGE: case INDEXEDA_GIMAGE: /* Least squares method */ - *dest = map_rgb_to_indexed (gimage->cmap, - gimage->num_cols, - gimage, - src[RED_PIX], - src[GREEN_PIX], - src[BLUE_PIX]); + *dest = gimp_image_color_hash_rgb_to_indexed (gimage, + src[RED_PIX], + src[GREEN_PIX], + src[BLUE_PIX]); break; } break; @@ -1356,12 +1368,10 @@ gimp_image_transform_color (const GimpImage *gimage, break; case INDEXED_GIMAGE: case INDEXEDA_GIMAGE: /* Least squares method */ - *dest = map_rgb_to_indexed (gimage->cmap, - gimage->num_cols, - gimage, - src[GRAY_PIX], - src[GRAY_PIX], - src[GRAY_PIX]); + *dest = gimp_image_color_hash_rgb_to_indexed (gimage, + src[GRAY_PIX], + src[GRAY_PIX], + src[GRAY_PIX]); break; } break; diff --git a/app/core/gimpprojection-construct.h b/app/core/gimpprojection-construct.h index 399d882510..956a51cbb9 100644 --- a/app/core/gimpprojection-construct.h +++ b/app/core/gimpprojection-construct.h @@ -25,17 +25,6 @@ #define GIMP_IMAGE_TYPE_HAS_ALPHA(t) ((t)==RGBA_GIMAGE || (t)==GRAYA_GIMAGE || (t)==INDEXEDA_GIMAGE) -#define MAX_CHANNELS 4 - -#define GRAY_PIX 0 -#define ALPHA_G_PIX 1 -#define RED_PIX 0 -#define GREEN_PIX 1 -#define BLUE_PIX 2 -#define ALPHA_PIX 3 -#define INDEXED_PIX 0 -#define ALPHA_I_PIX 1 - #define COLORMAP_SIZE 768 typedef enum diff --git a/app/core/gimpprojection.c b/app/core/gimpprojection.c index fdfe7ace19..f86eff5f97 100644 --- a/app/core/gimpprojection.c +++ b/app/core/gimpprojection.c @@ -28,6 +28,8 @@ #include "core/core-types.h" #include "tools/tools-types.h" +#include "base/temp-buf.h" + #include "core/gimpchannel.h" #include "core/gimpcontainer.h" #include "core/gimpcontext.h" @@ -57,7 +59,6 @@ #include "qmask.h" #include "scale.h" #include "selection.h" -#include "temp_buf.h" #include "undo.h" #ifdef DISPLAY_FILTERS diff --git a/app/core/gimpscanconvert.c b/app/core/gimpscanconvert.c index 513dc4c165..b290cd8492 100644 --- a/app/core/gimpscanconvert.c +++ b/app/core/gimpscanconvert.c @@ -26,10 +26,11 @@ #include "core/core-types.h" +#include "base/pixel-region.h" + #include "core/gimpchannel.h" #include "core/gimpimage.h" -#include "pixel_region.h" #include "scan_convert.h" diff --git a/app/core/gimptoolinfo.c b/app/core/gimptoolinfo.c index ff8b538bd5..08d4069e11 100644 --- a/app/core/gimptoolinfo.c +++ b/app/core/gimptoolinfo.c @@ -21,15 +21,16 @@ #include #include "core/core-types.h" -#include "tools/tools-types.h" + +#include "base/temp-buf.h" #include "gimpcontext.h" #include "gimptoolinfo.h" #include "context_manager.h" -#include "temp_buf.h" /* GRMPF */ +#include "tools/tools-types.h" #include "tools/gimprectselecttool.h" diff --git a/app/core/gimpundo.c b/app/core/gimpundo.c index e74d74404b..b40db1487e 100644 --- a/app/core/gimpundo.c +++ b/app/core/gimpundo.c @@ -22,11 +22,12 @@ #include "core-types.h" +#include "base/temp-buf.h" + #include "gimpimage.h" #include "gimpundo.h" #include "gimprc.h" -#include "temp_buf.h" enum diff --git a/app/core/gimpviewable.c b/app/core/gimpviewable.c index 5c5439042d..13e20b543c 100644 --- a/app/core/gimpviewable.c +++ b/app/core/gimpviewable.c @@ -25,9 +25,10 @@ #include "core-types.h" +#include "base/temp-buf.h" + #include "gimpmarshal.h" #include "gimpviewable.h" -#include "temp_buf.h" enum diff --git a/app/dialogs/file-open-dialog.c b/app/dialogs/file-open-dialog.c index 3424006a9a..1654a7e1ad 100644 --- a/app/dialogs/file-open-dialog.c +++ b/app/dialogs/file-open-dialog.c @@ -40,6 +40,8 @@ #include "core/core-types.h" +#include "base/temp-buf.h" + #include "core/gimpcontext.h" #include "core/gimpimage.h" @@ -57,7 +59,6 @@ #include "file-open.h" #include "file-utils.h" #include "plug_in.h" -#include "temp_buf.h" #include "undo.h" #include "libgimp/gimpintl.h" diff --git a/app/dialogs/file-save-dialog.c b/app/dialogs/file-save-dialog.c index 492b1b6c66..9cbce6d198 100644 --- a/app/dialogs/file-save-dialog.c +++ b/app/dialogs/file-save-dialog.c @@ -49,7 +49,6 @@ #include "file-save.h" #include "file-utils.h" #include "plug_in.h" -#include "temp_buf.h" #include "undo.h" #include "libgimp/gimpintl.h" diff --git a/app/dialogs/palette-import-dialog.c b/app/dialogs/palette-import-dialog.c index 3528e042dd..c8978c5d47 100644 --- a/app/dialogs/palette-import-dialog.c +++ b/app/dialogs/palette-import-dialog.c @@ -27,6 +27,8 @@ #include "core/core-types.h" +#include "base/temp-buf.h" + #include "core/gimpcontainer.h" #include "core/gimpcontext.h" #include "core/gimpdatafactory.h" @@ -41,7 +43,6 @@ #include "context_manager.h" #include "gimage.h" -#include "temp_buf.h" #include "libgimp/gimpintl.h" diff --git a/app/dialogs/preferences-dialog.c b/app/dialogs/preferences-dialog.c index cdb6c9e6de..ad7f1ffc95 100644 --- a/app/dialogs/preferences-dialog.c +++ b/app/dialogs/preferences-dialog.c @@ -28,6 +28,9 @@ #include "core/core-types.h" +#include "base/base-config.h" +#include "base/tile-cache.h" + #include "core/gimpcontainer.h" #include "core/gimpimage.h" @@ -42,7 +45,6 @@ #include "gimprc.h" #include "image_render.h" #include "resolution_calibrate.h" -#include "tile_cache.h" #include "libgimp/gimpintl.h" @@ -440,7 +442,7 @@ prefs_ok_callback (GtkWidget *widget, if (edit_tile_cache_size != old_tile_cache_size) { - tile_cache_size = edit_tile_cache_size; + base_config->tile_cache_size = edit_tile_cache_size; tile_cache_set_size (edit_tile_cache_size); } break; @@ -513,7 +515,7 @@ prefs_save_callback (GtkWidget *widget, prefs_dlg = NULL; /* Save variables so that we can restore them later */ - save_stingy_memory_use = stingy_memory_use; + save_stingy_memory_use = base_config->stingy_memory_use; save_min_colors = min_colors; save_install_cmap = install_cmap; save_cycled_marching_ants = cycled_marching_ants; @@ -522,8 +524,8 @@ prefs_save_callback (GtkWidget *widget, save_nav_window_per_display = nav_window_per_display; save_info_window_follows_mouse = info_window_follows_mouse; - save_temp_path = temp_path; - save_swap_path = swap_path; + save_temp_path = base_config->temp_path; + save_swap_path = base_config->swap_path; save_brush_path = brush_path; save_pattern_path = pattern_path; save_palette_path = palette_path; @@ -569,7 +571,7 @@ prefs_save_callback (GtkWidget *widget, update = g_list_append (update, "show-statusbar"); remove = g_list_append (remove, "dont-show-statusbar"); } - if (interpolation_type != old_interpolation_type) + if (base_config->interpolation_type != old_interpolation_type) { update = g_list_append (update, "interpolation-type"); } @@ -710,7 +712,7 @@ prefs_save_callback (GtkWidget *widget, /* values which can't be changed on the fly */ if (edit_stingy_memory_use != old_stingy_memory_use) { - stingy_memory_use = edit_stingy_memory_use; + base_config->stingy_memory_use = edit_stingy_memory_use; update = g_list_append (update, "stingy-memory-use"); } if (edit_min_colors != old_min_colors) @@ -759,12 +761,12 @@ prefs_save_callback (GtkWidget *widget, if (prefs_strcmp (old_temp_path, edit_temp_path)) { - temp_path = edit_temp_path; + base_config->temp_path = edit_temp_path; update = g_list_append (update, "temp-path"); } if (prefs_strcmp (old_swap_path, edit_swap_path)) { - swap_path = edit_swap_path; + base_config->swap_path = edit_swap_path; update = g_list_append (update, "swap-path"); } if (prefs_strcmp (old_brush_path, edit_brush_path)) @@ -801,7 +803,7 @@ prefs_save_callback (GtkWidget *widget, /* values which are changed on "OK" or "Save" */ if (edit_tile_cache_size != old_tile_cache_size) { - tile_cache_size = edit_tile_cache_size; + base_config->tile_cache_size = edit_tile_cache_size; update = g_list_append (update, "tile-cache-size"); } @@ -813,23 +815,23 @@ prefs_save_callback (GtkWidget *widget, gdisplay_xserver_resolution (&monitor_xres, &monitor_yres); /* restore variables which must not change */ - stingy_memory_use = save_stingy_memory_use; - min_colors = save_min_colors; - install_cmap = save_install_cmap; - cycled_marching_ants = save_cycled_marching_ants; - last_opened_size = save_last_opened_size; - show_indicators = save_show_indicators; - nav_window_per_display = save_nav_window_per_display; - info_window_follows_mouse = save_info_window_follows_mouse; + base_config->stingy_memory_use = save_stingy_memory_use; + min_colors = save_min_colors; + install_cmap = save_install_cmap; + cycled_marching_ants = save_cycled_marching_ants; + last_opened_size = save_last_opened_size; + show_indicators = save_show_indicators; + nav_window_per_display = save_nav_window_per_display; + info_window_follows_mouse = save_info_window_follows_mouse; - temp_path = save_temp_path; - swap_path = save_swap_path; - brush_path = save_brush_path; - pattern_path = save_pattern_path; - palette_path = save_palette_path; - gradient_path = save_gradient_path; - plug_in_path = save_plug_in_path; - module_path = save_module_path; + base_config->temp_path = save_temp_path; + base_config->swap_path = save_swap_path; + brush_path = save_brush_path; + pattern_path = save_pattern_path; + palette_path = save_palette_path; + gradient_path = save_gradient_path; + plug_in_path = save_plug_in_path; + module_path = save_module_path; /* no need to restore values which are only changed on "OK" and "Save" */ @@ -845,6 +847,7 @@ prefs_cancel_callback (GtkWidget *widget, prefs_dlg = NULL; /* restore ordinary gimprc variables */ + base_config->interpolation_type = old_interpolation_type; levels_of_undo = old_levels_of_undo; marching_speed = old_marching_speed; allow_resize_windows = old_allow_resize_windows; @@ -854,7 +857,6 @@ prefs_cancel_callback (GtkWidget *widget, show_tool_tips = old_show_tool_tips; show_rulers = old_show_rulers; show_statusbar = old_show_statusbar; - interpolation_type = old_interpolation_type; confirm_on_close = old_confirm_on_close; save_session_info = old_save_session_info; save_device_status = old_save_device_status; @@ -969,11 +971,11 @@ prefs_toggle_callback (GtkWidget *widget, } /* radio buttons */ - else if (data == &thumbnail_mode || - data == &interpolation_type || - data == &trust_dirty_flag || - data == &help_browser || - data == &cursor_mode || + else if (data == &thumbnail_mode || + data == &base_config->interpolation_type || + data == &trust_dirty_flag || + data == &help_browser || + data == &cursor_mode || data == &default_type) { *val = (gint) gtk_object_get_user_data (GTK_OBJECT (widget)); @@ -1389,7 +1391,7 @@ preferences_dialog_create (void) /* first time dialog is opened - * copy config vals to edit variables. */ - edit_stingy_memory_use = stingy_memory_use; + edit_stingy_memory_use = base_config->stingy_memory_use; edit_min_colors = min_colors; edit_install_cmap = install_cmap; edit_cycled_marching_ants = cycled_marching_ants; @@ -1399,8 +1401,8 @@ preferences_dialog_create (void) edit_info_window_follows_mouse = info_window_follows_mouse; edit_disable_tearoff_menus = disable_tearoff_menus; - edit_temp_path = prefs_strdup (temp_path); - edit_swap_path = prefs_strdup (swap_path); + edit_temp_path = prefs_strdup (base_config->temp_path); + edit_swap_path = prefs_strdup (base_config->swap_path); edit_plug_in_path = prefs_strdup (plug_in_path); edit_module_path = prefs_strdup (module_path); edit_brush_path = prefs_strdup (brush_path); @@ -1412,9 +1414,10 @@ preferences_dialog_create (void) /* assign edit variables for values which get changed on "OK" and "Save" * but not on the fly. */ - edit_tile_cache_size = tile_cache_size; + edit_tile_cache_size = base_config->tile_cache_size; /* remember all old values */ + old_interpolation_type = base_config->interpolation_type; old_perfectmouse = perfectmouse; old_transparency_type = transparency_type; old_transparency_size = transparency_size; @@ -1428,7 +1431,6 @@ preferences_dialog_create (void) old_show_tool_tips = show_tool_tips; old_show_rulers = show_rulers; old_show_statusbar = show_statusbar; - old_interpolation_type = interpolation_type; old_confirm_on_close = confirm_on_close; old_save_session_info = save_session_info; old_save_device_status = save_device_status; @@ -2266,7 +2268,8 @@ preferences_dialog_create (void) optionmenu = gimp_option_menu_new2 (FALSE, prefs_toggle_callback, - &interpolation_type, (gpointer) interpolation_type, + &base_config->interpolation_type, + (gpointer) base_config->interpolation_type, _("Nearest Neighbor (Fast)"), (gpointer) NEAREST_NEIGHBOR_INTERPOLATION, NULL, diff --git a/app/dialogs/user-install-dialog.c b/app/dialogs/user-install-dialog.c index 21ce3064e9..90e0231ac4 100644 --- a/app/dialogs/user-install-dialog.c +++ b/app/dialogs/user-install-dialog.c @@ -35,6 +35,8 @@ #include "core/core-types.h" +#include "base/base-config.h" + #include "appenv.h" #include "gdisplay_ops.h" #include "gimprc.h" @@ -381,7 +383,7 @@ user_install_continue_callback (GtkWidget *widget, #ifdef G_OS_WIN32 FreeConsole (); #endif - parse_buffers_init (); + gimprc_init (); parse_unitrc (); parse_gimprc (); user_install_tuning (); @@ -896,7 +898,7 @@ user_install_dialog_create (UserInstallCallback callback) #ifdef G_OS_WIN32 -char * +static char * quote_spaces (char *string) { int nspaces = 0; @@ -1106,7 +1108,7 @@ user_install_tuning (void) gtk_box_pack_start (GTK_BOX (tuning_page), hbox, FALSE, FALSE, 0); gtk_widget_show (hbox); - tile_cache_adj = gtk_adjustment_new (tile_cache_size, + tile_cache_adj = gtk_adjustment_new (base_config->tile_cache_size, 0, (4069.0 * 1024 * 1024), 1.0, 1.0, 0.0); memsize = gimp_mem_size_entry_new (GTK_ADJUSTMENT (tile_cache_adj)); gtk_box_pack_end (GTK_BOX (hbox), memsize, FALSE, FALSE, 0); @@ -1132,7 +1134,8 @@ user_install_tuning (void) gtk_box_pack_start (GTK_BOX (tuning_page), hbox, FALSE, FALSE, 0); gtk_widget_show (hbox); - swap_path_filesel = gimp_file_selection_new (_("Select Swap Dir"), swap_path, + swap_path_filesel = gimp_file_selection_new (_("Select Swap Dir"), + base_config->swap_path, TRUE, TRUE); gtk_box_pack_end (GTK_BOX (hbox), swap_path_filesel, FALSE, FALSE, 0); gtk_widget_show (swap_path_filesel); @@ -1291,15 +1294,16 @@ user_install_resolution_done (void) new_monitor_yres = gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (resolution_entry), 1); - if (tile_cache_size != new_tile_cache_size) + if (base_config->tile_cache_size != new_tile_cache_size) { - tile_cache_size = new_tile_cache_size; + base_config->tile_cache_size = new_tile_cache_size; update = g_list_append (update, "tile-cache-size"); } - if (swap_path && new_swap_path && - strcmp (swap_path, new_swap_path)) + if (base_config->swap_path && new_swap_path && + strcmp (base_config->swap_path, new_swap_path)) { - g_free (swap_path); swap_path = new_swap_path; + g_free (base_config->swap_path); + base_config->swap_path = new_swap_path; update = g_list_append (update, "swap-path"); } if (using_xserver_resolution != new_using_xserver_resolution || diff --git a/app/disp_callbacks.c b/app/disp_callbacks.c index 0bad0790c6..ab87f7d0cd 100644 --- a/app/disp_callbacks.c +++ b/app/disp_callbacks.c @@ -28,6 +28,10 @@ #include "core/core-types.h" #include "tools/tools-types.h" +#include "base/pixel-region.h" +#include "base/temp-buf.h" +#include "base/tile-manager.h" + #include "paint-funcs/paint-funcs.h" #include "core/gimpcontext.h" @@ -53,12 +57,9 @@ #include "drawable.h" #include "gimprc.h" #include "gimpui.h" -#include "pixel_region.h" #include "scale.h" #include "scroll.h" #include "selection.h" -#include "temp_buf.h" -#include "tile_manager.h" #include "undo.h" #include "libgimp/gimpintl.h" diff --git a/app/display/gimpdisplay-callbacks.c b/app/display/gimpdisplay-callbacks.c index 0bad0790c6..ab87f7d0cd 100644 --- a/app/display/gimpdisplay-callbacks.c +++ b/app/display/gimpdisplay-callbacks.c @@ -28,6 +28,10 @@ #include "core/core-types.h" #include "tools/tools-types.h" +#include "base/pixel-region.h" +#include "base/temp-buf.h" +#include "base/tile-manager.h" + #include "paint-funcs/paint-funcs.h" #include "core/gimpcontext.h" @@ -53,12 +57,9 @@ #include "drawable.h" #include "gimprc.h" #include "gimpui.h" -#include "pixel_region.h" #include "scale.h" #include "scroll.h" #include "selection.h" -#include "temp_buf.h" -#include "tile_manager.h" #include "undo.h" #include "libgimp/gimpintl.h" diff --git a/app/display/gimpdisplay-render.c b/app/display/gimpdisplay-render.c index 2a1cd4da67..da2608c6d1 100644 --- a/app/display/gimpdisplay-render.c +++ b/app/display/gimpdisplay-render.c @@ -25,6 +25,9 @@ #include "core/core-types.h" +#include "base/tile-manager.h" +#include "base/tile.h" + #include "core/gimpimage.h" #include "appenv.h" @@ -32,10 +35,7 @@ #include "gimprc.h" #include "gximage.h" #include "image_render.h" -#include "pixel_region.h" #include "scale.h" -#include "tile.h" -#include "tile_manager.h" #define MAX_PREVIEW_SIZE 256 /* EEK */ diff --git a/app/display/gimpdisplay-render.h b/app/display/gimpdisplay-render.h index 343224298a..7d8db7d629 100644 --- a/app/display/gimpdisplay-render.h +++ b/app/display/gimpdisplay-render.h @@ -19,7 +19,6 @@ #ifndef __IMAGE_RENDER_H__ #define __IMAGE_RENDER_H__ -#include "gimpchecks.h" /* Functions */ void render_setup (GimpCheckType check_type, diff --git a/app/display/gimpdisplay-selection.c b/app/display/gimpdisplay-selection.c index f5fae7004b..22732ce038 100644 --- a/app/display/gimpdisplay-selection.c +++ b/app/display/gimpdisplay-selection.c @@ -22,10 +22,11 @@ #include "core/core-types.h" +#include "base/boundary.h" + #include "core/gimpimage.h" #include "core/gimpimage-mask.h" -#include "boundary.h" #include "colormaps.h" #include "gdisplay.h" #include "gdisplay_ops.h" diff --git a/app/display/gimpdisplay.c b/app/display/gimpdisplay.c index fdfe7ace19..f86eff5f97 100644 --- a/app/display/gimpdisplay.c +++ b/app/display/gimpdisplay.c @@ -28,6 +28,8 @@ #include "core/core-types.h" #include "tools/tools-types.h" +#include "base/temp-buf.h" + #include "core/gimpchannel.h" #include "core/gimpcontainer.h" #include "core/gimpcontext.h" @@ -57,7 +59,6 @@ #include "qmask.h" #include "scale.h" #include "selection.h" -#include "temp_buf.h" #include "undo.h" #ifdef DISPLAY_FILTERS diff --git a/app/display/gimpdisplayshell-callbacks.c b/app/display/gimpdisplayshell-callbacks.c index 0bad0790c6..ab87f7d0cd 100644 --- a/app/display/gimpdisplayshell-callbacks.c +++ b/app/display/gimpdisplayshell-callbacks.c @@ -28,6 +28,10 @@ #include "core/core-types.h" #include "tools/tools-types.h" +#include "base/pixel-region.h" +#include "base/temp-buf.h" +#include "base/tile-manager.h" + #include "paint-funcs/paint-funcs.h" #include "core/gimpcontext.h" @@ -53,12 +57,9 @@ #include "drawable.h" #include "gimprc.h" #include "gimpui.h" -#include "pixel_region.h" #include "scale.h" #include "scroll.h" #include "selection.h" -#include "temp_buf.h" -#include "tile_manager.h" #include "undo.h" #include "libgimp/gimpintl.h" diff --git a/app/display/gimpdisplayshell-layer-select.c b/app/display/gimpdisplayshell-layer-select.c index 374d27c486..561a0f4296 100644 --- a/app/display/gimpdisplayshell-layer-select.c +++ b/app/display/gimpdisplayshell-layer-select.c @@ -33,7 +33,6 @@ #include "gdisplay.h" #include "gimprc.h" -#include "temp_buf.h" #include "libgimp/gimpintl.h" diff --git a/app/display/gimpdisplayshell-render.c b/app/display/gimpdisplayshell-render.c index 2a1cd4da67..da2608c6d1 100644 --- a/app/display/gimpdisplayshell-render.c +++ b/app/display/gimpdisplayshell-render.c @@ -25,6 +25,9 @@ #include "core/core-types.h" +#include "base/tile-manager.h" +#include "base/tile.h" + #include "core/gimpimage.h" #include "appenv.h" @@ -32,10 +35,7 @@ #include "gimprc.h" #include "gximage.h" #include "image_render.h" -#include "pixel_region.h" #include "scale.h" -#include "tile.h" -#include "tile_manager.h" #define MAX_PREVIEW_SIZE 256 /* EEK */ diff --git a/app/display/gimpdisplayshell-render.h b/app/display/gimpdisplayshell-render.h index 343224298a..7d8db7d629 100644 --- a/app/display/gimpdisplayshell-render.h +++ b/app/display/gimpdisplayshell-render.h @@ -19,7 +19,6 @@ #ifndef __IMAGE_RENDER_H__ #define __IMAGE_RENDER_H__ -#include "gimpchecks.h" /* Functions */ void render_setup (GimpCheckType check_type, diff --git a/app/display/gimpdisplayshell-selection.c b/app/display/gimpdisplayshell-selection.c index f5fae7004b..22732ce038 100644 --- a/app/display/gimpdisplayshell-selection.c +++ b/app/display/gimpdisplayshell-selection.c @@ -22,10 +22,11 @@ #include "core/core-types.h" +#include "base/boundary.h" + #include "core/gimpimage.h" #include "core/gimpimage-mask.h" -#include "boundary.h" #include "colormaps.h" #include "gdisplay.h" #include "gdisplay_ops.h" diff --git a/app/display/gimpnavigationeditor.c b/app/display/gimpnavigationeditor.c index 00210785e2..d015cec050 100644 --- a/app/display/gimpnavigationeditor.c +++ b/app/display/gimpnavigationeditor.c @@ -27,6 +27,8 @@ #include "core/core-types.h" +#include "base/temp-buf.h" + #include "core/gimpcontainer.h" #include "core/gimpcontext.h" #include "core/gimpimage.h" @@ -42,7 +44,6 @@ #include "gimprc.h" #include "scroll.h" #include "scale.h" -#include "temp_buf.h" #include "libgimp/gimpintl.h" diff --git a/app/display/gimpnavigationview.c b/app/display/gimpnavigationview.c index 00210785e2..d015cec050 100644 --- a/app/display/gimpnavigationview.c +++ b/app/display/gimpnavigationview.c @@ -27,6 +27,8 @@ #include "core/core-types.h" +#include "base/temp-buf.h" + #include "core/gimpcontainer.h" #include "core/gimpcontext.h" #include "core/gimpimage.h" @@ -42,7 +44,6 @@ #include "gimprc.h" #include "scroll.h" #include "scale.h" -#include "temp_buf.h" #include "libgimp/gimpintl.h" diff --git a/app/file-open.c b/app/file-open.c index 98efe53aae..a8e2ee2220 100644 --- a/app/file-open.c +++ b/app/file-open.c @@ -66,7 +66,6 @@ #include "file-open.h" #include "file-utils.h" #include "plug_in.h" -#include "temp_buf.h" #include "undo.h" #include "libgimp/gimpintl.h" diff --git a/app/file-save.c b/app/file-save.c index d87b2c6481..7ee11fbaf5 100644 --- a/app/file-save.c +++ b/app/file-save.c @@ -69,7 +69,6 @@ #include "file-save.h" #include "file-utils.h" #include "plug_in.h" -#include "temp_buf.h" #include "undo.h" #include "libgimp/gimpintl.h" diff --git a/app/file-utils.c b/app/file-utils.c index 5ba5996778..141fe2b4c2 100644 --- a/app/file-utils.c +++ b/app/file-utils.c @@ -44,11 +44,12 @@ #include "core/core-types.h" +#include "base/temp-buf.h" + #include "core/gimpimage.h" #include "file-utils.h" #include "plug_in.h" -#include "temp_buf.h" static PlugInProcDef * diff --git a/app/file/file-open.c b/app/file/file-open.c index 98efe53aae..a8e2ee2220 100644 --- a/app/file/file-open.c +++ b/app/file/file-open.c @@ -66,7 +66,6 @@ #include "file-open.h" #include "file-utils.h" #include "plug_in.h" -#include "temp_buf.h" #include "undo.h" #include "libgimp/gimpintl.h" diff --git a/app/file/file-save.c b/app/file/file-save.c index d87b2c6481..7ee11fbaf5 100644 --- a/app/file/file-save.c +++ b/app/file/file-save.c @@ -69,7 +69,6 @@ #include "file-save.h" #include "file-utils.h" #include "plug_in.h" -#include "temp_buf.h" #include "undo.h" #include "libgimp/gimpintl.h" diff --git a/app/file/file-utils.c b/app/file/file-utils.c index 5ba5996778..141fe2b4c2 100644 --- a/app/file/file-utils.c +++ b/app/file/file-utils.c @@ -44,11 +44,12 @@ #include "core/core-types.h" +#include "base/temp-buf.h" + #include "core/gimpimage.h" #include "file-utils.h" #include "plug_in.h" -#include "temp_buf.h" static PlugInProcDef * diff --git a/app/floating_sel.c b/app/floating_sel.c index 6c456e10d8..6dd2be2f6c 100644 --- a/app/floating_sel.c +++ b/app/floating_sel.c @@ -24,6 +24,10 @@ #include "core/core-types.h" +#include "base/boundary.h" +#include "base/pixel-region.h" +#include "base/tile-manager.h" + #include "paint-funcs/paint-funcs.h" #include "core/gimpimage.h" @@ -31,12 +35,9 @@ #include "core/gimplayer.h" #include "core/gimplayermask.h" -#include "boundary.h" #include "drawable.h" #include "floating_sel.h" #include "gdisplay.h" -#include "pixel_region.h" -#include "tile_manager.h" #include "undo.h" #include "libgimp/gimpintl.h" diff --git a/app/gdisplay.c b/app/gdisplay.c index fdfe7ace19..f86eff5f97 100644 --- a/app/gdisplay.c +++ b/app/gdisplay.c @@ -28,6 +28,8 @@ #include "core/core-types.h" #include "tools/tools-types.h" +#include "base/temp-buf.h" + #include "core/gimpchannel.h" #include "core/gimpcontainer.h" #include "core/gimpcontext.h" @@ -57,7 +59,6 @@ #include "qmask.h" #include "scale.h" #include "selection.h" -#include "temp_buf.h" #include "undo.h" #ifdef DISPLAY_FILTERS diff --git a/app/gimage.c b/app/gimage.c index e4476992e1..92a80ce4c1 100644 --- a/app/gimage.c +++ b/app/gimage.c @@ -23,8 +23,6 @@ #include "core/core-types.h" #include "tools/tools-types.h" -#include "paint-funcs/paint-funcs.h" - #include "core/gimpcontainer.h" #include "core/gimpimage.h" @@ -141,10 +139,8 @@ gimage_cmap_change_handler (GimpImage *gimage, gint ncol, gpointer user_data) { - gdisplays_update_full (gimage); - if (gimp_image_base_type (gimage) == INDEXED) - paint_funcs_invalidate_color_hash_table (gimage, ncol); + gdisplays_update_full (gimage); } static void diff --git a/app/gimpchecks.h b/app/gimpchecks.h deleted file mode 100644 index 45f55d7a55..0000000000 --- a/app/gimpchecks.h +++ /dev/null @@ -1,43 +0,0 @@ -/* The GIMP -- an image manipulation program - * Copyright (C) 1995-2001 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 2 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, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -#ifndef __GIMP_CHECKS_H__ -#define __GIMP_CHECKS_H__ - - -/* Transparency representation */ - -typedef enum -{ - LIGHT_CHECKS = 0, - GRAY_CHECKS = 1, - DARK_CHECKS = 2, - WHITE_ONLY = 3, - GRAY_ONLY = 4, - BLACK_ONLY = 5 -} GimpCheckType; - -typedef enum -{ - SMALL_CHECKS = 0, - MEDIUM_CHECKS = 1, - LARGE_CHECKS = 2 -} GimpCheckSize; - -#endif /* __GIMP_CHECKS_H__ */ - diff --git a/app/gimphistogram.c b/app/gimphistogram.c index 0dab16f1ed..e7e6668052 100644 --- a/app/gimphistogram.c +++ b/app/gimphistogram.c @@ -27,17 +27,17 @@ #include #include "libgimpmath/gimpmath.h" -#include "libgimpwidgets/gimpwidgets.h" #include "core/core-types.h" +#include "base/pixel-processor.h" +#include "base/pixel-region.h" + #include "core/gimpdrawable.h" #include "core/gimpimage.h" #include "gimphistogram.h" #include "gimprc.h" -#include "pixel_processor.h" -#include "pixel_region.h" struct _GimpHistogram diff --git a/app/gimplut.c b/app/gimplut.c deleted file mode 100644 index 7bca4744db..0000000000 --- a/app/gimplut.c +++ /dev/null @@ -1,262 +0,0 @@ -/* The GIMP -- an image manipulation program - * Copyright (C) 1995 Spencer Kimball and Peter Mattis - * - * gimplut.c: Copyright (C) 1999 Jay Cox - * - * 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 2 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, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -#include "config.h" - -#include - -#include - -#include "apptypes.h" - -#include "gimplut.h" -#include "pixel_region.h" - - -GimpLut * -gimp_lut_new (void) -{ - GimpLut *lut; - - lut = g_new (GimpLut, 1); - - lut->luts = NULL; - lut->nchannels = 0; - - return lut; -} - -void -gimp_lut_free (GimpLut *lut) -{ - gint i; - - for (i = 0; i < lut->nchannels; i++) - g_free (lut->luts[i]); - g_free (lut->luts); -} - -void -gimp_lut_setup (GimpLut *lut, - GimpLutFunc func, - void *user_data, - gint nchannels) -{ - gint i, v; - gdouble val; - - if (lut->luts) - { - for (i = 0; i < lut->nchannels; i++) - g_free (lut->luts[i]); - g_free (lut->luts); - } - lut->nchannels = nchannels; - lut->luts = g_new (guchar*, lut->nchannels); - - for (i = 0; i < lut->nchannels; i++) - { - lut->luts[i] = g_new (guchar, 256); - for (v = 0; v < 256; v++) - { /* to add gamma correction use func(v ^ g) ^ 1/g instead. */ - val = 255.0 * func (user_data, lut->nchannels, i, v/255.0) + 0.5; - if (val < 0.0) - lut->luts[i][v] = 0; - else if (val >= 255.0) - lut->luts[i][v] = 255; - else - lut->luts[i][v] = val; - } - } -} - -void -gimp_lut_setup_exact (GimpLut *lut, - GimpLutFunc func, - void *user_data, - gint nchannels) -{ - gimp_lut_setup (lut, func, user_data, nchannels); -} - -void -gimp_lut_process (GimpLut *lut, - PixelRegion *srcPR, - PixelRegion *destPR) -{ - gint h, width, src_r_i, dest_r_i; - guchar *src, *dest; - guchar *lut0 = NULL, *lut1 = NULL, *lut2 = NULL, *lut3 = NULL; - - if (lut->nchannels > 0) - lut0 = lut->luts[0]; - if (lut->nchannels > 1) - lut1 = lut->luts[1]; - if (lut->nchannels > 2) - lut2 = lut->luts[2]; - if (lut->nchannels > 3) - lut3 = lut->luts[3]; - - h = srcPR->h; - src = srcPR->data; - dest = destPR->data; - width = srcPR->w; - src_r_i = srcPR->rowstride - (srcPR->bytes * srcPR->w); - dest_r_i = destPR->rowstride - (destPR->bytes * srcPR->w); - - if (src_r_i == 0 && dest_r_i == 0) - { - width *= h; - h = 1; - } - - while (h--) - { - switch (lut->nchannels) - { - case 1: - while (width--) - { - *dest = lut0[*src]; - src++; - dest++; - } - break; - case 2: - while (width--) - { - dest[0] = lut0[src[0]]; - dest[1] = lut1[src[1]]; - src += 2; - dest += 2; - } - break; - case 3: - while (width--) - { - dest[0] = lut0[src[0]]; - dest[1] = lut1[src[1]]; - dest[2] = lut2[src[2]]; - src += 3; - dest += 3; - } - break; - case 4: - while (width--) - { - dest[0] = lut0[src[0]]; - dest[1] = lut1[src[1]]; - dest[2] = lut2[src[2]]; - dest[3] = lut3[src[3]]; - src += 4; - dest += 4; - } - break; - default: - g_warning ("gimplut: Error: nchannels = %d\n", lut->nchannels); - } - - width = srcPR->w; - src += src_r_i; - dest += dest_r_i; - } -} - -void -gimp_lut_process_inline (GimpLut *lut, - PixelRegion *srcPR) -{ - gint h, width, src_r_i; - guchar *src; - guchar *lut0 = NULL, *lut1 = NULL, *lut2 = NULL, *lut3 = NULL; - - if (lut->nchannels > 0) - lut0 = lut->luts[0]; - if (lut->nchannels > 1) - lut1 = lut->luts[1]; - if (lut->nchannels > 2) - lut2 = lut->luts[2]; - if (lut->nchannels > 3) - lut3 = lut->luts[3]; - - h = srcPR->h; - src = srcPR->data; - width = srcPR->w; - src_r_i = srcPR->rowstride - (srcPR->bytes * srcPR->w); - - if (src_r_i == 0) - { - width *= h; - h = 1; - } - - while (h--) - { - switch (lut->nchannels) - { - case 1: - while (width--) - { - *src = lut0[*src]; - src++; - } - break; - case 2: - while (width--) - { - src[0] = lut0[src[0]]; - src[1] = lut1[src[1]]; - src += 2; - } - break; - case 3: - while (width--) - { - src[0] = lut0[src[0]]; - src[1] = lut1[src[1]]; - src[2] = lut2[src[2]]; - src += 3; - } - break; - case 4: - while (width--) - { - src[0] = lut0[src[0]]; - src[1] = lut1[src[1]]; - src[2] = lut2[src[2]]; - src[3] = lut3[src[3]]; - src += 4; - } - break; - default: - g_warning ("gimplut: Error: nchannels = %d\n", lut->nchannels); - } - width = srcPR->w; - src += src_r_i; - } -} - -void -gimp_lut_process_2 (PixelRegion *srcPR, - PixelRegion *destPR, - GimpLut *lut) -{ - gimp_lut_process (lut, srcPR, destPR); -} diff --git a/app/gimplut.h b/app/gimplut.h deleted file mode 100644 index 24f31ccf2f..0000000000 --- a/app/gimplut.h +++ /dev/null @@ -1,76 +0,0 @@ -/* The GIMP -- an image manipulation program - * Copyright (C) 1995 Spencer Kimball and Peter Mattis - * - * gimplut.h: Copyright (C) 1999 Jay Cox - * - * 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 2 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, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -#ifndef __GIMP_LUT_H__ -#define __GIMP_LUT_H__ - - -struct _GimpLut -{ - guchar **luts; - gint nchannels; -}; - -/* TODO: the GimpLutFunc should really be passed the ColorModel of the region, - not just the number of channels */ -/* GimpLutFuncs should assume that the input and output gamma are 1.0 - and do no correction as this will be handled by gimp_lut_setup */ -typedef gfloat (*GimpLutFunc) (gpointer user_data, - gint nchannels, - gint channel, - gfloat value); - -GimpLut * gimp_lut_new (void); -void gimp_lut_free (GimpLut *lut); - -void gimp_lut_setup (GimpLut *lut, - GimpLutFunc func, - gpointer user_data, - gint nchannels); - -/* gimp_lut_setup_exact is currently identical to gimp_lut_setup. It - however is guaranteed to never perform any interpolation or gamma - correction on the lut */ -void gimp_lut_setup_exact (GimpLut *lut, - GimpLutFunc func, - gpointer user_data, - gint nchannels); - -void gimp_lut_process (GimpLut *lut, - PixelRegion *srcPR, - PixelRegion *destPR); - -/* gimp_lut_process_inline is like gimp_lut_process except it uses a - single PixelRegion as both the source and destination */ -void gimp_lut_process_inline (GimpLut *lut, - PixelRegion *src_destPR); - -/* gimp_lut_process_2 is the same as gimp_lut_process but the lut - perameter is last instead of first. this is necesary because - pixel_region_process_paralell sends the user_data as the 1st - parameter, and the image_map functions send user_data as the last - parameter */ -void gimp_lut_process_2 (PixelRegion *srcPR, - PixelRegion *destPR, - GimpLut *lut); - - -#endif /* __GIMP_LUT_H__ */ - diff --git a/app/gimppreviewcache.c b/app/gimppreviewcache.c index 08e6b90954..642e5f5914 100644 --- a/app/gimppreviewcache.c +++ b/app/gimppreviewcache.c @@ -18,9 +18,11 @@ #include "config.h" -#include +#include -#include "apptypes.h" +#include "base/base-types.h" + +#include "base/temp-buf.h" #include "gimppreviewcache.h" diff --git a/app/gimppreviewcache.h b/app/gimppreviewcache.h index 17e5e3e0c5..7e84d7806b 100644 --- a/app/gimppreviewcache.h +++ b/app/gimppreviewcache.h @@ -20,9 +20,6 @@ #define __GIMPPREVIEWCACHE_H__ -#include "temp_buf.h" - - #define PREVIEW_CACHE_PRIME_WIDTH 112 #define PREVIEW_CACHE_PRIME_HEIGHT 112 diff --git a/app/gimprc.c b/app/gimprc.c index 41a959b362..737747cf58 100644 --- a/app/gimprc.c +++ b/app/gimprc.c @@ -389,7 +389,7 @@ gimp_system_rc_file (void) } gboolean -parse_buffers_init (void) +gimprc_init (void) { if (!parse_info.buffer) { diff --git a/app/gimprc.h b/app/gimprc.h index 46dba84adc..d125fef6a9 100644 --- a/app/gimprc.h +++ b/app/gimprc.h @@ -22,8 +22,6 @@ /* global gimprc variables */ extern gchar *plug_in_path; -extern gchar *temp_path; -extern gchar *swap_path; extern gchar *brush_path; extern gchar *default_brush; extern gchar *pattern_path; @@ -34,7 +32,6 @@ extern gchar *gradient_path; extern gchar *default_gradient; extern gchar *pluginrc_path; extern gchar *module_path; -extern guint tile_cache_size; extern gint marching_speed; extern gint last_opened_size; extern gdouble gamma_val; @@ -46,7 +43,6 @@ extern gint min_colors; extern gboolean install_cmap; extern gboolean cycled_marching_ants; extern gint default_threshold; -extern gboolean stingy_memory_use; extern gboolean allow_resize_windows; extern gboolean no_cursor_updating; extern gint preview_size; @@ -55,7 +51,6 @@ extern gboolean show_rulers; extern GimpUnit default_units; extern gboolean show_statusbar; extern gboolean auto_save; -extern InterpolationType interpolation_type; extern gboolean confirm_on_close; extern gint default_width, default_height; extern gint default_type; @@ -89,7 +84,7 @@ extern gint cursor_mode; extern gboolean disable_tearoff_menus; /* function prototypes */ -gboolean parse_buffers_init (void); /* this has to be called before any file +gboolean gimprc_init (void); /* this has to be called before any file * is parsed */ void parse_gimprc (void); diff --git a/app/global_edit.c b/app/global_edit.c index 4f95336cc9..48514dee88 100644 --- a/app/global_edit.c +++ b/app/global_edit.c @@ -27,6 +27,9 @@ #include "core/core-types.h" #include "tools/tools-types.h" +#include "base/pixel-region.h" +#include "base/tile-manager.h" + #include "paint-funcs/paint-funcs.h" #include "core/gimpchannel.h" @@ -44,8 +47,6 @@ #include "gimage.h" #include "global_edit.h" #include "image_new.h" -#include "pixel_region.h" -#include "tile_manager.h" #include "undo.h" #include "libgimp/gimpintl.h" diff --git a/app/gui/brush-editor.c b/app/gui/brush-editor.c index 65b86266d7..60a6283322 100644 --- a/app/gui/brush-editor.c +++ b/app/gui/brush-editor.c @@ -30,12 +30,12 @@ #include "core/core-types.h" +#include "base/temp-buf.h" + #include "core/gimpbrushgenerated.h" #include "brush-editor.h" -#include "temp_buf.h" - #include "libgimp/gimpintl.h" diff --git a/app/gui/brush-select.c b/app/gui/brush-select.c index fc1ba6238c..25f34d0b9e 100644 --- a/app/gui/brush-select.c +++ b/app/gui/brush-select.c @@ -24,9 +24,10 @@ #include "libgimpwidgets/gimpwidgets.h" -#include "apptypes.h" #include "widgets/widgets-types.h" +#include "base/temp-buf.h" + #include "core/gimpbrushgenerated.h" #include "core/gimpcontainer.h" #include "core/gimpcontext.h" @@ -45,7 +46,6 @@ #include "context_manager.h" #include "dialog_handler.h" #include "gimprc.h" -#include "temp_buf.h" #include "libgimp/gimpintl.h" diff --git a/app/gui/file-open-dialog.c b/app/gui/file-open-dialog.c index 3424006a9a..1654a7e1ad 100644 --- a/app/gui/file-open-dialog.c +++ b/app/gui/file-open-dialog.c @@ -40,6 +40,8 @@ #include "core/core-types.h" +#include "base/temp-buf.h" + #include "core/gimpcontext.h" #include "core/gimpimage.h" @@ -57,7 +59,6 @@ #include "file-open.h" #include "file-utils.h" #include "plug_in.h" -#include "temp_buf.h" #include "undo.h" #include "libgimp/gimpintl.h" diff --git a/app/gui/file-save-dialog.c b/app/gui/file-save-dialog.c index 492b1b6c66..9cbce6d198 100644 --- a/app/gui/file-save-dialog.c +++ b/app/gui/file-save-dialog.c @@ -49,7 +49,6 @@ #include "file-save.h" #include "file-utils.h" #include "plug_in.h" -#include "temp_buf.h" #include "undo.h" #include "libgimp/gimpintl.h" diff --git a/app/gui/layer-select.c b/app/gui/layer-select.c index 374d27c486..561a0f4296 100644 --- a/app/gui/layer-select.c +++ b/app/gui/layer-select.c @@ -33,7 +33,6 @@ #include "gdisplay.h" #include "gimprc.h" -#include "temp_buf.h" #include "libgimp/gimpintl.h" diff --git a/app/gui/palette-import-dialog.c b/app/gui/palette-import-dialog.c index 3528e042dd..c8978c5d47 100644 --- a/app/gui/palette-import-dialog.c +++ b/app/gui/palette-import-dialog.c @@ -27,6 +27,8 @@ #include "core/core-types.h" +#include "base/temp-buf.h" + #include "core/gimpcontainer.h" #include "core/gimpcontext.h" #include "core/gimpdatafactory.h" @@ -41,7 +43,6 @@ #include "context_manager.h" #include "gimage.h" -#include "temp_buf.h" #include "libgimp/gimpintl.h" diff --git a/app/gui/pattern-select.c b/app/gui/pattern-select.c index 280421db9e..baebbb3c3c 100644 --- a/app/gui/pattern-select.c +++ b/app/gui/pattern-select.c @@ -27,6 +27,8 @@ #include "apptypes.h" #include "widgets/widgets-types.h" +#include "base/temp-buf.h" + #include "core/gimpcontainer.h" #include "core/gimpcontext.h" #include "core/gimpdatafactory.h" @@ -41,7 +43,6 @@ #include "appenv.h" #include "context_manager.h" -#include "temp_buf.h" #include "libgimp/gimpintl.h" diff --git a/app/gui/plug-in-commands.c b/app/gui/plug-in-commands.c index 2b9b8afa01..37a596f9d2 100644 --- a/app/gui/plug-in-commands.c +++ b/app/gui/plug-in-commands.c @@ -85,6 +85,9 @@ #include "libgimp/gimpprotocol.h" #include "libgimp/gimpwire.h" +#include "base/tile.h" +#include "base/tile-manager.h" + #include "core/gimpdrawable.h" #include "core/gimpimage.h" @@ -102,8 +105,6 @@ #include "gimpprogress.h" #include "gimprc.h" #include "plug_in.h" -#include "tile.h" -#include "tile_manager.h" #include "libgimp/gimpintl.h" diff --git a/app/gui/plug-in-menus.c b/app/gui/plug-in-menus.c index 2b9b8afa01..37a596f9d2 100644 --- a/app/gui/plug-in-menus.c +++ b/app/gui/plug-in-menus.c @@ -85,6 +85,9 @@ #include "libgimp/gimpprotocol.h" #include "libgimp/gimpwire.h" +#include "base/tile.h" +#include "base/tile-manager.h" + #include "core/gimpdrawable.h" #include "core/gimpimage.h" @@ -102,8 +105,6 @@ #include "gimpprogress.h" #include "gimprc.h" #include "plug_in.h" -#include "tile.h" -#include "tile_manager.h" #include "libgimp/gimpintl.h" diff --git a/app/gui/preferences-dialog.c b/app/gui/preferences-dialog.c index cdb6c9e6de..ad7f1ffc95 100644 --- a/app/gui/preferences-dialog.c +++ b/app/gui/preferences-dialog.c @@ -28,6 +28,9 @@ #include "core/core-types.h" +#include "base/base-config.h" +#include "base/tile-cache.h" + #include "core/gimpcontainer.h" #include "core/gimpimage.h" @@ -42,7 +45,6 @@ #include "gimprc.h" #include "image_render.h" #include "resolution_calibrate.h" -#include "tile_cache.h" #include "libgimp/gimpintl.h" @@ -440,7 +442,7 @@ prefs_ok_callback (GtkWidget *widget, if (edit_tile_cache_size != old_tile_cache_size) { - tile_cache_size = edit_tile_cache_size; + base_config->tile_cache_size = edit_tile_cache_size; tile_cache_set_size (edit_tile_cache_size); } break; @@ -513,7 +515,7 @@ prefs_save_callback (GtkWidget *widget, prefs_dlg = NULL; /* Save variables so that we can restore them later */ - save_stingy_memory_use = stingy_memory_use; + save_stingy_memory_use = base_config->stingy_memory_use; save_min_colors = min_colors; save_install_cmap = install_cmap; save_cycled_marching_ants = cycled_marching_ants; @@ -522,8 +524,8 @@ prefs_save_callback (GtkWidget *widget, save_nav_window_per_display = nav_window_per_display; save_info_window_follows_mouse = info_window_follows_mouse; - save_temp_path = temp_path; - save_swap_path = swap_path; + save_temp_path = base_config->temp_path; + save_swap_path = base_config->swap_path; save_brush_path = brush_path; save_pattern_path = pattern_path; save_palette_path = palette_path; @@ -569,7 +571,7 @@ prefs_save_callback (GtkWidget *widget, update = g_list_append (update, "show-statusbar"); remove = g_list_append (remove, "dont-show-statusbar"); } - if (interpolation_type != old_interpolation_type) + if (base_config->interpolation_type != old_interpolation_type) { update = g_list_append (update, "interpolation-type"); } @@ -710,7 +712,7 @@ prefs_save_callback (GtkWidget *widget, /* values which can't be changed on the fly */ if (edit_stingy_memory_use != old_stingy_memory_use) { - stingy_memory_use = edit_stingy_memory_use; + base_config->stingy_memory_use = edit_stingy_memory_use; update = g_list_append (update, "stingy-memory-use"); } if (edit_min_colors != old_min_colors) @@ -759,12 +761,12 @@ prefs_save_callback (GtkWidget *widget, if (prefs_strcmp (old_temp_path, edit_temp_path)) { - temp_path = edit_temp_path; + base_config->temp_path = edit_temp_path; update = g_list_append (update, "temp-path"); } if (prefs_strcmp (old_swap_path, edit_swap_path)) { - swap_path = edit_swap_path; + base_config->swap_path = edit_swap_path; update = g_list_append (update, "swap-path"); } if (prefs_strcmp (old_brush_path, edit_brush_path)) @@ -801,7 +803,7 @@ prefs_save_callback (GtkWidget *widget, /* values which are changed on "OK" or "Save" */ if (edit_tile_cache_size != old_tile_cache_size) { - tile_cache_size = edit_tile_cache_size; + base_config->tile_cache_size = edit_tile_cache_size; update = g_list_append (update, "tile-cache-size"); } @@ -813,23 +815,23 @@ prefs_save_callback (GtkWidget *widget, gdisplay_xserver_resolution (&monitor_xres, &monitor_yres); /* restore variables which must not change */ - stingy_memory_use = save_stingy_memory_use; - min_colors = save_min_colors; - install_cmap = save_install_cmap; - cycled_marching_ants = save_cycled_marching_ants; - last_opened_size = save_last_opened_size; - show_indicators = save_show_indicators; - nav_window_per_display = save_nav_window_per_display; - info_window_follows_mouse = save_info_window_follows_mouse; + base_config->stingy_memory_use = save_stingy_memory_use; + min_colors = save_min_colors; + install_cmap = save_install_cmap; + cycled_marching_ants = save_cycled_marching_ants; + last_opened_size = save_last_opened_size; + show_indicators = save_show_indicators; + nav_window_per_display = save_nav_window_per_display; + info_window_follows_mouse = save_info_window_follows_mouse; - temp_path = save_temp_path; - swap_path = save_swap_path; - brush_path = save_brush_path; - pattern_path = save_pattern_path; - palette_path = save_palette_path; - gradient_path = save_gradient_path; - plug_in_path = save_plug_in_path; - module_path = save_module_path; + base_config->temp_path = save_temp_path; + base_config->swap_path = save_swap_path; + brush_path = save_brush_path; + pattern_path = save_pattern_path; + palette_path = save_palette_path; + gradient_path = save_gradient_path; + plug_in_path = save_plug_in_path; + module_path = save_module_path; /* no need to restore values which are only changed on "OK" and "Save" */ @@ -845,6 +847,7 @@ prefs_cancel_callback (GtkWidget *widget, prefs_dlg = NULL; /* restore ordinary gimprc variables */ + base_config->interpolation_type = old_interpolation_type; levels_of_undo = old_levels_of_undo; marching_speed = old_marching_speed; allow_resize_windows = old_allow_resize_windows; @@ -854,7 +857,6 @@ prefs_cancel_callback (GtkWidget *widget, show_tool_tips = old_show_tool_tips; show_rulers = old_show_rulers; show_statusbar = old_show_statusbar; - interpolation_type = old_interpolation_type; confirm_on_close = old_confirm_on_close; save_session_info = old_save_session_info; save_device_status = old_save_device_status; @@ -969,11 +971,11 @@ prefs_toggle_callback (GtkWidget *widget, } /* radio buttons */ - else if (data == &thumbnail_mode || - data == &interpolation_type || - data == &trust_dirty_flag || - data == &help_browser || - data == &cursor_mode || + else if (data == &thumbnail_mode || + data == &base_config->interpolation_type || + data == &trust_dirty_flag || + data == &help_browser || + data == &cursor_mode || data == &default_type) { *val = (gint) gtk_object_get_user_data (GTK_OBJECT (widget)); @@ -1389,7 +1391,7 @@ preferences_dialog_create (void) /* first time dialog is opened - * copy config vals to edit variables. */ - edit_stingy_memory_use = stingy_memory_use; + edit_stingy_memory_use = base_config->stingy_memory_use; edit_min_colors = min_colors; edit_install_cmap = install_cmap; edit_cycled_marching_ants = cycled_marching_ants; @@ -1399,8 +1401,8 @@ preferences_dialog_create (void) edit_info_window_follows_mouse = info_window_follows_mouse; edit_disable_tearoff_menus = disable_tearoff_menus; - edit_temp_path = prefs_strdup (temp_path); - edit_swap_path = prefs_strdup (swap_path); + edit_temp_path = prefs_strdup (base_config->temp_path); + edit_swap_path = prefs_strdup (base_config->swap_path); edit_plug_in_path = prefs_strdup (plug_in_path); edit_module_path = prefs_strdup (module_path); edit_brush_path = prefs_strdup (brush_path); @@ -1412,9 +1414,10 @@ preferences_dialog_create (void) /* assign edit variables for values which get changed on "OK" and "Save" * but not on the fly. */ - edit_tile_cache_size = tile_cache_size; + edit_tile_cache_size = base_config->tile_cache_size; /* remember all old values */ + old_interpolation_type = base_config->interpolation_type; old_perfectmouse = perfectmouse; old_transparency_type = transparency_type; old_transparency_size = transparency_size; @@ -1428,7 +1431,6 @@ preferences_dialog_create (void) old_show_tool_tips = show_tool_tips; old_show_rulers = show_rulers; old_show_statusbar = show_statusbar; - old_interpolation_type = interpolation_type; old_confirm_on_close = confirm_on_close; old_save_session_info = save_session_info; old_save_device_status = save_device_status; @@ -2266,7 +2268,8 @@ preferences_dialog_create (void) optionmenu = gimp_option_menu_new2 (FALSE, prefs_toggle_callback, - &interpolation_type, (gpointer) interpolation_type, + &base_config->interpolation_type, + (gpointer) base_config->interpolation_type, _("Nearest Neighbor (Fast)"), (gpointer) NEAREST_NEIGHBOR_INTERPOLATION, NULL, diff --git a/app/gui/toolbox.c b/app/gui/toolbox.c index 4336eb07b2..c4d5400003 100644 --- a/app/gui/toolbox.c +++ b/app/gui/toolbox.c @@ -28,6 +28,9 @@ #include "tools/tools-types.h" #include "widgets/widgets-types.h" +#include "base/pixel-region.h" +#include "base/tile-manager.h" + #include "paint-funcs/paint-funcs.h" #include "core/gimpcontext.h" @@ -56,8 +59,6 @@ #include "app_procs.h" #include "gimage.h" #include "gimprc.h" -#include "pixel_region.h" -#include "tile_manager.h" #include "libgimp/gimpintl.h" diff --git a/app/gui/user-install-dialog.c b/app/gui/user-install-dialog.c index 21ce3064e9..90e0231ac4 100644 --- a/app/gui/user-install-dialog.c +++ b/app/gui/user-install-dialog.c @@ -35,6 +35,8 @@ #include "core/core-types.h" +#include "base/base-config.h" + #include "appenv.h" #include "gdisplay_ops.h" #include "gimprc.h" @@ -381,7 +383,7 @@ user_install_continue_callback (GtkWidget *widget, #ifdef G_OS_WIN32 FreeConsole (); #endif - parse_buffers_init (); + gimprc_init (); parse_unitrc (); parse_gimprc (); user_install_tuning (); @@ -896,7 +898,7 @@ user_install_dialog_create (UserInstallCallback callback) #ifdef G_OS_WIN32 -char * +static char * quote_spaces (char *string) { int nspaces = 0; @@ -1106,7 +1108,7 @@ user_install_tuning (void) gtk_box_pack_start (GTK_BOX (tuning_page), hbox, FALSE, FALSE, 0); gtk_widget_show (hbox); - tile_cache_adj = gtk_adjustment_new (tile_cache_size, + tile_cache_adj = gtk_adjustment_new (base_config->tile_cache_size, 0, (4069.0 * 1024 * 1024), 1.0, 1.0, 0.0); memsize = gimp_mem_size_entry_new (GTK_ADJUSTMENT (tile_cache_adj)); gtk_box_pack_end (GTK_BOX (hbox), memsize, FALSE, FALSE, 0); @@ -1132,7 +1134,8 @@ user_install_tuning (void) gtk_box_pack_start (GTK_BOX (tuning_page), hbox, FALSE, FALSE, 0); gtk_widget_show (hbox); - swap_path_filesel = gimp_file_selection_new (_("Select Swap Dir"), swap_path, + swap_path_filesel = gimp_file_selection_new (_("Select Swap Dir"), + base_config->swap_path, TRUE, TRUE); gtk_box_pack_end (GTK_BOX (hbox), swap_path_filesel, FALSE, FALSE, 0); gtk_widget_show (swap_path_filesel); @@ -1291,15 +1294,16 @@ user_install_resolution_done (void) new_monitor_yres = gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (resolution_entry), 1); - if (tile_cache_size != new_tile_cache_size) + if (base_config->tile_cache_size != new_tile_cache_size) { - tile_cache_size = new_tile_cache_size; + base_config->tile_cache_size = new_tile_cache_size; update = g_list_append (update, "tile-cache-size"); } - if (swap_path && new_swap_path && - strcmp (swap_path, new_swap_path)) + if (base_config->swap_path && new_swap_path && + strcmp (base_config->swap_path, new_swap_path)) { - g_free (swap_path); swap_path = new_swap_path; + g_free (base_config->swap_path); + base_config->swap_path = new_swap_path; update = g_list_append (update, "swap-path"); } if (using_xserver_resolution != new_using_xserver_resolution || diff --git a/app/image_map.c b/app/image_map.c index 130eb9fda8..0130af5851 100644 --- a/app/image_map.c +++ b/app/image_map.c @@ -22,6 +22,10 @@ #include "core/core-types.h" +#include "base/pixel-region.h" +#include "base/tile-manager.h" +#include "base/tile.h" + #include "paint-funcs/paint-funcs.h" #include "core/gimpdrawable.h" @@ -30,9 +34,6 @@ #include "drawable.h" #include "gdisplay.h" #include "image_map.h" -#include "pixel_region.h" -#include "tile.h" -#include "tile_manager.h" #define WAITING 0 diff --git a/app/image_new.c b/app/image_new.c index 96535cd068..b1a0548919 100644 --- a/app/image_new.c +++ b/app/image_new.c @@ -26,6 +26,8 @@ #include "libgimp/gimpparasite.h" +#include "base/tile-manager.h" + #include "paint-funcs/paint-funcs.h" #include "core/gimpcontext.h" @@ -40,7 +42,6 @@ #include "gimage.h" #include "gimprc.h" #include "image_new.h" -#include "tile_manager.h" #include "libgimp/gimpintl.h" diff --git a/app/image_render.c b/app/image_render.c index 2a1cd4da67..da2608c6d1 100644 --- a/app/image_render.c +++ b/app/image_render.c @@ -25,6 +25,9 @@ #include "core/core-types.h" +#include "base/tile-manager.h" +#include "base/tile.h" + #include "core/gimpimage.h" #include "appenv.h" @@ -32,10 +35,7 @@ #include "gimprc.h" #include "gximage.h" #include "image_render.h" -#include "pixel_region.h" #include "scale.h" -#include "tile.h" -#include "tile_manager.h" #define MAX_PREVIEW_SIZE 256 /* EEK */ diff --git a/app/image_render.h b/app/image_render.h index 343224298a..7d8db7d629 100644 --- a/app/image_render.h +++ b/app/image_render.h @@ -19,7 +19,6 @@ #ifndef __IMAGE_RENDER_H__ #define __IMAGE_RENDER_H__ -#include "gimpchecks.h" /* Functions */ void render_setup (GimpCheckType check_type, diff --git a/app/lut_funcs.c b/app/lut_funcs.c index 0a5d07704a..3a101ec8ad 100644 --- a/app/lut_funcs.c +++ b/app/lut_funcs.c @@ -26,7 +26,8 @@ #include "core/core-types.h" -#include "gimplut.h" +#include "base/gimplut.h" + #include "gimphistogram.h" diff --git a/app/main.c b/app/main.c index 5b0069135f..4463d72692 100644 --- a/app/main.c +++ b/app/main.c @@ -362,7 +362,11 @@ main (int argc, G_LOG_LEVEL_MESSAGE, gimp_message_func, NULL); - g_log_set_handler ("Gimp-GUI", + g_log_set_handler ("Gimp-Base", + G_LOG_LEVEL_MESSAGE, + gimp_message_func, + NULL); + g_log_set_handler ("Gimp-Core", G_LOG_LEVEL_MESSAGE, gimp_message_func, NULL); @@ -370,11 +374,15 @@ main (int argc, G_LOG_LEVEL_MESSAGE, gimp_message_func, NULL); + g_log_set_handler ("Gimp-Widgets", + G_LOG_LEVEL_MESSAGE, + gimp_message_func, + NULL); g_log_set_handler ("Gimp-Tools", G_LOG_LEVEL_MESSAGE, gimp_message_func, NULL); - g_log_set_handler ("Gimp-Widgets", + g_log_set_handler ("Gimp-GUI", G_LOG_LEVEL_MESSAGE, gimp_message_func, NULL); diff --git a/app/menus/plug-in-menus.c b/app/menus/plug-in-menus.c index 2b9b8afa01..37a596f9d2 100644 --- a/app/menus/plug-in-menus.c +++ b/app/menus/plug-in-menus.c @@ -85,6 +85,9 @@ #include "libgimp/gimpprotocol.h" #include "libgimp/gimpwire.h" +#include "base/tile.h" +#include "base/tile-manager.h" + #include "core/gimpdrawable.h" #include "core/gimpimage.h" @@ -102,8 +105,6 @@ #include "gimpprogress.h" #include "gimprc.h" #include "plug_in.h" -#include "tile.h" -#include "tile_manager.h" #include "libgimp/gimpintl.h" diff --git a/app/nav_window.c b/app/nav_window.c index 00210785e2..d015cec050 100644 --- a/app/nav_window.c +++ b/app/nav_window.c @@ -27,6 +27,8 @@ #include "core/core-types.h" +#include "base/temp-buf.h" + #include "core/gimpcontainer.h" #include "core/gimpcontext.h" #include "core/gimpimage.h" @@ -42,7 +44,6 @@ #include "gimprc.h" #include "scroll.h" #include "scale.h" -#include "temp_buf.h" #include "libgimp/gimpintl.h" diff --git a/app/paint-funcs/Makefile.am b/app/paint-funcs/Makefile.am index ed9977aa7e..d24b4b6979 100644 --- a/app/paint-funcs/Makefile.am +++ b/app/paint-funcs/Makefile.am @@ -20,7 +20,7 @@ AM_CPPFLAGS = \ INCLUDES = \ -I$(top_srcdir) \ -I$(top_srcdir)/app \ - $(GTK_CFLAGS) \ + $(GLIB_CFLAGS) \ -I$(includedir) .PHONY: files diff --git a/app/paint-funcs/paint-funcs.c b/app/paint-funcs/paint-funcs.c index 71b2a717f6..0acda32e44 100644 --- a/app/paint-funcs/paint-funcs.c +++ b/app/paint-funcs/paint-funcs.c @@ -27,20 +27,18 @@ #include "libgimpcolor/gimpcolor.h" #include "libgimpmath/gimpmath.h" -#include "core/core-types.h" +#include "base/base-types.h" + +#include "base/base-config.h" +#include "base/pixel-processor.h" +#include "base/pixel-region.h" +#include "base/tile-manager.h" +#include "base/tile.h" #include "paint-funcs.h" -#include "gimprc.h" -#include "pixel_processor.h" -#include "pixel_region.h" -#include "tile_manager.h" -#include "tile.h" - #define STD_BUF_SIZE 1021 -#define MAXDIFF 195076 -#define HASH_TABLE_SIZE 1021 #define RANDOM_TABLE_SIZE 4096 #define RANDOM_SEED 314159265 #define EPSILON 0.0001 @@ -108,20 +106,8 @@ static const LayerMode layer_modes[] = { TRUE, FALSE, TRUE, } /* ANTI_ERASE_MODE */ }; -/* ColorHash structure */ -typedef struct _ColorHash ColorHash; -struct _ColorHash -{ - gint pixel; /* R << 16 | G << 8 | B */ - gint index; /* colormap index */ - GimpImage *gimage; -}; - -static ColorHash color_hash_table[HASH_TABLE_SIZE]; static gint random_table[RANDOM_TABLE_SIZE]; -static gint color_hash_misses; -static gint color_hash_hits; static guchar *tmp_buffer; /* temporary buffer available upon request */ static gint tmp_buffer_size; static guchar no_mask = OPAQUE_OPACITY; @@ -493,12 +479,6 @@ paint_funcs_setup (void) tmp_buffer = g_new (guchar, STD_BUF_SIZE); tmp_buffer_size = STD_BUF_SIZE; - /* initialize the color hash table--invalidate all entries */ - for (i = 0; i < HASH_TABLE_SIZE; i++) - color_hash_table[i].gimage = NULL; - color_hash_misses = 0; - color_hash_hits = 0; - /* generate a table of random seeds */ srand (RANDOM_SEED); @@ -548,30 +528,6 @@ paint_funcs_free (void) */ } -void -paint_funcs_invalidate_color_hash_table (GimpImage* gimage, - gint index) -{ - gint i; - - g_return_if_fail (gimage != NULL); - - if (index == -1) /* invalidate all entries */ - { - for (i = 0; i < HASH_TABLE_SIZE; i++) - if (color_hash_table[i].gimage == gimage) - color_hash_table[i].gimage = NULL; - } - else - { - for (i = 0; i < HASH_TABLE_SIZE; i++) - if (color_hash_table[i].gimage == gimage && - color_hash_table[i].index == index) - color_hash_table[i].gimage = NULL; - } -} - - void color_pixels (guchar *dest, const guchar *color, @@ -3383,67 +3339,6 @@ map_to_color (gint src_type, } -gint -map_rgb_to_indexed (const guchar *cmap, - gint num_cols, - const GimpImage *gimage, - gint r, - gint g, - gint b) -{ - guint pixel; - gint hash_index; - gint cmap_index; - - pixel = (r << 16) | (g << 8) | b; - hash_index = pixel % HASH_TABLE_SIZE; - - /* Hash table lookup hit */ - if (color_hash_table[hash_index].gimage == gimage && - color_hash_table[hash_index].pixel == pixel) - { - cmap_index = color_hash_table[hash_index].index; - color_hash_hits++; - } - /* Hash table lookup miss */ - else - { - const guchar *col; - gint diff, sum, max; - gint i; - - max = MAXDIFF; - cmap_index = 0; - - col = cmap; - for (i = 0; i < num_cols; i++) - { - diff = r - *col++; - sum = diff * diff; - diff = g - *col++; - sum += diff * diff; - diff = b - *col++; - sum += diff * diff; - - if (sum < max) - { - cmap_index = i; - max = sum; - } - } - - /* update the hash table */ - color_hash_table[hash_index].pixel = pixel; - color_hash_table[hash_index].index = cmap_index; - color_hash_table[hash_index].gimage = (GimpImage *) gimage; - color_hash_misses++; - } - - return cmap_index; -} - - - /**************************************************/ /* REGION FUNCTIONS */ /**************************************************/ @@ -4324,10 +4219,10 @@ get_scaled_row (void **src, row, src_tmp, 1); if (new_width > srcPR->w) expand_line(src[3], row, srcPR->bytes, - srcPR->w, new_width, interpolation_type); + srcPR->w, new_width, base_config->interpolation_type); else if (srcPR->w > new_width) shrink_line(src[3], row, srcPR->bytes, - srcPR->w, new_width, interpolation_type); + srcPR->w, new_width, base_config->interpolation_type); else /* no scailing needed */ memcpy(src[3], row, sizeof (double) * new_width * srcPR->bytes); } @@ -4350,7 +4245,7 @@ scale_region (PixelRegion *srcPR, gint old_y = -4, new_y; gint x, y; - if (interpolation_type == NEAREST_NEIGHBOR_INTERPOLATION) + if (base_config->interpolation_type == NEAREST_NEIGHBOR_INTERPOLATION) { scale_region_no_resample (srcPR, destPR); return; @@ -4433,7 +4328,7 @@ scale_region (PixelRegion *srcPR, src_tmp); old_y++; } - switch(interpolation_type) + switch(base_config->interpolation_type) { case CUBIC_INTERPOLATION: { diff --git a/app/paint-funcs/paint-funcs.h b/app/paint-funcs/paint-funcs.h index 549e0e87ad..ea9b4d3bd7 100644 --- a/app/paint-funcs/paint-funcs.h +++ b/app/paint-funcs/paint-funcs.h @@ -29,8 +29,6 @@ void paint_funcs_setup (void); void paint_funcs_free (void); -void paint_funcs_invalidate_color_hash_table (GimpImage* gimage, - gint index); /* Paint functions */ @@ -415,15 +413,15 @@ void extract_from_inten_pixels (unsigned char *src, /* extract information from indexed pixels based on * a mask. */ -void extract_from_indexed_pixels (unsigned char *src, - unsigned char *dest, - const unsigned char *mask, - const unsigned char *cmap, - const unsigned char *bg, - int cut, - int length, - int bytes, - int has_alpha); +void extract_from_indexed_pixels (unsigned char *src, + unsigned char *dest, + const unsigned char *mask, + const unsigned char *cmap, + const unsigned char *bg, + int cut, + int length, + int bytes, + int has_alpha); /* variable source to RGB color mapping @@ -431,26 +429,11 @@ void extract_from_indexed_pixels (unsigned char *src, * src_type == 1 (GRAY) * src_type == 2 (INDEXED) */ -void -map_to_color (int src_type, +void map_to_color (int src_type, const unsigned char *cmap, const unsigned char *src, unsigned char *rgb); - -/* RGB to index mapping functions... - * - * Hash table lookup speeds up the standard - * least squares method - */ -gint map_rgb_to_indexed (const guchar *cmap, - gint num_cols, - const GimpImage *gimage, - gint r, - gint g, - gint b); - - /* Region functions */ void color_region (PixelRegion *dest, const unsigned char *color); diff --git a/app/paint/gimpairbrush.c b/app/paint/gimpairbrush.c index 998c77fcdc..a6a514856d 100644 --- a/app/paint/gimpairbrush.c +++ b/app/paint/gimpairbrush.c @@ -25,6 +25,8 @@ #include "tools-types.h" +#include "base/temp-buf.h" + #include "paint-funcs/paint-funcs.h" #include "core/gimpbrush.h" @@ -36,7 +38,6 @@ #include "drawable.h" #include "gdisplay.h" #include "selection.h" -#include "temp_buf.h" #include "gimpairbrushtool.h" #include "paint_options.h" diff --git a/app/paint/gimpclone.c b/app/paint/gimpclone.c index eee8e9d7cf..f7061c020b 100644 --- a/app/paint/gimpclone.c +++ b/app/paint/gimpclone.c @@ -27,6 +27,9 @@ #include "tools-types.h" +#include "base/pixel-region.h" +#include "base/temp-buf.h" + #include "paint-funcs/paint-funcs.h" #include "core/gimpdrawable.h" @@ -43,11 +46,8 @@ #include "drawable.h" #include "gdisplay.h" -#include "gimplut.h" #include "gimpui.h" -#include "pixel_region.h" #include "selection.h" -#include "temp_buf.h" #include "libgimp/gimpintl.h" diff --git a/app/paint/gimpconvolve.c b/app/paint/gimpconvolve.c index 00b2e8f4a1..d42a1ce3a8 100644 --- a/app/paint/gimpconvolve.c +++ b/app/paint/gimpconvolve.c @@ -25,6 +25,9 @@ #include "tools-types.h" +#include "base/pixel-region.h" +#include "base/temp-buf.h" + #include "core/gimpbrush.h" #include "core/gimpcontext.h" #include "core/gimpdrawable.h" @@ -38,9 +41,7 @@ #include "drawable.h" #include "gdisplay.h" -#include "pixel_region.h" #include "selection.h" -#include "temp_buf.h" #include "libgimp/gimpintl.h" diff --git a/app/paint/gimpdodgeburn.c b/app/paint/gimpdodgeburn.c index 137e050934..5ad388229e 100644 --- a/app/paint/gimpdodgeburn.c +++ b/app/paint/gimpdodgeburn.c @@ -26,6 +26,10 @@ #include "tools-types.h" +#include "base/gimplut.h" +#include "base/pixel-region.h" +#include "base/temp-buf.h" + #include "paint-funcs/paint-funcs.h" #include "core/gimpdrawable.h" @@ -33,10 +37,7 @@ #include "gdisplay.h" #include "gimage.h" -#include "gimplut.h" -#include "pixel_region.h" #include "selection.h" -#include "temp_buf.h" #include "gimpdodgeburntool.h" #include "gimppainttool.h" diff --git a/app/paint/gimperaser.c b/app/paint/gimperaser.c index 4532963b05..f3e9801c5f 100644 --- a/app/paint/gimperaser.c +++ b/app/paint/gimperaser.c @@ -25,6 +25,8 @@ #include "tools-types.h" +#include "base/temp-buf.h" + #include "paint-funcs/paint-funcs.h" #include "core/gimpcontext.h" @@ -33,7 +35,6 @@ #include "gdisplay.h" #include "selection.h" -#include "temp_buf.h" #include "gimperasertool.h" #include "paint_options.h" diff --git a/app/paint/gimpink.c b/app/paint/gimpink.c index 6f2b0696ce..d962215f8b 100644 --- a/app/paint/gimpink.c +++ b/app/paint/gimpink.c @@ -28,6 +28,11 @@ #include "tools-types.h" +#include "base/pixel-region.h" +#include "base/temp-buf.h" +#include "base/tile.h" +#include "base/tile-manager.h" + #include "paint-funcs/paint-funcs.h" #include "core/gimpcontext.h" @@ -39,10 +44,6 @@ #include "gimprc.h" #include "undo.h" #include "gdisplay.h" -#include "pixel_region.h" -#include "temp_buf.h" -#include "tile.h" -#include "tile_manager.h" #include "gimpinktool.h" #include "gimpinktool-blob.h" diff --git a/app/paint/gimppaintbrush.c b/app/paint/gimppaintbrush.c index 08ae5497ef..22a29bdc72 100644 --- a/app/paint/gimppaintbrush.c +++ b/app/paint/gimppaintbrush.c @@ -26,6 +26,8 @@ #include "tools-types.h" +#include "base/temp-buf.h" + #include "paint-funcs/paint-funcs.h" #include "core/gimpbrush.h" @@ -36,7 +38,6 @@ #include "gdisplay.h" #include "selection.h" -#include "temp_buf.h" #include "gimppaintbrushtool.h" #include "paint_options.h" diff --git a/app/paint/gimppaintcore.c b/app/paint/gimppaintcore.c index 6f885f86ba..5673686939 100644 --- a/app/paint/gimppaintcore.c +++ b/app/paint/gimppaintcore.c @@ -28,6 +28,12 @@ #include "tools-types.h" +#include "base/brush-scale.h" +#include "base/pixel-region.h" +#include "base/temp-buf.h" +#include "base/tile-manager.h" +#include "base/tile.h" + #include "paint-funcs/paint-funcs.h" #include "core/gimpbrushpipe.h" @@ -37,16 +43,11 @@ #include "core/gimpimage.h" #include "core/gimpimage-mask.h" -#include "brush_scale.h" #include "devices.h" #include "drawable.h" #include "gdisplay.h" #include "gimprc.h" -#include "pixel_region.h" #include "selection.h" -#include "temp_buf.h" -#include "tile.h" -#include "tile_manager.h" #include "undo.h" #include "gimpdrawtool.h" diff --git a/app/paint/gimppencil.c b/app/paint/gimppencil.c index 0fdb28df00..de6fb26faa 100644 --- a/app/paint/gimppencil.c +++ b/app/paint/gimppencil.c @@ -24,6 +24,8 @@ #include "tools-types.h" +#include "base/temp-buf.h" + #include "paint-funcs/paint-funcs.h" #include "core/gimpbrush.h" @@ -34,7 +36,6 @@ #include "gdisplay.h" #include "selection.h" -#include "temp_buf.h" #include "gimppenciltool.h" #include "gimppainttool.h" diff --git a/app/paint/gimpsmudge.c b/app/paint/gimpsmudge.c index c3f77dc1cf..69fc51c152 100644 --- a/app/paint/gimpsmudge.c +++ b/app/paint/gimpsmudge.c @@ -26,6 +26,9 @@ #include "tools-types.h" +#include "base/pixel-region.h" +#include "base/temp-buf.h" + #include "paint-funcs/paint-funcs.h" #include "core/gimpbrush.h" @@ -38,11 +41,8 @@ #include "tool_options.h" #include "gdisplay.h" -#include "gimplut.h" #include "gimpui.h" -#include "pixel_region.h" #include "selection.h" -#include "temp_buf.h" #include "libgimp/gimpintl.h" diff --git a/app/paint/gimpsourcecore.c b/app/paint/gimpsourcecore.c index eee8e9d7cf..f7061c020b 100644 --- a/app/paint/gimpsourcecore.c +++ b/app/paint/gimpsourcecore.c @@ -27,6 +27,9 @@ #include "tools-types.h" +#include "base/pixel-region.h" +#include "base/temp-buf.h" + #include "paint-funcs/paint-funcs.h" #include "core/gimpdrawable.h" @@ -43,11 +46,8 @@ #include "drawable.h" #include "gdisplay.h" -#include "gimplut.h" #include "gimpui.h" -#include "pixel_region.h" #include "selection.h" -#include "temp_buf.h" #include "libgimp/gimpintl.h" diff --git a/app/pdb/brush_select_cmds.c b/app/pdb/brush_select_cmds.c index 512f9e2ecf..576cdc9638 100644 --- a/app/pdb/brush_select_cmds.c +++ b/app/pdb/brush_select_cmds.c @@ -27,7 +27,7 @@ #include "core/core-types.h" #include "procedural_db.h" -#include "appenums.h" +#include "base/base-types.h" #include "context_manager.h" #include "core/gimpbrush.h" #include "core/gimpcontext.h" diff --git a/app/pdb/brushes_cmds.c b/app/pdb/brushes_cmds.c index f6f60125d0..06964b0be6 100644 --- a/app/pdb/brushes_cmds.c +++ b/app/pdb/brushes_cmds.c @@ -27,13 +27,13 @@ #include "core/core-types.h" #include "procedural_db.h" -#include "appenums.h" +#include "base/base-types.h" +#include "base/temp-buf.h" #include "context_manager.h" #include "core/gimpbrush.h" #include "core/gimpcontext.h" #include "core/gimpdatafactory.h" #include "core/gimplist.h" -#include "temp_buf.h" static ProcRecord brushes_refresh_proc; static ProcRecord brushes_get_brush_proc; diff --git a/app/pdb/color_cmds.c b/app/pdb/color_cmds.c index 5ac1051643..d5021ad201 100644 --- a/app/pdb/color_cmds.c +++ b/app/pdb/color_cmds.c @@ -27,6 +27,9 @@ #include "tools/tools-types.h" #include "procedural_db.h" +#include "base/gimplut.h" +#include "base/pixel-processor.h" +#include "base/pixel-region.h" #include "core/gimpdrawable-desaturate.h" #include "core/gimpdrawable-equalize.h" #include "core/gimpdrawable-invert.h" @@ -34,10 +37,7 @@ #include "core/gimpimage.h" #include "drawable.h" #include "gimphistogram.h" -#include "gimplut.h" #include "lut_funcs.h" -#include "pixel_processor.h" -#include "pixel_region.h" #include "tools/color_balance.h" #include "tools/curves.h" #include "tools/histogram_tool.h" diff --git a/app/pdb/drawable_cmds.c b/app/pdb/drawable_cmds.c index 63bf9a9aee..7e3ecbe431 100644 --- a/app/pdb/drawable_cmds.c +++ b/app/pdb/drawable_cmds.c @@ -28,6 +28,9 @@ #include "procedural_db.h" #include "appenums.h" +#include "base/temp-buf.h" +#include "base/tile-manager.h" +#include "base/tile.h" #include "core/core-types.h" #include "core/gimpchannel.h" #include "core/gimpdrawable-offset.h" @@ -37,9 +40,6 @@ #include "core/gimplayermask.h" #include "drawable.h" #include "pdb_glue.h" -#include "temp_buf.h" -#include "tile.h" -#include "tile_manager.h" static ProcRecord drawable_merge_shadow_proc; static ProcRecord drawable_fill_proc; diff --git a/app/pdb/fileops_cmds.c b/app/pdb/fileops_cmds.c index 9586b71b63..e54c023c4e 100644 --- a/app/pdb/fileops_cmds.c +++ b/app/pdb/fileops_cmds.c @@ -39,11 +39,11 @@ #include "core/core-types.h" #include "procedural_db.h" +#include "base/base-config.h" #include "core/gimpimage.h" #include "file-open.h" #include "file-save.h" #include "file-utils.h" -#include "gimprc.h" #include "plug_in.h" static ProcRecord file_load_proc; @@ -392,7 +392,7 @@ temp_name_invoker (Argument *args) pid = getpid(); name = g_strdup_printf ("%s" G_DIR_SEPARATOR_S "gimp_temp.%d%d.%s", - temp_path, pid, id++, extension); + base_config->temp_path, pid, id++, extension); } return_args = procedural_db_return_args (&temp_name_proc, success); diff --git a/app/pdb/image_cmds.c b/app/pdb/image_cmds.c index 23d61a4b28..4f346c541c 100644 --- a/app/pdb/image_cmds.c +++ b/app/pdb/image_cmds.c @@ -28,6 +28,7 @@ #include "procedural_db.h" #include "app_procs.h" +#include "base/temp-buf.h" #include "context_manager.h" #include "core/core-types.h" #include "core/gimpchannel.h" @@ -40,7 +41,6 @@ #include "drawable.h" #include "gdisplay.h" #include "gimage.h" -#include "temp_buf.h" #include "libgimp/gimpintl.h" #include "libgimp/gimplimits.h" diff --git a/app/pdb/layer_cmds.c b/app/pdb/layer_cmds.c index 97c2d2cdb7..9f867b12cf 100644 --- a/app/pdb/layer_cmds.c +++ b/app/pdb/layer_cmds.c @@ -27,6 +27,7 @@ #include "procedural_db.h" #include "appenums.h" +#include "base/base-types.h" #include "core/core-types.h" #include "core/gimpimage.h" #include "core/gimplayer.h" diff --git a/app/pdb/patterns_cmds.c b/app/pdb/patterns_cmds.c index 94f474d02c..b182c6305a 100644 --- a/app/pdb/patterns_cmds.c +++ b/app/pdb/patterns_cmds.c @@ -27,12 +27,12 @@ #include "core/core-types.h" #include "procedural_db.h" +#include "base/temp-buf.h" #include "context_manager.h" #include "core/gimpcontext.h" #include "core/gimpdatafactory.h" #include "core/gimplist.h" #include "core/gimppattern.h" -#include "temp_buf.h" static ProcRecord patterns_get_pattern_proc; static ProcRecord patterns_set_pattern_proc; diff --git a/app/pdb/tools_cmds.c b/app/pdb/tools_cmds.c index cdad1dea4c..3bbcbce647 100644 --- a/app/pdb/tools_cmds.c +++ b/app/pdb/tools_cmds.c @@ -28,10 +28,11 @@ #include "procedural_db.h" #include "appenums.h" +#include "base/base-types.h" +#include "base/tile-manager.h" #include "core/gimpdrawable.h" #include "core/gimpimage.h" #include "drawable.h" -#include "tile_manager.h" #include "tools/gimpairbrushtool.h" #include "tools/gimpblendtool.h" #include "tools/gimpbucketfilltool.h" diff --git a/app/pixel_processor.c b/app/pixel_processor.c deleted file mode 100644 index 8d3cf8a2ce..0000000000 --- a/app/pixel_processor.c +++ /dev/null @@ -1,420 +0,0 @@ -/* The GIMP -- an image manipulation program - * Copyright (C) 1995 Spencer Kimball and Peter Mattis - * - * pixel_processor.c: Copyright (C) 1999 Jay Cox - * - * 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 2 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, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -#include "config.h" - -#ifdef ENABLE_MP -#include -#define IF_THREAD(statement) statement -#else /* !ENABLE_MP */ -#define IF_THREAD(statement) -#endif /* ENABLE_MP */ - -#include - -#include "apptypes.h" - -#include "pixel_processor.h" -#include "pixel_region.h" - -#ifdef ENABLE_MP -#include "tile.h" -#endif - - -typedef void (* p1_func) (gpointer , - PixelRegion *); -typedef void (* p2_func) (gpointer , - PixelRegion * , - PixelRegion *); -typedef void (* p3_func) (gpointer , - PixelRegion *, - PixelRegion *, - PixelRegion *); -typedef void (* p4_func) (gpointer , - PixelRegion *, - PixelRegion *, - PixelRegion *, - PixelRegion *); - -struct _PixelProcessor -{ - gpointer data; - p_func f; - PixelRegionIterator *PRI; - IF_THREAD(pthread_mutex_t mutex;) - gint nthreads; - gint n_regions; - PixelRegion *r[4]; - - void *progress_report_data; - ProgressReportFunc progress_report_func; -}; - -IF_THREAD( -static void * -do_parallel_regions (PixelProcessor *p_s) -{ - PixelRegion tr[4]; - int ntiles = 0; - int i; - int cont = 1; - - pthread_mutex_lock(&p_s->mutex); - - if (p_s->nthreads != 0 && p_s->PRI) - p_s->PRI = (PixelRegionIterator*)pixel_regions_process(p_s->PRI); - - if (p_s->PRI == NULL) - { - pthread_mutex_unlock(&p_s->mutex); - return NULL; - } - - p_s->nthreads++; - - do - { - for (i = 0; i < p_s->n_regions; i++) - if (p_s->r[i]) - { - memcpy(&tr[i], p_s->r[i], sizeof(PixelRegion)); - if (tr[i].tiles) - tile_lock(tr[i].curtile); - } - - pthread_mutex_unlock(&p_s->mutex); - ntiles++; - - switch(p_s->n_regions) - { - case 1: - ((p1_func)p_s->f)(p_s->data, - p_s->r[0] ? &tr[0] : NULL); - break; - - case 2: - ((p2_func)p_s->f)(p_s->data, - p_s->r[0] ? &tr[0] : NULL, - p_s->r[1] ? &tr[1] : NULL); - break; - - case 3: - ((p3_func)p_s->f)(p_s->data, - p_s->r[0] ? &tr[0] : NULL, - p_s->r[1] ? &tr[1] : NULL, - p_s->r[2] ? &tr[2] : NULL); - break; - - case 4: - ((p4_func)p_s->f)(p_s->data, - p_s->r[0] ? &tr[0] : NULL, - p_s->r[1] ? &tr[1] : NULL, - p_s->r[2] ? &tr[2] : NULL, - p_s->r[3] ? &tr[3] : NULL); - break; - - default: - g_message("do_parallel_regions: Bad number of regions %d\n", - p_s->n_regions); - } - - pthread_mutex_lock(&p_s->mutex); - - for (i = 0; i < p_s->n_regions; i++) - if (p_s->r[i]) - { - if (tr[i].tiles) - tile_release(tr[i].curtile, tr[i].dirty); - } - - if (p_s->progress_report_func && - !p_s->progress_report_func(p_s->progress_report_data, - p_s->r[0]->x, p_s->r[0]->y, - p_s->r[0]->w, p_s->r[0]->h)) - cont = 0; - - } - while (cont && p_s->PRI && - (p_s->PRI = (PixelRegionIterator*)pixel_regions_process(p_s->PRI))); - - p_s->nthreads--; - - pthread_mutex_unlock(&p_s->mutex); - - return NULL; -} -) - -/* do_parallel_regions_single is just like do_parallel_regions - * except that all the mutex and tile locks have been removed - * - * If we are processing with only a single thread we don't need to do the - * mutex locks etc. and aditional tile locks even if we were - * configured --with-mp - */ - -static gpointer -do_parallel_regions_single (PixelProcessor *p_s) -{ - gint cont = 1; - - do - { - switch (p_s->n_regions) - { - case 1: - ((p1_func)p_s->f)(p_s->data, - p_s->r[0]); - break; - - case 2: - ((p2_func)p_s->f)(p_s->data, - p_s->r[0], - p_s->r[1]); - break; - - case 3: - ((p3_func)p_s->f)(p_s->data, - p_s->r[0], - p_s->r[1], - p_s->r[2]); - break; - - case 4: - ((p4_func)p_s->f)(p_s->data, - p_s->r[0], - p_s->r[1], - p_s->r[2], - p_s->r[3]); - break; - - default: - g_message("do_parallel_regions_single: Bad number of regions %d\n", - p_s->n_regions); - } - - if (p_s->progress_report_func) - if (!p_s->progress_report_func (p_s->progress_report_data, - p_s->r[0]->x, p_s->r[0]->y, - p_s->r[0]->w, p_s->r[0]->h)) - cont = 0; - } - while (cont && p_s->PRI && - (p_s->PRI = (PixelRegionIterator*)pixel_regions_process(p_s->PRI))); - - return NULL; -} - -#define MAX_THREADS 30 - -static void -pixel_regions_do_parallel (PixelProcessor *p_s) -{ - IF_THREAD( - gint nthreads; - - nthreads = MIN (num_processors, MAX_THREADS); - - /* make sure we have at least one tile per thread */ - nthreads = MIN (nthreads, - (p_s->PRI->region_width * p_s->PRI->region_height) - / (TILE_WIDTH * TILE_HEIGHT)); - - if (nthreads > 1) - { - gint i; - pthread_t threads[MAX_THREADS]; - pthread_attr_t pthread_attr; - - pthread_attr_init (&pthread_attr); - - for (i = 0; i < nthreads; i++) - { - pthread_create (&threads[i], &pthread_attr, - (void *(*)(void *)) do_parallel_regions, - p_s); - } - for (i = 0; i < nthreads; i++) - { - gint ret; - - if ((ret = pthread_join(threads[i], NULL))) - { - g_printerr ("pixel_regions_do_parallel:: pthread_join returned: %d\n", ret); - } - } - if (p_s->nthreads != 0) - g_printerr ("pixel_regions_do_prarallel: we lost a thread\n"); - } - else - ) - do_parallel_regions_single (p_s); -} - -static PixelProcessor * -pixel_regions_real_process_parallel (p_func f, - gpointer data, - ProgressReportFunc report_func, - gpointer report_data, - gint num_regions, - va_list ap) -{ - gint i; - PixelProcessor *p_s; - - p_s = g_new (PixelProcessor, 1); - - for (i = 0; i < num_regions; i++) - p_s->r[i] = va_arg (ap, PixelRegion *); - - switch(num_regions) - { - case 1: - p_s->PRI = (PixelRegionIterator *) pixel_regions_register (num_regions, - p_s->r[0]); - break; - - case 2: - p_s->PRI = (PixelRegionIterator *) pixel_regions_register (num_regions, - p_s->r[0], - p_s->r[1]); - break; - - case 3: - p_s->PRI = (PixelRegionIterator *) pixel_regions_register (num_regions, - p_s->r[0], - p_s->r[1], - p_s->r[2]); - break; - - case 4: - p_s->PRI = (PixelRegionIterator *) pixel_regions_register (num_regions, - p_s->r[0], - p_s->r[1], - p_s->r[2], - p_s->r[3]); - break; - - default: - g_message ("pixel_regions_real_process_parallel: Bad number of regions %d\n", - p_s->n_regions); - } - - if (!p_s->PRI) - { - pixel_processor_free (p_s); - return NULL; - } - - /* Why would we wan't to set dirty_tiles to 0 here? */ - /* IF_THREAD(p_s->PRI->dirty_tiles = 0;) */ - p_s->f = f; - p_s->data = data; - p_s->n_regions = num_regions; - IF_THREAD (pthread_mutex_init(&(p_s->mutex), NULL);) - p_s->nthreads = 0; - - p_s->progress_report_data = report_data; - p_s->progress_report_func = report_func; - - pixel_regions_do_parallel (p_s); - - if (p_s->PRI) - return p_s; - - pixel_processor_free (p_s); - - return NULL; -} - -void -pixel_regions_process_parallel (p_func f, - gpointer data, - gint num_regions, - ...) -{ - va_list va; - - va_start (va, num_regions); - - pixel_regions_real_process_parallel (f, data, NULL, NULL, num_regions, va); - - va_end (va); -} - -PixelProcessor * -pixel_regions_process_parallel_progress (p_func f, - gpointer data, - ProgressReportFunc progress_func, - gpointer progress_data, - gint num_regions, - ...) -{ - PixelProcessor *ret; - va_list va; - - va_start (va, num_regions); - - ret = pixel_regions_real_process_parallel (f, data, - progress_func, progress_data, - num_regions, va); - - va_end (va); - - return ret; -} - -void -pixel_processor_stop (PixelProcessor *pp) -{ - if (!pp) - return; - - if (pp->PRI) - { - pixel_regions_process_stop (pp->PRI); - pp->PRI = NULL; - } - pixel_processor_free (pp); -} - -PixelProcessor * -pixel_processor_cont (PixelProcessor *pp) -{ - pixel_regions_do_parallel (pp); - - if (pp->PRI) - return pp; - - pixel_processor_free (pp); - - return NULL; -} - -void -pixel_processor_free (PixelProcessor *pp) -{ - if (pp->PRI) - pixel_processor_stop (pp); - else - g_free(pp); -} - diff --git a/app/pixel_processor.h b/app/pixel_processor.h deleted file mode 100644 index b1888c36b8..0000000000 --- a/app/pixel_processor.h +++ /dev/null @@ -1,51 +0,0 @@ -/* The GIMP -- an image manipulation program - * Copyright (C) 1995 Spencer Kimball and Peter Mattis - * - * pixel_processor.h: Copyright (C) 1999 Jay Cox - * - * 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 2 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, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -#ifndef __PIXEL_PROCESSOR_H__ -#define __PIXEL_PROCESSOR_H__ - - -typedef struct _PixelProcessor PixelProcessor; - -typedef void (* p_func) (void); -typedef gint (* ProgressReportFunc) (void *, - gint, - gint, - gint, - gint); - - -void pixel_regions_process_parallel (p_func f, - gpointer data, - gint num_regions, - ...); -PixelProcessor * pixel_process_progress (p_func f, - gpointer data, - ProgressReportFunc progress_func, - gpointer progress_data, - gint num_regions, - ...); - -void pixel_processor_free (PixelProcessor *); -void pixel_processor_stop (PixelProcessor *); -PixelProcessor * pixel_processor_cont (PixelProcessor *); - - -#endif /* __PIXEL_PROCESSOR_H__ */ diff --git a/app/pixel_region.c b/app/pixel_region.c deleted file mode 100644 index 4fdd2bc4ae..0000000000 --- a/app/pixel_region.c +++ /dev/null @@ -1,598 +0,0 @@ -/* The GIMP -- an 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 2 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, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -#include "config.h" - -#include -#include - -#include - -#include "apptypes.h" - -#include "pixel_region.h" -#include "tile_manager.h" -#include "tile.h" - - -/*********************/ -/* Local Functions */ - -static gint get_portion_width (PixelRegionIterator *PRI); -static gint get_portion_height (PixelRegionIterator *PRI); -static gpointer pixel_regions_configure (PixelRegionIterator *PRI); -static void pixel_region_configure (PixelRegionHolder *PRH, - PixelRegionIterator *PRI); - - -/**************************/ -/* Function definitions */ - -void -pixel_region_init (PixelRegion *PR, - TileManager *tiles, - gint x, - gint y, - gint w, - gint h, - gboolean dirty) -{ - PR->tiles = tiles; - PR->curtile = NULL; - PR->data = NULL; - PR->bytes = tile_manager_bpp (tiles); - PR->rowstride = PR->bytes * TILE_WIDTH; - PR->x = x; - PR->y = y; - PR->w = w; - PR->h = h; - PR->dirty = dirty; -} - -void -pixel_region_resize (PixelRegion *PR, - gint x, - gint y, - gint w, - gint h) -{ - /* If the data is non-null, data is contiguous--need to advance */ - if (PR->data != NULL) - { - PR->data += (y - PR->y) * PR->rowstride + (x - PR->x) * PR->bytes; - } - - /* update sizes for both contiguous and tiled regions */ - PR->x = x; - PR->y = y; - PR->w = w; - PR->h = h; -} - - -/* request that tiles within a region be fetched asynchronously */ -void -pixel_region_get_async (PixelRegion *PR, - gint ulx, - gint uly, - gint lrx, - gint lry) -{ - gint x; - gint y; - - for (y = uly; y < lry; y += TILE_HEIGHT) - for (x = ulx; x < lrx; x += TILE_WIDTH) - tile_manager_get_async (PR->tiles, x, y); -} - - -void -pixel_region_get_row (PixelRegion *PR, - gint x, - gint y, - gint w, - guchar *data, - gint subsample) -{ - Tile *tile; - guchar *tile_data; - gint inc; - gint end; - gint boundary; - gint b; - gint npixels; - gint tilebpp; - - end = x + w; - - pixel_region_get_async (PR, x, y, end, y); - - while (x < end) - { - tile = tile_manager_get_tile (PR->tiles, x, y, TRUE, FALSE); - tilebpp = tile_bpp (tile); - tile_data = tile_data_pointer (tile, x % TILE_WIDTH, y % TILE_HEIGHT); - npixels = tile_ewidth (tile) - (x % TILE_WIDTH); - - if ((x + npixels) > end) /* make sure we don't write past the end */ - npixels = end - x; - - if (subsample == 1) /* optimize for the common case */ - { - memcpy (data, tile_data, tilebpp * npixels); - data += tilebpp * npixels; - x += npixels; - } - else - { - boundary = x + npixels; - inc = subsample * tilebpp; - for ( ; x < boundary; x += subsample) - { - for (b = 0; b < tilebpp; b++) - *data++ = tile_data[b]; - - tile_data += inc; - } - } - tile_release (tile, FALSE); - } -} - -void -pixel_region_set_row (PixelRegion *PR, - gint x, - gint y, - gint w, - guchar *data) -{ - Tile *tile; - guchar *tile_data; - gint end; - gint npixels; - - end = x + w; - - pixel_region_get_async (PR, x, y, end, y); - - while (x < end) - { - tile = tile_manager_get_tile (PR->tiles, x, y, TRUE, TRUE); - tile_data = tile_data_pointer (tile, x % TILE_WIDTH, y % TILE_HEIGHT); - - npixels = tile_ewidth (tile) - (x % TILE_WIDTH); - - if ((x + npixels) > end) /* make sure we don't write past the end */ - npixels = end - x; - - memcpy (tile_data, data, tile_bpp (tile) * npixels); - - data += tile_bpp (tile) * npixels; - x += npixels; - - tile_release (tile, TRUE); - } -} - - -void -pixel_region_get_col (PixelRegion *PR, - gint x, - gint y, - gint h, - guchar *data, - gint subsample) -{ - Tile *tile; - guchar *tile_data; - gint tilebpp; - gint inc; - gint end; - gint boundary; - gint b; - - end = y + h; - - pixel_region_get_async (PR, x, y, x, end); - - while (y < end) - { - tile = tile_manager_get_tile (PR->tiles, x, y, TRUE, FALSE); - tilebpp = tile_bpp (tile); - tile_data = tile_data_pointer (tile, x % TILE_WIDTH, y % TILE_HEIGHT); - boundary = y + (tile_eheight(tile) - (y % TILE_HEIGHT)); - - if (boundary > end) /* make sure we don't write past the end */ - boundary = end; - - inc = subsample * tilebpp * tile_ewidth (tile); - - for ( ; y < boundary; y += subsample) - { - for (b = 0; b < tilebpp; b++) - *data++ = tile_data[b]; - - tile_data += inc; - } - - tile_release (tile, FALSE); - } -} - - -void -pixel_region_set_col (PixelRegion *PR, - gint x, - gint y, - gint h, - guchar *data) -{ - Tile *tile; - guchar *tile_data; - gint tilebpp; - gint inc; - gint end; - gint boundary; - gint b; - - end = y + h; - - pixel_region_get_async (PR, x, y, x, end); - - while (y < end) - { - tile = tile_manager_get_tile (PR->tiles, x, y, TRUE, TRUE); - tilebpp = tile_bpp (tile); - tile_data = tile_data_pointer (tile, x % TILE_WIDTH, y % TILE_HEIGHT); - boundary = y + (tile_eheight (tile) - (y % TILE_HEIGHT)); - inc = tilebpp * tile_ewidth (tile); - - if (boundary > end) /* make sure we don't write past the end */ - boundary = end; - - for ( ; y < boundary; y++) - { - for (b = 0; b < tilebpp; b++) - tile_data[b] = *data++; - - tile_data += inc; - } - - tile_release (tile, TRUE); - } -} - -gboolean -pixel_region_has_alpha (PixelRegion *PR) -{ - if (PR->bytes == 2 || PR->bytes == 4) - return TRUE; - else - return FALSE; -} - -gpointer -pixel_regions_register (gint num_regions, - ...) -{ - PixelRegion *PR; - PixelRegionHolder *PRH; - PixelRegionIterator *PRI; - gboolean found; - va_list ap; - - PRI = g_new (PixelRegionIterator, 1); - PRI->pixel_regions = NULL; - PRI->process_count = 0; - PRI->dirty_tiles = 1; - - if (num_regions < 1) - return NULL; - - va_start (ap, num_regions); - - found = FALSE; - while (num_regions --) - { - PR = va_arg (ap, PixelRegion *); - PRH = g_new (PixelRegionHolder, 1); - PRH->PR = PR; - - if (PR != NULL) - { - /* If there is a defined value for data, make sure tiles is NULL */ - if (PR->data) - PR->tiles = NULL; - - PRH->original_data = PR->data; - PRH->startx = PR->x; - PRH->starty = PR->y; - PRH->PR->process_count = 0; - - if (!found) - { - found = TRUE; - PRI->region_width = PR->w; - PRI->region_height = PR->h; - } - } - - /* Add the pixel region holder to the list */ - PRI->pixel_regions = g_slist_prepend (PRI->pixel_regions, PRH); - } - - va_end (ap); - - return pixel_regions_configure (PRI); -} - - -gpointer -pixel_regions_process (gpointer PRI_ptr) -{ - GSList *list; - PixelRegionHolder *PRH; - PixelRegionIterator *PRI; - - PRI = (PixelRegionIterator *) PRI_ptr; - PRI->process_count++; - - /* Unref all referenced tiles and increment the offsets */ - - for (list = PRI->pixel_regions; list; list = g_slist_next (list)) - { - PRH = (PixelRegionHolder *) list->data; - - if ((PRH->PR != NULL) && (PRH->PR->process_count != PRI->process_count)) - { - /* This eliminates the possibility of incrementing the - * same region twice - */ - PRH->PR->process_count++; - - /* Unref the last referenced tile if the underlying region - is a tile manager */ - if (PRH->PR->tiles) - { - /* only set the dirty flag if PRH->dirty_tiles == TRUE */ - tile_release (PRH->PR->curtile, - PRH->PR->dirty && PRI->dirty_tiles); - PRH->PR->curtile = NULL; - } - - PRH->PR->x += PRI->portion_width; - - if ((PRH->PR->x - PRH->startx) >= PRI->region_width) - { - PRH->PR->x = PRH->startx; - PRH->PR->y += PRI->portion_height; - } - } - } - - return pixel_regions_configure (PRI); -} - -void -pixel_regions_process_stop (gpointer PRI_ptr) -{ - GSList *list; - PixelRegionHolder *PRH; - PixelRegionIterator *PRI; - - PRI = (PixelRegionIterator *) PRI_ptr; - PRI->process_count++; - - /* Unref all referenced tiles and increment the offsets */ - - for (list = PRI->pixel_regions; list; list = g_slist_next (list)) - { - PRH = (PixelRegionHolder *) list->data; - - if ((PRH->PR != NULL) && (PRH->PR->process_count != PRI->process_count)) - { - /* This eliminates the possibility of incrementing the - * same region twice - */ - PRH->PR->process_count++; - - /* Unref the last referenced tile if the underlying region - is a tile manager */ - if (PRH->PR->tiles) - { - tile_release (PRH->PR->curtile, PRH->PR->dirty); - PRH->PR->curtile = NULL; - } - } - } - - if (PRI->pixel_regions) - { - for (list = PRI->pixel_regions; list; list = g_slist_next (list)) - g_free (list->data); - - g_slist_free (PRI->pixel_regions); - g_free (PRI); - } -} - - -/*********************************/ -/* Static Function Definitions */ - -static gint -get_portion_height (PixelRegionIterator *PRI) -{ - GSList *list; - PixelRegionHolder *PRH; - gint min_height = G_MAXINT; - gint height; - - /* Find the minimum height to the next vertical tile - * (in the case of a tile manager) or to the end of the - * pixel region (in the case of no tile manager) - */ - - for (list = PRI->pixel_regions; list; list = g_slist_next (list)) - { - PRH = (PixelRegionHolder *) list->data; - - if (PRH->PR) - { - /* Check if we're past the point of no return */ - if ((PRH->PR->y - PRH->starty) >= PRI->region_height) - return 0; - - if (PRH->PR->tiles) - { - height = TILE_HEIGHT - (PRH->PR->y % TILE_HEIGHT); - height = CLAMP (height, - 0, - (PRI->region_height - (PRH->PR->y - PRH->starty))); - } - else - height = (PRI->region_height - (PRH->PR->y - PRH->starty)); - - if (height < min_height) - min_height = height; - } - } - - return min_height; -} - - -static gint -get_portion_width (PixelRegionIterator *PRI) -{ - GSList *list; - PixelRegionHolder *PRH; - gint min_width = G_MAXINT; - gint width; - - /* Find the minimum width to the next vertical tile - * (in the case of a tile manager) or to the end of - * the pixel region (in the case of no tile manager) - */ - - for (list = PRI->pixel_regions; list; list = g_slist_next (list)) - { - PRH = (PixelRegionHolder *) list->data; - - if (PRH->PR) - { - /* Check if we're past the point of no return */ - if ((PRH->PR->x - PRH->startx) >= PRI->region_width) - return 0; - - if (PRH->PR->tiles) - { - width = TILE_WIDTH - (PRH->PR->x % TILE_WIDTH); - width = CLAMP (width, - 0, - (PRI->region_width - (PRH->PR->x - PRH->startx))); - } - else - width = (PRI->region_width - (PRH->PR->x - PRH->startx)); - - if (width < min_width) - min_width = width; - } - } - - return min_width; -} - - -static gpointer -pixel_regions_configure (PixelRegionIterator *PRI) -{ - PixelRegionHolder *PRH; - GSList *list; - - /* Determine the portion width and height */ - PRI->portion_width = get_portion_width (PRI); - PRI->portion_height = get_portion_height (PRI); - - if (PRI->portion_width == 0 || PRI->portion_height == 0) - { - /* free the pixel regions list */ - if (PRI->pixel_regions) - { - for (list = PRI->pixel_regions; list; list = g_slist_next (list)) - g_free (list->data); - - g_slist_free (PRI->pixel_regions); - g_free (PRI); - } - - return NULL; - } - - PRI->process_count++; - - for (list = PRI->pixel_regions; list; list = g_slist_next (list)) - { - PRH = (PixelRegionHolder *) list->data; - - if ((PRH->PR != NULL) && (PRH->PR->process_count != PRI->process_count)) - { - PRH->PR->process_count++; - pixel_region_configure (PRH, PRI); - } - } - - return PRI; -} - - -static void -pixel_region_configure (PixelRegionHolder *PRH, - PixelRegionIterator *PRI) -{ - /* Configure the rowstride and data pointer for the pixel region - * based on the current offsets into the region and whether the - * region is represented by a tile manager or not - */ - if (PRH->PR->tiles) - { - PRH->PR->curtile = tile_manager_get_tile (PRH->PR->tiles, - PRH->PR->x, - PRH->PR->y, - TRUE, - PRH->PR->dirty); - - PRH->PR->offx = PRH->PR->x % TILE_WIDTH; - PRH->PR->offy = PRH->PR->y % TILE_HEIGHT; - - PRH->PR->rowstride = tile_ewidth (PRH->PR->curtile) * PRH->PR->bytes; - PRH->PR->data = tile_data_pointer (PRH->PR->curtile, - PRH->PR->offx, - PRH->PR->offy); - } - else - { - PRH->PR->data = PRH->original_data + - (PRH->PR->y - PRH->starty) * PRH->PR->rowstride + - (PRH->PR->x - PRH->startx) * PRH->PR->bytes; - } - - PRH->PR->w = PRI->portion_width; - PRH->PR->h = PRI->portion_height; -} diff --git a/app/pixel_region.h b/app/pixel_region.h deleted file mode 100644 index b34b197ec9..0000000000 --- a/app/pixel_region.h +++ /dev/null @@ -1,108 +0,0 @@ -/* The GIMP -- an 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 2 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, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -#ifndef __PIXEL_REGION_H__ -#define __PIXEL_REGION_H__ - -struct _PixelRegion -{ - guchar *data; /* pointer to region data */ - TileManager *tiles; /* pointer to tiles */ - Tile *curtile; /* current tile */ - gint offx; /* tile offsets */ - gint offy; /* tile offsets */ - gint rowstride; /* bytes per pixel row */ - gint x; /* origin */ - gint y; /* origin */ - gint w; /* width of region */ - gint h; /* height of region */ - gint bytes; /* bytes per pixel */ - gboolean dirty; /* will this region be dirtied? */ - gint process_count; /* used internally */ -}; - -struct _PixelRegionHolder -{ - PixelRegion *PR; - guchar *original_data; - gint startx; - gint starty; - gint count; -}; - -struct _PixelRegionIterator -{ - GSList *pixel_regions; - gint dirty_tiles; - gint region_width; - gint region_height; - gint portion_width; - gint portion_height; - gint process_count; -}; - - -/* PixelRegion functions */ - -void pixel_region_init (PixelRegion *PR, - TileManager *tiles, - gint x, - gint y, - gint w, - gint h, - gboolean dirty); -void pixel_region_resize (PixelRegion *PR, - gint x, - gint y, - gint w, - gint h); -void pixel_region_get_async (PixelRegion *PR, - gint ulx, - gint uly, - gint lrx, - gint lry); -void pixel_region_get_row (PixelRegion *PR, - gint x, - gint y, - gint w, - guchar *data, - gint subsample); -void pixel_region_set_row (PixelRegion *PR, - gint x, - gint y, - gint w, - guchar *data); -void pixel_region_get_col (PixelRegion *PR, - gint x, - gint y, - gint h, - guchar *data, - gint subsample); -void pixel_region_set_col (PixelRegion *PR, - gint x, - gint y, - gint h, - guchar *data); -gboolean pixel_region_has_alpha (PixelRegion *PR); -gpointer pixel_regions_register (gint num_regions, - ...); -gpointer pixel_regions_process (gpointer PRI_ptr); -void pixel_regions_process_stop (gpointer PRI_ptr); - - -#endif /* __PIXEL_REGION_H__ */ diff --git a/app/pixel_surround.c b/app/pixel_surround.c deleted file mode 100644 index 2f14508566..0000000000 --- a/app/pixel_surround.c +++ /dev/null @@ -1,150 +0,0 @@ -/* The GIMP -- an image manipulation program - * Copyright (C) 1995-2001 Spencer Kimball, Peter Mattis, and others - * - * 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 2 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, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -#include "config.h" - -#include - -#include "core/core-types.h" - -#include "core/gimpimage.h" - -#include "pixel_region.h" -#include "pixel_surround.h" -#include "tile_manager.h" -#include "tile.h" - - -void -pixel_surround_init (PixelSurround *ps, - TileManager *tm, - gint w, - gint h, - guchar bg[MAX_CHANNELS]) -{ - gint i; - - for (i = 0; i < MAX_CHANNELS; ++i) - { - ps->bg[i] = bg[i]; - } - - ps->tile = NULL; - ps->mgr = tm; - ps->bpp = tile_manager_bpp (tm); - ps->w = w; - ps->h = h; - /* make sure buffer is big enough */ - ps->buff_size = w * h * ps->bpp; - ps->buff = g_malloc (ps->buff_size); - ps->row_stride = 0; -} - -guchar * -pixel_surround_lock (PixelSurround *ps, - gint x, - gint y) -{ - gint i, j; - guchar *k; - guchar *ptr; - - ps->tile = tile_manager_get_tile (ps->mgr, x, y, TRUE, FALSE); - - i = x % TILE_WIDTH; - j = y % TILE_HEIGHT; - - /* do we have the whole region? */ - if (ps->tile && - (i < (tile_ewidth(ps->tile) - ps->w)) && - (j < (tile_eheight(ps->tile) - ps->h))) - { - ps->row_stride = tile_ewidth (ps->tile) * ps->bpp; - /* is this really the correct way? */ - return tile_data_pointer (ps->tile, i, j); - } - - /* nope, do this the hard way (for now) */ - if (ps->tile) - { - tile_release (ps->tile, FALSE); - ps->tile = 0; - } - - /* copy pixels, one by one */ - /* no, this is not the best way, but it's much better than before */ - ptr = ps->buff; - for (j = y; j < y+ps->h; ++j) - { - for (i = x; i < x+ps->w; ++i) - { - Tile *tile = tile_manager_get_tile (ps->mgr, i, j, TRUE, FALSE); - - if (tile) - { - guchar *buff = tile_data_pointer (tile, - i % TILE_WIDTH, - j % TILE_HEIGHT); - - for (k = buff; k < buff+ps->bpp; ++k, ++ptr) - { - *ptr = *k; - } - tile_release (tile, FALSE); - } - else - { - for (k = ps->bg; k < ps->bg+ps->bpp; ++k, ++ptr) - { - *ptr = *k; - } - } - } - } - ps->row_stride = ps->w * ps->bpp; - - return ps->buff; -} - -gint -pixel_surround_rowstride (PixelSurround *ps) -{ - return ps->row_stride; -} - -void -pixel_surround_release (PixelSurround *ps) -{ - /* always get new tile (for now), so release the old one */ - if (ps->tile) - { - tile_release (ps->tile, FALSE); - ps->tile = 0; - } -} - -void -pixel_surround_clear (PixelSurround *ps) -{ - if (ps->buff) - { - g_free (ps->buff); - ps->buff = 0; - ps->buff_size = 0; - } -} diff --git a/app/pixel_surround.h b/app/pixel_surround.h deleted file mode 100644 index 246e9d90f8..0000000000 --- a/app/pixel_surround.h +++ /dev/null @@ -1,62 +0,0 @@ -/* The GIMP -- an 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 2 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, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -#ifndef __PIXEL_SURROUND_H__ -#define __PIXEL_SURROUND_H__ - - -/* PixelSurround describes a (read-only) - * region around a pixel in a tile manager - */ - -typedef struct _PixelSurround -{ - Tile *tile; - TileManager *mgr; - guchar *buff; - gint buff_size; - gint bpp; - gint w; - gint h; - guchar bg[MAX_CHANNELS]; - gint row_stride; -} PixelSurround; - - -void pixel_surround_init (PixelSurround *ps, - TileManager *tm, - gint w, - gint h, - guchar bg[MAX_CHANNELS]); - -/* return a pointer to a buffer which contains all the surrounding pixels - * strategy: if we are in the middle of a tile, use the tile storage - * otherwise just copy into our own malloced buffer and return that - */ -guchar * pixel_surround_lock (PixelSurround *ps, - gint x, - gint y); - -gint pixel_surround_rowstride (PixelSurround *ps); - -void pixel_surround_release (PixelSurround *ps); - -void pixel_surround_clear (PixelSurround *ps); - - -#endif /* __PIXEL_SURROUND_H__ */ diff --git a/app/plug-in/gimpplugin-message.c b/app/plug-in/gimpplugin-message.c index 2b9b8afa01..37a596f9d2 100644 --- a/app/plug-in/gimpplugin-message.c +++ b/app/plug-in/gimpplugin-message.c @@ -85,6 +85,9 @@ #include "libgimp/gimpprotocol.h" #include "libgimp/gimpwire.h" +#include "base/tile.h" +#include "base/tile-manager.h" + #include "core/gimpdrawable.h" #include "core/gimpimage.h" @@ -102,8 +105,6 @@ #include "gimpprogress.h" #include "gimprc.h" #include "plug_in.h" -#include "tile.h" -#include "tile_manager.h" #include "libgimp/gimpintl.h" diff --git a/app/plug-in/gimpplugin-progress.c b/app/plug-in/gimpplugin-progress.c index 2b9b8afa01..37a596f9d2 100644 --- a/app/plug-in/gimpplugin-progress.c +++ b/app/plug-in/gimpplugin-progress.c @@ -85,6 +85,9 @@ #include "libgimp/gimpprotocol.h" #include "libgimp/gimpwire.h" +#include "base/tile.h" +#include "base/tile-manager.h" + #include "core/gimpdrawable.h" #include "core/gimpimage.h" @@ -102,8 +105,6 @@ #include "gimpprogress.h" #include "gimprc.h" #include "plug_in.h" -#include "tile.h" -#include "tile_manager.h" #include "libgimp/gimpintl.h" diff --git a/app/plug-in/gimpplugin.c b/app/plug-in/gimpplugin.c index 2b9b8afa01..37a596f9d2 100644 --- a/app/plug-in/gimpplugin.c +++ b/app/plug-in/gimpplugin.c @@ -85,6 +85,9 @@ #include "libgimp/gimpprotocol.h" #include "libgimp/gimpwire.h" +#include "base/tile.h" +#include "base/tile-manager.h" + #include "core/gimpdrawable.h" #include "core/gimpimage.h" @@ -102,8 +105,6 @@ #include "gimpprogress.h" #include "gimprc.h" #include "plug_in.h" -#include "tile.h" -#include "tile_manager.h" #include "libgimp/gimpintl.h" diff --git a/app/plug-in/gimppluginmanager-call.c b/app/plug-in/gimppluginmanager-call.c index 2b9b8afa01..37a596f9d2 100644 --- a/app/plug-in/gimppluginmanager-call.c +++ b/app/plug-in/gimppluginmanager-call.c @@ -85,6 +85,9 @@ #include "libgimp/gimpprotocol.h" #include "libgimp/gimpwire.h" +#include "base/tile.h" +#include "base/tile-manager.h" + #include "core/gimpdrawable.h" #include "core/gimpimage.h" @@ -102,8 +105,6 @@ #include "gimpprogress.h" #include "gimprc.h" #include "plug_in.h" -#include "tile.h" -#include "tile_manager.h" #include "libgimp/gimpintl.h" diff --git a/app/plug-in/gimppluginmanager-run.c b/app/plug-in/gimppluginmanager-run.c index 2b9b8afa01..37a596f9d2 100644 --- a/app/plug-in/gimppluginmanager-run.c +++ b/app/plug-in/gimppluginmanager-run.c @@ -85,6 +85,9 @@ #include "libgimp/gimpprotocol.h" #include "libgimp/gimpwire.h" +#include "base/tile.h" +#include "base/tile-manager.h" + #include "core/gimpdrawable.h" #include "core/gimpimage.h" @@ -102,8 +105,6 @@ #include "gimpprogress.h" #include "gimprc.h" #include "plug_in.h" -#include "tile.h" -#include "tile_manager.h" #include "libgimp/gimpintl.h" diff --git a/app/plug-in/gimppluginmanager.c b/app/plug-in/gimppluginmanager.c index 2b9b8afa01..37a596f9d2 100644 --- a/app/plug-in/gimppluginmanager.c +++ b/app/plug-in/gimppluginmanager.c @@ -85,6 +85,9 @@ #include "libgimp/gimpprotocol.h" #include "libgimp/gimpwire.h" +#include "base/tile.h" +#include "base/tile-manager.h" + #include "core/gimpdrawable.h" #include "core/gimpimage.h" @@ -102,8 +105,6 @@ #include "gimpprogress.h" #include "gimprc.h" #include "plug_in.h" -#include "tile.h" -#include "tile_manager.h" #include "libgimp/gimpintl.h" diff --git a/app/plug-in/gimppluginshm.c b/app/plug-in/gimppluginshm.c index 2b9b8afa01..37a596f9d2 100644 --- a/app/plug-in/gimppluginshm.c +++ b/app/plug-in/gimppluginshm.c @@ -85,6 +85,9 @@ #include "libgimp/gimpprotocol.h" #include "libgimp/gimpwire.h" +#include "base/tile.h" +#include "base/tile-manager.h" + #include "core/gimpdrawable.h" #include "core/gimpimage.h" @@ -102,8 +105,6 @@ #include "gimpprogress.h" #include "gimprc.h" #include "plug_in.h" -#include "tile.h" -#include "tile_manager.h" #include "libgimp/gimpintl.h" diff --git a/app/plug-in/plug-in-def.c b/app/plug-in/plug-in-def.c index 2b9b8afa01..37a596f9d2 100644 --- a/app/plug-in/plug-in-def.c +++ b/app/plug-in/plug-in-def.c @@ -85,6 +85,9 @@ #include "libgimp/gimpprotocol.h" #include "libgimp/gimpwire.h" +#include "base/tile.h" +#include "base/tile-manager.h" + #include "core/gimpdrawable.h" #include "core/gimpimage.h" @@ -102,8 +105,6 @@ #include "gimpprogress.h" #include "gimprc.h" #include "plug_in.h" -#include "tile.h" -#include "tile_manager.h" #include "libgimp/gimpintl.h" diff --git a/app/plug-in/plug-in-message.c b/app/plug-in/plug-in-message.c index 2b9b8afa01..37a596f9d2 100644 --- a/app/plug-in/plug-in-message.c +++ b/app/plug-in/plug-in-message.c @@ -85,6 +85,9 @@ #include "libgimp/gimpprotocol.h" #include "libgimp/gimpwire.h" +#include "base/tile.h" +#include "base/tile-manager.h" + #include "core/gimpdrawable.h" #include "core/gimpimage.h" @@ -102,8 +105,6 @@ #include "gimpprogress.h" #include "gimprc.h" #include "plug_in.h" -#include "tile.h" -#include "tile_manager.h" #include "libgimp/gimpintl.h" diff --git a/app/plug-in/plug-in-params.c b/app/plug-in/plug-in-params.c index 2b9b8afa01..37a596f9d2 100644 --- a/app/plug-in/plug-in-params.c +++ b/app/plug-in/plug-in-params.c @@ -85,6 +85,9 @@ #include "libgimp/gimpprotocol.h" #include "libgimp/gimpwire.h" +#include "base/tile.h" +#include "base/tile-manager.h" + #include "core/gimpdrawable.h" #include "core/gimpimage.h" @@ -102,8 +105,6 @@ #include "gimpprogress.h" #include "gimprc.h" #include "plug_in.h" -#include "tile.h" -#include "tile_manager.h" #include "libgimp/gimpintl.h" diff --git a/app/plug-in/plug-in-progress.c b/app/plug-in/plug-in-progress.c index 2b9b8afa01..37a596f9d2 100644 --- a/app/plug-in/plug-in-progress.c +++ b/app/plug-in/plug-in-progress.c @@ -85,6 +85,9 @@ #include "libgimp/gimpprotocol.h" #include "libgimp/gimpwire.h" +#include "base/tile.h" +#include "base/tile-manager.h" + #include "core/gimpdrawable.h" #include "core/gimpimage.h" @@ -102,8 +105,6 @@ #include "gimpprogress.h" #include "gimprc.h" #include "plug_in.h" -#include "tile.h" -#include "tile_manager.h" #include "libgimp/gimpintl.h" diff --git a/app/plug-in/plug-in-run.c b/app/plug-in/plug-in-run.c index 2b9b8afa01..37a596f9d2 100644 --- a/app/plug-in/plug-in-run.c +++ b/app/plug-in/plug-in-run.c @@ -85,6 +85,9 @@ #include "libgimp/gimpprotocol.h" #include "libgimp/gimpwire.h" +#include "base/tile.h" +#include "base/tile-manager.h" + #include "core/gimpdrawable.h" #include "core/gimpimage.h" @@ -102,8 +105,6 @@ #include "gimpprogress.h" #include "gimprc.h" #include "plug_in.h" -#include "tile.h" -#include "tile_manager.h" #include "libgimp/gimpintl.h" diff --git a/app/plug-in/plug-in-shm.c b/app/plug-in/plug-in-shm.c index 2b9b8afa01..37a596f9d2 100644 --- a/app/plug-in/plug-in-shm.c +++ b/app/plug-in/plug-in-shm.c @@ -85,6 +85,9 @@ #include "libgimp/gimpprotocol.h" #include "libgimp/gimpwire.h" +#include "base/tile.h" +#include "base/tile-manager.h" + #include "core/gimpdrawable.h" #include "core/gimpimage.h" @@ -102,8 +105,6 @@ #include "gimpprogress.h" #include "gimprc.h" #include "plug_in.h" -#include "tile.h" -#include "tile_manager.h" #include "libgimp/gimpintl.h" diff --git a/app/plug-in/plug-in.c b/app/plug-in/plug-in.c index 2b9b8afa01..37a596f9d2 100644 --- a/app/plug-in/plug-in.c +++ b/app/plug-in/plug-in.c @@ -85,6 +85,9 @@ #include "libgimp/gimpprotocol.h" #include "libgimp/gimpwire.h" +#include "base/tile.h" +#include "base/tile-manager.h" + #include "core/gimpdrawable.h" #include "core/gimpimage.h" @@ -102,8 +105,6 @@ #include "gimpprogress.h" #include "gimprc.h" #include "plug_in.h" -#include "tile.h" -#include "tile_manager.h" #include "libgimp/gimpintl.h" diff --git a/app/plug-in/plug-ins.c b/app/plug-in/plug-ins.c index 2b9b8afa01..37a596f9d2 100644 --- a/app/plug-in/plug-ins.c +++ b/app/plug-in/plug-ins.c @@ -85,6 +85,9 @@ #include "libgimp/gimpprotocol.h" #include "libgimp/gimpwire.h" +#include "base/tile.h" +#include "base/tile-manager.h" + #include "core/gimpdrawable.h" #include "core/gimpimage.h" @@ -102,8 +105,6 @@ #include "gimpprogress.h" #include "gimprc.h" #include "plug_in.h" -#include "tile.h" -#include "tile_manager.h" #include "libgimp/gimpintl.h" diff --git a/app/plug_in.c b/app/plug_in.c index 2b9b8afa01..37a596f9d2 100644 --- a/app/plug_in.c +++ b/app/plug_in.c @@ -85,6 +85,9 @@ #include "libgimp/gimpprotocol.h" #include "libgimp/gimpwire.h" +#include "base/tile.h" +#include "base/tile-manager.h" + #include "core/gimpdrawable.h" #include "core/gimpimage.h" @@ -102,8 +105,6 @@ #include "gimpprogress.h" #include "gimprc.h" #include "plug_in.h" -#include "tile.h" -#include "tile_manager.h" #include "libgimp/gimpintl.h" diff --git a/app/scan_convert.c b/app/scan_convert.c index 513dc4c165..b290cd8492 100644 --- a/app/scan_convert.c +++ b/app/scan_convert.c @@ -26,10 +26,11 @@ #include "core/core-types.h" +#include "base/pixel-region.h" + #include "core/gimpchannel.h" #include "core/gimpimage.h" -#include "pixel_region.h" #include "scan_convert.h" diff --git a/app/selection.c b/app/selection.c index f5fae7004b..22732ce038 100644 --- a/app/selection.c +++ b/app/selection.c @@ -22,10 +22,11 @@ #include "core/core-types.h" +#include "base/boundary.h" + #include "core/gimpimage.h" #include "core/gimpimage-mask.h" -#include "boundary.h" #include "colormaps.h" #include "gdisplay.h" #include "gdisplay_ops.h" diff --git a/app/temp_buf.c b/app/temp_buf.c deleted file mode 100644 index 5de3444d6b..0000000000 --- a/app/temp_buf.c +++ /dev/null @@ -1,739 +0,0 @@ -/* The GIMP -- an 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 2 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, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -#include "config.h" - -#include - -#include -#include -#include -#ifdef HAVE_UNISTD_H -#include -#endif -#include -#include -#include - -#ifdef G_OS_WIN32 -#include /* For _getpid() */ -#endif - -#include "libgimpcolor/gimpcolor.h" - -#include "core/core-types.h" - -#include "paint-funcs/paint-funcs.h" - -#include "core/gimpimage.h" - -#include "gimprc.h" -#include "pixel_region.h" -#include "temp_buf.h" -#include "image_render.h" - - -static guchar * temp_buf_allocate (guint); -static void temp_buf_to_color (TempBuf *src_buf, - TempBuf *dest_buf); -static void temp_buf_to_gray (TempBuf *src_buf, - TempBuf *dest_buf); - - -/* Memory management */ - -static guchar * -temp_buf_allocate (guint size) -{ - guchar *data; - - data = g_new (guchar, size); - - return data; -} - - -/* The conversion routines */ - -static void -temp_buf_to_color (TempBuf *src_buf, - TempBuf *dest_buf) -{ - guchar *src; - guchar *dest; - glong num_bytes; - - src = temp_buf_data (src_buf); - dest = temp_buf_data (dest_buf); - - num_bytes = src_buf->width * src_buf->height; - - while (num_bytes--) - { - guchar tmpch; - *dest++ = *src++; /* alpha channel */ - *dest++ = tmpch = *src++; - *dest++ = tmpch; - *dest++ = tmpch; - } -} - - -static void -temp_buf_to_gray (TempBuf *src_buf, - TempBuf *dest_buf) -{ - guchar *src; - guchar *dest; - glong num_bytes; - gfloat pix; - - src = temp_buf_data (src_buf); - dest = temp_buf_data (dest_buf); - - num_bytes = src_buf->width * src_buf->height; - - while (num_bytes--) - { - *dest++ = *src++; /* alpha channel */ - - pix = INTENSITY (*src++, *src++, *src++); - - *dest++ = (guchar) pix; - } -} - -TempBuf * -temp_buf_new (gint width, - gint height, - gint bytes, - gint x, - gint y, - guchar *col) -{ - glong i; - gint j; - guchar *data; - TempBuf *temp; - - temp = g_new (TempBuf, 1); - - temp->width = width; - temp->height = height; - temp->bytes = bytes; - temp->x = x; - temp->y = y; - temp->swapped = FALSE; - temp->filename = NULL; - - temp->data = data = temp_buf_allocate (width * height * bytes); - - /* initialize the data */ - if (col) - { - /* First check if we can save a lot of work */ - if (bytes == 1) - { - memset (data, *col, width * height); - } - else if ((bytes == 3) && (col[1] == *col) && (*col == col[2])) - { - memset (data, *col, width * height * 3); - } - else if ((bytes == 4) && - (col[1] == *col) && (*col == col[2]) && (col[2] == col[3])) - { - memset (data, *col, (width * height) << 2); - } - else - { - /* No, we cannot */ - guchar *dptr; - - /* Fill the first row */ - dptr = data; - - for (i = width - 1; i >= 0; --i) - { - guchar *init; - - j = bytes; - init = col; - - while (j--) - *dptr++ = *init++; - } - - /* Now copy from it (we set bytes to bytesperrow now) */ - bytes *= width; - - while (--height) - { - memcpy (dptr, data, bytes); - dptr += bytes; - } - } - } - - return temp; -} - -/* This function simply renders a checkerboard with the given - parameters into a newly allocated tempbuf */ - -TempBuf * -temp_buf_new_check (gint width, - gint height, - GimpCheckType check_type, - GimpCheckSize check_size) -{ - TempBuf *newbuf = NULL; - guchar *data = 0; - guchar check_shift = 0; - guchar fg_color = 0; - guchar bg_color = 0; - gint j, i = 0; - - if (check_type < LIGHT_CHECKS || check_type > BLACK_ONLY) - g_error ("invalid check_type argument to temp_buf_check: %d", check_type); - if (check_size < SMALL_CHECKS || check_size > LARGE_CHECKS) - g_error ("invalid check_size argument to temp_buf_check: %d", check_size); - - switch (check_size) - { - case SMALL_CHECKS: - check_shift = 2; - break; - case MEDIUM_CHECKS: - check_shift = 4; - break; - case LARGE_CHECKS: - check_shift = 6; - } - - switch (check_type) - { - case LIGHT_CHECKS: - fg_color = 204; - bg_color = 255; - break; - case GRAY_CHECKS: - fg_color = 102; - bg_color = 153; - break; - case DARK_CHECKS: - fg_color = 0; - bg_color = 51; - break; - case WHITE_ONLY: - fg_color = 255; - bg_color = 255; - break; - case GRAY_ONLY: - fg_color = 127; - bg_color = 127; - break; - case BLACK_ONLY: - fg_color = 0; - bg_color = 0; - } - - newbuf = temp_buf_new (width, height, 3, 0, 0, NULL); - data = temp_buf_data (newbuf); - - for (j = 1; i <= height; j++) - { - for (i = 1; i <= width; i++) - { - *(data + i - 1) = ((j & check_shift) && (i & check_shift)) - ? fg_color : bg_color; - } - } - - return newbuf; -} - -TempBuf * -temp_buf_copy (TempBuf *src, - TempBuf *dest) -{ - TempBuf *new; - glong length; - - if (!src) - { - g_message ("trying to copy a temp buf which is NULL."); - return dest; - } - - if (!dest) - { - new = temp_buf_new (src->width, src->height, src->bytes, 0, 0, NULL); - } - else - { - new = dest; - if (dest->width != src->width || dest->height != src->height) - g_message ("In temp_buf_copy, the widths or heights don't match."); - /* The temp buf is smart, and can translate between color and gray */ - /* (only necessary if not we allocated it */ - if (src->bytes != new->bytes) - { - if (src->bytes == 4) /* RGB color */ - temp_buf_to_gray (src, new); - else if (src->bytes == 2) /* grayscale */ - temp_buf_to_color (src, new); - else - g_message ("Cannot convert from indexed color."); - - return new; - } - } - - /* make the copy */ - length = src->width * src->height * src->bytes; - memcpy (temp_buf_data (new), temp_buf_data (src), length); - - return new; -} - -TempBuf * -temp_buf_resize (TempBuf *buf, - gint bytes, - gint x, - gint y, - gint width, - gint height) -{ - gint size; - - /* calculate the requested size */ - size = width * height * bytes; - - /* First, configure the canvas buffer */ - if (!buf) - { - buf = temp_buf_new (width, height, bytes, x, y, NULL); - } - else - { - if (size != (buf->width * buf->height * buf->bytes)) - { - /* Make sure the temp buf is unswapped */ - temp_buf_unswap (buf); - - /* Reallocate the data for it */ - buf->data = g_realloc (buf->data, size); - } - - /* Make sure the temp buf fields are valid */ - buf->x = x; - buf->y = y; - buf->width = width; - buf->height = height; - buf->bytes = bytes; - } - - return buf; -} - -TempBuf * -temp_buf_scale (TempBuf *src, - gint new_width, - gint new_height) -{ - gint loop1; - gint loop2; - gdouble x_ratio; - gdouble y_ratio; - guchar *src_data; - guchar *dest_data; - TempBuf *dest; - - dest = temp_buf_new (new_width, - new_height, - src->bytes, - 0, 0, NULL); - - src_data = temp_buf_data (src); - dest_data = temp_buf_data (dest); - - x_ratio = (gdouble) src->width / (gdouble) new_width; - y_ratio = (gdouble) src->height / (gdouble) new_height; - - for (loop1 = 0 ; loop1 < new_height ; loop1++) - { - for (loop2 = 0 ; loop2 < new_width ; loop2++) - { - gint i; - guchar *src_pixel; - guchar *dest_pixel; - - src_pixel = src_data + - (gint) (loop2 * x_ratio) * src->bytes + - (gint) (loop1 * y_ratio) * src->bytes * src->width; - - dest_pixel = dest_data + - (loop2 + loop1 * new_width) * src->bytes; - - for (i = 0 ; i < src->bytes; i++) - *dest_pixel++ = *src_pixel++; - } - } - - return dest; -} - -TempBuf * -temp_buf_copy_area (TempBuf *src, - TempBuf *dest, - gint x, - gint y, - gint width, - gint height, - gint dest_x, - gint dest_y) -{ - TempBuf *new; - PixelRegion srcR, destR; - guchar empty[MAX_CHANNELS] = { 0, 0, 0, 0 }; - gint x1, y1, x2, y2; - - g_return_val_if_fail (src != NULL, dest); - g_return_val_if_fail (!dest || dest->bytes == src->bytes, dest); - - g_return_val_if_fail (width + dest_x > 0, dest); - g_return_val_if_fail (height + dest_y > 0, dest); - - g_return_val_if_fail (!dest || dest->width >= width + dest_x, dest); - g_return_val_if_fail (!dest || dest->height >= height + dest_y, dest); - - /* some bounds checking */ - x1 = CLAMP (x, 0, src->width - 1); - y1 = CLAMP (y, 0, src->height - 1); - x2 = CLAMP (x + width - 1, 0, src->width - 1); - y2 = CLAMP (y + height - 1, 0, src->height - 1); - - if (!(x2 - x1) || !(y2 - y1)) - return dest; - - width = x2 - x1 + 1; - height = y2 - y1 + 1; - - if (! dest) - { - new = temp_buf_new (width + dest_x, - height + dest_y, - src->bytes, - 0, 0, - empty); - } - else - { - new = dest; - } - - /* Copy the region */ - srcR.bytes = src->bytes; - srcR.w = width; - srcR.h = height; - srcR.rowstride = src->bytes * src->width; - srcR.data = (temp_buf_data (src) + - y1 * srcR.rowstride + - x1 * srcR.bytes); - - destR.bytes = dest->bytes; - destR.rowstride = new->bytes * new->width; - destR.data = (temp_buf_data (new) + - dest_y * destR.rowstride + - dest_x * destR.bytes); - - copy_region (&srcR, &destR); - - return new; -} - -void -temp_buf_free (TempBuf *temp_buf) -{ if (temp_buf->data) - g_free (temp_buf->data); - - if (temp_buf->swapped) - temp_buf_swap_free (temp_buf); - - g_free (temp_buf); -} - -guchar * -temp_buf_data (TempBuf *temp_buf) -{ - if (temp_buf->swapped) - temp_buf_unswap (temp_buf); - - return temp_buf->data; -} - -guchar * -temp_buf_data_clear (TempBuf *temp_buf) -{ - if (temp_buf->swapped) - temp_buf_unswap (temp_buf); - - memset (temp_buf->data, 0, - temp_buf->height * temp_buf->width * temp_buf->bytes); - - return temp_buf->data; -} - -/****************************************************************** - * Mask buffer functions * - ******************************************************************/ - - -MaskBuf * -mask_buf_new (gint width, - gint height) -{ - static guchar empty = 0; - - return temp_buf_new (width, height, 1, 0, 0, &empty); -} - -void -mask_buf_free (MaskBuf *mask) -{ - temp_buf_free ((TempBuf *) mask); -} - -guchar * -mask_buf_data (MaskBuf *mask_buf) -{ - return temp_buf_data ((TempBuf *) mask_buf); -} - -guchar * -mask_buf_data_clear (MaskBuf *mask_buf) -{ - return temp_buf_data_clear ((TempBuf *) mask_buf); -} - - -/****************************************************************** - * temp buffer disk caching functions * - ******************************************************************/ - -/* NOTES: - * Disk caching is setup as follows: - * On a call to temp_buf_swap, the TempBuf parameter is stored - * in a temporary variable called cached_in_memory. - * On the next call to temp_buf_swap, if cached_in_memory is non-null, - * cached_in_memory is moved to disk, and the latest TempBuf parameter - * is stored in cached_in_memory. This method keeps the latest TempBuf - * structure in memory instead of moving it directly to disk as requested. - * On a call to temp_buf_unswap, if cached_in_memory is non-null, it is - * compared against the requested TempBuf. If they are the same, nothing - * must be moved in from disk since it still resides in memory. However, - * if the two pointers are different, the requested TempBuf is retrieved - * from disk. In the former case, cached_in_memory is set to NULL; - * in the latter case, cached_in_memory is left unchanged. - * If temp_buf_swap_free is called, cached_in_memory must be checked - * against the temp buf being freed. If they are the same, then - * cached_in_memory must be set to NULL; - * - * In the case where memory usage is set to "stingy": - * temp bufs are not cached in memory at all, they go right to disk. - */ - - -/* a static counter for generating unique filenames */ -static gint swap_index = 0; - -/* a static pointer which keeps track of the last request for a swapped buffer */ -static TempBuf * cached_in_memory = NULL; - - -static gchar * -generate_unique_filename (void) -{ - pid_t pid; - - pid = getpid (); - return g_strdup_printf ("%s" G_DIR_SEPARATOR_S "gimp%d.%d", - temp_path, (int) pid, swap_index++); -} - -void -temp_buf_swap (TempBuf *buf) -{ - TempBuf *swap; - gchar *filename; - struct stat stat_buf; - gint err; - FILE *fp; - - if (!buf || buf->swapped) - return; - - /* Set the swapped flag */ - buf->swapped = TRUE; - - if (stingy_memory_use) - swap = buf; - else - { - swap = cached_in_memory; - cached_in_memory = buf; - } - - /* For the case where there is no temp buf ready to be moved to disk, return */ - if (!swap) - return; - - /* Get a unique filename for caching the data to a UNIX file */ - filename = generate_unique_filename (); - - /* Check if generated filename is valid */ - err = stat (filename, &stat_buf); - if (!err) - { - if (stat_buf.st_mode & S_IFDIR) - { - g_message ("Error in temp buf caching: \"%s\" is a directory (cannot overwrite)", filename); - g_free (filename); - return; - } - } - - /* Open file for overwrite */ - if ((fp = fopen (filename, "wb"))) - { - size_t blocks_written; - blocks_written = fwrite (swap->data, swap->width * swap->height * swap->bytes, 1, fp); - /* Check whether all bytes were written and fclose() was able to flush its buffers */ - if ((0 != fclose (fp)) || (1 != blocks_written)) - { - (void) unlink (filename); - perror ("Write error on temp buf"); - g_message ("Cannot write \"%s\"", filename); - g_free (filename); - return; - } - } - else - { - (void) unlink (filename); - perror ("Error in temp buf caching"); - g_message ("Cannot write \"%s\"", filename); - g_free (filename); - return; - } - /* Finally, free the buffer's data */ - g_free (swap->data); - swap->data = NULL; - - swap->filename = filename; -} - -void -temp_buf_unswap (TempBuf *buf) -{ - struct stat stat_buf; - FILE *fp; - gboolean succ = FALSE; - - if (!buf || !buf->swapped) - return; - - /* Set the swapped flag */ - buf->swapped = FALSE; - - /* If the requested temp buf is still in memory, simply return */ - if (cached_in_memory == buf) - { - cached_in_memory = NULL; - return; - } - - /* Allocate memory for the buffer's data */ - buf->data = temp_buf_allocate (buf->width * buf->height * buf->bytes); - - /* Find out if the filename of the swapped data is an existing file... */ - /* (buf->filname HAS to be != 0 */ - if (!stat (buf->filename, &stat_buf)) - { - if ((fp = fopen (buf->filename, "rb"))) - { - size_t blocks_read; - blocks_read = fread (buf->data, buf->width * buf->height * buf->bytes, 1, fp); - (void) fclose (fp); - if (blocks_read != 1) - perror ("Read error on temp buf"); - else - succ = TRUE; - } - else - perror ("Error in temp buf caching"); - - /* Delete the swap file */ - unlink (buf->filename); - } - if (!succ) - g_message ("Error in temp buf caching: information swapped to disk was lost!"); - - g_free (buf->filename); /* free filename */ - buf->filename = NULL; -} - -void -temp_buf_swap_free (TempBuf *buf) -{ - struct stat stat_buf; - - if (!buf->swapped) - return; - - /* Set the swapped flag */ - buf->swapped = FALSE; - - /* If the requested temp buf is cached in memory... */ - if (cached_in_memory == buf) - { - cached_in_memory = NULL; - return; - } - - /* Find out if the filename of the swapped data is an existing file... */ - if (!stat (buf->filename, &stat_buf)) - { - /* Delete the swap file */ - unlink (buf->filename); - } - else - g_message ("Error in temp buf disk swapping: information swapped to disk was lost!"); - - if (buf->filename) - g_free (buf->filename); /* free filename */ - buf->filename = NULL; -} - -void -swapping_free (void) -{ - if (cached_in_memory) - temp_buf_free (cached_in_memory); -} diff --git a/app/temp_buf.h b/app/temp_buf.h deleted file mode 100644 index 0166d0288a..0000000000 --- a/app/temp_buf.h +++ /dev/null @@ -1,93 +0,0 @@ -/* The GIMP -- an 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 2 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, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -#ifndef __TEMP_BUF_H__ -#define __TEMP_BUF_H__ - -#include "gimpchecks.h" - -struct _TempBuf -{ - gint bytes; /* The necessary info */ - gint width; - gint height; - gint x, y; /* origin of data source */ - - gboolean swapped; /* flag indicating whether buf is cached to disk */ - gchar *filename; /* filename of cached information */ - - guchar *data; /* The data buffer */ -}; - - -/* The temp buffer functions */ - -TempBuf * temp_buf_new (gint width, - gint height, - gint bytes, - gint x, - gint y, - guchar *col); -TempBuf * temp_buf_new_check (gint width, - gint height, - GimpCheckType check_type, - GimpCheckSize check_size); -TempBuf * temp_buf_copy (TempBuf *src, - TempBuf *dest); -TempBuf * temp_buf_resize (TempBuf *buf, - gint bytes, - gint x, - gint y, - gint width, - gint height); -TempBuf * temp_buf_scale (TempBuf *buf, - gint width, - gint height); -TempBuf * temp_buf_copy_area (TempBuf *src, - TempBuf *dest, - gint x, - gint y, - gint width, - gint height, - gint dest_x, - gint dest_y); -void temp_buf_free (TempBuf *buf); -guchar * temp_buf_data (TempBuf *buf); -guchar * temp_buf_data_clear (TempBuf *buf); - -/* The mask buffer functions */ - -MaskBuf * mask_buf_new (gint width, - gint height); -void mask_buf_free (MaskBuf *mask_buf); -guchar * mask_buf_data (MaskBuf *mask_buf); -guchar * mask_buf_data_clear (MaskBuf *mask_buf); - -/* The disk caching functions */ - -void temp_buf_swap (TempBuf *buf); -void temp_buf_unswap (TempBuf *buf); -void temp_buf_swap_free (TempBuf *buf); - - -/* Called by app_procs:exit() to free up the cached undo buffer */ - -void swapping_free (void); - - -#endif /* __TEMP_BUF_H__ */ diff --git a/app/tile.c b/app/tile.c deleted file mode 100644 index 5431b2a89c..0000000000 --- a/app/tile.c +++ /dev/null @@ -1,403 +0,0 @@ -/* The GIMP -- an 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 2 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, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -#include "config.h" - -#include - -#include "apptypes.h" - -#include "tile.h" -#include "tile_pvt.h" -#include "tile_cache.h" -#include "tile_manager.h" -#include "tile_swap.h" - - -static void tile_destroy (Tile *tile); - - -gint tile_count = 0; - - -void -tile_sanitize_rowhints (Tile *tile) -{ - gint height, y; - - /* If tile has rowhints array already, do nothing. */ - if (tile->rowhint) - return; - - height = tile->eheight; - - tile->rowhint = g_new (TileRowHint, height); - - for (y=0; yrowhint[y] = TILEROWHINT_UNKNOWN; - } -} - -TileRowHint -tile_get_rowhint (Tile *tile, - gint yoff) -{ -#ifdef HINTS_SANITY - if (yoff < tile_eheight(tile) && yoff>=0) - { - return tile->rowhint[yoff]; - } - else - g_error("GET_ROWHINT OUT OF RANGE"); - return TILEROWHINT_OUTOFRANGE; -#else - return tile->rowhint[yoff]; -#endif -} - -void -tile_set_rowhint (Tile *tile, - gint yoff, - TileRowHint rowhint) -{ -#ifdef HINTS_SANITY - if (yoff < tile_eheight(tile) && yoff>=0) - { - tile->rowhint[yoff] = rowhint; - } - else - g_error("SET_ROWHINT OUT OF RANGE"); -#else - tile->rowhint[yoff] = rowhint; -#endif -} - -void -tile_init (Tile *tile, - gint bpp) -{ - tile->ref_count = 0; - tile->write_count = 0; - tile->share_count = 0; - tile->dirty = FALSE; - tile->valid = FALSE; - tile->data = NULL; - tile->ewidth = TILE_WIDTH; - tile->eheight = TILE_HEIGHT; - tile->bpp = bpp; - tile->swap_num = 1; - tile->swap_offset = -1; - tile->tlink = NULL; - tile->next = NULL; - tile->prev = NULL; - tile->listhead = NULL; - tile->rowhint = NULL; - -#ifdef USE_PTHREADS - { - pthread_mutex_init (&tile->mutex, NULL); - } -#endif - - tile_count++; -} - -gint tile_ref_count = 0; -gint tile_share_count = 0; -gint tile_active_count = 0; - -#ifdef HINTS_SANITY -gint tile_exist_peak = 0; -gint tile_exist_count = 0; -#endif - -void -tile_lock (Tile *tile) -{ - /* Increment the global reference count. - */ - tile_ref_count++; - - /* Increment this tile's reference count. - */ - - TILE_MUTEX_LOCK (tile); - tile->ref_count++; - - if (tile->ref_count == 1) - { - if (tile->listhead) - { - /* remove from cache, move to main store */ - tile_cache_flush (tile); - } - tile_active_count++; - } - if (tile->data == NULL) - { - /* There is no data, so the tile must be swapped out */ - tile_swap_in (tile); - } - - TILE_MUTEX_UNLOCK (tile); - - /* Call 'tile_manager_validate' if the tile was invalid. - */ - if (!tile->valid) - { - /* an invalid tile should never be shared, so this should work */ - tile_manager_validate ((TileManager*) tile->tlink->tm, tile); - } -} - -void -tile_release (Tile *tile, - gboolean dirty) -{ - /* Decrement the global reference count. - */ - tile_ref_count--; - - TILE_MUTEX_LOCK (tile); - - /* Decrement this tile's reference count. - */ - tile->ref_count--; - - /* Decrement write ref count if dirtying - */ - if (dirty) - { - gint y; - - tile->write_count--; - - if (tile->rowhint) - { - for (y = 0; y < tile->eheight; y++) - { - tile->rowhint[y] = TILEROWHINT_UNKNOWN; - } - } - } - - if (tile->ref_count == 0) - { - tile_active_count--; - - if (tile->share_count == 0) - { - /* tile is truly dead */ - tile_destroy (tile); - return; /* skip terminal unlock */ - } - else - { - /* last reference was just released, so move the tile to the - tile cache */ - tile_cache_insert (tile); - } - } - - TILE_MUTEX_UNLOCK (tile); -} - -void -tile_alloc (Tile *tile) -{ - if (tile->data) - return; - - /* Allocate the data for the tile. - */ - tile->data = g_new (guchar, tile_size (tile)); - -#ifdef HINTS_SANITY - tile_exist_count++; - if (tile_exist_count > tile_exist_peak) - tile_exist_peak = tile_exist_count; -#endif -} - -static void -tile_destroy (Tile *tile) -{ - if (tile->ref_count) - { - g_warning ("tried to destroy a ref'd tile"); - return; - } - if (tile->share_count) - { - g_warning ("tried to destroy an attached tile"); - return; - } - if (tile->data) - { - g_free (tile->data); - tile->data = NULL; - } - if (tile->rowhint) - { - g_free (tile->rowhint); - tile->rowhint = NULL; - } - if (tile->swap_offset != -1) - { - /* If the tile is on disk, then delete its - * presence there. - */ - tile_swap_delete (tile); - } - if (tile->listhead) - tile_cache_flush (tile); - - TILE_MUTEX_UNLOCK (tile); - g_free (tile); - - tile_count--; - -#ifdef HINTS_SANITY - tile_exist_count--; -#endif -} - -gint -tile_size (Tile *tile) -{ - /* Return the actual size of the tile data. - * (Based on its effective width and height). - */ - return tile->ewidth * tile->eheight * tile->bpp; -} - -gint -tile_ewidth (Tile *tile) -{ - return tile->ewidth; -} - -gint -tile_eheight (Tile *tile) -{ - return tile->eheight; -} - -gint -tile_bpp (Tile *tile) -{ - return tile->bpp; -} - -gint -tile_is_valid (Tile *tile) -{ - return tile->valid; -} - -void -tile_mark_valid (Tile *tile) -{ - TILE_MUTEX_LOCK (tile); - tile->valid = TRUE; - TILE_MUTEX_UNLOCK (tile); -} - -void -tile_attach (Tile *tile, - void *tm, - gint tile_num) -{ - TileLink *tmp; - - if ((tile->share_count > 0) && (!tile->valid)) - { - /* trying to share invalid tiles is problematic, not to mention silly */ - tile_manager_validate ((TileManager*) tile->tlink->tm, tile); - } - - tile->share_count++; - tile_share_count++; - -#ifdef TILE_DEBUG - g_print("tile_attach: %p -> (%p,%d) *%d\n", tile, tm, tile_num, tile->share_count); -#endif - - /* link this tile into the tile's tilelink chain */ - tmp = g_new (TileLink, 1); - tmp->tm = tm; - tmp->tile_num = tile_num; - tmp->next = tile->tlink; - - tile->tlink = tmp; -} - -void -tile_detach (Tile *tile, - void *tm, - gint tile_num) -{ - TileLink **link; - TileLink *tmp; - -#ifdef TILE_DEBUG - g_print("tile_detach: %p ~> (%p,%d) r%d *%d\n", tile, tm, tile_num, - tile->ref_count, tile->share_count); -#endif - - for (link = &tile->tlink; - *link != NULL; - link = &(*link)->next) - { - if (((*link)->tm == tm) && ((*link)->tile_num == tile_num)) - break; - } - - if (*link == NULL) - { - g_warning ("Tried to detach a nonattached tile -- TILE BUG!"); - return; - } - - tmp = *link; - *link = tmp->next; - g_free (tmp); - - tile_share_count--; - tile->share_count--; - - if (tile->share_count == 0 && tile->ref_count == 0) - { - tile_destroy (tile); - return; - } - TILE_MUTEX_UNLOCK (tile); -} - -gpointer -tile_data_pointer (Tile *tile, - gint xoff, - gint yoff) -{ - gint offset; - - offset = yoff * tile->ewidth + xoff; - - return (gpointer) (tile->data + offset * tile->bpp); -} diff --git a/app/tile.h b/app/tile.h deleted file mode 100644 index e89236282f..0000000000 --- a/app/tile.h +++ /dev/null @@ -1,110 +0,0 @@ -/* The GIMP -- an 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 2 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, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -#ifndef __TILE_H__ -#define __TILE_H__ - - -#define TILE_WIDTH 64 -#define TILE_HEIGHT 64 - -/* Uncomment for verbose debugging on copy-on-write logic -#define TILE_DEBUG -*/ - -/* sanity checking on new tile hinting code */ -/* #define HINTS_SANITY */ - -/* explicit guchar type rather than enum since gcc chooses an int - * representation but arrays of TileRowHints are quite space-critical - * in GIMP. - */ -typedef guchar TileRowHint; - -#define TILEROWHINT_BROKEN 0 -#define TILEROWHINT_OPAQUE 1 -#define TILEROWHINT_TRANSPARENT 2 -#define TILEROWHINT_MIXED 3 -#define TILEROWHINT_OUTOFRANGE 4 -#define TILEROWHINT_UNDEFINED 5 -#define TILEROWHINT_UNKNOWN 6 - - -/* Initializes the fields of a tile to "good" values. - */ -void tile_init (Tile *tile, - gint bpp); - - -/* - * tile_lock locks a tile into memory. This does what tile_ref used - * to do. It is the responsibility of the tile manager to take care - * of the copy-on-write semantics. Locks stack; a tile remains locked - * in memory as long as it's been locked more times than it has been - * released. tile_release needs to know whether the release was for - * write access. (This is a hack, and should be handled better.) - */ - -void tile_lock (Tile *tile); -void tile_release (Tile *tile, - gboolean dirty); - -/* Allocate the data for the tile. - */ -void tile_alloc (Tile *tile); - -/* Return the size in bytes of the tiles data. - */ -gint tile_size (Tile *tile); - -gint tile_ewidth (Tile *tile); -gint tile_eheight (Tile *tile); -gint tile_bpp (Tile *tile); - -gint tile_is_valid (Tile *tile); - -void tile_mark_valid (Tile *tile); - -/* DOCUMENT ME -- adm */ -TileRowHint tile_get_rowhint (Tile *tile, - gint yoff); -void tile_set_rowhint (Tile *tile, - gint yoff, - TileRowHint rowhint); -void tile_sanitize_rowhints (Tile *tile); - -void * tile_data_pointer (Tile *tile, - gint xoff, - gint yoff); - -/* tile_attach attaches a tile to a tile manager: this function - * increments the tile's share count and inserts a tilelink into the - * tile's link list. tile_detach reverses the process. - * If a tile's share count is zero after a tile_detach, the tile is - * discarded. - */ - -void tile_attach (Tile *tile, - void *tm, - gint tile_num); -void tile_detach (Tile *tile, - void *tm, - gint tile_num); - - -#endif /* __TILE_H__ */ diff --git a/app/tile_cache.c b/app/tile_cache.c deleted file mode 100644 index 21971651e1..0000000000 --- a/app/tile_cache.c +++ /dev/null @@ -1,404 +0,0 @@ -/* The GIMP -- an 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 2 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, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -#include "config.h" - -#ifdef USE_PTHREADS -#include -#endif - -#include - -#include "apptypes.h" - -#include "gimprc.h" -#include "tile.h" -#include "tile_cache.h" -#include "tile_swap.h" -#include "tile_pvt.h" - - -/* This is the percentage of the maximum cache size that should be cleared - * from the cache when an eviction is necessary - */ -#define FREE_QUANTUM 0.1 - -#define IDLE_SWAPPER_TIMEOUT 250 - - -static void tile_cache_init (void); -static gint tile_cache_zorch_next (void); -static void tile_cache_flush_internal (Tile *tile); - -#ifdef USE_PTHREADS -static gpointer tile_idle_thread (gpointer data); -#else -static gint tile_idle_preswap (gpointer data); -#endif - - -static int initialize = TRUE; - -typedef struct _TileList -{ - Tile *first; - Tile *last; -} TileList; - -static unsigned long max_tile_size = TILE_WIDTH * TILE_HEIGHT * 4; -static unsigned long cur_cache_size = 0; -static unsigned long max_cache_size = 0; -static unsigned long cur_cache_dirty = 0; -static TileList clean_list = { NULL, NULL }; -static TileList dirty_list = { NULL, NULL }; - -#ifdef USE_PTHREADS -static pthread_t preswap_thread; -static pthread_mutex_t dirty_mutex = PTHREAD_MUTEX_INITIALIZER; -static pthread_cond_t dirty_signal = PTHREAD_COND_INITIALIZER; -static pthread_mutex_t tile_mutex = PTHREAD_MUTEX_INITIALIZER; -#define CACHE_LOCK pthread_mutex_lock(&tile_mutex) -#define CACHE_UNLOCK pthread_mutex_unlock(&tile_mutex) -#else -static gint idle_swapper = 0; -#define CACHE_LOCK /*nothing*/ -#define CACHE_UNLOCK /*nothing*/ -#endif - - -void -tile_cache_insert (Tile *tile) -{ - TileList *list; - TileList *newlist; - - if (initialize) - tile_cache_init (); - - CACHE_LOCK; - if (tile->data == NULL) goto out; - - /* First check and see if the tile is already - * in the cache. In that case we will simply place - * it at the end of the tile list to indicate that - * it was the most recently accessed tile. - */ - - list = (TileList*)(tile->listhead); - newlist = (tile->dirty || tile->swap_offset == -1) ? &dirty_list : &clean_list; - - /* if list is NULL, the tile is not in the cache */ - - if (list) - { - /* Tile is in the cache. Remove it from its current list and - put it at the tail of the proper list (clean or dirty) */ - - if (tile->next) - tile->next->prev = tile->prev; - else - list->last = tile->prev; - - if (tile->prev) - tile->prev->next = tile->next; - else - list->first = tile->next; - - tile->listhead = NULL; - if (list == &dirty_list) cur_cache_dirty -= tile_size (tile); - } - else - { - /* The tile was not in the cache. First check and see - * if there is room in the cache. If not then we'll have - * to make room first. Note: it might be the case that the - * cache is smaller than the size of a tile in which case - * it won't be possible to put it in the cache. - */ - while ((cur_cache_size + max_tile_size) > max_cache_size) - { - if (!tile_cache_zorch_next()) - { - g_warning ("cache: unable to find room for a tile"); - goto out; - /* goto grump;*/ - } - } - - /*grump:*/ - - /* Note the increase in the number of bytes the cache - * is referencing. - */ - cur_cache_size += tile_size (tile); - } - - /* Put the tile at the end of the proper list */ - - tile->next = NULL; - tile->prev = newlist->last; - tile->listhead = newlist; - - if (newlist->last) newlist->last->next = tile; - else newlist->first = tile; - newlist->last = tile; - - /* gosgood@idt.net 1999-12-04 */ - /* bytes on cur_cache_dirty miscounted in CVS 1.12: */ - /* Invariant: test for selecting dirty list should be the same */ - /* as counting files dirty. */ - - if ((tile->dirty) || ( tile->swap_offset == -1)) - { - cur_cache_dirty += tile_size (tile); - if (1) - { -#ifdef USE_PTHREADS - pthread_mutex_lock(&dirty_mutex); - pthread_cond_signal(&dirty_signal); - pthread_mutex_unlock(&dirty_mutex); -#endif - } - } -out: - CACHE_UNLOCK; - -} - -void -tile_cache_flush (Tile *tile) -{ - if (initialize) - tile_cache_init (); - - CACHE_LOCK; - tile_cache_flush_internal (tile); - CACHE_UNLOCK; -} - -static void -tile_cache_flush_internal (Tile *tile) -{ - TileList *list; - - /* Find where the tile is in the cache. - */ - - list = (TileList*)(tile->listhead); - - if (list) - { - /* Note the decrease in the number of bytes the cache - * is referencing. - */ - cur_cache_size -= tile_size (tile); - if (list == &dirty_list) cur_cache_dirty -= tile_size (tile); - - if (tile->next) - tile->next->prev = tile->prev; - else - list->last = tile->prev; - - if (tile->prev) - tile->prev->next = tile->next; - else - list->first = tile->next; - - tile->listhead = NULL; - } -} - - -/* untested -- ADM */ -void -tile_cache_set_size (gulong cache_size) -{ - if (initialize) - tile_cache_init (); - - max_cache_size = cache_size; - CACHE_LOCK; - while (cur_cache_size > max_cache_size) - { - if (!tile_cache_zorch_next ()) - break; - } - CACHE_UNLOCK; -} - - -static void -tile_cache_init (void) -{ - if (initialize) - { - initialize = FALSE; - - clean_list.first = clean_list.last = NULL; - dirty_list.first = dirty_list.last = NULL; - - max_cache_size = tile_cache_size; - -#ifdef USE_PTHREADS - pthread_create (&preswap_thread, NULL, &tile_idle_thread, NULL); -#else - idle_swapper = gtk_timeout_add (IDLE_SWAPPER_TIMEOUT, - (GtkFunction) tile_idle_preswap, - (gpointer) 0); -#endif - } -} - -static gint -tile_cache_zorch_next (void) -{ - Tile *tile; - - if (clean_list.first) - tile = clean_list.first; - else if (dirty_list.first) - tile = dirty_list.first; - else - return FALSE; - - CACHE_UNLOCK; - TILE_MUTEX_LOCK (tile); - CACHE_LOCK; - tile_cache_flush_internal (tile); - if (tile->dirty || tile->swap_offset == -1) - { - tile_swap_out (tile); - } - - if (! tile->dirty) - { - g_free (tile->data); - tile->data = NULL; - TILE_MUTEX_UNLOCK (tile); - - return TRUE; - } - - /* unable to swap out tile for some reason */ - TILE_MUTEX_UNLOCK (tile); - - return FALSE; -} - -#if USE_PTHREADS -static gpointer -tile_idle_thread (gpointer data) -{ - Tile *tile; - TileList *list; - gint count; - - g_printerr ("starting tile preswapper\n"); - - count = 0; - while (TRUE) - { - CACHE_LOCK; - if (count > 5 || dirty_list.first == NULL) - { - CACHE_UNLOCK; - count = 0; - pthread_mutex_lock (&dirty_mutex); - pthread_cond_wait (&dirty_signal, &dirty_mutex); - pthread_mutex_unlock (&dirty_mutex); - CACHE_LOCK; - } - - if ((tile = dirty_list.first)) - { - CACHE_UNLOCK; - TILE_MUTEX_LOCK (tile); - CACHE_LOCK; - - if (tile->dirty || tile->swap_offset == -1) - { - list = tile->listhead; - - if (list == &dirty_list) cur_cache_dirty -= tile_size (tile); - - if (tile->next) - tile->next->prev = tile->prev; - else - list->last = tile->prev; - - if (tile->prev) - tile->prev->next = tile->next; - else - list->first = tile->next; - - tile->next = NULL; - tile->prev = clean_list.last; - tile->listhead = &clean_list; - - if (clean_list.last) clean_list.last->next = tile; - else clean_list.first = tile; - clean_list.last = tile; - - CACHE_UNLOCK; - - tile_swap_out (tile); - } - else - { - CACHE_UNLOCK; - } - - TILE_MUTEX_UNLOCK (tile); - } - else - { - CACHE_UNLOCK; - } - count++; - } -} - -#else -static gint -tile_idle_preswap (gpointer data) -{ - Tile *tile; - if (cur_cache_dirty*2 < max_cache_size) return TRUE; - if ((tile = dirty_list.first)) - { - tile_swap_out(tile); - - dirty_list.first = tile->next; - if (tile->next) - tile->next->prev = NULL; - else - dirty_list.last = NULL; - - tile->next = NULL; - tile->prev = clean_list.last; - tile->listhead = &clean_list; - if (clean_list.last) clean_list.last->next = tile; - else clean_list.first = tile; - clean_list.last = tile; - cur_cache_dirty -= tile_size (tile); - } - - return TRUE; -} -#endif - diff --git a/app/tile_manager.c b/app/tile_manager.c deleted file mode 100644 index 82980e52e5..0000000000 --- a/app/tile_manager.c +++ /dev/null @@ -1,639 +0,0 @@ -/* The GIMP -- an 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 2 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, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -#include "config.h" - -#include - -#include - -#include "apptypes.h" - -#include "tile.h" -#include "tile_pvt.h" -#include "tile_cache.h" -#include "tile_manager.h" -#include "tile_manager_pvt.h" -#include "tile_swap.h" - - -static gint tile_manager_get_tile_num (TileManager *tm, - gint xpixel, - gint ypixel); - - -TileManager * -tile_manager_new (gint toplevel_width, - gint toplevel_height, - gint bpp) -{ - TileManager *tm; - gint width; - gint height; - - tm = g_new (TileManager, 1); - - tm->user_data = NULL; - tm->validate_proc = NULL; - - width = toplevel_width; - height = toplevel_height; - - tm->x = 0; - tm->y = 0; - tm->width = width; - tm->height = height; - tm->bpp = bpp; - tm->ntile_rows = (height + TILE_HEIGHT - 1) / TILE_HEIGHT; - tm->ntile_cols = (width + TILE_WIDTH - 1) / TILE_WIDTH; - tm->tiles = NULL; - - return tm; -} - -void -tile_manager_destroy (TileManager *tm) -{ - gint ntiles; - gint i; - - g_return_if_fail (tm != NULL); - - if (tm->tiles) - { - ntiles = tm->ntile_rows * tm->ntile_cols; - - for (i = 0; i < ntiles; i++) - { - TILE_MUTEX_LOCK (tm->tiles[i]); - tile_detach (tm->tiles[i], tm, i); - } - - g_free (tm->tiles); - } - - g_free (tm); -} - - -void -tile_manager_set_validate_proc (TileManager *tm, - TileValidateProc proc) -{ - g_return_if_fail (tm != NULL); - - tm->validate_proc = proc; -} - - -Tile * -tile_manager_get_tile (TileManager *tm, - gint xpixel, - gint ypixel, - gint wantread, - gint wantwrite) -{ - gint tile_num; - - g_return_val_if_fail (tm != NULL, NULL); - - tile_num = tile_manager_get_tile_num (tm, xpixel, ypixel); - if (tile_num < 0) - return NULL; - - return tile_manager_get (tm, tile_num, wantread, wantwrite); -} - -Tile * -tile_manager_get (TileManager *tm, - gint tile_num, - gint wantread, - gint wantwrite) -{ - Tile **tiles; - Tile **tile_ptr; - gint ntiles; - gint nrows, ncols; - gint right_tile; - gint bottom_tile; - gint i, j, k; - - g_return_val_if_fail (tm != NULL, NULL); - - ntiles = tm->ntile_rows * tm->ntile_cols; - - if ((tile_num < 0) || (tile_num >= ntiles)) - return NULL; - - if (!tm->tiles) - { - tm->tiles = g_new (Tile *, ntiles); - tiles = tm->tiles; - - nrows = tm->ntile_rows; - ncols = tm->ntile_cols; - - right_tile = tm->width - ((ncols - 1) * TILE_WIDTH); - bottom_tile = tm->height - ((nrows - 1) * TILE_HEIGHT); - - for (i = 0, k = 0; i < nrows; i++) - { - for (j = 0; j < ncols; j++, k++) - { - tiles[k] = g_new (Tile, 1); - tile_init (tiles[k], tm->bpp); - tile_attach (tiles[k], tm, k); - - if (j == (ncols - 1)) - tiles[k]->ewidth = right_tile; - - if (i == (nrows - 1)) - tiles[k]->eheight = bottom_tile; - } - } - } - - tile_ptr = &tm->tiles[tile_num]; - - if (wantwrite && !wantread) - { - g_warning("WRITE-ONLY TILE... UNTESTED!"); - } - - /* - if ((*tile_ptr)->share_count && - (*tile_ptr)->write_count) - fprintf(stderr," >> MEEPITY %d,%d << ", - (*tile_ptr)->share_count, - (*tile_ptr)->write_count - ); */ - - if (wantread) - { - TILE_MUTEX_LOCK (*tile_ptr); - if (wantwrite) - { - if ((*tile_ptr)->share_count > 1) - { - /* Copy-on-write required */ - Tile *newtile = g_new (Tile, 1); - - tile_init (newtile, (*tile_ptr)->bpp); - newtile->ewidth = (*tile_ptr)->ewidth; - newtile->eheight = (*tile_ptr)->eheight; - newtile->valid = (*tile_ptr)->valid; - newtile->data = g_new (guchar, tile_size (newtile)); - - if (!newtile->valid) - g_warning ("Oh boy, r/w tile is invalid... we suck. Please report."); - - if ((*tile_ptr)->rowhint) - { - tile_sanitize_rowhints (newtile); - i = newtile->eheight; - while (i--) - { - newtile->rowhint[i] = (*tile_ptr)->rowhint[i]; - } - } - - if ((*tile_ptr)->data != NULL) - { - memcpy (newtile->data, (*tile_ptr)->data, tile_size (newtile)); - } - else - { - tile_lock (*tile_ptr); - memcpy (newtile->data, (*tile_ptr)->data, tile_size (newtile)); - tile_release (*tile_ptr, FALSE); - } - - tile_detach (*tile_ptr, tm, tile_num); - TILE_MUTEX_LOCK (newtile); - tile_attach (newtile, tm, tile_num); - *tile_ptr = newtile; - } - - (*tile_ptr)->write_count++; - (*tile_ptr)->dirty = TRUE; - } - /* else - { - if ((*tile_ptr)->write_count) - fprintf(stderr,"STINK! r/o on r/w tile /%d\007 ",(*tile_ptr)->write_count); - } */ - TILE_MUTEX_UNLOCK (*tile_ptr); - tile_lock (*tile_ptr); - } - - return *tile_ptr; -} - -void -tile_manager_get_async (TileManager *tm, - gint xpixel, - gint ypixel) -{ - Tile *tile_ptr; - gint tile_num; - - g_return_if_fail (tm != NULL); - - tile_num = tile_manager_get_tile_num (tm, xpixel, ypixel); - if (tile_num < 0) - return; - - tile_ptr = tm->tiles[tile_num]; - - tile_swap_in_async (tile_ptr); -} - -void -tile_manager_validate (TileManager *tm, - Tile *tile) -{ - g_return_if_fail (tm != NULL); - g_return_if_fail (tile != NULL); - - tile->valid = TRUE; - - if (tm->validate_proc) - (* tm->validate_proc) (tm, tile); - -/* DEBUG STUFF -> if (tm->user_data) - { - fprintf(stderr,"V%p ",tm->user_data); - fprintf(stderr,"V"); - } - else - { - fprintf(stderr,"v"); - } */ - -} - -void -tile_manager_invalidate_tiles (TileManager *tm, - Tile *toplevel_tile) -{ - gdouble x, y; - gint row, col; - gint num; - - g_return_if_fail (tm != NULL); - g_return_if_fail (toplevel_tile != NULL); - - col = toplevel_tile->tlink->tile_num % tm->ntile_cols; - row = toplevel_tile->tlink->tile_num / tm->ntile_cols; - - x = (col * TILE_WIDTH + toplevel_tile->ewidth / 2.0) / (gdouble) tm->width; - y = (row * TILE_HEIGHT + toplevel_tile->eheight / 2.0) / (gdouble) tm->height; - - if (tm->tiles) - { - col = x * tm->width / TILE_WIDTH; - row = y * tm->height / TILE_HEIGHT; - num = row * tm->ntile_cols + col; - tile_invalidate (&tm->tiles[num], tm, num); - } -} - - -void -tile_invalidate_tile (Tile **tile_ptr, - TileManager *tm, - gint xpixel, - gint ypixel) -{ - gint tile_num; - - g_return_if_fail (tile_ptr != NULL); - g_return_if_fail (tm != NULL); - - tile_num = tile_manager_get_tile_num (tm, xpixel, ypixel); - if (tile_num < 0) - return; - - tile_invalidate (tile_ptr, tm, tile_num); -} - - -void -tile_invalidate (Tile **tile_ptr, - TileManager *tm, - gint tile_num) -{ - Tile *tile = *tile_ptr; - - g_return_if_fail (tile_ptr != NULL); - g_return_if_fail (tm != NULL); - - TILE_MUTEX_LOCK (tile); - - if (!tile->valid) - goto leave; - - if (tile->share_count > 1) - { - /* This tile is shared. Replace it with a new, invalid tile. */ - Tile *newtile = g_new (Tile, 1); - - tile_init (newtile, tile->bpp); - newtile->ewidth = tile->ewidth; - newtile->eheight = tile->eheight; - tile_detach (tile, tm, tile_num); - TILE_MUTEX_LOCK (newtile); - tile_attach (newtile, tm, tile_num); - tile = *tile_ptr = newtile; - } - - if (tile->listhead) - tile_cache_flush (tile); - - tile->valid = FALSE; - if (tile->data) - { - g_free (tile->data); - tile->data = NULL; - } - if (tile->swap_offset != -1) - { - /* If the tile is on disk, then delete its - * presence there. - */ - tile_swap_delete (tile); - } - -leave: - TILE_MUTEX_UNLOCK (tile); -} - - -void -tile_manager_map_tile (TileManager *tm, - gint xpixel, - gint ypixel, - Tile *srctile) -{ - gint tile_row; - gint tile_col; - gint tile_num; - - g_return_if_fail (tm != NULL); - g_return_if_fail (srctile != NULL); - - if ((xpixel < 0) || (xpixel >= tm->width) || - (ypixel < 0) || (ypixel >= tm->height)) - { - g_warning ("tile_manager_map_tile: tile co-ord out of range."); - return; - } - - tile_row = ypixel / TILE_HEIGHT; - tile_col = xpixel / TILE_WIDTH; - tile_num = tile_row * tm->ntile_cols + tile_col; - - tile_manager_map (tm, tile_num, srctile); -} - -void -tile_manager_map (TileManager *tm, - gint tile_num, - Tile *srctile) -{ - Tile **tiles; - Tile **tile_ptr; - gint ntiles; - gint nrows, ncols; - gint right_tile; - gint bottom_tile; - gint i, j, k; - - g_return_if_fail (tm != NULL); - g_return_if_fail (srctile != NULL); - - ntiles = tm->ntile_rows * tm->ntile_cols; - - if ((tile_num < 0) || (tile_num >= ntiles)) - { - g_warning ("tile_manager_map: tile out of range."); - return; - } - - if (!tm->tiles) - { - g_warning ("tile_manager_map: empty tile level - init'ing."); - - tm->tiles = g_new (Tile *, ntiles); - tiles = tm->tiles; - - nrows = tm->ntile_rows; - ncols = tm->ntile_cols; - - right_tile = tm->width - ((ncols - 1) * TILE_WIDTH); - bottom_tile = tm->height - ((nrows - 1) * TILE_HEIGHT); - - for (i = 0, k = 0; i < nrows; i++) - { - for (j = 0; j < ncols; j++, k++) - { - /* printf(",");fflush(stdout);*/ - - tiles[k] = g_new (Tile, 1); - tile_init (tiles[k], tm->bpp); - tile_attach (tiles[k], tm, k); - - if (j == (ncols - 1)) - tiles[k]->ewidth = right_tile; - - if (i == (nrows - 1)) - tiles[k]->eheight = bottom_tile; - } - } - - /* g_warning ("tile_manager_map: empty tile level - done.");*/ - } - - tile_ptr = &tm->tiles[tile_num]; - - /* printf(")");fflush(stdout);*/ - - if (!srctile->valid) - g_warning("tile_manager_map: srctile not validated yet! please report."); - - TILE_MUTEX_LOCK (*tile_ptr); - if ((*tile_ptr)->ewidth != srctile->ewidth || - (*tile_ptr)->eheight != srctile->eheight || - (*tile_ptr)->bpp != srctile->bpp) - { - g_warning ("tile_manager_map: nonconformant map (%p -> %p)", - srctile, *tile_ptr); - } - tile_detach (*tile_ptr, tm, tile_num); - - - /* printf(">");fflush(stdout);*/ - - TILE_MUTEX_LOCK (srctile); - - /* printf(" [src:%p tm:%p tn:%d] ", srctile, tm, tile_num); fflush(stdout);*/ - - tile_attach (srctile, tm, tile_num); - *tile_ptr = srctile; - - TILE_MUTEX_UNLOCK (srctile); - - /* printf("}");fflush(stdout);*/ -} - -static gint -tile_manager_get_tile_num (TileManager *tm, - gint xpixel, - gint ypixel) -{ - gint tile_row; - gint tile_col; - gint tile_num; - - g_return_val_if_fail (tm != NULL, -1); - - if ((xpixel < 0) || (xpixel >= tm->width) || - (ypixel < 0) || (ypixel >= tm->height)) - return -1; - - tile_row = ypixel / TILE_HEIGHT; - tile_col = xpixel / TILE_WIDTH; - tile_num = tile_row * tm->ntile_cols + tile_col; - - return tile_num; -} - -void -tile_manager_set_user_data (TileManager *tm, - gpointer user_data) -{ - g_return_if_fail (tm != NULL); - - tm->user_data = user_data; -} - -gpointer -tile_manager_get_user_data (const TileManager *tm) -{ - g_return_val_if_fail (tm != NULL, NULL); - - return tm->user_data; -} - -gint -tile_manager_width (const TileManager *tm) -{ - g_return_val_if_fail (tm != NULL, 0); - - return tm->width; -} - -gint -tile_manager_height (const TileManager *tm) -{ - g_return_val_if_fail (tm != NULL, 0); - - return tm->height; -} - -gint -tile_manager_bpp (const TileManager *tm) -{ - g_return_val_if_fail (tm != NULL, 0); - - return tm->bpp; -} - -void -tile_manager_get_offsets (const TileManager *tm, - gint *x, - gint *y) -{ - g_return_if_fail (x!= NULL && y != NULL); - - *x = tm->x; - *y = tm->y; -} - -void -tile_manager_set_offsets (TileManager *tm, - gint x, - gint y) -{ - g_return_if_fail (tm != NULL); - - tm->x = x; - tm->y = y; -} - -void -tile_manager_get_tile_coordinates (TileManager *tm, - Tile *tile, - gint *x, - gint *y) -{ - TileLink *tl; - - g_return_if_fail (tm != NULL); - g_return_if_fail (x != NULL && y != NULL); - - for (tl = tile->tlink; tl; tl = tl->next) - { - if (tl->tm == tm) break; - } - - if (tl == NULL) - { - g_warning ("tile_manager_get_tile_coordinates: tile not attached to manager"); - return; - } - - *x = TILE_WIDTH * (tl->tile_num % tm->ntile_cols); - *y = TILE_HEIGHT * (tl->tile_num / tm->ntile_cols); -} - - -void -tile_manager_map_over_tile (TileManager *tm, - Tile *tile, - Tile *srctile) -{ - TileLink *tl; - - g_return_if_fail (tm != NULL); - g_return_if_fail (tile != NULL); - g_return_if_fail (srctile != NULL); - - for (tl = tile->tlink; tl; tl = tl->next) - { - if (tl->tm == tm) break; - } - - if (tl == NULL) - { - g_warning ("tile_manager_map_over_tile: tile not attached to manager"); - return; - } - - tile_manager_map (tm, tl->tile_num, srctile); -} diff --git a/app/tile_manager.h b/app/tile_manager.h deleted file mode 100644 index e4aa1a05bc..0000000000 --- a/app/tile_manager.h +++ /dev/null @@ -1,125 +0,0 @@ -/* The GIMP -- an 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 2 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, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -#ifndef __TILE_MANAGER_H__ -#define __TILE_MANAGER_H__ - - -/* Creates a new tile manager with the specified - * width for the toplevel. The toplevel sizes is - * used to compute the number of levels and there - * size. Each level is 1/2 the width and height of - * the level above it. - * The toplevel is level 0. The smallest level in the - * hierarchy is "nlevels - 1". That level will be smaller - * than TILE_WIDTH x TILE_HEIGHT - */ -TileManager * tile_manager_new (gint toplevel_width, - gint toplevel_height, - gint bpp); - -/* Destroy a tile manager and all the tiles it contains. - */ -void tile_manager_destroy (TileManager *tm); - -/* Set the validate procedure for the tile manager. - * The validate procedure is called when an invalid tile - * is referenced. If the procedure is NULL, then the tile - * is set to valid and its memory is allocated, but - * not initialized. - */ -void tile_manager_set_validate_proc (TileManager *tm, - TileValidateProc proc); - -/* Get a specified tile from a tile manager. - */ -Tile * tile_manager_get_tile (TileManager *tm, - gint xpixel, - gint ypixel, - gint wantread, - gint wantwrite); - -/* Get a specified tile from a tile manager. - */ -Tile * tile_manager_get (TileManager *tm, - gint tile_num, - gint wantread, - gint wantwrite); - -/* Request that (if possible) the tile at x,y be swapped - * in. This is only a hint to improve performance; no guarantees. - * The tile may be swapped in or otherwise made more accessible - * if it is convenient... - */ -void tile_manager_get_async (TileManager *tm, - gint xpixel, - gint ypixel); - -void tile_manager_map_tile (TileManager *tm, - gint xpixel, - gint ypixel, - Tile *srctile); - -void tile_manager_map (TileManager *tm, - gint time_num, - Tile *srctile); - -/* Validate a tiles memory. - */ -void tile_manager_validate (TileManager *tm, - Tile *tile); - -void tile_invalidate (Tile **tile_ptr, - TileManager *tm, - gint tile_num); -void tile_invalidate_tile (Tile **tile_ptr, - TileManager *tm, - gint xpixel, - gint ypixel); - -/* Given a toplevel tile, this procedure will invalidate - * (set the dirty bit) for this toplevel tile. - */ -void tile_manager_invalidate_tiles (TileManager *tm, - Tile *toplevel_tile); - -void tile_manager_set_user_data (TileManager *tm, - gpointer user_data); -gpointer tile_manager_get_user_data (const TileManager *tm); - -gint tile_manager_width (const TileManager *tm); -gint tile_manager_height (const TileManager *tm); -gint tile_manager_bpp (const TileManager *tm); - -void tile_manager_get_offsets (const TileManager *tm, - gint *x, - gint *y); -void tile_manager_set_offsets (TileManager *tm, - gint x, - gint y); - -void tile_manager_get_tile_coordinates (TileManager *tm, - Tile *tile, - gint *x, - gint *y); - -void tile_manager_map_over_tile (TileManager *tm, - Tile *tile, - Tile *srctile); - -#endif /* __TILE_MANAGER_H__ */ diff --git a/app/tile_manager_pvt.h b/app/tile_manager_pvt.h deleted file mode 100644 index 50b6f423c6..0000000000 --- a/app/tile_manager_pvt.h +++ /dev/null @@ -1,43 +0,0 @@ -/* The GIMP -- an 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 2 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, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -#ifndef __TILE_MANAGER_PVT_H__ -#define __TILE_MANAGER_PVT_H__ - - -struct _TileManager -{ - gint x, y; /* tile manager offsets */ - - gint width; /* the width of the tiled area */ - gint height; /* the height of the tiled area */ - gint bpp; /* the bpp of each tile */ - - gint ntile_rows; /* the number of tiles in each row */ - gint ntile_cols; /* the number of tiles in each columns */ - - Tile **tiles; /* the tiles for this level */ - TileValidateProc validate_proc; /* this proc is called when an attempt - * to get an invalid tile is made. - */ - - gpointer user_data; /* hook for hanging data off of */ -}; - - -#endif /* __TILE_MANAGER_PVT_H__ */ diff --git a/app/tile_pvt.h b/app/tile_pvt.h deleted file mode 100644 index 386696e0fa..0000000000 --- a/app/tile_pvt.h +++ /dev/null @@ -1,84 +0,0 @@ -#ifndef __TILE_PVT_H__ -#define __TILE_PVT_H__ - - -#include "config.h" - -#ifdef USE_PTHREADS -#include -#endif - -#include -#include - - -typedef struct _TileLink TileLink; - -struct _TileLink -{ - TileLink *next; - gint tile_num; /* the number of this tile within the drawable */ - TileManager *tm; /* A pointer to the tile manager for this tile. - * We need this in order to call the tile managers - * validate proc whenever the tile is referenced - * yet invalid. - */ -}; - -struct _Tile -{ - gshort ref_count; /* reference count. when the reference count is - * non-zero then the "data" for this tile must - * be valid. when the reference count for a tile - * is 0 then the "data" for this tile must be - * NULL. - */ - gshort write_count; /* write count: number of references that are - for write access */ - gshort share_count; /* share count: number of tile managers that - hold this tile */ - guint dirty : 1; /* is the tile dirty? has it been modified? */ - guint valid : 1; /* is the tile valid? */ - - guchar bpp; /* the bytes per pixel (1, 2, 3 or 4) */ - gushort ewidth; /* the effective width of the tile */ - gushort eheight; /* the effective height of the tile - * a tile's effective width and height may be smaller - * (but not larger) than TILE_WIDTH and TILE_HEIGHT. - * this is to handle edge tiles of a drawable. - */ - - TileRowHint *rowhint; /* An array of hints for rendering purposes */ - - guchar *data; /* the data for the tile. this may be NULL in which - * case the tile data is on disk. - */ - - gint swap_num; /* the index into the file table of the file to be used - * for swapping. swap_num 1 is always the global - * swap file. - */ - off_t swap_offset; /* the offset within the swap file of the tile data. - * if the tile data is in memory this will be set to -1. - */ - TileLink *tlink; - - Tile *next; - Tile *prev; /* List pointers for the tile cache lists */ - gpointer listhead; /* Pointer to the head of the list this tile is on */ - -#ifdef USE_PTHREADS - pthread_mutex_t mutex; -#endif -}; - -#ifdef USE_PTHREADS -#define TILE_MUTEX_LOCK(tile) pthread_mutex_lock(&((tile)->mutex)) -#define TILE_MUTEX_UNLOCK(tile) pthread_mutex_unlock(&((tile)->mutex)) -#else -#define TILE_MUTEX_LOCK(tile) /* nothing */ -#define TILE_MUTEX_UNLOCK(tile) /* nothing */ -#endif - - -#endif /* __TILE_PVT_H__ */ diff --git a/app/tile_swap.c b/app/tile_swap.c deleted file mode 100644 index 08f5ad02c2..0000000000 --- a/app/tile_swap.c +++ /dev/null @@ -1,919 +0,0 @@ -/* The GIMP -- an 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 2 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, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -#include "config.h" - -#include - -#include /* SEEK_SET */ -#include -#include -#include -#include -#ifdef HAVE_UNISTD_H -#include -#endif -#ifdef USE_PTHREADS -#include -#endif - -#ifdef G_OS_WIN32 -#include -#endif - -#ifndef _O_BINARY -#define _O_BINARY 0 -#endif -#ifndef _O_TEMPORARY -#define _O_TEMPORARY 0 -#endif - -#include "apptypes.h" - -#include "tile.h" -#include "tile_pvt.h" -#include "tile_swap.h" - - -#define MAX_OPEN_SWAP_FILES 16 - -typedef struct _SwapFile SwapFile; -typedef struct _DefSwapFile DefSwapFile; -typedef struct _Gap Gap; -typedef struct _AsyncSwapArgs AsyncSwapArgs; - -struct _SwapFile -{ - gchar *filename; - gint swap_num; - SwapFunc swap_func; - gpointer user_data; - gint fd; -}; - -struct _DefSwapFile -{ - GList *gaps; - glong swap_file_end; - off_t cur_position; -}; - -struct _Gap -{ - glong start; - glong end; -}; - -struct _AsyncSwapArgs -{ - DefSwapFile *def_swap_file; - gint fd; - Tile *tile; -}; - - -static void tile_swap_init (void); -static guint tile_swap_hash (gint *key); -static gint tile_swap_compare (gint *a, - gint *b); -static void tile_swap_command (Tile *tile, - gint command); -static void tile_swap_open (SwapFile *swap_file); - -static gint tile_swap_default (gint fd, - Tile *tile, - gint cmd, - gpointer user_data); -static void tile_swap_default_in (DefSwapFile *def_swap_file, - gint fd, - Tile *tile); -static void tile_swap_default_in_async (DefSwapFile *def_swap_file, - gint fd, - Tile *tile); -static void tile_swap_default_out (DefSwapFile *def_swap_file, - gint fd, - Tile *tile); -static void tile_swap_default_delete (DefSwapFile *def_swap_file, - gint fd, - Tile *tile); -static glong tile_swap_find_offset (DefSwapFile *def_swap_file, - gint fd, - gint bytes); -static void tile_swap_resize (DefSwapFile *def_swap_file, - gint fd, - glong new_size); -static Gap * tile_swap_gap_new (glong start, - glong end); -static void tile_swap_gap_destroy (Gap *gap); -#ifdef USE_PTHREADS -static gpointer tile_swap_in_thread (gpointer); -#endif - - -static gboolean initialize = TRUE; -static GHashTable * swap_files = NULL; -static GList * open_swap_files = NULL; -static gint nopen_swap_files = 0; -static gint next_swap_num = 1; -static glong swap_file_grow = 16 * TILE_WIDTH * TILE_HEIGHT * 4; -#ifdef USE_PTHREADS -static pthread_mutex_t swapfile_mutex = PTHREAD_MUTEX_INITIALIZER; - -/* async_swapin_mutex protects only the list, not the tiles therein */ -static pthread_t swapin_thread; -static pthread_mutex_t async_swapin_mutex = PTHREAD_MUTEX_INITIALIZER; -static pthread_cond_t async_swapin_signal = PTHREAD_COND_INITIALIZER; -static GSList * async_swapin_tiles = NULL; -static GSList * async_swapin_tiles_end = NULL; -#endif - -static gboolean seek_err_msg = TRUE, read_err_msg = TRUE, write_err_msg = TRUE; - - -static void -tile_swap_print_gaps (DefSwapFile *def_swap_file) -{ - GList *gaps; - Gap *gap; - - gaps = def_swap_file->gaps; - while (gaps) - { - gap = gaps->data; - gaps = gaps->next; - - g_print (" %6ld - %6ld\n", gap->start, gap->end); - } -} - -static void -tile_swap_exit1 (gpointer key, - gpointer value, - gpointer data) -{ - extern gint tile_ref_count; - SwapFile *swap_file; - DefSwapFile *def_swap_file; - - if (tile_ref_count != 0) - g_warning ("tile ref count balance: %d\n", tile_ref_count); - - swap_file = value; - if (swap_file->swap_func == tile_swap_default) - { - def_swap_file = swap_file->user_data; - if (def_swap_file->swap_file_end != 0) - { - g_warning ("swap file not empty: \"%s\"\n", swap_file->filename); - tile_swap_print_gaps (def_swap_file); - } - -#if defined (__EMX__) || defined (G_OS_WIN32) - /* should close before unlink */ - if (swap_file->fd > 0) - { - close (swap_file->fd); - swap_file->fd = -1; - } -#endif - unlink (swap_file->filename); - } -} - -void -tile_swap_exit (void) -{ -#ifdef HINTS_SANITY - extern int tile_exist_peak; - - g_printerr ("Tile exist peak was %d Tile structs (%d bytes)", - tile_exist_peak, tile_exist_peak * sizeof(Tile)); -#endif - - if (swap_files) - g_hash_table_foreach (swap_files, tile_swap_exit1, NULL); -} - -gint -tile_swap_add (gchar *filename, - SwapFunc swap_func, - gpointer user_data) -{ - SwapFile *swap_file; - DefSwapFile *def_swap_file; - -#ifdef USE_PTHREADS - pthread_mutex_lock(&swapfile_mutex); -#endif - - if (initialize) - tile_swap_init (); - - swap_file = g_new (SwapFile, 1); - swap_file->filename = g_strdup (filename); - swap_file->swap_num = next_swap_num++; - - if (!swap_func) - { - swap_func = tile_swap_default; - - def_swap_file = g_new (DefSwapFile, 1); - def_swap_file->gaps = NULL; - def_swap_file->swap_file_end = 0; - def_swap_file->cur_position = 0; - - user_data = def_swap_file; - } - - swap_file->swap_func = swap_func; - swap_file->user_data = user_data; - swap_file->fd = -1; - - g_hash_table_insert (swap_files, &swap_file->swap_num, swap_file); - -#ifdef USE_PTHREADS - pthread_mutex_unlock(&swapfile_mutex); -#endif - return swap_file->swap_num; -} - -void -tile_swap_remove (gint swap_num) -{ - SwapFile *swap_file; - -#ifdef USE_PTHREADS - pthread_mutex_lock(&swapfile_mutex); -#endif - - if (initialize) - tile_swap_init (); - - swap_file = g_hash_table_lookup (swap_files, &swap_num); - if (!swap_file) - goto out; - - g_hash_table_remove (swap_files, &swap_num); - - if (swap_file->fd != -1) - close (swap_file->fd); - - g_free (swap_file); -out: -#ifdef USE_PTHREADS - pthread_mutex_unlock(&swapfile_mutex); -#endif - return; -} - -void -tile_swap_in_async (Tile *tile) -{ - if (tile->swap_offset == -1) - return; - - tile_swap_command (tile, SWAP_IN_ASYNC); -} - -void -tile_swap_in (Tile *tile) -{ - if (tile->swap_offset == -1) - { - tile_alloc (tile); - return; - } - - tile_swap_command (tile, SWAP_IN); -} - -void -tile_swap_out (Tile *tile) -{ - tile_swap_command (tile, SWAP_OUT); -} - -void -tile_swap_delete (Tile *tile) -{ - tile_swap_command (tile, SWAP_DELETE); -} - -void -tile_swap_compress (gint swap_num) -{ - tile_swap_command (NULL, SWAP_COMPRESS); -} - -static void -tile_swap_init (void) -{ - - if (initialize) - { - initialize = FALSE; - - swap_files = g_hash_table_new ((GHashFunc) tile_swap_hash, - (GCompareFunc) tile_swap_compare); - -#ifdef NOTDEF /* USE_PTHREADS */ - pthread_create (&swapin_thread, NULL, &tile_swap_in_thread, NULL); -#endif - } -} - -static guint -tile_swap_hash (gint *key) -{ - return (guint) *key; -} - -static gint -tile_swap_compare (gint *a, - gint *b) -{ - return (*a == *b); -} - -static void -tile_swap_command (Tile *tile, - gint command) -{ - SwapFile *swap_file; -#ifdef USE_PTHREADS - pthread_mutex_lock(&swapfile_mutex); -#endif - - if (initialize) - tile_swap_init (); - - do { - swap_file = g_hash_table_lookup (swap_files, &tile->swap_num); - if (!swap_file) - { - g_warning ("could not find swap file for tile"); - goto out; - } - - if (swap_file->fd == -1) - { - tile_swap_open (swap_file); - - if (swap_file->fd == -1) - goto out; - } - } - while ((* swap_file->swap_func) (swap_file->fd, - tile, command, swap_file->user_data)); - -out: -#ifdef USE_PTHREADS - pthread_mutex_unlock(&swapfile_mutex); -#endif - - return; -} - -static void -tile_swap_open (SwapFile *swap_file) -{ - SwapFile *tmp; - - if (swap_file->fd != -1) - return; - - if (nopen_swap_files == MAX_OPEN_SWAP_FILES) - { - tmp = open_swap_files->data; - close (tmp->fd); - tmp->fd = -1; - - open_swap_files = g_list_remove (open_swap_files, open_swap_files->data); - nopen_swap_files -= 1; - } - - swap_file->fd = open (swap_file->filename, - O_CREAT | O_RDWR | _O_BINARY | _O_TEMPORARY, - S_IREAD | S_IWRITE); - - if (swap_file->fd == -1) - { - g_message ("unable to open swap file...BAD THINGS WILL HAPPEN SOON"); - return; - } - - open_swap_files = g_list_append (open_swap_files, swap_file); - nopen_swap_files += 1; -} - -/* The actual swap file code. The swap file consists of tiles - * which have been moved out to disk in order to conserve memory. - * The swap file format is free form. Any tile in memory may - * end up anywhere on disk. - * An actual tile in the swap file consists only of the tile data. - * The offset of the tile on disk is stored in the tile data structure - * in memory. - */ - -static int -tile_swap_default (gint fd, - Tile *tile, - gint cmd, - gpointer user_data) -{ - DefSwapFile *def_swap_file; - - def_swap_file = (DefSwapFile*) user_data; - - switch (cmd) - { - case SWAP_IN: - tile_swap_default_in (def_swap_file, fd, tile); - break; - case SWAP_IN_ASYNC: - tile_swap_default_in_async (def_swap_file, fd, tile); - break; - case SWAP_OUT: - tile_swap_default_out (def_swap_file, fd, tile); - break; - case SWAP_DELETE: - tile_swap_default_delete (def_swap_file, fd, tile); - break; - case SWAP_COMPRESS: - g_warning ("tile_swap_default: SWAP_COMPRESS: UNFINISHED"); - break; - } - - return FALSE; -} - -static void -tile_swap_default_in_async (DefSwapFile *def_swap_file, - gint fd, - Tile *tile) -{ -#ifdef NOTDEF /* USE_PTHREADS */ - AsyncSwapArgs *args; - - args = g_new(AsyncSwapArgs, 1); - args->def_swap_file = def_swap_file; - args->fd = fd; - args->tile = tile; - - /* add this tile to the list of tiles for the async swapin task */ - pthread_mutex_lock (&async_swapin_mutex); - g_slist_append (async_swapin_tiles_end, args); - - if (!async_swapin_tiles) - async_swapin_tiles = async_swapin_tiles_end; - - pthread_cond_signal (&async_swapin_signal); - pthread_mutex_unlock (&async_swapin_mutex); - -#else - /* ignore; it's only a hint anyway */ - /* this could be changed to call out to another program that - * tries to make the OS read the data in from disk. - */ -#endif - - return; -} - -/* NOTE: if you change this function, check to see if your changes - * apply to tile_swap_in_attempt() near the end of the file. The - * difference is that this version makes guarantees about what it - * provides, but tile_swap_in_attempt() just tries and gives up if - * anything goes wrong. - * - * I'm not sure that it is worthwhile to try to pull out common - * bits; I think the two functions are (at least for now) different - * enough to keep as two functions. - * - * N.B. the mutex on the tile must already have been locked on entry - * to this function. DO NOT LOCK IT HERE. - */ -static void -tile_swap_default_in (DefSwapFile *def_swap_file, - gint fd, - Tile *tile) -{ - gint bytes; - gint err; - gint nleft; - off_t offset; - - err = -1; - - if (tile->data) - { - return; - } - - if (def_swap_file->cur_position != tile->swap_offset) - { - def_swap_file->cur_position = tile->swap_offset; - - offset = lseek (fd, tile->swap_offset, SEEK_SET); - if (offset == -1) - { - if (seek_err_msg) - g_message ("unable to seek to tile location on disk: %d", err); - seek_err_msg = FALSE; - return; - } - } - - bytes = tile_size (tile); - tile_alloc (tile); - - nleft = bytes; - while (nleft > 0) - { - do - { - err = read (fd, tile->data + bytes - nleft, nleft); - } - while ((err == -1) && ((errno == EAGAIN) || (errno == EINTR))); - - if (err <= 0) - { - if (read_err_msg) - g_message ("unable to read tile data from disk: %s (%d/%d bytes read)", - g_strerror (errno), err, nleft); - read_err_msg = FALSE; - return; - } - - nleft -= err; - } - - def_swap_file->cur_position += bytes; - - /* Do not delete the swap from the file */ - /* tile_swap_default_delete (def_swap_file, fd, tile); */ - - read_err_msg = seek_err_msg = TRUE; -} - -static void -tile_swap_default_out (DefSwapFile *def_swap_file, - int fd, - Tile *tile) -{ - gint bytes; - gint rbytes; - gint err; - gint nleft; - off_t offset; - off_t newpos; - - bytes = TILE_WIDTH * TILE_HEIGHT * tile->bpp; - rbytes = tile_size (tile); - - /* If there is already a valid swap_offset, use it */ - if (tile->swap_offset == -1) - newpos = tile_swap_find_offset (def_swap_file, fd, bytes); - else - newpos = tile->swap_offset; - - if (def_swap_file->cur_position != newpos) - { - offset = lseek (fd, newpos, SEEK_SET); - if (offset == -1) - { - if (seek_err_msg) - g_message ("unable to seek to tile location on disk: %s", - g_strerror (errno)); - seek_err_msg = FALSE; - return; - } - def_swap_file->cur_position = newpos; - } - - nleft = rbytes; - while (nleft > 0) - { - err = write (fd, tile->data + rbytes - nleft, nleft); - if (err <= 0) - { - if (write_err_msg) - g_message ("unable to write tile data to disk: %s (%d/%d bytes written)", - g_strerror (errno), err, nleft); - write_err_msg = FALSE; - return; - } - - nleft -= err; - } - - def_swap_file->cur_position += rbytes; - - /* Do NOT free tile->data because we may be pre-swapping. - * tile->data is freed in tile_cache_zorch_next - */ - tile->dirty = FALSE; - tile->swap_offset = newpos; - - write_err_msg = seek_err_msg = TRUE; -} - -static void -tile_swap_default_delete (DefSwapFile *def_swap_file, - gint fd, - Tile *tile) -{ - GList *tmp; - GList *tmp2; - Gap *gap; - Gap *gap2; - glong start; - glong end; - - if (tile->swap_offset == -1) - return; - - start = tile->swap_offset; - end = start + TILE_WIDTH * TILE_HEIGHT * tile->bpp; - tile->swap_offset = -1; - - tmp = def_swap_file->gaps; - while (tmp) - { - gap = tmp->data; - - if (end == gap->start) - { - gap->start = start; - - if (tmp->prev) - { - gap2 = tmp->prev->data; - if (gap->start == gap2->end) - { - gap2->end = gap->end; - tile_swap_gap_destroy (gap); - def_swap_file->gaps = - g_list_remove_link (def_swap_file->gaps, tmp); - g_list_free (tmp); - } - } - break; - } - else if (start == gap->end) - { - gap->end = end; - - if (tmp->next) - { - gap2 = tmp->next->data; - if (gap->end == gap2->start) - { - gap2->start = gap->start; - tile_swap_gap_destroy (gap); - def_swap_file->gaps = - g_list_remove_link (def_swap_file->gaps, tmp); - g_list_free (tmp); - } - } - break; - } - else if (end < gap->start) - { - gap = tile_swap_gap_new (start, end); - - tmp2 = g_list_alloc (); - tmp2->data = gap; - tmp2->next = tmp; - tmp2->prev = tmp->prev; - if (tmp->prev) - tmp->prev->next = tmp2; - tmp->prev = tmp2; - - if (tmp == def_swap_file->gaps) - def_swap_file->gaps = tmp2; - break; - } - else if (!tmp->next) - { - gap = tile_swap_gap_new (start, end); - tmp->next = g_list_alloc (); - tmp->next->data = gap; - tmp->next->prev = tmp; - break; - } - - tmp = tmp->next; - } - - if (!def_swap_file->gaps) - { - gap = tile_swap_gap_new (start, end); - def_swap_file->gaps = g_list_append (def_swap_file->gaps, gap); - } - - tmp = g_list_last (def_swap_file->gaps); - gap = tmp->data; - - if (gap->end == def_swap_file->swap_file_end) - { - tile_swap_resize (def_swap_file, fd, gap->start); - tile_swap_gap_destroy (gap); - def_swap_file->gaps = g_list_remove_link (def_swap_file->gaps, tmp); - g_list_free (tmp); - } -} - -static void -tile_swap_resize (DefSwapFile *def_swap_file, - gint fd, - glong new_size) -{ - if (def_swap_file->swap_file_end > new_size) - { - ftruncate (fd, new_size); - } - - def_swap_file->swap_file_end = new_size; -} - -static long -tile_swap_find_offset (DefSwapFile *def_swap_file, - gint fd, - gint bytes) -{ - GList *tmp; - Gap *gap; - glong offset; - - tmp = def_swap_file->gaps; - while (tmp) - { - gap = tmp->data; - - if ((gap->end - gap->start) >= bytes) - { - offset = gap->start; - gap->start += bytes; - - if (gap->start == gap->end) - { - tile_swap_gap_destroy (gap); - def_swap_file->gaps = - g_list_remove_link (def_swap_file->gaps, tmp); - g_list_free (tmp); - } - - return offset; - } - - tmp = tmp->next; - } - - offset = def_swap_file->swap_file_end; - - tile_swap_resize (def_swap_file, fd, - def_swap_file->swap_file_end + swap_file_grow); - - if ((offset + bytes) < (def_swap_file->swap_file_end)) - { - gap = tile_swap_gap_new (offset + bytes, def_swap_file->swap_file_end); - def_swap_file->gaps = g_list_append (def_swap_file->gaps, gap); - } - - return offset; -} - -static Gap * -tile_swap_gap_new (glong start, - glong end) -{ - Gap *gap; - - gap = g_new (Gap, 1); - gap->start = start; - gap->end = end; - - return gap; -} - -static void -tile_swap_gap_destroy (Gap *gap) -{ - g_free (gap); -} - - -#ifdef NOTDEF /* USE_PTHREADS */ -/* go through the list of tiles that are likely to be used soon and - * try to swap them in. If any tile is not in a state to be swapped - * in, ignore it, and the error will get dealt with when the tile - * is really needed -- assuming that the error still happens. - * - * Potential future enhancement: for non-threaded systems, we could - * fork() a process which merely attempts to bring tiles into the - * OS's buffer/page cache, where they will be read into the gimp - * more quickly. This would be pretty trivial, actually. - */ - -static void -tile_swap_in_attempt (DefSwapFile *def_swap_file, - gint fd, - Tile *tile) -{ - gint bytes; - gint err; - gint nleft; - off_t offset; - - err = -1; - - TILE_MUTEX_LOCK (tile); - if (tile->data) - goto out; - - if (!tile->swap_num || !tile->swap_offset) - goto out; - - if (def_swap_file->cur_position != tile->swap_offset) - { - def_swap_file->cur_position = tile->swap_offset; - - offset = lseek (fd, tile->swap_offset, SEEK_SET); - if (offset == -1) - return; - } - - bytes = tile_size (tile); - tile_alloc (tile); - - nleft = bytes; - while (nleft > 0) - { - do - { - err = read (fd, tile->data + bytes - nleft, nleft); - } - while ((err == -1) && ((errno == EAGAIN) || (errno == EINTR))); - - if (err <= 0) - { - g_free (tile->data); - return; - } - - nleft -= err; - } - - def_swap_file->cur_position += bytes; - -out: - TILE_MUTEX_UNLOCK (tile); -} - -static gpointer -tile_swap_in_thread (gpointer data) -{ - AsyncSwapArgs *args; - GSList *free_item; - - while (TRUE) - { - pthread_mutex_lock (&async_swapin_mutex); - - if (!async_swapin_tiles) - { - pthread_cond_wait (&async_swapin_signal, &async_swapin_mutex); - } - args = async_swapin_tiles->data; - - free_item = async_swapin_tiles; - async_swapin_tiles = async_swapin_tiles->next; - g_slist_free_1(free_item); - - if (!async_swapin_tiles) - async_swapin_tiles_end = NULL; - - pthread_mutex_unlock (&async_swapin_mutex); - - tile_swap_in_attempt(args->def_swap_file, args->fd, args->tile); - - g_free(args); - } -} -#endif diff --git a/app/tile_swap.h b/app/tile_swap.h deleted file mode 100644 index 72ead7facc..0000000000 --- a/app/tile_swap.h +++ /dev/null @@ -1,50 +0,0 @@ -/* The GIMP -- an 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 2 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, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -#ifndef __TILE_SWAP_H__ -#define __TILE_SWAP_H__ - - -typedef enum -{ - SWAP_IN = 1, - SWAP_IN_ASYNC, - SWAP_OUT, - SWAP_DELETE, - SWAP_COMPRESS -} SwapCommand; - -typedef gint (*SwapFunc) (gint fd, - Tile *tile, - gint cmd, - gpointer user_data); - - -void tile_swap_exit (void); -gint tile_swap_add (gchar *filename, - SwapFunc swap_func, - gpointer user_data); -void tile_swap_remove (gint swap_num); -void tile_swap_in (Tile *tile); -void tile_swap_in_async (Tile *tile); -void tile_swap_out (Tile *tile); -void tile_swap_delete (Tile *tile); -void tile_swap_compress (gint swap_num); - - -#endif /* __TILE_SWAP_H__ */ diff --git a/app/tools/gimpairbrushtool.c b/app/tools/gimpairbrushtool.c index 998c77fcdc..a6a514856d 100644 --- a/app/tools/gimpairbrushtool.c +++ b/app/tools/gimpairbrushtool.c @@ -25,6 +25,8 @@ #include "tools-types.h" +#include "base/temp-buf.h" + #include "paint-funcs/paint-funcs.h" #include "core/gimpbrush.h" @@ -36,7 +38,6 @@ #include "drawable.h" #include "gdisplay.h" #include "selection.h" -#include "temp_buf.h" #include "gimpairbrushtool.h" #include "paint_options.h" diff --git a/app/tools/gimpbezierselecttool.c b/app/tools/gimpbezierselecttool.c index 814b13daec..96d251d546 100644 --- a/app/tools/gimpbezierselecttool.c +++ b/app/tools/gimpbezierselecttool.c @@ -28,6 +28,8 @@ #include "tools-types.h" +#include "base/pixel-region.h" + #include "core/gimpchannel.h" #include "core/gimpmarshal.h" #include "core/gimpcontext.h" @@ -44,7 +46,6 @@ #include "gui/paths-dialog.h" #include "floating_sel.h" -#include "pixel_region.h" #include "gimpeditselectiontool.h" #include "gimpbezierselecttool.h" diff --git a/app/tools/gimpblendtool.c b/app/tools/gimpblendtool.c index 2550cf9043..32a7d9cf48 100644 --- a/app/tools/gimpblendtool.c +++ b/app/tools/gimpblendtool.c @@ -28,6 +28,10 @@ #include "tools-types.h" +#include "base/pixel-region.h" +#include "base/tile-manager.h" +#include "base/tile.h" + #include "paint-funcs/paint-funcs.h" #include "core/gimpcontext.h" @@ -45,13 +49,9 @@ #include "errors.h" #include "gdisplay.h" #include "gimpprogress.h" -#include "pixel_region.h" #include "selection.h" #include "undo.h" -#include "tile.h" -#include "tile_manager.h" - #include "gimpblendtool.h" #include "paint_options.h" #include "tool_manager.h" diff --git a/app/tools/gimpbrushtool.c b/app/tools/gimpbrushtool.c index 6f885f86ba..5673686939 100644 --- a/app/tools/gimpbrushtool.c +++ b/app/tools/gimpbrushtool.c @@ -28,6 +28,12 @@ #include "tools-types.h" +#include "base/brush-scale.h" +#include "base/pixel-region.h" +#include "base/temp-buf.h" +#include "base/tile-manager.h" +#include "base/tile.h" + #include "paint-funcs/paint-funcs.h" #include "core/gimpbrushpipe.h" @@ -37,16 +43,11 @@ #include "core/gimpimage.h" #include "core/gimpimage-mask.h" -#include "brush_scale.h" #include "devices.h" #include "drawable.h" #include "gdisplay.h" #include "gimprc.h" -#include "pixel_region.h" #include "selection.h" -#include "temp_buf.h" -#include "tile.h" -#include "tile_manager.h" #include "undo.h" #include "gimpdrawtool.h" diff --git a/app/tools/gimpbucketfilltool.c b/app/tools/gimpbucketfilltool.c index 4503f013e4..5ad6745405 100644 --- a/app/tools/gimpbucketfilltool.c +++ b/app/tools/gimpbucketfilltool.c @@ -25,6 +25,10 @@ #include "tools-types.h" +#include "base/pixel-region.h" +#include "base/temp-buf.h" +#include "base/tile-manager.h" + #include "paint-funcs/paint-funcs.h" #include "core/gimpchannel.h" @@ -39,10 +43,7 @@ #include "drawable.h" #include "gdisplay.h" #include "gimprc.h" -#include "pixel_region.h" #include "selection.h" -#include "temp_buf.h" -#include "tile_manager.h" #include "undo.h" #include "gimpbucketfilltool.h" diff --git a/app/tools/gimpbycolorselecttool.c b/app/tools/gimpbycolorselecttool.c index 976db3c8bc..0e01232746 100644 --- a/app/tools/gimpbycolorselecttool.c +++ b/app/tools/gimpbycolorselecttool.c @@ -28,6 +28,11 @@ #include "tools-types.h" +#include "base/pixel-region.h" +#include "base/temp-buf.h" +#include "base/tile.h" +#include "base/tile-manager.h" + #include "paint-funcs/paint-funcs.h" #include "core/gimpdrawable.h" @@ -38,15 +43,10 @@ #include "widgets/gimpdnd.h" -#include "boundary.h" #include "context_manager.h" #include "gimprc.h" #include "gimpui.h" #include "gdisplay.h" -#include "pixel_region.h" -#include "temp_buf.h" -#include "tile.h" -#include "tile_manager.h" #include "gimpbycolorselecttool.h" #include "selection_options.h" diff --git a/app/tools/gimpclonetool.c b/app/tools/gimpclonetool.c index eee8e9d7cf..f7061c020b 100644 --- a/app/tools/gimpclonetool.c +++ b/app/tools/gimpclonetool.c @@ -27,6 +27,9 @@ #include "tools-types.h" +#include "base/pixel-region.h" +#include "base/temp-buf.h" + #include "paint-funcs/paint-funcs.h" #include "core/gimpdrawable.h" @@ -43,11 +46,8 @@ #include "drawable.h" #include "gdisplay.h" -#include "gimplut.h" #include "gimpui.h" -#include "pixel_region.h" #include "selection.h" -#include "temp_buf.h" #include "libgimp/gimpintl.h" diff --git a/app/tools/gimpconvolvetool.c b/app/tools/gimpconvolvetool.c index 00b2e8f4a1..d42a1ce3a8 100644 --- a/app/tools/gimpconvolvetool.c +++ b/app/tools/gimpconvolvetool.c @@ -25,6 +25,9 @@ #include "tools-types.h" +#include "base/pixel-region.h" +#include "base/temp-buf.h" + #include "core/gimpbrush.h" #include "core/gimpcontext.h" #include "core/gimpdrawable.h" @@ -38,9 +41,7 @@ #include "drawable.h" #include "gdisplay.h" -#include "pixel_region.h" #include "selection.h" -#include "temp_buf.h" #include "libgimp/gimpintl.h" diff --git a/app/tools/gimpcroptool.c b/app/tools/gimpcroptool.c index c330eca074..1f0a9671cd 100644 --- a/app/tools/gimpcroptool.c +++ b/app/tools/gimpcroptool.c @@ -28,6 +28,8 @@ #include "tools-types.h" +#include "base/pixel-region.h" + #include "core/gimpchannel.h" #include "core/gimpdrawable.h" #include "core/gimpimage.h" @@ -46,7 +48,6 @@ #include "app_procs.h" #include "floating_sel.h" -#include "pixel_region.h" #include "undo.h" #include "libgimp/gimpintl.h" diff --git a/app/tools/gimpdodgeburntool.c b/app/tools/gimpdodgeburntool.c index 137e050934..5ad388229e 100644 --- a/app/tools/gimpdodgeburntool.c +++ b/app/tools/gimpdodgeburntool.c @@ -26,6 +26,10 @@ #include "tools-types.h" +#include "base/gimplut.h" +#include "base/pixel-region.h" +#include "base/temp-buf.h" + #include "paint-funcs/paint-funcs.h" #include "core/gimpdrawable.h" @@ -33,10 +37,7 @@ #include "gdisplay.h" #include "gimage.h" -#include "gimplut.h" -#include "pixel_region.h" #include "selection.h" -#include "temp_buf.h" #include "gimpdodgeburntool.h" #include "gimppainttool.h" diff --git a/app/tools/gimpeditselectiontool.c b/app/tools/gimpeditselectiontool.c index 5a6e6b7d65..c520991f7d 100644 --- a/app/tools/gimpeditselectiontool.c +++ b/app/tools/gimpeditselectiontool.c @@ -28,13 +28,14 @@ #include "tools-types.h" +#include "base/boundary.h" + #include "core/gimpdrawable.h" #include "core/gimpimage.h" #include "core/gimpimage-mask.h" #include "core/gimplayer.h" #include "core/gimplist.h" -#include "boundary.h" #include "floating_sel.h" #include "gdisplay.h" #include "gimprc.h" diff --git a/app/tools/gimperasertool.c b/app/tools/gimperasertool.c index 4532963b05..f3e9801c5f 100644 --- a/app/tools/gimperasertool.c +++ b/app/tools/gimperasertool.c @@ -25,6 +25,8 @@ #include "tools-types.h" +#include "base/temp-buf.h" + #include "paint-funcs/paint-funcs.h" #include "core/gimpcontext.h" @@ -33,7 +35,6 @@ #include "gdisplay.h" #include "selection.h" -#include "temp_buf.h" #include "gimperasertool.h" #include "paint_options.h" diff --git a/app/tools/gimpfliptool.c b/app/tools/gimpfliptool.c index 8f90ed5944..2c7c2e42d9 100644 --- a/app/tools/gimpfliptool.c +++ b/app/tools/gimpfliptool.c @@ -27,6 +27,9 @@ #include "tools-types.h" +#include "base/pixel-region.h" +#include "base/tile-manager.h" + #include "paint-funcs/paint-funcs.h" #include "core/gimpdrawable.h" @@ -40,8 +43,6 @@ #include "selection.h" #include "undo.h" #include "path_transform.h" -#include "pixel_region.h" -#include "tile_manager.h" #include "gimpfliptool.h" #include "tool_manager.h" diff --git a/app/tools/gimpfuzzyselecttool.c b/app/tools/gimpfuzzyselecttool.c index 4f3061347d..7b4f96b9ee 100644 --- a/app/tools/gimpfuzzyselecttool.c +++ b/app/tools/gimpfuzzyselecttool.c @@ -26,18 +26,19 @@ #include "tools-types.h" +#include "base/boundary.h" +#include "base/pixel-region.h" +#include "base/tile-manager.h" +#include "base/tile.h" + #include "core/gimpchannel.h" #include "core/gimpdrawable.h" #include "core/gimpimage.h" #include "core/gimpimage-mask.h" #include "app_procs.h" -#include "boundary.h" #include "gdisplay.h" #include "gimprc.h" -#include "pixel_region.h" -#include "tile_manager.h" -#include "tile.h" #include "gimpeditselectiontool.h" #include "gimpfuzzyselecttool.h" diff --git a/app/tools/gimpinktool.c b/app/tools/gimpinktool.c index 6f2b0696ce..d962215f8b 100644 --- a/app/tools/gimpinktool.c +++ b/app/tools/gimpinktool.c @@ -28,6 +28,11 @@ #include "tools-types.h" +#include "base/pixel-region.h" +#include "base/temp-buf.h" +#include "base/tile.h" +#include "base/tile-manager.h" + #include "paint-funcs/paint-funcs.h" #include "core/gimpcontext.h" @@ -39,10 +44,6 @@ #include "gimprc.h" #include "undo.h" #include "gdisplay.h" -#include "pixel_region.h" -#include "temp_buf.h" -#include "tile.h" -#include "tile_manager.h" #include "gimpinktool.h" #include "gimpinktool-blob.h" diff --git a/app/tools/gimpiscissorstool.c b/app/tools/gimpiscissorstool.c index 19c7c8d5fb..da078b2a2a 100644 --- a/app/tools/gimpiscissorstool.c +++ b/app/tools/gimpiscissorstool.c @@ -45,6 +45,11 @@ #include "tools-types.h" +#include "base/pixel-region.h" +#include "base/temp-buf.h" +#include "base/tile-manager.h" +#include "base/tile.h" + #include "paint-funcs/paint-funcs.h" #include "core/gimpchannel.h" @@ -53,11 +58,7 @@ #include "drawable.h" #include "gdisplay.h" -#include "pixel_region.h" -#include "temp_buf.h" #include "scan_convert.h" -#include "tile.h" -#include "tile_manager.h" #include "gimpbezierselecttool.h" #include "gimpiscissorstool.h" diff --git a/app/tools/gimppaintbrushtool.c b/app/tools/gimppaintbrushtool.c index 08ae5497ef..22a29bdc72 100644 --- a/app/tools/gimppaintbrushtool.c +++ b/app/tools/gimppaintbrushtool.c @@ -26,6 +26,8 @@ #include "tools-types.h" +#include "base/temp-buf.h" + #include "paint-funcs/paint-funcs.h" #include "core/gimpbrush.h" @@ -36,7 +38,6 @@ #include "gdisplay.h" #include "selection.h" -#include "temp_buf.h" #include "gimppaintbrushtool.h" #include "paint_options.h" diff --git a/app/tools/gimppainttool.c b/app/tools/gimppainttool.c index 6f885f86ba..5673686939 100644 --- a/app/tools/gimppainttool.c +++ b/app/tools/gimppainttool.c @@ -28,6 +28,12 @@ #include "tools-types.h" +#include "base/brush-scale.h" +#include "base/pixel-region.h" +#include "base/temp-buf.h" +#include "base/tile-manager.h" +#include "base/tile.h" + #include "paint-funcs/paint-funcs.h" #include "core/gimpbrushpipe.h" @@ -37,16 +43,11 @@ #include "core/gimpimage.h" #include "core/gimpimage-mask.h" -#include "brush_scale.h" #include "devices.h" #include "drawable.h" #include "gdisplay.h" #include "gimprc.h" -#include "pixel_region.h" #include "selection.h" -#include "temp_buf.h" -#include "tile.h" -#include "tile_manager.h" #include "undo.h" #include "gimpdrawtool.h" diff --git a/app/tools/gimppenciltool.c b/app/tools/gimppenciltool.c index 0fdb28df00..de6fb26faa 100644 --- a/app/tools/gimppenciltool.c +++ b/app/tools/gimppenciltool.c @@ -24,6 +24,8 @@ #include "tools-types.h" +#include "base/temp-buf.h" + #include "paint-funcs/paint-funcs.h" #include "core/gimpbrush.h" @@ -34,7 +36,6 @@ #include "gdisplay.h" #include "selection.h" -#include "temp_buf.h" #include "gimppenciltool.h" #include "gimppainttool.h" diff --git a/app/tools/gimpperspectivetool.c b/app/tools/gimpperspectivetool.c index 82aca619d0..e03bc3ef99 100644 --- a/app/tools/gimpperspectivetool.c +++ b/app/tools/gimpperspectivetool.c @@ -31,7 +31,6 @@ #include "gimpprogress.h" #include "gui/info-dialog.h" #include "selection.h" -#include "tile_manager.h" #include "undo.h" #include "gimpperspectivetool.h" diff --git a/app/tools/gimpregionselecttool.c b/app/tools/gimpregionselecttool.c index 4f3061347d..7b4f96b9ee 100644 --- a/app/tools/gimpregionselecttool.c +++ b/app/tools/gimpregionselecttool.c @@ -26,18 +26,19 @@ #include "tools-types.h" +#include "base/boundary.h" +#include "base/pixel-region.h" +#include "base/tile-manager.h" +#include "base/tile.h" + #include "core/gimpchannel.h" #include "core/gimpdrawable.h" #include "core/gimpimage.h" #include "core/gimpimage-mask.h" #include "app_procs.h" -#include "boundary.h" #include "gdisplay.h" #include "gimprc.h" -#include "pixel_region.h" -#include "tile_manager.h" -#include "tile.h" #include "gimpeditselectiontool.h" #include "gimpfuzzyselecttool.h" diff --git a/app/tools/gimprotatetool.c b/app/tools/gimprotatetool.c index 8ce5177dc0..c12d251a71 100644 --- a/app/tools/gimprotatetool.c +++ b/app/tools/gimprotatetool.c @@ -38,8 +38,6 @@ #include "selection.h" #include "undo.h" #include "path_transform.h" -#include "pixel_region.h" -#include "tile_manager.h" #include "gimprotatetool.h" #include "tool_manager.h" diff --git a/app/tools/gimpscaletool.c b/app/tools/gimpscaletool.c index 0671ac1ce7..d56ed2b5cd 100644 --- a/app/tools/gimpscaletool.c +++ b/app/tools/gimpscaletool.c @@ -34,7 +34,6 @@ #include "drawable.h" #include "gimpprogress.h" #include "selection.h" -#include "tile_manager.h" #include "undo.h" #include "gimpscaletool.h" diff --git a/app/tools/gimpsheartool.c b/app/tools/gimpsheartool.c index ad0d7c1a63..84be76b460 100644 --- a/app/tools/gimpsheartool.c +++ b/app/tools/gimpsheartool.c @@ -37,8 +37,6 @@ #include "gimpprogress.h" #include "selection.h" #include "undo.h" -#include "pixel_region.h" -#include "tile_manager.h" #include "gimpsheartool.h" #include "tool_manager.h" diff --git a/app/tools/gimpsmudgetool.c b/app/tools/gimpsmudgetool.c index c3f77dc1cf..69fc51c152 100644 --- a/app/tools/gimpsmudgetool.c +++ b/app/tools/gimpsmudgetool.c @@ -26,6 +26,9 @@ #include "tools-types.h" +#include "base/pixel-region.h" +#include "base/temp-buf.h" + #include "paint-funcs/paint-funcs.h" #include "core/gimpbrush.h" @@ -38,11 +41,8 @@ #include "tool_options.h" #include "gdisplay.h" -#include "gimplut.h" #include "gimpui.h" -#include "pixel_region.h" #include "selection.h" -#include "temp_buf.h" #include "libgimp/gimpintl.h" diff --git a/app/tools/gimpsourcetool.c b/app/tools/gimpsourcetool.c index eee8e9d7cf..f7061c020b 100644 --- a/app/tools/gimpsourcetool.c +++ b/app/tools/gimpsourcetool.c @@ -27,6 +27,9 @@ #include "tools-types.h" +#include "base/pixel-region.h" +#include "base/temp-buf.h" + #include "paint-funcs/paint-funcs.h" #include "core/gimpdrawable.h" @@ -43,11 +46,8 @@ #include "drawable.h" #include "gdisplay.h" -#include "gimplut.h" #include "gimpui.h" -#include "pixel_region.h" #include "selection.h" -#include "temp_buf.h" #include "libgimp/gimpintl.h" diff --git a/app/tools/gimptexttool.c b/app/tools/gimptexttool.c index ab856de81d..b4d5d6b081 100644 --- a/app/tools/gimptexttool.c +++ b/app/tools/gimptexttool.c @@ -35,6 +35,10 @@ #include "tools-types.h" +#include "base/pixel-region.h" +#include "base/tile-manager.h" +#include "base/tile.h" + #include "paint-funcs/paint-funcs.h" #include "core/gimpchannel.h" @@ -48,11 +52,8 @@ #include "gdisplay.h" #include "gimpui.h" #include "global_edit.h" -#include "pixel_region.h" #include "plug_in.h" #include "selection.h" -#include "tile.h" -#include "tile_manager.h" #include "undo.h" #include "gimpeditselectiontool.h" diff --git a/app/tools/gimptransformtool.c b/app/tools/gimptransformtool.c index 46a88c26b6..2ea8dad5c4 100644 --- a/app/tools/gimptransformtool.c +++ b/app/tools/gimptransformtool.c @@ -27,6 +27,12 @@ #include "tools-types.h" +#include "base/base-config.h" +#include "base/pixel-region.h" +#include "base/pixel-surround.h" +#include "base/tile-manager.h" +#include "base/tile.h" + #include "paint-funcs/paint-funcs.h" #include "core/gimpchannel.h" @@ -45,13 +51,8 @@ #include "app_procs.h" #include "drawable.h" #include "floating_sel.h" -#include "gimprc.h" -#include "path_transform.h" -#include "pixel_region.h" -#include "pixel_surround.h" #include "undo.h" -#include "tile_manager.h" -#include "tile.h" +#include "path_transform.h" #include "tool_manager.h" #include "tool_options.h" @@ -1149,7 +1150,7 @@ gimp_transform_tool_do (GimpImage *gimage, /* turn interpolation off for simple transformations (e.g. rot90) */ if (gimp_matrix3_is_simple (matrix) || - interpolation_type == NEAREST_NEIGHBOR_INTERPOLATION) + base_config->interpolation_type == NEAREST_NEIGHBOR_INTERPOLATION) interpolation = FALSE; /* Get the background color */ @@ -1247,7 +1248,7 @@ gimp_transform_tool_do (GimpImage *gimage, /* initialise the pixel_surround accessor */ if (interpolation) { - if (interpolation_type == CUBIC_INTERPOLATION) + if (base_config->interpolation_type == CUBIC_INTERPOLATION) { pixel_surround_init (&surround, float_tiles, 4, 4, bg_col); } @@ -1309,7 +1310,7 @@ gimp_transform_tool_do (GimpImage *gimage, if (interpolation) { - if (interpolation_type == CUBIC_INTERPOLATION) + if (base_config->interpolation_type == CUBIC_INTERPOLATION) { /* ttx & tty are the subpixel coordinates of the point in * the original selection's floating buffer. diff --git a/app/undo.c b/app/undo.c index 2f45b6e8e2..01396f3d98 100644 --- a/app/undo.c +++ b/app/undo.c @@ -26,6 +26,10 @@ #include "core/core-types.h" #include "tools/tools-types.h" +#include "base/pixel-region.h" +#include "base/tile-manager.h" +#include "base/tile.h" + #include "paint-funcs/paint-funcs.h" #include "core/gimpchannel.h" @@ -50,9 +54,6 @@ #include "gimprc.h" #include "parasitelist.h" #include "path_transform.h" -#include "pixel_region.h" -#include "tile_manager.h" -#include "tile.h" #include "undo.h" #include "libgimp/gimpparasite.h" diff --git a/app/undo_history.c b/app/undo_history.c index f15bf4e54a..e0e024d6e0 100644 --- a/app/undo_history.c +++ b/app/undo_history.c @@ -49,6 +49,9 @@ #include "core/core-types.h" +#include "base/pixel-region.h" +#include "base/temp-buf.h" + #include "paint-funcs/paint-funcs.h" #include "core/gimpdrawable.h" @@ -57,8 +60,6 @@ #include "dialog_handler.h" #include "gimprc.h" -#include "pixel_region.h" -#include "temp_buf.h" #include "undo.h" #include "libgimp/gimplimits.h" diff --git a/app/user_install.c b/app/user_install.c index 21ce3064e9..90e0231ac4 100644 --- a/app/user_install.c +++ b/app/user_install.c @@ -35,6 +35,8 @@ #include "core/core-types.h" +#include "base/base-config.h" + #include "appenv.h" #include "gdisplay_ops.h" #include "gimprc.h" @@ -381,7 +383,7 @@ user_install_continue_callback (GtkWidget *widget, #ifdef G_OS_WIN32 FreeConsole (); #endif - parse_buffers_init (); + gimprc_init (); parse_unitrc (); parse_gimprc (); user_install_tuning (); @@ -896,7 +898,7 @@ user_install_dialog_create (UserInstallCallback callback) #ifdef G_OS_WIN32 -char * +static char * quote_spaces (char *string) { int nspaces = 0; @@ -1106,7 +1108,7 @@ user_install_tuning (void) gtk_box_pack_start (GTK_BOX (tuning_page), hbox, FALSE, FALSE, 0); gtk_widget_show (hbox); - tile_cache_adj = gtk_adjustment_new (tile_cache_size, + tile_cache_adj = gtk_adjustment_new (base_config->tile_cache_size, 0, (4069.0 * 1024 * 1024), 1.0, 1.0, 0.0); memsize = gimp_mem_size_entry_new (GTK_ADJUSTMENT (tile_cache_adj)); gtk_box_pack_end (GTK_BOX (hbox), memsize, FALSE, FALSE, 0); @@ -1132,7 +1134,8 @@ user_install_tuning (void) gtk_box_pack_start (GTK_BOX (tuning_page), hbox, FALSE, FALSE, 0); gtk_widget_show (hbox); - swap_path_filesel = gimp_file_selection_new (_("Select Swap Dir"), swap_path, + swap_path_filesel = gimp_file_selection_new (_("Select Swap Dir"), + base_config->swap_path, TRUE, TRUE); gtk_box_pack_end (GTK_BOX (hbox), swap_path_filesel, FALSE, FALSE, 0); gtk_widget_show (swap_path_filesel); @@ -1291,15 +1294,16 @@ user_install_resolution_done (void) new_monitor_yres = gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (resolution_entry), 1); - if (tile_cache_size != new_tile_cache_size) + if (base_config->tile_cache_size != new_tile_cache_size) { - tile_cache_size = new_tile_cache_size; + base_config->tile_cache_size = new_tile_cache_size; update = g_list_append (update, "tile-cache-size"); } - if (swap_path && new_swap_path && - strcmp (swap_path, new_swap_path)) + if (base_config->swap_path && new_swap_path && + strcmp (base_config->swap_path, new_swap_path)) { - g_free (swap_path); swap_path = new_swap_path; + g_free (base_config->swap_path); + base_config->swap_path = new_swap_path; update = g_list_append (update, "swap-path"); } if (using_xserver_resolution != new_using_xserver_resolution || diff --git a/app/widgets/gimpbrusheditor.c b/app/widgets/gimpbrusheditor.c index 65b86266d7..60a6283322 100644 --- a/app/widgets/gimpbrusheditor.c +++ b/app/widgets/gimpbrusheditor.c @@ -30,12 +30,12 @@ #include "core/core-types.h" +#include "base/temp-buf.h" + #include "core/gimpbrushgenerated.h" #include "brush-editor.h" -#include "temp_buf.h" - #include "libgimp/gimpintl.h" diff --git a/app/widgets/gimpbrushpreview.c b/app/widgets/gimpbrushpreview.c index 2d8763893b..c7c67d04b0 100644 --- a/app/widgets/gimpbrushpreview.c +++ b/app/widgets/gimpbrushpreview.c @@ -25,14 +25,14 @@ #include "widgets-types.h" +#include "base/temp-buf.h" + #include "core/gimpbrush.h" #include "core/gimpbrushpipe.h" #include "gimpbrushpreview.h" #include "gimpdnd.h" -#include "temp_buf.h" - static void gimp_brush_preview_class_init (GimpBrushPreviewClass *klass); static void gimp_brush_preview_init (GimpBrushPreview *preview); diff --git a/app/widgets/gimpcontainerview-utils.c b/app/widgets/gimpcontainerview-utils.c index 0bd8a6f782..0544776a60 100644 --- a/app/widgets/gimpcontainerview-utils.c +++ b/app/widgets/gimpcontainerview-utils.c @@ -22,6 +22,8 @@ #include "widgets/widgets-types.h" +#include "base/temp-buf.h" + #include "core/gimpbrush.h" #include "core/gimpimage.h" #include "core/gimppalette.h" @@ -34,8 +36,6 @@ #include "widgets/gimpmenuitem.h" #include "widgets/gimppreview.h" -#include "temp_buf.h" - static gchar * gimp_container_view_tool_name_func (GtkWidget *widget); static gchar * gimp_container_view_image_name_func (GtkWidget *widget); diff --git a/app/widgets/gimpdnd.c b/app/widgets/gimpdnd.c index 40e43df378..79467194bb 100644 --- a/app/widgets/gimpdnd.c +++ b/app/widgets/gimpdnd.c @@ -49,7 +49,6 @@ #include "context_manager.h" #include "gimprc.h" -#include "temp_buf.h" #include "gimpdnd.h" #include "gimppreview.h" diff --git a/app/widgets/gimpdrawablepreview.c b/app/widgets/gimpdrawablepreview.c index 6e7721356d..a94063b006 100644 --- a/app/widgets/gimpdrawablepreview.c +++ b/app/widgets/gimpdrawablepreview.c @@ -27,13 +27,13 @@ #include "widgets-types.h" +#include "base/temp-buf.h" + #include "core/gimpdrawable.h" #include "core/gimpimage.h" #include "gimpdrawablepreview.h" -#include "temp_buf.h" - static void gimp_drawable_preview_class_init (GimpDrawablePreviewClass *klass); static void gimp_drawable_preview_init (GimpDrawablePreview *preview); diff --git a/app/widgets/gimpgradientpreview.c b/app/widgets/gimpgradientpreview.c index 0ff637bf6c..8823640414 100644 --- a/app/widgets/gimpgradientpreview.c +++ b/app/widgets/gimpgradientpreview.c @@ -25,12 +25,12 @@ #include "widgets-types.h" +#include "base/temp-buf.h" + #include "core/gimpgradient.h" #include "gimpgradientpreview.h" -#include "temp_buf.h" - static void gimp_gradient_preview_class_init (GimpGradientPreviewClass *klass); static void gimp_gradient_preview_init (GimpGradientPreview *preview); diff --git a/app/widgets/gimphistogramview.c b/app/widgets/gimphistogramview.c index 1a35df126d..da1b569cbc 100644 --- a/app/widgets/gimphistogramview.c +++ b/app/widgets/gimphistogramview.c @@ -26,9 +26,7 @@ #include "gimphistogramview.h" -#include "gimage.h" #include "gimphistogram.h" -#include "tile_manager.h" #define WAITING 0 diff --git a/app/widgets/gimpimagepreview.c b/app/widgets/gimpimagepreview.c index a7e46e5820..5c2f08d475 100644 --- a/app/widgets/gimpimagepreview.c +++ b/app/widgets/gimpimagepreview.c @@ -25,12 +25,12 @@ #include "widgets-types.h" +#include "base/temp-buf.h" + #include "core/gimpimage.h" #include "gimpimagepreview.h" -#include "temp_buf.h" - static void gimp_image_preview_class_init (GimpImagePreviewClass *klass); static void gimp_image_preview_init (GimpImagePreview *preview); diff --git a/app/widgets/gimppalettepreview.c b/app/widgets/gimppalettepreview.c index e5a3726096..460447617a 100644 --- a/app/widgets/gimppalettepreview.c +++ b/app/widgets/gimppalettepreview.c @@ -25,12 +25,12 @@ #include "widgets-types.h" +#include "base/temp-buf.h" + #include "core/gimppalette.h" #include "gimppalettepreview.h" -#include "temp_buf.h" - static void gimp_palette_preview_class_init (GimpPalettePreviewClass *klass); static void gimp_palette_preview_init (GimpPalettePreview *preview); diff --git a/app/widgets/gimppatternpreview.c b/app/widgets/gimppatternpreview.c index cbc2419feb..4134bea847 100644 --- a/app/widgets/gimppatternpreview.c +++ b/app/widgets/gimppatternpreview.c @@ -25,12 +25,12 @@ #include "widgets-types.h" +#include "base/temp-buf.h" + #include "core/gimppattern.h" #include "gimppatternpreview.h" -#include "temp_buf.h" - static void gimp_pattern_preview_class_init (GimpPatternPreviewClass *klass); static void gimp_pattern_preview_init (GimpPatternPreview *preview); diff --git a/app/widgets/gimppreview.c b/app/widgets/gimppreview.c index e873100a9a..137eda29bf 100644 --- a/app/widgets/gimppreview.c +++ b/app/widgets/gimppreview.c @@ -31,6 +31,8 @@ #include "widgets-types.h" +#include "base/temp-buf.h" + #include "core/gimpbrush.h" #include "core/gimpdrawable.h" #include "core/gimpgradient.h" @@ -51,7 +53,6 @@ #include "gimptoolinfopreview.h" #include "image_render.h" -#include "temp_buf.h" #include "libgimp/gimplimits.h" diff --git a/app/widgets/gimppreviewrenderer.c b/app/widgets/gimppreviewrenderer.c index e873100a9a..137eda29bf 100644 --- a/app/widgets/gimppreviewrenderer.c +++ b/app/widgets/gimppreviewrenderer.c @@ -31,6 +31,8 @@ #include "widgets-types.h" +#include "base/temp-buf.h" + #include "core/gimpbrush.h" #include "core/gimpdrawable.h" #include "core/gimpgradient.h" @@ -51,7 +53,6 @@ #include "gimptoolinfopreview.h" #include "image_render.h" -#include "temp_buf.h" #include "libgimp/gimplimits.h" diff --git a/app/widgets/gimppreviewrendererbrush.c b/app/widgets/gimppreviewrendererbrush.c index 2d8763893b..c7c67d04b0 100644 --- a/app/widgets/gimppreviewrendererbrush.c +++ b/app/widgets/gimppreviewrendererbrush.c @@ -25,14 +25,14 @@ #include "widgets-types.h" +#include "base/temp-buf.h" + #include "core/gimpbrush.h" #include "core/gimpbrushpipe.h" #include "gimpbrushpreview.h" #include "gimpdnd.h" -#include "temp_buf.h" - static void gimp_brush_preview_class_init (GimpBrushPreviewClass *klass); static void gimp_brush_preview_init (GimpBrushPreview *preview); diff --git a/app/widgets/gimppreviewrendererdrawable.c b/app/widgets/gimppreviewrendererdrawable.c index 6e7721356d..a94063b006 100644 --- a/app/widgets/gimppreviewrendererdrawable.c +++ b/app/widgets/gimppreviewrendererdrawable.c @@ -27,13 +27,13 @@ #include "widgets-types.h" +#include "base/temp-buf.h" + #include "core/gimpdrawable.h" #include "core/gimpimage.h" #include "gimpdrawablepreview.h" -#include "temp_buf.h" - static void gimp_drawable_preview_class_init (GimpDrawablePreviewClass *klass); static void gimp_drawable_preview_init (GimpDrawablePreview *preview); diff --git a/app/widgets/gimppreviewrendererimage.c b/app/widgets/gimppreviewrendererimage.c index a7e46e5820..5c2f08d475 100644 --- a/app/widgets/gimppreviewrendererimage.c +++ b/app/widgets/gimppreviewrendererimage.c @@ -25,12 +25,12 @@ #include "widgets-types.h" +#include "base/temp-buf.h" + #include "core/gimpimage.h" #include "gimpimagepreview.h" -#include "temp_buf.h" - static void gimp_image_preview_class_init (GimpImagePreviewClass *klass); static void gimp_image_preview_init (GimpImagePreview *preview); diff --git a/app/widgets/gimptoolbox.c b/app/widgets/gimptoolbox.c index 4336eb07b2..c4d5400003 100644 --- a/app/widgets/gimptoolbox.c +++ b/app/widgets/gimptoolbox.c @@ -28,6 +28,9 @@ #include "tools/tools-types.h" #include "widgets/widgets-types.h" +#include "base/pixel-region.h" +#include "base/tile-manager.h" + #include "paint-funcs/paint-funcs.h" #include "core/gimpcontext.h" @@ -56,8 +59,6 @@ #include "app_procs.h" #include "gimage.h" #include "gimprc.h" -#include "pixel_region.h" -#include "tile_manager.h" #include "libgimp/gimpintl.h" diff --git a/app/widgets/gimptoolinfopreview.c b/app/widgets/gimptoolinfopreview.c index 30f71fab95..5e192608ad 100644 --- a/app/widgets/gimptoolinfopreview.c +++ b/app/widgets/gimptoolinfopreview.c @@ -25,12 +25,12 @@ #include "widgets-types.h" +#include "base/temp-buf.h" + #include "core/gimptoolinfo.h" #include "gimptoolinfopreview.h" -#include "temp_buf.h" - /* FIXME: make tool icons nicer */ #define TOOL_INFO_WIDTH 22 diff --git a/app/widgets/gimpview.c b/app/widgets/gimpview.c index e873100a9a..137eda29bf 100644 --- a/app/widgets/gimpview.c +++ b/app/widgets/gimpview.c @@ -31,6 +31,8 @@ #include "widgets-types.h" +#include "base/temp-buf.h" + #include "core/gimpbrush.h" #include "core/gimpdrawable.h" #include "core/gimpgradient.h" @@ -51,7 +53,6 @@ #include "gimptoolinfopreview.h" #include "image_render.h" -#include "temp_buf.h" #include "libgimp/gimplimits.h" diff --git a/app/widgets/gimpviewrenderer.c b/app/widgets/gimpviewrenderer.c index e873100a9a..137eda29bf 100644 --- a/app/widgets/gimpviewrenderer.c +++ b/app/widgets/gimpviewrenderer.c @@ -31,6 +31,8 @@ #include "widgets-types.h" +#include "base/temp-buf.h" + #include "core/gimpbrush.h" #include "core/gimpdrawable.h" #include "core/gimpgradient.h" @@ -51,7 +53,6 @@ #include "gimptoolinfopreview.h" #include "image_render.h" -#include "temp_buf.h" #include "libgimp/gimplimits.h" diff --git a/app/widgets/gimpviewrendererbrush.c b/app/widgets/gimpviewrendererbrush.c index 2d8763893b..c7c67d04b0 100644 --- a/app/widgets/gimpviewrendererbrush.c +++ b/app/widgets/gimpviewrendererbrush.c @@ -25,14 +25,14 @@ #include "widgets-types.h" +#include "base/temp-buf.h" + #include "core/gimpbrush.h" #include "core/gimpbrushpipe.h" #include "gimpbrushpreview.h" #include "gimpdnd.h" -#include "temp_buf.h" - static void gimp_brush_preview_class_init (GimpBrushPreviewClass *klass); static void gimp_brush_preview_init (GimpBrushPreview *preview); diff --git a/app/widgets/gimpviewrendererdrawable.c b/app/widgets/gimpviewrendererdrawable.c index 6e7721356d..a94063b006 100644 --- a/app/widgets/gimpviewrendererdrawable.c +++ b/app/widgets/gimpviewrendererdrawable.c @@ -27,13 +27,13 @@ #include "widgets-types.h" +#include "base/temp-buf.h" + #include "core/gimpdrawable.h" #include "core/gimpimage.h" #include "gimpdrawablepreview.h" -#include "temp_buf.h" - static void gimp_drawable_preview_class_init (GimpDrawablePreviewClass *klass); static void gimp_drawable_preview_init (GimpDrawablePreview *preview); diff --git a/app/widgets/gimpviewrendererimage.c b/app/widgets/gimpviewrendererimage.c index a7e46e5820..5c2f08d475 100644 --- a/app/widgets/gimpviewrendererimage.c +++ b/app/widgets/gimpviewrendererimage.c @@ -25,12 +25,12 @@ #include "widgets-types.h" +#include "base/temp-buf.h" + #include "core/gimpimage.h" #include "gimpimagepreview.h" -#include "temp_buf.h" - static void gimp_image_preview_class_init (GimpImagePreviewClass *klass); static void gimp_image_preview_init (GimpImagePreview *preview); diff --git a/app/xcf.c b/app/xcf.c index d852046757..b7be62a609 100644 --- a/app/xcf.c +++ b/app/xcf.c @@ -38,6 +38,10 @@ #include "core/core-types.h" #include "tools/tools-types.h" +#include "base/tile.h" +#include "base/tile-manager.h" +#include "base/tile-manager-private.h" + #include "core/gimpchannel.h" #include "core/gimpimage.h" #include "core/gimpimage-mask.h" @@ -53,9 +57,6 @@ #include "parasitelist.h" #include "path.h" #include "pathP.h" -#include "tile.h" -#include "tile_manager.h" -#include "tile_manager_pvt.h" #include "xcf.h" #include "libgimp/gimplimits.h" diff --git a/app/xcf/xcf.c b/app/xcf/xcf.c index d852046757..b7be62a609 100644 --- a/app/xcf/xcf.c +++ b/app/xcf/xcf.c @@ -38,6 +38,10 @@ #include "core/core-types.h" #include "tools/tools-types.h" +#include "base/tile.h" +#include "base/tile-manager.h" +#include "base/tile-manager-private.h" + #include "core/gimpchannel.h" #include "core/gimpimage.h" #include "core/gimpimage-mask.h" @@ -53,9 +57,6 @@ #include "parasitelist.h" #include "path.h" #include "pathP.h" -#include "tile.h" -#include "tile_manager.h" -#include "tile_manager_pvt.h" #include "xcf.h" #include "libgimp/gimplimits.h" diff --git a/configure.in b/configure.in index 53aeeb635f..a2412db95f 100644 --- a/configure.in +++ b/configure.in @@ -792,6 +792,7 @@ libgimpwidgets/Makefile libgimpwidgets/makefile.mingw app/Makefile app/makefile.mingw +app/base/Makefile app/core/Makefile app/gui/Makefile app/paint-funcs/Makefile diff --git a/tools/pdbgen/Makefile.am b/tools/pdbgen/Makefile.am index 4b842ca1c7..d94b2caa0d 100644 --- a/tools/pdbgen/Makefile.am +++ b/tools/pdbgen/Makefile.am @@ -53,6 +53,7 @@ enum_headers = \ ../../app/errors.h \ ../../app/lut_funcs.h \ ../../app/paint-funcs/paint-funcs.h \ + ../../app/base/base-types.h \ ../../app/core/core-types.h \ ../../app/core/gimpdrawable-offset.h \ ../../app/core/gimpimage.h \ diff --git a/tools/pdbgen/enums.pl b/tools/pdbgen/enums.pl index b418d7b75d..7ba87edee3 100644 --- a/tools/pdbgen/enums.pl +++ b/tools/pdbgen/enums.pl @@ -36,43 +36,6 @@ package Gimp::CodeGen::enums; TRANSPARENT_FILL => 'TRANS_IMAGE_FILL', NO_FILL => 'NO_IMAGE_FILL' } }, - LayerModeEffects => - { contig => 1, - header => 'appenums.h', - symbols => [ qw(NORMAL_MODE DISSOLVE_MODE BEHIND_MODE - MULTIPLY_MODE SCREEN_MODE OVERLAY_MODE - DIFFERENCE_MODE ADDITION_MODE SUBTRACT_MODE - DARKEN_ONLY_MODE LIGHTEN_ONLY_MODE HUE_MODE - SATURATION_MODE COLOR_MODE VALUE_MODE DIVIDE_MODE - DODGE_MODE BURN_MODE HARDLIGHT_MODE) ], - mapping => { NORMAL_MODE => '0', - DISSOLVE_MODE => '1', - BEHIND_MODE => '2', - MULTIPLY_MODE => '3', - SCREEN_MODE => '4', - OVERLAY_MODE => '5', - DIFFERENCE_MODE => '6', - ADDITION_MODE => '7', - SUBTRACT_MODE => '8', - DARKEN_ONLY_MODE => '9', - LIGHTEN_ONLY_MODE => '10', - HUE_MODE => '11', - SATURATION_MODE => '12', - COLOR_MODE => '13', - VALUE_MODE => '14', - DIVIDE_MODE => '15', - DODGE_MODE => '16', - BURN_MODE => '17', - HARDLIGHT_MODE => '18' } - }, - ConvolutionType => - { contig => 1, - header => 'appenums.h', - symbols => [ qw(NORMAL_CONVOL ABSOLUTE_CONVOL NEGATIVE_CONVOL) ], - mapping => { NORMAL_CONVOL => '0', - ABSOLUTE_CONVOL => '1', - NEGATIVE_CONVOL => '2' } - }, BrushApplicationMode => { contig => 1, header => 'appenums.h', @@ -116,15 +79,6 @@ package Gimp::CodeGen::enums; LOOP_TRIANGLE => '3', ONCE_END_COLOR => '4' } }, - InterpolationType => - { contig => 1, - header => 'appenums.h', - symbols => [ qw(LINEAR_INTERPOLATION CUBIC_INTERPOLATION - NEAREST_NEIGHBOR_INTERPOLATION) ], - mapping => { LINEAR_INTERPOLATION => '0', - CUBIC_INTERPOLATION => '1', - NEAREST_NEIGHBOR_INTERPOLATION => '2' } - }, OrientationType => { contig => 1, header => 'appenums.h', @@ -242,6 +196,52 @@ package Gimp::CodeGen::enums; BLUE_LUT => '3', ALPHA_LUT => '4' } }, + LayerModeEffects => + { contig => 1, + header => 'base/base-types.h', + symbols => [ qw(NORMAL_MODE DISSOLVE_MODE BEHIND_MODE + MULTIPLY_MODE SCREEN_MODE OVERLAY_MODE + DIFFERENCE_MODE ADDITION_MODE SUBTRACT_MODE + DARKEN_ONLY_MODE LIGHTEN_ONLY_MODE HUE_MODE + SATURATION_MODE COLOR_MODE VALUE_MODE DIVIDE_MODE + DODGE_MODE BURN_MODE HARDLIGHT_MODE) ], + mapping => { NORMAL_MODE => '0', + DISSOLVE_MODE => '1', + BEHIND_MODE => '2', + MULTIPLY_MODE => '3', + SCREEN_MODE => '4', + OVERLAY_MODE => '5', + DIFFERENCE_MODE => '6', + ADDITION_MODE => '7', + SUBTRACT_MODE => '8', + DARKEN_ONLY_MODE => '9', + LIGHTEN_ONLY_MODE => '10', + HUE_MODE => '11', + SATURATION_MODE => '12', + COLOR_MODE => '13', + VALUE_MODE => '14', + DIVIDE_MODE => '15', + DODGE_MODE => '16', + BURN_MODE => '17', + HARDLIGHT_MODE => '18' } + }, + ConvolutionType => + { contig => 1, + header => 'base/base-types.h', + symbols => [ qw(NORMAL_CONVOL ABSOLUTE_CONVOL NEGATIVE_CONVOL) ], + mapping => { NORMAL_CONVOL => '0', + ABSOLUTE_CONVOL => '1', + NEGATIVE_CONVOL => '2' } + }, + InterpolationType => + { contig => 1, + header => 'base/base-types.h', + symbols => [ qw(LINEAR_INTERPOLATION CUBIC_INTERPOLATION + NEAREST_NEIGHBOR_INTERPOLATION) ], + mapping => { LINEAR_INTERPOLATION => '0', + CUBIC_INTERPOLATION => '1', + NEAREST_NEIGHBOR_INTERPOLATION => '2' } + }, GimpImageBaseType => { contig => 1, header => 'core/core-types.h', diff --git a/tools/pdbgen/pdb/brushes.pdb b/tools/pdbgen/pdb/brushes.pdb index cdf4ea2d69..4b9be88072 100644 --- a/tools/pdbgen/pdb/brushes.pdb +++ b/tools/pdbgen/pdb/brushes.pdb @@ -358,7 +358,7 @@ CODE } @headers = qw("context_manager.h" "core/gimplist.h" "core/gimpbrush.h" - "core/gimpcontext.h" "core/gimpdatafactory.h" "temp_buf.h"); + "core/gimpcontext.h" "core/gimpdatafactory.h" "base/temp-buf.h"); @procs = qw(brushes_refresh brushes_get_brush brushes_set_brush brushes_get_opacity brushes_set_opacity brushes_get_spacing diff --git a/tools/pdbgen/pdb/color.pdb b/tools/pdbgen/pdb/color.pdb index 8ec4b7f062..fe6de5e2d3 100644 --- a/tools/pdbgen/pdb/color.pdb +++ b/tools/pdbgen/pdb/color.pdb @@ -762,8 +762,8 @@ CODE } @headers = qw("widgets/gimphistogramview.h" "core/gimpimage.h" - "core/gimpdrawable.h" "gimphistogram.h" "gimplut.h" - "lut_funcs.h" "pixel_region.h" "pixel_processor.h" + "core/gimpdrawable.h" "gimphistogram.h" "base/gimplut.h" + "lut_funcs.h" "base/pixel-region.h" "base/pixel-processor.h" "tools/tools-types.h"); @procs = qw(brightness_contrast levels posterize desaturate equalize invert diff --git a/tools/pdbgen/pdb/drawable.pdb b/tools/pdbgen/pdb/drawable.pdb index 79614977d4..7e7614acdb 100644 --- a/tools/pdbgen/pdb/drawable.pdb +++ b/tools/pdbgen/pdb/drawable.pdb @@ -538,7 +538,8 @@ CODE @headers = qw("core/gimplayermask.h" "core/gimpchannel.h" "core/gimpdrawable.h" "drawable.h" - "pdb_glue.h" "tile.h" "tile_manager.h" "temp_buf.h"); + "pdb_glue.h" "base/tile.h" "base/tile-manager.h" + "base/temp-buf.h"); @procs = qw(drawable_merge_shadow drawable_fill drawable_update drawable_mask_bounds drawable_image drawable_type diff --git a/tools/pdbgen/pdb/fileops.pdb b/tools/pdbgen/pdb/fileops.pdb index 561f92776d..881cb30189 100644 --- a/tools/pdbgen/pdb/fileops.pdb +++ b/tools/pdbgen/pdb/fileops.pdb @@ -272,7 +272,7 @@ HELP ); %invoke = ( - headers => [ qw( "gimprc.h") ], + headers => [ qw( "base/base-config.h") ], vars => [ 'static gint id = 0', 'static gint pid' ], code => <<'CODE' { @@ -280,7 +280,7 @@ HELP pid = getpid(); name = g_strdup_printf ("%s" G_DIR_SEPARATOR_S "gimp_temp.%d%d.%s", - temp_path, pid, id++, extension); + base_config->temp_path, pid, id++, extension); } CODE ); diff --git a/tools/pdbgen/pdb/image.pdb b/tools/pdbgen/pdb/image.pdb index 68f93f09ae..3fd75b199f 100644 --- a/tools/pdbgen/pdb/image.pdb +++ b/tools/pdbgen/pdb/image.pdb @@ -1461,7 +1461,7 @@ CODE @headers = qw( "gimage.h" "context_manager.h" "core/gimpcontainer.h" - "core/gimplist.h" "temp_buf.h" + "core/gimplist.h" "base/temp-buf.h" "libgimpmath/gimpmath.h" "libgimp/gimplimits.h" "libgimp/gimpintl.h"); diff --git a/tools/pdbgen/pdb/misc_tools.pdb b/tools/pdbgen/pdb/misc_tools.pdb index 12dc4d9afd..df01399325 100644 --- a/tools/pdbgen/pdb/misc_tools.pdb +++ b/tools/pdbgen/pdb/misc_tools.pdb @@ -1538,7 +1538,7 @@ sub ink { } @headers = qw("libgimpmath/gimpmath.h" "tools/tools-types.h" - "core/gimpdrawable.h" "tile_manager.h"); + "core/gimpdrawable.h" "base/tile-manager.h"); @procs = qw(airbrush airbrush_default blend bucket_fill by_color_select clone clone_default color_picker diff --git a/tools/pdbgen/pdb/paint_tools.pdb b/tools/pdbgen/pdb/paint_tools.pdb index 12dc4d9afd..df01399325 100644 --- a/tools/pdbgen/pdb/paint_tools.pdb +++ b/tools/pdbgen/pdb/paint_tools.pdb @@ -1538,7 +1538,7 @@ sub ink { } @headers = qw("libgimpmath/gimpmath.h" "tools/tools-types.h" - "core/gimpdrawable.h" "tile_manager.h"); + "core/gimpdrawable.h" "base/tile-manager.h"); @procs = qw(airbrush airbrush_default blend bucket_fill by_color_select clone clone_default color_picker diff --git a/tools/pdbgen/pdb/patterns.pdb b/tools/pdbgen/pdb/patterns.pdb index d7e37a8265..14d4fca178 100644 --- a/tools/pdbgen/pdb/patterns.pdb +++ b/tools/pdbgen/pdb/patterns.pdb @@ -221,7 +221,7 @@ CODE } @headers = qw("context_manager.h" "core/gimpcontext.h" "core/gimpdatafactory.h" - "core/gimplist.h" "core/gimppattern.h" "temp_buf.h"); + "core/gimplist.h" "core/gimppattern.h" "base/temp-buf.h"); @procs = qw(patterns_get_pattern patterns_set_pattern patterns_list patterns_get_pattern_data); diff --git a/tools/pdbgen/pdb/tools.pdb b/tools/pdbgen/pdb/tools.pdb index 12dc4d9afd..df01399325 100644 --- a/tools/pdbgen/pdb/tools.pdb +++ b/tools/pdbgen/pdb/tools.pdb @@ -1538,7 +1538,7 @@ sub ink { } @headers = qw("libgimpmath/gimpmath.h" "tools/tools-types.h" - "core/gimpdrawable.h" "tile_manager.h"); + "core/gimpdrawable.h" "base/tile-manager.h"); @procs = qw(airbrush airbrush_default blend bucket_fill by_color_select clone clone_default color_picker diff --git a/tools/pdbgen/pdb/transform_tools.pdb b/tools/pdbgen/pdb/transform_tools.pdb index 12dc4d9afd..df01399325 100644 --- a/tools/pdbgen/pdb/transform_tools.pdb +++ b/tools/pdbgen/pdb/transform_tools.pdb @@ -1538,7 +1538,7 @@ sub ink { } @headers = qw("libgimpmath/gimpmath.h" "tools/tools-types.h" - "core/gimpdrawable.h" "tile_manager.h"); + "core/gimpdrawable.h" "base/tile-manager.h"); @procs = qw(airbrush airbrush_default blend bucket_fill by_color_select clone clone_default color_picker