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

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.
This commit is contained in:
Werner Almesberger 2016-08-20 15:05:34 -03:00
parent 1e13572283
commit 3b76b058fd
3 changed files with 2 additions and 22 deletions

View File

@ -45,7 +45,6 @@ struct cro_ctx {
struct record record; /* must be first */ struct record record; /* must be first */
int xo, yo; /* offset in target (e.g., canvas) coord */ int xo, yo; /* offset in target (e.g., canvas) coord */
int xe, ye; /* additional offset in eeschema coord */
float scale; float scale;
cairo_t *cr; 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) 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) 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 = alloc_type(struct cro_ctx);
cc->xo = cc->yo = 0; cc->xo = cc->yo = 0;
cc->xe = cc->ye = 0;
cc->scale = DEFAULT_SCALE; cc->scale = DEFAULT_SCALE;
cc->sheets = NULL; 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, 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) float scale, cairo_t **res_cr, int *res_stride)
{ {
int 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->s = s;
ctx->xo = xo; ctx->xo = xo;
ctx->yo = yo; ctx->yo = yo;
ctx->xe = xe;
ctx->ye = ye;
ctx->scale = scale; ctx->scale = scale;
ctx->color_override = COLOR_NONE; ctx->color_override = COLOR_NONE;

View File

@ -44,7 +44,6 @@ void cro_canvas_draw(struct cro_ctx *cc, cairo_t *cr,
int x, int y, float scale); int x, int y, float scale);
uint32_t *cro_img(struct cro_ctx *ctx, int x0, int yo, int w, int h, 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); float scale, cairo_t **res_cr, int *res_stride);
#endif /* !GFX_CRO_H */ #endif /* !GFX_CRO_H */

View File

@ -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_xmin, new_xmin, old_w, new_w, &xmin, &w);
merge_coord(old_ymin, new_ymin, old_h, new_h, &ymin, &h); 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, img_old = cro_img(old,
sw / 2.0 - (cx + xmin) * scale, sw / 2.0 - (cx + xmin) * scale,
sh / 2.0 - (cy + ymin) * scale, sh / 2.0 - (cy + ymin) * scale,
sw, sh, sw, sh,
xmin - old_xmin,
ymin - old_ymin,
scale, &old_cr, &stride); scale, &old_cr, &stride);
img_new = cro_img(new, img_new = cro_img(new,
sw / 2.0 - (cx + xmin) * scale, sw / 2.0 - (cx + xmin) * scale,
sh / 2.0 - (cy + ymin) * scale, sh / 2.0 - (cy + ymin) * scale,
sw, sh, sw, sh,
xmin - new_xmin,
ymin - new_ymin,
scale, NULL, NULL); scale, NULL, NULL);
struct diff diff = { struct diff diff = {