sprixel: remove x/y fields, as we now shrink the plane to fit #1612

pull/1621/head
nick black 3 years ago
parent 70357f7173
commit 6944dd5bf8
No known key found for this signature in database
GPG Key ID: 5F43400C21CBFACC

@ -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;
}

@ -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;

@ -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)){

@ -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;
}

@ -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;
}

Loading…
Cancel
Save