Notcurses 3.0.13
a blingful library for TUIs and character graphics
Loading...
Searching...
No Matches
linux.c File Reference
#include "linux.h"
#include "internal.h"
Include dependency graph for linux.c:

Go to the source code of this file.

Functions

int fbcon_wipe (sprixel *s, int ycell, int xcell)
 
int fbcon_blit (struct ncplane *n, int linesize, const void *data, int leny, int lenx, const struct blitterargs *bargs)
 
int fbcon_scrub (const struct ncpile *p, sprixel *s)
 
int fbcon_rebuild (sprixel *s, int ycell, int xcell, uint8_t *auxvec)
 
int fbcon_draw (const tinfo *ti, sprixel *s, int y, int x)
 
void fbcon_scroll (const struct ncpile *p, tinfo *ti, int rows)
 
int get_linux_fb_pixelgeom (tinfo *ti, unsigned *ypix, unsigned *xpix)
 

Function Documentation

◆ fbcon_blit()

int fbcon_blit ( struct ncplane n,
int  linesize,
const void *  data,
int  leny,
int  lenx,
const struct blitterargs bargs 
)

Definition at line 44 of file linux.c.

45 {
46 uint32_t transcolor = bargs->transcolor;
47 sprixel* s = bargs->u.pixel.spx;
48 int cdimx = bargs->u.pixel.cellpxx;
49 int cdimy = bargs->u.pixel.cellpxy;
50 // FIXME this will need be a copy of the tinfo's fbuf map
51 size_t flen = leny * lenx * 4;
52 if(fbuf_reserve(&s->glyph, flen)){
53 return -1;
54 }
55 for(int l = 0 ; l < leny ; ++l){
56 int ycell = l / cdimy;
57 size_t soffset = l * linesize;
58 const uint8_t* src = (const unsigned char*)data + soffset;
59 size_t toffset = l * lenx * 4;
60 char* dst = (char *)s->glyph.buf + toffset;
61 for(int c = 0 ; c < lenx ; ++c){
62 int xcell = c / cdimx;
63 int tyx = xcell + ycell * bargs->u.pixel.spx->dimx;
64 if(n->tam[tyx].state >= SPRIXCELL_ANNIHILATED){
65 if(rgba_trans_p(*(uint32_t*)src, transcolor)){
66 ncpixel_set_a((uint32_t*)src, 0); // in case it was transcolor
67 if(c % cdimx == 0 && l % cdimy == 0){
68 n->tam[tyx].state = SPRIXCELL_ANNIHILATED_TRANS;
69 }
70 }else{
71 n->tam[tyx].state = SPRIXCELL_ANNIHILATED;
72 }
73 dst[3] = 0;
74 const int vyx = (l % cdimy) * cdimx + (c % cdimx);
75 ((uint8_t*)n->tam[tyx].auxvector)[vyx] = src[3];
76 }else{
77 if(rgba_trans_p(*(uint32_t*)src, transcolor)){
78 ncpixel_set_a((uint32_t*)src, 0); // in case it was transcolor
79 if(c % cdimx == 0 && l % cdimy == 0){
80 n->tam[tyx].state = SPRIXCELL_TRANSPARENT;
81 }else if(n->tam[tyx].state == SPRIXCELL_OPAQUE_SIXEL){
82 n->tam[tyx].state = SPRIXCELL_MIXED_SIXEL;
83 }
84 dst[3] = 0;
85 }else{
86 if(c % cdimx == 0 && l % cdimy == 0){
87 n->tam[tyx].state = SPRIXCELL_OPAQUE_SIXEL;
88 }else if(n->tam[tyx].state == SPRIXCELL_TRANSPARENT){
89 n->tam[tyx].state = SPRIXCELL_MIXED_SIXEL;
90 }
91 memcpy(dst + 3, src + 3, 1);
92 }
93 }
94 memcpy(dst, src + 2, 1);
95 memcpy(dst + 1, src + 1, 1);
96 memcpy(dst + 2, src, 1);
97 dst += 4;
98 src += 4;
99 }
100 }
101 scrub_tam_boundaries(n->tam, leny, lenx, cdimy, cdimx);
102 if(plane_blit_sixel(s, &s->glyph, leny, lenx, 0, n->tam, SPRIXEL_INVALIDATED) < 0){
103 goto error;
104 }
105 return 1;
106
107error:
108 fbuf_free(&s->glyph);
109 s->glyph.size = 0;
110 return -1;
111}
const nccell * c
Definition egcpool.h:296
vopts n
Definition notcurses.h:3502
@ SPRIXCELL_ANNIHILATED
Definition sprite.h:120
@ SPRIXCELL_TRANSPARENT
Definition sprite.h:115
@ SPRIXCELL_ANNIHILATED_TRANS
Definition sprite.h:121
@ SPRIXCELL_MIXED_SIXEL
Definition sprite.h:118
@ SPRIXCELL_OPAQUE_SIXEL
Definition sprite.h:116
@ SPRIXEL_INVALIDATED
Definition sprite.h:24
struct blitterargs::@3::@5 pixel
sprixel * spx
Definition internal.h:388
union blitterargs::@3 u
uint32_t transcolor
Definition internal.h:380
char * buf
Definition fbuf.h:28
uint64_t size
Definition fbuf.h:26
unsigned dimx
Definition sprite.h:146
fbuf glyph
Definition sprite.h:138

