diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..f9a5742 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "editor.fontSize": 12 +} \ No newline at end of file diff --git a/azur/src/gint/shaders/circle.c b/azur/src/gint/shaders/circle.c index 5afb07d..b3c9c4e 100644 --- a/azur/src/gint/shaders/circle.c +++ b/azur/src/gint/shaders/circle.c @@ -14,6 +14,7 @@ void azrp_shader_circle_configure(void) azrp_set_uniforms(AZRP_SHADER_CIRCLE, (void *)azrp_width); } + static int min(int x, int y) { return (x < y) ? x : y; @@ -27,11 +28,13 @@ static int max(int x, int y) typedef struct { - uint16_t x; - uint16_t y; -}Pixel; + int16_t x; + int16_t y; +} Pixel; -Pixel TablePixels[14][396]; // 14 fragments each able to store as much pixels as width +#define TABLE_WIDTH 396 + +Pixel TablePixels[14*TABLE_WIDTH]; // 14 fragments each able to store as much pixels as width uint16_t NbPixels[14]; // Nunmber of pixels in each fragment struct command { @@ -39,20 +42,22 @@ struct command { uint16_t color; uint8_t currfrag; - uint16_t* pixnb; - Pixel **data; + uint16_t *pixnb; + Pixel *data; }; -void AddPixel( int xp, int yp ) +void AddPixel( int16_t xp, int16_t yp ) { if (xp >= 0 && xp < azrp_width && yp >= 0 && yp < azrp_height) { - int currfrag = yp >> 4; + uint8_t currfrag = yp >> 4; uint16_t nbpixinfrag = NbPixels[ currfrag ]; - TablePixels[ currfrag ][ nbpixinfrag ].x = xp; - TablePixels[ currfrag ][ nbpixinfrag ].y = yp & 15; + uint16_t index = currfrag * TABLE_WIDTH + nbpixinfrag; + + TablePixels[ index ].x = xp; + TablePixels[ index ].y = yp & 15; NbPixels[ currfrag ]++; } @@ -63,7 +68,7 @@ void azrp_circle(int xc, int yc, int rad, int color) prof_enter(azrp_perf_cmdgen); - for(int i=0;i<14;i++) NbPixels[i]=0; + for( int i = 0; i < 14; i++ ) NbPixels[i]=0; int xmin = xc - rad; @@ -94,9 +99,9 @@ void azrp_circle(int xc, int yc, int rad, int color) int x = 0; int y = rad; - int d = rad - 1; + int m = 5 - 4*rad; - while (y >= x) + while (x <= y) { AddPixel( xc+x, yc+y ); AddPixel( xc+y, yc+y ); @@ -107,22 +112,15 @@ void azrp_circle(int xc, int yc, int rad, int color) AddPixel( xc-x, yc-y ); AddPixel( xc-y, yc-x ); - if (d >= 2*x) + if (m >0) { - d = d - 2*x - 1; - x++; - } - else if (d < 2*(rad-y)) - { - d = d + 2*y - 1; y--; + m -= 8*y; } - else - { - d = d + 2*(y - x - 1); - y--; - x++; - } + + x--; + m += 8*x + 4; + } cmd.pixnb = NbPixels; @@ -137,15 +135,12 @@ void azrp_shader_circle( void *uniforms, void *comnd, void *fragment ) struct command *cmd = (struct command *) comnd; uint16_t *frag = (uint16_t *) fragment; - uint16_t *nbPix = cmd->pixnb; - uint16_t taille = nbPix[ cmd->currfrag ]; + uint16_t taille = (uint16_t) cmd->pixnb[ cmd->currfrag ]; + Pixel *Data = (Pixel *) &cmd->data[ cmd->currfrag * TABLE_WIDTH ]; - Pixel *pixData = cmd->data[ cmd->currfrag ]; - - for( int i=0; icurrfrag]; i++ ) + for( int i = 0; i < taille; i++ ) { - - frag[ azrp_width * currFragPix[i].y + currFragPix[i].x ] = cmd->color; + frag[ azrp_width * Data[i].y + Data[i].x ] = cmd->color; } cmd->currfrag++; diff --git a/azur/src/gint/shaders/line.c b/azur/src/gint/shaders/line.c index 5030f57..f7a7354 100644 --- a/azur/src/gint/shaders/line.c +++ b/azur/src/gint/shaders/line.c @@ -14,14 +14,6 @@ void azrp_shader_line_configure(void) azrp_set_uniforms(AZRP_SHADER_LINE, (void *)azrp_width); } -static int min(int x, int y) -{ - return (x < y) ? x : y; -} -static int max(int x, int y) -{ - return (x > y) ? x : y; -} //---