summaryrefslogtreecommitdiff
path: root/gfx
diff options
context:
space:
mode:
authorWerner Almesberger <werner@almesberger.net>2016-08-20 15:05:34 -0300
committerWerner Almesberger <werner@almesberger.net>2016-08-20 15:05:34 -0300
commit39fe8984c452f304b2946bf3125512499aa714dc (patch)
tree478f1b590b1c27be81a9d73d43586a7d75b35470 /gfx
parent7ddbb6d35f2af3be0ede0d13bf795b2333739e61 (diff)
downloadeeshow-39fe8984c452f304b2946bf3125512499aa714dc.tar.gz
eeshow-39fe8984c452f304b2946bf3125512499aa714dc.tar.bz2
eeshow-39fe8984c452f304b2946bf3125512499aa714dc.zip
eeshow/gfx/: don't overthink coordinate transforms
The xe/ye element was completely unnecessary because we never have an offset at the pixel level. Furthermore, it was used incorrectly, causing a shift between old and new when xmin/ymin differed.
Diffstat (limited to 'gfx')
-rw-r--r--gfx/cro.c9
-rw-r--r--gfx/cro.h1
-rw-r--r--gfx/diff.c14
3 files changed, 2 insertions, 22 deletions
diff --git a/gfx/cro.c b/gfx/cro.c
index 317ff10..65e241c 100644
--- a/gfx/cro.c
+++ b/gfx/cro.c
@@ -45,7 +45,6 @@ struct cro_ctx {
struct record record; /* must be first */
int xo, yo; /* offset in target (e.g., canvas) coord */
- int xe, ye; /* additional offset in eeschema coord */
float scale;
cairo_t *cr;
@@ -74,13 +73,13 @@ static inline int dc(const struct cro_ctx *cc, int x)
static inline int cx(const struct cro_ctx *cc, int x)
{
- return cc->xo + (x + cc->xe) * cc->scale;
+ return cc->xo + x * cc->scale;
}
static inline int cy(const struct cro_ctx *cc, int y)
{
- return cc->yo + (y + cc->ye) * cc->scale;
+ return cc->yo + y * cc->scale;
}
@@ -265,7 +264,6 @@ static struct cro_ctx *new_cc(void)
cc = alloc_type(struct cro_ctx);
cc->xo = cc->yo = 0;
- cc->xe = cc->ye = 0;
cc->scale = DEFAULT_SCALE;
cc->sheets = NULL;
@@ -535,7 +533,6 @@ void cro_canvas_draw(struct cro_ctx *cc, cairo_t *cr, int xo, int yo,
uint32_t *cro_img(struct cro_ctx *ctx, int xo, int yo, int w, int h,
- int xe, int ye,
float scale, cairo_t **res_cr, int *res_stride)
{
int stride;
@@ -562,8 +559,6 @@ uint32_t *cro_img(struct cro_ctx *ctx, int xo, int yo, int w, int h,
ctx->s = s;
ctx->xo = xo;
ctx->yo = yo;
- ctx->xe = xe;
- ctx->ye = ye;
ctx->scale = scale;
ctx->color_override = COLOR_NONE;
diff --git a/gfx/cro.h b/gfx/cro.h
index 954a3d7..3e9d9fd 100644
--- a/gfx/cro.h
+++ b/gfx/cro.h
@@ -44,7 +44,6 @@ void cro_canvas_draw(struct cro_ctx *cc, cairo_t *cr,
int x, int y, float scale);
uint32_t *cro_img(struct cro_ctx *ctx, int x0, int yo, int w, int h,
- int xe, int ye,
float scale, cairo_t **res_cr, int *res_stride);
#endif /* !GFX_CRO_H */
diff --git a/gfx/diff.c b/gfx/diff.c
index 05f4f18..14a9f68 100644
--- a/gfx/diff.c
+++ b/gfx/diff.c
@@ -350,29 +350,15 @@ void diff_to_canvas(cairo_t *cr, int cx, int cy, float scale,
merge_coord(old_xmin, new_xmin, old_w, new_w, &xmin, &w);
merge_coord(old_ymin, new_ymin, old_h, new_h, &ymin, &h);
- /*
- * We use two sets of offset differences: one applied to eeschema
- * coordinates (the xe, ye pair), and one applied to canvas coordinates
- * (the xo, yo pair).
- *
- * This is to prevent different offsets from leading to rounding
- * differences, resulting in single-pixel differences, which in turn
- * the differences algorithm will be eager to mark with big yellow
- * boxes.
- */
img_old = cro_img(old,
sw / 2.0 - (cx + xmin) * scale,
sh / 2.0 - (cy + ymin) * scale,
sw, sh,
- xmin - old_xmin,
- ymin - old_ymin,
scale, &old_cr, &stride);
img_new = cro_img(new,
sw / 2.0 - (cx + xmin) * scale,
sh / 2.0 - (cy + ymin) * scale,
sw, sh,
- xmin - new_xmin,
- ymin - new_ymin,
scale, NULL, NULL);
struct diff diff = {