Commit e87f6dcc authored by Sven Neumann's avatar Sven Neumann Committed by Sven Neumann

changed time-smoother code to use guint32 time values externally, guint64

2005-03-21  Sven Neumann  <sven@gimp.org>

	* app/paint/gimpink.c: changed time-smoother code to use guint32
	time values externally, guint64 internally. Proper fix for bug
	#164272.
parent eac2c006
2005-03-21 Sven Neumann <sven@gimp.org>
* app/paint/gimpink.c: changed time-smoother code to use guint32
time values externally, guint64 internally. Proper fix for bug
#164272.
2005-03-21 Sven Neumann <sven@gimp.org>
* app/actions/dialogs-actions.h: bail out if
......
......@@ -76,9 +76,10 @@ static Blob * ink_pen_ellipse (GimpInkOptions *options,
static void time_smoother_add (GimpInk *ink,
guint32 value);
static gdouble time_smoother_result (GimpInk *ink);
static guint32 time_smoother_result (GimpInk *ink);
static void time_smoother_init (GimpInk *ink,
guint32 initval);
static void dist_smoother_add (GimpInk *ink,
gdouble value);
static gdouble dist_smoother_result (GimpInk *ink);
......@@ -518,84 +519,82 @@ ink_pen_ellipse (GimpInkOptions *options,
radmin * tcos);
}
static void
dist_smoother_init (GimpInk *ink,
gdouble initval)
time_smoother_init (GimpInk *ink,
guint32 initval)
{
gint i;
ink->dt_index = 0;
ink->ts_index = 0;
for (i = 0; i < DIST_SMOOTHER_BUFFER; i++)
{
ink->dt_buffer[i] = initval;
}
for (i = 0; i < TIME_SMOOTHER_BUFFER; i++)
ink->ts_buffer[i] = initval;
}
static gdouble
dist_smoother_result (GimpInk *ink)
static guint32
time_smoother_result (GimpInk *ink)
{
gint i;
gdouble result = 0.0;
guint64 result = 0;
for (i = 0; i < DIST_SMOOTHER_BUFFER; i++)
{
result += ink->dt_buffer[i];
}
for (i = 0; i < TIME_SMOOTHER_BUFFER; i++)
result += ink->ts_buffer[i];
return (result / (gdouble) DIST_SMOOTHER_BUFFER);
return (result / (guint64) TIME_SMOOTHER_BUFFER);
}
static void
dist_smoother_add (GimpInk *ink,
gdouble value)
time_smoother_add (GimpInk *ink,
guint32 value)
{
ink->dt_buffer[ink->dt_index] = value;
guint64 long_value = (guint64) value;
if ((++ink->dt_index) == DIST_SMOOTHER_BUFFER)
ink->dt_index = 0;
/* handle wrap-around of time values */
if (long_value < ink->ts_buffer[ink->ts_index])
long_value += (guint64) + G_MAXUINT32;
ink->ts_buffer[ink->ts_index++] = long_value;
ink->ts_buffer[ink->ts_index++] = value;
if (ink->ts_index == TIME_SMOOTHER_BUFFER)
ink->ts_index = 0;
}
static void
time_smoother_init (GimpInk *ink,
guint32 initval)
dist_smoother_init (GimpInk *ink,
gdouble initval)
{
gint i;
ink->ts_index = 0;
ink->dt_index = 0;
for (i = 0; i < TIME_SMOOTHER_BUFFER; i++)
{
ink->ts_buffer[i] = initval;
}
for (i = 0; i < DIST_SMOOTHER_BUFFER; i++)
ink->dt_buffer[i] = initval;
}
static gdouble
time_smoother_result (GimpInk *ink)
dist_smoother_result (GimpInk *ink)
{
gint i;
guint64 result = 0;
gdouble result = 0.0;
for (i = 0; i < TIME_SMOOTHER_BUFFER; i++)
{
result += ink->ts_buffer[i];
}
for (i = 0; i < DIST_SMOOTHER_BUFFER; i++)
result += ink->dt_buffer[i];
#ifdef _MSC_VER
return (gdouble) (gint64) (result / TIME_SMOOTHER_BUFFER);
#else
return (result / TIME_SMOOTHER_BUFFER);
#endif
return (result / (gdouble) DIST_SMOOTHER_BUFFER);
}
static void
time_smoother_add (GimpInk *ink,
guint32 value)
dist_smoother_add (GimpInk *ink,
gdouble value)
{
ink->ts_buffer[ink->ts_index] = value;
ink->dt_buffer[ink->dt_index++] = value;
if ((++ink->ts_index) == TIME_SMOOTHER_BUFFER)
ink->ts_index = 0;
if (ink->dt_index == DIST_SMOOTHER_BUFFER)
ink->dt_index = 0;
}
......
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