Skip to content

Commit 1d3f750

Browse files
committed
vfx_core: optimize color filling
1 parent 9056a14 commit 1d3f750

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

main/inc/user/vfx_core.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#include <stdint.h>
1212

1313
extern uint32_t vfx_get_color(float color_h, float color_l);
14-
14+
extern void vfx_draw_pixel_raw(uint8_t x, uint8_t y, uint8_t z, uint32_t color);
1515
extern void vfx_draw_pixel(uint8_t x, uint8_t y, uint8_t z, float color_h, float color_l);
1616
extern void vfx_fill_cube(uint8_t x, uint8_t y, uint8_t z, uint8_t cx, uint8_t cy, uint8_t cz, float color_h, float color_l);
1717
extern void vfx_draw_cube_bitmap(const uint8_t *bitmap, float color_l);

main/src/user/vfx_core.c

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,8 @@ uint32_t vfx_get_color(float color_h, float color_l)
6767
}
6868

6969
#ifdef CONFIG_VFX_OUTPUT_CUBE0414
70-
void vfx_draw_pixel(uint8_t x, uint8_t y, uint8_t z, float color_h, float color_l)
70+
void vfx_draw_pixel_raw(uint8_t x, uint8_t y, uint8_t z, uint32_t color)
7171
{
72-
uint32_t pixel_color = vfx_get_color(color_h, color_l);
73-
7472
#ifdef CONFIG_CUBE0414_LAYER_H
7573
uint8_t pixel_x = x + y * 8;
7674
uint8_t pixel_y = z;
@@ -96,15 +94,24 @@ void vfx_draw_pixel(uint8_t x, uint8_t y, uint8_t z, float color_h, float color_
9694
uint8_t pixel_y = 7 - y;
9795
#endif
9896

99-
gdispGDrawPixel(vfx_gdisp, pixel_x, pixel_y, pixel_color);
97+
gdispGDrawPixel(vfx_gdisp, pixel_x, pixel_y, color);
98+
}
99+
100+
void vfx_draw_pixel(uint8_t x, uint8_t y, uint8_t z, float color_h, float color_l)
101+
{
102+
uint32_t pixel_color = vfx_get_color(color_h, color_l);
103+
104+
vfx_draw_pixel_raw(x, y, z, pixel_color);
100105
}
101106

102107
void vfx_fill_cube(uint8_t x, uint8_t y, uint8_t z, uint8_t cx, uint8_t cy, uint8_t cz, float color_h, float color_l)
103108
{
109+
uint32_t pixel_color = vfx_get_color(color_h, color_l);
110+
104111
for (uint8_t i=0; i<cx; i++) {
105112
for (uint8_t j=0; j<cy; j++) {
106113
for (uint8_t k=0; k<cz; k++) {
107-
vfx_draw_pixel(x+i, y+j, z+k, color_h, color_l);
114+
vfx_draw_pixel_raw(x+i, y+j, z+k, pixel_color);
108115
}
109116
}
110117
}

0 commit comments

Comments
 (0)