|
|
@@ -9,7 +9,7 @@
|
|
|
#define LUAT_LOG_TAG "ui_sdl2"
|
|
|
#include "luat_log.h"
|
|
|
|
|
|
-static uint32_t* fb;
|
|
|
+static luat_color_t* fb;
|
|
|
|
|
|
static inline uint32_t luat_color_565to8888(luat_color_t color);
|
|
|
|
|
|
@@ -19,7 +19,7 @@ static int sdl2_init(luat_lcd_conf_t* conf) {
|
|
|
.height = conf->h
|
|
|
};
|
|
|
luat_sdl2_init(&sdl2_conf);
|
|
|
- size_t fb_size = sizeof(uint32_t) * conf->w * conf->h;
|
|
|
+ size_t fb_size = sizeof(luat_color_t) * conf->w * conf->h;
|
|
|
fb = luat_heap_opt_malloc(LUAT_HEAP_PSRAM, fb_size);
|
|
|
if (fb == NULL) {
|
|
|
fb = luat_heap_opt_malloc(LUAT_HEAP_SRAM, fb_size);
|
|
|
@@ -34,7 +34,8 @@ static int sdl2_init(luat_lcd_conf_t* conf) {
|
|
|
return -1;
|
|
|
}
|
|
|
}
|
|
|
- LLOGD("sdl2_init conf->buff %p, conf->opts %p fb %p", conf->buff, conf->opts, fb);
|
|
|
+ LLOGD("sdl2_init w %d h %d fb_size %u conf->buff %p conf->opts %p fb %p",
|
|
|
+ conf->w, conf->h, (unsigned int)fb_size, conf->buff, conf->opts, fb);
|
|
|
luat_lcd_clear(conf, LCD_WHITE);
|
|
|
// printf("ARGB8888 0xFFFF %08X\n", luat_color_565to8888(0xFFFF));
|
|
|
// printf("ARGB8888 0X001F %08X\n", luat_color_565to8888(0X001F));
|
|
|
@@ -94,14 +95,7 @@ int luat_lcd_flush(luat_lcd_conf_t* conf) {
|
|
|
size_t height = y_max - y_min + 1;
|
|
|
|
|
|
luat_color_t* src = conf->buff + y_min * conf->w;
|
|
|
- uint32_t* tmp = fb;
|
|
|
- for (size_t row = 0; row < height; row++) {
|
|
|
- for (size_t col = 0; col < width; col++) {
|
|
|
- tmp[row * width + col] = luat_color_565to8888(src[col]);
|
|
|
- }
|
|
|
- src += conf->w;
|
|
|
- }
|
|
|
- luat_sdl2_draw(0, y_min, conf->w - 1, y_max, fb);
|
|
|
+ luat_sdl2_draw(0, y_min, conf->w - 1, y_max, src);
|
|
|
luat_sdl2_flush();
|
|
|
|
|
|
conf->flush_y_max = 0;
|
|
|
@@ -155,18 +149,18 @@ int luat_lcd_draw(luat_lcd_conf_t* conf, int16_t x1, int16_t y1, int16_t x2, int
|
|
|
size_t rw = x2 - x1 + 1;
|
|
|
size_t rh = y2 - y1 + 1;
|
|
|
|
|
|
- uint32_t *tmp = fb;
|
|
|
+ luat_color_t *tmp = fb;
|
|
|
for (size_t i = 0; i < rh; i++)
|
|
|
{
|
|
|
for (size_t j = 0; j < rw; j++)
|
|
|
{
|
|
|
- // 输入为 RGB565,SDL 纹理为 ARGB8888,这里做明确转换
|
|
|
- *tmp = luat_color_565to8888(*color_p);
|
|
|
+ // 直接拷贝 RGB565 数据
|
|
|
+ *tmp = *color_p;
|
|
|
tmp ++;
|
|
|
color_p ++;
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
luat_sdl2_draw(x1, y1, x2, y2, fb);
|
|
|
return 0;
|
|
|
}
|