Ansel 0.0
A darktable fork - bloat + design vision
Loading...
Searching...
No Matches
stroke_raster.c File Reference
#include "widgets/stroke_raster.h"
#include <float.h>
#include <limits.h>
#include <math.h>
#include <stdint.h>
#include <string.h>
+ Include dependency graph for stroke_raster.c:

Go to the source code of this file.

Data Structures

struct  _touched_t
 
struct  _scratch_t
 
struct  _plane_t
 
struct  _segment_t
 
struct  _dash_t
 
struct  _composite_t
 
struct  _gather_t
 

Typedefs

typedef struct _touched_t _touched_t
 
typedef struct _scratch_t _scratch_t
 
typedef struct _plane_t _plane_t
 
typedef struct _segment_t _segment_t
 
typedef struct _dash_t _dash_t
 
typedef struct _composite_t _composite_t
 
typedef struct _gather_t _gather_t
 

Functions

static _touched_t_touched_of (cairo_surface_t *surface, const gboolean create)
 
static void _touched_add (cairo_surface_t *surface, const int x0, const int y0, const int x1, const int y1)
 
gboolean dt_stroke_raster_touched (cairo_surface_t *surface, cairo_rectangle_int_t *touched)
 
void dt_stroke_raster_touched_reset (cairo_surface_t *surface)
 
gboolean dt_stroke_raster_can_paint (cairo_surface_t *surface)
 
static void _scratch_free (void *data)
 
static _scratch_t_scratch_of (cairo_surface_t *surface)
 
static gboolean _plane_acquire (cairo_surface_t *surface, _plane_t *plane, const int x0, const int y0, const int width, const int height)
 
static gboolean _plane_stamp_row (_plane_t *const plane, const int y, const int x_first, const int x_last, const _segment_t *const seg, const double reach2)
 
static void _plane_stamp_capsule (_plane_t *const plane, const _segment_t *const seg, const double reach)
 
static void _plane_stamp_dashed (_plane_t *const plane, const _segment_t *const seg, const dt_stroke_style_t *style, const double reach, _dash_t *const dash)
 
static void _polyline_stamp (_plane_t *const plane, const double *xy, const int count, const dt_stroke_style_t *style, const double reach, const gboolean closed, _dash_t *const dash)
 
static _dash_t _dash_start (const dt_stroke_style_t *const style)
 
static uint32_t _pixel_pack (const double a, const double r, const double g, const double b)
 
static void _pixel_over (uint32_t *const pixel, const dt_stroke_pass_t *const pass, const double coverage)
 
static gboolean _composite_row (const _plane_t *const plane, const int y, const _composite_t *const c, int *const tx0, int *const tx1)
 
static void _plane_composite_and_clear (_plane_t *const plane, cairo_surface_t *surface, const dt_stroke_style_t *style, const double reach)
 
static gboolean _stroke_polyline (cairo_surface_t *surface, const double *xy, const int count, const dt_stroke_style_t *style, const gboolean closed, _dash_t *const dash)
 
gboolean dt_stroke_raster_polyline (cairo_surface_t *surface, const double *xy, int count, const dt_stroke_style_t *style)
 
static double _matrix_scale (cairo_t *cr)
 
static void _gather_flush (_gather_t *const g, cairo_surface_t *surface, const dt_stroke_style_t *style, _dash_t *const dash)
 
static void _gather_point (_gather_t *const g, cairo_t *cr, const cairo_path_data_t *const point)
 
gboolean dt_stroke_raster_path (cairo_t *cr, const dt_stroke_style_t *style)
 

Variables

static const cairo_user_data_key_t _touched_key = { 0 }
 
static const cairo_user_data_key_t _scratch_key = { 0 }
 

Typedef Documentation

◆ _composite_t

typedef struct _composite_t _composite_t

◆ _dash_t

typedef struct _dash_t _dash_t

◆ _gather_t

typedef struct _gather_t _gather_t

◆ _plane_t

typedef struct _plane_t _plane_t

◆ _scratch_t

typedef struct _scratch_t _scratch_t

◆ _segment_t

typedef struct _segment_t _segment_t

◆ _touched_t

typedef struct _touched_t _touched_t

