Improved perf.

This commit is contained in:
yellows8 2018-02-27 17:51:01 -05:00
parent a614d2fd98
commit 1542a249f0
2 changed files with 41 additions and 28 deletions

View File

@ -82,17 +82,25 @@ static inline void DrawPixelRaw(uint32_t x, uint32_t y, color_t clr)
if (x >= 1280 || y >= 720)
return;
u32 off = (y * g_framebuf_width + x)*4;
g_framebuf[off] = clr.r; off++;
g_framebuf[off] = clr.g; off++;
g_framebuf[off] = clr.b; off++;
g_framebuf[off] = 0xff;
*((u32*)&g_framebuf[off]) = clr.r | (clr.g<<8) | (clr.b<<16) | (0xff<<24);
}
static inline void Draw4PixelsRaw(uint32_t x, uint32_t y, color_t clr)
{
if (x >= 1280 || y >= 720 || x > 1280-4)
return;
u32 color = clr.r | (clr.g<<8) | (clr.b<<16) | (0xff<<24);
u128 val = color | ((u128)color<<32) | ((u128)color<<64) | ((u128)color<<96);
u32 off = (y * g_framebuf_width + x)*4;
*((u128*)&g_framebuf[off]) = val;
}
static inline color_t FetchPixelColor(uint32_t x, uint32_t y)
{
u32 off = (y * g_framebuf_width + x)*4;
u8 r = g_framebuf[off]; off++;
u8 g = g_framebuf[off]; off++;
u8 b = g_framebuf[off];
u32 val = *((u32*)&g_framebuf[off]);
u8 r = (u8)val;
u8 g = (u8)(val>>8);
u8 b = (u8)(val>>16);
return MakeColor(r, g, b, 255);
}
#else
@ -115,6 +123,11 @@ static inline void DrawPixelRaw(uint32_t x, uint32_t y, color_t clr)
pixels[y][x].b = clr.b;
pixels[y][x].a = 0xff;
}
static inline void Draw4PixelsRaw(uint32_t x, uint32_t y, color_t clr)
{
uint32_t pos;
for (pos=0; pos<4; pos++) DrawPixelRaw(x+pos, y, clr);
}
static inline color_t FetchPixelColor(uint32_t x, uint32_t y)
{
return pixels[y][x];

View File

@ -55,6 +55,7 @@ static void drawEntry(menuEntry_s* me, int off_x, int is_active) {
int end_y = start_y + 140 + 32;
int start_x = off_x;//(n / 2);
int end_x = start_x + 140;
int j;
const uint8_t *smallimg = NULL;
const uint8_t *largeimg = NULL;
@ -87,23 +88,22 @@ static void drawEntry(menuEntry_s* me, int off_x, int is_active) {
}
//{
for (x=border_start_x; x<border_end_x; x++) {
//DrawPixelRaw(x, start_y , border_color0);
DrawPixelRaw(x, end_y , border_color);
DrawPixelRaw(x, start_y-1, border_color);
DrawPixelRaw(x, end_y +1, border_color);
DrawPixelRaw(x, start_y-2, border_color);
DrawPixelRaw(x, end_y +2, border_color);
DrawPixelRaw(x, start_y-3, border_color);
DrawPixelRaw(x, end_y +3, border_color);
for (x=border_start_x; x<border_end_x; x+=4) {
Draw4PixelsRaw(x, end_y , border_color);
Draw4PixelsRaw(x, start_y-1, border_color);
Draw4PixelsRaw(x, end_y +1, border_color);
Draw4PixelsRaw(x, start_y-2, border_color);
Draw4PixelsRaw(x, end_y +2, border_color);
Draw4PixelsRaw(x, start_y-3, border_color);
Draw4PixelsRaw(x, end_y +3, border_color);
if (is_active) {
DrawPixelRaw(x, start_y-3, border_color);
DrawPixelRaw(x, end_y +3, border_color);
DrawPixelRaw(x, start_y-4, border_color);
DrawPixelRaw(x, end_y +4, border_color);
DrawPixelRaw(x, start_y-5, border_color);
DrawPixelRaw(x, end_y +5, border_color);
Draw4PixelsRaw(x, start_y-3, border_color);
Draw4PixelsRaw(x, end_y +3, border_color);
Draw4PixelsRaw(x, start_y-4, border_color);
Draw4PixelsRaw(x, end_y +4, border_color);
Draw4PixelsRaw(x, start_y-5, border_color);
Draw4PixelsRaw(x, end_y +5, border_color);
shadow_start_y = 6;
}
else {
@ -115,7 +115,7 @@ static void drawEntry(menuEntry_s* me, int off_x, int is_active) {
shadow_inset =(shadow_y-shadow_start_y);
if (x >= border_start_x + shadow_inset && x < border_end_x - shadow_inset) {
DrawPixel(x, end_y +shadow_y, shadow_color);
for (j=0; j<4; j++) DrawPixel(x+j, end_y +shadow_y, shadow_color);
}
}
}
@ -140,9 +140,9 @@ static void drawEntry(menuEntry_s* me, int off_x, int is_active) {
}
//}
for (x=start_x; x<end_x; x++) {
for (y=start_y; y<end_y; y++) {
DrawPixelRaw(x, y, MakeColor(255, 255, 255, 255));
for (y=start_y; y<end_y; y++) {
for (x=start_x; x<end_x; x+=4) {
Draw4PixelsRaw(x, y, MakeColor(255, 255, 255, 255));
}
}
@ -327,8 +327,8 @@ void menuLoop() {
int x, y;
for (y=0; y<450; y++) {
for (x=0; x<1280; x++) {// don't draw bottom pixels as they are covered by the waves
DrawPixelRaw(x, y, themeCurrent.backgroundColor);
for (x=0; x<1280; x+=4) {// don't draw bottom pixels as they are covered by the waves
Draw4PixelsRaw(x, y, themeCurrent.backgroundColor);
}
}