Ansel 0.0
A darktable fork - bloat + design vision
Loading...
Searching...
No Matches
brush.h File Reference

Dab-level brush rasterization API for drawlayer. More...

#include <glib.h>
#include <stdint.h>
+ Include dependency graph for brush.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  dt_drawlayer_brush_dab_t
 Fully resolved input dab descriptor. More...
 

Macros

#define OUTER_LOOP   1
 

Typedefs

typedef struct dt_drawlayer_cache_patch_t dt_drawlayer_cache_patch_t
 
typedef enum dt_drawlayer_brush_shape_t dt_drawlayer_brush_shape_t
 Supported analytic fall-off profiles for brush alpha.
 
typedef enum dt_drawlayer_brush_mode_t dt_drawlayer_brush_mode_t
 Pixel blending behavior used while stamping a dab.
 
typedef dt_drawlayer_brush_shape_t dt_iop_drawlayer_brush_shape_t
 
typedef dt_drawlayer_brush_mode_t dt_iop_drawlayer_brush_mode_t
 
typedef struct dt_drawlayer_brush_dab_t dt_drawlayer_brush_dab_t
 Fully resolved input dab descriptor.
 

Enumerations

enum  dt_drawlayer_brush_shape_t {
  DT_DRAWLAYER_BRUSH_SHAPE_LINEAR = 0 ,
  DT_DRAWLAYER_BRUSH_SHAPE_GAUSSIAN = 1 ,
  DT_DRAWLAYER_BRUSH_SHAPE_QUADRATIC = 2 ,
  DT_DRAWLAYER_BRUSH_SHAPE_SIGMOIDAL = 3
}
 Supported analytic fall-off profiles for brush alpha. More...
 
enum  dt_drawlayer_brush_mode_t {
  DT_DRAWLAYER_BRUSH_MODE_PAINT = 0 ,
  DT_DRAWLAYER_BRUSH_MODE_ERASE = 1 ,
  DT_DRAWLAYER_BRUSH_MODE_BLUR = 2 ,
  DT_DRAWLAYER_BRUSH_MODE_SMUDGE = 3
}
 Pixel blending behavior used while stamping a dab. More...
 

Functions

gboolean dt_drawlayer_brush_rasterize (dt_drawlayer_cache_patch_t *patch, float scale, const dt_drawlayer_brush_dab_t *dab, float sample_opacity_scale, dt_drawlayer_cache_patch_t *stroke_mask, struct dt_drawlayer_paint_stroke_t *stroke)
 Rasterize one dab into a float RGBA buffer.
 
gboolean dt_drawlayer_brush_rasterize_dab_argb8 (const dt_drawlayer_brush_dab_t *dab, uint8_t *argb, int width, int height, int stride, float center_x, float center_y, float opacity_multiplier)
 Rasterize a single dab preview into ARGB8 for GUI overlays.
 
gboolean dt_drawlayer_brush_rasterize_dab_rgbaf (const dt_drawlayer_brush_dab_t *dab, float *rgba, int width, int height, float center_x, float center_y, float opacity_multiplier, const float background_rgb[3])
 Rasterize a single dab preview in linear float RGBA over an opaque background.
 

Detailed Description

Dab-level brush rasterization API for drawlayer.

This API is intentionally independent from drawlayer module internals. Callers provide fully resolved dab inputs in target buffer coordinates.

Macro Definition Documentation

◆ OUTER_LOOP

#define OUTER_LOOP   1

Typedef Documentation

◆ dt_drawlayer_brush_dab_t

Fully resolved input dab descriptor.

Instances are produced by the stroke-level paint API (or equivalent caller code) and consumed by the brush rasterizer.

◆ dt_drawlayer_brush_mode_t

Pixel blending behavior used while stamping a dab.

◆ dt_drawlayer_brush_shape_t

Supported analytic fall-off profiles for brush alpha.

◆ dt_drawlayer_cache_patch_t

◆ dt_iop_drawlayer_brush_mode_t

◆ dt_iop_drawlayer_brush_shape_t

Enumeration Type Documentation

◆ dt_drawlayer_brush_mode_t

Pixel blending behavior used while stamping a dab.

Enumerator
DT_DRAWLAYER_BRUSH_MODE_PAINT 

Standard source-over paint in premultiplied space.

DT_DRAWLAYER_BRUSH_MODE_ERASE 

Alpha attenuation / erase mode.

DT_DRAWLAYER_BRUSH_MODE_BLUR 

Local blur gather then blend.

DT_DRAWLAYER_BRUSH_MODE_SMUDGE 

Carry-and-deposit color pickup mode.

◆ dt_drawlayer_brush_shape_t

Supported analytic fall-off profiles for brush alpha.

Enumerator
DT_DRAWLAYER_BRUSH_SHAPE_LINEAR 

Linear ramp from inner to outer radius.

DT_DRAWLAYER_BRUSH_SHAPE_GAUSSIAN 

Smooth bell-like fall-off.

DT_DRAWLAYER_BRUSH_SHAPE_QUADRATIC 