Function Documentation

◆ _composite_row()

static gboolean _composite_row ( const _plane_t *const  plane,
const int  y,
const _composite_t *const  c,
int *const  tx0,
int *const  tx1 
)
inlinestatic

◆ _dash_start()

static _dash_t _dash_start ( const dt_stroke_style_t *const  style)
static

Definition at line 364 of file stroke_raster.c.

References dt_stroke_style_t::dash_on, _dash_t::on, and TRUE.

Referenced by dt_stroke_raster_path(), and dt_stroke_raster_polyline().

◆ _gather_flush()

static void _gather_flush ( _gather_t *const  g,
cairo_surface_t *  surface,
const dt_stroke_style_t style,
_dash_t *const  dash 
)
static

Definition at line 567 of file stroke_raster.c.

References _stroke_polyline(), FALSE, and g.

Referenced by dt_stroke_raster_path().

◆ _gather_point()

static void _gather_point ( _gather_t *const  g,
cairo_t *  cr,
const cairo_path_data_t *const  point 
)
static

Definition at line 576 of file stroke_raster.c.

References g, x, point::x, and point::y.

Referenced by dt_stroke_raster_path().

◆ _matrix_scale()

static double _matrix_scale ( cairo_t *  cr)
static

Definition at line 533 of file stroke_raster.c.

Referenced by dt_stroke_raster_path().

◆ _pixel_over()

static void _pixel_over ( uint32_t *const  pixel,
const dt_stroke_pass_t *const  pass,
const double  coverage 
)
inlinestatic

◆ _pixel_pack()

static uint32_t _pixel_pack ( const double  a,
const double  r,
const double  g,
const double  b 
)
inlinestatic

Definition at line 390 of file stroke_raster.c.

References g, and r.

Referenced by _pixel_over().

◆ _plane_acquire()

static gboolean _plane_acquire ( cairo_surface_t *  surface,
_plane_t plane,
const int  x0,
const int  y0,
const int  width,
const int  height 
)
static

◆ _plane_composite_and_clear()

static void _plane_composite_and_clear ( _plane_t *const  plane,
cairo_surface_t *  surface,
const dt_stroke_style_t style,
const double  reach 
)
static

◆ _plane_stamp_capsule()

static void _plane_stamp_capsule ( _plane_t *const  plane,
const _segment_t *const  seg,
const double  reach 
)
inlinestatic

◆ _plane_stamp_dashed()

static void _plane_stamp_dashed ( _plane_t *const  plane,
const _segment_t *const  seg,
const dt_stroke_style_t style,
const double  reach,
_dash_t *const  dash 
)
static

◆ _plane_stamp_row()

static gboolean _plane_stamp_row ( _plane_t *const  plane,
const int  y,
const int  x_first,
const int  x_last,
const _segment_t *const  seg,
const double  reach2 
)
inlinestatic

◆ _polyline_stamp()

static void _polyline_stamp ( _plane_t *const  plane,
const double xy,
const int  count,
const dt_stroke_style_t style,
const double  reach,
const gboolean  closed,
_dash_t *const  dash 
)
static

◆ _scratch_free()

static void _scratch_free ( void data)
static

Definition at line 134 of file stroke_raster.c.

References _scratch_t::span_max, _scratch_t::span_min, and _scratch_t::value.

Referenced by _scratch_of().

◆ _scratch_of()

static _scratch_t * _scratch_of ( cairo_surface_t *  surface)
static

Definition at line 144 of file stroke_raster.c.

References _scratch_free(), and _scratch_key.

Referenced by _plane_acquire().

◆ _stroke_polyline()

static gboolean _stroke_polyline ( cairo_surface_t *  surface,
const double xy,
const int  count,
const dt_stroke_style_t style,
const gboolean  closed,
_dash_t *const  dash 
)
static

◆ _touched_add()

static void _touched_add ( cairo_surface_t *  surface,
const int  x0,
const int  y0,
const int  x1,
const int  y1 
)
static

◆ _touched_of()

static _touched_t * _touched_of ( cairo_surface_t *  surface,
const gboolean  create 
)
static

Definition at line 49 of file stroke_raster.c.

References _touched_key.

