--- gimp-2.4.3-/app/paint/gimpmixbrush.c Sat Jan 26 18:40:37 2008 +++ gimp-painter--2.4.3/app/paint/gimpmixbrush.c Sat Jan 26 02:23:53 2008 @@ -149,7 +149,8 @@ PixelRegion *srcPR, PixelRegion *maskPR, const gboolean is_rgb, - const gboolean has_alpha); + const gboolean has_alpha, + gboolean *active_components); __inline__ void composite_textured_dab (GimpRGB *paint_color, gdouble opacity, @@ -162,7 +163,8 @@ gint drawable_y, gdouble grain, const gboolean is_rgb, - const gboolean has_alpha); + const gboolean has_alpha, + gboolean *active_components); #endif @@ -291,6 +293,11 @@ (mixbrush_options->alpha_channel_mixing && gimp_drawable_has_alpha (drawable)); /* Init the pressure params */ + calc_pressure_params (&mixbrush->pr_texture_grain, + mixbrush_options->texture_options->grain_pressure_in1, + mixbrush_options->texture_options->grain_pressure_in2, + mixbrush_options->texture_options->grain_pressure_out1, + mixbrush_options->texture_options->grain_pressure_out2); calc_pressure_params (&mixbrush->pr_main_density, mixbrush_options->main_color_density_pressure_in1, mixbrush_options->main_color_density_pressure_in2, @@ -631,7 +638,8 @@ if (mixbrush_options->texture_options->use_texture) { grain = mixbrush_options->texture_options->grain; - grain -= (2.0 - (grain + 1.0)) * (1.0 - paint_core->cur_coords.pressure); + grain = -1.0 + (grain + 1.0) * calc_pressure (paint_core->cur_coords.pressure, + &mixbrush->pr_texture_grain); texture = gimp_context_get_pattern (context); } @@ -1010,16 +1018,25 @@ gdouble grain, gboolean reduce_update_freq) { - TempBuf *brush_mask = gimp_brush_core_get_brush_mask (GIMP_BRUSH_CORE (core), GIMP_BRUSH_SOFT); - TempBuf *canvas_buf = core->canvas_buf; - gint c_x = canvas_buf->x, c_y = canvas_buf->y, c_w = canvas_buf->width, c_h = canvas_buf->height; - PixelRegion srcPR, maskPR; - gint x, y, off_x, off_y; - gboolean is_rgb, has_alpha; - - if (!brush_mask || !canvas_buf || opacity == 0.0) + TempBuf *brush_mask = gimp_brush_core_get_brush_mask (GIMP_BRUSH_CORE (core), GIMP_BRUSH_SOFT); + TempBuf *canvas_buf = core->canvas_buf; + gint c_x, c_y, c_w, c_h; + PixelRegion srcPR, maskPR; + gint x, y, off_x, off_y; + gboolean is_rgb, has_alpha; + gboolean active_components[MAX_CHANNELS]; + + if (!brush_mask || + !canvas_buf || + opacity == 0.0 || + (texture && grain <= -1.0)) return; + c_x = canvas_buf->x; + c_y = canvas_buf->y; + c_w = canvas_buf->width; + c_h = canvas_buf->height; + /* set undo blocks */ gimp_paint_core_validate_undo_tiles (core, drawable, c_x, c_y, c_w, c_h); @@ -1042,6 +1059,9 @@ is_rgb = (srcPR.bytes > 2); has_alpha = (srcPR.bytes == 2 || srcPR.bytes == 4); + /* configure the active channel array */ + gimp_drawable_get_active_components (drawable, active_components); + if (texture) { gint dx, dy; @@ -1057,7 +1077,8 @@ dx, dy, grain, is_rgb, - has_alpha); + has_alpha, + active_components); } else composite_dab (paint_color, @@ -1065,7 +1086,8 @@ &srcPR, &maskPR, is_rgb, - has_alpha); + has_alpha, + active_components); #if 0 { @@ -1150,11 +1172,12 @@ PixelRegion *srcPR, PixelRegion *maskPR, const gboolean is_rgb, - const gboolean has_alpha) + const gboolean has_alpha, + gboolean *active_components) { { /* _composite_* () */ gpointer iter; - gint w, h; + gint width, height; gint src_bytes; gint src_stride, mask_stride; guchar *src_data, *_src_data; @@ -1179,17 +1202,17 @@ src_data = srcPR->data; mask_data = maskPR->data; - w = maskPR->w; - h = maskPR->h; + width = maskPR->w; + height = maskPR->h; src_stride = srcPR->rowstride; mask_stride = maskPR->rowstride; - for (i = 0; i < h; i++) + for (i = 0; i < height; i++) { _src_data = src_data; _mask_data = mask_data; - for (j = 0; j < w; j++) + for (j = 0; j < width; j++) { gdouble op, mask_op, paint_color_op, canvas_color_op, src_op; gdouble factor1, factor2; @@ -1208,7 +1231,7 @@ { mask_op = _mask_data[0] / 255.0; - if (has_alpha) + if (has_alpha && active_components[src_bytes - 1]) { src_op = _src_data[src_bytes - 1] / 255.0; @@ -1287,11 +1310,12 @@ gint drawable_y, gdouble grain, const gboolean is_rgb, - const gboolean has_alpha) + const gboolean has_alpha, + gboolean *active_components) { gpointer iter; - gint w, h; - gint src_bytes; + gint width, height, texture_width, texture_height; + gint src_bytes, texture_bytes; gint src_stride, mask_stride, texture_stride; guchar *src_data, *_src_data; guchar *mask_data, *_mask_data; @@ -1311,12 +1335,16 @@ } texture_data = temp_buf_data (texture_buf); - texture_stride = texture_buf->width * texture_buf->bytes; + texture_bytes = texture_buf->bytes; + texture_width = texture_buf->width; + texture_height = texture_buf->height; + texture_stride = texture_width * texture_bytes; for (iter = pixel_regions_register (2, srcPR, maskPR); iter != NULL; iter = pixel_regions_process (iter)) { gint i, j; gint texture_off_x, _texture_off_x, texture_off_y; + guchar *texture_row_data; /* calc origin of texture buffer */ texture_off_x = drawable_x + x + maskPR->x; @@ -1324,36 +1352,37 @@ src_data = srcPR->data; mask_data = maskPR->data; - w = maskPR->w; - h = maskPR->h; + width = maskPR->w; + height = maskPR->h; src_stride = srcPR->rowstride; mask_stride = maskPR->rowstride; - for (i = 0; i < h; i++, texture_off_y++) + for (i = 0; i < height; i++, texture_off_y++) { _src_data = src_data; _mask_data = mask_data; - texture_off_y = texture_off_y % texture_buf->height; + texture_off_y = texture_off_y % texture_height; _texture_off_x = texture_off_x; + texture_row_data = texture_data + texture_off_y * texture_stride; - for (j = 0; j < w; j++, _texture_off_x++) + for (j = 0; j < width; j++, _texture_off_x++) { gdouble op, mask_op, paint_color_op, canvas_color_op, src_op; gdouble texture_op; gdouble factor1, factor2; gdouble component; - _texture_off_x = _texture_off_x % texture_buf->width; + _texture_off_x = _texture_off_x % texture_width; - texture_op = *(texture_data + texture_off_y * texture_stride + _texture_off_x * texture_buf->bytes) / 255.0; + texture_op = *(texture_row_data + _texture_off_x * texture_bytes) / 255.0; texture_op = CLAMP (texture_op + grain, 0.0, 1.0); - if (_mask_data[0]) + if (_mask_data[0] && texture_op > 0.0) { mask_op = _mask_data[0] / 255.0; - if (has_alpha) + if (has_alpha && active_components[src_bytes - 1]) { src_op = _src_data[src_bytes - 1] / 255.0; --- gimp-2.4.3-/app/paint/gimpmixbrush.h Sat Jan 26 18:40:37 2008 +++ gimp-painter--2.4.3/app/paint/gimpmixbrush.h Fri Jan 25 16:00:59 2008 @@ -52,6 +52,7 @@ GimpDrawable *drawable; GimpPaintOptions *paint_options; TempBuf *mask; + PressureParams pr_texture_grain; PressureParams pr_main_density; PressureParams pr_main_rate; PressureParams pr_canvas_density; --- gimp-2.4.3-/app/paint/gimpmixbrushoptions.c Sat Jan 26 18:40:37 2008 +++ gimp-painter--2.4.3/app/paint/gimpmixbrushoptions.c Fri Jan 25 19:25:01 2008 @@ -58,6 +58,11 @@ PROP_0, PROP_USE_TEXTURE, PROP_TEXTURE_GRAIN, + PROP_TEXTURE_GRAIN_PRESSURE_IN1, + PROP_TEXTURE_GRAIN_PRESSURE_IN2, + PROP_TEXTURE_GRAIN_PRESSURE_OUT1, + PROP_TEXTURE_GRAIN_PRESSURE_OUT2, + PROP_MAIN_COLOR_DENSITY, PROP_MAIN_COLOR_RATE, PROP_CANVAS_COLOR_DENSITY, @@ -127,6 +132,26 @@ -1.0, 1.0, MIXBRUSH_DEFAULT_TEXTURE_GRAIN, GIMP_PARAM_STATIC_STRINGS); + GIMP_CONFIG_INSTALL_PROP_DOUBLE (object_class, PROP_TEXTURE_GRAIN_PRESSURE_IN1, + "texture-grain-pressure-in1", NULL, + 0.0, 1.0, MIXBRUSH_DEFAULT_PRESSURE_IN1, + GIMP_PARAM_STATIC_STRINGS); + + GIMP_CONFIG_INSTALL_PROP_DOUBLE (object_class, PROP_TEXTURE_GRAIN_PRESSURE_IN2, + "texture-grain-pressure-in2", NULL, + 0.0, 1.0, MIXBRUSH_DEFAULT_PRESSURE_IN2, + GIMP_PARAM_STATIC_STRINGS); + + GIMP_CONFIG_INSTALL_PROP_DOUBLE (object_class, PROP_TEXTURE_GRAIN_PRESSURE_OUT1, + "texture-grain-pressure-out1", NULL, + 0.0, 1.0, MIXBRUSH_DEFAULT_PRESSURE_OUT1, + GIMP_PARAM_STATIC_STRINGS); + + GIMP_CONFIG_INSTALL_PROP_DOUBLE (object_class, PROP_TEXTURE_GRAIN_PRESSURE_OUT2, + "texture-grain-pressure-out2", NULL, + 0.0, 1.0, MIXBRUSH_DEFAULT_PRESSURE_OUT2, + GIMP_PARAM_STATIC_STRINGS); + GIMP_CONFIG_INSTALL_PROP_DOUBLE (object_class, PROP_MAIN_COLOR_DENSITY, "main-color-density", NULL, 0.0, 1.0, MIXBRUSH_DEFAULT_MAIN_COLOR_DENSITY, @@ -176,7 +201,7 @@ "main-color-pressure-out2", NULL, 0.0, 1.0, MIXBRUSH_DEFAULT_PRESSURE_OUT2, GIMP_PARAM_STATIC_STRINGS); - + GIMP_CONFIG_INSTALL_PROP_DOUBLE (object_class, PROP_CANVAS_COLOR_DENSITY, "canvas-color-density", NULL, 0.0, 1.0, MIXBRUSH_DEFAULT_CANVAS_COLOR_DENSITY, @@ -315,6 +340,18 @@ case PROP_TEXTURE_GRAIN: texture_options->grain = g_value_get_double (value); break; + case PROP_TEXTURE_GRAIN_PRESSURE_IN1: + texture_options->grain_pressure_in1 = g_value_get_double (value); + break; + case PROP_TEXTURE_GRAIN_PRESSURE_IN2: + texture_options->grain_pressure_in2 = g_value_get_double (value); + break; + case PROP_TEXTURE_GRAIN_PRESSURE_OUT1: + texture_options->grain_pressure_out1 = g_value_get_double (value); + break; + case PROP_TEXTURE_GRAIN_PRESSURE_OUT2: + texture_options->grain_pressure_out2 = g_value_get_double (value); + break; case PROP_MAIN_COLOR_DENSITY: options->main_color_density = g_value_get_double (value); break; @@ -427,6 +464,18 @@ break; case PROP_TEXTURE_GRAIN: g_value_set_double (value, texture_options->grain); + break; + case PROP_TEXTURE_GRAIN_PRESSURE_IN1: + g_value_set_double (value, texture_options->grain_pressure_in1); + break; + case PROP_TEXTURE_GRAIN_PRESSURE_IN2: + g_value_set_double (value, texture_options->grain_pressure_in2); + break; + case PROP_TEXTURE_GRAIN_PRESSURE_OUT1: + g_value_set_double (value, texture_options->grain_pressure_out1); + break; + case PROP_TEXTURE_GRAIN_PRESSURE_OUT2: + g_value_set_double (value, texture_options->grain_pressure_out2); break; case PROP_MAIN_COLOR_DENSITY: g_value_set_double (value, options->main_color_density); --- gimp-2.4.3-/app/paint/gimpmixbrushoptions.h Sat Jan 26 18:40:37 2008 +++ gimp-painter--2.4.3/app/paint/gimpmixbrushoptions.h Fri Jan 25 16:02:33 2008 @@ -52,6 +52,10 @@ { gboolean use_texture; gdouble grain; + gdouble grain_pressure_in1; + gdouble grain_pressure_in2; + gdouble grain_pressure_out1; + gdouble grain_pressure_out2; } GimpTextureOptions; struct _GimpMixbrushOptions --- gimp-2.4.3-/app/tools/gimpmixbrushtool.c Sat Jan 26 18:40:37 2008 +++ gimp-painter--2.4.3/app/tools/gimpmixbrushtool.c Fri Jan 25 19:25:09 2008 @@ -91,24 +91,57 @@ /* Texture configurations */ { - table = gtk_table_new (3, 3, FALSE); + table = gtk_table_new (3, 4, FALSE); gtk_table_set_col_spacings (GTK_TABLE (table), 2); mixbrush_frame = gimp_prop_expanding_frame_new (config, "use-texture", "Use texture", table, NULL); - gimp_prop_scale_entry_new (config, "texture-grain", - GTK_TABLE (table), 0, 1, - _("Grain:"), - 0.01, 0.1, 2, - FALSE, -1.0, 1.0); - mixbrush_box = gimp_prop_pattern_box_new (NULL, GIMP_CONTEXT (tool_options), 2, "pattern-view-type", "pattern-view-size"); - gtk_table_attach (GTK_TABLE (table), mixbrush_box, 0, 3, 2, 3, + gtk_table_attach (GTK_TABLE (table), mixbrush_box, 0, 3, 1, 2, GTK_EXPAND | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0); gtk_widget_show (mixbrush_box); + gimp_prop_scale_entry_new (config, "texture-grain", + GTK_TABLE (table), 0, 2, + _("Grain:"), + 0.01, 0.1, 2, + FALSE, -1.0, 1.0); + + { + GtkWidget *expander = gtk_expander_new (_("Pressure")); + GtkWidget *inner_table = gtk_table_new (3, 4, FALSE); + + gtk_container_add (GTK_CONTAINER (expander), inner_table); + gtk_table_attach (GTK_TABLE (table), expander, 0, 3, 3, 4, + GTK_EXPAND | GTK_FILL, GTK_SHRINK | GTK_FILL, + 0, 0); + + gimp_prop_scale_entry_new (config, "texture-grain-pressure-in1", + GTK_TABLE (inner_table), 0, 0, + _("In1:"), + 0.01, 0.1, 2, + FALSE, 0.0, 1.0); + gimp_prop_scale_entry_new (config, "texture-grain-pressure-in2", + GTK_TABLE (inner_table), 0, 1, + _("In2:"), + 0.01, 0.1, 2, + FALSE, 0.0, 1.0); + gimp_prop_scale_entry_new (config, "texture-grain-pressure-out1", + GTK_TABLE (inner_table), 0, 2, + _("Out1:"), + 0.01, 0.1, 2, + FALSE, 0.0, 1.0); + gimp_prop_scale_entry_new (config, "texture-grain-pressure-out2", + GTK_TABLE (inner_table), 0, 3, + _("Out2:"), + 0.01, 0.1, 2, + FALSE, 0.0, 1.0); + + gtk_widget_show_all (expander); + } + gtk_box_pack_start (GTK_BOX (vbox), mixbrush_frame, FALSE, FALSE, 0); gtk_widget_show (mixbrush_frame); } @@ -145,12 +178,12 @@ { GtkWidget *expander = gtk_expander_new (_("Pressure")); GtkWidget *inner_table = gtk_table_new (3, 4, FALSE); - + gtk_container_add (GTK_CONTAINER (expander), inner_table); gtk_table_attach (GTK_TABLE (table), expander, 0, 3, 2, 3, GTK_EXPAND | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0); - + gimp_prop_scale_entry_new (config, "main-color-density-pressure-in1", GTK_TABLE (inner_table), 0, 0, _("In1:"), @@ -184,12 +217,12 @@ { GtkWidget *expander = gtk_expander_new (_("Pressure")); GtkWidget *inner_table = gtk_table_new (3, 4, FALSE); - + gtk_container_add (GTK_CONTAINER (expander), inner_table); gtk_table_attach (GTK_TABLE (table), expander, 0, 3, 4, 5, GTK_EXPAND | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0); - + gimp_prop_scale_entry_new (config, "main-color-pressure-in1", GTK_TABLE (inner_table), 0, 0, _("In1:"), @@ -232,7 +265,7 @@ gtk_table_set_col_spacings (GTK_TABLE (table), 2); gtk_box_pack_start (GTK_BOX (mixbrush_vbox), table, TRUE, TRUE, 0); gtk_widget_show (table); - + gimp_prop_scale_entry_new (config, "canvas-color-density", GTK_TABLE (table), 0, 0, _("Density:"), @@ -242,12 +275,12 @@ { GtkWidget *expander = gtk_expander_new (_("Pressure")); GtkWidget *inner_table = gtk_table_new (3, 4, FALSE); - + gtk_container_add (GTK_CONTAINER (expander), inner_table); gtk_table_attach (GTK_TABLE (table), expander, 0, 3, 1, 2, GTK_EXPAND | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0); - + gimp_prop_scale_entry_new (config, "canvas-color-density-pressure-in1", GTK_TABLE (inner_table), 0, 0, _("In1:"), @@ -281,12 +314,12 @@ { GtkWidget *expander = gtk_expander_new (_("Pressure")); GtkWidget *inner_table = gtk_table_new (3, 4, FALSE); - + gtk_container_add (GTK_CONTAINER (expander), inner_table); gtk_table_attach (GTK_TABLE (table), expander, 0, 3, 3, 4, GTK_EXPAND | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0); - + gimp_prop_scale_entry_new (config, "canvas-color-pressure-in1", GTK_TABLE (inner_table), 0, 0, _("In1:"),