app: remove gimp_parallel_distribute(); use gegl_parallel_distribute()
The parallel_distribute() family of functions has been migrated to
GEGL. Remove the gimp_parallel_distribute() functions from
gimp-parallel, and replace all uses of these functions with the
corresponding gegl_parallel_distrubte() functions.
(cherry picked from commit 2736cee577
)
This commit is contained in:
@ -47,7 +47,6 @@ extern "C"
|
|||||||
|
|
||||||
#define GIMP_PARALLEL_MAX_THREADS 64
|
#define GIMP_PARALLEL_MAX_THREADS 64
|
||||||
#define GIMP_PARALLEL_RUN_ASYNC_MAX_THREADS 1
|
#define GIMP_PARALLEL_RUN_ASYNC_MAX_THREADS 1
|
||||||
#define GIMP_PARALLEL_DISTRIBUTE_MAX_THREADS GIMP_PARALLEL_MAX_THREADS
|
|
||||||
|
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
@ -68,25 +67,6 @@ typedef struct
|
|||||||
GimpAsync *current_async;
|
GimpAsync *current_async;
|
||||||
} GimpParallelRunAsyncThread;
|
} GimpParallelRunAsyncThread;
|
||||||
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
GimpParallelDistributeFunc func;
|
|
||||||
gint n;
|
|
||||||
gpointer user_data;
|
|
||||||
} GimpParallelDistributeTask;
|
|
||||||
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
GThread *thread;
|
|
||||||
GMutex mutex;
|
|
||||||
GCond cond;
|
|
||||||
|
|
||||||
gboolean quit;
|
|
||||||
|
|
||||||
GimpParallelDistributeTask *volatile task;
|
|
||||||
volatile gint i;
|
|
||||||
} GimpParallelDistributeThread;
|
|
||||||
|
|
||||||
|
|
||||||
/* local function prototypes */
|
/* local function prototypes */
|
||||||
|
|
||||||
@ -104,9 +84,6 @@ static gboolean gimp_parallel_run_async_execute_task (GimpPa
|
|||||||
static void gimp_parallel_run_async_abort_task (GimpParallelRunAsyncTask *task);
|
static void gimp_parallel_run_async_abort_task (GimpParallelRunAsyncTask *task);
|
||||||
static void gimp_parallel_run_async_cancel (GimpAsync *async);
|
static void gimp_parallel_run_async_cancel (GimpAsync *async);
|
||||||
|
|
||||||
static void gimp_parallel_distribute_set_n_threads (gint n_threads);
|
|
||||||
static gpointer gimp_parallel_distribute_thread_func (GimpParallelDistributeThread *thread);
|
|
||||||
|
|
||||||
|
|
||||||
/* local variables */
|
/* local variables */
|
||||||
|
|
||||||
@ -117,14 +94,6 @@ static GMutex gimp_parallel_run_async_mutex;
|
|||||||
static GCond gimp_parallel_run_async_cond;
|
static GCond gimp_parallel_run_async_cond;
|
||||||
static GQueue gimp_parallel_run_async_queue = G_QUEUE_INIT;
|
static GQueue gimp_parallel_run_async_queue = G_QUEUE_INIT;
|
||||||
|
|
||||||
static gint gimp_parallel_distribute_n_threads = 1;
|
|
||||||
static GimpParallelDistributeThread gimp_parallel_distribute_threads[GIMP_PARALLEL_DISTRIBUTE_MAX_THREADS - 1];
|
|
||||||
|
|
||||||
static GMutex gimp_parallel_distribute_completion_mutex;
|
|
||||||
static GCond gimp_parallel_distribute_completion_cond;
|
|
||||||
static volatile gint gimp_parallel_distribute_completion_counter;
|
|
||||||
static volatile gint gimp_parallel_distribute_busy;
|
|
||||||
|
|
||||||
|
|
||||||
/* public functions */
|
/* public functions */
|
||||||
|
|
||||||
@ -257,154 +226,6 @@ gimp_parallel_run_async_independent (GimpParallelRunAsyncFunc func,
|
|||||||
return async;
|
return async;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
gimp_parallel_distribute (gint max_n,
|
|
||||||
GimpParallelDistributeFunc func,
|
|
||||||
gpointer user_data)
|
|
||||||
{
|
|
||||||
GimpParallelDistributeTask task;
|
|
||||||
gint i;
|
|
||||||
|
|
||||||
g_return_if_fail (func != NULL);
|
|
||||||
|
|
||||||
if (max_n == 0)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (max_n < 0)
|
|
||||||
max_n = gimp_parallel_distribute_n_threads;
|
|
||||||
else
|
|
||||||
max_n = MIN (max_n, gimp_parallel_distribute_n_threads);
|
|
||||||
|
|
||||||
if (max_n == 1 ||
|
|
||||||
! g_atomic_int_compare_and_exchange (&gimp_parallel_distribute_busy,
|
|
||||||
0, 1))
|
|
||||||
{
|
|
||||||
func (0, 1, user_data);
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
task.n = max_n;
|
|
||||||
task.func = func;
|
|
||||||
task.user_data = user_data;
|
|
||||||
|
|
||||||
g_atomic_int_set (&gimp_parallel_distribute_completion_counter, task.n - 1);
|
|
||||||
|
|
||||||
for (i = 0; i < task.n - 1; i++)
|
|
||||||
{
|
|
||||||
GimpParallelDistributeThread *thread =
|
|
||||||
&gimp_parallel_distribute_threads[i];
|
|
||||||
|
|
||||||
g_mutex_lock (&thread->mutex);
|
|
||||||
|
|
||||||
thread->task = &task;
|
|
||||||
thread->i = i;
|
|
||||||
|
|
||||||
g_cond_signal (&thread->cond);
|
|
||||||
|
|
||||||
g_mutex_unlock (&thread->mutex);
|
|
||||||
}
|
|
||||||
|
|
||||||
func (i, task.n, user_data);
|
|
||||||
|
|
||||||
if (g_atomic_int_get (&gimp_parallel_distribute_completion_counter))
|
|
||||||
{
|
|
||||||
g_mutex_lock (&gimp_parallel_distribute_completion_mutex);
|
|
||||||
|
|
||||||
while (g_atomic_int_get (&gimp_parallel_distribute_completion_counter))
|
|
||||||
{
|
|
||||||
g_cond_wait (&gimp_parallel_distribute_completion_cond,
|
|
||||||
&gimp_parallel_distribute_completion_mutex);
|
|
||||||
}
|
|
||||||
|
|
||||||
g_mutex_unlock (&gimp_parallel_distribute_completion_mutex);
|
|
||||||
}
|
|
||||||
|
|
||||||
g_atomic_int_set (&gimp_parallel_distribute_busy, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
gimp_parallel_distribute_range (gsize size,
|
|
||||||
gsize min_sub_size,
|
|
||||||
GimpParallelDistributeRangeFunc func,
|
|
||||||
gpointer user_data)
|
|
||||||
{
|
|
||||||
gsize n = size;
|
|
||||||
|
|
||||||
g_return_if_fail (func != NULL);
|
|
||||||
|
|
||||||
if (size == 0)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (min_sub_size > 1)
|
|
||||||
n /= min_sub_size;
|
|
||||||
|
|
||||||
n = CLAMP (n, 1, gimp_parallel_distribute_n_threads);
|
|
||||||
|
|
||||||
gimp_parallel_distribute (n, [=] (gint i, gint n)
|
|
||||||
{
|
|
||||||
gsize offset;
|
|
||||||
gsize sub_size;
|
|
||||||
|
|
||||||
offset = (2 * i * size + n) / (2 * n);
|
|
||||||
sub_size = (2 * (i + 1) * size + n) / (2 * n) - offset;
|
|
||||||
|
|
||||||
func (offset, sub_size, user_data);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
gimp_parallel_distribute_area (const GeglRectangle *area,
|
|
||||||
gsize min_sub_area,
|
|
||||||
GimpParallelDistributeAreaFunc func,
|
|
||||||
gpointer user_data)
|
|
||||||
{
|
|
||||||
gsize n;
|
|
||||||
|
|
||||||
g_return_if_fail (area != NULL);
|
|
||||||
g_return_if_fail (func != NULL);
|
|
||||||
|
|
||||||
if (area->width <= 0 || area->height <= 0)
|
|
||||||
return;
|
|
||||||
|
|
||||||
n = (gsize) area->width * (gsize) area->height;
|
|
||||||
|
|
||||||
if (min_sub_area > 1)
|
|
||||||
n /= min_sub_area;
|
|
||||||
|
|
||||||
n = CLAMP (n, 1, gimp_parallel_distribute_n_threads);
|
|
||||||
|
|
||||||
gimp_parallel_distribute (n, [=] (gint i, gint n)
|
|
||||||
{
|
|
||||||
GeglRectangle sub_area;
|
|
||||||
|
|
||||||
if (area->width <= area->height)
|
|
||||||
{
|
|
||||||
sub_area.x = area->x;
|
|
||||||
sub_area.width = area->width;
|
|
||||||
|
|
||||||
sub_area.y = (2 * i * area->height + n) / (2 * n);
|
|
||||||
sub_area.height = (2 * (i + 1) * area->height + n) / (2 * n);
|
|
||||||
|
|
||||||
sub_area.height -= sub_area.y;
|
|
||||||
sub_area.y += area->y;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
sub_area.y = area->y;
|
|
||||||
sub_area.height = area->height;
|
|
||||||
|
|
||||||
sub_area.x = (2 * i * area->width + n) / (2 * n);
|
|
||||||
sub_area.width = (2 * (i + 1) * area->width + n) / (2 * n);
|
|
||||||
|
|
||||||
sub_area.width -= sub_area.x;
|
|
||||||
sub_area.x += area->x;
|
|
||||||
}
|
|
||||||
|
|
||||||
func (&sub_area, user_data);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* private functions */
|
/* private functions */
|
||||||
|
|
||||||
@ -421,7 +242,6 @@ gimp_parallel_set_n_threads (gint n_threads,
|
|||||||
gboolean finish_tasks)
|
gboolean finish_tasks)
|
||||||
{
|
{
|
||||||
gimp_parallel_run_async_set_n_threads (n_threads, finish_tasks);
|
gimp_parallel_run_async_set_n_threads (n_threads, finish_tasks);
|
||||||
gimp_parallel_distribute_set_n_threads (n_threads);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -678,96 +498,4 @@ gimp_parallel_run_async_cancel (GimpAsync *async)
|
|||||||
gimp_parallel_run_async_abort_task (task);
|
gimp_parallel_run_async_abort_task (task);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
gimp_parallel_distribute_set_n_threads (gint n_threads)
|
|
||||||
{
|
|
||||||
gint i;
|
|
||||||
|
|
||||||
while (! g_atomic_int_compare_and_exchange (&gimp_parallel_distribute_busy,
|
|
||||||
0, 1));
|
|
||||||
|
|
||||||
n_threads = CLAMP (n_threads, 1, GIMP_PARALLEL_DISTRIBUTE_MAX_THREADS);
|
|
||||||
|
|
||||||
if (n_threads > gimp_parallel_distribute_n_threads) /* need more threads */
|
|
||||||
{
|
|
||||||
for (i = gimp_parallel_distribute_n_threads - 1; i < n_threads - 1; i++)
|
|
||||||
{
|
|
||||||
GimpParallelDistributeThread *thread =
|
|
||||||
&gimp_parallel_distribute_threads[i];
|
|
||||||
|
|
||||||
thread->quit = FALSE;
|
|
||||||
thread->task = NULL;
|
|
||||||
|
|
||||||
thread->thread = g_thread_new (
|
|
||||||
"worker",
|
|
||||||
(GThreadFunc) gimp_parallel_distribute_thread_func,
|
|
||||||
thread);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (n_threads < gimp_parallel_distribute_n_threads) /* need less threads */
|
|
||||||
{
|
|
||||||
for (i = n_threads - 1; i < gimp_parallel_distribute_n_threads - 1; i++)
|
|
||||||
{
|
|
||||||
GimpParallelDistributeThread *thread =
|
|
||||||
&gimp_parallel_distribute_threads[i];
|
|
||||||
|
|
||||||
g_mutex_lock (&thread->mutex);
|
|
||||||
|
|
||||||
thread->quit = TRUE;
|
|
||||||
g_cond_signal (&thread->cond);
|
|
||||||
|
|
||||||
g_mutex_unlock (&thread->mutex);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (i = n_threads - 1; i < gimp_parallel_distribute_n_threads - 1; i++)
|
|
||||||
{
|
|
||||||
GimpParallelDistributeThread *thread =
|
|
||||||
&gimp_parallel_distribute_threads[i];
|
|
||||||
|
|
||||||
g_thread_join (thread->thread);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
gimp_parallel_distribute_n_threads = n_threads;
|
|
||||||
|
|
||||||
g_atomic_int_set (&gimp_parallel_distribute_busy, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
static gpointer
|
|
||||||
gimp_parallel_distribute_thread_func (GimpParallelDistributeThread *thread)
|
|
||||||
{
|
|
||||||
g_mutex_lock (&thread->mutex);
|
|
||||||
|
|
||||||
while (TRUE)
|
|
||||||
{
|
|
||||||
if (thread->quit)
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
else if (thread->task)
|
|
||||||
{
|
|
||||||
thread->task->func (thread->i, thread->task->n,
|
|
||||||
thread->task->user_data);
|
|
||||||
|
|
||||||
if (g_atomic_int_dec_and_test (
|
|
||||||
&gimp_parallel_distribute_completion_counter))
|
|
||||||
{
|
|
||||||
g_mutex_lock (&gimp_parallel_distribute_completion_mutex);
|
|
||||||
|
|
||||||
g_cond_signal (&gimp_parallel_distribute_completion_cond);
|
|
||||||
|
|
||||||
g_mutex_unlock (&gimp_parallel_distribute_completion_mutex);
|
|
||||||
}
|
|
||||||
|
|
||||||
thread->task = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
g_cond_wait (&thread->cond, &thread->mutex);
|
|
||||||
}
|
|
||||||
|
|
||||||
g_mutex_unlock (&thread->mutex);
|
|
||||||
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
} /* extern "C" */
|
} /* extern "C" */
|
||||||
|
@ -47,17 +47,6 @@ GimpAsync * gimp_parallel_run_async_full (gint
|
|||||||
GimpAsync * gimp_parallel_run_async_independent (GimpParallelRunAsyncFunc func,
|
GimpAsync * gimp_parallel_run_async_independent (GimpParallelRunAsyncFunc func,
|
||||||
gpointer user_data);
|
gpointer user_data);
|
||||||
|
|
||||||
void gimp_parallel_distribute (gint max_n,
|
|
||||||
GimpParallelDistributeFunc func,
|
|
||||||
gpointer user_data);
|
|
||||||
void gimp_parallel_distribute_range (gsize size,
|
|
||||||
gsize min_sub_size,
|
|
||||||
GimpParallelDistributeRangeFunc func,
|
|
||||||
gpointer user_data);
|
|
||||||
void gimp_parallel_distribute_area (const GeglRectangle *area,
|
|
||||||
gsize min_sub_area,
|
|
||||||
GimpParallelDistributeAreaFunc func,
|
|
||||||
gpointer user_data);
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
||||||
@ -161,61 +150,6 @@ gimp_parallel_run_async_independent (ParallelRunAsyncFunc func)
|
|||||||
func_copy);
|
func_copy);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class ParallelDistributeFunc>
|
|
||||||
inline void
|
|
||||||
gimp_parallel_distribute (gint max_n,
|
|
||||||
ParallelDistributeFunc func)
|
|
||||||
{
|
|
||||||
gimp_parallel_distribute (max_n,
|
|
||||||
[] (gint i,
|
|
||||||
gint n,
|
|
||||||
gpointer user_data)
|
|
||||||
{
|
|
||||||
ParallelDistributeFunc func_copy (
|
|
||||||
*(const ParallelDistributeFunc *) user_data);
|
|
||||||
|
|
||||||
func_copy (i, n);
|
|
||||||
},
|
|
||||||
&func);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class ParallelDistributeRangeFunc>
|
|
||||||
inline void
|
|
||||||
gimp_parallel_distribute_range (gsize size,
|
|
||||||
gsize min_sub_size,
|
|
||||||
ParallelDistributeRangeFunc func)
|
|
||||||
{
|
|
||||||
gimp_parallel_distribute_range (size, min_sub_size,
|
|
||||||
[] (gsize offset,
|
|
||||||
gsize size,
|
|
||||||
gpointer user_data)
|
|
||||||
{
|
|
||||||
ParallelDistributeRangeFunc func_copy (
|
|
||||||
*(const ParallelDistributeRangeFunc *) user_data);
|
|
||||||
|
|
||||||
func_copy (offset, size);
|
|
||||||
},
|
|
||||||
&func);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class ParallelDistributeAreaFunc>
|
|
||||||
inline void
|
|
||||||
gimp_parallel_distribute_area (const GeglRectangle *area,
|
|
||||||
gsize min_sub_area,
|
|
||||||
ParallelDistributeAreaFunc func)
|
|
||||||
{
|
|
||||||
gimp_parallel_distribute_area (area, min_sub_area,
|
|
||||||
[] (const GeglRectangle *area,
|
|
||||||
gpointer user_data)
|
|
||||||
{
|
|
||||||
ParallelDistributeAreaFunc func_copy (
|
|
||||||
*(const ParallelDistributeAreaFunc *) user_data);
|
|
||||||
|
|
||||||
func_copy (area);
|
|
||||||
},
|
|
||||||
&func);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* __cplusplus */
|
#endif /* __cplusplus */
|
||||||
|
@ -33,14 +33,13 @@ extern "C"
|
|||||||
|
|
||||||
#include "gegl/gimp-gegl-loops.h"
|
#include "gegl/gimp-gegl-loops.h"
|
||||||
|
|
||||||
#include "gimp-parallel.h"
|
|
||||||
#include "gimpbrush.h"
|
#include "gimpbrush.h"
|
||||||
#include "gimpbrush-transform.h"
|
#include "gimpbrush-transform.h"
|
||||||
#include "gimptempbuf.h"
|
#include "gimptempbuf.h"
|
||||||
|
|
||||||
|
|
||||||
#define MIN_PARALLEL_SUB_SIZE 64
|
#define PIXELS_PER_THREAD \
|
||||||
#define MIN_PARALLEL_SUB_AREA (MIN_PARALLEL_SUB_SIZE * MIN_PARALLEL_SUB_SIZE)
|
(/* each thread costs as much as */ 64.0 * 64.0 /* pixels */)
|
||||||
|
|
||||||
|
|
||||||
/* local function prototypes */
|
/* local function prototypes */
|
||||||
@ -256,8 +255,8 @@ gimp_brush_real_transform_mask (GimpBrush *brush,
|
|||||||
src_walk_vx_i = (gint) ((src_tl_to_bl_delta_x / dest_height) * int_multiple);
|
src_walk_vx_i = (gint) ((src_tl_to_bl_delta_x / dest_height) * int_multiple);
|
||||||
src_walk_vy_i = (gint) ((src_tl_to_bl_delta_y / dest_height) * int_multiple);
|
src_walk_vy_i = (gint) ((src_tl_to_bl_delta_y / dest_height) * int_multiple);
|
||||||
|
|
||||||
gimp_parallel_distribute_area (GEGL_RECTANGLE (0, 0, dest_width, dest_height),
|
gegl_parallel_distribute_area (
|
||||||
MIN_PARALLEL_SUB_AREA,
|
GEGL_RECTANGLE (0, 0, dest_width, dest_height), PIXELS_PER_THREAD,
|
||||||
[=] (const GeglRectangle *area)
|
[=] (const GeglRectangle *area)
|
||||||
{
|
{
|
||||||
guchar *dest;
|
guchar *dest;
|
||||||
@ -556,8 +555,8 @@ gimp_brush_real_transform_pixmap (GimpBrush *brush,
|
|||||||
src_walk_vx_i = (gint) ((src_tl_to_bl_delta_x / dest_height) * int_multiple);
|
src_walk_vx_i = (gint) ((src_tl_to_bl_delta_x / dest_height) * int_multiple);
|
||||||
src_walk_vy_i = (gint) ((src_tl_to_bl_delta_y / dest_height) * int_multiple);
|
src_walk_vy_i = (gint) ((src_tl_to_bl_delta_y / dest_height) * int_multiple);
|
||||||
|
|
||||||
gimp_parallel_distribute_area (GEGL_RECTANGLE (0, 0, dest_width, dest_height),
|
gegl_parallel_distribute_area (
|
||||||
MIN_PARALLEL_SUB_AREA,
|
GEGL_RECTANGLE (0, 0, dest_width, dest_height), PIXELS_PER_THREAD,
|
||||||
[=] (const GeglRectangle *area)
|
[=] (const GeglRectangle *area)
|
||||||
{
|
{
|
||||||
guchar *dest;
|
guchar *dest;
|
||||||
@ -808,7 +807,8 @@ gimp_brush_transform_blur (GimpTempBuf *buf,
|
|||||||
|
|
||||||
sums = g_new (Sums, width * height * components);
|
sums = g_new (Sums, width * height * components);
|
||||||
|
|
||||||
gimp_parallel_distribute_range (height, MIN_PARALLEL_SUB_SIZE,
|
gegl_parallel_distribute_range (
|
||||||
|
height, PIXELS_PER_THREAD / width,
|
||||||
[=] (gint y0, gint height)
|
[=] (gint y0, gint height)
|
||||||
{
|
{
|
||||||
gint x;
|
gint x;
|
||||||
@ -885,7 +885,8 @@ gimp_brush_transform_blur (GimpTempBuf *buf,
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
gimp_parallel_distribute_range (width, MIN_PARALLEL_SUB_SIZE,
|
gegl_parallel_distribute_range (
|
||||||
|
width, PIXELS_PER_THREAD / height,
|
||||||
[=] (gint x0, gint width)
|
[=] (gint x0, gint width)
|
||||||
{
|
{
|
||||||
gint x;
|
gint x;
|
||||||
|
@ -41,8 +41,8 @@
|
|||||||
#include "gimpwaitable.h"
|
#include "gimpwaitable.h"
|
||||||
|
|
||||||
|
|
||||||
#define MIN_PARALLEL_SUB_SIZE 64
|
#define PIXELS_PER_THREAD \
|
||||||
#define MIN_PARALLEL_SUB_AREA (MIN_PARALLEL_SUB_SIZE * MIN_PARALLEL_SUB_SIZE)
|
(/* each thread costs as much as */ 64.0 * 64.0 /* pixels */)
|
||||||
|
|
||||||
|
|
||||||
enum
|
enum
|
||||||
@ -946,8 +946,8 @@ gimp_histogram_calculate_internal (GimpAsync *async,
|
|||||||
data.format = format;
|
data.format = format;
|
||||||
data.values_list = NULL;
|
data.values_list = NULL;
|
||||||
|
|
||||||
gimp_parallel_distribute_area (
|
gegl_parallel_distribute_area (
|
||||||
&context->buffer_rect, MIN_PARALLEL_SUB_AREA,
|
&context->buffer_rect, PIXELS_PER_THREAD, GEGL_SPLIT_STRATEGY_AUTO,
|
||||||
(GimpParallelDistributeAreaFunc) gimp_histogram_calculate_area,
|
(GimpParallelDistributeAreaFunc) gimp_histogram_calculate_area,
|
||||||
&data);
|
&data);
|
||||||
|
|
||||||
|
@ -41,13 +41,12 @@ extern "C"
|
|||||||
#include "gimp-gegl-loops-sse2.h"
|
#include "gimp-gegl-loops-sse2.h"
|
||||||
|
|
||||||
#include "core/gimp-atomic.h"
|
#include "core/gimp-atomic.h"
|
||||||
#include "core/gimp-parallel.h"
|
|
||||||
#include "core/gimp-utils.h"
|
#include "core/gimp-utils.h"
|
||||||
#include "core/gimpprogress.h"
|
#include "core/gimpprogress.h"
|
||||||
|
|
||||||
|
|
||||||
#define MIN_PARALLEL_SUB_SIZE 64
|
#define PIXELS_PER_THREAD \
|
||||||
#define MIN_PARALLEL_SUB_AREA (MIN_PARALLEL_SUB_SIZE * MIN_PARALLEL_SUB_SIZE)
|
(/* each thread costs as much as */ 64.0 * 64.0 /* pixels */)
|
||||||
|
|
||||||
#define SHIFTED_AREA(dest, src) \
|
#define SHIFTED_AREA(dest, src) \
|
||||||
const GeglRectangle dest##_area_ = { \
|
const GeglRectangle dest##_area_ = { \
|
||||||
@ -82,7 +81,8 @@ gimp_gegl_buffer_copy (GeglBuffer *src_buffer,
|
|||||||
if (! dest_rect)
|
if (! dest_rect)
|
||||||
dest_rect = src_rect;
|
dest_rect = src_rect;
|
||||||
|
|
||||||
gimp_parallel_distribute_area (src_rect, MIN_PARALLEL_SUB_AREA,
|
gegl_parallel_distribute_area (
|
||||||
|
src_rect, PIXELS_PER_THREAD,
|
||||||
[=] (const GeglRectangle *src_area)
|
[=] (const GeglRectangle *src_area)
|
||||||
{
|
{
|
||||||
SHIFTED_AREA (dest, src);
|
SHIFTED_AREA (dest, src);
|
||||||
@ -161,7 +161,8 @@ gimp_gegl_convolve (GeglBuffer *src_buffer,
|
|||||||
offset = 0.0;
|
offset = 0.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
gimp_parallel_distribute_area (dest_rect, MIN_PARALLEL_SUB_AREA,
|
gegl_parallel_distribute_area (
|
||||||
|
dest_rect, PIXELS_PER_THREAD,
|
||||||
[=] (const GeglRectangle *dest_area)
|
[=] (const GeglRectangle *dest_area)
|
||||||
{
|
{
|
||||||
const gint components = src_components;
|
const gint components = src_components;
|
||||||
@ -313,7 +314,8 @@ gimp_gegl_dodgeburn (GeglBuffer *src_buffer,
|
|||||||
if (! dest_rect)
|
if (! dest_rect)
|
||||||
dest_rect = gegl_buffer_get_extent (dest_buffer);
|
dest_rect = gegl_buffer_get_extent (dest_buffer);
|
||||||
|
|
||||||
gimp_parallel_distribute_area (src_rect, MIN_PARALLEL_SUB_AREA,
|
gegl_parallel_distribute_area (
|
||||||
|
src_rect, PIXELS_PER_THREAD,
|
||||||
[=] (const GeglRectangle *src_area)
|
[=] (const GeglRectangle *src_area)
|
||||||
{
|
{
|
||||||
GeglBufferIterator *iter;
|
GeglBufferIterator *iter;
|
||||||
@ -548,7 +550,8 @@ gimp_gegl_smudge_with_paint (GeglBuffer *accum_buffer,
|
|||||||
brush_a *= brush_color_ptr[3];
|
brush_a *= brush_color_ptr[3];
|
||||||
}
|
}
|
||||||
|
|
||||||
gimp_parallel_distribute_area (accum_rect, MIN_PARALLEL_SUB_AREA,
|
gegl_parallel_distribute_area (
|
||||||
|
accum_rect, PIXELS_PER_THREAD,
|
||||||
[=] (const GeglRectangle *accum_area)
|
[=] (const GeglRectangle *accum_area)
|
||||||
{
|
{
|
||||||
GeglBufferIterator *iter;
|
GeglBufferIterator *iter;
|
||||||
@ -616,7 +619,8 @@ gimp_gegl_apply_mask (GeglBuffer *mask_buffer,
|
|||||||
if (! dest_rect)
|
if (! dest_rect)
|
||||||
dest_rect = gegl_buffer_get_extent (dest_buffer);
|
dest_rect = gegl_buffer_get_extent (dest_buffer);
|
||||||
|
|
||||||
gimp_parallel_distribute_area (mask_rect, MIN_PARALLEL_SUB_AREA,
|
gegl_parallel_distribute_area (
|
||||||
|
mask_rect, PIXELS_PER_THREAD,
|
||||||
[=] (const GeglRectangle *mask_area)
|
[=] (const GeglRectangle *mask_area)
|
||||||
{
|
{
|
||||||
GeglBufferIterator *iter;
|
GeglBufferIterator *iter;
|
||||||
@ -661,7 +665,8 @@ gimp_gegl_combine_mask (GeglBuffer *mask_buffer,
|
|||||||
if (! dest_rect)
|
if (! dest_rect)
|
||||||
dest_rect = gegl_buffer_get_extent (dest_buffer);
|
dest_rect = gegl_buffer_get_extent (dest_buffer);
|
||||||
|
|
||||||
gimp_parallel_distribute_area (mask_rect, MIN_PARALLEL_SUB_AREA,
|
gegl_parallel_distribute_area (
|
||||||
|
mask_rect, PIXELS_PER_THREAD,
|
||||||
[=] (const GeglRectangle *mask_area)
|
[=] (const GeglRectangle *mask_area)
|
||||||
{
|
{
|
||||||
GeglBufferIterator *iter;
|
GeglBufferIterator *iter;
|
||||||
@ -707,7 +712,8 @@ gimp_gegl_combine_mask_weird (GeglBuffer *mask_buffer,
|
|||||||
if (! dest_rect)
|
if (! dest_rect)
|
||||||
dest_rect = gegl_buffer_get_extent (dest_buffer);
|
dest_rect = gegl_buffer_get_extent (dest_buffer);
|
||||||
|
|
||||||
gimp_parallel_distribute_area (mask_rect, MIN_PARALLEL_SUB_AREA,
|
gegl_parallel_distribute_area (
|
||||||
|
mask_rect, PIXELS_PER_THREAD,
|
||||||
[=] (const GeglRectangle *mask_area)
|
[=] (const GeglRectangle *mask_area)
|
||||||
{
|
{
|
||||||
GeglBufferIterator *iter;
|
GeglBufferIterator *iter;
|
||||||
@ -777,7 +783,8 @@ gimp_gegl_replace (GeglBuffer *top_buffer,
|
|||||||
if (! dest_rect)
|
if (! dest_rect)
|
||||||
dest_rect = gegl_buffer_get_extent (dest_buffer);
|
dest_rect = gegl_buffer_get_extent (dest_buffer);
|
||||||
|
|
||||||
gimp_parallel_distribute_area (top_rect, MIN_PARALLEL_SUB_AREA,
|
gegl_parallel_distribute_area (
|
||||||
|
top_rect, PIXELS_PER_THREAD,
|
||||||
[=] (const GeglRectangle *top_area)
|
[=] (const GeglRectangle *top_area)
|
||||||
{
|
{
|
||||||
GeglBufferIterator *iter;
|
GeglBufferIterator *iter;
|
||||||
@ -893,7 +900,8 @@ gimp_gegl_index_to_mask (GeglBuffer *indexed_buffer,
|
|||||||
if (! mask_rect)
|
if (! mask_rect)
|
||||||
mask_rect = gegl_buffer_get_extent (mask_buffer);
|
mask_rect = gegl_buffer_get_extent (mask_buffer);
|
||||||
|
|
||||||
gimp_parallel_distribute_area (indexed_rect, MIN_PARALLEL_SUB_AREA,
|
gegl_parallel_distribute_area (
|
||||||
|
indexed_rect, PIXELS_PER_THREAD,
|
||||||
[=] (const GeglRectangle *indexed_area)
|
[=] (const GeglRectangle *indexed_area)
|
||||||
{
|
{
|
||||||
GeglBufferIterator *iter;
|
GeglBufferIterator *iter;
|
||||||
@ -983,7 +991,8 @@ gimp_gegl_convert_color_profile (GeglBuffer *src_buffer,
|
|||||||
|
|
||||||
GIMP_TIMER_START ();
|
GIMP_TIMER_START ();
|
||||||
|
|
||||||
gimp_parallel_distribute_area (src_rect, MIN_PARALLEL_SUB_AREA,
|
gegl_parallel_distribute_area (
|
||||||
|
src_rect, PIXELS_PER_THREAD,
|
||||||
[=] (const GeglRectangle *src_area)
|
[=] (const GeglRectangle *src_area)
|
||||||
{
|
{
|
||||||
SHIFTED_AREA (dest, src);
|
SHIFTED_AREA (dest, src);
|
||||||
@ -1042,7 +1051,8 @@ gimp_gegl_average_color (GeglBuffer *buffer,
|
|||||||
else
|
else
|
||||||
roi = *rect;
|
roi = *rect;
|
||||||
|
|
||||||
gimp_parallel_distribute_area (&roi, MIN_PARALLEL_SUB_AREA,
|
gegl_parallel_distribute_area (
|
||||||
|
&roi, PIXELS_PER_THREAD,
|
||||||
[&] (const GeglRectangle *area)
|
[&] (const GeglRectangle *area)
|
||||||
{
|
{
|
||||||
Sum *sum;
|
Sum *sum;
|
||||||
|
@ -29,7 +29,6 @@ extern "C"
|
|||||||
|
|
||||||
#include "paint-types.h"
|
#include "paint-types.h"
|
||||||
|
|
||||||
#include "core/gimp-parallel.h"
|
|
||||||
#include "core/gimptempbuf.h"
|
#include "core/gimptempbuf.h"
|
||||||
|
|
||||||
#include "gimpbrushcore.h"
|
#include "gimpbrushcore.h"
|
||||||
@ -37,8 +36,8 @@ extern "C"
|
|||||||
#include "gimpbrushcore-kernels.h"
|
#include "gimpbrushcore-kernels.h"
|
||||||
|
|
||||||
|
|
||||||
#define MIN_PARALLEL_SUB_SIZE 64
|
#define PIXELS_PER_THREAD \
|
||||||
#define MIN_PARALLEL_SUB_AREA (MIN_PARALLEL_SUB_SIZE * MIN_PARALLEL_SUB_SIZE)
|
(/* each thread costs as much as */ 64.0 * 64.0 /* pixels */)
|
||||||
|
|
||||||
|
|
||||||
static inline void
|
static inline void
|
||||||
@ -133,7 +132,8 @@ gimp_brush_core_subsample_mask (GimpBrushCore *core,
|
|||||||
|
|
||||||
core->subsample_brushes[index2][index1] = dest;
|
core->subsample_brushes[index2][index1] = dest;
|
||||||
|
|
||||||
gimp_parallel_distribute_range (mask_height, MIN_PARALLEL_SUB_SIZE,
|
gegl_parallel_distribute_range (
|
||||||
|
mask_height, PIXELS_PER_THREAD / mask_width,
|
||||||
[=] (gint y, gint height)
|
[=] (gint y, gint height)
|
||||||
{
|
{
|
||||||
const guchar *m;
|
const guchar *m;
|
||||||
@ -322,9 +322,10 @@ gimp_brush_core_pressurize_mask (GimpBrushCore *core,
|
|||||||
|
|
||||||
/* Now convert the brush */
|
/* Now convert the brush */
|
||||||
|
|
||||||
gimp_parallel_distribute_range (gimp_temp_buf_get_width (subsample_mask) *
|
gegl_parallel_distribute_range (
|
||||||
|
gimp_temp_buf_get_width (subsample_mask) *
|
||||||
gimp_temp_buf_get_height (subsample_mask),
|
gimp_temp_buf_get_height (subsample_mask),
|
||||||
MIN_PARALLEL_SUB_AREA,
|
PIXELS_PER_THREAD,
|
||||||
[=] (gint offset, gint size)
|
[=] (gint offset, gint size)
|
||||||
{
|
{
|
||||||
const guchar *source;
|
const guchar *source;
|
||||||
@ -396,11 +397,9 @@ gimp_brush_core_solidify_mask (GimpBrushCore *core,
|
|||||||
|
|
||||||
core->solid_brushes[dest_offset_y][dest_offset_x] = dest;
|
core->solid_brushes[dest_offset_y][dest_offset_x] = dest;
|
||||||
|
|
||||||
gimp_parallel_distribute_area (GEGL_RECTANGLE (0,
|
gegl_parallel_distribute_area (
|
||||||
0,
|
GEGL_RECTANGLE (0, 0, brush_mask_width, brush_mask_height),
|
||||||
brush_mask_width,
|
PIXELS_PER_THREAD,
|
||||||
brush_mask_height),
|
|
||||||
MIN_PARALLEL_SUB_AREA,
|
|
||||||
[=] (const GeglRectangle *area)
|
[=] (const GeglRectangle *area)
|
||||||
{
|
{
|
||||||
const guchar *m;
|
const guchar *m;
|
||||||
|
@ -27,7 +27,6 @@ extern "C"
|
|||||||
|
|
||||||
#include "operations/layer-modes/gimp-layer-modes.h"
|
#include "operations/layer-modes/gimp-layer-modes.h"
|
||||||
|
|
||||||
#include "core/gimp-parallel.h"
|
|
||||||
#include "core/gimptempbuf.h"
|
#include "core/gimptempbuf.h"
|
||||||
|
|
||||||
#include "operations/layer-modes/gimpoperationlayermode.h"
|
#include "operations/layer-modes/gimpoperationlayermode.h"
|
||||||
@ -37,8 +36,8 @@ extern "C"
|
|||||||
} /* extern "C" */
|
} /* extern "C" */
|
||||||
|
|
||||||
|
|
||||||
#define MIN_PARALLEL_SUB_SIZE 64
|
#define PIXELS_PER_THREAD \
|
||||||
#define MIN_PARALLEL_SUB_AREA (MIN_PARALLEL_SUB_SIZE * MIN_PARALLEL_SUB_SIZE)
|
(/* each thread costs as much as */ 64.0 * 64.0 /* pixels */)
|
||||||
|
|
||||||
|
|
||||||
/* In order to avoid iterating over the same region of the same buffers
|
/* In order to avoid iterating over the same region of the same buffers
|
||||||
@ -1131,7 +1130,8 @@ gimp_paint_core_loops_process (const GimpPaintCoreLoopsParams *params,
|
|||||||
|
|
||||||
Algorithm algorithm (params);
|
Algorithm algorithm (params);
|
||||||
|
|
||||||
gimp_parallel_distribute_area (&roi, MIN_PARALLEL_SUB_AREA,
|
gegl_parallel_distribute_area (
|
||||||
|
&roi, PIXELS_PER_THREAD,
|
||||||
[=] (const GeglRectangle *area)
|
[=] (const GeglRectangle *area)
|
||||||
{
|
{
|
||||||
State state;
|
State state;
|
||||||
@ -1347,7 +1347,8 @@ mask_components_onto (GeglBuffer *src_buffer,
|
|||||||
else
|
else
|
||||||
iterator_format = babl_format ("R'G'B'A float");
|
iterator_format = babl_format ("R'G'B'A float");
|
||||||
|
|
||||||
gimp_parallel_distribute_area (roi, MIN_PARALLEL_SUB_AREA,
|
gegl_parallel_distribute_area (
|
||||||
|
roi, PIXELS_PER_THREAD,
|
||||||
[=] (const GeglRectangle *area)
|
[=] (const GeglRectangle *area)
|
||||||
{
|
{
|
||||||
GeglBufferIterator *iter;
|
GeglBufferIterator *iter;
|
||||||
|
Reference in New Issue
Block a user