gimp/app/base/pixel-region.h
Michael Natterer 09454fb2a4 some general cleanup.
2005-09-03  Michael Natterer  <mitch@gimp.org>

	* app/base/pixel-region.[ch]: some general cleanup.

	(pixel_region_init_temp_buf)
	(pixel_region_init_data): new functions which initialize pixel
	regions on TempBufs and on raw contiguous arrays of pixel data.

	(pixel_region_configure): fixed a bug that has probably been there
	forever: when processing contiguous (non-tiled) data, interpret
	the original x and y coordinates of the region as offsets into
	the data. Before this fix, the initial x and y were simply ignored
	(by using them in a broken way), thus always forcing the upper
	left corner of the region being the beginning of the passed data.

	Lots of code was working around this problem by setting the
	pixel_region's data pointer to the proper starting pixel of the
	region in the middle the buffer.

	* libgimp/gimppixelrgn.c: some general cleanup.

	(gimp_pixel_rgn_configure): same fix as above. Fortunately, nobody
	seems to know that libgimp pixel regions can be used on arrays of
	data, just as core ones. Only two plug-ins were using this
	feature, and they are antique and written by spencer and federico,
	respectively. They both don't use offsets into the buffers and are
	not affected by this change. It's highly unlikely that anybody out
	there knows/uses this feature, so it can IMHO be safely changed.

	* app/base/temp-buf.c
	* app/core/gimpbuffer.c
	* app/core/gimpdrawable-combine.c
	* app/core/gimpdrawable-preview.c
	* app/core/gimpimage-preview.c
	* app/core/gimplayer.c
	* app/paint/gimpbrushcore.c
	* app/paint/gimpclone.c
	* app/paint/gimpconvolve.c
	* app/paint/gimpdodgeburn.c
	* app/paint/gimppaintcore.c
	* app/paint/gimpsmudge.c
	* app/tools/gimpiscissorstool.c
	* app/tools/gimppainttool.c: use the pixel_region_init_foo()
	functions instead of initializing regions of TempBufs and raw data
	manually. Removed lots of workarounds for the broken offset
	handling. The changed places of code are much more readable now.
2005-09-03 17:16:58 +00:00

125 lines
4.9 KiB
C

/* 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_init_temp_buf (PixelRegion *PR,
TempBuf *temp_buf,
gint x,
gint y,
gint w,
gint h);
void pixel_region_init_data (PixelRegion *PR,
guchar *data,
gint bytes,
gint rowstride,
gint x,
gint y,
gint w,
gint h);
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);
PixelRegionIterator * pixel_regions_register (gint num_regions,
...);
PixelRegionIterator * pixel_regions_process (PixelRegionIterator *PRI);
void pixel_regions_process_stop (PixelRegionIterator *PRI);
#endif /* __PIXEL_REGION_H__ */