w32tex
About: TeX Live provides a comprehensive TeX system including all the major TeX-related programs, macro packages, and fonts that are free software. Windows sources.
  Fossies Dox: w32tex-src.tar.xz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

cairo-tor-scan-converter.c File Reference
#include "cairoint.h"
#include "cairo-spans-private.h"
#include "cairo-error-private.h"
#include <stdlib.h>
#include <string.h>
#include <limits.h>
#include <setjmp.h>
Include dependency graph for cairo-tor-scan-converter.c:

Go to the source code of this file.

Classes

struct  quorem
 
struct  _pool_chunk
 
struct  pool
 
struct  edge
 
struct  polygon
 
struct  cell
 
struct  cell_list
 
struct  cell_pair
 
struct  active_list
 
struct  glitter_scan_converter
 
struct  _cairo_tor_scan_converter
 

Macros

#define I   static
 
#define GLITTER_HAVE_STATUS_T   1
 
#define GLITTER_STATUS_SUCCESS   CAIRO_STATUS_SUCCESS
 
#define GLITTER_STATUS_NO_MEMORY   CAIRO_STATUS_NO_MEMORY
 
#define GLITTER_INPUT_BITS   CAIRO_FIXED_FRAC_BITS
 
#define GRID_X_BITS   CAIRO_FIXED_FRAC_BITS
 
#define GRID_Y   15
 
#define GLITTER_INPUT_SCALE   (1<<GLITTER_INPUT_BITS)
 
#define GRID_X   (1 << GRID_X_BITS)
 
#define GRID_X_TO_INT_FRAC(x, i, f)    _GRID_TO_INT_FRAC_shift(x, i, f, GRID_X_BITS)
 
#define _GRID_TO_INT_FRAC_general(t, i, f, m)
 
#define _GRID_TO_INT_FRAC_shift(t, i, f, b)
 
#define GRID_XY   (2*GRID_X*GRID_Y) /* Unit area on the grid. */
 
#define GRID_AREA_TO_ALPHA(c)   (((c) + ((c)<<4) + 256) >> 9)
 
#define UNROLL3(x)   x x x
 
#define SIZEOF_POOL_CHUNK   (sizeof(struct _pool_chunk) - sizeof(int64_t))
 
#define EDGE_Y_BUCKET_INDEX(y, ymin)   (((y) - (ymin))/GRID_Y)
 
#define int_to_grid_scaled_x(x)   int_to_grid_scaled((x), GRID_X)
 
#define int_to_grid_scaled_y(x)   int_to_grid_scaled((x), GRID_Y)
 
#define INPUT_TO_GRID_Y(in, out)   INPUT_TO_GRID_general(in, out, GRID_Y)
 
#define INPUT_TO_GRID_X(in, out)   (out) = (in) >> (GLITTER_INPUT_BITS - GRID_X_BITS)
 
#define INPUT_TO_GRID_general(in, out, grid_scale)
 
#define GRID_AREA_TO_A1(A)   ((GRID_AREA_TO_ALPHA (A) > 127) ? 255 : 0)
 

Typedefs

typedef cairo_status_t glitter_status_t
 
typedef int glitter_input_scaled_t
 
typedef struct glitter_scan_converter glitter_scan_converter_t
 
typedef int grid_scaled_t
 
typedef int grid_scaled_x_t
 
typedef int grid_scaled_y_t
 
typedef struct _cairo_tor_scan_converter cairo_tor_scan_converter_t
 

Functions

static glitter_status_t glitter_scan_converter_reset (glitter_scan_converter_t *converter, int xmin, int ymin, int xmax, int ymax)
 
static struct _pool_chunk_pool_chunk_init (struct _pool_chunk *p, struct _pool_chunk *prev_chunk, size_t capacity)
 
static struct _pool_chunk_pool_chunk_create (struct pool *pool, size_t size)
 
static void pool_init (struct pool *pool, jmp_buf *jmp, size_t default_capacity, size_t embedded_capacity)
 
static void pool_fini (struct pool *pool)
 
static void_pool_alloc_from_new_chunk (struct pool *pool, size_t size)
 
static voidpool_alloc (struct pool *pool, size_t size)
 
static void pool_reset (struct pool *pool)
 
