图库: 阅读器页槽改 RGB565 常驻,页图内存减半(M32)
- 页槽从 RGBA 改成「已落框的 RGB565 位图」(2B/px):真机 480×853 页 1599KB → 800KB, 两页常驻 3.2MB → 1.6MB。解码仍在 worker 里产出 RGBA,当场转 565 并释放 RGBA。 - SDK 新增 565 原语(meow_ui_draw.h / meow_ui_gfx.c):meow_gfx_blit_rgb565 命中页每行 一次 memcpy(单次拷贝、无每帧重采样),缩放兜底走 565 最近邻。量化与 back_buf 用同一个 rgb565(),565 屏上落下的像素与旧 RGBA 路径逐像素一致(不引入色偏/新增色带)。 - 预算按 565 重算:单页像素上限沿用旧 3MB@RGBA 的同几何口径(=1.5MB@565), MR_RESIDENT_CAP = 3 槽 + 1 张在途 = 3.2MB;reader_estimate_peak 新增 convert_bytes (落槽暂存 2B/px)与 peak_bytes 一起参与门控,避免实测超预算。 - 结果队列(已解码、未落槽)字节计入总预算(pending_bytes),不再「偷吃」最多 2 页。 - CBZ meta() 改读条目 4KB 前缀(mz_read_prefix;deflate 解到 4KB 即停,输入缓冲走栈), 500 页排版不再触发 500 次全量解压。 - 测试:B3/B8 的 565 常驻与在途预算断言、CBZ 500 页 stored/deflate 前后对比、 P12 565 与 RGBA 路径的逐像素颜色对比(量化误差/RMSE/灰阶梯)。
This commit is contained in:
1 parent
bbc73635a6
commit
7036020005
11 files changed
+910
-111
No files matched your search
@@ -50,6 +50,19 @@ void meow_ui_flush_region(int x, int y, int w, int h); /* 只刷新指定区 *
|
||||
/* 半透明(blend565:前景按 alpha 与背景混叠) */
|
||||
void meow_ui_fill_rect_alpha(int x, int y, int w, int h, uint32_t color, int alpha); /* 0-255 */
|
||||
|
||||
/* ---- RGB565 页图(M32)----
|
||||
* 页槽常驻 RGB565(2 字节/像素):真机 480×853 页 1599KB → 800KB。
|
||||
* 量化与 back_buf 用同一个 565 转换(逐位截断),565 屏上最终像素与 RGBA blit
|
||||
* 路径逐像素一致——不引入色偏、不会比现在多出色带。
|
||||
* 命中页(页图尺寸 == 显示尺寸)走 meow_gfx_blit_rgb565:每行一次拷贝,无重采样。 */
|
||||
uint16_t meow_gfx_rgb565(uint32_t rgb); /* 24-bit RGB → 565(与 back_buf 同式) */
|
||||
void meow_gfx_rgba_to_rgb565(const uint8_t *rgba, uint16_t *out, int npx); /* 不透明像素 */
|
||||
/* 原生尺寸 blit(不透明):16bpp back_buf 上是每行一次 memcpy。 */
|
||||
void meow_gfx_blit_rgb565(int x, int y, int w, int h, const uint16_t *px);
|
||||
/* 最近邻缩放 blit(几何不符时的兜底;采样点与 meow_img_resample 同式)。 */
|
||||
void meow_gfx_blit_rgb565_scaled(int x, int y, int w, int h,
|
||||
int sw, int sh, const uint16_t *px);
|
||||
|
||||
/* ============================================================ */
|
||||
/* §7 动画/时间(B1 最小可用) */
|
||||
/* ============================================================ */
|
||||
|
||||
@@ -856,6 +856,105 @@ void meow_gfx_blit_rgba(int x, int y, int w, int h, const uint8_t *rgba, int alp
|
||||
dirty_add(x1, y1, x2 - x1, y2 - y1);
|
||||
}
|
||||
|
||||
/* ================= RGB565 页图(M32) =================
|
||||
* 阅读器页槽常驻 RGB565(2B/px)而不是 RGBA:真机 480×853 页 1599KB → 800KB。
|
||||
* 量化与 back_buf 用同一个 rgb565()(逐位截断),所以 565 屏上落下的像素与旧的
|
||||
* RGBA blit 路径**逐像素一致**——不引入色偏,也不会比现在多出色带。
|
||||
* 命中页(解码/落框尺寸 == 显示尺寸)走 meow_gfx_blit_rgb565:每行一次 memcpy,
|
||||
* 单次拷贝、没有每帧重采样。alpha 按不透明处理(页图没有透明通道)。 */
|
||||
uint16_t meow_gfx_rgb565(uint32_t rgb)
|
||||
{
|
||||
return rgb565(rgb);
|
||||
}
|
||||
|
||||
void meow_gfx_rgba_to_rgb565(const uint8_t *rgba, uint16_t *out, int npx)
|
||||
{
|
||||
if (!rgba || !out || npx <= 0) return;
|
||||
for (int i = 0; i < npx; i++) {
|
||||
const uint8_t *p = rgba + (size_t)i * 4;
|
||||
out[i] = rgb565(((uint32_t)p[0] << 16) | ((uint32_t)p[1] << 8) | (uint32_t)p[2]);
|
||||
}
|
||||
}
|
||||
|
||||
/* 目标矩形与 clip 求交;返回 1=还有可画区域。 */
|
||||
static int blit565_clip(int x, int y, int w, int h, int *x1, int *y1, int *x2, int *y2)
|
||||
{
|
||||
if (!g_init_ok || w <= 0 || h <= 0) return 0;
|
||||
*x1 = x; *y1 = y; *x2 = x + w; *y2 = y + h;
|
||||
if (*x1 < 0) *x1 = 0;
|
||||
if (*y1 < 0) *y1 = 0;
|
||||
if (*x2 > g_xres) *x2 = g_xres;
|
||||
if (*y2 > g_yres) *y2 = g_yres;
|
||||
if (g_clip_n > 0) {
|
||||
int *c = g_clip_stack[g_clip_n - 1];
|
||||
if (*x1 < c[0]) *x1 = c[0];
|
||||
if (*y1 < c[1]) *y1 = c[1];
|
||||
if (*x2 > c[2]) *x2 = c[2];
|
||||
if (*y2 > c[3]) *y2 = c[3];
|
||||
}
|
||||
return *x2 > *x1 && *y2 > *y1;
|
||||
}
|
||||
|
||||
void meow_gfx_blit_rgb565(int x, int y, int w, int h, const uint16_t *px)
|
||||
{
|
||||
if (!px) return;
|
||||
int x1, y1, x2, y2;
|
||||
if (!blit565_clip(x, y, w, h, &x1, &y1, &x2, &y2)) return;
|
||||
int n = x2 - x1;
|
||||
for (int py = y1; py < y2; py++) {
|
||||
const uint16_t *src = px + (size_t)(py - y) * w + (x1 - x);
|
||||
unsigned char *dst = g_fb + (size_t)py * g_line + (size_t)x1 * (size_t)(g_bpp / 8);
|
||||
if (g_bpp == 16) {
|
||||
memcpy(dst, src, (size_t)n * 2); /* 命中页:每行一次拷贝 */
|
||||
} else {
|
||||
uint32_t *d32 = (uint32_t *)dst;
|
||||
for (int i = 0; i < n; i++) {
|
||||
uint16_t c = src[i];
|
||||
d32[i] = ((uint32_t)ex5((c >> 11) & 0x1F) << 24) |
|
||||
((uint32_t)ex6((c >> 5) & 0x3F) << 16) |
|
||||
((uint32_t)ex5(c & 0x1F) << 8) | 0xFFu;
|
||||
}
|
||||
}
|
||||
}
|
||||
dirty_add(x1, y1, n, y2 - y1);
|
||||
}
|
||||
|
||||
/* 最近邻缩放(仅几何不符时的兜底路径;采样点与 meow_img_resample 同式)。
|
||||
* 命中页不会走到这里——那是热路径纪律(M17/M32)。 */
|
||||
void meow_gfx_blit_rgb565_scaled(int x, int y, int w, int h,
|
||||
int sw, int sh, const uint16_t *px)
|
||||
{
|
||||
if (!px || sw <= 0 || sh <= 0) return;
|
||||
int x1, y1, x2, y2;
|
||||
if (!blit565_clip(x, y, w, h, &x1, &y1, &x2, &y2)) return;
|
||||
int n = x2 - x1;
|
||||
for (int py = y1; py < y2; py++) {
|
||||
int sy = (int)((long long)(py - y) * sh / h);
|
||||
if (sy >= sh) sy = sh - 1;
|
||||
const uint16_t *row = px + (size_t)sy * sw;
|
||||
unsigned char *dst = g_fb + (size_t)py * g_line + (size_t)x1 * (size_t)(g_bpp / 8);
|
||||
if (g_bpp == 16) {
|
||||
uint16_t *d16 = (uint16_t *)dst;
|
||||
for (int i = 0; i < n; i++) {
|
||||
int sx = (int)((long long)(x1 + i - x) * sw / w);
|
||||
if (sx >= sw) sx = sw - 1;
|
||||
d16[i] = row[sx];
|
||||
}
|
||||
} else {
|
||||
uint32_t *d32 = (uint32_t *)dst;
|
||||
for (int i = 0; i < n; i++) {
|
||||
int sx = (int)((long long)(x1 + i - x) * sw / w);
|
||||
if (sx >= sw) sx = sw - 1;
|
||||
uint16_t c = row[sx];
|
||||
d32[i] = ((uint32_t)ex5((c >> 11) & 0x1F) << 24) |
|
||||
((uint32_t)ex6((c >> 5) & 0x3F) << 16) |
|
||||
((uint32_t)ex5(c & 0x1F) << 8) | 0xFFu;
|
||||
}
|
||||
}
|
||||
}
|
||||
dirty_add(x1, y1, n, y2 - y1);
|
||||
}
|
||||
|
||||
/* ================= present / 上屏 ================= */
|
||||
static void dump_ppm(void)
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user