◆ fbcon_draw()

int fbcon_draw ( const tinfo ti,
sprixel s,
int  y,
int  x 
)

Definition at line 799 of file linux.c.

799 {
800 (void)ti;
801 (void)s;
802 (void)y;
803 (void)x;
804 return 0;
805}
int y
Definition notcurses.h:1905
int int x
Definition notcurses.h:1905

◆ fbcon_rebuild()

int fbcon_rebuild ( sprixel s,
int  ycell,
int  xcell,
uint8_t *  auxvec 
)

Definition at line 791 of file linux.c.

791 {
792 (void)s;
793 (void)ycell;
794 (void)xcell;
795 (void)auxvec;
796 return 0;
797}

◆ fbcon_scroll()

void fbcon_scroll ( const struct ncpile p,
tinfo ti,
int  rows 
)

Definition at line 807 of file linux.c.

807 {
808 (void)p;
809 (void)ti;
810 (void)rows;
811}

◆ fbcon_scrub()

int fbcon_scrub ( const struct ncpile p,
sprixel s 
)

Definition at line 113 of file linux.c.

113 {
114 return sixel_scrub(p, s);
115}
int sixel_scrub(const ncpile *p, sprixel *s)
Definition sixel.c:1439
Here is the call graph for this function:

◆ fbcon_wipe()

int fbcon_wipe ( sprixel s,
int  ycell,
int  xcell 
)

Definition at line 16 of file linux.c.

16 {
17 uint8_t* auxvec = fbcon_auxiliary_vector(s);
18 if(auxvec == NULL){
19 return -1;
20 }
21 const int cellpxy = ncplane_pile(s->n)->cellpxy;
22 const int cellpxx = ncplane_pile(s->n)->cellpxx;
23 char* glyph = s->glyph.buf;
24 for(int y = 0 ; y < cellpxy ; ++y){
25 if(ycell * cellpxy + y >= s->pixy){
26 break;
27 }
28 // number of pixels total above our pixel row
29 const size_t yoff = s->pixx * (ycell * cellpxy + y);
30 for(int x = 0 ; x < cellpxx ; ++x){
31 if(xcell * cellpxx + x >= s->pixx){
32 break;
33 }
34 size_t offset = (yoff + xcell * cellpxx + x) * 4;
35 const int vyx = (y % cellpxy) * cellpxx + x;
36 auxvec[vyx] = glyph[offset + 3];
37 glyph[offset + 3] = 0;
38 }
39 }
40 s->n->tam[s->dimx * ycell + xcell].auxvector = auxvec;
41 return 0;
42}
tament * tam
Definition internal.h:106
int pixx
Definition sprite.h:147
int pixy
Definition sprite.h:147
struct ncplane * n
Definition sprite.h:142
void * auxvector
Definition sprite.h:128
return NULL
Definition termdesc.h:229

◆ get_linux_fb_pixelgeom()

int get_linux_fb_pixelgeom ( tinfo ti,
unsigned *  ypix,
unsigned *  xpix 
)

Definition at line 813 of file linux.c.

813 {
814 (void)ti;
815 (void)ypix;
816 (void)xpix;
817 return -1;
818}
Here is the caller graph for this function: