Ansel 0.0
A darktable fork - bloat + design vision
Loading...
Searching...
No Matches
masks_solid.c File Reference
#include "develop/masks/masks_solid.h"
#include "develop/masks_gui.h"
#include "caches/pixelpipe_cache_alloc.h"
#include "system/mem_alloc.h"
#include "common/logging.h"
#include "common/times.h"
#include <float.h>
#include <math.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
Include dependency graph for masks_solid.c:

Go to the source code of this file.

Data Structures

struct  _solid_edge_t
struct  _solid_crossing_t
struct  _solid_bands_t
struct  _solid_grid_t

Macros

#define SOLID_SUBLINES   4
#define SOLID_MAX_CELLS   ((size_t)8 << 20)
#define SOLID_MAX_CROSSINGS   ((size_t)32 << 20)
#define SOLID_DRIFT   0.1f
#define SOLID_INSERTION   32

Typedefs

typedef struct _solid_edge_t _solid_edge_t
typedef struct _solid_crossing_t _solid_crossing_t
typedef struct _solid_bands_t _solid_bands_t
typedef struct _solid_grid_t _solid_grid_t

Enumerations

enum  {
  SOLID_TOP = 0 ,
  SOLID_RIGHT = 1 ,
  SOLID_BOTTOM = 2 ,
  SOLID_LEFT = 3
}

Functions

static gboolean _solid_spokes_cross (const _solid_bands_t *const b, const int k, const int l, float *const t)
static int _solid_band_signs (const _solid_bands_t *const b, int8_t *const sign, float bbox[4], int *const twisted)
static int _solid_add_edge (_solid_edge_t *const e, const float xa, const float ya, const float xb, const float yb, const int winding)
static int _solid_untwist (const _solid_bands_t *const b, const int k, const int l, const float t, const int s, _solid_edge_t *const edges)
static int _solid_edges (const _solid_bands_t *const bands, const int8_t *const sign, _solid_edge_t *const edges)
static void _solid_grid_fit (_solid_grid_t *const g, const float bbox[4], float cell)
static void _solid_lines (const _solid_edge_t *const e, const _solid_grid_t *const g, int *t0, int *t1)
static size_t _solid_count (const _solid_edge_t *const edges, const int count, const _solid_grid_t *const g, int *const offset)
static uint32_t _solid_key (const _solid_crossing_t *const c)
static void _solid_sort (_solid_crossing_t *const c, _solid_crossing_t *const scratch, const int m)
static void _solid_span (float *const partial, float *const step, const float xa, const float xb, int *const lo, int *const hi)
static int _solid_fill (const _solid_edge_t *const edges, const int count, const _solid_grid_t *const g, const int *const offset, _solid_crossing_t *const crossing, uint8_t *const cover, int *const range)
static void _solid_spine (const _solid_bands_t *const b, const int8_t *const sign, const _solid_grid_t *const g, uint8_t *const cover, int *const range)
static uint8_t * _solid_visit (uint8_t *const visited, const int w, const int i, const int j, const int e, uint8_t *const bit)
static int _solid_exit (const uint8_t *const cover, const int w, const int i, const int j, const int entry)
static void _solid_point (const uint8_t *const cover, const _solid_grid_t *const g, const int i, const int j, const int e, float *const out)
static int _solid_follow (const uint8_t *const cover, uint8_t *const visited, const _solid_grid_t *const g, int i, int j, float *const out)
static int _solid_trace (const uint8_t *const cover, const int *const range, const _solid_grid_t *const g, dt_masks_form_gui_points_t *const gp)
int dt_masks_solid_edge (dt_masks_form_gui_points_t *gui_points, const float *contour, const int header, const float cell)

Variables

static const int _corner_i [4] = { 0, 1, 1, 0 }
static const int _corner_j [4] = { 0, 0, 1, 1 }
static const int _visit_corner [4] = { 0, 1, 3, 0 }
static const int _step_i [4] = { 0, 1, 0, -1 }
static const int _step_j [4] = { -1, 0, 1, 0 }

Macro Definition Documentation

◆ SOLID_DRIFT

#define SOLID_DRIFT   0.1f

Definition at line 52 of file masks_solid.c.

Referenced by _solid_band_signs().

◆ SOLID_INSERTION

#define SOLID_INSERTION   32

Definition at line 54 of file masks_solid.c.

Referenced by _solid_sort().