static void cell_list_rewind (struct cell_list *cells)
 
static void cell_list_maybe_rewind (struct cell_list *cells, int x)
 
static void cell_list_set_rewind (struct cell_list *cells)
 
static void cell_list_init (struct cell_list *cells, jmp_buf *jmp)
 
static void cell_list_fini (struct cell_list *cells)
 
static void cell_list_reset (struct cell_list *cells)
 
static struct cellcell_list_alloc (struct cell_list *cells, struct cell *tail, int x)
 
static struct cellcell_list_find (struct cell_list *cells, int x)
 
static struct cell_pair cell_list_find_pair (struct cell_list *cells, int x1, int x2)
 
static void cell_list_add_subspan (struct cell_list *cells, grid_scaled_x_t x1, grid_scaled_x_t x2)
 
static void full_step (struct edge *e)
 
static void cell_list_render_edge (struct cell_list *cells, struct edge *edge, int sign)
 
static void polygon_init (struct polygon *polygon, jmp_buf *jmp)
 
static void polygon_fini (struct polygon *polygon)
 
static glitter_status_t polygon_reset (struct polygon *polygon, grid_scaled_y_t ymin, grid_scaled_y_t ymax)
 
static void _polygon_insert_edge_into_its_y_bucket (struct polygon *polygon, struct edge *e)
 
static void active_list_reset (struct active_list *active)
 
static void active_list_init (struct active_list *active)
 
static struct edgemerge_sorted_edges (struct edge *head_a, struct edge *head_b)
 
static struct edgesort_edges (struct edge *list, unsigned int level, struct edge **head_out)
 
static struct edgemerge_unsorted_edges (struct edge *head, struct edge *unsorted)
 
static int can_do_full_row (struct active_list *active)
 
static void active_list_merge_edges_from_bucket (struct active_list *active, struct edge *edges)
 
static int polygon_fill_buckets (struct active_list *active, struct edge *edge, int y, struct edge **buckets)
 
static void step (struct edge *edge)
 
static void sub_row (struct active_list *active, struct cell_list *coverages, unsigned int mask)
 
static void dec (struct active_list *a, struct edge *e, int h)
 
static void full_row (struct active_list *active, struct cell_list *coverages, unsigned int mask)
 
static void _glitter_scan_converter_init (glitter_scan_converter_t *converter, jmp_buf *jmp)
 
static void _glitter_scan_converter_fini (glitter_scan_converter_t *self)
 
static grid_scaled_t int_to_grid_scaled (int i, int scale)
 
static void polygon_add_edge (struct polygon *polygon, const cairo_edge_t *edge)
 
static void glitter_scan_converter_add_edge (glitter_scan_converter_t *converter, const cairo_edge_t *edge)
 
static void step_edges (struct active_list *active, int count)
 
static glitter_status_t blit_a8 (struct cell_list *cells, cairo_span_renderer_t *renderer, cairo_half_open_span_t *spans, int y, int height, int xmin, int xmax)
 
static glitter_status_t blit_a1 (struct cell_list *cells, cairo_span_renderer_t *renderer, cairo_half_open_span_t *spans, int y, int height, int xmin, int xmax)
 
static void glitter_scan_converter_render (glitter_scan_converter_t *converter, unsigned int winding_mask, int antialias, cairo_span_renderer_t *renderer)
 
static void _cairo_tor_scan_converter_destroy (void *converter)
 
cairo_status_t _cairo_tor_scan_converter_add_polygon (void *converter, const cairo_polygon_t *polygon)
 
static cairo_status_t _cairo_tor_scan_converter_generate (void *converter, cairo_span_renderer_t *renderer)
 
cairo_scan_converter_t_cairo_tor_scan_converter_create (int xmin, int ymin, int xmax, int ymax, cairo_fill_rule_t fill_rule, cairo_antialias_t antialias)
 

Macro Definition Documentation

◆ _GRID_TO_INT_FRAC_general

#define _GRID_TO_INT_FRAC_general (   t,
  i,
  f,
  m 
)
Value:
do { \
(i) = (t) / (m); \
(f) = (t) % (m); \
if ((f) < 0) { \
--(i); \
(f) += (m); \
} \
} while (0)
mpz_t * f
Definition: gen-fib.c:34
small capitals from c petite p scientific i
Definition: afcover.h:80
Definition: dvips.h:235
m
Definition: tex4ht.c:3990

