Commit Graph

95 Commits

Author SHA1 Message Date
Michael Natterer 021a49ce73 Add tile_manager_duplicate() which does quick tile-by-tile COW copy
and use it instead of duplicating the same code twice less efficiently.
2010-03-19 19:18:18 +01:00
Michael Natterer 68ee4a5d6c base: add a proper version of the code that tracked down the tile manager leak
For GIMP_UNSTABLE, keep around a list of allocated tile managers and
have a function tile_manager_exit() which complains about them and
unrefs them. This is infinitely more helpful than the tile cache and
swap complaining about not being empty, because there is absolutely
nothing wrong with swap and cache when we simply leaked tile managers.
2010-02-10 12:33:30 +01:00
Sven Neumann b2fc6d2876 whitespace and coding style cleanups 2009-06-04 12:15:06 +02:00
Monty e925338321 Replace two list 'flush clean first' cache strategy with an LRU strategy.
Although the clean-first strategy gives fast light-load performance,
it also degrades catastrophically under moderate cache pressure. LRU is
not as efficient under light load, but degrades more gracefully under
moderate and heavy load.
2009-06-04 12:15:05 +02:00
Monty ac51a588d6 Add additional profiling to tile usage.
Add more profiling In order to analyze efficiency and behavior of the
tile cache. Profiling includes run-time indication of idle swapper
activity.

Also, fixes to original tile profiling code that appears to have
bitrotted some; it was no longer tracking changes made to tile memory
outside of tile.c.
2009-06-04 12:15:05 +02:00
Michael Natterer d9b5207aa2 Change licence to GPLv3 (and to LGPLv3 for libgimp).
2009-01-17  Michael Natterer  <mitch@gimp.org>

	* all files with a GPL header and all COPYING files:

	Change licence to GPLv3 (and to LGPLv3 for libgimp).

	Cleaned up some copyright headers and regenerated the parsers in
	the ImageMap plugin.


svn path=/trunk/; revision=27913
2009-01-17 22:28:01 +00:00
Sven Neumann 972309fe48 changed to silently return in case of out-of-bounds access. There's code
2008-08-25  Sven Neumann  <sven@gimp.org>

	* app/base/tile-manager.c (read_pixel_data_1): changed to 
silently
	return in case of out-of-bounds access. There's code that relies
	on this.

	* app/base/pixel-surround.[ch]: added SMEAR as another edge
	strategy for the PixelSurround helper.

	* core/gimp-transform-region.c: changed accordingly.


svn path=/trunk/; revision=26767
2008-08-25 20:38:52 +00:00
Sven Neumann 3e5d269e59 provide a macro version of tile_data_pointer().
2008-08-25  Sven Neumann  <sven@gimp.org>

	* app/base/tile-private.h: provide a macro version of
	tile_data_pointer().

	* app/base/tile.c (tile_data_pointer): turned into a wrapper
	around the TILE_DATA_POINTER() macro.

	* app/base/tile-manager.c (read_pixel_data) (read_pixel_data_1)
	(write_pixel_data) (write_pixel_data_1): access tile struct
	members directly and use the new macro to access the tile data.


svn path=/trunk/; revision=26757
2008-08-25 13:00:28 +00:00
Sven Neumann 47afc75282 removed redundant check that is already performed by
2008-08-25  Sven Neumann  <sven@gimp.org>

	* app/base/tile-manager.c (read_pixel_data_1): removed redundant
	check that is already performed by tile_manager_get_tile_num().
	Warn if an out-of-bounds read is requested, instead of silently
	doing nothing.



svn path=/trunk/; revision=26755
2008-08-25 12:00:58 +00:00
Sven Neumann 9e163bb41b implement tile_manager_get_tile_coordinates() by calling
2008-08-08  Sven Neumann  <sven@gimp.org>

	* app/base/tile-manager.c: implement
	tile_manager_get_tile_coordinates() by calling
	tile_manager_get_tile_col_row() instead of the other way around.
	Saves two multiplications and divisions for each call of
	tile_manager_get_tile_col_row().


