NovaSVG 0.10.0
A header-only SVG library
Loading...
Searching...
No Matches
private.h
Go to the documentation of this file.
1#pragma once
2
3#ifndef NOVASVG_PRIVATE_H
4#define NOVASVG_PRIVATE_H
5
6#include "render.h"
7
8namespace novasvg {
9namespace render {
10
11#if defined(_WIN32)
12
13} // namespace render
14} // namespace novasvg
15#include <windows.h>
16namespace novasvg {
17namespace render {
18
19typedef LONG ref_count_t;
20
21#define novasvg_init_reference(ob) ((ob)->ref_count = 1)
22#define novasvg_increment_reference(ob) (void)(ob && InterlockedIncrement(&(ob)->ref_count))
23#define novasvg_destroy_reference(ob) (ob && InterlockedDecrement(&(ob)->ref_count) == 0)
24#define novasvg_get_reference_count(ob) ((ob) ? InterlockedCompareExchange((LONG*)&(ob)->ref_count, 0, 0) : 0)
25
26#elif defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L && !defined(__STDC_NO_ATOMICS__)
27
28} // namespace render
29} // namespace novasvg
30#include <stdatomic.h>
31namespace novasvg {
32namespace render {
33
34typedef atomic_int ref_count_t;
35
36#define novasvg_init_reference(ob) atomic_init(&(ob)->ref_count, 1)
37#define novasvg_increment_reference(ob) (void)(ob && atomic_fetch_add(&(ob)->ref_count, 1))
38#define novasvg_destroy_reference(ob) (ob && atomic_fetch_sub(&(ob)->ref_count, 1) == 1)
39#define novasvg_get_reference_count(ob) ((ob) ? atomic_load(&(ob)->ref_count) : 0)
40
41#else
42
43typedef int ref_count_t;
44
45#define novasvg_init_reference(ob) ((ob)->ref_count = 1)
46#define novasvg_increment_reference(ob) (void)(ob && ++(ob)->ref_count)
47#define novasvg_destroy_reference(ob) (ob && --(ob)->ref_count == 0)
48#define novasvg_get_reference_count(ob) ((ob) ? (ob)->ref_count : 0)
49
50#endif
51
52struct surface {
54 float width;
55 float height;
56 int stride;
57 unsigned char* data;
58};
59
72
78
83
88
93
103
111
112typedef struct {
113 int x;
114 int len;
115 int y;
116 unsigned char coverage;
117} span_t;
118
119typedef struct {
120 struct {
122 int size;
124 } spans;
125
126 int x;
127 int y;
128 int w;
129 int h;
131
132typedef struct {
133 float offset;
134 struct {
135 float* data;
136 int size;
138 } array;
140
147
152
167
179
180void span_buffer_init(span_buffer_t* span_buffer);
181void span_buffer_init_rect(span_buffer_t* span_buffer, int x, int y, int width, int height);
182void span_buffer_reset(span_buffer_t* span_buffer);
183void span_buffer_destroy(span_buffer_t* span_buffer);
184void span_buffer_copy(span_buffer_t* span_buffer, const span_buffer_t* source);
185bool span_buffer_contains(const span_buffer_t* span_buffer, float x, float y);
186void span_buffer_extents(span_buffer_t* span_buffer, rect_t* extents);
187void span_buffer_intersect(span_buffer_t* span_buffer, const span_buffer_t* a, const span_buffer_t* b);
188
189void rasterize(span_buffer_t* span_buffer, const path_t* path, const matrix_t* matrix, const rect_t* clip_rect, const stroke_data_t* stroke_data, fill_rule_t winding);
190void blend(canvas_t* canvas, const span_buffer_t* span_buffer);
191void memfill32(unsigned int* dest, int length, unsigned int value);
192
193} // namespace render
194} // namespace novasvg
195
196#endif // NOVASVG_PRIVATE_H
void span_buffer_init_rect(span_buffer_t *span_buffer, int x, int y, int width, int height)
Definition rasterize.h:20
void span_buffer_init(span_buffer_t *span_buffer)
Definition rasterize.h:14
texture_type_t
Defines the type of texture, either plain or tiled.
Definition render.h:1294
struct novasvg::render::state state_t
line_join_t
Defines the shape used at the corners of paths.
Definition render.h:1464
fill_rule_t
Defines fill rule types for filling paths.
Definition render.h:1421
NOVASVG_INLINE void blend(canvas_t *canvas, const span_buffer_t *span_buffer)
Definition blend.h:1215
line_cap_t
Defines the shape used at the ends of open subpaths.
Definition render.h:1455
operator_t
Defines compositing operations.
Definition render.h:1429
void span_buffer_reset(span_buffer_t *span_buffer)
Definition rasterize.h:39
NOVASVG_INLINE void memfill32(unsigned int *dest, int length, unsigned int value)
Definition blend.h:164
void span_buffer_destroy(span_buffer_t *span_buffer)
Definition rasterize.h:48
void span_buffer_copy(span_buffer_t *span_buffer, const span_buffer_t *source)
Definition rasterize.h:53
void span_buffer_extents(span_buffer_t *span_buffer, rect_t *extents)
Definition rasterize.h:108
void span_buffer_intersect(span_buffer_t *span_buffer, const span_buffer_t *a, const span_buffer_t *b)
Definition rasterize.h:117
spread_method_t
Defines the spread method for gradients.
Definition render.h:1302
bool span_buffer_contains(const span_buffer_t *span_buffer, float x, float y)
Definition rasterize.h:63
@ NOVASVG_PAINT_TYPE_GRADIENT
Definition private.h:75
@ NOVASVG_PAINT_TYPE_TEXTURE
Definition private.h:76
@ NOVASVG_PAINT_TYPE_COLOR
Definition private.h:74
void rasterize(span_buffer_t *span_buffer, const path_t *path, const matrix_t *matrix, const rect_t *clip_rect, const stroke_data_t *stroke_data, fill_rule_t winding)
Definition rasterize.h:383
@ NOVASVG_GRADIENT_TYPE_LINEAR
Definition private.h:90
@ NOVASVG_GRADIENT_TYPE_RADIAL
Definition private.h:91
Main namespace for the NovaSVG library.
Definition bitmap.h:23
span_buffer_t fill_spans
Definition private.h:177
font_face_cache_t * face_cache
Definition private.h:174
span_buffer_t clip_spans
Definition private.h:176
surface_t * surface
Definition private.h:170
ref_count_t ref_count
Definition private.h:169
Represents a color with red, green, blue, and alpha components.
Definition render.h:1019
Represents a gradient stop.
Definition render.h:1311
A structure representing a 2D transformation matrix.
Definition render.h:138
paint_type_t type
Definition private.h:81
ref_count_t ref_count
Definition private.h:80
path_element_t * data
Definition private.h:67
ref_count_t ref_count
Definition private.h:61
struct novasvg::render::path::@11 elements
A structure representing a point in 2D space.
Definition render.h:114
A structure representing a rectangle in 2D space.
Definition render.h:125
unsigned char coverage
Definition private.h:116
span_buffer_t clip_spans
Definition private.h:159
fill_rule_t winding
Definition private.h:160
font_face_t * font_face
Definition private.h:155
stroke_data_t stroke
Definition private.h:158
struct state * next
Definition private.h:165
ref_count_t ref_count
Definition private.h:53
unsigned char * data
Definition private.h:57