Definition at line 221 of file cairo-tor-scan-converter.c.

◆ _GRID_TO_INT_FRAC_shift

#define _GRID_TO_INT_FRAC_shift (   t,
  i,
  f,
  b 
)
Value:
do { \
(f) = (t) & ((1 << (b)) - 1); \
(i) = (t) >> (b); \
} while (0)
#define b
Definition: jpegint.h:372

Definition at line 230 of file cairo-tor-scan-converter.c.

◆ EDGE_Y_BUCKET_INDEX

#define EDGE_Y_BUCKET_INDEX (   y,
  ymin 
)    (((y) - (ymin))/GRID_Y)

Definition at line 350 of file cairo-tor-scan-converter.c.

◆ GLITTER_HAVE_STATUS_T

#define GLITTER_HAVE_STATUS_T   1

Definition at line 111 of file cairo-tor-scan-converter.c.

◆ GLITTER_INPUT_BITS

#define GLITTER_INPUT_BITS   CAIRO_FIXED_FRAC_BITS

Definition at line 117 of file cairo-tor-scan-converter.c.

◆ GLITTER_INPUT_SCALE

#define GLITTER_INPUT_SCALE   (1<<GLITTER_INPUT_BITS)

Definition at line 139 of file cairo-tor-scan-converter.c.

◆ GLITTER_STATUS_NO_MEMORY

#define GLITTER_STATUS_NO_MEMORY   CAIRO_STATUS_NO_MEMORY

Definition at line 113 of file cairo-tor-scan-converter.c.

◆ GLITTER_STATUS_SUCCESS

#define GLITTER_STATUS_SUCCESS   CAIRO_STATUS_SUCCESS

Definition at line 112 of file cairo-tor-scan-converter.c.

◆ GRID_AREA_TO_A1

#define GRID_AREA_TO_A1 (   A)    ((GRID_AREA_TO_ALPHA (A) > 127) ? 255 : 0)

Definition at line 1646 of file cairo-tor-scan-converter.c.

◆ GRID_AREA_TO_ALPHA

#define GRID_AREA_TO_ALPHA (   c)    (((c) + ((c)<<4) + 256) >> 9)

Definition at line 256 of file cairo-tor-scan-converter.c.

◆ GRID_X

#define GRID_X   (1 << GRID_X_BITS)

Definition at line 203 of file cairo-tor-scan-converter.c.

◆ GRID_X_BITS

#define GRID_X_BITS   CAIRO_FIXED_FRAC_BITS

Definition at line 118 of file cairo-tor-scan-converter.c.

◆ GRID_X_TO_INT_FRAC

#define GRID_X_TO_INT_FRAC (   x,
  i,
  f 
)     _GRID_TO_INT_FRAC_shift(x, i, f, GRID_X_BITS)

Definition at line 214 of file cairo-tor-scan-converter.c.

◆ GRID_XY

#define GRID_XY   (2*GRID_X*GRID_Y) /* Unit area on the grid. */

Definition at line 240 of file cairo-tor-scan-converter.c.

◆ GRID_Y

#define GRID_Y   15

Definition at line 119 of file cairo-tor-scan-converter.c.

◆ I

#define I   static

Definition at line 108 of file cairo-tor-scan-converter.c.

◆ INPUT_TO_GRID_general

#define INPUT_TO_GRID_general (   in,
  out,
  grid_scale 
)
Value:
do { \
long long tmp__ = (long long)(grid_scale) * (in); \
tmp__ += 1 << (GLITTER_INPUT_BITS-1); \
tmp__ >>= GLITTER_INPUT_BITS; \
(out) = tmp__; \
} while (0)
#define GLITTER_INPUT_BITS
FILE * out
Definition: hbf2gf.c:286
static FILE * in
Definition: squeeze.c:36

Definition at line 1458 of file cairo-tor-scan-converter.c.

◆ INPUT_TO_GRID_X

#define INPUT_TO_GRID_X (   in,
  out 
)    (out) = (in) >> (GLITTER_INPUT_BITS - GRID_X_BITS)

