Commit ccfe47ad authored by jaycox's avatar jaycox
Browse files

removed a c++ style comment


	* app/ops_buttons.h: removed a c++ style comment

	* app/paint_funcs.c: applied Craig Wiegert's patch to fix
 	the rounding errors in the scaling code.

	* app/paint_funcs.c: Use a mutex lock in disolve pixels instead of
 	rand_r on linux systems since linux's rand_r appears to be broken.

	* app/bezier_select.c: applied Shuji Narazaki's patch that corrects
 	for layer offsets in bezier_stroke.
parent 7e28ed4c
1999-03-18 Jay Cox <jaycox@earthlink.net>
* app/ops_buttons.h: removed a c++ style comment
* app/paint_funcs.c: applied Craig Wiegert's patch to fix
the rounding errors in the scaling code.
* app/paint_funcs.c: Use a mutex lock in disolve pixels instead of
rand_r on linux systems since linux's rand_r appears to be broken.
* app/bezier_select.c: applied Shuji Narazaki's patch that corrects
for layer offsets in bezier_stroke.
Thu Mar 18 19:35:48 EST 1999 Adrian Likins <adrian@gimp.org>
* app/paintbrush.c
......
......@@ -2256,9 +2256,27 @@ bezier_stroke (BezierSelect *bezier_sel,
if (stroke_points)
{
GimpDrawable *drawable;
int offset_x, offset_y;
drawable = gimage_active_drawable (gdisp->gimage);
gimp_drawable_offsets (drawable, &offset_x, &offset_y);
if ((offset_x != 0) || (offset_y != 0))
{
gdouble *ptr;
ptr = stroke_points;
while (ptr < stroke_points + (num_stroke_points * 2))
{
*ptr++ -= offset_x;
*ptr++ -= offset_y;
}
}
return_vals = procedural_db_run_proc ("gimp_paintbrush",
&nreturn_vals,
PDB_DRAWABLE, drawable_ID (gimage_active_drawable (gdisp->gimage)),
PDB_DRAWABLE, drawable_ID (drawable),
PDB_FLOAT, (gdouble) 0,
PDB_INT32, (gint32) num_stroke_points * 2,
PDB_FLOATARRAY, stroke_points,
......
......@@ -24,7 +24,7 @@ typedef struct _OpsButton OpsButton;
typedef void (*OpsButtonCallback) (GtkWidget *widget,
gpointer user_data);
// typedef OpsButtonCallback OpsButtonExtCallbacks;
/* typedef OpsButtonCallback OpsButtonExtCallbacks; */
typedef enum {
OPS_BUTTON_MODIFIER_NONE,
......
......@@ -39,6 +39,12 @@
#include <stdio.h>
#ifdef ENABLE_MP
/* pthread.h is only needed because of an apparent bug in the
rand_r function in GNU Libc 2.1 */
#include <pthread.h>
#endif /* ENABLE_MP */
#define STD_BUF_SIZE 1021
#define MAXDIFF 195076
#define HASH_TABLE_SIZE 1021
......@@ -1000,13 +1006,23 @@ dissolve_pixels (const unsigned char *src,
{
int alpha, b;
int rand_val;
#ifdef ENABLE_MP
#if defined(ENABLE_MP) && defined(linux)
/* rand_r seems to be broken on the linux systems we tried, so
disable it for now */
/* if we are mult-threaded and can't use rand_r then we must
use a mutex to force single-threaded execution of this function */
static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
pthread_mutex_lock(&mutex);
{
#elif defined(ENABLE_MP) && !defined(linux)
/* if we are running with multiple threads rand_r give _much_
better performance than rand */
unsigned int seed;
seed = random_table [y % RANDOM_TABLE_SIZE];
for (b = 0; b < x; b++)
rand_r(&seed);
#else
/* Set up the random number generator */
srand (random_table [y % RANDOM_TABLE_SIZE]);
......@@ -1022,7 +1038,7 @@ dissolve_pixels (const unsigned char *src,
dest[b] = src[b];
/* dissolve if random value is > opacity */
#ifdef ENABLE_MP
#if defined(ENABLE_MP) && !defined(linux)
rand_val = (rand_r(&seed) & 0xFF);
#else
rand_val = (rand() & 0xFF);
......@@ -1035,6 +1051,10 @@ dissolve_pixels (const unsigned char *src,
dest += db;
src += sb;
}
#if defined(ENABLE_MP) && defined(linux)
}
pthread_mutex_unlock(&mutex);
#endif /* defined(ENABLE_MP) && !defined(_SGI_REENTRANT_FUNCTIONS) */
}
void
......@@ -3755,7 +3775,7 @@ scale_region (PixelRegion *srcPR,
{
b = bytes;
while (b--)
*d++ = (unsigned char) (*r++ * tot_frac);
*d++ = (unsigned char) (*r++ * tot_frac + 0.5);
}
/* set the pixel region span */
......@@ -3928,7 +3948,7 @@ subsample_region (PixelRegion *srcPR,
{
b = bytes;
while (b--)
*d++ = (unsigned char) (*r++ * tot_frac);
*d++ = (unsigned char) (*r++ * tot_frac + 0.5);
}
dest += destwidth;
......
......@@ -39,6 +39,12 @@
#include <stdio.h>
#ifdef ENABLE_MP
/* pthread.h is only needed because of an apparent bug in the
rand_r function in GNU Libc 2.1 */
#include <pthread.h>
#endif /* ENABLE_MP */
#define STD_BUF_SIZE 1021
#define MAXDIFF 195076
#define HASH_TABLE_SIZE 1021
......@@ -1000,13 +1006,23 @@ dissolve_pixels (const unsigned char *src,
{
int alpha, b;
int rand_val;
#ifdef ENABLE_MP
#if defined(ENABLE_MP) && defined(linux)
/* rand_r seems to be broken on the linux systems we tried, so
disable it for now */
/* if we are mult-threaded and can't use rand_r then we must
use a mutex to force single-threaded execution of this function */
static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
pthread_mutex_lock(&mutex);
{
#elif defined(ENABLE_MP) && !defined(linux)
/* if we are running with multiple threads rand_r give _much_
better performance than rand */
unsigned int seed;
seed = random_table [y % RANDOM_TABLE_SIZE];
for (b = 0; b < x; b++)
rand_r(&seed);
#else
/* Set up the random number generator */
srand (random_table [y % RANDOM_TABLE_SIZE]);
......@@ -1022,7 +1038,7 @@ dissolve_pixels (const unsigned char *src,
dest[b] = src[b];
/* dissolve if random value is > opacity */
#ifdef ENABLE_MP
#if defined(ENABLE_MP) && !defined(linux)
rand_val = (rand_r(&seed) & 0xFF);
#else
rand_val = (rand() & 0xFF);
......@@ -1035,6 +1051,10 @@ dissolve_pixels (const unsigned char *src,
dest += db;
src += sb;
}
#if defined(ENABLE_MP) && defined(linux)
}
pthread_mutex_unlock(&mutex);
#endif /* defined(ENABLE_MP) && !defined(_SGI_REENTRANT_FUNCTIONS) */
}
void
......@@ -3755,7 +3775,7 @@ scale_region (PixelRegion *srcPR,
{
b = bytes;
while (b--)
*d++ = (unsigned char) (*r++ * tot_frac);
*d++ = (unsigned char) (*r++ * tot_frac + 0.5);
}
/* set the pixel region span */
......@@ -3928,7 +3948,7 @@ subsample_region (PixelRegion *srcPR,
{
b = bytes;
while (b--)
*d++ = (unsigned char) (*r++ * tot_frac);
*d++ = (unsigned char) (*r++ * tot_frac + 0.5);
}
dest += destwidth;
......
......@@ -2256,9 +2256,27 @@ bezier_stroke (BezierSelect *bezier_sel,
if (stroke_points)
{
GimpDrawable *drawable;
int offset_x, offset_y;
drawable = gimage_active_drawable (gdisp->gimage);
gimp_drawable_offsets (drawable, &offset_x, &offset_y);
if ((offset_x != 0) || (offset_y != 0))
{
gdouble *ptr;
ptr = stroke_points;
while (ptr < stroke_points + (num_stroke_points * 2))
{
*ptr++ -= offset_x;
*ptr++ -= offset_y;
}
}
return_vals = procedural_db_run_proc ("gimp_paintbrush",
&nreturn_vals,
PDB_DRAWABLE, drawable_ID (gimage_active_drawable (gdisp->gimage)),
PDB_DRAWABLE, drawable_ID (drawable),
PDB_FLOAT, (gdouble) 0,
PDB_INT32, (gint32) num_stroke_points * 2,
PDB_FLOATARRAY, stroke_points,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment