mirror of
https://github.com/dankamongmen/notcurses.git
synced 2024-11-20 03:25:47 +00:00
sprixel: remove x/y fields, as we now shrink the plane to fit #1612
This commit is contained in:
parent
70357f7173
commit
6944dd5bf8
@ -554,7 +554,7 @@ ncdirect_render_visual(ncdirect* n, ncvisual* ncv, ncblitter_e blitfxn,
|
|||||||
bargs.u.pixel.colorregs = n->tcache.color_registers;
|
bargs.u.pixel.colorregs = n->tcache.color_registers;
|
||||||
int cols = lenx / bargs.u.pixel.celldimx + !!(lenx % bargs.u.pixel.celldimx);
|
int cols = lenx / bargs.u.pixel.celldimx + !!(lenx % bargs.u.pixel.celldimx);
|
||||||
int rows = leny / bargs.u.pixel.celldimy + !!(leny % bargs.u.pixel.celldimy);
|
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);
|
free_plane(ncdv);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -171,7 +171,6 @@ typedef struct sprixel {
|
|||||||
sprixel_e invalidated;// sprixel invalidation state
|
sprixel_e invalidated;// sprixel invalidation state
|
||||||
struct sprixel* next;
|
struct sprixel* next;
|
||||||
struct sprixel* prev;
|
struct sprixel* prev;
|
||||||
int y, x;
|
|
||||||
int dimy, dimx; // cell geometry
|
int dimy, dimx; // cell geometry
|
||||||
int pixy, pixx; // pixel geometry (might be smaller than cell geo)
|
int pixy, pixx; // pixel geometry (might be smaller than cell geo)
|
||||||
int cellpxy, cellpxx; // cell-pixel geometry at time of creation
|
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 kitty_draw(const ncpile *p, sprixel* s, FILE* out);
|
||||||
int sixel_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.
|
// dimy and dimx are cell geometry, not pixel.
|
||||||
sprixel* sprixel_alloc(ncplane* n, int dimy, int dimx, int placey, int placex);
|
sprixel* sprixel_alloc(ncplane* n, int dimy, int dimx);
|
||||||
sprixel* sprixel_recycle(ncplane* n);
|
sprixel* sprixel_recycle(ncplane* n);
|
||||||
// takes ownership of s on success.
|
// takes ownership of s on success.
|
||||||
int sprixel_load(sprixel* spx, char* s, int bytes, int placey, int placex,
|
int sprixel_load(sprixel* spx, char* s, int bytes, int pixy, int pixx, int parse_start);
|
||||||
int pixy, int pixx, int parse_start);
|
|
||||||
int sixel_destroy(const notcurses* nc, const ncpile* p, FILE* out, sprixel* s);
|
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_destroy(const notcurses* nc, const ncpile* p, FILE* out, sprixel* s);
|
||||||
int kitty_remove(int id, FILE* out);
|
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,
|
plane_blit_sixel(sprixel* spx, char* s, int bytes, int rows, int cols,
|
||||||
int placey, int placex, int leny, int lenx,
|
int placey, int placex, int leny, int lenx,
|
||||||
int parse_start, tament* tam){
|
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;
|
return -1;
|
||||||
}
|
}
|
||||||
ncplane* n = spx->n;
|
ncplane* n = spx->n;
|
||||||
|
@ -933,8 +933,6 @@ clean_sprixels(notcurses* nc, ncpile* p, FILE* out){
|
|||||||
}
|
}
|
||||||
int y, x;
|
int y, x;
|
||||||
ncplane_yx(s->n, &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);
|
//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(goto_location(nc, out, y + nc->stdplane->absy, x + nc->stdplane->absx) == 0){
|
||||||
if(sprite_draw(nc, p, s, out)){
|
if(sprite_draw(nc, p, s, out)){
|
||||||
@ -961,8 +959,6 @@ rasterize_sprixels(notcurses* nc, ncpile* p, FILE* out){
|
|||||||
if(s->invalidated == SPRIXEL_INVALIDATED){
|
if(s->invalidated == SPRIXEL_INVALIDATED){
|
||||||
int y, x;
|
int y, x;
|
||||||
ncplane_yx(s->n, &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);
|
//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(goto_location(nc, out, y + nc->stdplane->absy, x + nc->stdplane->absx) == 0){
|
||||||
if(sprite_draw(nc, p, s, out)){
|
if(sprite_draw(nc, p, s, out)){
|
||||||
|
@ -57,10 +57,8 @@ sprixel* sprixel_recycle(ncplane* n){
|
|||||||
sprixel* hides = n->sprite;
|
sprixel* hides = n->sprite;
|
||||||
int dimy = hides->dimy;
|
int dimy = hides->dimy;
|
||||||
int dimx = hides->dimx;
|
int dimx = hides->dimx;
|
||||||
int y = hides->y;
|
|
||||||
int x = hides->x;
|
|
||||||
sprixel_hide(hides);
|
sprixel_hide(hides);
|
||||||
return sprixel_alloc(n, dimy, dimx, y, x);
|
return sprixel_alloc(n, dimy, dimx);
|
||||||
}
|
}
|
||||||
return n->sprite;
|
return n->sprite;
|
||||||
}
|
}
|
||||||
@ -120,15 +118,13 @@ sprixel* sprixel_by_id(const ncpile* n, uint32_t id){
|
|||||||
return NULL;
|
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));
|
sprixel* ret = malloc(sizeof(sprixel));
|
||||||
if(ret){
|
if(ret){
|
||||||
memset(ret, 0, sizeof(*ret));
|
memset(ret, 0, sizeof(*ret));
|
||||||
ret->n = n;
|
ret->n = n;
|
||||||
ret->dimy = dimy;
|
ret->dimy = dimy;
|
||||||
ret->dimx = dimx;
|
ret->dimx = dimx;
|
||||||
ret->y = placey;
|
|
||||||
ret->x = placex;
|
|
||||||
ret->id = ++sprixelid_nonce;
|
ret->id = ++sprixelid_nonce;
|
||||||
//fprintf(stderr, "LOOKING AT %p (p->n = %p)\n", ret, ret->n);
|
//fprintf(stderr, "LOOKING AT %p (p->n = %p)\n", ret, ret->n);
|
||||||
if(ncplane_pile(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
|
// 'y' and 'x' are the cell geometry, not the pixel geometry. takes
|
||||||
// ownership of 's' on success. pixel geometry ought include any Sixel excess.
|
// 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 sprixel_load(sprixel* spx, char* s, int bytes, int pixy, int pixx,
|
||||||
int pixy, int pixx, int parse_start){
|
int parse_start){
|
||||||
assert(spx->n);
|
assert(spx->n);
|
||||||
free(spx->glyph);
|
free(spx->glyph);
|
||||||
spx->glyph = s;
|
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->invalidated = SPRIXEL_INVALIDATED;
|
||||||
spx->pixx = pixx;
|
spx->pixx = pixx;
|
||||||
spx->pixy = pixy;
|
spx->pixy = pixy;
|
||||||
spx->y = placey;
|
|
||||||
spx->x = placex;
|
|
||||||
spx->parse_start = parse_start;
|
spx->parse_start = parse_start;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -723,15 +723,13 @@ ncplane* ncvisual_render_pixels(notcurses* nc, ncvisual* ncv, const struct blits
|
|||||||
}
|
}
|
||||||
bargs.begy = begy;
|
bargs.begy = begy;
|
||||||
bargs.begx = begx;
|
bargs.begx = begx;
|
||||||
bargs.placey = placey;
|
|
||||||
bargs.placex = placex;
|
|
||||||
bargs.u.pixel.celldimx = nc->tcache.cellpixx;
|
bargs.u.pixel.celldimx = nc->tcache.cellpixx;
|
||||||
bargs.u.pixel.celldimy = nc->tcache.cellpixy;
|
bargs.u.pixel.celldimy = nc->tcache.cellpixy;
|
||||||
bargs.u.pixel.colorregs = nc->tcache.color_registers;
|
bargs.u.pixel.colorregs = nc->tcache.color_registers;
|
||||||
if(n->sprite == NULL){
|
if(n->sprite == NULL){
|
||||||
int cols = dispcols / bargs.u.pixel.celldimx + !!(dispcols % bargs.u.pixel.celldimx);
|
int cols = dispcols / bargs.u.pixel.celldimx + !!(dispcols % bargs.u.pixel.celldimx);
|
||||||
int rows = disprows / bargs.u.pixel.celldimy + !!(disprows % bargs.u.pixel.celldimy);
|
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);
|
ncplane_destroy(createdn);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user