svn path=/trunk/; revision=26446
2008-08-08 11:33:18 +00:00
Sven Neumann 7f05996abc simplified tile_manager_map_tile()
svn path=/trunk/; revision=26439
2008-08-08 11:00:29 +00:00
Sven Neumann 576ea3cda1 whitespace fix
svn path=/trunk/; revision=26438
2008-08-08 10:57:38 +00:00
Sven Neumann c10f60e4c8 introduced utility function tile_manager_allocate_tiles() to avoid code
2008-08-08  Sven Neumann  <sven@gimp.org>

	* app/base/tile-manager.c: introduced utility function
	tile_manager_allocate_tiles() to avoid code duplication.


svn path=/trunk/; revision=26437
2008-08-08 10:55:46 +00:00
Sven Neumann eb92ab8b22 fixed broken copy-on-write code. The old code did not insert the new tile
2008-08-07  Sven Neumann  <sven@gimp.org>

	* app/base/tile-manager.c (tile_manager_invalidate_tile): fixed
	broken copy-on-write code. The old code did not insert the new
	tile in the tile-manager's tile pointer array.

	(tile_manager_map): changed in a similar way as
	tile_manager_invalidate_tile(). This code was not broken, but it
	is easier to read now.

	* app/base/tile-private.h: moved a comment.

	* app/core/gimpselection.c (gimp_selection_extract): removed
	workaround for above bug.


