1
0
mirror of git://projects.qi-hardware.com/eda-tools.git synced 2024-11-30 02:41:32 +02:00

sch2fig/: rename "cairo" to "cro"

To avoid confusion and possible clashes with the real Cairo.
This commit is contained in:
Werner Almesberger 2016-08-01 18:11:42 -03:00
parent c5064a8dca
commit 5d0596d0b7
5 changed files with 57 additions and 59 deletions

View File

@ -13,7 +13,7 @@
NAME = sch2fig
OBJS = main.o sch-parse.o sch-render.o lib-parse.o lib-render.o \
file.o \
style.o fig.o record.o cairo.o diff.o gfx.o dwg.o text.o misc.o
style.o fig.o record.o cro.o diff.o gfx.o dwg.o text.o misc.o
CFLAGS = -g -Wall -Wextra -Wno-unused-parameter -Wshadow \
-Wmissing-prototypes -Wmissing-declarations \

View File

@ -1,5 +1,5 @@
/*
* cairo.c - Cairo graphics back-end
* cro.c - Cairo graphics back-end
*
* Written 2016 by Werner Almesberger
* Copyright 2016 by Werner Almesberger
@ -28,7 +28,7 @@
#include "gfx.h"
#include "record.h"
#include "main.h"
#include "cairo.h"
#include "cro.h"
/*
@ -40,7 +40,7 @@
#define DEFAULT_SCALE (72.0 / 1200)
struct cairo_ctx {
struct cro_ctx {
struct record record; /* must be first */
int xo, yo;
@ -56,31 +56,31 @@ struct cairo_ctx {
};
static inline int cd(struct cairo_ctx *cc, int x)
static inline int cd(struct cro_ctx *cc, int x)
{
return x * cc->scale;
}
static inline int cx(struct cairo_ctx *cc, int x)
static inline int cx(struct cro_ctx *cc, int x)
{
return cc->xo + x * cc->scale;
}
static inline int xc(struct cairo_ctx *cc, int x)
static inline int xc(struct cro_ctx *cc, int x)
{
return (x - cc->xo) / cc->scale;
}
static inline int cy(struct cairo_ctx *cc, int y)
static inline int cy(struct cro_ctx *cc, int y)
{
return cc->yo + y * cc->scale;
}
static inline float pt(struct cairo_ctx *cc, int x)
static inline float pt(struct cro_ctx *cc, int x)
{
return cd(cc, x) * 72 * 1.5 / 1200.0;
}
@ -120,7 +120,7 @@ static void paint(cairo_t *cr, int color, int fill_color)
static void cr_line(void *ctx, int sx, int sy, int ex, int ey,
int color, unsigned layer)
{
struct cairo_ctx *cc = ctx;
struct cro_ctx *cc = ctx;
static const double dashes[] = { 4, 2 };
cairo_new_path(cc->cr);
@ -136,7 +136,7 @@ static void cr_poly(void *ctx,
int points, const int x[points], const int y[points],
int color, int fill_color, unsigned layer)
{
struct cairo_ctx *cc = ctx;
struct cro_ctx *cc = ctx;
bool closed;
int i;
@ -159,7 +159,7 @@ static void cr_poly(void *ctx,
static void cr_circ(void *ctx, int x, int y, int r,
int color, int fill_color, unsigned layer)
{
struct cairo_ctx *cc = ctx;
struct cro_ctx *cc = ctx;
cairo_new_path(cc->cr);
cairo_arc(cc->cr, cx(cc, x), cy(cc, y), cd(cc, r), 0, 2 * M_PI);
@ -170,7 +170,7 @@ static void cr_circ(void *ctx, int x, int y, int r,
static void cr_arc(void *ctx, int x, int y, int r, int sa, int ea,
int color, int fill_color, unsigned layer)
{
struct cairo_ctx *cc = ctx;
struct cro_ctx *cc = ctx;
cairo_new_path(cc->cr);
cairo_arc(cc->cr, cx(cc, x), cy(cc, y), cd(cc, r),
@ -185,7 +185,7 @@ static void cr_arc(void *ctx, int x, int y, int r, int sa, int ea,
static void cr_text(void *ctx, int x, int y, const char *s, unsigned size,
enum text_align align, int rot, unsigned color, unsigned layer)
{
struct cairo_ctx *cc = ctx;
struct cro_ctx *cc = ctx;
cairo_text_extents_t ext;
cairo_matrix_t m;
@ -219,7 +219,7 @@ static void cr_text(void *ctx, int x, int y, const char *s, unsigned size,
static unsigned cr_text_width(void *ctx, const char *s, unsigned size)
{
struct cairo_ctx *cc = ctx;
struct cro_ctx *cc = ctx;
cairo_text_extents_t ext;
cairo_set_font_size(cc->cr, cx(cc, size) * TEXT_STRETCH);
@ -231,7 +231,7 @@ static unsigned cr_text_width(void *ctx, const char *s, unsigned size)
/* ----- Initializatio and termination ------------------------------------- */
static const struct gfx_ops real_cairo_ops = {
static const struct gfx_ops real_cro_ops = {
.name = "cairo",
.line = cr_line,
.poly = cr_poly,
@ -242,12 +242,12 @@ static const struct gfx_ops real_cairo_ops = {
};
static struct cairo_ctx *init_common(int argc, char *const *argv)
static struct cro_ctx *init_common(int argc, char *const *argv)
{
struct cairo_ctx *cc;
struct cro_ctx *cc;
char c;
cc = alloc_type(struct cairo_ctx);
cc = alloc_type(struct cro_ctx);
cc->xo = cc->yo = 0;
cc->scale = DEFAULT_SCALE;
@ -267,7 +267,7 @@ static struct cairo_ctx *init_common(int argc, char *const *argv)
usage(*argv);
}
record_init(&cc->record, &real_cairo_ops, cc);
record_init(&cc->record, &real_cro_ops, cc);
return cc;
}
@ -275,7 +275,7 @@ static struct cairo_ctx *init_common(int argc, char *const *argv)
static void *cr_png_init(int argc, char *const *argv)
{
struct cairo_ctx *cc;
struct cro_ctx *cc;
cc = init_common(argc, argv);
@ -290,7 +290,7 @@ static void *cr_png_init(int argc, char *const *argv)
static void *cr_pdf_init(int argc, char *const *argv)
{
struct cairo_ctx *cc;
struct cro_ctx *cc;
cc = init_common(argc, argv);
@ -303,7 +303,7 @@ static void *cr_pdf_init(int argc, char *const *argv)
}
static void end_common(struct cairo_ctx *cc, int *w, int *h)
static void end_common(struct cro_ctx *cc, int *w, int *h)
{
int x, y;
@ -323,7 +323,7 @@ static void end_common(struct cairo_ctx *cc, int *w, int *h)
static void cr_png_end(void *ctx)
{
struct cairo_ctx *cc = ctx;
struct cro_ctx *cc = ctx;
int w, h;
end_common(cc, &w, &h);
@ -348,7 +348,7 @@ static void cr_png_end(void *ctx)
static void cr_pdf_new_sheet(void *ctx)
{
struct cairo_ctx *cc = ctx;
struct cro_ctx *cc = ctx;
cc->n_sheets++;
cc->sheets = realloc(cc->sheets, sizeof(struct record) * cc->n_sheets);
@ -363,7 +363,7 @@ static void cr_pdf_new_sheet(void *ctx)
static void cr_pdf_end(void *ctx)
{
struct cairo_ctx *cc = ctx;
struct cro_ctx *cc = ctx;
int w, h;
unsigned i;
@ -396,9 +396,9 @@ static void cr_pdf_end(void *ctx)
}
uint32_t *cairo_img_end(void *ctx, int *w, int *h, int *stride)
uint32_t *cro_img_end(void *ctx, int *w, int *h, int *stride)
{
struct cairo_ctx *cc = ctx;
struct cro_ctx *cc = ctx;
uint32_t *data;
end_common(cc, w, h);
@ -424,9 +424,9 @@ uint32_t *cairo_img_end(void *ctx, int *w, int *h, int *stride)
}
void cairo_img_write(void *ctx, const char *name)
void cro_img_write(void *ctx, const char *name)
{
struct cairo_ctx *cc = ctx;
struct cro_ctx *cc = ctx;
cairo_surface_write_to_png(cc->s, name);
}
@ -435,7 +435,7 @@ void cairo_img_write(void *ctx, const char *name)
/* ----- Operations -------------------------------------------------------- */
const struct gfx_ops cairo_png_ops = {
const struct gfx_ops cro_png_ops = {
.name = "png",
.line = record_line,
.poly = record_poly,
@ -447,7 +447,7 @@ const struct gfx_ops cairo_png_ops = {
.end = cr_png_end,
};
const struct gfx_ops cairo_pdf_ops = {
const struct gfx_ops cro_pdf_ops = {
.name = "pdf",
.line = record_line,
.poly = record_poly,

View File

@ -1,5 +1,5 @@
/*
* cairo.h - Cairo graphics back-end
* cro.h - Cairo graphics back-end
*
* Written 2016 by Werner Almesberger
* Copyright 2016 by Werner Almesberger
@ -11,21 +11,21 @@
*/
#ifndef MY_CAIRO_H
#define MY_CAIRO_H
#ifndef CRO_H
#define CRO_H
#include <stdint.h>
#include "gfx.h"
extern const struct gfx_ops cairo_png_ops;
extern const struct gfx_ops cairo_pdf_ops;
extern const struct gfx_ops cro_png_ops;
extern const struct gfx_ops cro_pdf_ops;
#define cairo_img_ops cairo_png_ops /* just don't call cairo_img_ops.end */
#define cro_img_ops cro_png_ops /* just don't call cro_img_ops.end */
uint32_t *cairo_img_end(void *ctx, int *w, int *h, int *stride);
void cairo_img_write(void *ctx, const char *name);
uint32_t *cro_img_end(void *ctx, int *w, int *h, int *stride);
void cro_img_write(void *ctx, const char *name);
#endif /* !MY_CAIRO_H */
#endif /* !CRO_H */

View File

@ -19,7 +19,7 @@
#include "util.h"
#include "main.h"
#include "cairo.h"
#include "cro.h"
#include "sch.h"
#include "lib.h"
#include "diff.h"
@ -51,7 +51,7 @@ static void diff_line(void *ctx, int sx, int sy, int ex, int ey,
{
const struct diff *diff = ctx;
cairo_img_ops.line(diff->cr_ctx, sx, sy, ex, ey, color, layer);
cro_img_ops.line(diff->cr_ctx, sx, sy, ex, ey, color, layer);
}
@ -61,8 +61,7 @@ static void diff_poly(void *ctx,
{
const struct diff *diff = ctx;
cairo_img_ops.poly(diff->cr_ctx, points, x, y,
color, fill_color, layer);
cro_img_ops.poly(diff->cr_ctx, points, x, y, color, fill_color, layer);
}
@ -71,7 +70,7 @@ static void diff_circ(void *ctx, int x, int y, int r,
{
const struct diff *diff = ctx;
cairo_img_ops.circ(diff->cr_ctx, x, y, r, color, fill_color, layer);
cro_img_ops.circ(diff->cr_ctx, x, y, r, color, fill_color, layer);
}
@ -80,7 +79,7 @@ static void diff_arc(void *ctx, int x, int y, int r, int sa, int ea,
{
const struct diff *diff = ctx;
cairo_img_ops.arc(diff->cr_ctx, x, y, r, sa, ea,
cro_img_ops.arc(diff->cr_ctx, x, y, r, sa, ea,
color, fill_color, layer);
}
@ -90,7 +89,7 @@ static void diff_text(void *ctx, int x, int y, const char *s, unsigned size,
{
const struct diff *diff = ctx;
cairo_img_ops.text(diff->cr_ctx, x, y, s, size, align, rot,
cro_img_ops.text(diff->cr_ctx, x, y, s, size, align, rot,
color, layer);
}
@ -99,7 +98,7 @@ static unsigned diff_text_width(void *ctx, const char *s, unsigned size)
{
const struct diff *diff = ctx;
return cairo_img_ops.text_width(diff->cr_ctx, s, size);
return cro_img_ops.text_width(diff->cr_ctx, s, size);
}
@ -128,7 +127,7 @@ static void *diff_init(int argc, char *const *argv)
diff->output_name = optarg;
break;
case 's':
/* for cairo_png */
/* for cro_png */
break;
default:
usage(*argv);
@ -142,14 +141,14 @@ static void *diff_init(int argc, char *const *argv)
sch_parse(&new_sch, argv[argc - 1], &new_lib);
optind = 0;
gfx_init(&cairo_img_ops, argc, argv);
gfx_init(&cro_img_ops, argc, argv);
diff->cr_ctx = gfx_ctx;
sch_render(new_sch.sheets);
diff->new_img = cairo_img_end(gfx_ctx,
diff->new_img = cro_img_end(gfx_ctx,
&diff->w, &diff->h, &diff->stride);
optind = 0;
diff->cr_ctx = cairo_img_ops.init(argc, argv);
diff->cr_ctx = cro_img_ops.init(argc, argv);
return diff;
}
@ -249,7 +248,7 @@ static void diff_end(void *ctx)
uint32_t *old_img;
int w, h, stride;
old_img = cairo_img_end(diff->cr_ctx, &w, &h, &stride);
old_img = cro_img_end(diff->cr_ctx, &w, &h, &stride);
if (diff->w != w || diff->h != h) {
fprintf(stderr, "%d x %d vs. %d x %d image\n",
w, h, diff->w, diff->h);
@ -260,7 +259,7 @@ static void diff_end(void *ctx)
show_areas(diff, old_img);
if (diff->output_name)
cairo_img_write(diff->cr_ctx, diff->output_name);
cro_img_write(diff->cr_ctx, diff->output_name);
}

View File

@ -19,7 +19,7 @@
#include "util.h"
#include "fig.h"
#include "cairo.h"
#include "cro.h"
#include "diff.h"
#include "gfx.h"
#include "lib.h"
@ -29,8 +29,8 @@
static struct gfx_ops const *ops_list[] = {
&fig_ops,
&cairo_png_ops,
&cairo_pdf_ops,
&cro_png_ops,
&cro_pdf_ops,
&diff_ops,
};
@ -127,6 +127,5 @@ found:
} else {
sch_render(sch_ctx.sheets);
}
//gfx_init(&cairo_ops, template, n_vars, vars);
gfx_end();
}