Definition at line 1453 of file cairo-tor-scan-converter.c.

◆ INPUT_TO_GRID_Y

#define INPUT_TO_GRID_Y (   in,
  out 
)    INPUT_TO_GRID_general(in, out, GRID_Y)

Definition at line 1449 of file cairo-tor-scan-converter.c.

◆ int_to_grid_scaled_x

#define int_to_grid_scaled_x (   x)    int_to_grid_scaled((x), GRID_X)

Definition at line 1396 of file cairo-tor-scan-converter.c.

◆ int_to_grid_scaled_y

#define int_to_grid_scaled_y (   x)    int_to_grid_scaled((x), GRID_Y)

Definition at line 1397 of file cairo-tor-scan-converter.c.

◆ SIZEOF_POOL_CHUNK

#define SIZEOF_POOL_CHUNK   (sizeof(struct _pool_chunk) - sizeof(int64_t))

Definition at line 286 of file cairo-tor-scan-converter.c.

◆ UNROLL3

#define UNROLL3 (   x)    x x x

Definition at line 261 of file cairo-tor-scan-converter.c.

Typedef Documentation

◆ cairo_tor_scan_converter_t

◆ glitter_input_scaled_t

Definition at line 140 of file cairo-tor-scan-converter.c.

◆ glitter_scan_converter_t

◆ glitter_status_t

Definition at line 114 of file cairo-tor-scan-converter.c.

◆ grid_scaled_t

typedef int grid_scaled_t

Definition at line 187 of file cairo-tor-scan-converter.c.

◆ grid_scaled_x_t

Definition at line 188 of file cairo-tor-scan-converter.c.

◆ grid_scaled_y_t

Definition at line 189 of file cairo-tor-scan-converter.c.

Function Documentation

◆ _cairo_tor_scan_converter_add_polygon()

cairo_status_t _cairo_tor_scan_converter_add_polygon ( void converter,
const cairo_polygon_t polygon 
)

Definition at line 1829 of file cairo-tor-scan-converter.c.

◆ _cairo_tor_scan_converter_create()

cairo_scan_converter_t* _cairo_tor_scan_converter_create ( int  xmin,
int  ymin,
int  xmax,
int  ymax,
cairo_fill_rule_t  fill_rule,
cairo_antialias_t  antialias 
)

Definition at line 1865 of file cairo-tor-scan-converter.c.

◆ _cairo_tor_scan_converter_destroy()

static void _cairo_tor_scan_converter_destroy ( void converter)
static

◆ _cairo_tor_scan_converter_generate()

◆ _glitter_scan_converter_fini()

static void _glitter_scan_converter_fini ( glitter_scan_converter_t self)
static

Definition at line 1367 of file cairo-tor-scan-converter.c.

References cell_list_fini(), free, and polygon_fini().

Referenced by _cairo_tor_scan_converter_destroy().

◆ _glitter_scan_converter_init()

◆ _polygon_insert_edge_into_its_y_bucket()

static void _polygon_insert_edge_into_its_y_bucket ( struct polygon polygon,
struct edge e 
)
static

Definition at line 990 of file cairo-tor-scan-converter.c.

References e, EDGE_Y_BUCKET_INDEX, polygon::y_buckets, and polygon::ymin.

Referenced by polygon_add_edge().

◆ _pool_alloc_from_new_chunk()

static void* _pool_alloc_from_new_chunk ( struct pool pool,
size_t  size 
)
static

◆ _pool_chunk_create()

static struct _pool_chunk* _pool_chunk_create ( struct pool pool,
size_t  size 
)
static

◆ _pool_chunk_init()

static struct _pool_chunk* _pool_chunk_init ( struct _pool_chunk p,
struct _pool_chunk prev_chunk,
size_t  capacity 
)
static

Definition at line 470 of file cairo-tor-scan-converter.c.

References capacity, p, and prev_chunk.

Referenced by _pool_alloc_from_new_chunk(), _pool_chunk_create(), and pool_init().

◆ active_list_init()

static void active_list_init ( struct active_list active)
static

Definition at line 1017 of file cairo-tor-scan-converter.c.

References active, and active_list_reset().

Referenced by _glitter_scan_converter_init().