svn path=/trunk/; revision=26419
2008-08-07 15:29:02 +00:00
Michael Natterer 31a5214fd5 app/base/tile-manager.c use G_STRLOC instead of G_GNUC_FUNCTION (which is
2008-01-28  Michael Natterer  <mitch@gimp.org>

	* app/base/tile-manager.c
	* plug-ins/common/lcms.c: use G_STRLOC instead of
	G_GNUC_FUNCTION (which is now deprecated).


svn path=/trunk/; revision=24727
2008-01-28 13:19:42 +00:00
Michael Natterer 6be63006ec add boxed type GIMP_TYPE_TILE_MANAGER.
2007-12-29  Michael Natterer  <mitch@gimp.org>

	* app/base/tile-manager.[ch]: add boxed type GIMP_TYPE_TILE_MANAGER.

	* app/gegl/gimpoperationtilesink.c
	* app/gegl/gimpoperationtilesource.c: use GParamSpecBoxed instead
	of GParamSpecPointer for the tile-manager properties and ref them
	properly. Some cleanup.


svn path=/trunk/; revision=24465
2007-12-29 13:46:13 +00:00
Sven Neumann e080bb1f26 renamed tile_manager_validate() to tile_manager_validate_tile(). If no
2007-12-18  Sven Neumann  <sven@gimp.org>

	* app/base/tile-manager.[ch]: renamed tile_manager_validate() to
	tile_manager_validate_tile(). If no validate_proc is set,
	initialize the tile data to all zero when validating it. This way
	we never hand out uninitialized data and valgrind doesn't need to
	complain any longer.

	* app/base/tile.c: changed accordingly.

	* app/core/gimpselection.c: no need to set an extra validate_proc
	here as the default implementation now does the job for us.

svn path=/trunk/; revision=24389
2007-12-18 13:07:01 +00:00
Sven Neumann 870ccda6f7 if no tiles have been allocated, there's no need to invalidate any. Should
2007-11-30  Sven Neumann  <sven@gimp.org>

	* app/base/tile-manager.c (tile_manager_invalidate_area): if no
	tiles have been allocated, there's no need to invalidate any.
	Should fix bug #500178.

svn path=/trunk/; revision=24244
2007-11-30 12:19:21 +00:00
Michael Natterer 036085fd9e app/base/temp-buf.c app/base/tile-manager.c accept NULL in all
2007-11-16  Michael Natterer  <mitch@gimp.org>

	* app/base/temp-buf.c
	* app/base/tile-manager.c
	* app/core/gimpobject.c: accept NULL in all get_memsize() functions.

	* app/core/gimp-utils.[ch]: ditto. Added gimp_string_get_memsize().

	* app/core/gimp.c
	* app/core/gimpbrush.c
	* app/core/gimpbuffer.c
	* app/core/gimpcontainer.c
	* app/core/gimpcontext.c
	* app/core/gimpdata.c
	* app/core/gimpdrawable.c
	* app/core/gimpdrawablemodundo.c
	* app/core/gimpdrawableundo.c
	* app/core/gimpimage.c
	* app/core/gimpitempropundo.c
	* app/core/gimplayer.c
	* app/core/gimpmaskundo.c
	* app/core/gimppalette.c
	* app/core/gimpparasitelist.c
	* app/core/gimppattern.c
	* app/core/gimppreviewcache.c
	* app/core/gimpundo.c
	* app/core/gimpundostack.c
	* app/core/gimpviewable.c
	* app/pdb/gimpprocedure.c
	* app/plug-in/gimpplugindef.c
	* app/plug-in/gimppluginmanager.c
	* app/plug-in/gimppluginprocedure.c
	* app/text/gimptext.c
	* app/text/gimptextlayer.c
	* app/text/gimptextundo.c
	* app/vectors/gimpvectorsmodundo.c: simplify
	GimpObject::get_memsize() implementations accordingly.

	* app/core/gimpimageundo.c: ditto. Always keep around colormaps in
	chunks of GIMP_IMAGE_COLORMAP_SIZE to be coonsistent with the
	other colormap handling code.


svn path=/trunk/; revision=24174
2007-11-16 18:19:30 +00:00
Sven Neumann 30e5f7063b app/base/Makefile.am app/base/tile.[ch] moved tile row hints code to its
2007-10-09  Sven Neumann  <sven@gimp.org>

	* app/base/Makefile.am
	* app/base/tile.[ch]
	* app/base/tile-rowhints.[ch]: moved tile row hints code to its
	own file.
	
	* app/base/tile-cache.c
	* app/base/tile-manager.c
	* app/base/tile-swap.c
	* app/paint-funcs/paint-funcs.c: changed accordingly.

svn path=/trunk/; revision=23781
2007-10-09 16:14:10 +00:00
Sven Neumann 1954ee81fe use the offsets module TILE_WIDTH and TILE_HEIGHT instead of doing the
2007-09-12  Sven Neumann  <sven@gimp.org>

	* app/base/tile.c (tile_data_pointer): use the offsets module
	TILE_WIDTH and TILE_HEIGHT instead of doing the module operation
	in each and every caller.

	* app/base/boundary.c
	* app/base/pixel-region.c
	* app/base/tile-manager.c
	* app/core/gimpchannel.c
	* app/core/gimpdrawable-blend.c
	* app/core/gimpdrawable.c
	* app/core/gimpimage-contiguous-region.c
	* app/core/gimplayer.c
	* app/display/gimpdisplayshell-render.c
	* app/paint-funcs/paint-funcs.c
	* app/paint/gimppaintcore.c
	* app/tools/gimpiscissorstool.c: changed accordingly.


svn path=/trunk/; revision=23515
2007-09-12 18:29:11 +00:00
Michael Natterer 15c969c862 use a temporary variable to store the return value of tile_manager_get()
2007-09-07  Michael Natterer  <mitch@gimp.org>

	* app/base/tile-manager.c (read_pixel_data_1): use a temporary
	variable to store the return value of tile_manager_get() instead
	of assigning to tm->cached_tile directly to make sure
	tm->cached_num and tm->cached_tile are always in a consistent
	state (the requested tile might be invalid and needs to be
	validated, which would call tile_manager_get() recursively, which
	in turn would clear the cached tile). Fixes bug #472770.


svn path=/trunk/; revision=23472
2007-09-07 08:35:21 +00:00
Michael Natterer a55fe4cf6f if tile_manager->cached_tile is requested for writing, clear the cache
2007-08-31  Michael Natterer  <mitch@gimp.org>

	* app/base/tile-manager.c (tile_manager_get): if
	tile_manager->cached_tile is requested for writing, clear the
	cache before giving out the tile. Fixes bug #472170.


svn path=/trunk/; revision=23425
2007-08-31 10:55:09 +00:00
Sven Neumann 610feafb3e app/base/base-types.h app/base/tile-manager.[ch] removed accessors for
2007-06-21  Sven Neumann  <sven@gimp.org>

	* app/base/base-types.h
	* app/base/tile-manager.[ch]
	* app/base/tile-manager-private.h: removed accessors for user_data.
	Instead pass the user_data when setting the validation proc.

	* app/base/tile-pyramid.c
	* app/core/gimpchannel.c
	* app/core/gimpprojection.c
	* app/core/gimpselection.c
	* app/tools/gimpiscissorstool.c: changed accordingly.

svn path=/trunk/; revision=22820
2007-06-21 14:36:58 +00:00
Sven Neumann f2e9d552b2 app/base/tile-manager.[ch] removed "level_below" from the TileManager
2007-06-21  Sven Neumann  <sven@gimp.org>

	* app/base/tile-manager.[ch]
	* app/base/tile-manager-private.h: removed "level_below" from the
	TileManager struct.
	
	* app/base/tile-pyramid.c: use the TileManager's user_data to
	store a pointer to the lower level.

svn path=/trunk/; revision=22819
2007-06-21 14:13:01 +00:00
Sven Neumann 173c9d40aa use gboolean for boolean parameters.
2007-06-21  Sven Neumann  <sven@gimp.org>

	* app/base/tile-manager.[ch]: use gboolean for boolean parameters.

	* app/base/tile-pyramid.c (tile_pyramid_get_memsize): pass TRUE
	for sparse to tile_manager_get_memsize().

	* app/base/tile.c
	* app/base/tile-swap.c: minor cleanups.

	* app/core/gimpprojection.c (gimp_projection_get_tiles_at_level):
	inline the creation of the TilePyramid.

svn path=/trunk/; revision=22818
2007-06-21 14:02:14 +00:00
Sven Neumann 923b06bd0e removed unused function tile_mark_valid().
2007-06-20  Sven Neumann  <sven@gimp.org>

	* app/base/tile.[ch]: removed unused function tile_mark_valid().

	* app/base/tile-manager.[ch]: removed unused public API and cleaned
	up internals used for invalidating tiles.

svn path=/trunk/; revision=22806
2007-06-20 14:25:07 +00:00
Sven Neumann 345855a711 formatting.
2007-06-07  Sven Neumann  <sven@gimp.org>

	* app/base/tile-manager.c: formatting.


svn path=/trunk/; revision=22742
2007-06-07 21:55:46 +00:00
Martin Nordholts 7917611e53 Implemented an image pyramid for the GimpProjection. An image pyramid
2007-06-06  Martin Nordholts  <martinn@svn.gnome.org>

	Implemented an image pyramid for the GimpProjection. An image pyramid
	caches a projection at several sizes, causing the rendering code not to
	have to swap in all tiles of a (potentially) large image; it can use
	small versions of the projection if the user is zoomed out.

	The image pyramid also imroves visual quality, especially at zoom levels
	where there is a pyramid level that matches perfectly (i.e. at e.g. 50%,
	25%, and 12.5% zoom). A step on the right track for bug #76096.

	* app/core/gimpprojection.[ch]: Adjusted to make use of an image
	pyramid. GimpProjection now keeps an array of TileManager:s, one per
	pyramid level. Renamed _alloc_tiles to _alloc_levels.

	* app/display/gimpdisplayshell-draw.c: (gimp_display_shell_draw_area):
	Use the right GimpProjection level when drawing

	* app/display/gimpdisplayshell-render.c: (render_image_init_info_full):
	Setup RenderInfo with level in mind

	* app/base/tile-manager.[ch]: Extended API a bit, nothing complicated.

	* app/base/tile-manager-private.h (struct _TileManager): Keep a pointer
	to the level below for use in an image pyramid.


svn path=/trunk/; revision=22727
2007-06-06 13:45:44 +00:00
Sven Neumann 3081e02db0 renamed tile_sanitize_rowhints() to tile_allocate_rowhints().
2007-05-29  Sven Neumann  <sven@gimp.org>

	* app/base/tile.[ch]: renamed tile_sanitize_rowhints() to
	tile_allocate_rowhints().
	
	* app/base/tile-manager.c
	* app/paint-funcs/paint-funcs.c: changed accordingly.

svn path=/trunk/; revision=22648
2007-05-29 09:06:15 +00:00
Michael Natterer 91ca374788 allocate tile->rowhint using tile_sanitize_rowhints() (which uses GSlice)
2007-05-28  Michael Natterer  <mitch@gimp.org>

	* app/base/tile-manager.c (tile_manager_get): allocate
	tile->rowhint using tile_sanitize_rowhints() (which uses GSlice)
	instead of g_memdup(). Fixes bug #441878.


svn path=/trunk/; revision=22643
2007-05-28 21:27:15 +00:00
Sven Neumann 1a3abcff9b app/base/tile-manager.[ch] removed unused code.
2007-05-22  Sven Neumann  <sven@gimp.org>

	* app/base/tile-manager.[ch]
	* app/base/tile-manager-private.h: removed unused code.

	* app/base/pixel-surround.c
	* app/base/pixel-region.c: allocate structs using GSlice.

	* app/base/tile.c: allocate TileLink and TileRowHint using 
GSlice.


svn path=/trunk/; revision=22583
2007-05-22 18:29:33 +00:00
Michael Natterer 7654733de9 changed tile_init() to tile_new() and return a GSlice-allocated Tile
2007-05-22  Michael Natterer  <mitch@gimp.org>

	* app/base/tile.[ch]: changed tile_init() to tile_new() and return
	a GSlice-allocated Tile structure.

	(tile_destroy): free it using GSLice.

	* app/base/tile-manager.c: use tile_new() instead of g_new plus
	tile_init(). Also allocate TileManager itself using GSlice.

	* app/xcf/xcf-load.c (xcf_load_parasite): allocate parasites using
	gimp_parasite_new().


svn path=/trunk/; revision=22571
2007-05-22 15:12:30 +00:00
Sven Neumann ab30daf8b9 if the invalided tile is the cached tile, release the cached tile. Fixes
2007-05-16  Sven Neumann  <sven@gimp.org>

	* app/base/tile-manager.c (tile_invalidate): if the invalided tile
	is the cached tile, release the cached tile. Fixes bug #438802.


svn path=/trunk/; revision=22507
2007-05-16 12:05:15 +00:00
Sven Neumann 8f7491f2eb cosmetics.
2007-05-02  Sven Neumann  <sven@gimp.org>

	* app/base/tile-manager.c: cosmetics.

svn path=/trunk/; revision=22373
2007-05-02 09:00:46 +00:00
Sven Neumann 3f7c188f59 made tile_ref_count a static variable and added a function to access it.
2007-02-22  Sven Neumann  <sven@gimp.org>

	* app/base/tile.[ch]: made tile_ref_count a static variable and
	added a function to access it.  Declared other (unused) global
	counters as static variables and moved them into #ifdefs.

	* app/base/tile-swap.c: use the function instead of declaring
	tile_ref_count as extern.

	* app/base/tile-manager.c
	* app/base/pixel-surround.c: cosmetics.


svn path=/trunk/; revision=21975
2007-02-22 22:28:24 +00:00
Sven Neumann 41237259c9 In all files, changed the standard copyright notice to say "GIMP - The GNU
2006-12-09  Sven Neumann  <sven@gimp.org>

        * In all files, changed the standard copyright notice to say
        "GIMP - The GNU Image Manipulation Program".
2006-12-09 21:33:38 +00:00
Sven Neumann 26ecfe60b7 use the same code on all platforms. The optimization for bytes == 4 was
2006-09-21  Sven Neumann  <neumann@jpk.com>

	* app/base/tile-manager.c (read_pixel_data_1) (write_pixel_data_1):
	use the same code on all platforms. The optimization for bytes == 4
	was pointless anyway.
2006-09-21 09:45:07 +00:00
Michael Natterer a9c03ad6b6 fix build on big endian.
2006-09-21  Michael Natterer  <mitch@gimp.org>

	* app/base/tile-manager.c (read_pixel_data_1): fix build on
	big endian.
2006-09-21 01:16:09 +00:00
Sven Neumann d3904c6d85 fixed endian issues (bug #340965).
2006-09-20  Sven Neumann  <sven@gimp.org>

	* app/base/tile-manager.c (read_pixel_data_1) (write_pixel_data_1):
	fixed endian issues (bug #340965).
2006-09-20 10:38:42 +00:00
Sven Neumann 6d0e04ae6e app/base/pixel-region.[ch] app/base/tile-manager.[ch] removed code that
2006-09-07  Sven Neumann  <sven@gimp.org>

	* app/base/pixel-region.[ch]
	* app/base/tile-manager.[ch]
	* app/base/tile-swap.[ch]: removed code that tried to swap in
	tiles asynchronously (but ended up calling up nothing).
2006-09-07 09:58:17 +00:00
Sven Neumann 79931072c8 app/base/tile-cache.c app/base/tile-manager.c app/base/tile-private.h
2006-09-07  Sven Neumann  <sven@gimp.org>

	* app/base/tile-cache.c
	* app/base/tile-manager.c
	* app/base/tile-private.h
	* app/base/tile.c: removed tile locking macros that were only used
	for the threaded tile swapper.
2006-09-07 09:41:23 +00:00
Sven Neumann dbeb1bcbae more code cleanup 2006-07-06 12:27:32 +00:00
Sven Neumann 049872b361 app/*.[ch] converted tabs to spaces.
2006-04-12  Sven Neumann  <sven@gimp.org>

	* app/*.[ch]
	* app/*/*.[ch]: converted tabs to spaces.
2006-04-12 12:49:29 +00:00
Sven Neumann c995db3ce0 app/base/tile-cache.c app/base/tile-manager.c app/base/tile-private.h
2005-09-29  Sven Neumann  <sven@gimp.org>

	* app/base/tile-cache.c
	* app/base/tile-manager.c
	* app/base/tile-private.h
	* app/base/tile-swap.c
	* app/base/tile.c: keep the data size of a tile in the Tile struct
	instead of recalculating it over and over again. Adds an overhead
	of 4 bytes per tile but speeds up the tile cache significantly.
2005-09-29 22:24:57 +00:00
Sven Neumann 3bb2f79984 inline tile_manager_get_tile_num().
2005-05-09  Sven Neumann  <sven@gimp.org>

	* app/base/tile-manager.c: inline tile_manager_get_tile_num().

	* app/display/gimpdisplayshell-render.c (render_image_tile_fault):
	reverted one of the changes I did here earlier.
2005-05-08 23:30:54 +00:00
Sven Neumann 001bd33231 some code cleanup.
2005-05-08  Sven Neumann  <sven@gimp.org>

	* app/base/tile-manager.[ch]: some code cleanup.
2005-05-08 20:24:54 +00:00
Sven Neumann 928b4f23a6 removed redundant check.
2005-04-27  Sven Neumann  <sven@gimp.org>

	* app/base/tile-manager.c (tile_manager_get_tile): removed
	redundant check.

	* app/display/gimpdisplayshell-render.c: don't access the next
	tile if we are at the end of the render loop anyway.
2005-04-27 17:53:10 +00:00
Michael Natterer 53c3ff1821 added new function copy_region_nocow() as a workaround for the fact that
2004-12-12  Michael Natterer  <mitch@gimp.org>

	* app/paint-funcs/paint-funcs.[ch]: added new function
	copy_region_nocow() as a workaround for the fact that sharing
	tiles with the projection is heavily broken.

	* app/base/tile-manager.c (tile_invalidate): added a warning when
	entering the code path that breaks badly.

	* app/core/gimp-edit.[ch]: added gimp_edit_copy_visible(), using
	the non-COW copying function above.

	* app/widgets/gimphelp-ids.h: added GIMP_HELP_COPY_VISIBLE.

	* app/actions/edit-actions.c
	* app/actions/edit-commands.[ch]: added action & callback for
	"edit-copy-visible".

	* menus/image-menu.xml.in: added "edit-copy-visible" to the image
	menu.

	* tools/pdbgen/pdb/edit.pdb: added gimp_edit_copy_visible()
	PDB wrapper.

	* app/pdb/edit_cmds.c
	* app/pdb/internal_procs.c
	* libgimp/gimpedit_pdb.[ch]: regenerated.

	* plug-ins/script-fu/scripts/copy-visible.scm: removed all code
	and made it a backward compat wrapper around gimp-edit-copy-visible.
	Fixes bug #138662.
2004-12-12 14:01:08 +00:00
Sven Neumann 811ca2dc1e count valid tiles, not dirty ones.
2004-09-19  Sven Neumann  <sven@gimp.org>

	* app/base/tile-manager.c (tile_manager_get_memsize): count valid
	tiles, not dirty ones.
2004-09-19 21:54:26 +00:00