- P1:plan_decode_long 的判据从 l*s*4 改成 l*s*2(MR_PAGE_BYTES_CAP 已是 565 口径)。 改前真机 480×853 页被压到 359×639(448KB)且每帧重采样;改后原尺寸落槽 799KB、 绘制走原生 blit(scaled 增量 0)。 - 测试:新增 perf P13 —— 480×853 单页册,断言 slot_kb==480*853*2/1024、resident 相等、 draw 后 blit 增长且 scaled 增量为 0;现有夹具(480×640/600×960)都在阈值以下,抓不到。 - P2:decode 日志 ok/fail 也打 peak+convert(与 skip 同口径);CBZ 500 页的「前缀字节」 改成 mz_read_prefix 实测(不再用 500×4096 硬算),并说明 zlib 窗口不计入 --wrap 峰值; 565 页图 alpha 忽略的行为差异写进 meow_ui_draw.h / gfx 注释;MR_ZOOM_TEMP_CAP 注释更正。
96 lines
4.8 KiB
C
96 lines
4.8 KiB
C
/*
|
||
* meow_ui_draw.h — SDK 绘制层(§3)+ 动画/时间(§7)+ 显示刷新率调度(§7.1)。
|
||
*
|
||
* 原 meow_ui.h 拆分的一部分(draw/gfx 模块)。坐标 0,0 = 左上;颜色均 24-bit RGB
|
||
* (0xRRGGBB),内部转 RGB565;所有绘制先进离屏 back_buf,调用 meow_ui_flush()/
|
||
* flush_region() 才上屏。文本字号:28(标题/状态栏)、20(正文/按钮)。
|
||
*/
|
||
#ifndef MEOW_UI_DRAW_H
|
||
#define MEOW_UI_DRAW_H
|
||
|
||
#include "meow_ui_types.h"
|
||
|
||
#ifdef __cplusplus
|
||
extern "C" {
|
||
#endif
|
||
|
||
/* ============================================================ */
|
||
/* §3 绘制层 */
|
||
/* ============================================================ */
|
||
/* init 选项。width/height 为 0 表示自动读取 /dev/fb0 几何;
|
||
* 无 fb(宿主/qemu 离屏)时用 480×720 缺省([D1])。 */
|
||
typedef struct meow_ui_opts {
|
||
int width;
|
||
int height;
|
||
} meow_ui_opts;
|
||
|
||
int meow_ui_init(const meow_ui_opts *opts); /* 开 fb、读几何、载字库、建 back_buf;0=成功 */
|
||
void meow_ui_shutdown(void);
|
||
|
||
int meow_ui_width(void); /* 480 */
|
||
int meow_ui_height(void); /* 720 */
|
||
|
||
void meow_ui_clear(uint32_t color); /* 整屏清(填背景色) */
|
||
void meow_ui_put_px(int x, int y, uint32_t color);
|
||
void meow_ui_fill_rect(int x, int y, int w, int h, uint32_t color);
|
||
void meow_ui_draw_rect(int x, int y, int w, int h, uint32_t color); /* 空心框 */
|
||
void meow_ui_draw_rect_round(int x, int y, int w, int h, int r, uint32_t color); /* 圆角框 */
|
||
|
||
/* 文本(size=20/28) */
|
||
void meow_ui_text(int x, int y, const char *utf8, int size, uint32_t color);
|
||
void meow_ui_text_right(int right_x, int y, const char *utf8, int size, uint32_t color);
|
||
void meow_ui_text_center(int cx, int y, const char *utf8, int size, uint32_t color);
|
||
int meow_ui_text_width(const char *utf8, int size);
|
||
int meow_ui_text_height(int size); /* = meow_font_line_height */
|
||
|
||
/* 上屏:vsync + 原子 blit 脏区(内建脏区追踪) */
|
||
void meow_ui_flush(void);
|
||
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:每行一次拷贝,无重采样。
|
||
*
|
||
* alpha:565 页图**按不透明**处理(alpha 被忽略)。漫画页解码后 alpha 恒为 255,
|
||
* 与旧路径等价;带透明像素的 PNG(调色板/tRNS/color type 6、或 32bpp BMP)会有可见
|
||
* 差异:旧 RGBA 路径把透明像素混合到阅读器底色,565 路径直接画它的 RGB(通常是黑)。
|
||
* 若将来要支持透明页,需要在上屏时按 alpha 混合(而不是在落槽时丢通道)。 */
|
||
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); /* 不透明像素(忽略 alpha) */
|
||
/* 原生尺寸 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 最小可用) */
|
||
/* ============================================================ */
|
||
uint64_t meow_ui_time_ms(void); /* 单调毫秒时间戳 */
|
||
|
||
/* ============================================================ */
|
||
/* §7.1 显示刷新率调度(A-1/A-2:从 launcher M2.16 迁入,归口 SDK,PERF_SCHEDULER 显示子域) */
|
||
/* ============================================================ */
|
||
/* 设目标档位 60/30/15(launcher 与 app 统一走 SDK 的 present 帧率门控一致)。
|
||
* 同时把当前有效档对齐到目标(与 launcher settings_load 语义一致)。 */
|
||
void meow_ui_set_refresh_rate(int r);
|
||
|
||
/* 1=恒 max 不降档(性能优先);0=允许 governor 在 [15,30,60] 自适应降/升档。 */
|
||
void meow_ui_set_refresh_always_max(int on);
|
||
|
||
/* 当前有效帧率(governor 可能已降档;诊断用)。 */
|
||
int meow_ui_effective_rate(void);
|
||
|
||
/* 已呈现帧计数(验证 present 频率用)。 */
|
||
unsigned long long meow_ui_frames_presented(void);
|
||
|
||
#ifdef __cplusplus
|
||
}
|
||
#endif
|
||
#endif /* MEOW_UI_DRAW_H */
|