◆ SOLID_MAX_CELLS

#define SOLID_MAX_CELLS   ((size_t)8 << 20)

Definition at line 49 of file masks_solid.c.

Referenced by _solid_grid_fit().

◆ SOLID_MAX_CROSSINGS

#define SOLID_MAX_CROSSINGS   ((size_t)32 << 20)

Definition at line 50 of file masks_solid.c.

Referenced by _solid_count(), and dt_masks_solid_edge().

◆ SOLID_SUBLINES

#define SOLID_SUBLINES   4

Typedef Documentation

◆ _solid_bands_t

typedef struct _solid_bands_t _solid_bands_t

◆ _solid_crossing_t

typedef struct _solid_crossing_t _solid_crossing_t

◆ _solid_edge_t

typedef struct _solid_edge_t _solid_edge_t

◆ _solid_grid_t

typedef struct _solid_grid_t _solid_grid_t

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
SOLID_TOP 
SOLID_RIGHT 
SOLID_BOTTOM 
SOLID_LEFT 

Definition at line 56 of file masks_solid.c.

Function Documentation

◆ _solid_add_edge()

int _solid_add_edge ( _solid_edge_t *const e,
const float xa,
const float ya,
const float xb,
const float yb,
const int winding )
static

◆ _solid_band_signs()

int _solid_band_signs ( const _solid_bands_t *const b,
int8_t *const sign,
float bbox[4],
int *const twisted )
static

Definition at line 119 of file masks_solid.c.

References _solid_spokes_cross(), bbox, k, n, sign, SOLID_DRIFT, t, and width.

Referenced by dt_masks_solid_edge().

◆ _solid_count()

size_t _solid_count ( const _solid_edge_t *const edges,
const int count,
const _solid_grid_t *const g,
int *const offset )
static

Definition at line 308 of file masks_solid.c.

References _solid_lines(), g, k, SOLID_MAX_CROSSINGS, SOLID_SUBLINES, and t.

Referenced by dt_masks_solid_edge().

◆ _solid_edges()

int _solid_edges ( const _solid_bands_t *const bands,
const int8_t *const sign,
_solid_edge_t *const edges )
static

◆ _solid_exit()

int _solid_exit ( const uint8_t *const cover,
const int w,
const int i,
const int j,
const int entry )
static

Definition at line 537 of file masks_solid.c.

References i, SOLID_BOTTOM, SOLID_LEFT, SOLID_RIGHT, SOLID_TOP, top, and v.

Referenced by _solid_follow().

◆ _solid_fill()

int _solid_fill ( const _solid_edge_t *const edges,
const int count,
const _solid_grid_t *const g,
const int *const offset,
_solid_crossing_t *const crossing,
uint8_t *const cover,
int *const range )
static

◆ _solid_follow()

int _solid_follow ( const uint8_t *const cover,
uint8_t *const visited,
const _solid_grid_t *const g,
int i,
int j,
float *const out )
static

Definition at line 575 of file masks_solid.c.

References _solid_exit(), _solid_point(), _solid_visit(), _step_i, _step_j, g, i, out, and SOLID_TOP.

Referenced by _solid_trace().

◆ _solid_grid_fit()

void _solid_grid_fit ( _solid_grid_t *const g,
const float bbox[4],
float cell )
static

Definition at line 279 of file masks_solid.c.

References bbox, g, and SOLID_MAX_CELLS.

Referenced by dt_masks_solid_edge().

◆ _solid_key()

uint32_t _solid_key ( const _solid_crossing_t *const c)
inlinestatic

Definition at line 336 of file masks_solid.c.

References key, and memcpy().

Referenced by _solid_sort().

◆ _solid_lines()

void _solid_lines ( const _solid_edge_t *const e,
const _solid_grid_t *const g,
int * t0,
int * t1 )
inlinestatic

Definition at line 299 of file masks_solid.c.

References g, SOLID_SUBLINES, _solid_edge_t::y, and _solid_edge_t::y_end.

Referenced by _solid_count(), and _solid_fill().

◆ _solid_point()

void _solid_point ( const uint8_t *const cover,
const _solid_grid_t *const g,
const int i,
const int j,
const int e,
float *const out )
inlinestatic

Definition at line 558 of file masks_solid.c.

References _corner_i, _corner_j, g, i, out, t, and x.

Referenced by _solid_follow().

◆ _solid_sort()

