more cursor support. new cursor fix that rounding error the right way this
* app/clone.c: more cursor support.
* app/cursorutil.[ch], cursors/{bad,badmsk}: new cursor
* app/paint_core.c: fix that rounding error the right way this time.
* app/pixel_processor.c, app/pixel_region.c: Lock the tiles while
they are being processed. Only create new threads if the region
being processed is large enough to warrant it.
This commit is contained in:
@ -22,6 +22,7 @@
|
||||
|
||||
#include "pixel_processor.h"
|
||||
#include "pixel_region.h"
|
||||
#include "pixel_regionP.h"
|
||||
#include "gimprc.h"
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
@ -47,8 +48,6 @@ typedef void (*p3_func)(void *, PixelRegion * ,PixelRegion *, PixelRegion *);
|
||||
typedef void (*p4_func)(void *, PixelRegion * ,PixelRegion *, PixelRegion *,
|
||||
PixelRegion *);
|
||||
|
||||
typedef struct _PixelRegionIterator PixelRegionIterator;
|
||||
|
||||
struct _PixelProcessor
|
||||
{
|
||||
void *data;
|
||||
@ -85,7 +84,13 @@ do_parallel_regions(PixelProcessor *p_s)
|
||||
{
|
||||
for (i = 0; i < p_s->n_regions; i++)
|
||||
if (p_s->r[i])
|
||||
{
|
||||
memcpy(&tr[i], p_s->r[i], sizeof(PixelRegion));
|
||||
IF_THREAD(
|
||||
if (tr[i].tiles)
|
||||
tile_lock(tr[i].curtile);
|
||||
)
|
||||
}
|
||||
IF_THREAD(pthread_mutex_unlock(&p_s->mutex);)
|
||||
ntiles++;
|
||||
switch(p_s->n_regions)
|
||||
@ -117,6 +122,15 @@ do_parallel_regions(PixelProcessor *p_s)
|
||||
p_s->n_regions);
|
||||
}
|
||||
IF_THREAD(pthread_mutex_lock(&p_s->mutex);)
|
||||
IF_THREAD(
|
||||
{
|
||||
for (i = 0; i < p_s->n_regions; i++)
|
||||
if (p_s->r[i])
|
||||
{
|
||||
if (tr[i].tiles)
|
||||
tile_release(tr[i].curtile, tr[i].dirty);
|
||||
}
|
||||
})
|
||||
if (p_s->progress_report_func)
|
||||
if (!p_s->progress_report_func(p_s->progress_report_data,
|
||||
p_s->r[0]->x, p_s->r[0]->y,
|
||||
@ -142,7 +156,10 @@ pixel_regions_do_parallel(PixelProcessor *p_s)
|
||||
|
||||
/* (p_s->PRI->region_width * p_s->PRI->region_height) /(64*64)); */
|
||||
IF_THREAD(
|
||||
nthreads = MIN(num_processors, 5);
|
||||
nthreads = MIN(num_processors, MAX_THREADS);
|
||||
nthreads = MIN(nthreads, 1 +
|
||||
(p_s->PRI->region_width * p_s->PRI->region_height)
|
||||
/(TILE_WIDTH*TILE_HEIGHT));
|
||||
if (nthreads > 1)
|
||||
{
|
||||
pthread_attr_init (&pthread_attr);
|
||||
@ -213,6 +230,7 @@ pixel_regions_real_process_parallel(p_func f, void *data,
|
||||
pixel_processor_free(p_s);
|
||||
return NULL;
|
||||
}
|
||||
IF_THREAD(p_s->PRI->dirty_tiles = 0;)
|
||||
p_s->f = f;
|
||||
p_s->data = data;
|
||||
p_s->n_regions = num_regions;
|
||||
|
||||
@ -21,35 +21,13 @@
|
||||
#include <string.h>
|
||||
#include "appenv.h"
|
||||
#include "pixel_region.h"
|
||||
#include "pixel_regionP.h"
|
||||
#include "gimprc.h"
|
||||
|
||||
#include "tile_manager_pvt.h"
|
||||
#include "tile.h" /* ick. */
|
||||
|
||||
|
||||
typedef struct _PixelRegionHolder PixelRegionHolder;
|
||||
|
||||
struct _PixelRegionHolder
|
||||
{
|
||||
PixelRegion *PR;
|
||||
unsigned char *original_data;
|
||||
int startx, starty;
|
||||
int count;
|
||||
};
|
||||
|
||||
|
||||
typedef struct _PixelRegionIterator PixelRegionIterator;
|
||||
|
||||
struct _PixelRegionIterator
|
||||
{
|
||||
GSList *pixel_regions;
|
||||
int region_width;
|
||||
int region_height;
|
||||
int portion_width;
|
||||
int portion_height;
|
||||
int process_count;
|
||||
};
|
||||
|
||||
/*********************/
|
||||
/* Local Variables */
|
||||
|
||||
@ -306,6 +284,7 @@ pixel_regions_register (int num_regions,
|
||||
PRI = (PixelRegionIterator *) g_malloc (sizeof (PixelRegionIterator));
|
||||
PRI->pixel_regions = NULL;
|
||||
PRI->process_count = 0;
|
||||
PRI->dirty_tiles = 1;
|
||||
|
||||
if (num_regions < 1)
|
||||
return FALSE;
|
||||
@ -374,7 +353,9 @@ pixel_regions_process (void *PRI_ptr)
|
||||
/* Unref the last referenced tile if the underlying region is a tile manager */
|
||||
if (PRH->PR->tiles)
|
||||
{
|
||||
tile_release (PRH->PR->curtile, PRH->PR->dirty);
|
||||
/* only set the dirty flag if PRH->dirty_tiles = true */
|
||||
tile_release (PRH->PR->curtile,
|
||||
PRH->PR->dirty * PRI->dirty_tiles);
|
||||
PRH->PR->curtile = NULL;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user