From 6944dd5bf8e198eff68c2edae4f7638733fe9b39 Mon Sep 17 00:00:00 2001 From: nick black Date: Sat, 1 May 2021 17:37:48 -0400 Subject: [PATCH] sprixel: remove x/y fields, as we now shrink the plane to fit #1612 --- src/lib/direct.c | 2 +- src/lib/internal.h | 10 ++++------ src/lib/render.c | 4 ---- src/lib/sprite.c | 14 ++++---------- src/lib/visual.c | 4 +--- 5 files changed, 10 insertions(+), 24 deletions(-) diff --git a/src/lib/direct.c b/src/lib/direct.c index c68642efb..d5a6978f6 100644 --- a/src/lib/direct.c +++ b/src/lib/direct.c @@ -554,7 +554,7 @@ ncdirect_render_visual(ncdirect* n, ncvisual* ncv, ncblitter_e blitfxn, bargs.u.pixel.colorregs = n->tcache.color_registers; int cols = lenx / bargs.u.pixel.celldimx + !!(lenx % bargs.u.pixel.celldimx); int rows = leny / bargs.u.pixel.celldimy + !!(leny % bargs.u.pixel.celldimy); - if((bargs.u.pixel.spx = sprixel_alloc(ncdv, rows, cols, 0, 0)) == NULL){ + if((bargs.u.pixel.spx = sprixel_alloc(ncdv, rows, cols)) == NULL){ free_plane(ncdv); return NULL; } diff --git a/src/lib/internal.h b/src/lib/internal.h index 4413e7924..299766b6f 100644 --- a/src/lib/internal.h +++ b/src/lib/internal.h @@ -171,7 +171,6 @@ typedef struct sprixel { sprixel_e invalidated;// sprixel invalidation state struct sprixel* next; struct sprixel* prev; - int y, x; int dimy, dimx; // cell geometry int pixy, pixx; // pixel geometry (might be smaller than cell geo) int cellpxy, cellpxx; // cell-pixel geometry at time of creation @@ -951,12 +950,11 @@ void sprixel_hide(sprixel* s); int kitty_draw(const ncpile *p, sprixel* s, FILE* out); int sixel_draw(const ncpile *p, sprixel* s, FILE* out); -// dimy and dimx are cell geometry, not pixel. pixy/pixx are of course pixel. -sprixel* sprixel_alloc(ncplane* n, int dimy, int dimx, int placey, int placex); +// dimy and dimx are cell geometry, not pixel. +sprixel* sprixel_alloc(ncplane* n, int dimy, int dimx); sprixel* sprixel_recycle(ncplane* n); // takes ownership of s on success. -int sprixel_load(sprixel* spx, char* s, int bytes, int placey, int placex, - int pixy, int pixx, int parse_start); +int sprixel_load(sprixel* spx, char* s, int bytes, int pixy, int pixx, int parse_start); int sixel_destroy(const notcurses* nc, const ncpile* p, FILE* out, sprixel* s); int kitty_destroy(const notcurses* nc, const ncpile* p, FILE* out, sprixel* s); int kitty_remove(int id, FILE* out); @@ -1468,7 +1466,7 @@ static inline int plane_blit_sixel(sprixel* spx, char* s, int bytes, int rows, int cols, int placey, int placex, int leny, int lenx, int parse_start, tament* tam){ - if(sprixel_load(spx, s, bytes, placey, placex, leny, lenx, parse_start)){ + if(sprixel_load(spx, s, bytes, leny, lenx, parse_start)){ return -1; } ncplane* n = spx->n; diff --git a/src/lib/render.c b/src/lib/render.c index 83662e567..dd7cf4ce8 100644 --- a/src/lib/render.c +++ b/src/lib/render.c @@ -933,8 +933,6 @@ clean_sprixels(notcurses* nc, ncpile* p, FILE* out){ } int y, x; ncplane_yx(s->n, &y, &x); - y += s->y; - x += s->x; //fprintf(stderr, "DRAWING BITMAP %d STATE %d AT %d/%d for %p\n", s->id, s->invalidated, y + nc->stdplane->absy, x + nc->stdplane->absx, s->n); if(goto_location(nc, out, y + nc->stdplane->absy, x + nc->stdplane->absx) == 0){ if(sprite_draw(nc, p, s, out)){ @@ -961,8 +959,6 @@ rasterize_sprixels(notcurses* nc, ncpile* p, FILE* out){ if(s->invalidated == SPRIXEL_INVALIDATED){ int y, x; ncplane_yx(s->n, &y, &x); - y += s->y; - x += s->x; //fprintf(stderr, "DRAWING BITMAP %d STATE %d AT %d/%d for %p\n", s->id, s->invalidated, y + nc->stdplane->absy, x + nc->stdplane->absx, s->n); if(goto_location(nc, out, y + nc->stdplane->absy, x + nc->stdplane->absx) == 0){ if(sprite_draw(nc, p, s, out)){ diff --git a/src/lib/sprite.c b/src/lib/sprite.c index 74c747bec..f4b74cf8f 100644 --- a/src/lib/sprite.c +++ b/src/lib/sprite.c @@ -57,10 +57,8 @@ sprixel* sprixel_recycle(ncplane* n){ sprixel* hides = n->sprite; int dimy = hides->dimy; int dimx = hides->dimx; - int y = hides->y; - int x = hides->x; sprixel_hide(hides); - return sprixel_alloc(n, dimy, dimx, y, x); + return sprixel_alloc(n, dimy, dimx); } return n->sprite; } @@ -120,15 +118,13 @@ sprixel* sprixel_by_id(const ncpile* n, uint32_t id){ return NULL; } -sprixel* sprixel_alloc(ncplane* n, int dimy, int dimx, int placey, int placex){ +sprixel* sprixel_alloc(ncplane* n, int dimy, int dimx){ sprixel* ret = malloc(sizeof(sprixel)); if(ret){ memset(ret, 0, sizeof(*ret)); ret->n = n; ret->dimy = dimy; ret->dimx = dimx; - ret->y = placey; - ret->x = placex; ret->id = ++sprixelid_nonce; //fprintf(stderr, "LOOKING AT %p (p->n = %p)\n", ret, ret->n); if(ncplane_pile(ret->n)){ @@ -152,8 +148,8 @@ sprixel* sprixel_alloc(ncplane* n, int dimy, int dimx, int placey, int placex){ // 'y' and 'x' are the cell geometry, not the pixel geometry. takes // ownership of 's' on success. pixel geometry ought include any Sixel excess. -int sprixel_load(sprixel* spx, char* s, int bytes, int placey, int placex, - int pixy, int pixx, int parse_start){ +int sprixel_load(sprixel* spx, char* s, int bytes, int pixy, int pixx, + int parse_start){ assert(spx->n); free(spx->glyph); spx->glyph = s; @@ -161,8 +157,6 @@ int sprixel_load(sprixel* spx, char* s, int bytes, int placey, int placex, spx->invalidated = SPRIXEL_INVALIDATED; spx->pixx = pixx; spx->pixy = pixy; - spx->y = placey; - spx->x = placex; spx->parse_start = parse_start; return 0; } diff --git a/src/lib/visual.c b/src/lib/visual.c index 15891b4e4..cea301d56 100644 --- a/src/lib/visual.c +++ b/src/lib/visual.c @@ -723,15 +723,13 @@ ncplane* ncvisual_render_pixels(notcurses* nc, ncvisual* ncv, const struct blits } bargs.begy = begy; bargs.begx = begx; - bargs.placey = placey; - bargs.placex = placex; bargs.u.pixel.celldimx = nc->tcache.cellpixx; bargs.u.pixel.celldimy = nc->tcache.cellpixy; bargs.u.pixel.colorregs = nc->tcache.color_registers; if(n->sprite == NULL){ int cols = dispcols / bargs.u.pixel.celldimx + !!(dispcols % bargs.u.pixel.celldimx); int rows = disprows / bargs.u.pixel.celldimy + !!(disprows % bargs.u.pixel.celldimy); - if((n->sprite = sprixel_alloc(n, rows, cols, placey, placex)) == NULL){ + if((n->sprite = sprixel_alloc(n, rows, cols)) == NULL){ ncplane_destroy(createdn); return NULL; }