app: gegl dissolve layer-mode pedantic indentation

This commit is contained in:
Øyvind Kolås 2012-03-31 22:53:23 +01:00 committed by Michael Natterer
parent 3b043a1597
commit 671164a0fe
1 changed files with 26 additions and 43 deletions

View File

@ -28,23 +28,23 @@
#include "gimpoperationdissolvemode.h"
#define RANDOM_TABLE_SIZE 4096
static void gimp_operation_dissolve_mode_prepare (GeglOperation *operation);
static gboolean gimp_operation_dissolve_mode_process (GeglOperation *operation,
void *in_buf,
void *aux_buf,
void *out_buf,
glong samples,
const GeglRectangle *result,
gint level);
G_DEFINE_TYPE (GimpOperationDissolveMode, gimp_operation_dissolve_mode,
GIMP_TYPE_OPERATION_POINT_LAYER_MODE)
#define RANDOM_TABLE_SIZE 4096
static gint32 random_table[RANDOM_TABLE_SIZE];
static void gimp_operation_dissolve_mode_prepare (
GeglOperation *operation);
static gboolean gimp_operation_dissolve_mode_process (
GeglOperation *operation,
void *in_buf,
void *aux_buf,
void *out_buf,
glong samples,
const GeglRectangle *result,
gint level);
static void
gimp_operation_dissolve_mode_class_init (GimpOperationDissolveModeClass *klass)
@ -53,9 +53,8 @@ gimp_operation_dissolve_mode_class_init (GimpOperationDissolveModeClass *klass)
GeglOperationPointComposerClass *point_composer_class;
GRand *gr;
gint i;
static gboolean table_initialized = FALSE;
operation_class = GEGL_OPERATION_CLASS (klass);
operation_class = GEGL_OPERATION_CLASS (klass);
point_composer_class = GEGL_OPERATION_POINT_COMPOSER_CLASS (klass);
gegl_operation_class_set_keys (operation_class,
@ -67,21 +66,12 @@ gimp_operation_dissolve_mode_class_init (GimpOperationDissolveModeClass *klass)
operation_class->prepare = gimp_operation_dissolve_mode_prepare;
point_composer_class->process = gimp_operation_dissolve_mode_process;
#define RANDOM_SEED 314159265
/* generate a table of random seeds */
gr = g_rand_new_with_seed (314159265);
for (i = 0; i < RANDOM_TABLE_SIZE; i++)
random_table[i] = g_rand_int (gr);
if (!table_initialized)
{
/* generate a table of random seeds */
gr = g_rand_new_with_seed (RANDOM_SEED);
for (i = 0; i < RANDOM_TABLE_SIZE; i++)
{
random_table[i] = g_rand_int (gr);
}
g_rand_free (gr);
table_initialized = TRUE;
}
g_rand_free (gr);
}
static void
@ -92,12 +82,10 @@ gimp_operation_dissolve_mode_init (GimpOperationDissolveMode *self)
static void
gimp_operation_dissolve_mode_prepare (GeglOperation *operation)
{
const Babl *format;
const Babl *format = babl_format ("R'G'B'A float");
format = babl_format ("R'G'B'A float");
gegl_operation_set_format (operation, "input", format);
gegl_operation_set_format (operation, "aux", format);
gegl_operation_set_format (operation, "input", format);
gegl_operation_set_format (operation, "aux", format);
gegl_operation_set_format (operation, "output", format);
}
@ -119,17 +107,13 @@ gimp_operation_dissolve_mode_process (GeglOperation *operation,
{
GRand *gr = g_rand_new_with_seed (random_table[y % RANDOM_TABLE_SIZE]);
/* fast forward through this rows pseudo random sequence */
/* fast forward through the rows pseudo random sequence */
for (x = 0; x < result->x; x++)
g_rand_int (gr);
for (x = result->x; x < result->x + result->width; x++, i++)
{
int rand_val;
/* dissolve if random value is >= opacity */
rand_val = g_rand_int_range (gr, 0, 255);
if (rand_val >= aux[3] * 255)
if (g_rand_int_range (gr, 0, 255) >= aux[3] * 255)
{
out[0] = in[0];
out[1] = in[1];
@ -143,10 +127,9 @@ gimp_operation_dissolve_mode_process (GeglOperation *operation,
out[2] = aux[2];
out[3] = 1.0;
}
in+=4;
out+=4;
aux+=4;
in += 4;
out += 4;
aux += 4;
}
g_rand_free (gr);
}