void _solid_sort ( _solid_crossing_t *const c,
_solid_crossing_t *const scratch,
const int m )
static

Definition at line 346 of file masks_solid.c.

References _solid_key(), d, m, memcpy(), r, SOLID_INSERTION, and v.

Referenced by _solid_fill().

◆ _solid_span()

void _solid_span ( float *const partial,
float *const step,
const float xa,
const float xb,
int *const lo,
int *const hi )
inlinestatic

Definition at line 377 of file masks_solid.c.

References k, MAX, MIN, and SOLID_SUBLINES.

Referenced by _solid_fill().

◆ _solid_spine()

void _solid_spine ( const _solid_bands_t *const b,
const int8_t *const sign,
const _solid_grid_t *const g,
uint8_t *const cover,
int *const range )
static

Definition at line 482 of file masks_solid.c.

References g, i, k, MAX, MIN, and sign.

Referenced by dt_masks_solid_edge().

◆ _solid_spokes_cross()

gboolean _solid_spokes_cross ( const _solid_bands_t *const b,
const int k,
const int l,
float *const t )
inlinestatic

Definition at line 93 of file masks_solid.c.

References c1, FALSE, k, and t.

Referenced by _solid_band_signs(), and _solid_edges().

◆ _solid_trace()

◆ _solid_untwist()

int _solid_untwist ( const _solid_bands_t *const b,
const int k,
const int l,
const float t,
const int s,
_solid_edge_t *const edges )
static

Definition at line 214 of file masks_solid.c.

References _solid_add_edge(), c1, k, t, and x.

Referenced by _solid_edges().

◆ _solid_visit()

uint8_t * _solid_visit ( uint8_t *const visited,
const int w,
const int i,
const int j,
const int e,
uint8_t *const bit )
inlinestatic

Definition at line 528 of file masks_solid.c.

References _corner_i, _corner_j, _visit_corner, and i.

Referenced by _solid_follow().

◆ dt_masks_solid_edge()

int dt_masks_solid_edge ( struct dt_masks_form_gui_points_t * gui_points,
const float * contour,
int header,
float cell )

The edge of the part of a stroke painted at full density, as closed loops.

The rasteriser paints every spoke solid from its spine sample to its contour sample, so the solid part is the union of the bands between neighbouring spokes. That union is filled on a grid of cell image pixels and its edge traced at half coverage.

Reads points and border_count of gui_points, and contour, index-aligned with points, their first header samples being node data. Writes fading, fading_count, fading_breaks and fading_break_count: every loop ends on its first point, and a zero-length break starts each loop but the first.

Returns
0 on success, an empty edge included; 1 when an allocation failed, nothing written.

Definition at line 649 of file masks_solid.c.

References _solid_band_signs(), _solid_count(), _solid_edges(), _solid_fill(), _solid_grid_fit(), _solid_spine(), _solid_trace(), bbox, dt_masks_form_gui_points_t::border_count, dt_alloc_align(), dt_calloc_align(), DT_DEBUG_MASKS, DT_DEBUG_PERF, dt_free_align, dt_get_debug_flags(), dt_get_wtime(), dt_print(), dt_masks_form_gui_points_t::fading_break_count, dt_masks_form_gui_points_t::fading_count, g, IS_NULL_PTR, MAX, n, dt_masks_form_gui_points_t::points, sign, SOLID_MAX_CROSSINGS, and SOLID_SUBLINES.

Referenced by _judge_fading_edge(), and dt_masks_gui_form_create().

Variable Documentation

◆ _corner_i

const int _corner_i[4] = { 0, 1, 1, 0 }
static

Definition at line 522 of file masks_solid.c.

Referenced by _solid_point(), and _solid_visit().

◆ _corner_j

const int _corner_j[4] = { 0, 0, 1, 1 }
static

Definition at line 523 of file masks_solid.c.

Referenced by _solid_point(), and _solid_visit().

◆ _step_i

const int _step_i[4] = { 0, 1, 0, -1 }
static

Definition at line 525 of file masks_solid.c.

Referenced by _solid_follow().

◆ _step_j

const int _step_j[4] = { -1, 0, 1, 0 }
static

Definition at line 526 of file masks_solid.c.

Referenced by _solid_follow().

◆ _visit_corner

const int _visit_corner[4] = { 0, 1, 3, 0 }
static

Definition at line 524 of file masks_solid.c.

Referenced by _solid_visit().