[sprixel_create] eliminate copy of glyph

pull/1477/head
nick black 3 years ago
parent fac56fc2cc
commit 11685e77cc
No known key found for this signature in database
GPG Key ID: 5F43400C21CBFACC

@ -755,7 +755,7 @@ void sprixel_free(sprixel* s);
void sprixel_invalidate(sprixel* s);
void sprixel_hide(sprixel* s);
// dimy and dimx are cell geometry, not pixel
sprixel* sprixel_create(ncplane* n, const char* s, int bytes, int placey, int placex,
sprixel* sprixel_create(ncplane* n, char* s, int bytes, int placey, int placex,
int sprixelid, int dimy, int dimx, int pixy, int pixx,
int parse_start, int* tacache);
API int sprite_wipe_cell(const notcurses* nc, sprixel* s, int y, int x);
@ -1160,7 +1160,7 @@ egc_rtl(const char* egc, int* bytes){
// a reference to the context-wide sprixel cache. this ought be an entirely
// new, purpose-specific plane.
static inline int
plane_blit_sixel(ncplane* n, const char* s, int bytes, int placey, int placex,
plane_blit_sixel(ncplane* n, char* s, int bytes, int placey, int placex,
int leny, int lenx, int sprixelid, int dimy, int dimx,
int parse_start, int* tacache){
sprixel* spx = sprixel_create(n, s, bytes, placey, placex, sprixelid,

@ -303,6 +303,7 @@ int kitty_blit(ncplane* nc, int linesize, const void* data,
free(buf);
return -1;
}
// takes ownership of |buf| on success
if(plane_blit_sixel(nc, buf, size, bargs->placey, bargs->placex,
rows, cols, bargs->u.pixel.sprixelid, leny, lenx,
parse_start, tacache) < 0){
@ -310,7 +311,6 @@ int kitty_blit(ncplane* nc, int linesize, const void* data,
free(buf);
return -1;
}
free(buf);
return 1;
}

@ -507,6 +507,7 @@ int sixel_blit_inner(ncplane* nc, int leny, int lenx, sixeltable* stab,
free(buf);
return -1;
}
// takes ownership of |buf| on success
if(plane_blit_sixel(nc, buf, size, bargs->placey, bargs->placex,
rows, cols, bargs->u.pixel.sprixelid, leny, lenx,
parse_start, tacache) < 0){
@ -514,7 +515,6 @@ int sixel_blit_inner(ncplane* nc, int leny, int lenx, sixeltable* stab,
free(buf);
return -1;
}
free(buf);
return 1;
}

@ -30,15 +30,12 @@ sprixel* sprixel_by_id(notcurses* nc, uint32_t id){
}
// y and x are the cell geometry, not the pixel geometry
sprixel* sprixel_create(ncplane* n, const char* s, int bytes, int placey, int placex,
sprixel* sprixel_create(ncplane* n, char* s, int bytes, int placey, int placex,
int sprixelid, int dimy, int dimx, int pixy, int pixx,
int parse_start, int* tacache){
sprixel* ret = malloc(sizeof(sprixel));
if(ret){
if((ret->glyph = memdup(s, bytes + 1)) == NULL){
free(ret);
return NULL;
}
ret->glyph = s;
ret->glyphlen = bytes;
ret->tacache = tacache;
ret->invalidated = SPRIXEL_INVALIDATED;

Loading…
Cancel
Save