◆ active_list_merge_edges_from_bucket()

static void active_list_merge_edges_from_bucket ( struct active_list active,
struct edge edges 
)
inlinestatic

Definition at line 1203 of file cairo-tor-scan-converter.c.

References active, and merge_unsorted_edges().

◆ active_list_reset()

static void active_list_reset ( struct active_list active)
static

Definition at line 1000 of file cairo-tor-scan-converter.c.

References active, INT_MAX, INT_MIN, and NULL.

Referenced by active_list_init(), and glitter_scan_converter_reset().

◆ blit_a1()

◆ blit_a8()

◆ can_do_full_row()

static int can_do_full_row ( struct active_list active)
inlinestatic

Definition at line 1146 of file cairo-tor-scan-converter.c.

References active, e, GRID_Y, INT_MAX, INT_MIN, is_vertical(), NULL, prev_x, and cordic::x.

◆ cell_list_add_subspan()

static void cell_list_add_subspan ( struct cell_list cells,
grid_scaled_x_t  x1,
grid_scaled_x_t  x2 
)
inlinestatic

◆ cell_list_alloc()

static struct cell* cell_list_alloc ( struct cell_list cells,
struct cell tail,
int  x 
)
inlinestatic

◆ cell_list_find()

static struct cell* cell_list_find ( struct cell_list cells,
int  x 
)
inlinestatic

◆ cell_list_find_pair()

static struct cell_pair cell_list_find_pair ( struct cell_list cells,
int  x1,
int  x2 
)
inlinestatic

Definition at line 671 of file cairo-tor-scan-converter.c.

Referenced by cell_list_add_subspan(), and cell_list_render_edge().

◆ cell_list_fini()

static void cell_list_fini ( struct cell_list cells)
static

◆ cell_list_init()

static void cell_list_init ( struct cell_list cells,
jmp_buf *  jmp 
)
static

◆ cell_list_maybe_rewind()

static void cell_list_maybe_rewind ( struct cell_list cells,
int  x 
)
inlinestatic

Definition at line 605 of file cairo-tor-scan-converter.c.

References cell_list::cursor, and cell_list::rewind.

Referenced by cell_list_render_edge().

◆ cell_list_render_edge()

◆ cell_list_reset()

static void cell_list_reset ( struct cell_list cells)
inlinestatic

◆ cell_list_rewind()

static void cell_list_rewind ( struct cell_list cells)
inlinestatic

Definition at line 599 of file cairo-tor-scan-converter.c.

References cell_list::cursor.

Referenced by cell_list_init(), cell_list_reset(), and sub_row().

◆ cell_list_set_rewind()

static void cell_list_set_rewind ( struct cell_list cells)
inlinestatic

Definition at line 615 of file cairo-tor-scan-converter.c.

References cell_list::cursor, and cell_list::rewind.

Referenced by full_row().

◆ dec()

static void dec ( struct active_list a,
struct edge e,
int  h 
)
inlinestatic

Definition at line 1309 of file cairo-tor-scan-converter.c.

References a, e, and h.

Referenced by full_row().

◆ full_row()

static void full_row ( struct active_list active,
struct cell_list coverages,
unsigned int  mask 
)
static

◆ full_step()

static void full_step ( struct edge e)
inlinestatic

Definition at line 758 of file cairo-tor-scan-converter.c.

References e.

Referenced by cell_list_render_edge(), and full_row().

◆ glitter_scan_converter_add_edge()

static void glitter_scan_converter_add_edge ( glitter_scan_converter_t converter,
const cairo_edge_t edge 
)
static

◆ glitter_scan_converter_render()

static void glitter_scan_converter_render ( glitter_scan_converter_t converter,
unsigned int  winding_mask,
int  antialias,
cairo_span_renderer_t renderer 
)
static

Definition at line 1717 of file cairo-tor-scan-converter.c.

Referenced by _cairo_tor_scan_converter_generate().

◆ glitter_scan_converter_reset()

◆ int_to_grid_scaled()

static grid_scaled_t int_to_grid_scaled ( int  i,
int  scale 
)
static

Definition at line 1382 of file cairo-tor-scan-converter.c.

References i, INT_MAX, INT_MIN, and scale.

