diff --git a/NEWS.md b/NEWS.md index c983d7a73..b0b348f4a 100644 --- a/NEWS.md +++ b/NEWS.md @@ -20,7 +20,12 @@ rearrangements of Notcurses. * `ncreader_options` has lost its `echannels`, `eattrword`, `egc`, `physrows`, and `physcols` fields. Just set the base character and size for the `ncplane`. - * ... + * Functions which set a 24-bit RGB value have had the suffix `g` replaced + with `g_rgb`. Functions which set three 8-bit RGB components have had the + suffix `rgb` replaced with `rgb8`. This was done because e.g. + `channels_set_fg()` and `channels_set_fchannel()` were indistinguishable on + sight. Failure to make the necessary conversions will result in compiler + errors. See https://github.com/dankamongmen/notcurses/issues/985. * 1.7.2 (2020-09-09) * Exported `ncvisual_default_blitter()`, so that the effective value of diff --git a/USAGE.md b/USAGE.md index bf0d41f2a..7c8d50c1a 100644 --- a/USAGE.md +++ b/USAGE.md @@ -296,15 +296,15 @@ This context must be destroyed using `ncdirect_stop()`. The following functions are available for direct mode: ```c -int ncdirect_fg(struct ncdirect* nc, unsigned rgb); -int ncdirect_bg(struct ncdirect* nc, unsigned rgb); +int ncdirect_fg_rgb(struct ncdirect* nc, unsigned rgb); +int ncdirect_bg_rgb(struct ncdirect* nc, unsigned rgb); static inline int ncdirect_bg_rgb8(struct ncdirect* nc, unsigned r, unsigned g, unsigned b){ if(r > 255 || g > 255 || b > 255){ return -1; } - return ncdirect_bg(nc, (r << 16u) + (g << 8u) + b); + return ncdirect_bg_rgb(nc, (r << 16u) + (g << 8u) + b); } static inline int @@ -312,7 +312,7 @@ ncdirect_fg_rgb8(struct ncdirect* nc, unsigned r, unsigned g, unsigned b){ if(r > 255 || g > 255 || b > 255){ return -1; } - return ncdirect_fg(nc, (r << 16u) + (g << 8u) + b); + return ncdirect_fg_rgb(nc, (r << 16u) + (g << 8u) + b); } // Get the current number of columns/rows. @@ -1425,14 +1425,14 @@ ncplane_fchannel(const struct ncplane* nc){ // Extract 24 bits of working foreground RGB from an ncplane, shifted to LSBs. static inline unsigned -ncplane_fg(const struct ncplane* nc){ - return channels_fg(ncplane_channels(nc)); +ncplane_fg_rgb(const struct ncplane* nc){ + return channels_fg_rgb(ncplane_channels(nc)); } // Extract 24 bits of working background RGB from an ncplane, shifted to LSBs. static inline unsigned -ncplane_bg(const struct ncplane* nc){ - return channels_bg(ncplane_channels(nc)); +ncplane_bg_rgb(const struct ncplane* nc){ + return channels_bg_rgb(ncplane_channels(nc)); } // Extract 2 bits of foreground alpha from 'struct ncplane', shifted to LSBs. @@ -1453,14 +1453,14 @@ int ncplane_set_bg_alpha(struct ncplane* n, unsigned alpha); // Extract 24 bits of foreground RGB from 'n', split into subcomponents. static inline unsigned -ncplane_fg_rgb(const struct ncplane* n, unsigned* r, unsigned* g, unsigned* - return channels_fg_rgb(ncplane_channels(n), r, g, b); +ncplane_fg_rgb8(const struct ncplane* n, unsigned* r, unsigned* g, unsigned* + return channels_fg_rgb8(ncplane_channels(n), r, g, b); } // Extract 24 bits of background RGB from 'n', split into subcomponents. static inline unsigned -ncplane_bg_rgb(const struct ncplane* n, unsigned* r, unsigned* g, unsigned* - return channels_bg_rgb(ncplane_channels(n), r, g, b); +ncplane_bg_rgb8(const struct ncplane* n, unsigned* r, unsigned* g, unsigned* + return channels_bg_rgb8(ncplane_channels(n), r, g, b); } // Set the current fore/background color using RGB specifications. If the @@ -1469,16 +1469,16 @@ ncplane_bg_rgb(const struct ncplane* n, unsigned* r, unsigned* g, unsigned* // interpreted in some lossy fashion. None of r, g, or b may exceed 255. // "HP-like" terminals require setting foreground and background at the same // time using "color pairs"; notcurses will manage color pairs transparently. -int ncplane_set_fg_rgb(struct ncplane* n, int r, int g, int b); -int ncplane_set_bg_rgb(struct ncplane* n, int r, int g, int b); +int ncplane_set_fg_rgb8(struct ncplane* n, int r, int g, int b); +int ncplane_set_bg_rgb8(struct ncplane* n, int r, int g, int b); // Same, but clipped to [0..255]. void ncplane_set_bg_rgb_clipped(struct ncplane* n, int r, int g, int b); void ncplane_set_fg_rgb_clipped(struct ncplane* n, int r, int g, int b); // Same, but with rgb assembled into a channel (i.e. lower 24 bits). -int ncplane_set_fg(struct ncplane* n, uint32_t channel); -int ncplane_set_bg(struct ncplane* n, uint32_t channel); +int ncplane_set_fg_rgb(struct ncplane* n, uint32_t channel); +int ncplane_set_bg_rgb(struct ncplane* n, uint32_t channel); // Use the default color for the foreground/background. void ncplane_set_fg_default(struct ncplane* n); @@ -1773,14 +1773,14 @@ cell_fchannel(const cell* cl){ // Extract 24 bits of foreground RGB from 'cell', shifted to LSBs. static inline uint32_t -cell_fg(const cell* cl){ - return channels_fg(cl->channels); +cell_fg_rgb(const cell* cl){ + return channels_fg_rgb(cl->channels); } // Extract 24 bits of background RGB from 'cell', shifted to LSBs. static inline uint32_t -cell_bg(const cell* cl){ - return channels_bg(cl->channels); +cell_bg_rgb(const cell* cl){ + return channels_bg_rgb(cl->channels); } // Extract 2 bits of foreground alpha from 'cell', shifted to LSBs. @@ -1797,21 +1797,21 @@ cell_bg_alpha(const cell* cl){ // Extract 24 bits of foreground RGB from 'cell', split into subcell. static inline uint32_t -cell_fg_rgb(const cell* cl, unsigned* r, unsigned* g, unsigned* b){ - return channels_fg_rgb(cl->channels, r, g, b); +cell_fg_rgb8(const cell* cl, unsigned* r, unsigned* g, unsigned* b){ + return channels_fg_rgb8(cl->channels, r, g, b); } // Extract 24 bits of background RGB from 'cell', split into subcell. static inline uint32_t -cell_bg_rgb(const cell* cl, unsigned* r, unsigned* g, unsigned* b){ - return channels_bg_rgb(cl->channels, r, g, b); +cell_bg_rgb8(const cell* cl, unsigned* r, unsigned* g, unsigned* b){ + return channels_bg_rgb8(cl->channels, r, g, b); } // Set the r, g, and b cell for the foreground component of this 64-bit // 'cell' variable, and mark it as not using the default color. static inline int -cell_set_fg_rgb(cell* cl, int r, int g, int b){ - return channels_set_fg_rgb(&cl->channels, r, g, b); +cell_set_fg_rgb8(cell* cl, int r, int g, int b){ + return channels_set_fg_rgb8(&cl->channels, r, g, b); } // Same, but clipped to [0..255]. @@ -1822,15 +1822,15 @@ cell_set_fg_rgb_clipped(cell* cl, int r, int g, int b){ // Same, but with an assembled 24-bit RGB value. static inline int -cell_set_fg(cell* c, uint32_t channel){ - return channels_set_fg(&c->channels, channel); +cell_set_fg_rgb(cell* c, uint32_t channel){ + return channels_set_fg_rgb(&c->channels, channel); } // Set the r, g, and b cell for the background component of this 64-bit // 'cell' variable, and mark it as not using the default color. static inline int -cell_set_bg_rgb(cell* cl, int r, int g, int b){ - return channels_set_bg_rgb(&cl->channels, r, g, b); +cell_set_bg_rgb8(cell* cl, int r, int g, int b){ + return channels_set_bg_rgb8(&cl->channels, r, g, b); } // Same, but clipped to [0..255]. @@ -1841,8 +1841,8 @@ cell_set_bg_rgb_clipped(cell* cl, int r, int g, int b){ // Same, but with an assembled 24-bit RGB value. static inline int -cell_set_bg(cell* c, uint32_t channel){ - return channels_set_bg(&c->channels, channel); +cell_set_bg_rgb(cell* c, uint32_t channel){ + return channels_set_bg_rgb(&c->channels, channel); } static inline int @@ -2334,7 +2334,7 @@ channel_b(uint32_t channel){ // Extract the three 8-bit R/G/B components from a 32-bit channel. static inline unsigned -channel_rgb(uint32_t channel, unsigned* r, unsigned* g, unsigned* b){ +channel_rgb8(uint32_t channel, unsigned* r, unsigned* g, unsigned* b){ *r = channel_r(channel); *g = channel_g(channel); *b = channel_b(channel); @@ -2344,7 +2344,7 @@ channel_rgb(uint32_t channel, unsigned* r, unsigned* g, unsigned* b){ // Set the three 8-bit components of a 32-bit channel, and mark it as not using // the default color. Retain the other bits unchanged. static inline int -channel_set_rgb(unsigned* channel, int r, int g, int b){ +channel_set_rgb8(unsigned* channel, int r, int g, int b){ if(r >= 256 || g >= 256 || b >= 256){ return -1; } @@ -2410,13 +2410,13 @@ channels_fchannel(uint64_t channels){ // Extract 24 bits of foreground RGB from 'channels', shifted to LSBs. static inline unsigned -channels_fg(uint64_t channels){ +channels_fg_rgb(uint64_t channels){ return channels_fchannel(channels) & CELL_BG_MASK; } // Extract 24 bits of background RGB from 'channels', shifted to LSBs. static inline unsigned -channels_bg(uint64_t channels){ +channels_bg_rgb(uint64_t channels){ return channels_bchannel(channels) & CELL_BG_MASK; } @@ -2434,22 +2434,22 @@ channels_bg_alpha(uint64_t channels){ // Extract 24 bits of foreground RGB from 'channels', split into subchannels. static inline unsigned -channels_fg_rgb(uint64_t channels, unsigned* r, unsigned* g, unsigned* b){ - return channel_rgb(channels_fchannel(channels), r, g, b); +channels_fg_rgb8(uint64_t channels, unsigned* r, unsigned* g, unsigned* b){ + return channel_rgb8(channels_fchannel(channels), r, g, b); } // Extract 24 bits of background RGB from 'channels', split into subchannels. static inline unsigned -channels_bg_rgb(uint64_t channels, unsigned* r, unsigned* g, unsigned* b){ - return channel_rgb(channels_bchannel(channels), r, g, b); +channels_bg_rgb8(uint64_t channels, unsigned* r, unsigned* g, unsigned* b){ + return channel_rgb8(channels_bchannel(channels), r, g, b); } // Set the r, g, and b channels for the foreground component of this 64-bit // 'channels' variable, and mark it as not using the default color. static inline int -channels_set_fg_rgb(uint64_t* channels, int r, int g, int b){ +channels_set_fg_rgb8(uint64_t* channels, int r, int g, int b){ unsigned channel = channels_fchannel(*channels); - if(channel_set_rgb(&channel, r, g, b) < 0){ + if(channel_set_rgb8(&channel, r, g, b) < 0){ return -1; } *channels = ((uint64_t)channel << 32llu) | (*channels & 0xffffffffllu); @@ -2459,9 +2459,9 @@ channels_set_fg_rgb(uint64_t* channels, int r, int g, int b){ // Set the r, g, and b channels for the background component of this 64-bit // 'channels' variable, and mark it as not using the default color. static inline int -channels_set_bg_rgb(uint64_t* channels, int r, int g, int b){ +channels_set_bg_rgb8(uint64_t* channels, int r, int g, int b){ unsigned channel = channels_bchannel(*channels); - if(channel_set_rgb(&channel, r, g, b) < 0){ + if(channel_set_rgb8(&channel, r, g, b) < 0){ return -1; } *channels = (*channels & 0xffffffff00000000llu) | channel; @@ -2470,7 +2470,7 @@ channels_set_bg_rgb(uint64_t* channels, int r, int g, int b){ // Same, but set an assembled 32 bit channel at once. static inline int -channels_set_fg(uint64_t* channels, unsigned rgb){ +channels_set_fg_rgb(uint64_t* channels, unsigned rgb){ unsigned channel = channels_fchannel(*channels); if(channel_set(&channel, rgb) < 0){ return -1; @@ -2480,7 +2480,7 @@ channels_set_fg(uint64_t* channels, unsigned rgb){ } static inline int -channels_set_bg(uint64_t* channels, unsigned rgb){ +channels_set_bg_rgb(uint64_t* channels, unsigned rgb){ unsigned channel = channels_bchannel(*channels); if(channel_set(&channel, rgb) < 0){ return -1; @@ -2808,7 +2808,7 @@ ncpixel_set_b(uint32_t* pixel, int b){ // set the RGB values of an RGB pixel static inline int -ncpixel_set_rgb(uint32_t* pixel, int r, int g, int b){ +ncpixel_set_rgb8(uint32_t* pixel, int r, int g, int b){ if(pixel_set_r(pixel, r) || pixel_set_g(pixel, g) || pixel_set_b(pixel, b)){ return -1; } diff --git a/include/notcurses/notcurses.h b/include/notcurses/notcurses.h index 5ce2a33c2..217be57ed 100644 --- a/include/notcurses/notcurses.h +++ b/include/notcurses/notcurses.h @@ -160,7 +160,7 @@ channel_b(uint32_t channel){ // Extract the three 8-bit R/G/B components from a 32-bit channel. static inline unsigned -channel_rgb(uint32_t channel, unsigned* RESTRICT r, unsigned* RESTRICT g, +channel_rgb8(uint32_t channel, unsigned* RESTRICT r, unsigned* RESTRICT g, unsigned* RESTRICT b){ *r = channel_r(channel); *g = channel_g(channel); @@ -171,7 +171,7 @@ channel_rgb(uint32_t channel, unsigned* RESTRICT r, unsigned* RESTRICT g, // Set the three 8-bit components of a 32-bit channel, and mark it as not using // the default color. Retain the other bits unchanged. static inline int -channel_set_rgb(uint32_t* channel, int r, int g, int b){ +channel_set_rgb8(uint32_t* channel, int r, int g, int b){ if(r >= 256 || g >= 256 || b >= 256){ return -1; } @@ -291,13 +291,13 @@ channels_combine(uint32_t fchan, uint32_t bchan){ // Extract 24 bits of foreground RGB from 'channels', shifted to LSBs. static inline unsigned -channels_fg(uint64_t channels){ +channels_fg_rgb(uint64_t channels){ return channels_fchannel(channels) & CELL_BG_RGB_MASK; } // Extract 24 bits of background RGB from 'channels', shifted to LSBs. static inline unsigned -channels_bg(uint64_t channels){ +channels_bg_rgb(uint64_t channels){ return channels_bchannel(channels) & CELL_BG_RGB_MASK; } @@ -315,22 +315,22 @@ channels_bg_alpha(uint64_t channels){ // Extract 24 bits of foreground RGB from 'channels', split into subchannels. static inline unsigned -channels_fg_rgb(uint64_t channels, unsigned* r, unsigned* g, unsigned* b){ - return channel_rgb(channels_fchannel(channels), r, g, b); +channels_fg_rgb8(uint64_t channels, unsigned* r, unsigned* g, unsigned* b){ + return channel_rgb8(channels_fchannel(channels), r, g, b); } // Extract 24 bits of background RGB from 'channels', split into subchannels. static inline unsigned -channels_bg_rgb(uint64_t channels, unsigned* r, unsigned* g, unsigned* b){ - return channel_rgb(channels_bchannel(channels), r, g, b); +channels_bg_rgb8(uint64_t channels, unsigned* r, unsigned* g, unsigned* b){ + return channel_rgb8(channels_bchannel(channels), r, g, b); } // Set the r, g, and b channels for the foreground component of this 64-bit // 'channels' variable, and mark it as not using the default color. static inline int -channels_set_fg_rgb(uint64_t* channels, int r, int g, int b){ +channels_set_fg_rgb8(uint64_t* channels, int r, int g, int b){ unsigned channel = channels_fchannel(*channels); - if(channel_set_rgb(&channel, r, g, b) < 0){ + if(channel_set_rgb8(&channel, r, g, b) < 0){ return -1; } *channels = ((uint64_t)channel << 32llu) | (*channels & 0xffffffffllu); @@ -371,7 +371,7 @@ channels_set_fg_palindex(uint64_t* channels, int idx){ // Same, but set an assembled 24 bit channel at once. static inline int -channels_set_fg(uint64_t* channels, unsigned rgb){ +channels_set_fg_rgb(uint64_t* channels, unsigned rgb){ unsigned channel = channels_fchannel(*channels); if(channel_set(&channel, rgb) < 0){ return -1; @@ -383,9 +383,9 @@ channels_set_fg(uint64_t* channels, unsigned rgb){ // Set the r, g, and b channels for the background component of this 64-bit // 'channels' variable, and mark it as not using the default color. static inline int -channels_set_bg_rgb(uint64_t* channels, int r, int g, int b){ +channels_set_bg_rgb8(uint64_t* channels, int r, int g, int b){ unsigned channel = channels_bchannel(*channels); - if(channel_set_rgb(&channel, r, g, b) < 0){ + if(channel_set_rgb8(&channel, r, g, b) < 0){ return -1; } channels_set_bchannel(channels, channel); @@ -431,7 +431,7 @@ channels_set_bg_palindex(uint64_t* channels, int idx){ // Same, but set an assembled 24 bit channel at once. static inline int -channels_set_bg(uint64_t* channels, unsigned rgb){ +channels_set_bg_rgb(uint64_t* channels, unsigned rgb){ unsigned channel = channels_bchannel(*channels); if(channel_set(&channel, rgb) < 0){ return -1; @@ -1764,14 +1764,14 @@ cell_set_fchannel(cell* cl, uint32_t channel){ // Extract 24 bits of foreground RGB from 'cell', shifted to LSBs. static inline unsigned -cell_fg(const cell* cl){ - return channels_fg(cl->channels); +cell_fg_rgb(const cell* cl){ + return channels_fg_rgb(cl->channels); } // Extract 24 bits of background RGB from 'cell', shifted to LSBs. static inline unsigned -cell_bg(const cell* cl){ - return channels_bg(cl->channels); +cell_bg_rgb(const cell* cl){ + return channels_bg_rgb(cl->channels); } // Extract 2 bits of foreground alpha from 'cell', shifted to LSBs. @@ -1788,21 +1788,21 @@ cell_bg_alpha(const cell* cl){ // Extract 24 bits of foreground RGB from 'cell', split into components. static inline unsigned -cell_fg_rgb(const cell* cl, unsigned* r, unsigned* g, unsigned* b){ - return channels_fg_rgb(cl->channels, r, g, b); +cell_fg_rgb8(const cell* cl, unsigned* r, unsigned* g, unsigned* b){ + return channels_fg_rgb8(cl->channels, r, g, b); } // Extract 24 bits of background RGB from 'cell', split into components. static inline unsigned -cell_bg_rgb(const cell* cl, unsigned* r, unsigned* g, unsigned* b){ - return channels_bg_rgb(cl->channels, r, g, b); +cell_bg_rgb8(const cell* cl, unsigned* r, unsigned* g, unsigned* b){ + return channels_bg_rgb8(cl->channels, r, g, b); } // Set the r, g, and b cell for the foreground component of this 64-bit // 'cell' variable, and mark it as not using the default color. static inline int -cell_set_fg_rgb(cell* cl, int r, int g, int b){ - return channels_set_fg_rgb(&cl->channels, r, g, b); +cell_set_fg_rgb8(cell* cl, int r, int g, int b){ + return channels_set_fg_rgb8(&cl->channels, r, g, b); } // Same, but clipped to [0..255]. @@ -1813,8 +1813,8 @@ cell_set_fg_rgb_clipped(cell* cl, int r, int g, int b){ // Same, but with an assembled 24-bit RGB value. static inline int -cell_set_fg(cell* c, uint32_t channel){ - return channels_set_fg(&c->channels, channel); +cell_set_fg_rgb(cell* c, uint32_t channel){ + return channels_set_fg_rgb(&c->channels, channel); } // Set the cell's foreground palette index, set the foreground palette index @@ -1832,8 +1832,8 @@ cell_fg_palindex(const cell* cl){ // Set the r, g, and b cell for the background component of this 64-bit // 'cell' variable, and mark it as not using the default color. static inline int -cell_set_bg_rgb(cell* cl, int r, int g, int b){ - return channels_set_bg_rgb(&cl->channels, r, g, b); +cell_set_bg_rgb8(cell* cl, int r, int g, int b){ + return channels_set_bg_rgb8(&cl->channels, r, g, b); } // Same, but clipped to [0..255]. @@ -1845,8 +1845,8 @@ cell_set_bg_rgb_clipped(cell* cl, int r, int g, int b){ // Same, but with an assembled 24-bit RGB value. A value over 0xffffff // will be rejected, with a non-zero return value. static inline int -cell_set_bg(cell* c, uint32_t channel){ - return channels_set_bg(&c->channels, channel); +cell_set_bg_rgb(cell* c, uint32_t channel){ + return channels_set_bg_rgb(&c->channels, channel); } // Set the cell's background palette index, set the background palette index @@ -1913,14 +1913,14 @@ API void ncplane_styles_off(struct ncplane* n, unsigned stylebits); // Extract 24 bits of working foreground RGB from an ncplane, shifted to LSBs. static inline unsigned -ncplane_fg(const struct ncplane* n){ - return channels_fg(ncplane_channels(n)); +ncplane_fg_rgb(const struct ncplane* n){ + return channels_fg_rgb(ncplane_channels(n)); } // Extract 24 bits of working background RGB from an ncplane, shifted to LSBs. static inline unsigned -ncplane_bg(const struct ncplane* n){ - return channels_bg(ncplane_channels(n)); +ncplane_bg_rgb(const struct ncplane* n){ + return channels_bg_rgb(ncplane_channels(n)); } // Extract 2 bits of foreground alpha from 'struct ncplane', shifted to LSBs. @@ -1949,14 +1949,14 @@ ncplane_bg_default_p(const struct ncplane* n){ // Extract 24 bits of foreground RGB from 'n', split into components. static inline unsigned -ncplane_fg_rgb(const struct ncplane* n, unsigned* r, unsigned* g, unsigned* b){ - return channels_fg_rgb(ncplane_channels(n), r, g, b); +ncplane_fg_rgb8(const struct ncplane* n, unsigned* r, unsigned* g, unsigned* b){ + return channels_fg_rgb8(ncplane_channels(n), r, g, b); } // Extract 24 bits of background RGB from 'n', split into components. static inline unsigned -ncplane_bg_rgb(const struct ncplane* n, unsigned* r, unsigned* g, unsigned* b){ - return channels_bg_rgb(ncplane_channels(n), r, g, b); +ncplane_bg_rgb8(const struct ncplane* n, unsigned* r, unsigned* g, unsigned* b){ + return channels_bg_rgb8(ncplane_channels(n), r, g, b); } // Set an entire 32-bit channel of the plane @@ -1969,16 +1969,16 @@ API uint64_t ncplane_set_bchannel(struct ncplane* n, uint32_t channel); // interpreted in some lossy fashion. None of r, g, or b may exceed 255. // "HP-like" terminals require setting foreground and background at the same // time using "color pairs"; notcurses will manage color pairs transparently. -API int ncplane_set_fg_rgb(struct ncplane* n, int r, int g, int b); -API int ncplane_set_bg_rgb(struct ncplane* n, int r, int g, int b); +API int ncplane_set_fg_rgb8(struct ncplane* n, int r, int g, int b); +API int ncplane_set_bg_rgb8(struct ncplane* n, int r, int g, int b); // Same, but clipped to [0..255]. API void ncplane_set_bg_rgb_clipped(struct ncplane* n, int r, int g, int b); API void ncplane_set_fg_rgb_clipped(struct ncplane* n, int r, int g, int b); // Same, but with rgb assembled into a channel (i.e. lower 24 bits). -API int ncplane_set_fg(struct ncplane* n, unsigned channel); -API int ncplane_set_bg(struct ncplane* n, unsigned channel); +API int ncplane_set_fg_rgb(struct ncplane* n, unsigned channel); +API int ncplane_set_bg_rgb(struct ncplane* n, unsigned channel); // Use the default color for the foreground/background. API void ncplane_set_fg_default(struct ncplane* n); @@ -2406,7 +2406,7 @@ ncpixel_set_b(uint32_t* pixel, int b){ // set the RGB values of an RGB pixel static inline int -ncpixel_set_rgb(uint32_t* pixel, int r, int g, int b){ +ncpixel_set_rgb8(uint32_t* pixel, int r, int g, int b){ if(ncpixel_set_r(pixel, r) || ncpixel_set_g(pixel, g) || ncpixel_set_b(pixel, b)){ return -1; } @@ -2601,11 +2601,11 @@ API int palette256_use(struct notcurses* nc, const palette256* p); // Manipulate entries in the palette store 'p'. These are *not* locked. static inline int -palette256_set_rgb(palette256* p, int idx, int r, int g, int b){ +palette256_set_rgb8(palette256* p, int idx, int r, int g, int b){ if(idx < 0 || (size_t)idx > sizeof(p->chans) / sizeof(*p->chans)){ return -1; } - return channel_set_rgb(&p->chans[idx], r, g, b); + return channel_set_rgb8(&p->chans[idx], r, g, b); } static inline int @@ -2617,11 +2617,11 @@ palette256_set(palette256* p, int idx, unsigned rgb){ } static inline int -palette256_get_rgb(const palette256* p, int idx, unsigned* RESTRICT r, unsigned* RESTRICT g, unsigned* RESTRICT b){ +palette256_get_rgb8(const palette256* p, int idx, unsigned* RESTRICT r, unsigned* RESTRICT g, unsigned* RESTRICT b){ if(idx < 0 || (size_t)idx > sizeof(p->chans) / sizeof(*p->chans)){ return -1; } - return channel_rgb(p->chans[idx], r, g, b); + return channel_rgb8(p->chans[idx], r, g, b); } // Free the palette store 'p'. diff --git a/src/lib/blit.c b/src/lib/blit.c index 484db71c3..951277e66 100644 --- a/src/lib/blit.c +++ b/src/lib/blit.c @@ -8,9 +8,9 @@ static inline uint32_t lerp(uint32_t c0, uint32_t c1){ uint32_t ret = 0; unsigned r0, g0, b0, r1, g1, b1; - channel_rgb(c0, &r0, &g0, &b0); - channel_rgb(c1, &r1, &g1, &b1); - channel_set_rgb(&ret, (r0 + r1 + 1) / 2, (g0 + g1 + 1) / 2, (b0 + b1 + 1) / 2); + channel_rgb8(c0, &r0, &g0, &b0); + channel_rgb8(c1, &r1, &g1, &b1); + channel_set_rgb8(&ret, (r0 + r1 + 1) / 2, (g0 + g1 + 1) / 2, (b0 + b1 + 1) / 2); return ret; } @@ -19,10 +19,10 @@ static inline uint32_t trilerp(uint32_t c0, uint32_t c1, uint32_t c2){ uint32_t ret = 0; unsigned r0, g0, b0, r1, g1, b1, r2, g2, b2; - channel_rgb(c0, &r0, &g0, &b0); - channel_rgb(c1, &r1, &g1, &b1); - channel_rgb(c2, &r2, &g2, &b2); - channel_set_rgb(&ret, (r0 + r1 + r2 + 2) / 3, + channel_rgb8(c0, &r0, &g0, &b0); + channel_rgb8(c1, &r1, &g1, &b1); + channel_rgb8(c2, &r2, &g2, &b2); + channel_set_rgb8(&ret, (r0 + r1 + r2 + 2) / 3, (g0 + g1 + g2 + 2) / 3, (b0 + b1 + b2 + 2) / 3); return ret; @@ -76,8 +76,8 @@ tria_blit_ascii(ncplane* nc, int placey, int placex, int linesize, cell_set_bg_alpha(c, CELL_ALPHA_TRANSPARENT); cell_set_fg_alpha(c, CELL_ALPHA_TRANSPARENT); }else{ - cell_set_fg_rgb(c, rgbbase_up[rpos], rgbbase_up[1], rgbbase_up[bpos]); - cell_set_bg_rgb(c, rgbbase_up[rpos], rgbbase_up[1], rgbbase_up[bpos]); + cell_set_fg_rgb8(c, rgbbase_up[rpos], rgbbase_up[1], rgbbase_up[bpos]); + cell_set_bg_rgb8(c, rgbbase_up[rpos], rgbbase_up[1], rgbbase_up[bpos]); if(cell_load(nc, c, " ") <= 0){ return -1; } @@ -134,23 +134,23 @@ tria_blit(ncplane* nc, int placey, int placex, int linesize, if(cell_load(nc, c, "\u2584") <= 0){ // lower half block return -1; } - cell_set_fg_rgb(c, rgbbase_down[rpos], rgbbase_down[1], rgbbase_down[bpos]); + cell_set_fg_rgb8(c, rgbbase_down[rpos], rgbbase_down[1], rgbbase_down[bpos]); }else{ // up has the color if(cell_load(nc, c, "\u2580") <= 0){ // upper half block return -1; } - cell_set_fg_rgb(c, rgbbase_up[rpos], rgbbase_up[1], rgbbase_up[bpos]); + cell_set_fg_rgb8(c, rgbbase_up[rpos], rgbbase_up[1], rgbbase_up[bpos]); } }else{ if(memcmp(rgbbase_up, rgbbase_down, 3) == 0){ - cell_set_fg_rgb(c, rgbbase_down[rpos], rgbbase_down[1], rgbbase_down[bpos]); - cell_set_bg_rgb(c, rgbbase_down[rpos], rgbbase_down[1], rgbbase_down[bpos]); + cell_set_fg_rgb8(c, rgbbase_down[rpos], rgbbase_down[1], rgbbase_down[bpos]); + cell_set_bg_rgb8(c, rgbbase_down[rpos], rgbbase_down[1], rgbbase_down[bpos]); if(cell_load(nc, c, " ") <= 0){ // only need the background return -1; } }else{ - cell_set_fg_rgb(c, rgbbase_up[rpos], rgbbase_up[1], rgbbase_up[bpos]); - cell_set_bg_rgb(c, rgbbase_down[rpos], rgbbase_down[1], rgbbase_down[bpos]); + cell_set_fg_rgb8(c, rgbbase_up[rpos], rgbbase_up[1], rgbbase_up[bpos]); + cell_set_bg_rgb8(c, rgbbase_down[rpos], rgbbase_down[1], rgbbase_down[bpos]); if(cell_load(nc, c, "\u2580") <= 0){ // upper half block return -1; } @@ -198,10 +198,10 @@ rgb_4diff(uint32_t* diffs, uint32_t tl, uint32_t tr, uint32_t bl, uint32_t br){ struct rgb { unsigned r, g, b; } colors[4]; - channel_rgb(tl, &colors[0].r, &colors[0].g, &colors[0].b); - channel_rgb(tr, &colors[1].r, &colors[1].g, &colors[1].b); - channel_rgb(bl, &colors[2].r, &colors[2].g, &colors[2].b); - channel_rgb(br, &colors[3].r, &colors[3].g, &colors[3].b); + channel_rgb8(tl, &colors[0].r, &colors[0].g, &colors[0].b); + channel_rgb8(tr, &colors[1].r, &colors[1].g, &colors[1].b); + channel_rgb8(bl, &colors[2].r, &colors[2].g, &colors[2].b); + channel_rgb8(br, &colors[3].r, &colors[3].g, &colors[3].b); for(size_t idx = 0 ; idx < sizeof(quadrant_drivers) / sizeof(*quadrant_drivers) ; ++idx){ const struct qdriver* qd = quadrant_drivers + idx; const struct rgb* rgb0 = colors + qd->pair[0]; @@ -245,10 +245,10 @@ quadrant_solver(uint32_t tl, uint32_t tr, uint32_t bl, uint32_t br, // break down the excluded pair and lerp unsigned r0, r1, g0, g1, b0, b1; unsigned roth, goth, both, rlerp, glerp, blerp; - channel_rgb(colors[qd->others[0]], &r0, &g0, &b0); - channel_rgb(colors[qd->others[1]], &r1, &g1, &b1); - channel_rgb(*fore, &rlerp, &glerp, &blerp); - channel_rgb(*back, &roth, &goth, &both); + channel_rgb8(colors[qd->others[0]], &r0, &g0, &b0); + channel_rgb8(colors[qd->others[1]], &r1, &g1, &b1); + channel_rgb8(*fore, &rlerp, &glerp, &blerp); + channel_rgb8(*back, &roth, &goth, &both); //fprintf(stderr, "rgbs: %02x %02x %02x / %02x %02x %02x\n", r0, g0, b0, r1, g1, b1); diffs[0] = rgb_diff(r0, g0, b0, rlerp, glerp, blerp); diffs[1] = rgb_diff(r0, g0, b0, roth, goth, both); @@ -282,10 +282,10 @@ qtrans_check(cell* c, bool bgr, bool blendcolors, const int rpos = bgr ? 2 : 0; const int bpos = bgr ? 0 : 2; uint32_t tl = 0, tr = 0, bl = 0, br = 0; - channel_set_rgb(&tl, rgbbase_tl[rpos], rgbbase_tl[1], rgbbase_tl[bpos]); - channel_set_rgb(&tr, rgbbase_tr[rpos], rgbbase_tr[1], rgbbase_tr[bpos]); - channel_set_rgb(&bl, rgbbase_bl[rpos], rgbbase_bl[1], rgbbase_bl[bpos]); - channel_set_rgb(&br, rgbbase_br[rpos], rgbbase_br[1], rgbbase_br[bpos]); + channel_set_rgb8(&tl, rgbbase_tl[rpos], rgbbase_tl[1], rgbbase_tl[bpos]); + channel_set_rgb8(&tr, rgbbase_tr[rpos], rgbbase_tr[1], rgbbase_tr[bpos]); + channel_set_rgb8(&bl, rgbbase_bl[rpos], rgbbase_bl[1], rgbbase_bl[bpos]); + channel_set_rgb8(&br, rgbbase_br[rpos], rgbbase_br[1], rgbbase_br[bpos]); const char* egc = NULL; if(ffmpeg_trans_p(bgr, rgbbase_tl[3])){ // top left is transparent @@ -298,12 +298,12 @@ qtrans_check(cell* c, bool bgr, bool blendcolors, cell_set_fg_default(c); egc = ""; }else{ - cell_set_fg_rgb(c, rgbbase_br[rpos], rgbbase_br[1], rgbbase_br[bpos]); + cell_set_fg_rgb8(c, rgbbase_br[rpos], rgbbase_br[1], rgbbase_br[bpos]); egc = "▗"; } }else{ if(ffmpeg_trans_p(bgr, rgbbase_br[3])){ - cell_set_fg_rgb(c, rgbbase_bl[rpos], rgbbase_bl[1], rgbbase_bl[bpos]); + cell_set_fg_rgb8(c, rgbbase_bl[rpos], rgbbase_bl[1], rgbbase_bl[bpos]); egc = "▖"; }else{ cell_set_fchannel(c, lerp(bl, br)); @@ -313,7 +313,7 @@ qtrans_check(cell* c, bool bgr, bool blendcolors, }else{ // top right is foreground, top left is transparent if(ffmpeg_trans_p(bgr, rgbbase_bl[3])){ if(ffmpeg_trans_p(bgr, rgbbase_br[3])){ // entire bottom is transparent - cell_set_fg_rgb(c, rgbbase_tr[rpos], rgbbase_tr[1], rgbbase_tr[bpos]); + cell_set_fg_rgb8(c, rgbbase_tr[rpos], rgbbase_tr[1], rgbbase_tr[bpos]); egc = "▝"; }else{ cell_set_fchannel(c, lerp(tr, br)); @@ -331,7 +331,7 @@ qtrans_check(cell* c, bool bgr, bool blendcolors, if(ffmpeg_trans_p(bgr, rgbbase_tr[3])){ if(ffmpeg_trans_p(bgr, rgbbase_bl[3])){ if(ffmpeg_trans_p(bgr, rgbbase_br[3])){ - cell_set_fg_rgb(c, rgbbase_tl[rpos], rgbbase_tl[1], rgbbase_tl[bpos]); + cell_set_fg_rgb8(c, rgbbase_tl[rpos], rgbbase_tl[1], rgbbase_tl[bpos]); egc = "▘"; }else{ cell_set_fchannel(c, lerp(tl, br)); @@ -409,10 +409,10 @@ quadrant_blit(ncplane* nc, int placey, int placex, int linesize, const char* egc = qtrans_check(c, bgr, blendcolors, rgbbase_tl, rgbbase_tr, rgbbase_bl, rgbbase_br); if(egc == NULL){ uint32_t tl = 0, tr = 0, bl = 0, br = 0; - channel_set_rgb(&tl, rgbbase_tl[rpos], rgbbase_tl[1], rgbbase_tl[bpos]); - channel_set_rgb(&tr, rgbbase_tr[rpos], rgbbase_tr[1], rgbbase_tr[bpos]); - channel_set_rgb(&bl, rgbbase_bl[rpos], rgbbase_bl[1], rgbbase_bl[bpos]); - channel_set_rgb(&br, rgbbase_br[rpos], rgbbase_br[1], rgbbase_br[bpos]); + channel_set_rgb8(&tl, rgbbase_tl[rpos], rgbbase_tl[1], rgbbase_tl[bpos]); + channel_set_rgb8(&tr, rgbbase_tr[rpos], rgbbase_tr[1], rgbbase_tr[bpos]); + channel_set_rgb8(&bl, rgbbase_bl[rpos], rgbbase_bl[1], rgbbase_bl[bpos]); + channel_set_rgb8(&br, rgbbase_br[rpos], rgbbase_br[1], rgbbase_br[bpos]); uint32_t bg, fg; egc = quadrant_solver(tl, tr, bl, br, &fg, &bg); assert(egc); @@ -436,7 +436,7 @@ quadrant_blit(ncplane* nc, int placey, int placex, int linesize, // fold the r, g, and b components of the pixel into *r, *g, and *b, and // increment *foldcount static inline void -fold_rgb(unsigned* restrict r, unsigned* restrict g, unsigned* restrict b, +fold_rgb8(unsigned* restrict r, unsigned* restrict g, unsigned* restrict b, bool bgr, const uint8_t* pixel, unsigned* foldcount){ *r += bgr ? pixel[2] : pixel[0]; *g += pixel[1]; @@ -500,35 +500,35 @@ braille_blit(ncplane* nc, int placey, int placex, int linesize, // FIXME fold this into the above? if(!ffmpeg_trans_p(bgr, rgbbase_l0[3])){ egcidx |= 1u; - fold_rgb(&r, &g, &b, bgr, rgbbase_l0, &blends); + fold_rgb8(&r, &g, &b, bgr, rgbbase_l0, &blends); } if(!ffmpeg_trans_p(bgr, rgbbase_l1[3])){ egcidx |= 2u; - fold_rgb(&r, &g, &b, bgr, rgbbase_l1, &blends); + fold_rgb8(&r, &g, &b, bgr, rgbbase_l1, &blends); } if(!ffmpeg_trans_p(bgr, rgbbase_l2[3])){ egcidx |= 4u; - fold_rgb(&r, &g, &b, bgr, rgbbase_l2, &blends); + fold_rgb8(&r, &g, &b, bgr, rgbbase_l2, &blends); } if(!ffmpeg_trans_p(bgr, rgbbase_r0[3])){ egcidx |= 8u; - fold_rgb(&r, &g, &b, bgr, rgbbase_r0, &blends); + fold_rgb8(&r, &g, &b, bgr, rgbbase_r0, &blends); } if(!ffmpeg_trans_p(bgr, rgbbase_r1[3])){ egcidx |= 16u; - fold_rgb(&r, &g, &b, bgr, rgbbase_r1, &blends); + fold_rgb8(&r, &g, &b, bgr, rgbbase_r1, &blends); } if(!ffmpeg_trans_p(bgr, rgbbase_r2[3])){ egcidx |= 32u; - fold_rgb(&r, &g, &b, bgr, rgbbase_r2, &blends); + fold_rgb8(&r, &g, &b, bgr, rgbbase_r2, &blends); } if(!ffmpeg_trans_p(bgr, rgbbase_l3[3])){ egcidx |= 64u; - fold_rgb(&r, &g, &b, bgr, rgbbase_l3, &blends); + fold_rgb8(&r, &g, &b, bgr, rgbbase_l3, &blends); } if(!ffmpeg_trans_p(bgr, rgbbase_r3[3])){ egcidx |= 128u; - fold_rgb(&r, &g, &b, bgr, rgbbase_r3, &blends); + fold_rgb8(&r, &g, &b, bgr, rgbbase_r3, &blends); } //fprintf(stderr, "[%04d/%04d] bpp: %d lsize: %d %02x %02x %02x %02x\n", y, x, bpp, linesize, rgbbase_up[0], rgbbase_up[1], rgbbase_up[2], rgbbase_up[3]); cell* c = ncplane_cell_ref_yx(nc, y, x); @@ -551,7 +551,7 @@ braille_blit(ncplane* nc, int placey, int placex, int linesize, // FIXME else look for pairs of transparency! }else{ if(blends){ - cell_set_fg_rgb(c, r / blends, g / blends, b / blends); + cell_set_fg_rgb8(c, r / blends, g / blends, b / blends); } // UTF-8 encodings of the Brailler Patterns are always 0xe2 0xaX 0xCC, // where 0 <= X <= 3 and 0x80 <= CC <= 0xbf (4 groups of 64). diff --git a/src/lib/direct.cpp b/src/lib/direct.cpp index 563a3dffd..3f68ac79d 100644 --- a/src/lib/direct.cpp +++ b/src/lib/direct.cpp @@ -14,14 +14,14 @@ int ncdirect_putstr(ncdirect* nc, uint64_t channels, const char* utf8){ if(ncdirect_fg_default(nc)){ return -1; } - }else if(ncdirect_fg(nc, channels_fg(channels))){ + }else if(ncdirect_fg(nc, channels_fg_rgb(channels))){ return -1; } if(channels_bg_default_p(channels)){ if(ncdirect_bg_default(nc)){ return -1; } - }else if(ncdirect_bg(nc, channels_bg(channels))){ + }else if(ncdirect_bg(nc, channels_bg_rgb(channels))){ return -1; } return fprintf(nc->ttyfp, "%s", utf8); @@ -386,8 +386,8 @@ ncdirect_dump_plane(ncdirect* n, const ncplane* np, int xoff){ if(egc == nullptr){ return -1; } - ncdirect_fg(n, channels_fg(channels)); - ncdirect_bg(n, channels_bg(channels)); + ncdirect_fg(n, channels_fg_rgb(channels)); + ncdirect_bg(n, channels_bg_rgb(channels)); //fprintf(stderr, "%03d/%03d [%s] (%03dx%03d)\n", y, x, egc, dimy, dimx); if(fprintf(n->ttyfp, "%s", strlen(egc) == 0 ? " " : egc) < 0){ free(egc); @@ -688,13 +688,13 @@ int ncdirect_hline_interp(ncdirect* n, const char* egc, int len, unsigned ur, ug, ub; int r1, g1, b1, r2, g2, b2; int br1, bg1, bb1, br2, bg2, bb2; - channels_fg_rgb(c1, &ur, &ug, &ub); + channels_fg_rgb8(c1, &ur, &ug, &ub); r1 = ur; g1 = ug; b1 = ub; - channels_fg_rgb(c2, &ur, &ug, &ub); + channels_fg_rgb8(c2, &ur, &ug, &ub); r2 = ur; g2 = ug; b2 = ub; - channels_bg_rgb(c1, &ur, &ug, &ub); + channels_bg_rgb8(c1, &ur, &ug, &ub); br1 = ur; bg1 = ug; bb1 = ub; - channels_bg_rgb(c2, &ur, &ug, &ub); + channels_bg_rgb8(c2, &ur, &ug, &ub); br2 = ur; bg2 = ug; bb2 = ub; int deltr = r2 - r1; int deltg = g2 - g1; @@ -735,13 +735,13 @@ int ncdirect_vline_interp(ncdirect* n, const char* egc, int len, unsigned ur, ug, ub; int r1, g1, b1, r2, g2, b2; int br1, bg1, bb1, br2, bg2, bb2; - channels_fg_rgb(c1, &ur, &ug, &ub); + channels_fg_rgb8(c1, &ur, &ug, &ub); r1 = ur; g1 = ug; b1 = ub; - channels_fg_rgb(c2, &ur, &ug, &ub); + channels_fg_rgb8(c2, &ur, &ug, &ub); r2 = ur; g2 = ug; b2 = ub; - channels_bg_rgb(c1, &ur, &ug, &ub); + channels_bg_rgb8(c1, &ur, &ug, &ub); br1 = ur; bg1 = ug; bb1 = ub; - channels_bg_rgb(c2, &ur, &ug, &ub); + channels_bg_rgb8(c2, &ur, &ug, &ub); br2 = ur; bg2 = ug; bb2 = ub; int deltr = (r2 - r1) / (len + 1); int deltg = (g2 - g1) / (len + 1); @@ -766,10 +766,10 @@ int ncdirect_vline_interp(ncdirect* n, const char* egc, int len, bb1 += deltbb; uint64_t channels = 0; if(!fgdef){ - channels_set_fg_rgb(&channels, r1, g1, b1); + channels_set_fg_rgb8(&channels, r1, g1, b1); } if(!bgdef){ - channels_set_bg_rgb(&channels, br1, bg1, bb1); + channels_set_bg_rgb8(&channels, br1, bg1, bb1); } if(ncdirect_putstr(n, channels, egc) <= 0){ break; @@ -796,8 +796,8 @@ int ncdirect_box(ncdirect* n, uint64_t ul, uint64_t ur, unsigned edges; edges = !(ctlword & NCBOXMASK_TOP) + !(ctlword & NCBOXMASK_LEFT); if(edges >= box_corner_needs(ctlword)){ - ncdirect_fg(n, channels_fg(ul)); - ncdirect_bg(n, channels_bg(ul)); + ncdirect_fg(n, channels_fg_rgb(ul)); + ncdirect_bg(n, channels_bg_rgb(ul)); if(fprintf(n->ttyfp, "%lc", wchars[0]) < 0){ return -1; } @@ -826,8 +826,8 @@ int ncdirect_box(ncdirect* n, uint64_t ul, uint64_t ur, } edges = !(ctlword & NCBOXMASK_TOP) + !(ctlword & NCBOXMASK_RIGHT); if(edges >= box_corner_needs(ctlword)){ - ncdirect_fg(n, channels_fg(ur)); - ncdirect_bg(n, channels_bg(ur)); + ncdirect_fg(n, channels_fg_rgb(ur)); + ncdirect_bg(n, channels_bg_rgb(ur)); if(fprintf(n->ttyfp, "%lc", wchars[1]) < 0){ return -1; } @@ -860,8 +860,8 @@ int ncdirect_box(ncdirect* n, uint64_t ul, uint64_t ur, // bottom line edges = !(ctlword & NCBOXMASK_BOTTOM) + !(ctlword & NCBOXMASK_LEFT); if(edges >= box_corner_needs(ctlword)){ - ncdirect_fg(n, channels_fg(ll)); - ncdirect_bg(n, channels_bg(ll)); + ncdirect_fg(n, channels_fg_rgb(ll)); + ncdirect_bg(n, channels_bg_rgb(ll)); if(fprintf(n->ttyfp, "%lc", wchars[2]) < 0){ return -1; } @@ -879,8 +879,8 @@ int ncdirect_box(ncdirect* n, uint64_t ul, uint64_t ur, } edges = !(ctlword & NCBOXMASK_BOTTOM) + !(ctlword & NCBOXMASK_RIGHT); if(edges >= box_corner_needs(ctlword)){ - ncdirect_fg(n, channels_fg(lr)); - ncdirect_bg(n, channels_bg(lr)); + ncdirect_fg(n, channels_fg_rgb(lr)); + ncdirect_bg(n, channels_bg_rgb(lr)); if(fprintf(n->ttyfp, "%lc", wchars[3]) < 0){ return -1; } diff --git a/src/lib/fade.c b/src/lib/fade.c index 9f2d9a9ed..fdb108c6e 100644 --- a/src/lib/fade.c +++ b/src/lib/fade.c @@ -37,7 +37,7 @@ alloc_ncplane_palette(ncplane* n, ncfadectx* pp, const struct timespec* ts){ for(x = 0 ; x < pp->cols ; ++x){ channels = n->fb[nfbcellidx(n, y, x)].channels; pp->channels[y * pp->cols + x] = channels; - channels_fg_rgb(channels, &r, &g, &b); + channels_fg_rgb8(channels, &r, &g, &b); if(r > pp->maxr){ pp->maxr = r; } @@ -47,7 +47,7 @@ alloc_ncplane_palette(ncplane* n, ncfadectx* pp, const struct timespec* ts){ if(b > pp->maxb){ pp->maxb = b; } - channels_bg_rgb(channels, &br, &bg, &bb); + channels_bg_rgb8(channels, &br, &bg, &bb); if(br > pp->maxbr){ pp->maxbr = br; } @@ -61,7 +61,7 @@ alloc_ncplane_palette(ncplane* n, ncfadectx* pp, const struct timespec* ts){ } channels = n->basecell.channels; pp->channels[y * pp->cols] = channels; - channels_fg_rgb(channels, &r, &g, &b); + channels_fg_rgb8(channels, &r, &g, &b); if(r > pp->maxr){ pp->maxr = r; } @@ -71,7 +71,7 @@ alloc_ncplane_palette(ncplane* n, ncfadectx* pp, const struct timespec* ts){ if(b > pp->maxb){ pp->maxb = b; } - channels_bg_rgb(channels, &br, &bg, &bb); + channels_bg_rgb8(channels, &br, &bg, &bb); if(br > pp->maxbr){ pp->maxbr = br; } @@ -116,21 +116,21 @@ int ncplane_fadein_iteration(ncplane* n, ncfadectx* nctx, int iter, for(y = 0 ; y < nctx->rows && y < dimy ; ++y){ for(x = 0 ; x < nctx->cols && x < dimx; ++x){ unsigned r, g, b; - channels_fg_rgb(nctx->channels[nctx->cols * y + x], &r, &g, &b); + channels_fg_rgb8(nctx->channels[nctx->cols * y + x], &r, &g, &b); unsigned br, bg, bb; - channels_bg_rgb(nctx->channels[nctx->cols * y + x], &br, &bg, &bb); + channels_bg_rgb8(nctx->channels[nctx->cols * y + x], &br, &bg, &bb); cell* c = &n->fb[dimx * y + x]; if(!cell_fg_default_p(c)){ r = r * iter / nctx->maxsteps; g = g * iter / nctx->maxsteps; b = b * iter / nctx->maxsteps; - cell_set_fg_rgb(c, r, g, b); + cell_set_fg_rgb8(c, r, g, b); } if(!cell_bg_default_p(c)){ br = br * iter / nctx->maxsteps; bg = bg * iter / nctx->maxsteps; bb = bb * iter / nctx->maxsteps; - cell_set_bg_rgb(c, br, bg, bb); + cell_set_bg_rgb8(c, br, bg, bb); } } } @@ -184,35 +184,35 @@ int ncplane_fadeout_iteration(ncplane* n, ncfadectx* nctx, int iter, for(x = 0 ; x < nctx->cols && x < dimx; ++x){ cell* c = &n->fb[dimx * y + x]; if(!cell_fg_default_p(c)){ - channels_fg_rgb(nctx->channels[nctx->cols * y + x], &r, &g, &b); + channels_fg_rgb8(nctx->channels[nctx->cols * y + x], &r, &g, &b); r = r * (nctx->maxsteps - iter) / nctx->maxsteps; g = g * (nctx->maxsteps - iter) / nctx->maxsteps; b = b * (nctx->maxsteps - iter) / nctx->maxsteps; - cell_set_fg_rgb(c, r, g, b); + cell_set_fg_rgb8(c, r, g, b); } if(!cell_bg_default_p(c)){ - channels_bg_rgb(nctx->channels[nctx->cols * y + x], &br, &bg, &bb); + channels_bg_rgb8(nctx->channels[nctx->cols * y + x], &br, &bg, &bb); br = br * (nctx->maxsteps - iter) / nctx->maxsteps; bg = bg * (nctx->maxsteps - iter) / nctx->maxsteps; bb = bb * (nctx->maxsteps - iter) / nctx->maxsteps; - cell_set_bg_rgb(c, br, bg, bb); + cell_set_bg_rgb8(c, br, bg, bb); } } } cell* c = &n->basecell; if(!cell_fg_default_p(c)){ - channels_fg_rgb(nctx->channels[nctx->cols * y], &r, &g, &b); + channels_fg_rgb8(nctx->channels[nctx->cols * y], &r, &g, &b); r = r * (nctx->maxsteps - iter) / nctx->maxsteps; g = g * (nctx->maxsteps - iter) / nctx->maxsteps; b = b * (nctx->maxsteps - iter) / nctx->maxsteps; - cell_set_fg_rgb(&n->basecell, r, g, b); + cell_set_fg_rgb8(&n->basecell, r, g, b); } if(!cell_bg_default_p(c)){ - channels_bg_rgb(nctx->channels[nctx->cols * y], &br, &bg, &bb); + channels_bg_rgb8(nctx->channels[nctx->cols * y], &br, &bg, &bb); br = br * (nctx->maxsteps - iter) / nctx->maxsteps; bg = bg * (nctx->maxsteps - iter) / nctx->maxsteps; bb = bb * (nctx->maxsteps - iter) / nctx->maxsteps; - cell_set_bg_rgb(&n->basecell, br, bg, bb); + cell_set_bg_rgb8(&n->basecell, br, bg, bb); } uint64_t nextwake = (iter + 1) * nctx->nanosecs_step + nctx->startns; struct timespec sleepspec; diff --git a/src/lib/fill.c b/src/lib/fill.c index f6c028aef..54d9ad5d7 100644 --- a/src/lib/fill.c +++ b/src/lib/fill.c @@ -5,12 +5,12 @@ void ncplane_greyscale(ncplane *n){ for(int x = 0 ; x < n->lenx ; ++x){ cell* c = &n->fb[nfbcellidx(n, y, x)]; unsigned r, g, b; - cell_fg_rgb(c, &r, &g, &b); + cell_fg_rgb8(c, &r, &g, &b); int gy = rgb_greyscale(r, g, b); - cell_set_fg_rgb(c, gy, gy, gy); - cell_bg_rgb(c, &r, &g, &b); + cell_set_fg_rgb8(c, gy, gy, gy); + cell_bg_rgb8(c, &r, &g, &b); gy = rgb_greyscale(r, g, b); - cell_set_bg_rgb(c, gy, gy, gy); + cell_set_bg_rgb8(c, gy, gy, gy); } } } @@ -608,7 +608,7 @@ int ncplane_qrcode(ncplane* n, ncblitter_e blitter, int* ymax, int* xmax, if(ncplane_fg_default_p(n)){ r = g = b = 0xff; }else{ - ncplane_fg_rgb(n, &r, &g, &b); + ncplane_fg_rgb8(n, &r, &g, &b); } memcpy(src, data, len); int ret = -1; @@ -621,7 +621,7 @@ int ncplane_qrcode(ncplane* n, ncblitter_e blitter, int* ymax, int* xmax, for(int x = startx ; x < startx + square ; ++x){ const bool pixel = qrcodegen_getModule(dst, x, y); ncpixel_set_a(&rgba[y * square + x], 0xff); - ncpixel_set_rgb(&rgba[y * square + x], r * pixel, g * pixel, b * pixel); + ncpixel_set_rgb8(&rgba[y * square + x], r * pixel, g * pixel, b * pixel); } } struct ncvisual* ncv = ncvisual_from_rgba(rgba, square, square * sizeof(uint32_t), square); diff --git a/src/lib/internal.h b/src/lib/internal.h index 38599b18b..fc2ab0c47 100644 --- a/src/lib/internal.h +++ b/src/lib/internal.h @@ -864,21 +864,21 @@ channels_blend(unsigned c1, unsigned c2, unsigned* blends){ return c1; // do *not* increment *blends } unsigned rsum, gsum, bsum; - channel_rgb(c2, &rsum, &gsum, &bsum); + channel_rgb8(c2, &rsum, &gsum, &bsum); bool c2default = channel_default_p(c2); if(*blends == 0){ // don't just return c2, or you set wide status and all kinds of crap if(channel_default_p(c2)){ channel_set_default(&c1); }else{ - channel_set_rgb(&c1, rsum, gsum, bsum); + channel_set_rgb8(&c1, rsum, gsum, bsum); } channel_set_alpha(&c1, channel_alpha(c2)); }else if(!c2default && !channel_default_p(c1)){ rsum = (channel_r(c1) * *blends + rsum) / (*blends + 1); gsum = (channel_g(c1) * *blends + gsum) / (*blends + 1); bsum = (channel_b(c1) * *blends + bsum) / (*blends + 1); - channel_set_rgb(&c1, rsum, gsum, bsum); + channel_set_rgb8(&c1, rsum, gsum, bsum); channel_set_alpha(&c1, channel_alpha(c2)); } ++*blends;