Stronger center emphasis than linear.

DT_DRAWLAYER_BRUSH_SHAPE_SIGMOIDAL 

S-curve transition near edge.

Function Documentation

◆ dt_drawlayer_brush_rasterize()

gboolean dt_drawlayer_brush_rasterize ( 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 
)

Rasterize one dab into a float RGBA buffer.

Parameters
patchDestination premultiplied RGBA float patch.
scaleLayer-to-buffer scale factor, must be >0.
dabFully resolved dab input (coordinates already in layer space).
sample_opacity_scaleOpacity normalization factor derived from spacing.
stroke_maskOptional stroke-local alpha mask patch for overlap-aware flow.
strokeMutable stroke runtime payload (smudge context + dab bounds output).
Returns
TRUE when at least one pixel was processed; FALSE on invalid inputs or empty footprint.
Precondition
dab->radius > 0, dab->opacity > 0, scale > 0.
Coordinates transformation to layer space is handled by the caller.

Rasterize one dab into a float RGBA buffer.

Assumes caller already converted coordinates to layer space.

References _apply_smudge_stroke_mode(), _brush_runtime_view_from_state(), _clamp01(), _estimate_alpha_noise_gain(), _prepare_analytic_pixel_context(), _prepare_blur_context(), dt_drawlayer_brush_runtime_view_t::alpha_noise_gain, dt_drawlayer_paint_stroke_t::bounds, DT_DRAWLAYER_BRUSH_MODE_BLUR, DT_DRAWLAYER_BRUSH_MODE_ERASE, DT_DRAWLAYER_BRUSH_MODE_PAINT, DT_DRAWLAYER_BRUSH_MODE_SMUDGE, dt_drawlayer_paint_runtime_ensure_smudge_pixels(), dt_drawlayer_paint_runtime_prepare_dab_context(), dt_simd_set1(), dt_store_simd(), FALSE, dt_drawlayer_brush_dab_t::flow, height, dt_drawlayer_cache_patch_t::height, dt_drawlayer_brush_dab_t::opacity, dt_drawlayer_cache_patch_t::pixels, dt_drawlayer_brush_dab_t::radius, dt_drawlayer_damaged_rect_t::se, dt_drawlayer_brush_pixel_eval_t::src_alpha, dt_drawlayer_brush_pixel_eval_t::stroke_alpha, dt_drawlayer_brush_pixel_eval_t::stroke_old_alpha, TRUE, view(), width, dt_drawlayer_cache_patch_t::width, x, dt_drawlayer_cache_patch_t::x, and dt_drawlayer_cache_patch_t::y.

Referenced by dt_drawlayer_paint_rasterize_segment_to_buffer().

◆ dt_drawlayer_brush_rasterize_dab_argb8()

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 
)

Rasterize a single dab preview into ARGB8 for GUI overlays.

Parameters
dabInput dab descriptor.
argbDestination 8-bit ARGB surface memory.
widthSurface width.
heightSurface height.
strideSurface stride in bytes.
center_xDab center X in surface coordinates.
center_yDab center Y in surface coordinates.
opacity_multiplierAdditional UI-time opacity scalar in [0,1].
Returns
TRUE on success, FALSE on invalid inputs.
Note
This path is for cursor/post-expose rendering only and does not update stroke runtime state.

Rasterize a single dab preview into ARGB8 for GUI overlays.

Returns
TRUE on success.

References _clamp01(), _prepare_sprinkle_preview(), _sample_sprinkle_preview(), dt_drawlayer_brush_dab_t::display_color, dt_drawlayer_brush_profile_eval(), FALSE, height, dt_drawlayer_brush_dab_t::opacity, dt_drawlayer_brush_dab_t::radius, TRUE, width, and x.

Referenced by _ensure_cursor_stamp_surface().

◆ dt_drawlayer_brush_rasterize_dab_rgbaf()

gboolean dt_drawlayer_brush_rasterize_dab_rgbaf ( const dt_drawlayer_brush_dab_t dab,
float *  rgba,
int  width,
int  height,
float  center_x,
float  center_y,
float  opacity_multiplier,
const float  background_rgb[3] 
)

Rasterize a single dab preview in linear float RGBA over an opaque background.

Parameters
dabInput dab descriptor.
rgbaDestination float RGBA buffer (width*height*4), filled in linear display RGB.
widthSurface width.
heightSurface height.
center_xDab center X in surface coordinates.
center_yDab center Y in surface coordinates.
opacity_multiplierAdditional UI-time opacity scalar in [0,1].
background_rgbOpaque linear RGB background color, or NULL for white.
Returns
TRUE on success, FALSE on invalid inputs.

References _clamp01(), _prepare_sprinkle_preview(), _sample_sprinkle_preview(), dt_drawlayer_brush_dab_t::color, dt_drawlayer_brush_profile_eval(), FALSE, height, i, dt_drawlayer_brush_dab_t::opacity, dt_drawlayer_brush_dab_t::radius, TRUE, width, and x.

Referenced by _render_brush_profile_cell().