41 return fminf(fmaxf(
v, 0.0f), 1.0f);
45static inline float _lerpf(
const float a,
const float b,
const float t)
47 return a + (b - a) *
t;
53 return (
float)
splitmix32(cell_seed ^ salt) / (float)UINT32_MAX;
59 const int cell_x = (int)floorf(
x);
60 const int cell_y = (int)floorf(y);
62 float weight_sum = 0.0f;
64 for(
int oy = -1; oy <= 1; oy++)
66 for(
int ox = -1; ox <= 1; ox++)
68 const int ix = cell_x + ox;
69 const int iy = cell_y + oy;
71 ^ ((
uint64_t)(uint32_t)ix * 0x9e3779b185ebca87ull)
72 ^ ((
uint64_t)(uint32_t)iy * 0xc2b2ae3d27d4eb4full);
76 const float dx =
x - ((float)ix + jitter_x);
77 const float dy = y - ((float)iy + jitter_y);
78 const float dist2 = dx * dx + dy * dy;
80 const float grain = fmaxf(0.0f, 1.0f - dist2 / (radius * radius));
81 const float shaped = grain * grain * (3.0f - 2.0f * grain);
82 accum += grain_gain * shaped;
83 weight_sum += grain_gain;
87 return (weight_sum > 1e-6f) ?
_clamp01(accum / weight_sum) : 0.0f;
93 const float c = 1.0f -
_clamp01(coarseness);
96 const float t = c * 2.0f;
103 const float t = (c - 0.5f) * 2.0f;
112 const float scale,
const float strength,
113 const float w0,
const float w1,
const float w2,
117 const float x = px * scale;
118 const float y = py * scale;
120 const float g1 = (
w1 > 1e-6f) ?
_cellular_grain_2d(seed1,
x * 1.93f + 4.7f, y * 1.93f - 2.9f) : 0.0f;
121 const float g2 = (
w2 > 1e-6f) ?
_cellular_grain_2d(seed2,
x * 3.71f - 6.2f, y * 3.71f + 8.4f) : 0.0f;
122 const float field = w0 * g0 +
w1 * g1 +
w2 * g2;
123 const float centered = 2.0f * field - 1.0f;
124 return fmaxf(0.0f, 1.0f +
strength * centered);
142 const float center_x,
const float center_y,
173 float noise_sum = 0.0f;
175 for(
int sy = -2; sy <= 2; sy++)
177 for(
int sx = -2; sx <= 2; sx++)
179 const float nx = 0.4f * (float)sx;
180 const float ny = 0.4f * (float)sy;
181 if(nx * nx + ny * ny > 1.0f)
continue;
182 const int pixel_x = (int)lrintf(center_x + nx * radius);
183 const int pixel_y = (int)lrintf(center_y + ny * radius);
194 const float mean_noise = noise_sum / (float)noise_count;
195 preview->gain = (mean_noise > 1e-6f) ? (1.0f / mean_noise) : 1.0f;
200 const float px,
const float py)
252 const int origin_x,
const int origin_y,
261 const float dir_len = hypotf(dab->
dir_x, dab->
dir_y);
262 float sprinkle_w0 = 0.0f, sprinkle_w1 = 0.0f, sprinkle_w2 = 0.0f;
269 .sample_origin_x = origin_x,
270 .sample_origin_y = origin_y,
271 .scaled_radius = fmaxf(dab->
radius * scale, 0.5f),
272 .center_x = dab->
x * scale - (float)origin_x,
273 .center_y = dab->
y * scale - (
float)origin_y,
275 .tx = (dir_len > 1e-6f) ? (dab->
dir_x / dir_len) : 0.0f,
276 .ty = (dir_len > 1e-6f) ? (dab->
dir_y / dir_len) : 1.0f,
277 .alpha_noise_gain = 1.0f,
278 .sprinkle_coord_scale = 1.0f / fmaxf(scale, 1e-6f),
281 .sprinkle_w0 = sprinkle_w0,
282 .sprinkle_w1 = sprinkle_w1,
283 .sprinkle_w2 = sprinkle_w2,
284 .sprinkle_seed0 = sprinkle_seed0,
285 .sprinkle_seed1 = sprinkle_seed0 ^ 0xbf58476d1ce4e5b9ull,
286 .sprinkle_seed2 = sprinkle_seed0 ^ 0x94d049bb133111ebull,
288 .have_sprinkles = (dab->
sprinkles > 1e-6f),
290 view->inv_radius = 1.0f /
view->scaled_radius;
300 const int pixel_x,
const int pixel_y)
302 float alpha_noise = 1.0f;
305 const float layer_x = ((float)pixel_x + 0.5f) *
view->sprinkle_coord_scale;
306 const float layer_y = ((float)pixel_y + 0.5f) *
view->sprinkle_coord_scale;
308 view->sprinkle_scale,
309 view->sprinkle_strength,
313 view->sprinkle_seed0,
314 view->sprinkle_seed1,
315 view->sprinkle_seed2);
326 float noise_sum = 0.0f;
328 for(
int sy = -2; sy <= 2; sy++)
330 for(
int sx = -2; sx <= 2; sx++)
332 const float nx = 0.4f * (float)sx;
333 const float ny = 0.4f * (float)sy;
334 if(nx * nx + ny * ny > 1.0f)
continue;
336 const int pixel_x = (int)lrintf(
view->sample_origin_x +
view->center_x + nx *
view->scaled_radius);
337 const int pixel_y = (int)lrintf(
view->sample_origin_y +
view->center_y + ny *
view->scaled_radius);
343 if(noise_count <= 0)
return 1.0f;
344 const float mean_noise = noise_sum / (float)noise_count;
345 return (mean_noise > 1e-6f) ? (1.0f / mean_noise) : 1.0f;
356 const float sample_opacity_scale,
const float profile,
const float brush_alpha,
357 const float old_alpha,
const float stroke_old_alpha,
358 const gboolean have_stroke_alpha)
361 const float opacity_scale
362 = isfinite(sample_opacity_scale) ? CLAMP(sample_opacity_scale, 1e-6f, 1.0f) : 1.0f;
369 const float normalized = 1.0f - powf(fmaxf(1.0f - brush_alpha, 0.0f), opacity_scale);
373 const float flow_ref_alpha = have_stroke_alpha ? stroke_old_alpha
379 const float stroke_cap =
_clamp01(opacity);
380 const float remaining_to_cap = fmaxf(stroke_cap - flow_ref_alpha, 0.0f);
381 const float capped_alpha = fminf(
_clamp01(brush_alpha),
382 remaining_to_cap / fmaxf(1.0f - flow_ref_alpha, 1e-6f));
383 const float accum_alpha = 1.0f - powf(fmaxf(1.0f - brush_alpha, 0.0f), opacity_scale);
395 const float sample_opacity_scale,
396 float *stroke_mask,
const int stroke_mask_width,
397 const int stroke_mask_height,
398 const int x,
const int y,
const float old_alpha,
404 const float dy = ((float)y + 0.5f -
view->center_y) *
view->inv_radius;
405 const float dx = ((float)
x + 0.5f -
view->center_x) *
view->inv_radius;
406 const float norm2 = dx * dx + dy * dy;
411 view->sample_origin_x +
x,
412 view->sample_origin_y + y)
413 *
view->alpha_noise_gain);
421 if(
view->use_stroke_mask)
423 pixel_eval->
stroke_alpha = stroke_mask + (size_t)y * stroke_mask_width +
x;
439 const int height,
const int source_origin_x,
const int source_origin_y,
440 const int patch_origin_x,
const int patch_origin_y,
444 float blur_weight_sum = 0.0f;
448 for(
int y =
view->bounds.nw[1]; y <
view->bounds.se[1]; y++)
450 const float dy = ((float)y + 0.5f -
view->center_y) *
view->inv_radius;
451 const float dy2 = dy * dy;
452 for(
int x =
view->bounds.nw[0];
x <
view->bounds.se[0];
x++)
454 const float dx = ((float)
x + 0.5f -
view->center_x) *
view->inv_radius;
456 if(blur_weight <= 0.0f)
continue;
458 const int source_x =
x + patch_origin_x - source_origin_x;
459 const int source_y = y + patch_origin_y - source_origin_y;
460 if(source_x < 0 || source_y < 0 || source_x >=
width || source_y >=
height)
continue;
461 const float *pixel = buffer + 4 * ((size_t)source_y *
width + source_x);
462 blur_sum += dt_load_simd(pixel) *
dt_simd_set1(blur_weight);
463 blur_weight_sum += blur_weight;
467 if(blur_weight_sum <= 1e-8f)
return FALSE;
468 *blur_px = blur_sum *
dt_simd_set1(1.0f / blur_weight_sum);
476 guint32 h = (guint32)(
x * 73856093u) ^ (guint32)(y * 19349663u) ^ (guint32)(lane * 83492791u);
480 return ((h & 0xffffu) / 32767.5f) - 1.0f;
488_sample_rgba_float_bilinear(
const float *buffer,
const int width,
const int height,
const float x,
493 const float fx = CLAMP(
x, 0.0f, (
float)(
width - 1));
494 const float fy = CLAMP(y, 0.0f, (
float)(
height - 1));
495 const int x0 = (int)floorf(
fx);
496 const int y0 = (int)floorf(fy);
497 const int x1 =
MIN(
width - 1, x0 + 1);
499 const float tx =
fx - x0;
500 const float ty = fy - y0;
502 const float *p00 = buffer + 4 * ((size_t)y0 *
width + x0);
503 const float *p10 = buffer + 4 * ((size_t)y0 *
width + x1);
504 const float *p01 = buffer + 4 * ((size_t)y1 *
width + x0);
505 const float *p11 = buffer + 4 * ((size_t)y1 *
width + x1);
506 const dt_aligned_pixel_simd_t p00v = dt_load_simd(p00);
507 const dt_aligned_pixel_simd_t p10v = dt_load_simd(p10);
508 const dt_aligned_pixel_simd_t p01v = dt_load_simd(p01);
509 const dt_aligned_pixel_simd_t p11v = dt_load_simd(p11);
512 const dt_aligned_pixel_simd_t av = p00v + (p10v - p00v) * txv;
513 const dt_aligned_pixel_simd_t bv = p01v + (p11v - p01v) * txv;
514 return av + (bv - av) * tyv;
522static inline __attribute__((always_inline)) dt_aligned_pixel_simd_t
523_sample_smudge_source_float(
const float *buffer,
const int width,
const int height,
const float sx,
524 const float sy,
const float motion_dx,
const float motion_dy,
525 const int jitter_x,
const int jitter_y)
530 float dir_x = motion_dx;
531 float dir_y = motion_dy;
532 const float motion = hypotf(dir_x, dir_y);
544 const float perp_x = -dir_y;
545 const float perp_y = dir_x;
550 const float taps[7][3] = {
551 { 0.00f, jitter, 0.24f },
552 { -trail, 0.25f + jitter, 0.18f },
553 { -0.45f, -0.35f + jitter, 0.15f },
554 { -0.15f, side + jitter, 0.11f },
555 { -0.15f, -side + jitter, 0.11f },
556 { 0.25f, 0.45f * side + jitter, 0.11f },
557 { 0.25f, -0.45f * side + jitter, 0.10f },
560 float weight_sum = 0.0f;
561 for(
int i = 0;
i < 7;
i++)
563 const float px = sx + dir_x * taps[
i][0] + perp_x * taps[
i][1];
564 const float py = sy + dir_y * taps[
i][0] + perp_y * taps[
i][1];
565 const float w = taps[
i][2];
570 if(weight_sum > 1e-8f)
578 const float carry =
_clamp01(carried_alpha);
579 const float base =
_clamp01(opacity);
580 const float influence = base + (1.0f - base) * carry;
581 return _clamp01(src_alpha * influence);
589 const int source_height,
const int source_origin_x,
590 const int source_origin_y,
593 const float scale,
const int patch_origin_x,
594 const int patch_origin_y,
const int x,
const int y,
595 const float src_alpha,
596 const dt_aligned_pixel_simd_t old_px)
599 const float source_x_offset = (float)(patch_origin_x - source_origin_x);
600 const float source_y_offset = (float)(patch_origin_y - source_origin_y);
601 const float center_abs_x =
view->center_x + (float)patch_origin_x;
602 const float center_abs_y =
view->center_y + (float)patch_origin_y;
603 float sample_x = (float)
x + source_x_offset;
604 float sample_y = (float)y + source_y_offset;
605 float motion_dx = 0.0f;
606 float motion_dy = 0.0f;
613 float pickup_center_x = 0.0f;
614 float pickup_center_y = 0.0f;
616 pickup_center_x *= scale;
617 pickup_center_y *= scale;
618 sample_x += pickup_center_x - center_abs_x;
619 sample_y += pickup_center_y - center_abs_y;
620 motion_dx = center_abs_x - pickup_center_x;
621 motion_dy = center_abs_y - pickup_center_y;
624 const dt_aligned_pixel_simd_t sampled_px
625 = _sample_smudge_source_float(source_buffer, source_width, source_height, sample_x, sample_y,
626 motion_dx, motion_dy,
627 x -
view->bounds.nw[0], y -
view->bounds.nw[1]);
629 if(
IS_NULL_PTR(smudge_pixels) || smudge_width <= 0)
return old_px;
630 float *carry = smudge_pixels + 4 * ((size_t)(y -
view->bounds.nw[1]) * smudge_width + (
x -
view->bounds.nw[0]));
631 const dt_aligned_pixel_simd_t carried_px = dt_load_simd(carry);
633 const float carried_alpha =
_clamp01(carry[3]);
635 const float inv_alpha = 1.0f - deposit_alpha;
637 const dt_aligned_pixel_simd_t out_px = carried_px *
dt_simd_set1(deposit_alpha)
639 const dt_aligned_pixel_simd_t next_carry = carried_px
640 + (sampled_px - carried_px) *
dt_simd_set1(pickup_blend);
652 const float sample_opacity_scale,
664 float *
const buffer = patch->
pixels;
667 const int origin_x = patch->
x;
668 const int origin_y = patch->
y;
670 = (sample_patch && sample_patch->
pixels) ? sample_patch : patch;
671 const float *
const source_buffer = source_patch->
pixels;
672 const int source_width = source_patch->
width;
673 const int source_height = source_patch->
height;
674 const int source_origin_x = source_patch->
x;
675 const int source_origin_y = source_patch->
y;
676 float *
const stroke_mask_pixels = stroke_mask ? stroke_mask->
pixels : NULL;
677 const int stroke_mask_width = stroke_mask ? stroke_mask->
width : 0;
678 const int stroke_mask_height = stroke_mask ? stroke_mask->
height : 0;
686 origin_x, origin_y, scale))
695 switch(
view.dab->mode)
699 source_origin_y, origin_x, origin_y, &
view))
705 view.bounds.se[1] -
view.bounds.nw[1]))
716 for(
int y =
view.bounds.nw[1]; y <
view.bounds.se[1]; y++)
718 for(
int x =
view.bounds.nw[0];
x <
view.bounds.se[0];
x++)
720 float *pixel = buffer + 4 * ((size_t)y *
width +
x);
721 const float old_alpha =
_clamp01(pixel[3]);
722 const dt_aligned_pixel_simd_t old_px = (old_alpha > 1e-8f) ? dt_load_simd(pixel) :
dt_simd_set1(0.0f);
725 stroke_mask_pixels, stroke_mask_width, stroke_mask_height,
726 x, y, old_alpha, &pixel_eval))
729 const dt_aligned_pixel_simd_t out_px
731 source_origin_y, runtime_private, &
view,
732 scale, origin_x, origin_y,
747#if defined(_OPENMP) && !OUTER_LOOP
748#pragma omp parallel for default(firstprivate) collapse(2)
750 for(
int y =
view.bounds.nw[1]; y <
view.bounds.se[1]; y++)
752 for(
int x =
view.bounds.nw[0];
x <
view.bounds.se[0];
x++)
754 float *pixel = buffer + 4 * ((size_t)y *
width +
x);
755 const float old_alpha =
_clamp01(pixel[3]);
756 const dt_aligned_pixel_simd_t old_px = (old_alpha > 1e-8f) ? dt_load_simd(pixel) :
dt_simd_set1(0.0f);
759 stroke_mask_pixels, stroke_mask_width, stroke_mask_height,
760 x, y, old_alpha, &pixel_eval))
763 dt_aligned_pixel_simd_t out_px;
765 switch(
view.dab->mode)
768 out_px = old_px * inv_alpha;
799 const int width,
const int height,
const int stride,
800 const float center_x,
const float center_y,
801 const float opacity_multiplier)
806 memset(argb, 0, (
size_t)stride *
height);
813 const float radius = fmaxf(
preview.radius, 0.5f);
814 const float inv_radius = 1.0f / radius;
815 const int x0 = (int)fmaxf(0.0f, floorf(center_x - radius));
816 const int y0 = (int)fmaxf(0.0f, floorf(center_y - radius));
817 const int x1 = (int)fminf((
float)
width, ceilf(center_x + radius) + 1.0f);
818 const int y1 = (int)fminf((
float)
height, ceilf(center_y + radius) + 1.0f);
826 for(
int y = y0; y < y1; y++)
828 const float dy = ((float)y + 0.5f - center_y) * inv_radius;
829 const float dy2 = dy * dy;
830 for(
int x = x0;
x < x1;
x++)
832 const float dx = ((float)
x + 0.5f - center_x) * inv_radius;
834 if(profile <= 0.0f)
continue;
838 if(alpha <= 0.0f)
continue;
840 uint8_t *pixel = argb + (size_t)y * stride + 4 *
x;
841 pixel[0] = (uint8_t)fminf(fmaxf(roundf(255.0f *
_clamp01(disp_b * alpha)), 0.0f), 255.0f);
842 pixel[1] = (uint8_t)fminf(fmaxf(roundf(255.0f *
_clamp01(disp_g * alpha)), 0.0f), 255.0f);
843 pixel[2] = (uint8_t)fminf(fmaxf(roundf(255.0f *
_clamp01(disp_r * alpha)), 0.0f), 255.0f);
844 pixel[3] = (uint8_t)fminf(fmaxf(roundf(255.0f * alpha), 0.0f), 255.0f);
853 const float center_x,
const float center_y,
854 const float opacity_multiplier,
855 const float background_rgb[3])
859 const float bg_r = background_rgb ?
_clamp01(background_rgb[0]) : 1.0f;
860 const float bg_g = background_rgb ?
_clamp01(background_rgb[1]) : 1.0f;
861 const float bg_b = background_rgb ?
_clamp01(background_rgb[2]) : 1.0f;
864 rgba[4 *
i + 0] = bg_r;
865 rgba[4 *
i + 1] = bg_g;
866 rgba[4 *
i + 2] = bg_b;
867 rgba[4 *
i + 3] = 1.0f;
876 const float radius = fmaxf(
preview.radius, 0.5f);
877 const float inv_radius = 1.0f / radius;
878 const int x0 = (int)fmaxf(0.0f, floorf(center_x - radius));
879 const int y0 = (int)fmaxf(0.0f, floorf(center_y - radius));
880 const int x1 = (int)fminf((
float)
width, ceilf(center_x + radius) + 1.0f);
881 const int y1 = (int)fminf((
float)
height, ceilf(center_y + radius) + 1.0f);
889 for(
int y = y0; y < y1; y++)
891 const float dy = ((float)y + 0.5f - center_y) * inv_radius;
892 const float dy2 = dy * dy;
893 for(
int x = x0;
x < x1;
x++)
895 const float dx = ((float)
x + 0.5f - center_x) * inv_radius;
897 if(profile <= 0.0f)
continue;
901 if(alpha <= 0.0f)
continue;
903 float *pixel = rgba + 4 * ((size_t)y *
width +
x);
904 const float inv_alpha = 1.0f - alpha;
905 pixel[0] = src_r * alpha + pixel[0] * inv_alpha;
906 pixel[1] = src_g * alpha + pixel[1] * inv_alpha;
907 pixel[2] = src_b * alpha + pixel[2] * inv_alpha;
Dab-level brush rasterization API for drawlayer.
@ DT_DRAWLAYER_BRUSH_MODE_ERASE
@ DT_DRAWLAYER_BRUSH_MODE_PAINT
@ DT_DRAWLAYER_BRUSH_MODE_BLUR
@ DT_DRAWLAYER_BRUSH_MODE_SMUDGE
Inline brush profile and mass primitives shared by paint/brush code.
static float dt_drawlayer_brush_profile_eval(const dt_drawlayer_brush_dab_t *dab, const float norm2)
Evaluate normalized brush profile at squared normalized radius.
typedef void((*dt_cache_allocate_t)(void *userdata, dt_cache_entry_t *entry))
return vector dt_simd_set1(valid ?(scaling+NORM_MIN) :NORM_MIN)
static float strength(float value, float strength)
static unsigned int splitmix32(const unsigned long seed)
GtkWidget * preview
what the selected row actually captures
GtkWidget * view
the tree view
static gboolean _brush_runtime_view_from_state(const dt_drawlayer_paint_stroke_t *stroke, const dt_drawlayer_brush_dab_t *dab, const int origin_x, const int origin_y, const float scale, dt_drawlayer_brush_runtime_view_t *view)
Build immutable per-dab raster view from stroke runtime state.
static float _cellular_grain_2d(const uint64_t seed, const float x, const float y)
Grain-like round cellular field. Peaks at grain centers, falls off radially.
gboolean dt_drawlayer_brush_rasterize_dab_rgbaf(const dt_drawlayer_brush_dab_t *dab, float *rgba, const int width, const int height, const float center_x, const float center_y, const float opacity_multiplier, const float background_rgb[3])
Rasterize a single dab preview in linear float RGBA over an opaque background.
static float _sample_alpha_noise_raw(const dt_drawlayer_brush_dab_t *dab, const dt_drawlayer_brush_runtime_view_t *view, const int pixel_x, const int pixel_y)
Resolve multiplicative alpha noise at one pixel.
static void _prepare_sprinkle_preview(const dt_drawlayer_brush_dab_t *dab, const float center_x, const float center_y, const float radius, dt_drawlayer_sprinkle_preview_t *preview)
static gboolean _prepare_blur_context(dt_aligned_pixel_simd_t *blur_px, const float *buffer, const int width, const int height, const int source_origin_x, const int source_origin_y, const int patch_origin_x, const int patch_origin_y, const dt_drawlayer_brush_runtime_view_t *view)
Build blur gather color for current dab footprint.
static float _smudge_hash_signed(const int x, const int y, const int lane)
Stable signed pseudo-random helper in [-1,1].
static float _clamp01(const float v)
Clamp scalar to [0,1].
static float _smudge_deposit_alpha(const float src_alpha, const float carried_alpha, const float opacity)
Resolve effective smudge deposit alpha for one pixel.
static float _stroke_flow_alpha(const dt_drawlayer_brush_dab_t *dab, const float opacity, const float flow, const float sample_opacity_scale, const float profile, const float brush_alpha, const float old_alpha, const float stroke_old_alpha, const gboolean have_stroke_alpha)
Compute per-pixel source alpha from opacity/flow model.
gboolean dt_drawlayer_brush_rasterize_dab_argb8(const dt_drawlayer_brush_dab_t *dab, uint8_t *argb, const int width, const int height, const int stride, const float center_x, const float center_y, const float opacity_multiplier)
Render one dab to 8-bit ARGB surface for GUI cursor preview.
static void _sprinkle_octave_weights(const float coarseness, float *w0, float *w1, float *w2)
Resolve octave weights from coarseness control.
static float _sprinkle_noise_at_pixel_precomputed(const float px, const float py, const float scale, const float strength, const float w0, const float w1, const float w2, const uint64_t seed0, const uint64_t seed1, const uint64_t seed2)
Evaluate sprinkle modulation from precomputed dab constants.
static float _estimate_alpha_noise_gain(const dt_drawlayer_brush_dab_t *dab, const dt_drawlayer_brush_runtime_view_t *view)
Estimate per-dab texture gain so noise preserves average opacity across samples.
static float _sample_sprinkle_preview(const dt_drawlayer_sprinkle_preview_t *preview, const float px, const float py)
static float _cell_hash01_from_seed(const uint64_t cell_seed, const uint64_t salt)
Stable scalar hash in [0,1] from precomputed cell seed.
static float _lerpf(const float a, const float b, const float t)
Linear interpolation helper.
static dt_aligned_pixel_simd_t _apply_smudge_stroke_mode(const float *source_buffer, const int source_width, const int source_height, const int source_origin_x, const int source_origin_y, dt_drawlayer_paint_stroke_t *runtime_private, const dt_drawlayer_brush_runtime_view_t *view, const float scale, const int patch_origin_x, const int patch_origin_y, const int x, const int y, const float src_alpha, const dt_aligned_pixel_simd_t old_px)
Apply smudge mode for one pixel and update carried sample.
static gboolean _prepare_analytic_pixel_context(const dt_drawlayer_brush_runtime_view_t *view, const float sample_opacity_scale, float *stroke_mask, const int stroke_mask_width, const int stroke_mask_height, const int x, const int y, const float old_alpha, dt_drawlayer_brush_pixel_eval_t *pixel_eval)
Compute full analytic per-pixel brush context.
gboolean dt_drawlayer_brush_rasterize(const dt_drawlayer_cache_patch_t *sample_patch, dt_drawlayer_cache_patch_t *patch, const float scale, const dt_drawlayer_brush_dab_t *dab, const float sample_opacity_scale, dt_drawlayer_cache_patch_t *stroke_mask, dt_drawlayer_paint_stroke_t *runtime_private)
Public dab rasterization entry point.
Patch/cache helpers for drawlayer process and preview buffers.
float * dt_drawlayer_paint_runtime_smudge_pixels(dt_drawlayer_paint_stroke_t *state)
Get smudge carry buffer pointer (RGBA float).
gboolean dt_drawlayer_paint_runtime_have_smudge_pickup(const dt_drawlayer_paint_stroke_t *state)
Query whether smudge pickup coordinates are initialized.
void dt_drawlayer_paint_runtime_get_smudge_pickup(const dt_drawlayer_paint_stroke_t *state, float *x, float *y)
Read smudge pickup coordinates.
int dt_drawlayer_paint_runtime_smudge_width(const dt_drawlayer_paint_stroke_t *state)
Get smudge carry buffer width.
gboolean dt_drawlayer_paint_runtime_prepare_dab_context(dt_drawlayer_paint_stroke_t *state, const dt_drawlayer_brush_dab_t *dab, const int width, const int height, const int origin_x, const int origin_y, const float scale)
Compute current dab footprint bounds in target buffer coordinates.
gboolean dt_drawlayer_paint_runtime_ensure_smudge_pixels(dt_drawlayer_paint_stroke_t *state, const int width, const int height)
Ensure smudge carry buffer allocation for given footprint dimensions.
Stroke-level path sampling and runtime-state API for drawlayer.
#define IS_NULL_PTR(p)
C is way too permissive with !=, == and if(var) checks, which can mean too many things depending on w...
dt_store_simd(out, value)
float dt_aligned_pixel_simd_t __attribute__((vector_size(16), aligned(16)))
Apply one channel's tone curve to each of the three colour channels, or pass the channel through unto...
unsigned __int64 uint64_t
Fully resolved input dab descriptor.
float sprinkle_coarseness
dt_drawlayer_damaged_rect_t bounds
const dt_drawlayer_brush_dab_t * dab
float sprinkle_coord_scale
Generic float RGBA patch stored either in malloc memory or pixel cache.
Integer axis-aligned rectangle in buffer coordinates.
Mutable stroke runtime state owned by worker/backend code.
dt_drawlayer_damaged_rect_t bounds