◆ merge_sorted_edges()

static struct edge* merge_sorted_edges ( struct edge head_a,
struct edge head_b 
)
static

Definition at line 1041 of file cairo-tor-scan-converter.c.

References edge::cell, head, edge::next, next, NULL, prev, edge::prev, and cordic::x.

Referenced by merge_unsorted_edges(), and sort_edges().

◆ merge_unsorted_edges()

static struct edge* merge_unsorted_edges ( struct edge head,
struct edge unsorted 
)
static

◆ polygon_add_edge()

◆ polygon_fill_buckets()

static int polygon_fill_buckets ( struct active_list active,
struct edge edge,
int  y,
struct edge **  buckets 
)
inlinestatic

◆ polygon_fini()

static void polygon_fini ( struct polygon polygon)
static

◆ polygon_init()

static void polygon_init ( struct polygon polygon,
jmp_buf *  jmp 
)
static

◆ polygon_reset()

◆ pool_alloc()

static void* pool_alloc ( struct pool pool,
size_t  size 
)
inlinestatic

◆ pool_fini()

static void pool_fini ( struct pool pool)
static

Definition at line 507 of file cairo-tor-scan-converter.c.

References pool::current, pool::first_free, free, NULL, p, prev, and pool::sentinel.

Referenced by cell_list_fini(), and polygon_fini().

◆ pool_init()

static void pool_init ( struct pool pool,
jmp_buf *  jmp,
size_t  default_capacity,
size_t  embedded_capacity 
)
static

◆ pool_reset()

static void pool_reset ( struct pool pool)
static

◆ sort_edges()

static struct edge* sort_edges ( struct edge list,
unsigned int  level,
struct edge **  head_out 
)
static

◆ step()

static void step ( struct edge edge)
static

Definition at line 1241 of file cairo-tor-scan-converter.c.

References edge::cell, edge::dxdy, edge::dy, quorem::quo, quorem::rem, and edge::x.

Referenced by __gmpz_hamdist(), _cairo_arc_in_direction(), _cairo_hash_table_lookup(), _cairo_hash_table_lookup_exact_key(), _cairo_hash_table_lookup_unique_key(), _cairo_hash_table_random_entry(), _cairo_stroker_dash_step(), _findSameDataBlock(), _lzw_symbol_table_lookup(), _range_step(), add_fan(), apply_stch(), block_resieve(), BrotliOptimizeHuffmanCountsForRle(), BrotliTransformDictionaryWord(), hb_hashmap_t< K, V, kINVALID, vINVALID >::bucket_for_hash(), ccbaReadStream(), coerce_step_counter(), create_1d_filter(), crec_copy(), crec_copy_unroll(), crec_fill(), crec_fill_unroll(), Collation::decThreeBytePrimaryByOneStep(), Collation::decTwoBytePrimaryByOneStep(), do_dvi_pages(), do_mps_pages(), do_translation(), fdotcurvdist2(), PSOutputDev::filterPSLabel(), first_block_primesieve(), fix_expand_value(), font_from_lua(), font_to_lua(), forlimit(), gen_hex_dump(), geojson_curveto(), get_file(), get_filter(), CollationRootElements::getPrimaryAfter(), CollationRootElements::getPrimaryBefore(), gmp_snprintf_format(), gssentry(), graphite2::Segment::justify(), learn(), lj_opt_narrow_forl(), lj_str_new(), lookup(), luaS_hash(), luaS_newlstr(), luaV_execute(), magstep(), CollationDataBuilder::maybeSetPrimaryRange(), mrb_debug_get_line(), png_do_encode_alpha(), png_image_read_colormap(), DVIToSVGActions::progress(), range_step(), rec_for_check(), rec_for_loop(), recff_ffi_fill(), sendraw(), setParaRunsOnly(), CollationDataBuilder::setPrimaryRangeAndReturnNext(), GfxUnivariateShading::setupCache(), shapeUnicode(), sub_row(), u_shapeArabic_68(), and unpack_q().

◆ step_edges()

static void step_edges ( struct active_list active,
int  count 
)
static

◆ sub_row()

static void sub_row ( struct active_list active,
struct cell_list coverages,
unsigned int  mask 
)
inlinestatic