Commit b102101e authored by Sven Neumann's avatar Sven Neumann Committed by Sven Neumann
Browse files

app/convert.c app/floating_sel.c app/gimage_mask.c app/gimpimage.c

2001-01-23  Sven Neumann  <sven@gimp.org>

	* app/convert.c
	* app/floating_sel.c
	* app/gimage_mask.c
	* app/gimpimage.c
	* app/global_edit.c
	* app/image_map.c
	* app/image_new.c
	* app/layer.c
	* app/paint_funcs.c
	* app/pixel_region.c
	* app/tile_manager.c
	* app/tile_manager.h
	* app/tile_manager_pvt.h
	* app/undo.c
	* app/xcf.c
	* app/pdb/tools_cmds.c
	* app/tools/flip_tool.c
	* app/tools/perspective_tool.c
	* app/tools/rotate_tool.c
	* app/tools/scale_tool.c
	* app/tools/shear_tool.c
	* app/tools/text_tool.c
	* app/tools/transform_core.c
	* tools/pdbgen/pdb/tools.pdb: made all files execpt xcf.c use the
	TileManager accessor functions instead of accessing the TileManager
	struct directly.
parent f4d65cdf
2001-01-23 Sven Neumann <sven@gimp.org>
* app/convert.c
* app/floating_sel.c
* app/gimage_mask.c
* app/gimpimage.c
* app/global_edit.c
* app/image_map.c
* app/image_new.c
* app/layer.c
* app/paint_funcs.c
* app/pixel_region.c
* app/tile_manager.c
* app/tile_manager.h
* app/tile_manager_pvt.h
* app/undo.c
* app/xcf.c
* app/pdb/tools_cmds.c
* app/tools/flip_tool.c
* app/tools/perspective_tool.c
* app/tools/rotate_tool.c
* app/tools/scale_tool.c
* app/tools/shear_tool.c
* app/tools/text_tool.c
* app/tools/transform_core.c
* tools/pdbgen/pdb/tools.pdb: made all files execpt xcf.c use the
TileManager accessor functions instead of accessing the TileManager
struct directly.
2001-01-23 Sven Neumann <sven@gimp.org>
* TODO.xml: updated, added sections about libgck and script-fu
......
......@@ -30,7 +30,6 @@
#include "gimprc.h"
#include "pixel_region.h"
#include "tile_manager.h"
#include "tile_manager_pvt.h"
#include "tile.h"
......@@ -64,7 +63,7 @@ pixel_region_init (PixelRegion *PR,
PR->tiles = tiles;
PR->curtile = NULL;
PR->data = NULL;
PR->bytes = tiles->bpp;
PR->bytes = tile_manager_bpp (tiles);
PR->rowstride = PR->bytes * TILE_WIDTH;
PR->x = x;
PR->y = y;
......
......@@ -22,7 +22,7 @@
struct _TileManager
{
gint x, y; /* tile manager offsets */
gint x, y; /* tile manager offsets */
gint width; /* the width of the tiled area */
gint height; /* the height of the tiled area */
......
......@@ -26,9 +26,9 @@
#include "tile_cache.h"
#include "tile_manager.h"
#include "tile_manager_pvt.h"
#include "tile_swap.h"
#include "tile_manager_pvt.h"
#include "tile_pvt.h" /* ick. */
......@@ -54,6 +54,8 @@ tile_manager_new (gint toplevel_width,
width = toplevel_width;
height = toplevel_height;
tm->x = 0;
tm->y = 0;
tm->width = width;
tm->height = height;
tm->bpp = bpp;
......@@ -70,6 +72,8 @@ 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;
......@@ -91,6 +95,8 @@ void
tile_manager_set_validate_proc (TileManager *tm,
TileValidateProc proc)
{
g_return_if_fail (tm != NULL);
tm->validate_proc = proc;
}
......@@ -104,6 +110,8 @@ tile_manager_get_tile (TileManager *tm,
{
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;
......@@ -125,6 +133,8 @@ tile_manager_get (TileManager *tm,
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))
......@@ -242,6 +252,8 @@ tile_manager_get_async (TileManager *tm,
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;
......@@ -255,6 +267,9 @@ 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)
......@@ -280,6 +295,9 @@ tile_manager_invalidate_tiles (TileManager *tm,
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;
......@@ -304,6 +322,9 @@ tile_invalidate_tile (Tile **tile_ptr,
{
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;
......@@ -319,6 +340,9 @@ tile_invalidate (Tile **tile_ptr,
{
Tile *tile = *tile_ptr;
g_return_if_fail (tile_ptr != NULL);
g_return_if_fail (tm != NULL);
TILE_MUTEX_LOCK (tile);
if (!tile->valid)
......@@ -370,6 +394,9 @@ tile_manager_map_tile (TileManager *tm,
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))
{
......@@ -397,6 +424,9 @@ tile_manager_map (TileManager *tm,
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))
......@@ -471,7 +501,7 @@ tile_manager_map (TileManager *tm,
/* printf("}");fflush(stdout);*/
}
static int
static gint
tile_manager_get_tile_num (TileManager *tm,
gint xpixel,
gint ypixel)
......@@ -480,6 +510,8 @@ tile_manager_get_tile_num (TileManager *tm,
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;
......@@ -495,33 +527,65 @@ 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;
}
int
tile_manager_level_width (const TileManager *tm)
gint
tile_manager_width (const TileManager *tm)
{
g_return_val_if_fail (tm != NULL, 0);
return tm->width;
}
int
tile_manager_level_height (const TileManager *tm)
gint
tile_manager_height (const TileManager *tm)
{
g_return_val_if_fail (tm != NULL, 0);
return tm->height;
}
int
tile_manager_level_bpp (const TileManager *tm)
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,
......@@ -530,6 +594,9 @@ tile_manager_get_tile_coordinates (TileManager *tm,
{
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;
......@@ -553,6 +620,10 @@ tile_manager_map_over_tile (TileManager *tm,
{
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;
......
......@@ -102,9 +102,16 @@ void tile_manager_set_user_data (TileManager *tm,
gpointer user_data);
gpointer tile_manager_get_user_data (const TileManager *tm);
gint tile_manager_level_width (const TileManager *tm);
gint tile_manager_level_height (const TileManager *tm);
gint tile_manager_level_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_tile_coordinates (TileManager *tm,
Tile *tile,
......
......@@ -109,7 +109,6 @@
#include "palette_select.h"
#include "pixel_region.h"
#include "tile_manager.h"
#include "tile_manager_pvt.h" /* ick ick ick. */
#include "tools/brightness_contrast.h"
#include "tools/color_balance.h"
......@@ -3523,7 +3522,7 @@ median_cut_pass2_fs_dither_gray (QuantizeObj *quantobj,
pixel_region_init (&srcPR, GIMP_DRAWABLE(layer)->tiles, 0, 0, GIMP_DRAWABLE(layer)->width, GIMP_DRAWABLE(layer)->height, FALSE);
pixel_region_init (&destPR, new_tiles, 0, 0, GIMP_DRAWABLE(layer)->width, GIMP_DRAWABLE(layer)->height, TRUE);
src_bytes = GIMP_DRAWABLE(layer)->bytes;
dest_bytes = new_tiles->bpp;
dest_bytes = tile_manager_bpp (new_tiles);
width = GIMP_DRAWABLE(layer)->width;
height = GIMP_DRAWABLE(layer)->height;
......@@ -3733,7 +3732,7 @@ median_cut_pass2_fs_dither_rgb (QuantizeObj *quantobj,
pixel_region_init (&srcPR, GIMP_DRAWABLE(layer)->tiles, 0, 0, GIMP_DRAWABLE(layer)->width, GIMP_DRAWABLE(layer)->height, FALSE);
pixel_region_init (&destPR, new_tiles, 0, 0, GIMP_DRAWABLE(layer)->width, GIMP_DRAWABLE(layer)->height, TRUE);
src_bytes = GIMP_DRAWABLE(layer)->bytes;
dest_bytes = new_tiles->bpp;
dest_bytes = tile_manager_bpp (new_tiles);
width = GIMP_DRAWABLE(layer)->width;
height = GIMP_DRAWABLE(layer)->height;
......
......@@ -44,8 +44,6 @@
#include "libgimp/gimpintl.h"
#include "tile_manager_pvt.h"
typedef enum
{
......@@ -100,17 +98,19 @@ crop_buffer (TileManager *tiles,
void *pr;
guchar black[MAX_CHANNELS] = { 0, 0, 0, 0 };
bytes = tiles->bpp;
bytes = tile_manager_bpp (tiles);
alpha = bytes - 1;
/* go through and calculate the bounds */
x1 = tiles->width;
y1 = tiles->height;
x1 = tile_manager_width (tiles);
y1 = tile_manager_height (tiles);
x2 = 0;
y2 = 0;
pixel_region_init (&PR, tiles, 0, 0, x1, y1, FALSE);
for (pr = pixel_regions_register (1, &PR); pr != NULL; pr = pixel_regions_process (pr))
for (pr = pixel_regions_register (1, &PR);
pr != NULL;
pr = pixel_regions_process (pr))
{
data = PR.data + alpha;
ex = PR.x + PR.w;
......@@ -138,18 +138,25 @@ crop_buffer (TileManager *tiles,
}
}
x2 = CLAMP (x2 + 1, 0, tiles->width);
y2 = CLAMP (y2 + 1, 0, tiles->height);
x2 = CLAMP (x2 + 1, 0, tile_manager_width (tiles));
y2 = CLAMP (y2 + 1, 0, tile_manager_height (tiles));
empty = (x1 == tiles->width && y1 == tiles->height);
empty = (x1 == tile_manager_width (tiles) &&
y1 == tile_manager_height (tiles));
/* If there are no visible pixels, return NULL */
if (empty)
new_tiles = NULL;
{
new_tiles = NULL;
}
/* If no cropping, return original buffer */
else if (x1 == 0 && y1 == 0 && x2 == tiles->width &&
y2 == tiles->height && border == 0)
new_tiles = tiles;
else if (x1 == 0 && y1 == 0 &&
x2 == tile_manager_width (tiles) &&
y2 == tile_manager_height (tiles) &&
border == 0)
{
new_tiles = tiles;
}
/* Otherwise, crop the original area */
else
{
......@@ -173,13 +180,14 @@ crop_buffer (TileManager *tiles,
color_region (&destPR, black);
}
pixel_region_init (&srcPR, tiles, x1, y1, (x2 - x1), (y2 - y1), FALSE);
pixel_region_init (&destPR, new_tiles, border, border, (x2 - x1), (y2 - y1), TRUE);
pixel_region_init (&srcPR, tiles,
x1, y1, (x2 - x1), (y2 - y1), FALSE);
pixel_region_init (&destPR, new_tiles,
border, border, (x2 - x1), (y2 - y1), TRUE);
copy_region (&srcPR, &destPR);
new_tiles->x = x1;
new_tiles->y = y1;
tile_manager_set_offsets (new_tiles, x1, y1);
}
return new_tiles;
......@@ -375,7 +383,9 @@ edit_paste_as_new (GImage *invoke,
return FALSE;
/* create a new image (always of type RGB) */
gimage = gimage_new (paste->width, paste->height, RGB);
gimage = gimage_new (tile_manager_width (paste),
tile_manager_height (paste),
RGB);
gimp_image_undo_disable (gimage);
gimp_image_set_resolution (gimage, invoke->xresolution, invoke->yresolution);
gimp_image_set_unit (gimage, invoke->unit);
......@@ -833,19 +843,24 @@ static void
new_named_buffer (TileManager *tiles,
gchar *name)
{
PixelRegion srcPR, destPR;
PixelRegion srcPR, destPR;
NamedBuffer *nb;
gint width, height;
if (! tiles)
return;
if (! tiles) return;
width = tile_manager_width (tiles);
height = tile_manager_height (tiles);
nb = (NamedBuffer *) g_malloc (sizeof (NamedBuffer));
nb->buf = tile_manager_new (tiles->width, tiles->height, tiles->bpp);
pixel_region_init (&srcPR, tiles, 0, 0, tiles->width, tiles->height, FALSE);
pixel_region_init (&destPR, nb->buf, 0, 0, tiles->width, tiles->height, TRUE);
nb->buf = tile_manager_new (width, height, tile_manager_bpp (tiles));
pixel_region_init (&srcPR, tiles, 0, 0, width, height, FALSE);
pixel_region_init (&destPR, nb->buf, 0, 0, width, height, TRUE);
copy_region (&srcPR, &destPR);
nb->name = g_strdup ((char *) name);
nb->name = g_strdup ((gchar *) name);
named_buffers = g_slist_append (named_buffers, (void *) nb);
}
......
......@@ -44,8 +44,6 @@
#include "libgimp/gimpintl.h"
#include "tile_manager_pvt.h"
typedef enum
{
......@@ -100,17 +98,19 @@ crop_buffer (TileManager *tiles,
void *pr;
guchar black[MAX_CHANNELS] = { 0, 0, 0, 0 };
bytes = tiles->bpp;
bytes = tile_manager_bpp (tiles);
alpha = bytes - 1;
/* go through and calculate the bounds */
x1 = tiles->width;
y1 = tiles->height;
x1 = tile_manager_width (tiles);
y1 = tile_manager_height (tiles);
x2 = 0;
y2 = 0;
pixel_region_init (&PR, tiles, 0, 0, x1, y1, FALSE);
for (pr = pixel_regions_register (1, &PR); pr != NULL; pr = pixel_regions_process (pr))
for (pr = pixel_regions_register (1, &PR);
pr != NULL;
pr = pixel_regions_process (pr))
{
data = PR.data + alpha;
ex = PR.x + PR.w;
......@@ -138,18 +138,25 @@ crop_buffer (TileManager *tiles,
}
}
x2 = CLAMP (x2 + 1, 0, tiles->width);
y2 = CLAMP (y2 + 1, 0, tiles->height);
x2 = CLAMP (x2 + 1, 0, tile_manager_width (tiles));
y2 = CLAMP (y2 + 1, 0, tile_manager_height (tiles));
empty = (x1 == tiles->width && y1 == tiles->height);
empty = (x1 == tile_manager_width (tiles) &&
y1 == tile_manager_height (tiles));
/* If there are no visible pixels, return NULL */
if (empty)
new_tiles = NULL;
{
new_tiles = NULL;
}
/* If no cropping, return original buffer */
else if (x1 == 0 && y1 == 0 && x2 == tiles->width &&
y2 == tiles->height && border == 0)
new_tiles = tiles;
else if (x1 == 0 && y1 == 0 &&
x2 == tile_manager_width (tiles) &&
y2 == tile_manager_height (tiles) &&
border == 0)
{
new_tiles = tiles;
}
/* Otherwise, crop the original area */
else
{
......@@ -173,13 +180,14 @@ crop_buffer (TileManager *tiles,
color_region (&destPR, black);
}
pixel_region_init (&srcPR, tiles, x1, y1, (x2 - x1), (y2 - y1), FALSE);
pixel_region_init (&destPR, new_tiles, border, border, (x2 - x1), (y2 - y1), TRUE);
pixel_region_init (&srcPR, tiles,
x1, y1, (x2 - x1), (y2 - y1), FALSE);
pixel_region_init (&destPR, new_tiles,
border, border, (x2 - x1), (y2 - y1), TRUE);
copy_region (&srcPR, &destPR);
new_tiles->x = x1;
new_tiles->y = y1;
tile_manager_set_offsets (new_tiles, x1, y1);
}
return new_tiles;
......@@ -375,7 +383,9 @@ edit_paste_as_new (GImage *invoke,
return FALSE;
/* create a new image (always of type RGB) */
gimage = gimage_new (paste->width, paste->height, RGB);
gimage = gimage_new (tile_manager_width (paste),
tile_manager_height (paste),
RGB);
gimp_image_undo_disable (gimage);
gimp_image_set_resolution (gimage, invoke->xresolution, invoke->yresolution);
gimp_image_set_unit (gimage, invoke->unit);
......@@ -833,19 +843,24 @@ static void
new_named_buffer (TileManager *tiles,
gchar *name)
{
PixelRegion srcPR, destPR;
PixelRegion srcPR, destPR;
NamedBuffer *nb;
gint width, height;
if (! tiles)
return;
if (! tiles) return;
width = tile_manager_width (tiles);
height = tile_manager_height (tiles);
nb = (NamedBuffer *) g_malloc (sizeof (NamedBuffer));
nb->buf = tile_manager_new (tiles->width, tiles->height, tiles->bpp);
pixel_region_init (&srcPR, tiles, 0, 0, tiles->width, tiles->height, FALSE);
pixel_region_init (&destPR, nb->buf, 0, 0, tiles->width, tiles->height, TRUE);
nb->buf = tile_manager_new (width, height, tile_manager_bpp (tiles));
pixel_region_init (&srcPR, tiles, 0, 0, width, height, FALSE);
pixel_region_init (&destPR, nb->buf, 0, 0, width, height, TRUE);
copy_region (&srcPR, &destPR);
nb->name = g_strdup ((char *) name);
nb->name = g_strdup ((gchar *) name);
named_buffers = g_slist_append (named_buffers, (void *) nb);
}
......
......@@ -109,7 +109,6 @@
#include "palette_select.h"
#include "pixel_region.h"
#include "tile_manager.h"
#include "tile_manager_pvt.h" /* ick ick ick. */
#include "tools/brightness_contrast.h"
#include "tools/color_balance.h"
......@@ -3523,7 +3522,7 @@ median_cut_pass2_fs_dither_gray (QuantizeObj *quantobj,
pixel_region_init (&srcPR, GIMP_DRAWABLE(layer)->tiles, 0, 0, GIMP_DRAWABLE(layer)->width, GIMP_DRAWABLE(layer)->height, FALSE);
pixel_region_init (&destPR, new_tiles, 0, 0, GIMP_DRAWABLE(layer)->width, GIMP_DRAWABLE(layer)->height, TRUE);
src_bytes = GIMP_DRAWABLE(layer)->bytes;
dest_bytes = new_tiles->bpp;
dest_bytes = tile_manager_bpp (new_tiles);
width = GIMP_DRAWABLE(layer)->width;
height = GIMP_DRAWABLE(layer)->height;
......@@ -3733,7 +3732,7 @@ median_cut_pass2_fs_dither_rgb (QuantizeObj *quantobj,
pixel_region_init (&srcPR, GIMP_DRAWABLE(layer)->tiles, 0, 0, GIMP_DRAWABLE(layer)->width, GIMP_DRAWABLE(layer)->height, FALSE);
pixel_region_init (&destPR, new_tiles, 0, 0, GIMP_DRAWABLE(layer)->width, GIMP_DRAWABLE(layer)->height, TRUE);
src_bytes = GIMP_DRAWABLE(layer)->bytes;
dest_bytes = new_tiles->bpp;
dest_bytes = tile_manager_bpp (new_tiles);