Referenced by _touched_add(), dt_stroke_raster_touched(), and dt_stroke_raster_touched_reset().

◆ dt_stroke_raster_can_paint()

gboolean dt_stroke_raster_can_paint ( cairo_surface_t *  surface)

Is surface something this rasteriser can paint into: an ARGB32 image surface.

Definition at line 101 of file stroke_raster.c.

Referenced by dt_stroke_raster_path(), and dt_stroke_raster_polyline().

◆ dt_stroke_raster_path()

gboolean dt_stroke_raster_path ( cairo_t *  cr,
const dt_stroke_style_t style 
)

Stroke the current path of cr with style, then consume the path, as a pair of cairo_stroke() calls would. The path is flattened and mapped through cr's matrix into the pixels of the surface cr is drawing on – the current group's, if one is pushed – and the style's widths and dashes, given in USER units as the cairo calls receive them, are mapped through the same matrix. Returns FALSE, leaving the path in place, when that surface is not one this can paint into; the caller then strokes it with cairo instead.

Definition at line 592 of file stroke_raster.c.

References _dash_start(), _gather_flush(), _gather_point(), _matrix_scale(), dt_stroke_style_t::bright, _gather_t::closed, dt_stroke_style_t::dark, dt_stroke_style_t::dash_off, dt_stroke_style_t::dash_on, dt_stroke_raster_can_paint(), FALSE, _gather_t::first_x, _gather_t::first_y, i, _gather_t::offset_x, _gather_t::offset_y, _gather_t::scale_x, _gather_t::scale_y, TRUE, _gather_t::vertices, and dt_stroke_pass_t::width.

Referenced by _a_device_scaled_surface_is_painted_in_its_pixels(), _a_path_in_a_pushed_group_lands_where_cairo_puts_it(), _a_surface_it_cannot_write_is_refused_and_the_path_kept(), _the_matrix_scales_widths_and_positions(), and dt_draw_shape_lines().

◆ dt_stroke_raster_polyline()

gboolean dt_stroke_raster_polyline ( cairo_surface_t *  surface,
const double xy,
int  count,
const dt_stroke_style_t style 
)

Stroke count device-space vertices (x, y pairs, in the pixel grid of surface) as one open polyline into surface. The style's widths and dashes are device pixels. Returns FALSE, having painted nothing, when the surface is not one this can paint into (see dt_stroke_raster_can_paint()) or when there is nothing to draw.

Definition at line 523 of file stroke_raster.c.

References _dash_start(), _stroke_polyline(), dt_stroke_raster_can_paint(), and FALSE.

Referenced by _a_horizontal_line_paints_a_band_of_its_width(), _dashes_leave_gaps_along_the_line(), _flat_caps_stop_at_the_ends(), _the_bright_pass_paints_over_the_dark_one(), and _the_touched_record_resets().

◆ dt_stroke_raster_touched()

gboolean dt_stroke_raster_touched ( cairo_surface_t *  surface,
cairo_rectangle_int_t *  touched 
)

The pixel rectangle everything painted into surface through this file has touched since the last reset, so a caller can composite or clear that much and no more. Returns FALSE when nothing was painted.

Definition at line 82 of file stroke_raster.c.

References _touched_of(), _touched_t::any, FALSE, TRUE, _touched_t::x0, _touched_t::x1, _touched_t::y0, and _touched_t::y1.

Referenced by _a_horizontal_line_paints_a_band_of_its_width(), _overlay_dirty(), and _the_touched_record_resets().

◆ dt_stroke_raster_touched_reset()

void dt_stroke_raster_touched_reset ( cairo_surface_t *  surface)

Forget the touched rectangle of surface.

Definition at line 94 of file stroke_raster.c.

References _touched_of(), _touched_t::any, and FALSE.

Referenced by _canvas_begin(), and _the_touched_record_resets().

Variable Documentation

◆ _scratch_key

const cairo_user_data_key_t _scratch_key = { 0 }
static

Definition at line 132 of file stroke_raster.c.

Referenced by _scratch_of().

◆ _touched_key

const cairo_user_data_key_t _touched_key = { 0 }
static

Definition at line 47 of file stroke_raster.c.

Referenced by _touched_of().