40 return fminf(fmaxf(
v, 0.0f), 1.0f);
44static inline float _lerpf(
const float a,
const float b,
const float t)
46 return a + (b - a) *
t;
52 return (
float)
splitmix32(cell_seed ^ salt) / (float)UINT32_MAX;
58 const int cell_x = (int)floorf(
x);
59 const int cell_y = (int)floorf(y);
61 float weight_sum = 0.0f;
63 for(
int oy = -1; oy <= 1; oy++)
65 for(
int ox = -1; ox <= 1; ox++)
67 const int ix = cell_x + ox;
68 const int iy = cell_y + oy;
70 ^ ((
uint64_t)(uint32_t)ix * 0x9e3779b185ebca87ull)
71 ^ ((
uint64_t)(uint32_t)iy * 0xc2b2ae3d27d4eb4full);
75 const float dx =
x - ((float)ix + jitter_x);
76 const float dy = y - ((float)iy + jitter_y);
77 const float dist2 = dx * dx + dy * dy;
79 const float grain = fmaxf(0.0f, 1.0f - dist2 / (radius * radius));
80 const float shaped = grain * grain * (3.0f - 2.0f * grain);
81 accum += grain_gain * shaped;
82 weight_sum += grain_gain;
86 return (weight_sum > 1e-6f) ?
_clamp01(accum / weight_sum) : 0.0f;
92 const float c = 1.0f -
_clamp01(coarseness);
95 const float t = c * 2.0f;
102 const float t = (c - 0.5f) * 2.0f;
111 const float scale,
const float strength,
112 const float w0,
const float w1,
const float w2,
116 const float x = px * scale;
117 const float y = py * scale;
119 const float g1 = (
w1 > 1e-6f) ?
_cellular_grain_2d(seed1,
x * 1.93f + 4.7f, y * 1.93f - 2.9f) : 0.0f;
120 const float g2 = (
w2 > 1e-6f) ?
_cellular_grain_2d(seed2,
x * 3.71f - 6.2f, y * 3.71f + 8.4f) : 0.0f;
121 const float field = w0 * g0 +
w1 * g1 +
w2 * g2;
122 const float centered = 2.0f * field - 1.0f;
123 return fmaxf(0.0f, 1.0f +
strength * centered);
141 const float center_x,
const float center_y,
168 preview->
seed1 = preview->
seed0 ^ 0xbf58476d1ce4e5b9ull;
169 preview->
seed2 = preview->
seed0 ^ 0x94d049bb133111ebull;
172 float noise_sum = 0.0f;
174 for(
int sy = -2; sy <= 2; sy++)
176 for(
int sx = -2; sx <= 2; sx++)
178 const float nx = 0.4f * (float)sx;
179 const float ny = 0.4f * (float)sy;
180 if(nx * nx + ny * ny > 1.0f)
continue;
181 const int pixel_x = (int)lrintf(center_x + nx * radius);
182 const int pixel_y = (int)lrintf(center_y + ny * radius);
185 preview->
w0, preview->
w1, preview->
w2,
193 const float mean_noise = noise_sum / (float)noise_count;
194 preview->
gain = (mean_noise > 1e-6f) ? (1.0f / mean_noise) : 1.0f;
199 const float px,
const float py)
204 preview->
w0, preview->
w1, preview->
w2,
251 const int origin_x,
const int origin_y,
260 const float dir_len = hypotf(dab->
dir_x, dab->
dir_y);
261 float sprinkle_w0 = 0.0f, sprinkle_w1 = 0.0f, sprinkle_w2 = 0.0f;
268 .sample_origin_x = origin_x,
269 .sample_origin_y = origin_y,
270 .scaled_radius = fmaxf(dab->
radius * scale, 0.5f),
271 .center_x = dab->
x * scale - (float)origin_x,
272 .center_y = dab->
y * scale - (
float)origin_y,
274 .tx = (dir_len > 1e-6f) ? (dab->
dir_x / dir_len) : 0.0f,
275 .ty = (dir_len > 1e-6f) ? (dab->
dir_y / dir_len) : 1.0f,
276 .alpha_noise_gain = 1.0f,
277 .sprinkle_coord_scale = 1.0f / fmaxf(scale, 1e-6f),
280 .sprinkle_w0 = sprinkle_w0,
281 .sprinkle_w1 = sprinkle_w1,
282 .sprinkle_w2 = sprinkle_w2,
283 .sprinkle_seed0 = sprinkle_seed0,
284 .sprinkle_seed1 = sprinkle_seed0 ^ 0xbf58476d1ce4e5b9ull,
285 .sprinkle_seed2 = sprinkle_seed0 ^ 0x94d049bb133111ebull,
287 .have_sprinkles = (dab->
sprinkles > 1e-6f),
289 view->inv_radius = 1.0f /
view->scaled_radius;
299 const int pixel_x,
const int pixel_y)
301 float alpha_noise = 1.0f;
304 const float layer_x = ((float)pixel_x + 0.5f) *
view->sprinkle_coord_scale;
305 const float layer_y = ((float)pixel_y + 0.5f) *
view->sprinkle_coord_scale;
307 view->sprinkle_scale,
308 view->sprinkle_strength,
312 view->sprinkle_seed0,
313 view->sprinkle_seed1,
314 view->sprinkle_seed2);
325 float noise_sum = 0.0f;
327 for(
int sy = -2; sy <= 2; sy++)
329 for(
int sx = -2; sx <= 2; sx++)
331 const float nx = 0.4f * (float)sx;
332 const float ny = 0.4f * (float)sy;
333 if(nx * nx + ny * ny > 1.0f)
continue;
335 const int pixel_x = (int)lrintf(
view->sample_origin_x +
view->center_x + nx *
view->scaled_radius);
336 const int pixel_y = (int)lrintf(
view->sample_origin_y +
view->center_y + ny *
view->scaled_radius);
342 if(noise_count <= 0)
return 1.0f;
343 const float mean_noise = noise_sum / (float)noise_count;
344 return (mean_noise > 1e-6f) ? (1.0f / mean_noise) : 1.0f;
355 const float sample_opacity_scale,
const float profile,
const float brush_alpha,
356 const float old_alpha,
const float stroke_old_alpha,
357 const gboolean have_stroke_alpha)
360 const float opacity_scale
361 = isfinite(sample_opacity_scale) ? CLAMP(sample_opacity_scale, 1e-6f, 1.0f) : 1.0f;
368 const float normalized = 1.0f - powf(fmaxf(1.0f - brush_alpha, 0.0f), opacity_scale);
372 const float flow_ref_alpha = have_stroke_alpha ? stroke_old_alpha
378 const float stroke_cap =
_clamp01(opacity);
379 const float remaining_to_cap = fmaxf(stroke_cap - flow_ref_alpha, 0.0f);
380 const float capped_alpha = fminf(
_clamp01(brush_alpha),
381 remaining_to_cap / fmaxf(1.0f - flow_ref_alpha, 1e-6f));
382 const float accum_alpha = 1.0f - powf(fmaxf(1.0f - brush_alpha, 0.0f), opacity_scale);
394 const float sample_opacity_scale,
395 float *stroke_mask,
const int stroke_mask_width,
396 const int stroke_mask_height,
397 const int x,
const int y,
const float old_alpha,
403 const float dy = ((float)y + 0.5f -
view->center_y) *
view->inv_radius;
404 const float dx = ((float)
x + 0.5f -
view->center_x) *
view->inv_radius;
405 const float norm2 = dx * dx + dy * dy;
410 view->sample_origin_x +
x,
411 view->sample_origin_y + y)
412 *
view->alpha_noise_gain);
420 if(
view->use_stroke_mask)
422 pixel_eval->
stroke_alpha = stroke_mask + (size_t)y * stroke_mask_width +
x;
438 const int height,
const int source_origin_x,
const int source_origin_y,
439 const int patch_origin_x,
const int patch_origin_y,
443 float blur_weight_sum = 0.0f;
447 for(
int y =
view->bounds.nw[1]; y <
view->bounds.se[1]; y++)
449 const float dy = ((float)y + 0.5f -
view->center_y) *
view->inv_radius;
450 const float dy2 = dy * dy;
451 for(
int x =
view->bounds.nw[0];
x <
view->bounds.se[0];
x++)
453 const float dx = ((float)
x + 0.5f -
view->center_x) *
view->inv_radius;
455 if(blur_weight <= 0.0f)
continue;
457 const int source_x =
x + patch_origin_x - source_origin_x;
458 const int source_y = y + patch_origin_y - source_origin_y;
459 if(source_x < 0 || source_y < 0 || source_x >=
width || source_y >=
height)
continue;
460 const float *pixel = buffer + 4 * ((size_t)source_y *
width + source_x);
461 blur_sum += dt_load_simd(pixel) *
dt_simd_set1(blur_weight);
462 blur_weight_sum += blur_weight;
466 if(blur_weight_sum <= 1e-8f)
return FALSE;
467 *blur_px = blur_sum *
dt_simd_set1(1.0f / blur_weight_sum);
475 guint32 h = (guint32)(
x * 73856093u) ^ (guint32)(y * 19349663u) ^ (guint32)(lane * 83492791u);
479 return ((h & 0xffffu) / 32767.5f) - 1.0f;
487_sample_rgba_float_bilinear(
const float *buffer,
const int width,
const int height,
const float x,
492 const float fx = CLAMP(
x, 0.0f, (
float)(
width - 1));
493 const float fy = CLAMP(y, 0.0f, (
float)(
height - 1));
494 const int x0 = (int)floorf(
fx);
495 const int y0 = (int)floorf(fy);
496 const int x1 =
MIN(
width - 1, x0 + 1);
498 const float tx =
fx - x0;
499 const float ty = fy - y0;
501 const float *p00 = buffer + 4 * ((size_t)y0 *
width + x0);
502 const float *p10 = buffer + 4 * ((size_t)y0 *
width + x1);
503 const float *p01 = buffer + 4 * ((size_t)y1 *
width + x0);
504 const float *p11 = buffer + 4 * ((size_t)y1 *
width + x1);
505 const dt_aligned_pixel_simd_t p00v = dt_load_simd(p00);
506 const dt_aligned_pixel_simd_t p10v = dt_load_simd(p10);
507 const dt_aligned_pixel_simd_t p01v = dt_load_simd(p01);
508 const dt_aligned_pixel_simd_t p11v = dt_load_simd(p11);
511 const dt_aligned_pixel_simd_t av = p00v + (p10v - p00v) * txv;
512 const dt_aligned_pixel_simd_t bv = p01v + (p11v - p01v) * txv;
513 return av + (bv - av) * tyv;
521static inline __attribute__((always_inline)) dt_aligned_pixel_simd_t
522_sample_smudge_source_float(
const float *buffer,
const int width,
const int height,
const float sx,
523 const float sy,
const float motion_dx,
const float motion_dy,
524 const int jitter_x,
const int jitter_y)
529 float dir_x = motion_dx;
530 float dir_y = motion_dy;
531 const float motion = hypotf(dir_x, dir_y);
543 const float perp_x = -dir_y;
544 const float perp_y = dir_x;
549 const float taps[7][3] = {
550 { 0.00f, jitter, 0.24f },
551 { -trail, 0.25f + jitter, 0.18f },
552 { -0.45f, -0.35f + jitter, 0.15f },
553 { -0.15f, side + jitter, 0.11f },
554 { -0.15f, -side + jitter, 0.11f },
555 { 0.25f, 0.45f * side + jitter, 0.11f },
556 { 0.25f, -0.45f * side + jitter, 0.10f },
559 float weight_sum = 0.0f;
560 for(
int i = 0;
i < 7;
i++)
562 const float px = sx + dir_x * taps[
i][0] + perp_x * taps[
i][1];
563 const float py = sy + dir_y * taps[
i][0] + perp_y * taps[
i][1];
564 const float w = taps[
i][2];
569 if(weight_sum > 1e-8f)
577 const float carry =
_clamp01(carried_alpha);
578 const float base =
_clamp01(opacity);
579 const float influence = base + (1.0f - base) * carry;
580 return _clamp01(src_alpha * influence);
588 const int source_height,
const int source_origin_x,
589 const int source_origin_y,
592 const float scale,
const int patch_origin_x,
593 const int patch_origin_y,
const int x,
const int y,
594 const float src_alpha,
595 const dt_aligned_pixel_simd_t old_px)
598 const float source_x_offset = (float)(patch_origin_x - source_origin_x);
599 const float source_y_offset = (float)(patch_origin_y - source_origin_y);
600 const float center_abs_x =
view->center_x + (float)patch_origin_x;
601 const float center_abs_y =
view->center_y + (float)patch_origin_y;
602 float sample_x = (float)
x + source_x_offset;
603 float sample_y = (float)y + source_y_offset;
604 float motion_dx = 0.0f;
605 float motion_dy = 0.0f;
612 float pickup_center_x = 0.0f;
613 float pickup_center_y = 0.0f;
615 pickup_center_x *= scale;
616 pickup_center_y *= scale;
617 sample_x += pickup_center_x - center_abs_x;
618 sample_y += pickup_center_y - center_abs_y;
619 motion_dx = center_abs_x - pickup_center_x;
620 motion_dy = center_abs_y - pickup_center_y;
623 const dt_aligned_pixel_simd_t sampled_px
624 = _sample_smudge_source_float(source_buffer, source_width, source_height, sample_x, sample_y,
625 motion_dx, motion_dy,
626 x -
view->bounds.nw[0], y -
view->bounds.nw[1]);
628 if(
IS_NULL_PTR(smudge_pixels) || smudge_width <= 0)
return old_px;
629 float *carry = smudge_pixels + 4 * ((size_t)(y -
view->bounds.nw[1]) * smudge_width + (
x -
view->bounds.nw[0]));
630 const dt_aligned_pixel_simd_t carried_px = dt_load_simd(carry);
632 const float carried_alpha =
_clamp01(carry[3]);
634 const float inv_alpha = 1.0f - deposit_alpha;
636 const dt_aligned_pixel_simd_t out_px = carried_px *
dt_simd_set1(deposit_alpha)
638 const dt_aligned_pixel_simd_t next_carry = carried_px
639 + (sampled_px - carried_px) *
dt_simd_set1(pickup_blend);
651 const float sample_opacity_scale,
663 float *
const buffer = patch->
pixels;
666 const int origin_x = patch->
x;
667 const int origin_y = patch->
y;
669 = (sample_patch && sample_patch->
pixels) ? sample_patch : patch;
670 const float *
const source_buffer = source_patch->
pixels;
671 const int source_width = source_patch->
width;
672 const int source_height = source_patch->
height;
673 const int source_origin_x = source_patch->
x;
674 const int source_origin_y = source_patch->
y;
675 float *
const stroke_mask_pixels = stroke_mask ? stroke_mask->
pixels : NULL;
676 const int stroke_mask_width = stroke_mask ? stroke_mask->
width : 0;
677 const int stroke_mask_height = stroke_mask ? stroke_mask->
height : 0;
685 origin_x, origin_y, scale))
694 switch(
view.dab->mode)
698 source_origin_y, origin_x, origin_y, &
view))
704 view.bounds.se[1] -
view.bounds.nw[1]))
715 for(
int y =
view.bounds.nw[1]; y <
view.bounds.se[1]; y++)
717 for(
int x =
view.bounds.nw[0];
x <
view.bounds.se[0];
x++)
719 float *pixel = buffer + 4 * ((size_t)y *
width +
x);
720 const float old_alpha =
_clamp01(pixel[3]);
721 const dt_aligned_pixel_simd_t old_px = (old_alpha > 1e-8f) ? dt_load_simd(pixel) :
dt_simd_set1(0.0f);
724 stroke_mask_pixels, stroke_mask_width, stroke_mask_height,
725 x, y, old_alpha, &pixel_eval))
728 const dt_aligned_pixel_simd_t out_px
730 source_origin_y, runtime_private, &
view,
731 scale, origin_x, origin_y,
746#if defined(_OPENMP) && !OUTER_LOOP
747#pragma omp parallel for default(firstprivate) collapse(2)
749 for(
int y =
view.bounds.nw[1]; y <
view.bounds.se[1]; y++)
751 for(
int x =
view.bounds.nw[0];
x <
view.bounds.se[0];
x++)
753 float *pixel = buffer + 4 * ((size_t)y *
width +
x);
754 const float old_alpha =
_clamp01(pixel[3]);
755 const dt_aligned_pixel_simd_t old_px = (old_alpha > 1e-8f) ? dt_load_simd(pixel) :
dt_simd_set1(0.0f);
758 stroke_mask_pixels, stroke_mask_width, stroke_mask_height,
759 x, y, old_alpha, &pixel_eval))
762 dt_aligned_pixel_simd_t out_px;
764 switch(
view.dab->mode)
767 out_px = old_px * inv_alpha;
798 const int width,
const int height,
const int stride,
799 const float center_x,
const float center_y,
800 const float opacity_multiplier)
805 memset(argb, 0, (
size_t)stride *
height);
812 const float radius = fmaxf(preview.
radius, 0.5f);
813 const float inv_radius = 1.0f / radius;
814 const int x0 = (int)fmaxf(0.0f, floorf(center_x - radius));
815 const int y0 = (int)fmaxf(0.0f, floorf(center_y - radius));
816 const int x1 = (int)fminf((
float)
width, ceilf(center_x + radius) + 1.0f);
817 const int y1 = (int)fminf((
float)
height, ceilf(center_y + radius) + 1.0f);
825 for(
int y = y0; y < y1; y++)
827 const float dy = ((float)y + 0.5f - center_y) * inv_radius;
828 const float dy2 = dy * dy;
829 for(
int x = x0;
x < x1;
x++)
831 const float dx = ((float)
x + 0.5f - center_x) * inv_radius;
833 if(profile <= 0.0f)
continue;
837 if(alpha <= 0.0f)
continue;
839 uint8_t *pixel = argb + (size_t)y * stride + 4 *
x;
840 pixel[0] = (uint8_t)fminf(fmaxf(roundf(255.0f *
_clamp01(disp_b * alpha)), 0.0f), 255.0f);
841 pixel[1] = (uint8_t)fminf(fmaxf(roundf(255.0f *
_clamp01(disp_g * alpha)), 0.0f), 255.0f);
842 pixel[2] = (uint8_t)fminf(fmaxf(roundf(255.0f *
_clamp01(disp_r * alpha)), 0.0f), 255.0f);
843 pixel[3] = (uint8_t)fminf(fmaxf(roundf(255.0f * alpha), 0.0f), 255.0f);
852 const float center_x,
const float center_y,
853 const float opacity_multiplier,
854 const float background_rgb[3])
858 const float bg_r = background_rgb ?
_clamp01(background_rgb[0]) : 1.0f;
859 const float bg_g = background_rgb ?
_clamp01(background_rgb[1]) : 1.0f;
860 const float bg_b = background_rgb ?
_clamp01(background_rgb[2]) : 1.0f;
863 rgba[4 *
i + 0] = bg_r;
864 rgba[4 *
i + 1] = bg_g;
865 rgba[4 *
i + 2] = bg_b;
866 rgba[4 *
i + 3] = 1.0f;
875 const float radius = fmaxf(preview.
radius, 0.5f);
876 const float inv_radius = 1.0f / radius;
877 const int x0 = (int)fmaxf(0.0f, floorf(center_x - radius));
878 const int y0 = (int)fmaxf(0.0f, floorf(center_y - radius));
879 const int x1 = (int)fminf((
float)
width, ceilf(center_x + radius) + 1.0f);
880 const int y1 = (int)fminf((
float)
height, ceilf(center_y + radius) + 1.0f);
888 for(
int y = y0; y < y1; y++)
890 const float dy = ((float)y + 0.5f - center_y) * inv_radius;
891 const float dy2 = dy * dy;
892 for(
int x = x0;
x < x1;
x++)
894 const float dx = ((float)
x + 0.5f - center_x) * inv_radius;
896 if(profile <= 0.0f)
continue;
900 if(alpha <= 0.0f)
continue;
902 float *pixel = rgba + 4 * ((size_t)y *
width +
x);
903 const float inv_alpha = 1.0f - alpha;
904 pixel[0] = src_r * alpha + pixel[0] * inv_alpha;
905 pixel[1] = src_g * alpha + pixel[1] * inv_alpha;
906 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.
return vector dt_simd_set1(valid ?(scaling+NORM_MIN) :NORM_MIN)
static float strength(float value, float strength)
typedef void((*dt_cache_allocate_t)(void *userdata, dt_cache_entry_t *entry))
uint32_t view(const dt_view_t *self)
dt_store_simd(out, value)
float dt_aligned_pixel_simd_t __attribute__((vector_size(16), aligned(16)))
Enable aggressive floating-point arithmetic optimizations, in denormals handling. Set through user pr...
#define IS_NULL_PTR(p)
C is way too permissive with !=, == and if(var) checks, which can mean too many things depending on w...
static unsigned int splitmix32(const unsigned long seed)
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.
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