gimp/app/base/tile-cache.c

479 lines
10 KiB
C
Raw Normal View History

/* GIMP - The GNU Image Manipulation Program
app/Makefile.am app/channel_pvt.h app/drawable_pvt.h app/gdisplayF.h 2000-12-29 Michael Natterer <mitch@gimp.org> * app/Makefile.am * app/channel_pvt.h * app/drawable_pvt.h * app/gdisplayF.h * app/gimpdrawableP.h * app/gimpimageP.h * app/layer_pvt.h * app/toolsF.h: removed these files. * app/apptypes.h * tools/pdbgen/enums.pl: added tons of opaque typedefs and enums. * tools/pdbgen/pdb/brush_select.pdb * tools/pdbgen/pdb/brushes.pdb * tools/pdbgen/pdb/channel.pdb * tools/pdbgen/pdb/color.pdb * tools/pdbgen/pdb/convert.pdb * tools/pdbgen/pdb/display.pdb * tools/pdbgen/pdb/drawable.pdb * tools/pdbgen/pdb/fileops.pdb * tools/pdbgen/pdb/gradient_select.pdb * tools/pdbgen/pdb/gradients.pdb * tools/pdbgen/pdb/help.pdb * tools/pdbgen/pdb/image.pdb * tools/pdbgen/pdb/layer.pdb * tools/pdbgen/pdb/pattern_select.pdb * tools/pdbgen/pdb/patterns.pdb * tools/pdbgen/pdb/selection.pdb * tools/pdbgen/pdb/tools.pdb * app/*: chainsaw #include cleanup: - Never (never!!) include stuff in header files except where we need access to structures' contents (like derived objects). - Added prototypes and proper formating in many files. - The #include order in *all* *.c files is as follows: #include "config.h" #include <system stuff> #include <gtk/gtk.h> #include "apptypes.h" #include "gimp stuff" #include "libgimp stuff" #include "libgimp/gimpintl.h" By following this scheme we can easily see a file's dependencies from it's #include's and can grep for the inclusion to find out where a file is used. * tools/pdbgen/app.pl: changed to follow the include scheme above. * libgimp/Makefile.am * libgimp/gimpuitypes.h: new file, included from libgimp/gimpui.h and from app/apptypes.h. * libgimp/gimpcolorbutton.[ch] * libgimp/gimpdialog.[ch] * libgimp/gimphelpui.[ch] * libgimp/gimpparasite.[ch] * libgimp/gimppatheditor.[ch] * libgimp/gimpprotocol.c * libgimp/gimpquerybox.[ch] * libgimp/gimpsizeentry.[ch] * libgimp/gimptypes.h * libgimp/gimpui.h * libgimp/gimpunit.h * libgimp/gimpunitmenu.[ch] * libgimp/gimpwidgets.[ch]: changed accordingly. * plug-ins/FractalExplorer/Dialogs.c * plug-ins/gdyntext/message_window.c * plug-ins/imagemap/imap_default_dialog.c * plug-ins/imagemap/imap_file.c: these files used to include "libgimp/gimpui.h" without including "libgimp/gimp.h". This is no longer possible because the libgimpui headers don't inlcude "libgimp/gimpunit.h" any more.
2000-12-29 23:22:01 +08:00
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* This program is free software: you can redistribute it and/or modify
app/Makefile.am app/channel_pvt.h app/drawable_pvt.h app/gdisplayF.h 2000-12-29 Michael Natterer <mitch@gimp.org> * app/Makefile.am * app/channel_pvt.h * app/drawable_pvt.h * app/gdisplayF.h * app/gimpdrawableP.h * app/gimpimageP.h * app/layer_pvt.h * app/toolsF.h: removed these files. * app/apptypes.h * tools/pdbgen/enums.pl: added tons of opaque typedefs and enums. * tools/pdbgen/pdb/brush_select.pdb * tools/pdbgen/pdb/brushes.pdb * tools/pdbgen/pdb/channel.pdb * tools/pdbgen/pdb/color.pdb * tools/pdbgen/pdb/convert.pdb * tools/pdbgen/pdb/display.pdb * tools/pdbgen/pdb/drawable.pdb * tools/pdbgen/pdb/fileops.pdb * tools/pdbgen/pdb/gradient_select.pdb * tools/pdbgen/pdb/gradients.pdb * tools/pdbgen/pdb/help.pdb * tools/pdbgen/pdb/image.pdb * tools/pdbgen/pdb/layer.pdb * tools/pdbgen/pdb/pattern_select.pdb * tools/pdbgen/pdb/patterns.pdb * tools/pdbgen/pdb/selection.pdb * tools/pdbgen/pdb/tools.pdb * app/*: chainsaw #include cleanup: - Never (never!!) include stuff in header files except where we need access to structures' contents (like derived objects). - Added prototypes and proper formating in many files. - The #include order in *all* *.c files is as follows: #include "config.h" #include <system stuff> #include <gtk/gtk.h> #include "apptypes.h" #include "gimp stuff" #include "libgimp stuff" #include "libgimp/gimpintl.h" By following this scheme we can easily see a file's dependencies from it's #include's and can grep for the inclusion to find out where a file is used. * tools/pdbgen/app.pl: changed to follow the include scheme above. * libgimp/Makefile.am * libgimp/gimpuitypes.h: new file, included from libgimp/gimpui.h and from app/apptypes.h. * libgimp/gimpcolorbutton.[ch] * libgimp/gimpdialog.[ch] * libgimp/gimphelpui.[ch] * libgimp/gimpparasite.[ch] * libgimp/gimppatheditor.[ch] * libgimp/gimpprotocol.c * libgimp/gimpquerybox.[ch] * libgimp/gimpsizeentry.[ch] * libgimp/gimptypes.h * libgimp/gimpui.h * libgimp/gimpunit.h * libgimp/gimpunitmenu.[ch] * libgimp/gimpwidgets.[ch]: changed accordingly. * plug-ins/FractalExplorer/Dialogs.c * plug-ins/gdyntext/message_window.c * plug-ins/imagemap/imap_default_dialog.c * plug-ins/imagemap/imap_file.c: these files used to include "libgimp/gimpui.h" without including "libgimp/gimp.h". This is no longer possible because the libgimpui headers don't inlcude "libgimp/gimpunit.h" any more.
2000-12-29 23:22:01 +08:00
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
app/Makefile.am app/channel_pvt.h app/drawable_pvt.h app/gdisplayF.h 2000-12-29 Michael Natterer <mitch@gimp.org> * app/Makefile.am * app/channel_pvt.h * app/drawable_pvt.h * app/gdisplayF.h * app/gimpdrawableP.h * app/gimpimageP.h * app/layer_pvt.h * app/toolsF.h: removed these files. * app/apptypes.h * tools/pdbgen/enums.pl: added tons of opaque typedefs and enums. * tools/pdbgen/pdb/brush_select.pdb * tools/pdbgen/pdb/brushes.pdb * tools/pdbgen/pdb/channel.pdb * tools/pdbgen/pdb/color.pdb * tools/pdbgen/pdb/convert.pdb * tools/pdbgen/pdb/display.pdb * tools/pdbgen/pdb/drawable.pdb * tools/pdbgen/pdb/fileops.pdb * tools/pdbgen/pdb/gradient_select.pdb * tools/pdbgen/pdb/gradients.pdb * tools/pdbgen/pdb/help.pdb * tools/pdbgen/pdb/image.pdb * tools/pdbgen/pdb/layer.pdb * tools/pdbgen/pdb/pattern_select.pdb * tools/pdbgen/pdb/patterns.pdb * tools/pdbgen/pdb/selection.pdb * tools/pdbgen/pdb/tools.pdb * app/*: chainsaw #include cleanup: - Never (never!!) include stuff in header files except where we need access to structures' contents (like derived objects). - Added prototypes and proper formating in many files. - The #include order in *all* *.c files is as follows: #include "config.h" #include <system stuff> #include <gtk/gtk.h> #include "apptypes.h" #include "gimp stuff" #include "libgimp stuff" #include "libgimp/gimpintl.h" By following this scheme we can easily see a file's dependencies from it's #include's and can grep for the inclusion to find out where a file is used. * tools/pdbgen/app.pl: changed to follow the include scheme above. * libgimp/Makefile.am * libgimp/gimpuitypes.h: new file, included from libgimp/gimpui.h and from app/apptypes.h. * libgimp/gimpcolorbutton.[ch] * libgimp/gimpdialog.[ch] * libgimp/gimphelpui.[ch] * libgimp/gimpparasite.[ch] * libgimp/gimppatheditor.[ch] * libgimp/gimpprotocol.c * libgimp/gimpquerybox.[ch] * libgimp/gimpsizeentry.[ch] * libgimp/gimptypes.h * libgimp/gimpui.h * libgimp/gimpunit.h * libgimp/gimpunitmenu.[ch] * libgimp/gimpwidgets.[ch]: changed accordingly. * plug-ins/FractalExplorer/Dialogs.c * plug-ins/gdyntext/message_window.c * plug-ins/imagemap/imap_default_dialog.c * plug-ins/imagemap/imap_file.c: these files used to include "libgimp/gimpui.h" without including "libgimp/gimp.h". This is no longer possible because the libgimpui headers don't inlcude "libgimp/gimpunit.h" any more.
2000-12-29 23:22:01 +08:00
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
app/Makefile.am app/channel_pvt.h app/drawable_pvt.h app/gdisplayF.h 2000-12-29 Michael Natterer <mitch@gimp.org> * app/Makefile.am * app/channel_pvt.h * app/drawable_pvt.h * app/gdisplayF.h * app/gimpdrawableP.h * app/gimpimageP.h * app/layer_pvt.h * app/toolsF.h: removed these files. * app/apptypes.h * tools/pdbgen/enums.pl: added tons of opaque typedefs and enums. * tools/pdbgen/pdb/brush_select.pdb * tools/pdbgen/pdb/brushes.pdb * tools/pdbgen/pdb/channel.pdb * tools/pdbgen/pdb/color.pdb * tools/pdbgen/pdb/convert.pdb * tools/pdbgen/pdb/display.pdb * tools/pdbgen/pdb/drawable.pdb * tools/pdbgen/pdb/fileops.pdb * tools/pdbgen/pdb/gradient_select.pdb * tools/pdbgen/pdb/gradients.pdb * tools/pdbgen/pdb/help.pdb * tools/pdbgen/pdb/image.pdb * tools/pdbgen/pdb/layer.pdb * tools/pdbgen/pdb/pattern_select.pdb * tools/pdbgen/pdb/patterns.pdb * tools/pdbgen/pdb/selection.pdb * tools/pdbgen/pdb/tools.pdb * app/*: chainsaw #include cleanup: - Never (never!!) include stuff in header files except where we need access to structures' contents (like derived objects). - Added prototypes and proper formating in many files. - The #include order in *all* *.c files is as follows: #include "config.h" #include <system stuff> #include <gtk/gtk.h> #include "apptypes.h" #include "gimp stuff" #include "libgimp stuff" #include "libgimp/gimpintl.h" By following this scheme we can easily see a file's dependencies from it's #include's and can grep for the inclusion to find out where a file is used. * tools/pdbgen/app.pl: changed to follow the include scheme above. * libgimp/Makefile.am * libgimp/gimpuitypes.h: new file, included from libgimp/gimpui.h and from app/apptypes.h. * libgimp/gimpcolorbutton.[ch] * libgimp/gimpdialog.[ch] * libgimp/gimphelpui.[ch] * libgimp/gimpparasite.[ch] * libgimp/gimppatheditor.[ch] * libgimp/gimpprotocol.c * libgimp/gimpquerybox.[ch] * libgimp/gimpsizeentry.[ch] * libgimp/gimptypes.h * libgimp/gimpui.h * libgimp/gimpunit.h * libgimp/gimpunitmenu.[ch] * libgimp/gimpwidgets.[ch]: changed accordingly. * plug-ins/FractalExplorer/Dialogs.c * plug-ins/gdyntext/message_window.c * plug-ins/imagemap/imap_default_dialog.c * plug-ins/imagemap/imap_file.c: these files used to include "libgimp/gimpui.h" without including "libgimp/gimp.h". This is no longer possible because the libgimpui headers don't inlcude "libgimp/gimpunit.h" any more.
2000-12-29 23:22:01 +08:00
*/
#include "config.h"
removed from CVS, they are generated. 2001-12-07 Sven Neumann <sven@gimp.org> * app/core/gimpmarshal.[ch]: removed from CVS, they are generated. * app/base/Makefile.am * app/base/base-enums.h: new file defining enums that are to be registered. Used to build app/base/base-enums.c. * app/base/base-types.h: include base-enums.h. * tools/pdbgen/Makefile.am * tools/pdbgen/enumcode.pl * tools/pdbgen/enums.pl: parse the new base-enums.h file and modified the perl voodoo so it doesn't prefix enums with GIMP_ that are already properly namespaced. * app/core/core-types.h: don't need to chop GIMP from enum. * app/pdb/color_cmds.c * app/pdb/tools_cmds.c * libgimp/gimpenums.h * plug-ins/script-fu/script-fu-constants.c: regenerated. * app/config/gimpconfig-deserialize.[ch] * app/config/gimpconfig-serialize.[ch] * app/config/gimpconfig.[ch]: made GimpConfig an interface including a reasonable default implementation that works on object properties. * app/config/Makefile.am * app/config/gimpbaseconfig.[ch]: new GimpBaseConfig using the GimpConfig interface. Yet only used for testing from app/main.c. * app/main.c: test the new GimpBaseConfig object. * app/gimprc.c * app/base/base-config.h * app/base/*.c * app/core/gimpdatafiles.c * app/core/gimpdrawable-transform.c * app/core/gimppreviewcache.c * app/gui/preferences-dialog.c * app/paint-funcs/paint-funcs.c * app/xcf/xcf-seek.c: need to include glib-object.h since base-config contains registered enums now. Follow name change of InterpolationType to GimpInterpolationType.
2001-12-08 00:10:53 +08:00
#include <glib-object.h>
app/Makefile.am app/channel_pvt.h app/drawable_pvt.h app/gdisplayF.h 2000-12-29 Michael Natterer <mitch@gimp.org> * app/Makefile.am * app/channel_pvt.h * app/drawable_pvt.h * app/gdisplayF.h * app/gimpdrawableP.h * app/gimpimageP.h * app/layer_pvt.h * app/toolsF.h: removed these files. * app/apptypes.h * tools/pdbgen/enums.pl: added tons of opaque typedefs and enums. * tools/pdbgen/pdb/brush_select.pdb * tools/pdbgen/pdb/brushes.pdb * tools/pdbgen/pdb/channel.pdb * tools/pdbgen/pdb/color.pdb * tools/pdbgen/pdb/convert.pdb * tools/pdbgen/pdb/display.pdb * tools/pdbgen/pdb/drawable.pdb * tools/pdbgen/pdb/fileops.pdb * tools/pdbgen/pdb/gradient_select.pdb * tools/pdbgen/pdb/gradients.pdb * tools/pdbgen/pdb/help.pdb * tools/pdbgen/pdb/image.pdb * tools/pdbgen/pdb/layer.pdb * tools/pdbgen/pdb/pattern_select.pdb * tools/pdbgen/pdb/patterns.pdb * tools/pdbgen/pdb/selection.pdb * tools/pdbgen/pdb/tools.pdb * app/*: chainsaw #include cleanup: - Never (never!!) include stuff in header files except where we need access to structures' contents (like derived objects). - Added prototypes and proper formating in many files. - The #include order in *all* *.c files is as follows: #include "config.h" #include <system stuff> #include <gtk/gtk.h> #include "apptypes.h" #include "gimp stuff" #include "libgimp stuff" #include "libgimp/gimpintl.h" By following this scheme we can easily see a file's dependencies from it's #include's and can grep for the inclusion to find out where a file is used. * tools/pdbgen/app.pl: changed to follow the include scheme above. * libgimp/Makefile.am * libgimp/gimpuitypes.h: new file, included from libgimp/gimpui.h and from app/apptypes.h. * libgimp/gimpcolorbutton.[ch] * libgimp/gimpdialog.[ch] * libgimp/gimphelpui.[ch] * libgimp/gimpparasite.[ch] * libgimp/gimppatheditor.[ch] * libgimp/gimpprotocol.c * libgimp/gimpquerybox.[ch] * libgimp/gimpsizeentry.[ch] * libgimp/gimptypes.h * libgimp/gimpui.h * libgimp/gimpunit.h * libgimp/gimpunitmenu.[ch] * libgimp/gimpwidgets.[ch]: changed accordingly. * plug-ins/FractalExplorer/Dialogs.c * plug-ins/gdyntext/message_window.c * plug-ins/imagemap/imap_default_dialog.c * plug-ins/imagemap/imap_file.c: these files used to include "libgimp/gimpui.h" without including "libgimp/gimp.h". This is no longer possible because the libgimpui headers don't inlcude "libgimp/gimpunit.h" any more.
2000-12-29 23:22:01 +08:00
new directory app/base/ 2001-05-15 Michael Natterer <mitch@gimp.org> * 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-15 19:25:25 +08:00
#include "base-types.h"
app/Makefile.am app/channel_pvt.h app/drawable_pvt.h app/gdisplayF.h 2000-12-29 Michael Natterer <mitch@gimp.org> * app/Makefile.am * app/channel_pvt.h * app/drawable_pvt.h * app/gdisplayF.h * app/gimpdrawableP.h * app/gimpimageP.h * app/layer_pvt.h * app/toolsF.h: removed these files. * app/apptypes.h * tools/pdbgen/enums.pl: added tons of opaque typedefs and enums. * tools/pdbgen/pdb/brush_select.pdb * tools/pdbgen/pdb/brushes.pdb * tools/pdbgen/pdb/channel.pdb * tools/pdbgen/pdb/color.pdb * tools/pdbgen/pdb/convert.pdb * tools/pdbgen/pdb/display.pdb * tools/pdbgen/pdb/drawable.pdb * tools/pdbgen/pdb/fileops.pdb * tools/pdbgen/pdb/gradient_select.pdb * tools/pdbgen/pdb/gradients.pdb * tools/pdbgen/pdb/help.pdb * tools/pdbgen/pdb/image.pdb * tools/pdbgen/pdb/layer.pdb * tools/pdbgen/pdb/pattern_select.pdb * tools/pdbgen/pdb/patterns.pdb * tools/pdbgen/pdb/selection.pdb * tools/pdbgen/pdb/tools.pdb * app/*: chainsaw #include cleanup: - Never (never!!) include stuff in header files except where we need access to structures' contents (like derived objects). - Added prototypes and proper formating in many files. - The #include order in *all* *.c files is as follows: #include "config.h" #include <system stuff> #include <gtk/gtk.h> #include "apptypes.h" #include "gimp stuff" #include "libgimp stuff" #include "libgimp/gimpintl.h" By following this scheme we can easily see a file's dependencies from it's #include's and can grep for the inclusion to find out where a file is used. * tools/pdbgen/app.pl: changed to follow the include scheme above. * libgimp/Makefile.am * libgimp/gimpuitypes.h: new file, included from libgimp/gimpui.h and from app/apptypes.h. * libgimp/gimpcolorbutton.[ch] * libgimp/gimpdialog.[ch] * libgimp/gimphelpui.[ch] * libgimp/gimpparasite.[ch] * libgimp/gimppatheditor.[ch] * libgimp/gimpprotocol.c * libgimp/gimpquerybox.[ch] * libgimp/gimpsizeentry.[ch] * libgimp/gimptypes.h * libgimp/gimpui.h * libgimp/gimpunit.h * libgimp/gimpunitmenu.[ch] * libgimp/gimpwidgets.[ch]: changed accordingly. * plug-ins/FractalExplorer/Dialogs.c * plug-ins/gdyntext/message_window.c * plug-ins/imagemap/imap_default_dialog.c * plug-ins/imagemap/imap_file.c: these files used to include "libgimp/gimpui.h" without including "libgimp/gimp.h". This is no longer possible because the libgimpui headers don't inlcude "libgimp/gimpunit.h" any more.
2000-12-29 23:22:01 +08:00
#include "tile.h"
new directory app/base/ 2001-05-15 Michael Natterer <mitch@gimp.org> * 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-15 19:25:25 +08:00
#include "tile-cache.h"
#include "tile-swap.h"
#include "tile-rowhints.h"
new directory app/base/ 2001-05-15 Michael Natterer <mitch@gimp.org> * 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-15 19:25:25 +08:00
#include "tile-private.h"
2009-06-04 17:13:42 +08:00
#define IDLE_SWAPPER_START 1000
#define IDLE_SWAPPER_INTERVAL_MS 20
#define IDLE_SWAPPER_TILES_PER_INTERVAL 10
1997-11-25 06:05:25 +08:00
typedef struct _TileList
{
Tile *first;
Tile *last;
} TileList;
2009-06-04 17:13:42 +08:00
static gulong cur_cache_size = 0;
static gulong max_cache_size = 0;
static gulong cur_cache_dirty = 0;
static TileList tile_list = { NULL, NULL };
static guint idle_swapper = 0;
static guint idle_delay = 0;
static Tile *idle_scan_last = NULL;
#ifdef TILE_PROFILING
extern gulong tile_idle_swapout;
extern gulong tile_total_zorched;
extern gulong tile_total_zorched_swapout;
extern glong tile_total_interactive_sec;
extern glong tile_total_interactive_usec;
extern gint tile_exist_count;
#endif
#ifdef ENABLE_MP
static GMutex *tile_cache_mutex = NULL;
#define TILE_CACHE_LOCK g_mutex_lock (tile_cache_mutex)
#define TILE_CACHE_UNLOCK g_mutex_unlock (tile_cache_mutex)
#else
#define TILE_CACHE_LOCK /* nothing */
#define TILE_CACHE_UNLOCK /* nothing */
#endif
#define PENDING_WRITE(t) ((t)->dirty || (t)->swap_offset == -1)
2009-06-04 17:13:42 +08:00
static gboolean tile_cache_zorch_next (void);
static void tile_cache_flush_internal (Tile *tile);
static gboolean tile_idle_preswap (gpointer data);
#ifdef TILE_PROFILING
static void tile_verify (void);
#endif
void
tile_cache_init (gulong tile_cache_size)
{
#ifdef ENABLE_MP
g_return_if_fail (tile_cache_mutex == NULL);
tile_cache_mutex = g_mutex_new ();
#endif
tile_list.first = tile_list.last = NULL;
idle_scan_last = NULL;
max_cache_size = tile_cache_size;
}
void
tile_cache_exit (void)
{
if (idle_swapper)
{
g_source_remove (idle_swapper);
idle_swapper = 0;
}
if (cur_cache_size > 0)
g_warning ("tile cache not empty (%ld bytes left)", cur_cache_size);
tile_cache_set_size (0);
#ifdef ENABLE_MP
g_mutex_free (tile_cache_mutex);
tile_cache_mutex = NULL;
#endif
}
void
tile_cache_suspend_idle_swapper(void)
{
idle_delay = 1;
}
1997-11-25 06:05:25 +08:00
void
tile_cache_insert (Tile *tile)
{
TILE_CACHE_LOCK;
if (! tile->data)
goto out;
1997-11-25 06:05:25 +08:00
/* 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.
*/
if (tile->cached)
{
/* Tile is in the cache. Remove it from the list. */
if (tile->next)
tile->next->prev = tile->prev;
else
tile_list.last = tile->prev;
if(tile->prev){
tile->prev->next = tile->next;
}else{
tile_list.first = tile->next;
}
if (PENDING_WRITE(tile))
cur_cache_dirty -= tile->size;
if(tile == idle_scan_last)
idle_scan_last = tile->next;
1997-11-25 06:05:25 +08:00
}
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.
*/
#ifdef TILE_PROFILING
if ((cur_cache_size + tile->size) > max_cache_size)
{
GTimeVal now;
GTimeVal later;
2009-06-04 17:13:42 +08:00
g_get_current_time(&now);
#endif
while ((cur_cache_size + tile->size) > max_cache_size)
{
if (! tile_cache_zorch_next ())
{
g_warning ("cache: unable to find room for a tile");
goto out;
}
}
#ifdef TILE_PROFILING
2009-06-04 17:13:42 +08:00
g_get_current_time (&later);
tile_total_interactive_usec += later.tv_usec - now.tv_usec;
tile_total_interactive_sec += later.tv_sec - now.tv_sec;
if (tile_total_interactive_usec < 0)
{
tile_total_interactive_usec += 1000000;
tile_total_interactive_sec--;
}
if (tile_total_interactive_usec > 1000000)
{
tile_total_interactive_usec -= 1000000;
tile_total_interactive_sec++;
}
}
#endif
cur_cache_size += tile->size;
1997-11-25 06:05:25 +08:00
}
/* Put the tile at the end of the proper list */
tile->next = NULL;
tile->prev = tile_list.last;
2009-06-04 17:13:42 +08:00
if (tile_list.last)
tile_list.last->next = tile;
2009-06-04 17:13:42 +08:00
else
tile_list.first = tile;
2009-06-04 17:13:42 +08:00
tile_list.last = tile;
tile->cached = TRUE;
idle_delay = 1;
if (PENDING_WRITE(tile))
{
cur_cache_dirty += tile->size;
2009-06-04 17:13:42 +08:00
if (! idle_scan_last)
idle_scan_last=tile;
2009-06-04 17:13:42 +08:00
if (! idle_swapper)
{
#ifdef TILE_PROFILING
g_printerr("idle swapper -> started\n");
g_printerr("idle swapper -> waiting");
#endif
idle_delay = 0;
idle_swapper = g_timeout_add_full (G_PRIORITY_LOW,
IDLE_SWAPPER_START,
tile_idle_preswap,
NULL, NULL);
}
}
out:
TILE_CACHE_UNLOCK;
1997-11-25 06:05:25 +08:00
}
void
tile_cache_flush (Tile *tile)
{
TILE_CACHE_LOCK;
if (tile->cached)
tile_cache_flush_internal (tile);
TILE_CACHE_UNLOCK;
}
void
tile_cache_set_size (gulong cache_size)
{
TILE_CACHE_LOCK;
idle_delay = 1;
max_cache_size = cache_size;
while (cur_cache_size > max_cache_size)
{
if (! tile_cache_zorch_next ())
break;
}
TILE_CACHE_UNLOCK;
}
static void
tile_cache_flush_internal (Tile *tile)
{
tile->cached = FALSE;
2009-06-04 17:13:42 +08:00
if (PENDING_WRITE(tile))
cur_cache_dirty -= tile->size;
2009-06-04 17:13:42 +08:00
cur_cache_size -= tile->size;
2009-06-04 17:13:42 +08:00
if (tile->next)
tile->next->prev = tile->prev;
else
tile_list.last = tile->prev;
2009-06-04 17:13:42 +08:00
if (tile->prev)
tile->prev->next = tile->next;
2009-06-04 17:13:42 +08:00
else
tile_list.first = tile->next;
2009-06-04 17:13:42 +08:00
if (tile == idle_scan_last)
idle_scan_last = tile->next;
2009-06-04 17:13:42 +08:00
tile->next = tile->prev = NULL;
1997-11-25 06:05:25 +08:00
}
static gboolean
tile_cache_zorch_next (void)
1997-11-25 06:05:25 +08:00
{
2009-06-04 17:13:42 +08:00
Tile *tile = tile_list.first;
if (! tile)
return FALSE;
#ifdef TILE_PROFILING
tile_total_zorched++;
tile->zorched = TRUE;
2009-06-04 17:13:42 +08:00
if (PENDING_WRITE (tile))
{
tile_total_zorched_swapout++;
tile->zorchout = TRUE;
}
#endif
2009-06-04 17:13:42 +08:00
tile_cache_flush_internal (tile);
2009-06-04 17:13:42 +08:00
if (PENDING_WRITE (tile))
1998-07-13 06:35:01 +08:00
{
idle_delay = 1;
1998-07-13 06:35:01 +08:00
tile_swap_out (tile);
}
if (! tile->dirty)
{
g_free (tile->data);
tile->data = NULL;
2009-06-04 17:13:42 +08:00
#ifdef TILE_PROFILING
tile_exist_count--;
#endif
return TRUE;
}
/* unable to swap out tile for some reason */
return FALSE;
}
new directory app/base/ 2001-05-15 Michael Natterer <mitch@gimp.org> * 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-15 19:25:25 +08:00
static gboolean
tile_idle_preswap_run (gpointer data)
1997-11-25 06:05:25 +08:00
{
Tile *tile;
int count = 0;
if (idle_delay)
{
#ifdef TILE_PROFILING
g_printerr("\nidle swapper -> waiting");
#endif
idle_delay = 0;
idle_swapper = g_timeout_add_full (G_PRIORITY_LOW,
IDLE_SWAPPER_START,
tile_idle_preswap,
NULL, NULL);
return FALSE;
}
TILE_CACHE_LOCK;
#ifdef TILE_PROFILING
g_printerr(".");
#endif
tile = idle_scan_last;
2009-06-04 17:13:42 +08:00
while (tile)
{
2009-06-04 17:13:42 +08:00
if (PENDING_WRITE (tile))
{
idle_scan_last = tile->next;
2009-06-04 17:13:42 +08:00
#ifdef TILE_PROFILING
tile_idle_swapout++;
#endif
tile_swap_out (tile);
2009-06-04 17:13:42 +08:00
if (! PENDING_WRITE(tile))
cur_cache_dirty -= tile->size;
2009-06-04 17:13:42 +08:00
count++;
2009-06-04 17:13:42 +08:00
if (count >= IDLE_SWAPPER_TILES_PER_INTERVAL)
{
TILE_CACHE_UNLOCK;
return TRUE;
}
}
2009-06-04 17:13:42 +08:00
tile = tile->next;
}
2009-06-04 17:13:42 +08:00
#ifdef TILE_PROFILING
2009-06-04 17:13:42 +08:00
g_printerr ("\nidle swapper -> stopped\n");
#endif
idle_scan_last = NULL;
idle_swapper = 0;
#ifdef TILE_PROFILING
2009-06-04 17:13:42 +08:00
tile_verify ();
#endif
TILE_CACHE_UNLOCK;
2009-06-04 17:13:42 +08:00
return FALSE;
}
static gboolean
tile_idle_preswap (gpointer data)
{
2009-06-04 17:13:42 +08:00
if (idle_delay){
#ifdef TILE_PROFILING
g_printerr(".");
#endif
idle_delay = 0;
return TRUE;
}
2009-06-04 17:13:42 +08:00
#ifdef TILE_PROFILING
2009-06-04 17:13:42 +08:00
tile_verify ();
g_printerr("\nidle swapper -> running");
#endif
2009-06-04 17:13:42 +08:00
idle_swapper = g_timeout_add_full (G_PRIORITY_LOW,
IDLE_SWAPPER_INTERVAL_MS,
tile_idle_preswap_run,
NULL, NULL);
return FALSE;
}
#ifdef TILE_PROFILING
static void
2009-06-04 17:13:42 +08:00
tile_verify (void)
{
/* scan list linearly, count metrics, compare to running totals */
2009-06-04 17:13:42 +08:00
const Tile *t;
gulong local_size = 0;
gulong local_dirty = 0;
gulong acc = 0;
2009-06-04 17:13:42 +08:00
for (t = tile_list.first; t; t = t->next)
{
2009-06-04 17:13:42 +08:00
local_size += t->size;
if (PENDING_WRITE (t))
local_dirty += t->size;
}
2009-06-04 17:13:42 +08:00
if (local_size != cur_cache_size)
g_printerr ("\nCache size mismatch: running=%lu, tested=%lu\n",
cur_cache_size,local_size);
2009-06-04 17:13:42 +08:00
if (local_dirty != cur_cache_dirty)
g_printerr ("\nCache dirty mismatch: running=%lu, tested=%lu\n",
cur_cache_dirty,local_dirty);
/* scan forward from scan list */
2009-06-04 17:13:42 +08:00
for (t = idle_scan_last; t; t = t->next)
{
2009-06-04 17:13:42 +08:00
if (PENDING_WRITE (t))
acc += t->size;
}
2009-06-04 17:13:42 +08:00
if (acc != local_dirty)
g_printerr ("\nDirty scan follower mismatch: running=%lu, tested=%lu\n",
acc,local_dirty);
1997-11-25 06:05:25 +08:00
}
#endif