Add 'sdk/' from commit '2e7561d74f75de05dd7fb362f203f600afb451d7'

git-subtree-dir: sdk
git-subtree-mainline: 17a972d46f
git-subtree-split: 2e7561d74f
This commit is contained in:
MeowOS committed 2026-09-01 21:08:40 +08:00
commit f44e3bc6d0
85 files changed
+23811

No files matched your search

+77
View File
@@ -0,0 +1,77 @@
/*
* 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 */
/* ============================================================ */
/* §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 */