1997-11-25 06:05:25 +08:00
|
|
|
/* 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
|
1998-04-13 13:44:11 +08:00
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
1997-11-25 06:05:25 +08:00
|
|
|
*/
|
2000-06-08 02:43:22 +08:00
|
|
|
|
2000-12-17 05:37:03 +08:00
|
|
|
#include "config.h"
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
#include <stdarg.h>
|
|
|
|
#include <string.h>
|
2000-06-08 02:43:22 +08:00
|
|
|
|
2001-12-08 00:10:53 +08:00
|
|
|
#include <glib-object.h>
|
2000-12-17 05:37:03 +08:00
|
|
|
|
2001-05-15 19:25:25 +08:00
|
|
|
#include "base-types.h"
|
2000-12-17 05:37:03 +08:00
|
|
|
|
2001-05-15 19:25:25 +08:00
|
|
|
#include "pixel-region.h"
|
|
|
|
#include "tile-manager.h"
|
2000-12-29 23:22:01 +08:00
|
|
|
#include "tile.h"
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-01-23 07:46:44 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
/*********************/
|
|
|
|
/* Local Functions */
|
|
|
|
|
2002-08-22 17:48:56 +08:00
|
|
|
static gint get_portion_width (PixelRegionIterator *PRI);
|
|
|
|
static gint get_portion_height (PixelRegionIterator *PRI);
|
|
|
|
static PixelRegionIterator * pixel_regions_configure (PixelRegionIterator *PRI);
|
2003-09-29 04:13:59 +08:00
|
|
|
static void pixel_region_configure (PixelRegionHolder *PRH,
|
2002-08-22 17:48:56 +08:00
|
|
|
PixelRegionIterator *PRI);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
|
|
|
|
/**************************/
|
|
|
|
/* Function definitions */
|
|
|
|
|
|
|
|
void
|
2003-09-29 04:13:59 +08:00
|
|
|
pixel_region_init (PixelRegion *PR,
|
|
|
|
TileManager *tiles,
|
|
|
|
gint x,
|
|
|
|
gint y,
|
|
|
|
gint w,
|
|
|
|
gint h,
|
2000-06-08 02:43:22 +08:00
|
|
|
gboolean dirty)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2000-06-08 02:43:22 +08:00
|
|
|
PR->tiles = tiles;
|
|
|
|
PR->curtile = NULL;
|
|
|
|
PR->data = NULL;
|
2001-01-23 21:01:48 +08:00
|
|
|
PR->bytes = tile_manager_bpp (tiles);
|
1997-11-25 06:05:25 +08:00
|
|
|
PR->rowstride = PR->bytes * TILE_WIDTH;
|
2000-06-08 02:43:22 +08:00
|
|
|
PR->x = x;
|
|
|
|
PR->y = y;
|
|
|
|
PR->w = w;
|
|
|
|
PR->h = h;
|
|
|
|
PR->dirty = dirty;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2003-09-29 04:13:59 +08:00
|
|
|
pixel_region_resize (PixelRegion *PR,
|
|
|
|
gint x,
|
|
|
|
gint y,
|
|
|
|
gint w,
|
2000-06-08 02:43:22 +08:00
|
|
|
gint h)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
|
|
|
/* 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;
|
|
|
|
}
|
|
|
|
|
1999-07-20 03:46:05 +08:00
|
|
|
|
|
|
|
/* request that tiles within a region be fetched asynchronously */
|
1998-07-13 07:01:33 +08:00
|
|
|
void
|
2003-09-29 04:13:59 +08:00
|
|
|
pixel_region_get_async (PixelRegion *PR,
|
|
|
|
gint ulx,
|
|
|
|
gint uly,
|
|
|
|
gint lrx,
|
2000-06-08 02:43:22 +08:00
|
|
|
gint lry)
|
1998-07-13 07:01:33 +08:00
|
|
|
{
|
2000-06-08 02:43:22 +08:00
|
|
|
gint x;
|
|
|
|
gint y;
|
1998-07-13 07:01:33 +08:00
|
|
|
|
|
|
|
for (y = uly; y < lry; y += TILE_HEIGHT)
|
|
|
|
for (x = ulx; x < lrx; x += TILE_WIDTH)
|
1998-08-16 03:17:36 +08:00
|
|
|
tile_manager_get_async (PR->tiles, x, y);
|
1998-07-13 07:01:33 +08:00
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-20 03:46:05 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
void
|
2003-09-29 04:13:59 +08:00
|
|
|
pixel_region_get_row (PixelRegion *PR,
|
|
|
|
gint x,
|
|
|
|
gint y,
|
|
|
|
gint w,
|
|
|
|
guchar *data,
|
2000-06-08 02:43:22 +08:00
|
|
|
gint subsample)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2000-06-08 02:43:22 +08:00
|
|
|
Tile *tile;
|
|
|
|
guchar *tile_data;
|
2001-05-14 21:39:45 +08:00
|
|
|
gint inc;
|
|
|
|
gint end;
|
|
|
|
gint boundary;
|
|
|
|
gint b;
|
|
|
|
gint npixels;
|
|
|
|
gint tilebpp;
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
end = x + w;
|
|
|
|
|
1998-07-13 07:01:33 +08:00
|
|
|
pixel_region_get_async (PR, x, y, end, y);
|
|
|
|
|
2001-11-29 09:06:44 +08:00
|
|
|
tilebpp = tile_manager_bpp (PR->tiles);
|
|
|
|
inc = subsample * tilebpp;
|
1998-07-25 19:24:09 +08:00
|
|
|
|
2001-11-29 09:06:44 +08:00
|
|
|
if (subsample == 1)
|
|
|
|
{
|
2001-11-29 11:31:00 +08:00
|
|
|
read_pixel_data (PR->tiles, x, y, end-1, y, data, tilebpp);
|
2001-11-29 09:06:44 +08:00
|
|
|
}
|
2003-09-29 04:13:59 +08:00
|
|
|
else
|
2001-11-29 09:06:44 +08:00
|
|
|
{
|
|
|
|
while (x < end)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2001-11-29 09:06:44 +08:00
|
|
|
tile = tile_manager_get_tile (PR->tiles, x, y, TRUE, FALSE);
|
|
|
|
tile_data = tile_data_pointer (tile, x % TILE_WIDTH, y % TILE_HEIGHT);
|
|
|
|
npixels = tile_ewidth (tile) - (x % TILE_WIDTH);
|
2003-09-29 04:13:59 +08:00
|
|
|
|
2001-11-29 09:06:44 +08:00
|
|
|
if ((x + npixels) > end) /* make sure we don't write past the end */
|
|
|
|
npixels = end - x;
|
2003-09-29 04:13:59 +08:00
|
|
|
|
2000-06-08 02:43:22 +08:00
|
|
|
boundary = x + npixels;
|
|
|
|
for ( ; x < boundary; x += subsample)
|
|
|
|
{
|
|
|
|
for (b = 0; b < tilebpp; b++)
|
|
|
|
*data++ = tile_data[b];
|
2003-09-29 04:13:59 +08:00
|
|
|
|
2000-06-08 02:43:22 +08:00
|
|
|
tile_data += inc;
|
|
|
|
}
|
2001-11-29 09:06:44 +08:00
|
|
|
tile_release (tile, FALSE);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2003-09-29 04:13:59 +08:00
|
|
|
pixel_region_set_row (PixelRegion *PR,
|
|
|
|
gint x,
|
|
|
|
gint y,
|
|
|
|
gint w,
|
2000-06-08 02:43:22 +08:00
|
|
|
guchar *data)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2001-05-14 21:39:45 +08:00
|
|
|
gint end;
|
2001-11-29 11:31:00 +08:00
|
|
|
gint bpp;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-11-29 11:31:00 +08:00
|
|
|
end = x + w;
|
|
|
|
bpp = tile_manager_bpp (PR->tiles);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1998-07-13 07:01:33 +08:00
|
|
|
pixel_region_get_async (PR, x, y, end, y);
|
|
|
|
|
2001-11-29 11:31:00 +08:00
|
|
|
write_pixel_data (PR->tiles, x, y, end-1, y, data, bpp);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
2003-09-29 04:13:59 +08:00
|
|
|
pixel_region_get_col (PixelRegion *PR,
|
|
|
|
gint x,
|
|
|
|
gint y,
|
|
|
|
gint h,
|
|
|
|
guchar *data,
|
2000-06-08 02:43:22 +08:00
|
|
|
gint subsample)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2000-06-08 02:43:22 +08:00
|
|
|
Tile *tile;
|
|
|
|
guchar *tile_data;
|
2001-05-14 21:39:45 +08:00
|
|
|
gint tilebpp;
|
|
|
|
gint inc;
|
|
|
|
gint end;
|
|
|
|
gint boundary;
|
|
|
|
gint b;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
end = y + h;
|
|
|
|
|
1998-07-13 07:01:33 +08:00
|
|
|
pixel_region_get_async (PR, x, y, x, end);
|
|
|
|
|
2001-11-29 09:06:44 +08:00
|
|
|
tilebpp = tile_manager_bpp (PR->tiles);
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
while (y < end)
|
|
|
|
{
|
1998-08-16 03:17:36 +08:00
|
|
|
tile = tile_manager_get_tile (PR->tiles, x, y, TRUE, FALSE);
|
1998-08-12 01:35:34 +08:00
|
|
|
tile_data = tile_data_pointer (tile, x % TILE_WIDTH, y % TILE_HEIGHT);
|
|
|
|
boundary = y + (tile_eheight(tile) - (y % TILE_HEIGHT));
|
2000-06-08 02:43:22 +08:00
|
|
|
|
1998-07-25 19:24:09 +08:00
|
|
|
if (boundary > end) /* make sure we don't write past the end */
|
|
|
|
boundary = end;
|
|
|
|
|
2000-06-08 02:43:22 +08:00
|
|
|
inc = subsample * tilebpp * tile_ewidth (tile);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1998-07-25 19:24:09 +08:00
|
|
|
for ( ; y < boundary; y += subsample)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2000-06-08 02:43:22 +08:00
|
|
|
for (b = 0; b < tilebpp; b++)
|
1997-11-25 06:05:25 +08:00
|
|
|
*data++ = tile_data[b];
|
2000-06-08 02:43:22 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
tile_data += inc;
|
|
|
|
}
|
|
|
|
|
1998-07-10 10:43:12 +08:00
|
|
|
tile_release (tile, FALSE);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
2003-09-29 04:13:59 +08:00
|
|
|
pixel_region_set_col (PixelRegion *PR,
|
|
|
|
gint x,
|
|
|
|
gint y,
|
|
|
|
gint h,
|
2000-06-08 02:43:22 +08:00
|
|
|
guchar *data)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2001-05-14 21:39:45 +08:00
|
|
|
gint tilebpp;
|
|
|
|
gint end;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
end = y + h;
|
|
|
|
|
1998-07-13 07:01:33 +08:00
|
|
|
pixel_region_get_async (PR, x, y, x, end);
|
|
|
|
|
2001-11-29 09:06:44 +08:00
|
|
|
tilebpp = tile_manager_bpp (PR->tiles);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-11-29 10:28:57 +08:00
|
|
|
write_pixel_data (PR->tiles, x, y, x, end-1, data, tilebpp);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
2000-06-08 02:43:22 +08:00
|
|
|
gboolean
|
|
|
|
pixel_region_has_alpha (PixelRegion *PR)
|
1999-08-20 18:06:54 +08:00
|
|
|
{
|
|
|
|
if (PR->bytes == 2 || PR->bytes == 4)
|
2000-06-08 02:43:22 +08:00
|
|
|
return TRUE;
|
|
|
|
else
|
|
|
|
return FALSE;
|
1999-08-20 18:06:54 +08:00
|
|
|
}
|
|
|
|
|
2002-08-22 17:48:56 +08:00
|
|
|
PixelRegionIterator *
|
2003-09-29 04:13:59 +08:00
|
|
|
pixel_regions_register (gint num_regions,
|
1999-07-20 03:46:05 +08:00
|
|
|
...)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2001-05-14 21:39:45 +08:00
|
|
|
PixelRegion *PR;
|
|
|
|
PixelRegionHolder *PRH;
|
1997-11-25 06:05:25 +08:00
|
|
|
PixelRegionIterator *PRI;
|
2001-05-14 21:39:45 +08:00
|
|
|
gboolean found;
|
|
|
|
va_list ap;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2002-08-22 17:48:56 +08:00
|
|
|
PRI = g_new0 (PixelRegionIterator, 1);
|
|
|
|
PRI->dirty_tiles = 1;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
if (num_regions < 1)
|
2000-06-08 02:43:22 +08:00
|
|
|
return NULL;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
va_start (ap, num_regions);
|
|
|
|
|
|
|
|
found = FALSE;
|
|
|
|
while (num_regions --)
|
|
|
|
{
|
|
|
|
PR = va_arg (ap, PixelRegion *);
|
2002-08-22 17:48:56 +08:00
|
|
|
|
|
|
|
PRH = g_new0 (PixelRegionHolder, 1);
|
1997-11-25 06:05:25 +08:00
|
|
|
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;
|
2000-06-08 02:43:22 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
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 */
|
1998-01-29 16:03:27 +08:00
|
|
|
PRI->pixel_regions = g_slist_prepend (PRI->pixel_regions, PRH);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
va_end (ap);
|
|
|
|
|
|
|
|
return pixel_regions_configure (PRI);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-08-22 17:48:56 +08:00
|
|
|
PixelRegionIterator *
|
2001-08-17 22:27:31 +08:00
|
|
|
pixel_regions_process (PixelRegionIterator *PRI)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2001-05-14 21:39:45 +08:00
|
|
|
GSList *list;
|
|
|
|
PixelRegionHolder *PRH;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
PRI->process_count++;
|
|
|
|
|
|
|
|
/* Unref all referenced tiles and increment the offsets */
|
|
|
|
|
2000-06-08 02:43:22 +08:00
|
|
|
for (list = PRI->pixel_regions; list; list = g_slist_next (list))
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
|
|
|
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++;
|
|
|
|
|
2003-09-29 04:13:59 +08:00
|
|
|
/* Unref the last referenced tile if the underlying region
|
2000-06-08 02:43:22 +08:00
|
|
|
is a tile manager */
|
1997-11-25 06:05:25 +08:00
|
|
|
if (PRH->PR->tiles)
|
|
|
|
{
|
2000-06-08 02:43:22 +08:00
|
|
|
/* only set the dirty flag if PRH->dirty_tiles == TRUE */
|
1999-07-27 16:47:31 +08:00
|
|
|
tile_release (PRH->PR->curtile,
|
1999-12-14 03:48:24 +08:00
|
|
|
PRH->PR->dirty && PRI->dirty_tiles);
|
1998-08-16 03:17:36 +08:00
|
|
|
PRH->PR->curtile = NULL;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
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
|
2001-08-17 22:27:31 +08:00
|
|
|
pixel_regions_process_stop (PixelRegionIterator *PRI)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2001-05-14 21:39:45 +08:00
|
|
|
GSList *list;
|
2000-06-08 02:43:22 +08:00
|
|
|
PixelRegionHolder *PRH;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
PRI->process_count++;
|
|
|
|
|
|
|
|
/* Unref all referenced tiles and increment the offsets */
|
|
|
|
|
2000-06-08 02:43:22 +08:00
|
|
|
for (list = PRI->pixel_regions; list; list = g_slist_next (list))
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
|
|
|
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++;
|
|
|
|
|
2003-09-29 04:13:59 +08:00
|
|
|
/* Unref the last referenced tile if the underlying region
|
2000-06-08 02:43:22 +08:00
|
|
|
is a tile manager */
|
1997-11-25 06:05:25 +08:00
|
|
|
if (PRH->PR->tiles)
|
|
|
|
{
|
1998-08-16 03:17:36 +08:00
|
|
|
tile_release (PRH->PR->curtile, PRH->PR->dirty);
|
|
|
|
PRH->PR->curtile = NULL;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (PRI->pixel_regions)
|
|
|
|
{
|
2000-06-08 02:43:22 +08:00
|
|
|
for (list = PRI->pixel_regions; list; list = g_slist_next (list))
|
|
|
|
g_free (list->data);
|
|
|
|
|
1998-01-29 16:03:27 +08:00
|
|
|
g_slist_free (PRI->pixel_regions);
|
1997-11-25 06:05:25 +08:00
|
|
|
g_free (PRI);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*********************************/
|
|
|
|
/* Static Function Definitions */
|
|
|
|
|
2000-06-08 02:43:22 +08:00
|
|
|
static gint
|
1999-07-20 03:46:05 +08:00
|
|
|
get_portion_height (PixelRegionIterator *PRI)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2001-05-14 21:39:45 +08:00
|
|
|
GSList *list;
|
1997-11-25 06:05:25 +08:00
|
|
|
PixelRegionHolder *PRH;
|
2001-05-14 21:39:45 +08:00
|
|
|
gint min_height = G_MAXINT;
|
|
|
|
gint height;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2003-09-29 04:13:59 +08:00
|
|
|
/* Find the minimum height to the next vertical tile
|
|
|
|
* (in the case of a tile manager) or to the end of the
|
2000-06-08 02:43:22 +08:00
|
|
|
* pixel region (in the case of no tile manager)
|
1997-11-25 06:05:25 +08:00
|
|
|
*/
|
|
|
|
|
2000-06-08 02:43:22 +08:00
|
|
|
for (list = PRI->pixel_regions; list; list = g_slist_next (list))
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
|
|
|
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);
|
2003-09-29 04:13:59 +08:00
|
|
|
height = CLAMP (height,
|
|
|
|
0,
|
2000-06-08 02:43:22 +08:00
|
|
|
(PRI->region_height - (PRH->PR->y - PRH->starty)));
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
height = (PRI->region_height - (PRH->PR->y - PRH->starty));
|
|
|
|
|
|
|
|
if (height < min_height)
|
|
|
|
min_height = height;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return min_height;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-06-08 02:43:22 +08:00
|
|
|
static gint
|
1999-07-20 03:46:05 +08:00
|
|
|
get_portion_width (PixelRegionIterator *PRI)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2001-05-14 21:39:45 +08:00
|
|
|
GSList *list;
|
1997-11-25 06:05:25 +08:00
|
|
|
PixelRegionHolder *PRH;
|
2001-05-14 21:39:45 +08:00
|
|
|
gint min_width = G_MAXINT;
|
|
|
|
gint width;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2003-09-29 04:13:59 +08:00
|
|
|
/* Find the minimum width to the next vertical tile
|
|
|
|
* (in the case of a tile manager) or to the end of
|
2000-06-08 02:43:22 +08:00
|
|
|
* the pixel region (in the case of no tile manager)
|
1997-11-25 06:05:25 +08:00
|
|
|
*/
|
|
|
|
|
2000-06-08 02:43:22 +08:00
|
|
|
for (list = PRI->pixel_regions; list; list = g_slist_next (list))
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
|
|
|
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);
|
2003-09-29 04:13:59 +08:00
|
|
|
width = CLAMP (width,
|
|
|
|
0,
|
2000-06-08 02:43:22 +08:00
|
|
|
(PRI->region_width - (PRH->PR->x - PRH->startx)));
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
width = (PRI->region_width - (PRH->PR->x - PRH->startx));
|
|
|
|
|
|
|
|
if (width < min_width)
|
|
|
|
min_width = width;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return min_width;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-08-22 17:48:56 +08:00
|
|
|
static PixelRegionIterator *
|
1999-07-20 03:46:05 +08:00
|
|
|
pixel_regions_configure (PixelRegionIterator *PRI)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
|
|
|
PixelRegionHolder *PRH;
|
2001-05-14 21:39:45 +08:00
|
|
|
GSList *list;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/* Determine the portion width and height */
|
2002-08-22 17:48:56 +08:00
|
|
|
PRI->portion_width = get_portion_width (PRI);
|
1997-11-25 06:05:25 +08:00
|
|
|
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)
|
|
|
|
{
|
2000-06-08 02:43:22 +08:00
|
|
|
for (list = PRI->pixel_regions; list; list = g_slist_next (list))
|
|
|
|
g_free (list->data);
|
|
|
|
|
1998-01-29 16:03:27 +08:00
|
|
|
g_slist_free (PRI->pixel_regions);
|
1997-11-25 06:05:25 +08:00
|
|
|
g_free (PRI);
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
PRI->process_count++;
|
|
|
|
|
2000-06-08 02:43:22 +08:00
|
|
|
for (list = PRI->pixel_regions; list; list = g_slist_next (list))
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
|
|
|
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
|
2003-09-29 04:13:59 +08:00
|
|
|
pixel_region_configure (PixelRegionHolder *PRH,
|
1999-07-20 03:46:05 +08:00
|
|
|
PixelRegionIterator *PRI)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
|
|
|
/* 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)
|
|
|
|
{
|
2003-09-29 04:13:59 +08:00
|
|
|
PRH->PR->curtile = tile_manager_get_tile (PRH->PR->tiles,
|
|
|
|
PRH->PR->x,
|
|
|
|
PRH->PR->y,
|
|
|
|
TRUE,
|
2000-06-08 02:43:22 +08:00
|
|
|
PRH->PR->dirty);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1998-08-16 03:17:36 +08:00
|
|
|
PRH->PR->offx = PRH->PR->x % TILE_WIDTH;
|
|
|
|
PRH->PR->offy = PRH->PR->y % TILE_HEIGHT;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2000-06-08 02:43:22 +08:00
|
|
|
PRH->PR->rowstride = tile_ewidth (PRH->PR->curtile) * PRH->PR->bytes;
|
2003-09-29 04:13:59 +08:00
|
|
|
PRH->PR->data = tile_data_pointer (PRH->PR->curtile,
|
|
|
|
PRH->PR->offx,
|
2000-06-08 02:43:22 +08:00
|
|
|
PRH->PR->offy);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
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;
|
|
|
|
}
|