Skip to content

Commit

Permalink
kill deprecated style functions #1777
Browse files Browse the repository at this point in the history
  • Loading branch information
dankamongmen committed Oct 12, 2021
1 parent bfbfda5 commit a699480
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 61 deletions.
13 changes: 0 additions & 13 deletions include/notcurses/notcurses.h
Original file line number Diff line number Diff line change
Expand Up @@ -4082,19 +4082,6 @@ API void ncreader_destroy(struct ncreader* n, char** contents);
API void notcurses_debug(const struct notcurses* nc, FILE* debugfp)
__attribute__ ((nonnull (1, 2)));

// DEPRECATED MATERIAL, GOING AWAY IN ABI3

__attribute__ ((deprecated)) API int cell_duplicate(struct ncplane* n, nccell* targ, const nccell* c);

__attribute__ ((deprecated)) API void cell_release(struct ncplane* n, nccell* c);

API void ncplane_styles_set(struct ncplane* n, unsigned stylebits)
__attribute__ ((deprecated));
API void ncplane_styles_on(struct ncplane* n, unsigned stylebits)
__attribute__ ((deprecated));
API void ncplane_styles_off(struct ncplane* n, unsigned stylebits)
__attribute__ ((deprecated));

#undef API
#undef ALLOC

Expand Down
6 changes: 3 additions & 3 deletions src/demo/demo.c
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ summary_json(FILE* f, const char* spec, int rows, int cols){
continue;
}
ret |= (fprintf(f, "\"%s\":{\"bytes\":\"%"PRIu64"\",\"frames\":\"%"PRIu64"\",\"ns\":\"%"PRIu64"\"}%s",
demos[results[i].selector - 'a'].name, results[i].stats.render_bytes,
demos[results[i].selector - 'a'].name, results[i].stats.raster_bytes,
results[i].stats.renders, results[i].timens, i < strlen(spec) - 1 ? "," : "") < 0);
}
ret |= (fprintf(f, "}}}\n") < 0);
Expand Down Expand Up @@ -410,7 +410,7 @@ summary_table(struct notcurses* nc, const char* spec, bool canimage, bool canvid
for(size_t i = 0 ; i < strlen(spec) ; ++i){
nsdelta += results[i].timens;
qprefix(results[i].timens, NANOSECS_IN_SEC, timebuf, 0);
bprefix(results[i].stats.render_bytes, 1, totalbuf, 0);
bprefix(results[i].stats.raster_bytes, 1, totalbuf, 0);
uint64_t divisor = results[i].stats.render_ns + results[i].stats.writeout_ns + results[i].stats.raster_ns;
if(divisor){
qprefix((uintmax_t)results[i].stats.writeouts * NANOSECS_IN_SEC * 1000 / divisor,
Expand Down Expand Up @@ -454,7 +454,7 @@ summary_table(struct notcurses* nc, const char* spec, bool canimage, bool canvid
failed = true;
}
totalframes += results[i].stats.renders;
totalbytes += results[i].stats.render_bytes;
totalbytes += results[i].stats.raster_bytes;
totalrenderns += results[i].stats.render_ns;
totalwriteoutns += results[i].stats.writeout_ns;
}
Expand Down
2 changes: 1 addition & 1 deletion src/lib/internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@ void summarize_stats(notcurses* nc);

void update_raster_stats(const struct timespec* time1, const struct timespec* time0, ncstats* stats);
void update_render_stats(const struct timespec* time1, const struct timespec* time0, ncstats* stats);
void update_render_bytes(ncstats* stats, int bytes);
void update_raster_bytes(ncstats* stats, int bytes);
void update_write_stats(const struct timespec* time1, const struct timespec* time0, ncstats* stats, int bytes);

void sigwinch_handler(int signo);
Expand Down
12 changes: 0 additions & 12 deletions src/lib/notcurses.c
Original file line number Diff line number Diff line change
Expand Up @@ -1776,28 +1776,16 @@ void ncplane_set_styles(ncplane* n, unsigned stylebits){
n->stylemask = (stylebits & NCSTYLE_MASK);
}

void ncplane_styles_set(ncplane* n, unsigned stylebits){ // deprecated
ncplane_set_styles(n, stylebits);
}

// turn on any specified stylebits
void ncplane_on_styles(ncplane* n, unsigned stylebits){
n->stylemask |= (stylebits & NCSTYLE_MASK);
}

void ncplane_styles_on(ncplane* n, unsigned stylebits){ // deprecated
ncplane_on_styles(n, stylebits);
}

// turn off any specified stylebits
void ncplane_off_styles(ncplane* n, unsigned stylebits){
n->stylemask &= ~(stylebits & NCSTYLE_MASK);
}

void ncplane_styles_off(ncplane* n, unsigned stylebits){ // deprecated
ncplane_off_styles(n, stylebits);
}

// i hate the big allocation and two copies here, but eh what you gonna do?
// well, for one, we don't need the huge allocation FIXME
char* ncplane_vprintf_prep(const char* format, va_list ap){
Expand Down
16 changes: 3 additions & 13 deletions src/lib/render.c
Original file line number Diff line number Diff line change
Expand Up @@ -122,11 +122,6 @@ void nccell_release(ncplane* n, nccell* c){
pool_release(&n->pool, c);
}

// FIXME deprecated, goes away in abi3
void cell_release(ncplane* n, nccell* c){
nccell_release(n, c);
}

// Duplicate one cell onto another when they share a plane. Convenience wrapper.
int nccell_duplicate(ncplane* n, nccell* targ, const nccell* c){
if(cell_duplicate_far(&n->pool, targ, n, c) < 0){
Expand All @@ -136,11 +131,6 @@ int nccell_duplicate(ncplane* n, nccell* targ, const nccell* c){
return 0;
}

// deprecated, goes away in abi3
int cell_duplicate(struct ncplane* n, nccell* targ, const nccell* c){
return nccell_duplicate(n, targ, c);
}

// Emit fchannel with RGB changed to contrast effectively against bchannel.
static uint32_t
highcontrast(const tinfo* ti, uint32_t bchannel){
Expand Down Expand Up @@ -1471,7 +1461,7 @@ int ncpile_rasterize(ncplane* n){
// accepts -1 as an indication of failure
clock_gettime(CLOCK_MONOTONIC, &writedone);
pthread_mutex_lock(&nc->stats.lock);
update_render_bytes(&nc->stats.s, bytes);
update_raster_bytes(&nc->stats.s, bytes);
update_raster_stats(&rasterdone, &start, &nc->stats.s);
update_write_stats(&writedone, &rasterdone, &nc->stats.s, bytes);
pthread_mutex_unlock(&nc->stats.lock);
Expand Down Expand Up @@ -1517,7 +1507,7 @@ int ncpile_render(ncplane* n){
ncpile_render_internal(n, pile->crender, pile->dimy, pile->dimx);
clock_gettime(CLOCK_MONOTONIC, &renderdone);
pthread_mutex_lock(&nc->stats.lock);
update_render_stats(&renderdone, &start, &nc->stats.s);
update_raster_stats(&renderdone, &start, &nc->stats.s);
pthread_mutex_unlock(&nc->stats.lock);
return 0;
}
Expand All @@ -1534,7 +1524,7 @@ int ncpile_render_to_buffer(ncplane* p, char** buf, size_t* buflen){
fbuf_reset(&nc->rstate.f);
int bytes = notcurses_rasterize_inner(nc, ncplane_pile(p), &nc->rstate.f, &useasu);
pthread_mutex_lock(&nc->stats.lock);
update_render_bytes(&nc->stats.s, bytes);
update_raster_bytes(&nc->stats.s, bytes);
pthread_mutex_unlock(&nc->stats.lock);
if(bytes < 0){
return -1;
Expand Down
38 changes: 19 additions & 19 deletions src/lib/stats.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,16 @@ void update_write_stats(const struct timespec* time1, const struct timespec* tim
}

// negative 'bytes' are ignored as failures. call only while holding statlock.
// we don't increment failed_renders here because 'bytes' < 0 actually indicates
// a rasterization failure -- we can't fail in rendering anymore.
void update_render_bytes(ncstats* stats, int bytes){
// we don't increment failed_rasters here because 'bytes' < 0 actually indicates
// a rasterization failure -- we can't fail in rastering anymore.
void update_raster_bytes(ncstats* stats, int bytes){
if(bytes >= 0){
stats->render_bytes += bytes;
if(bytes > stats->render_max_bytes){
stats->render_max_bytes = bytes;
stats->raster_bytes += bytes;
if(bytes > stats->raster_max_bytes){
stats->raster_max_bytes = bytes;
}
if(bytes < stats->render_min_bytes){
stats->render_min_bytes = bytes;
if(bytes < stats->raster_min_bytes){
stats->raster_min_bytes = bytes;
}
}
}
Expand Down Expand Up @@ -76,7 +76,7 @@ void reset_stats(ncstats* stats){
unsigned planes = stats->planes;
memset(stats, 0, sizeof(*stats));
stats->render_min_ns = 1ull << 62u;
stats->render_min_bytes = 1ull << 62u;
stats->raster_min_bytes = 1ull << 62u;
stats->raster_min_ns = 1ull << 62u;
stats->writeout_min_ns = 1ull << 62u;
stats->fbbytes = fbbytes;
Expand Down Expand Up @@ -108,8 +108,8 @@ void notcurses_stats_reset(notcurses* nc, ncstats* stats){
if(nc->stats.s.render_min_ns < stash->render_min_ns){
stash->render_min_ns = nc->stats.s.render_min_ns;
}
if(nc->stats.s.render_min_bytes < stash->render_min_bytes){
stash->render_min_bytes = nc->stats.s.render_min_bytes;
if(nc->stats.s.raster_min_bytes < stash->raster_min_bytes){
stash->raster_min_bytes = nc->stats.s.raster_min_bytes;
}
if(nc->stats.s.raster_min_ns < stash->raster_min_ns){
stash->raster_min_ns = nc->stats.s.raster_min_ns;
Expand All @@ -120,8 +120,8 @@ void notcurses_stats_reset(notcurses* nc, ncstats* stats){
if(nc->stats.s.render_max_ns > stash->render_max_ns){
stash->render_max_ns = nc->stats.s.render_max_ns;
}
if(nc->stats.s.render_max_bytes > stash->render_max_bytes){
stash->render_max_bytes = nc->stats.s.render_max_bytes;
if(nc->stats.s.raster_max_bytes > stash->raster_max_bytes){
stash->raster_max_bytes = nc->stats.s.raster_max_bytes;
}
if(nc->stats.s.raster_max_ns > stash->raster_max_ns){
stash->raster_max_ns = nc->stats.s.raster_max_ns;
Expand All @@ -132,7 +132,7 @@ void notcurses_stats_reset(notcurses* nc, ncstats* stats){
stash->writeout_ns += nc->stats.s.writeout_ns;
stash->raster_ns += nc->stats.s.raster_ns;
stash->render_ns += nc->stats.s.render_ns;
stash->render_bytes += nc->stats.s.render_bytes;
stash->raster_bytes += nc->stats.s.raster_bytes;
stash->failed_renders += nc->stats.s.failed_renders;
stash->failed_writeouts += nc->stats.s.failed_writeouts;
stash->renders += nc->stats.s.renders;
Expand Down Expand Up @@ -198,11 +198,11 @@ void summarize_stats(notcurses* nc){
totalbuf, minbuf, avgbuf, maxbuf);
}
if(stats->renders || stats->input_events){
bprefix(stats->render_bytes, 1, totalbuf, 1),
bprefix(stats->render_bytes ? stats->render_min_bytes : 0,
bprefix(stats->raster_bytes, 1, totalbuf, 1),
bprefix(stats->raster_bytes ? stats->raster_min_bytes : 0,
1, minbuf, 1),
bprefix(stats->renders ? stats->render_bytes / stats->renders : 0, 1, avgbuf, 1);
bprefix(stats->render_max_bytes, 1, maxbuf, 1),
bprefix(stats->renders ? stats->raster_bytes / stats->renders : 0, 1, avgbuf, 1);
bprefix(stats->raster_max_bytes, 1, maxbuf, 1),
fprintf(stderr, "%s%sB (%sB min, %sB avg, %sB max) %"PRIu64" input%s" NL,
clreol, totalbuf, minbuf, avgbuf, maxbuf,
stats->input_events,
Expand Down Expand Up @@ -236,7 +236,7 @@ void summarize_stats(notcurses* nc){
(stats->sprixelemissions + stats->sprixelelisions) == 0 ? 0 :
(stats->sprixelelisions * 100.0) / (stats->sprixelemissions + stats->sprixelelisions),
totalbuf,
stats->render_bytes ? (stats->sprixelbytes * 100.0) / stats->render_bytes : 0,
stats->raster_bytes ? (stats->sprixelbytes * 100.0) / stats->raster_bytes : 0,
stats->appsync_updates,
stats->writeouts ? stats->appsync_updates * 100.0 / stats->writeouts : 0);
}

0 comments on commit a699480

Please sign in to comment.