summaryrefslogtreecommitdiff
path: root/kicad
diff options
context:
space:
mode:
authorWerner Almesberger <werner@almesberger.net>2016-08-24 14:07:45 -0300
committerWerner Almesberger <werner@almesberger.net>2016-08-24 14:19:21 -0300
commitbd9943d473ab96c5d37b0944ed33a1f6766d62e5 (patch)
tree59f27d8fa71f981928293bc8e55e7c0415d08db2 /kicad
parentc58e2ecd39de8f433c787a8feb558509e664ac88 (diff)
downloadeeshow-bd9943d473ab96c5d37b0944ed33a1f6766d62e5.tar.gz
eeshow-bd9943d473ab96c5d37b0944ed33a1f6766d62e5.tar.bz2
eeshow-bd9943d473ab96c5d37b0944ed33a1f6766d62e5.zip
remove global gfx state (pass context as argument)
Diffstat (limited to 'kicad')
-rw-r--r--kicad/dwg.c94
-rw-r--r--kicad/dwg.h21
-rw-r--r--kicad/lib-render.c171
-rw-r--r--kicad/lib.h9
-rw-r--r--kicad/pl-render.c16
-rw-r--r--kicad/pl.h5
-rw-r--r--kicad/sch-render.c41
-rw-r--r--kicad/sch.h11
8 files changed, 200 insertions, 168 deletions
diff --git a/kicad/dwg.c b/kicad/dwg.c
index 799c329..f925539 100644
--- a/kicad/dwg.c
+++ b/kicad/dwg.c
@@ -80,7 +80,7 @@ static enum box_type flip_box(enum box_type box)
}
-void dwg_label(int x, int y, const char *s, int dir, int dim,
+void dwg_label(struct gfx *gfx, int x, int y, const char *s, int dir, int dim,
enum dwg_shape shape, struct dwg_bbox *bbox)
{
struct text txt = {
@@ -121,11 +121,11 @@ void dwg_label(int x, int y, const char *s, int dir, int dim,
txt.y -= dy * LABEL_OFFSET;
txt.x += dx * LABEL_OFFSET;
- text_fig(&txt, COLOR_LABEL, LAYER_LABEL);
+ text_fig(&txt, gfx, COLOR_LABEL, LAYER_LABEL);
}
-void dwg_glabel(int x, int y, const char *s, int dir, int dim,
+void dwg_glabel(struct gfx *gfx, int x, int y, const char *s, int dir, int dim,
enum dwg_shape shape, struct dwg_bbox *bbox)
{
struct text txt = {
@@ -198,75 +198,75 @@ void dwg_glabel(int x, int y, const char *s, int dir, int dim,
switch (box) {
case box_simple:
n = 5;
- text_shift(&txt, txt.hor, text_mid, shift_flat, 0);
- text_rel(&txt, text_min, text_min,
+ text_shift(&txt, gfx, txt.hor, text_mid, shift_flat, 0);
+ text_rel(&txt, gfx, text_min, text_min,
-GLABEL_OFFSET, GLABEL_OFFSET, vx + 1, vy + 1);
- text_rel(&txt, text_max, text_min,
+ text_rel(&txt, gfx, text_max, text_min,
GLABEL_OFFSET, GLABEL_OFFSET, vx + 2, vy + 2);
- text_rel(&txt, text_max, text_max,
+ text_rel(&txt, gfx, text_max, text_max,
GLABEL_OFFSET, -GLABEL_OFFSET, vx + 3, vy + 3);
- text_rel(&txt, text_min, text_max,
+ text_rel(&txt, gfx, text_min, text_max,
-GLABEL_OFFSET, -GLABEL_OFFSET, vx + 4, vy + 4);
break;
case box_right:
- text_shift(&txt, txt.hor, text_mid,
+ text_shift(&txt, gfx, txt.hor, text_mid,
anchor_right ? shift_tip : shift_flat, 0);
- text_rel(&txt, text_min, text_min,
+ text_rel(&txt, gfx, text_min, text_min,
-GLABEL_OFFSET, GLABEL_OFFSET, vx + 1, vy + 1);
- text_rel(&txt, text_max, text_min,
+ text_rel(&txt, gfx, text_max, text_min,
GLABEL_OFFSET, GLABEL_OFFSET, vx + 2, vy + 2);
- text_rel(&txt, text_max, text_mid, GLABEL_OFFSET + half, 0,
+ text_rel(&txt, gfx, text_max, text_mid, GLABEL_OFFSET + half, 0,
vx + 3, vy + 3);
- text_rel(&txt, text_max, text_max,
+ text_rel(&txt, gfx, text_max, text_max,
GLABEL_OFFSET, -GLABEL_OFFSET, vx + 4, vy + 4);
- text_rel(&txt, text_min, text_max,
+ text_rel(&txt, gfx, text_min, text_max,
-GLABEL_OFFSET, -GLABEL_OFFSET, vx + 5, vy + 5);
break;
case box_left:
- text_shift(&txt, txt.hor, text_mid,
+ text_shift(&txt, gfx, txt.hor, text_mid,
anchor_right ? shift_flat : shift_tip, 0);
- text_rel(&txt, text_min, text_min,
+ text_rel(&txt, gfx, text_min, text_min,
-GLABEL_OFFSET, GLABEL_OFFSET, vx + 1, vy + 1);
- text_rel(&txt, text_max, text_min,
+ text_rel(&txt, gfx, text_max, text_min,
GLABEL_OFFSET, GLABEL_OFFSET, vx + 2, vy + 2);
- text_rel(&txt, text_max, text_max,
+ text_rel(&txt, gfx, text_max, text_max,
GLABEL_OFFSET, -GLABEL_OFFSET, vx + 3, vy + 3);
- text_rel(&txt, text_min, text_max,
+ text_rel(&txt, gfx, text_min, text_max,
-GLABEL_OFFSET, -GLABEL_OFFSET, vx + 4, vy + 4);
- text_rel(&txt, text_min, text_mid, -GLABEL_OFFSET- half, 0,
+ text_rel(&txt, gfx, text_min, text_mid, -GLABEL_OFFSET- half, 0,
vx + 5, vy + 5);
break;
case box_both:
n = 7;
- text_shift(&txt, txt.hor, text_mid, shift_tip, 0);
- text_rel(&txt, text_min, text_min,
+ text_shift(&txt, gfx, txt.hor, text_mid, shift_tip, 0);
+ text_rel(&txt, gfx, text_min, text_min,
-GLABEL_OFFSET, GLABEL_OFFSET, vx + 1, vy + 1);
- text_rel(&txt, text_max, text_min,
+ text_rel(&txt, gfx, text_max, text_min,
GLABEL_OFFSET, GLABEL_OFFSET, vx + 2, vy + 2);
- text_rel(&txt, text_max, text_mid, GLABEL_OFFSET + half, 0,
+ text_rel(&txt, gfx, text_max, text_mid, GLABEL_OFFSET + half, 0,
vx + 3, vy + 3);
- text_rel(&txt, text_max, text_max,
+ text_rel(&txt, gfx, text_max, text_max,
GLABEL_OFFSET, -GLABEL_OFFSET, vx + 4, vy + 4);
- text_rel(&txt, text_min, text_max,
+ text_rel(&txt, gfx, text_min, text_max,
-GLABEL_OFFSET, -GLABEL_OFFSET, vx + 5, vy + 5);
- text_rel(&txt, text_min, text_mid, -GLABEL_OFFSET- half, 0,
+ text_rel(&txt, gfx, text_min, text_mid, -GLABEL_OFFSET- half, 0,
vx + 6, vy + 6);
break;
default:
assert(0);
}
- text_fig(&txt, COLOR_GLABEL, LAYER_GLABEL);
+ text_fig(&txt, gfx, COLOR_GLABEL, LAYER_GLABEL);
vx[0] = vx[n - 1];
vy[0] = vy[n - 1];
- gfx_poly(n, vx, vy, COLOR_GLABEL, COLOR_NONE, LAYER_GLABEL);
+ gfx_poly(gfx, n, vx, vy, COLOR_GLABEL, COLOR_NONE, LAYER_GLABEL);
if (bbox)
bbox_from_poly(bbox, n, vx, vy);
if (asprintf(&tag, "G:%s", s)) {}
- gfx_tag(tag, n, vx, vy);
+ gfx_tag(gfx, tag, n, vx, vy);
}
@@ -325,7 +325,7 @@ static int make_box(enum box_type box, int h, int *vx, int *vy)
}
-void dwg_hlabel(int x, int y, const char *s, int dir, int dim,
+void dwg_hlabel(struct gfx *gfx, int x, int y, const char *s, int dir, int dim,
enum dwg_shape shape, struct dwg_bbox *bbox)
{
struct text txt = {
@@ -396,15 +396,15 @@ void dwg_hlabel(int x, int y, const char *s, int dir, int dim,
txt.rot = rot % 180;
- text_fig(&txt, COLOR_HLABEL, LAYER_HLABEL);
- gfx_poly(n + 1, vx, vy, COLOR_HLABEL, COLOR_NONE, LAYER_HLABEL);
+ text_fig(&txt, gfx, COLOR_HLABEL, LAYER_HLABEL);
+ gfx_poly(gfx, n + 1, vx, vy, COLOR_HLABEL, COLOR_NONE, LAYER_HLABEL);
}
/* ----- Text -------------------------------------------------------------- */
-void dwg_text(int x, int y, const char *s, int dir, int dim,
+void dwg_text(struct gfx *gfx, int x, int y, const char *s, int dir, int dim,
enum dwg_shape shape, struct dwg_bbox *bbox)
{
struct text txt = {
@@ -434,27 +434,27 @@ void dwg_text(int x, int y, const char *s, int dir, int dim,
assert(2 + 2 == 5);
}
- text_fig(&txt, COLOR_TEXT, LAYER_TEXT);
+ text_fig(&txt, gfx, COLOR_TEXT, LAYER_TEXT);
}
/* ----- Connections ------------------------------------------------------- */
-void dwg_junction(int x, int y)
+void dwg_junction(struct gfx *gfx, int x, int y)
{
- gfx_circ(x, y, JUNCTION_R, COLOR_NONE, COLOR_WIRE, LAYER_WIRES);
+ gfx_circ(gfx, x, y, JUNCTION_R, COLOR_NONE, COLOR_WIRE, LAYER_WIRES);
}
-void dwg_noconn(int x, int y)
+void dwg_noconn(struct gfx *gfx, int x, int y)
{
int vx[2] = { x - NOCONN_LEN, x + NOCONN_LEN };
int vy[2] = { y - NOCONN_LEN, y + NOCONN_LEN };
- gfx_poly(2, vx, vy, COLOR_NOCONN, COLOR_NONE, LAYER_NOCONN);
+ gfx_poly(gfx, 2, vx, vy, COLOR_NOCONN, COLOR_NONE, LAYER_NOCONN);
swap(vy[0], vy[1]);
- gfx_poly(2, vx, vy, COLOR_NOCONN, COLOR_NONE, LAYER_NOCONN);
+ gfx_poly(gfx, 2, vx, vy, COLOR_NOCONN, COLOR_NONE, LAYER_NOCONN);
}
@@ -469,33 +469,33 @@ void dwg_noconn(int x, int y)
* treat reversed lines as still equal.
*/
-void dwg_line(int sx, int sy, int ex, int ey)
+void dwg_line(struct gfx *gfx, int sx, int sy, int ex, int ey)
{
if (sx < ex || (sx == ex && sy < ey))
- gfx_line(sx, sy, ex, ey, COLOR_SHEET_DWG, LAYER_LINES);
+ gfx_line(gfx, sx, sy, ex, ey, COLOR_SHEET_DWG, LAYER_LINES);
else
- gfx_line(ex, ey, sx, sy, COLOR_SHEET_DWG, LAYER_LINES);
+ gfx_line(gfx, ex, ey, sx, sy, COLOR_SHEET_DWG, LAYER_LINES);
}
/* ----- Wires and busses -------------------------------------------------- */
-void dwg_wire(int sx, int sy, int ex, int ey)
+void dwg_wire(struct gfx *gfx, int sx, int sy, int ex, int ey)
{
int vx[] = { sx, ex };
int vy[] = { sy, ey };
// WIDTH_WIRE
- gfx_poly(2, vx, vy, COLOR_WIRE, COLOR_NONE, LAYER_WIRES);
+ gfx_poly(gfx, 2, vx, vy, COLOR_WIRE, COLOR_NONE, LAYER_WIRES);
}
-void dwg_bus(int sx, int sy, int ex, int ey)
+void dwg_bus(struct gfx *gfx, int sx, int sy, int ex, int ey)
{
int vx[] = { sx, ex };
int vy[] = { sy, ey };
// WIDTH_BUS
- gfx_poly(2, vx, vy, COLOR_BUS, COLOR_NONE, LAYER_BUSSES);
+ gfx_poly(gfx, 2, vx, vy, COLOR_BUS, COLOR_NONE, LAYER_BUSSES);
}
diff --git a/kicad/dwg.h b/kicad/dwg.h
index 2875b48..be1ac60 100644
--- a/kicad/dwg.h
+++ b/kicad/dwg.h
@@ -14,6 +14,9 @@
#ifndef KICAD_DWG_H
#define KICAD_DWG_H
+#include "gfx/gfx.h"
+
+
enum dwg_shape {
dwg_unspec, // UnSpc
dwg_in, // Input
@@ -28,21 +31,21 @@ struct dwg_bbox {
};
-void dwg_label(int x, int y, const char *s, int dir, int dim,
+void dwg_label(struct gfx *gfx, int x, int y, const char *s, int dir, int dim,
enum dwg_shape shape, struct dwg_bbox *bbox);
-void dwg_hlabel(int x, int y, const char *s, int dir, int dim,
+void dwg_hlabel(struct gfx *gfx, int x, int y, const char *s, int dir, int dim,
enum dwg_shape shape, struct dwg_bbox *bbox);
-void dwg_glabel(int x, int y, const char *s, int dir, int dim,
+void dwg_glabel(struct gfx *gfx, int x, int y, const char *s, int dir, int dim,
enum dwg_shape shape, struct dwg_bbox *bbox);
-void dwg_text(int x, int y, const char *s, int dir, int dim,
+void dwg_text(struct gfx *gfx, int x, int y, const char *s, int dir, int dim,
enum dwg_shape shape, struct dwg_bbox *bbox);
-void dwg_junction(int x, int y);
-void dwg_noconn(int x, int y);
+void dwg_junction(struct gfx *gfx, int x, int y);
+void dwg_noconn(struct gfx *gfx, int x, int y);
-void dwg_line(int sx, int sy, int ex, int ey);
+void dwg_line(struct gfx *gfx, int sx, int sy, int ex, int ey);
-void dwg_wire(int sx, int sy, int ex, int ey);
-void dwg_bus(int sx, int sy, int ex, int ey);
+void dwg_wire(struct gfx *gfx, int sx, int sy, int ex, int ey);
+void dwg_bus(struct gfx *gfx, int sx, int sy, int ex, int ey);
#endif /* !KICAD_DWG_H */
diff --git a/kicad/lib-render.c b/kicad/lib-render.c
index 7a08ea3..3e62bba 100644
--- a/kicad/lib-render.c
+++ b/kicad/lib-render.c
@@ -60,7 +60,8 @@ static void transform_poly_md(unsigned n, int *vx, int *vy, const int m[6],
/* ----- Polygons and rectangles ------------------------------------------- */
-static void draw_poly(const struct lib_poly *poly, const int m[6])
+static void draw_poly(const struct lib_poly *poly, struct gfx *gfx,
+ const int m[6])
{
int n = poly->points;
int x[n];
@@ -72,17 +73,17 @@ static void draw_poly(const struct lib_poly *poly, const int m[6])
y[i] = my(poly->x[i], poly->y[i], m);
}
- gfx_poly(n, x, y, COLOR_COMP_DWG, COLOR_NONE, LAYER_COMP_DWG);
+ gfx_poly(gfx, n, x, y, COLOR_COMP_DWG, COLOR_NONE, LAYER_COMP_DWG);
switch (poly->fill) {
case 'N':
break;
case 'F':
- gfx_poly(n, x, y, COLOR_NONE, COLOR_COMP_DWG,
+ gfx_poly(gfx, n, x, y, COLOR_NONE, COLOR_COMP_DWG,
LAYER_COMP_DWG_BG);
break;
case 'f':
- gfx_poly(n, x, y, COLOR_NONE, COLOR_COMP_DWG_BG,
+ gfx_poly(gfx, n, x, y, COLOR_NONE, COLOR_COMP_DWG_BG,
LAYER_COMP_DWG_BG);
break;
default:
@@ -91,24 +92,26 @@ static void draw_poly(const struct lib_poly *poly, const int m[6])
}
-static void draw_rect(const struct lib_rect *rect, const int m[6])
+static void draw_rect(const struct lib_rect *rect, struct gfx *gfx,
+ const int m[6])
{
int sx = mx(rect->sx, rect->sy, m);
int sy = my(rect->sx, rect->sy, m);
int ex = mx(rect->ex, rect->ey, m);
int ey = my(rect->ex, rect->ey, m);
- gfx_rect(sx, sy, ex, ey, COLOR_COMP_DWG, COLOR_NONE, LAYER_COMP_DWG);
+ gfx_rect(gfx, sx, sy, ex, ey,
+ COLOR_COMP_DWG, COLOR_NONE, LAYER_COMP_DWG);
switch (rect->fill) {
case 'N':
break;
case 'F':
- gfx_rect(sx, sy, ex, ey, COLOR_NONE, COLOR_COMP_DWG,
+ gfx_rect(gfx, sx, sy, ex, ey, COLOR_NONE, COLOR_COMP_DWG,
LAYER_COMP_DWG_BG);
break;
case 'f':
- gfx_rect(sx, sy, ex, ey, COLOR_NONE, COLOR_COMP_DWG_BG,
+ gfx_rect(gfx, sx, sy, ex, ey, COLOR_NONE, COLOR_COMP_DWG_BG,
LAYER_COMP_DWG_BG);
break;
default:
@@ -120,24 +123,25 @@ static void draw_rect(const struct lib_rect *rect, const int m[6])
/* ----- Circles and arcs -------------------------------------------------- */
-static void draw_circ(const struct lib_circ *circ, const int m[6])
+static void draw_circ(const struct lib_circ *circ, struct gfx *gfx,
+ const int m[6])
{
int x = mx(circ->x, circ->y, m);
int y = my(circ->x, circ->y, m);
int r = circ->r;
- gfx_circ(x, y, r, COLOR_COMP_DWG, COLOR_NONE, LAYER_COMP_DWG);
+ gfx_circ(gfx, x, y, r, COLOR_COMP_DWG, COLOR_NONE, LAYER_COMP_DWG);
switch (circ->fill) {
case 'N':
break;
case 'F':
- gfx_circ(x, y, r, COLOR_NONE, COLOR_COMP_DWG,
- LAYER_COMP_DWG_BG);
+ gfx_circ(gfx, x, y, r,
+ COLOR_NONE, COLOR_COMP_DWG, LAYER_COMP_DWG_BG);
break;
case 'f':
- gfx_circ(x, y, r, COLOR_NONE, COLOR_COMP_DWG_BG,
- LAYER_COMP_DWG_BG);
+ gfx_circ(gfx, x, y, r,
+ COLOR_NONE, COLOR_COMP_DWG_BG, LAYER_COMP_DWG_BG);
break;
default:
BUG("invalid fill '%c'", circ->fill);
@@ -145,7 +149,7 @@ static void draw_circ(const struct lib_circ *circ, const int m[6])
}
-static void draw_arc(const struct lib_arc *arc, const int m[6])
+static void draw_arc(const struct lib_arc *arc, struct gfx *gfx, const int m[6])
{
int a = matrix_to_angle(m);
int x = mx(arc->x, arc->y, m);
@@ -175,18 +179,18 @@ static void draw_arc(const struct lib_arc *arc, const int m[6])
case 'N':
break;
case 'F':
- gfx_arc(x, y, arc->r, sa, ea,
+ gfx_arc(gfx, x, y, arc->r, sa, ea,
COLOR_COMP_DWG, COLOR_COMP_DWG, LAYER_COMP_DWG_BG);
break;
case 'f':
- gfx_arc(x, y, arc->r, sa, ea,
+ gfx_arc(gfx, x, y, arc->r, sa, ea,
COLOR_COMP_DWG_BG, COLOR_COMP_DWG_BG, LAYER_COMP_DWG_BG);
break;
default:
assert(0);
}
- gfx_arc(x, y, arc->r, sa, ea,
+ gfx_arc(gfx, x, y, arc->r, sa, ea,
COLOR_COMP_DWG, COLOR_NONE, LAYER_COMP_DWG);
}
@@ -195,7 +199,8 @@ static void draw_arc(const struct lib_arc *arc, const int m[6])
static void draw_pin_name(const struct comp *comp, const struct lib_pin *pin,
- const int m[6], int dx, int dy, int rot, enum text_align hor)
+ struct gfx *gfx, const int m[6], int dx, int dy, int rot,
+ enum text_align hor)
{
int ox, oy, sx, sy;
@@ -244,12 +249,13 @@ static void draw_pin_name(const struct comp *comp, const struct lib_pin *pin,
break;
}
- text_fig(&txt, COLOR_PIN_NAME, LAYER_PIN_NAME);
+ text_fig(&txt, gfx, COLOR_PIN_NAME, LAYER_PIN_NAME);
}
static void draw_pin_num(const struct comp *comp, const struct lib_pin *pin,
- const int m[6], int dx, int dy, int rot, enum text_align hor)
+ struct gfx *gfx, const int m[6], int dx, int dy, int rot,
+ enum text_align hor)
{
int ox, oy, sx, sy;
@@ -303,15 +309,15 @@ static void draw_pin_num(const struct comp *comp, const struct lib_pin *pin,
break;
}
- text_fig(&txt, COLOR_PIN_NUMBER, LAYER_PIN_NUMBER);
+ text_fig(&txt, gfx, COLOR_PIN_NUMBER, LAYER_PIN_NUMBER);
}
/* ----- Pin shape --------------------------------------------------------- */
-static void draw_pin_line(const struct lib_pin *pin, enum pin_shape shape,
- int dx, int dy, const int m[6])
+static void draw_pin_line(const struct lib_pin *pin, struct gfx *gfx,
+ enum pin_shape shape, int dx, int dy, const int m[6])
{
int len = pin->length;
int x[4], y[4];
@@ -326,13 +332,13 @@ static void draw_pin_line(const struct lib_pin *pin, enum pin_shape shape,
y[1] = pin->y + dy * len;
transform_poly(2, x, y, m);
- gfx_poly(2, x, y, COLOR_COMP_DWG, COLOR_NONE, LAYER_COMP_DWG);
+ gfx_poly(gfx, 2, x, y, COLOR_COMP_DWG, COLOR_NONE, LAYER_COMP_DWG);
if (shape & pin_inverted) {
x[0] = pin->x + dx * (len + PIN_R);
y[0] = pin->y + dy * (len + PIN_R);
transform_poly(1, x, y, m);
- gfx_circ(x[0], y[0], PIN_R,
+ gfx_circ(gfx, x[0], y[0], PIN_R,
COLOR_COMP_DWG, COLOR_NONE, LAYER_COMP_DWG);
}
@@ -349,7 +355,8 @@ static void draw_pin_line(const struct lib_pin *pin, enum pin_shape shape,
x[3] = x[0];
y[3] = y[0];
transform_poly(4, x, y, m);
- gfx_poly(4, x, y, COLOR_COMP_DWG, COLOR_NONE, LAYER_COMP_DWG);
+ gfx_poly(gfx, 4, x, y,
+ COLOR_COMP_DWG, COLOR_NONE, LAYER_COMP_DWG);
}
/*
@@ -365,7 +372,8 @@ static void draw_pin_line(const struct lib_pin *pin, enum pin_shape shape,
x[2] = ex - dx * 2 * PIN_R;
y[2] = ey - dy * 2 * PIN_R;
transform_poly(3, x, y, m);
- gfx_poly(3, x, y, COLOR_COMP_DWG, COLOR_NONE, LAYER_COMP_DWG);
+ gfx_poly(gfx, 3, x, y,
+ COLOR_COMP_DWG, COLOR_NONE, LAYER_COMP_DWG);
}
if (shape & pin_output_low) {
@@ -374,7 +382,8 @@ static void draw_pin_line(const struct lib_pin *pin, enum pin_shape shape,
x[1] = ex - dx * 2 * PIN_R;
y[1] = ey - dy * 2 * PIN_R;
transform_poly(2, x, y, m);
- gfx_poly(2, x, y, COLOR_COMP_DWG, COLOR_NONE, LAYER_COMP_DWG);
+ gfx_poly(gfx, 2, x, y,
+ COLOR_COMP_DWG, COLOR_NONE, LAYER_COMP_DWG);
}
if (shape & pin_falling_edge) {
@@ -385,7 +394,8 @@ static void draw_pin_line(const struct lib_pin *pin, enum pin_shape shape,
x[2] = ex + dy * PIN_R;
y[2] = ey + dx * PIN_R;
transform_poly(3, x, y, m);
- gfx_poly(3, x, y, COLOR_COMP_DWG, COLOR_NONE, LAYER_COMP_DWG);
+ gfx_poly(gfx, 3, x, y,
+ COLOR_COMP_DWG, COLOR_NONE, LAYER_COMP_DWG);
}
if (shape & pin_non_logic) {
@@ -394,9 +404,11 @@ static void draw_pin_line(const struct lib_pin *pin, enum pin_shape shape,
x[1] = ex + PIN_R;
y[1] = ey + PIN_R;
transform_poly(2, x, y, m);
- gfx_poly(2, x, y, COLOR_COMP_DWG, COLOR_NONE, LAYER_COMP_DWG);
+ gfx_poly(gfx, 2, x, y,
+ COLOR_COMP_DWG, COLOR_NONE, LAYER_COMP_DWG);
swap(x[0], x[1]);
- gfx_poly(2, x, y, COLOR_COMP_DWG, COLOR_NONE, LAYER_COMP_DWG);
+ gfx_poly(gfx, 2, x, y,
+ COLOR_COMP_DWG, COLOR_NONE, LAYER_COMP_DWG);
}
}
@@ -404,8 +416,8 @@ static void draw_pin_line(const struct lib_pin *pin, enum pin_shape shape,
/* ----- Pin etype --------------------------------------------------------- */
-static void draw_pin_etype(const struct lib_pin *pin, enum pin_shape shape,
- int dx, int dy, const int m[6])
+static void draw_pin_etype(const struct lib_pin *pin, struct gfx *gfx,
+ enum pin_shape shape, int dx, int dy, const int m[6])
{
int mx, my;
int x[6], y[6];
@@ -423,7 +435,8 @@ static void draw_pin_etype(const struct lib_pin *pin, enum pin_shape shape,
x[2] = -PIN_EXTRA_R / 2;
y[2] = -PIN_EXTRA_R;
transform_poly_md(3, x, y, m, mx, my, dx, dy);
- gfx_poly(3, x, y, COLOR_PIN_EXTRA, COLOR_NONE, LAYER_PIN_EXTRA);
+ gfx_poly(gfx, 3, x, y,
+ COLOR_PIN_EXTRA, COLOR_NONE, LAYER_PIN_EXTRA);
break;
case 'O':
x[0] = PIN_EXTRA_R / 2;
@@ -433,7 +446,8 @@ static void draw_pin_etype(const struct lib_pin *pin, enum pin_shape shape,
x[2] = PIN_EXTRA_R / 2;
y[2] = -PIN_EXTRA_R;
transform_poly_md(3, x, y, m, mx, my, dx, dy);
- gfx_poly(3, x, y, COLOR_PIN_EXTRA, COLOR_NONE, LAYER_PIN_EXTRA);
+ gfx_poly(gfx, 3, x, y,
+ COLOR_PIN_EXTRA, COLOR_NONE, LAYER_PIN_EXTRA);
break;
case 'B':
bidir:
@@ -448,7 +462,8 @@ static void draw_pin_etype(const struct lib_pin *pin, enum pin_shape shape,
x[4] = x[0];
y[4] = y[0];
transform_poly_md(5, x, y, m, mx, my, dx, dy);
- gfx_poly(5, x, y, COLOR_PIN_EXTRA, COLOR_NONE, LAYER_PIN_EXTRA);
+ gfx_poly(gfx, 5, x, y,
+ COLOR_PIN_EXTRA, COLOR_NONE, LAYER_PIN_EXTRA);
break;
case 'T':
x[0] = 0;
@@ -464,7 +479,8 @@ static void draw_pin_etype(const struct lib_pin *pin, enum pin_shape shape,
x[5] = 0;
y[5] = -PIN_EXTRA_R;
transform_poly_md(6, x, y, m, mx, my, dx, dy);
- gfx_poly(6, x, y, COLOR_PIN_EXTRA, COLOR_NONE, LAYER_PIN_EXTRA);
+ gfx_poly(gfx, 6, x, y,
+ COLOR_PIN_EXTRA, COLOR_NONE, LAYER_PIN_EXTRA);
break;
case 'P':
x[0] = mx - PIN_EXTRA_R;
@@ -472,7 +488,7 @@ static void draw_pin_etype(const struct lib_pin *pin, enum pin_shape shape,
x[1] = mx + PIN_EXTRA_R;
y[1] = my + PIN_EXTRA_R;
transform_poly(2, x, y, m);
- gfx_rect(x[0], y[0], x[1], y[1],
+ gfx_rect(gfx, x[0], y[0], x[1], y[1],
COLOR_PIN_EXTRA, COLOR_NONE, LAYER_PIN_EXTRA);
break;
case 'U':
@@ -488,7 +504,7 @@ static void draw_pin_etype(const struct lib_pin *pin, enum pin_shape shape,
x[2] = off;
y[2] = -PIN_EXTRA_R;
transform_poly_md(3, x, y, m, mx, my, dx, dy);
- gfx_poly(3, x, y,
+ gfx_poly(gfx, 3, x, y,
COLOR_PIN_EXTRA, COLOR_NONE, LAYER_PIN_EXTRA);
}
break;
@@ -504,7 +520,7 @@ static void draw_pin_etype(const struct lib_pin *pin, enum pin_shape shape,
y[2] = -PIN_EXTRA_R;
transform_poly_md(3, x, y, m, mx, my,
dx, dy);
- gfx_poly(3, x, y,
+ gfx_poly(gfx, 3, x, y,
COLOR_PIN_EXTRA, COLOR_NONE, LAYER_PIN_EXTRA);
}
break;
@@ -514,7 +530,8 @@ static void draw_pin_etype(const struct lib_pin *pin, enum pin_shape shape,
x[1] = PIN_EXTRA_R;
y[1] = PIN_EXTRA_R;
transform_poly_md(2, x, y, m, mx, my, dx, dy);
- gfx_poly(2, x, y, COLOR_PIN_EXTRA, COLOR_NONE, LAYER_PIN_EXTRA);
+ gfx_poly(gfx, 2, x, y,
+ COLOR_PIN_EXTRA, COLOR_NONE, LAYER_PIN_EXTRA);
goto bidir;
case 'E':
x[0] = -PIN_EXTRA_R;
@@ -522,7 +539,8 @@ static void draw_pin_etype(const struct lib_pin *pin, enum pin_shape shape,
x[1] = PIN_EXTRA_R;
y[1] = -PIN_EXTRA_R;
transform_poly_md(2, x, y, m, mx, my, dx, dy);
- gfx_poly(2, x, y, COLOR_PIN_EXTRA, COLOR_NONE, LAYER_PIN_EXTRA);
+ gfx_poly(gfx, 2, x, y,
+ COLOR_PIN_EXTRA, COLOR_NONE, LAYER_PIN_EXTRA);
goto bidir;
case 'N':
x[0] = -PIN_EXTRA_R;
@@ -530,9 +548,11 @@ static void draw_pin_etype(const struct lib_pin *pin, enum pin_shape shape,
x[1] = PIN_EXTRA_R;
y[1] = PIN_EXTRA_R;
transform_poly_md(2, x, y, m, mx, my, dx, dy);
- gfx_poly(2, x, y, COLOR_PIN_EXTRA, COLOR_NONE, LAYER_PIN_EXTRA);
+ gfx_poly(gfx, 2, x, y,
+ COLOR_PIN_EXTRA, COLOR_NONE, LAYER_PIN_EXTRA);
swap(x[0], x[1]);
- gfx_poly(2, x, y, COLOR_PIN_EXTRA, COLOR_NONE, LAYER_PIN_EXTRA);
+ gfx_poly(gfx, 2, x, y,
+ COLOR_PIN_EXTRA, COLOR_NONE, LAYER_PIN_EXTRA);
break;
default:
BUG("unrecognized etype '%c'", pin->etype);
@@ -544,7 +564,7 @@ static void draw_pin_etype(const struct lib_pin *pin, enum pin_shape shape,
static void draw_pin(const struct comp *comp, const struct lib_pin *pin,
- const int m[6])
+ struct gfx *gfx, const int m[6])
{
int dx = 0, dy = 0;
int rot;
@@ -579,13 +599,13 @@ static void draw_pin(const struct comp *comp, const struct lib_pin *pin,
BUG("invalid orientation '%c'", pin->orient);
}
- draw_pin_line(pin, shape, dx, dy, m);
+ draw_pin_line(pin, gfx, shape, dx, dy, m);
if (comp->show_pin_name)
- draw_pin_name(comp, pin, m, dx, dy, rot, hor);
+ draw_pin_name(comp, pin, gfx, m, dx, dy, rot, hor);
if (comp->show_pin_num)
- draw_pin_num(comp, pin, m, dx, dy, rot, hor);
+ draw_pin_num(comp, pin, gfx, m, dx, dy, rot, hor);
}
@@ -593,7 +613,7 @@ static void draw_pin(const struct comp *comp, const struct lib_pin *pin,
static void draw_pin_extra(const struct comp *comp, const struct lib_pin *pin,
- const int m[6])
+ struct gfx *gfx, const int m[6])
{
int dx = 0, dy = 0;
@@ -617,14 +637,15 @@ static void draw_pin_extra(const struct comp *comp, const struct lib_pin *pin,
BUG("invalid orientation '%c'", pin->orient);
}
- draw_pin_etype(pin, pin->etype, dx, dy, m);
+ draw_pin_etype(pin, gfx, pin->etype, dx, dy, m);
}
/* ----- Text -------------------------------------------------------------- */
-static void draw_text(const struct lib_text *text, const int m[6])
+static void draw_text(const struct lib_text *text, struct gfx *gfx,
+ const int m[6])
{
struct text txt = {
.s = text->s,
@@ -663,7 +684,7 @@ static void draw_text(const struct lib_text *text, const int m[6])
BUG("unknown rotation %d", txt.rot);
}
- text_fig(&txt, COLOR_COMP_DWG, WIDTH_COMP_DWG);
+ text_fig(&txt, gfx, COLOR_COMP_DWG, WIDTH_COMP_DWG);
}
@@ -697,26 +718,26 @@ bool lib_field_visible(const struct comp *comp, int n)
static void draw(const struct comp *comp, const struct lib_obj *obj,
- const int m[6])
+ struct gfx *gfx, const int m[6])
{
switch (obj->type) {
case lib_obj_poly:
- draw_poly(&obj->u.poly, m);
+ draw_poly(&obj->u.poly, gfx, m);
break;
case lib_obj_rect:
- draw_rect(&obj->u.rect, m);
+ draw_rect(&obj->u.rect, gfx, m);
break;
case lib_obj_circ:
- draw_circ(&obj->u.circ, m);
+ draw_circ(&obj->u.circ, gfx, m);
break;
case lib_obj_arc:
- draw_arc(&obj->u.arc, m);
+ draw_arc(&obj->u.arc, gfx, m);
break;
case lib_obj_text:
- draw_text(&obj->u.text, m);
+ draw_text(&obj->u.text, gfx, m);
break;
case lib_obj_pin:
- draw_pin(comp, &obj->u.pin, m);
+ draw_pin(comp, &obj->u.pin, gfx, m);
break;
default:
BUG("invalid object type %d", obj->type);
@@ -725,7 +746,7 @@ static void draw(const struct comp *comp, const struct lib_obj *obj,
static void draw_extra(const struct comp *comp, const struct lib_obj *obj,
- const int m[6])
+ struct gfx *gfx, const int m[6])
{
switch (obj->type) {
case lib_obj_poly:
@@ -735,7 +756,7 @@ static void draw_extra(const struct comp *comp, const struct lib_obj *obj,
case lib_obj_text:
break;
case lib_obj_pin:
- draw_pin_extra(comp, &obj->u.pin, m);
+ draw_pin_extra(comp, &obj->u.pin, gfx, m);
break;
default:
BUG("invalid object type %d", obj->type);
@@ -743,27 +764,27 @@ static void draw_extra(const struct comp *comp, const struct lib_obj *obj,
}
-static void missing_component(const int m[4])
+static void missing_component(struct gfx *gfx, const int m[4])
{
int sx = mx(0, 0, m);
int sy = my(0, 0, m);
int ex = mx(MISSING_WIDTH, MISSING_HEIGHT, m);
int ey = my(MISSING_WIDTH, MISSING_HEIGHT, m);
- gfx_rect(sx, sy, ex, ey, COLOR_MISSING_FG, COLOR_MISSING_BG,
+ gfx_rect(gfx, sx, sy, ex, ey, COLOR_MISSING_FG, COLOR_MISSING_BG,
LAYER_COMP_DWG);
}
-static void render_lib(const struct comp *comp, unsigned unit, unsigned convert,
- const int m[4],
+static void render_lib(const struct comp *comp, struct gfx *gfx,
+ unsigned unit, unsigned convert, const int m[4],
void (*draw_fn)(const struct comp *comp, const struct lib_obj *obj,
- const int m[4]))
+ struct gfx *gfx, const int m[4]))
{
const struct lib_obj *obj;
if (!comp) {
- missing_component(m);
+ missing_component(gfx, m);
return;
}
if (!unit)
@@ -773,20 +794,20 @@ static void render_lib(const struct comp *comp, unsigned unit, unsigned convert,
continue;
if (obj->convert && obj->convert != convert)
continue;
- draw_fn(comp, obj, m);
+ draw_fn(comp, obj, gfx, m);
}
}
-void lib_render(const struct comp *comp, unsigned unit, unsigned convert,
- const int m[4])
+void lib_render(const struct comp *comp, struct gfx *gfx,
+ unsigned unit, unsigned convert, const int m[4])
{
- render_lib(comp, unit, convert, m, draw);
+ render_lib(comp, gfx, unit, convert, m, draw);
}
-void lib_render_extra(const struct comp *comp, unsigned unit, unsigned convert,
- const int m[4])
+void lib_render_extra(const struct comp *comp, struct gfx *gfx,
+ unsigned unit, unsigned convert, const int m[4])
{
- render_lib(comp, unit, convert, m, draw_extra);
+ render_lib(comp, gfx, unit, convert, m, draw_extra);
}
diff --git a/kicad/lib.h b/kicad/lib.h
index 9056748..f146091 100644
--- a/kicad/lib.h
+++ b/kicad/lib.h
@@ -18,6 +18,7 @@
#include "file/file.h"
#include "gfx/text.h"
+#include "gfx/gfx.h"
enum pin_shape {
@@ -134,10 +135,10 @@ extern struct comp *comps;
const struct comp *lib_find(const struct lib *lib, const char *name);
bool lib_field_visible(const struct comp *comp, int n);
-void lib_render(const struct comp *comp, unsigned unit, unsigned convert,
- const int m[6]);
-void lib_render_extra(const struct comp *comp, unsigned unit, unsigned convert,
- const int m[4]);
+void lib_render(const struct comp *comp, struct gfx *gfx,
+ unsigned unit, unsigned convert, const int m[6]);
+void lib_render_extra(const struct comp *comp, struct gfx *gfx,
+ unsigned unit, unsigned convert, const int m[4]);
bool lib_parse_file(struct lib *lib, struct file *file);
bool lib_parse(struct lib *lib, const char *name, const struct file *related);
diff --git a/kicad/pl-render.c b/kicad/pl-render.c
index 386f719..961a51d 100644
--- a/kicad/pl-render.c
+++ b/kicad/pl-render.c
@@ -142,7 +142,7 @@ static char *increment(char *s, int inc, const char *range)
static void render_text(const struct pl_ctx *pl, const struct pl_obj *obj,
- int x, int y, int inc,
+ struct gfx *gfx, int x, int y, int inc,
const struct sheet *sheets, const struct sheet *sheet)
{
char *s = expand(pl, obj->s, sheets, sheet);
@@ -173,13 +173,13 @@ static void render_text(const struct pl_ctx *pl, const struct pl_obj *obj,
}
}
txt.s = s;
- text_fig(&txt, COLOR_COMP_DWG, LAYER_COMP_DWG);
+ text_fig(&txt, gfx, COLOR_COMP_DWG, LAYER_COMP_DWG);
free(s);
}
static void render_obj(const struct pl_ctx *pl, const struct pl_obj *obj,
- unsigned inc,
+ struct gfx *gfx, unsigned inc,
const struct sheet *sheets, const struct sheet *sheet)
{
int w = sheet->w;
@@ -207,19 +207,19 @@ static void render_obj(const struct pl_ctx *pl, const struct pl_obj *obj,
switch (obj->type) {
case pl_obj_rect:
- gfx_rect(x, y, ex, ey,
+ gfx_rect(gfx, x, y, ex, ey,
COLOR_COMP_DWG, COLOR_NONE, LAYER_COMP_DWG);
break;
case pl_obj_line: {
int vx[] = { x, ex };
int vy[] = { y, ey };
- gfx_poly(2, vx, vy,
+ gfx_poly(gfx, 2, vx, vy,
COLOR_COMP_DWG, COLOR_NONE, LAYER_COMP_DWG);
}
break;
case pl_obj_text:
- render_text(pl, obj, x, y, inc, sheets, sheet);
+ render_text(pl, obj, gfx, x, y, inc, sheets, sheet);
break;
default:
break;
@@ -227,7 +227,7 @@ static void render_obj(const struct pl_ctx *pl, const struct pl_obj *obj,
}
-void pl_render(struct pl_ctx *pl, const struct sheet *sheets,
+void pl_render(struct pl_ctx *pl, struct gfx *gfx, const struct sheet *sheets,
const struct sheet *sheet)
{
const struct pl_obj *obj;
@@ -235,5 +235,5 @@ void pl_render(struct pl_ctx *pl, const struct sheet *sheets,
for (obj = pl->objs; obj; obj = obj->next)
for (i = 0; i != obj->repeat; i++)
- render_obj(pl, obj, i, sheets, sheet);
+ render_obj(pl, obj, gfx, i, sheets, sheet);
}
diff --git a/kicad/pl.h b/kicad/pl.h
index 7aee176..3f19347 100644
--- a/kicad/pl.h
+++ b/kicad/pl.h
@@ -14,6 +14,7 @@
#ifndef KICAD_PL_H
#define KICAD_PL_H
+#include "gfx/gfx.h"
#include "file/file.h"
#include "kicad/sch.h"
@@ -21,8 +22,8 @@
struct pl_ctx;
-void pl_render(struct pl_ctx *pl, const struct sheet *sheets,
- const struct sheet *sheet);
+void pl_render(struct pl_ctx *pl, struct gfx *gfx,
+ const struct sheet *sheets, const struct sheet *sheet);
struct pl_ctx *pl_parse(struct file *file);
void pl_free(struct pl_ctx *pl);
diff --git a/kicad/sch-render.c b/kicad/sch-render.c
index 265181e..49b5e64 100644
--- a/kicad/sch-render.c
+++ b/kicad/sch-render.c
@@ -27,7 +27,8 @@
/* ----- Rendering --------------------------------------------------------- */
-static void dump_field(const struct comp_field *field, const int m[6])
+static void dump_field(const struct comp_field *field, struct gfx *gfx,
+ const int m[6])
{
struct text txt = field->txt;
int dx, dy;
@@ -61,12 +62,12 @@ static void dump_field(const struct comp_field *field, const int m[6])
txt.vert = text_flip(txt.vert);
}
- text_fig(&txt, COLOR_FIELD, LAYER_FIELD);
+ text_fig(&txt, gfx, COLOR_FIELD, LAYER_FIELD);
}
static void do_hsheet_text(const struct sch_obj *obj,
- const struct sch_sheet *sheet)
+ const struct sch_sheet *sheet, struct gfx *gfx)
{
char *s;
@@ -105,8 +106,8 @@ static void do_hsheet_text(const struct sch_obj *obj,
file_txt.y += sheet->h + HSHEET_FIELD_OFFSET;
}
- text_fig(&sheet_txt, COLOR_HSHEET_SHEET, LAYER_HSHEET_FIELD);
- text_fig(&file_txt, COLOR_HSHEET_FILE, LAYER_HSHEET_FIELD);
+ text_fig(&sheet_txt, gfx, COLOR_HSHEET_SHEET, LAYER_HSHEET_FIELD);
+ text_fig(&file_txt, gfx, COLOR_HSHEET_FILE, LAYER_HSHEET_FIELD);
// free((void *) ctx->sheet);
// free((void *) ctx->file);
@@ -114,24 +115,24 @@ static void do_hsheet_text(const struct sch_obj *obj,
static void render_sheet(const struct sch_obj *obj,
- const struct sch_sheet *sheet)
+ const struct sch_sheet *sheet, struct gfx *gfx)
{
const struct sheet_field *field;
- gfx_rect(obj->x, obj->y, obj->x + sheet->w, obj->y + sheet->h,
+ gfx_rect(gfx, obj->x, obj->y, obj->x + sheet->w, obj->y + sheet->h,
COLOR_HSHEET_BOX, sheet->error ? COLOR_MISSING_BG : COLOR_NONE,
LAYER_HSHEET_BOX);
- do_hsheet_text(obj, sheet);
+ do_hsheet_text(obj, sheet, gfx);
for (field = sheet->fields; field; field = field->next)
- dwg_hlabel(field->x, field->y, field->s,
+ dwg_hlabel(gfx, field->x, field->y, field->s,
field->side, field->dim,
field->shape, NULL);
// free(field->s)
}
-void sch_render(const struct sheet *sheet)
+void sch_render(const struct sheet *sheet, struct gfx *gfx)
{
struct sch_obj *obj;
@@ -141,21 +142,23 @@ void sch_render(const struct sheet *sheet)
{
const struct sch_wire *wire = &obj->u.wire;
- wire->fn(obj->x, obj->y, wire->ex, wire->ey);
+ wire->fn(gfx, obj->x, obj->y,
+ wire->ex, wire->ey);
}
break;
case sch_obj_junction:
- dwg_junction(obj->x, obj->y);
+ dwg_junction(gfx, obj->x, obj->y);
break;
case sch_obj_noconn:
- dwg_noconn(obj->x, obj->y);
+ dwg_noconn(gfx, obj->x, obj->y);
break;
case sch_obj_glabel:
case sch_obj_text:
{
struct sch_text *text = &obj->u.text;
- text->fn(obj->x, obj->y, text->s, text->dir,
+ text->fn(gfx, obj->x, obj->y,
+ text->s, text->dir,
text->dim, text->shape, &text->bbox);
}
break;
@@ -164,15 +167,15 @@ void sch_render(const struct sheet *sheet)
const struct sch_comp *comp = &obj->u.comp;
const struct comp_field *field;
- lib_render(comp->comp, comp->unit,
+ lib_render(comp->comp, gfx, comp->unit,
comp->convert, comp->m);
for (field = comp->fields; field;
field = field->next)
- dump_field(field, comp->m);
+ dump_field(field, gfx, comp->m);
}
break;
case sch_obj_sheet:
- render_sheet(obj, &obj->u.sheet);
+ render_sheet(obj, &obj->u.sheet, gfx);
break;
default:
BUG("invalid object type \"%d\"", obj->type);
@@ -180,7 +183,7 @@ void sch_render(const struct sheet *sheet)
}
-void sch_render_extra(const struct sheet *sheet)
+void sch_render_extra(const struct sheet *sheet, struct gfx *gfx)
{
struct sch_obj *obj;
@@ -197,7 +200,7 @@ void sch_render_extra(const struct sheet *sheet)
{
const struct sch_comp *comp = &obj->u.comp;
- lib_render_extra(comp->comp, comp->unit,
+ lib_render_extra(comp->comp, gfx, comp->unit,
comp->convert, comp->m);
}
break;
diff --git a/kicad/sch.h b/kicad/sch.h
index 06d9684..48c2ee5 100644
--- a/kicad/sch.h
+++ b/kicad/sch.h
@@ -18,6 +18,7 @@
#include "kicad/dwg.h"
#include "gfx/text.h"
+#include "gfx/gfx.h"
#include "file/file.h"
#include "kicad/lib.h"
@@ -49,11 +50,13 @@ struct sch_obj {
union {
struct sch_wire {
- void (*fn)(int sx, int sy, int ex, int ey);
+ void (*fn)(struct gfx *gfx,
+ int sx, int sy, int ex, int ey);
int ex, ey;
} wire;
struct sch_text {
- void (*fn)(int x, int y, const char *s,
+ void (*fn)(struct gfx *gfx,
+ int x, int y, const char *s,
int dir, int dim, enum dwg_shape shape,
struct dwg_bbox *bbox);
const char *s;
@@ -131,8 +134,8 @@ struct sch_ctx {
void decode_alignment(struct text *txt, char hor, char vert);
-void sch_render(const struct sheet *sheet);
-void sch_render_extra(const struct sheet *sheet);
+void sch_render(const struct sheet *sheet, struct gfx *gfx);
+void sch_render_extra(const struct sheet *sheet, struct gfx *gfx);
bool sch_parse(struct sch_ctx *ctx, struct file *file, const struct lib *lib,
const struct sch_ctx *prev);
void sch_init(struct sch_ctx *ctx, bool recurse);