[gimp/wip/alxsa/mypaint-brush-v2] Further consolidation
- From: Alx Sa <sawyeralex src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp/wip/alxsa/mypaint-brush-v2] Further consolidation
- Date: Mon, 10 Oct 2022 10:47:17 +0000 (UTC)
commit 1d99721ff84afe343f8da8f5a06e3e2dd774e7e1
Author: Alx Sa <cmyk student gmail com>
Date: Mon Oct 10 10:47:16 2022 +0000
Further consolidation
app/paint/gimpmybrushcore.c | 20 ++++++------
app/paint/gimpmybrushsurface.c | 70 ++++++++++++++++++++++++++++--------------
2 files changed, 57 insertions(+), 33 deletions(-)
---
diff --git a/app/paint/gimpmybrushcore.c b/app/paint/gimpmybrushcore.c
index 1c61c0bded..08249bd841 100644
--- a/app/paint/gimpmybrushcore.c
+++ b/app/paint/gimpmybrushcore.c
@@ -49,11 +49,11 @@
struct _GimpMybrushCorePrivate
{
- GimpMybrush *mybrush;
- GimpMybrushSurface2 *surface;
- GList *brushes;
- gboolean synthetic;
- gint64 last_time;
+ GimpMybrush *mybrush;
+ GimpMybrushSurface *surface;
+ GList *brushes;
+ gboolean synthetic;
+ gint64 last_time;
};
@@ -221,11 +221,11 @@ gimp_mybrush_core_paint (GimpPaintCore *paint_core,
gimp_item_get_offset (drawables->data, &offset_x, &offset_y);
mybrush->private->surface =
- gimp_mypaint_surface2_new (gimp_drawable_get_buffer (drawables->data),
- gimp_drawable_get_active_mask (drawables->data),
- paint_core->mask_buffer,
- -offset_x, -offset_y,
- GIMP_MYBRUSH_OPTIONS (paint_options));
+ gimp_mypaint_surface_new (gimp_drawable_get_buffer (drawables->data),
+ gimp_drawable_get_active_mask (drawables->data),
+ paint_core->mask_buffer,
+ -offset_x, -offset_y,
+ GIMP_MYBRUSH_OPTIONS (paint_options));
gimp_mybrush_core_create_brushes (mybrush, drawables->data, paint_options, sym);
diff --git a/app/paint/gimpmybrushsurface.c b/app/paint/gimpmybrushsurface.c
index 2a6c070a31..f2bd130717 100644
--- a/app/paint/gimpmybrushsurface.c
+++ b/app/paint/gimpmybrushsurface.c
@@ -83,7 +83,17 @@ spectral_to_rgb (float *spectral,
float *rgb_);
float
-spectral_blend_factor (float x);
+spectral_blend_factor (float x);
+
+void
+get_color_pixels_legacy (float *mask,
+ float *pixel,
+ float *sum_weight,
+ float *sum_r,
+ float *sum_g,
+ float *sum_b,
+ float *sum_a,
+ float pixel_weight);
void
get_color_pixels_accumulate (float *mask,
@@ -306,6 +316,23 @@ spectral_to_rgb (float *spectral,
}
/* -- Taken from brushmode.c -- */
+void
+get_color_pixels_legacy (float *mask,
+ float *pixel,
+ float *sum_weight,
+ float *sum_r,
+ float *sum_g,
+ float *sum_b,
+ float *sum_a,
+ float pixel_weight)
+{
+ *sum_r += pixel_weight * pixel[RED];
+ *sum_g += pixel_weight * pixel[GREEN];
+ *sum_b += pixel_weight * pixel[BLUE];
+ *sum_a += pixel_weight * pixel[ALPHA];
+ *sum_weight += pixel_weight;
+}
+
void
get_color_pixels_accumulate (float *mask,
float *pixel,
@@ -325,6 +352,14 @@ get_color_pixels_accumulate (float *mask,
float avg_rgb[3] = {*sum_r, *sum_g, *sum_b};
float spec_rgb[3] = {0};
+ /* V1 Brush Code */
+ if (paint < 0.0f)
+ {
+ get_color_pixels_legacy (mask, pixel, sum_weight,
+ sum_r, sum_g, sum_b, sum_a, pixel_weight);
+ return;
+ }
+
rgb_to_spectral (*sum_r, *sum_g, *sum_b, avg_spectral);
if (interval_counter == 0 || rand() < random_sample_threshold)
@@ -446,6 +481,7 @@ gimp_mypaint_surface_draw_dab_2 (MyPaintSurface2 *base_surface,
float posterize_num,
float paint)
{
+ /* Placeholder - eventually implement here */
GimpMybrushSurface *surface = (GimpMybrushSurface *) base_surface;
GeglBufferIterator *iter;
GeglRectangle dabRect;
@@ -779,28 +815,16 @@ gimp_mypaint_surface_get_color_2 (MyPaintSurface2 *base_surface,
if (mask)
pixel_weight *= *mask;
- /* Version 1 / Legacy Brushes */
- if (paint < 0.0f)
- {
- sum_r += pixel_weight * pixel[RED];
- sum_g += pixel_weight * pixel[GREEN];
- sum_b += pixel_weight * pixel[BLUE];
- sum_a += pixel_weight * pixel[ALPHA];
- sum_weight += pixel_weight;
- }
- /* Version 2 Brushes */
- else
- {
- #ifdef _OPENMP
- #pragma omp critical
- #endif
- get_color_pixels_accumulate (mask, pixel, &sum_weight,
- &sum_r, &sum_g, &sum_b, &sum_a, paint,
- pixel_weight, sample_interval,
- random_sample_rate, interval_counter);
-
- interval_counter = (interval_counter + 1) % sample_interval;
- }
+ #ifdef _OPENMP
+ #pragma omp critical
+ #endif
+ get_color_pixels_accumulate (mask, pixel, &sum_weight,
+ &sum_r, &sum_g, &sum_b, &sum_a, paint,
+ pixel_weight, sample_interval,
+ random_sample_rate, interval_counter);
+
+ interval_counter = (interval_counter + 1) % sample_interval;
+
pixel += 4;
if (mask)
mask += 1;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]