refactor(sdk/lyric)+misc: ①G5断言改成EXIT(播放页任意右滑回桌面,宿主全过) ②meow_img_pixels正式访问器上收(替代局部补全结构体,const化w/h,清3处警告) ③RECOVERY_PROMPT §五铁律补重链四App ④MEOW_APP_SDK.md §4.1取色/§5.9音频/§9后台字段/§16歌词组件;0warning;meow_ui.a变M6.34需重编+四App重链
This commit is contained in:
1 parent
45c633868f
commit
3c5612f7c9
6 files changed
+168
-33
No files matched your search
@@ -287,9 +287,9 @@ int main(void)
|
||||
/* 播放页:左缘右滑 → 回桌面(保留 M6.26) */
|
||||
CHECK(np_gesture_decide(NP_PAGE_PLAY, 8, 100, 80, 5) == NP_GEST_EXIT,
|
||||
"play: edge right-swipe -> exit");
|
||||
/* 播放页:非左缘右滑 → 播放页无上一页,忽略(不误切/不误退) */
|
||||
CHECK(np_gesture_decide(NP_PAGE_PLAY, 200, 100, 80, 5) == NP_GEST_NONE,
|
||||
"play: non-edge right-swipe -> none");
|
||||
/* 播放页:任意右滑 → 返回桌面(用户定案「播放页任意右滑回桌面」,含非左缘;np_gesture.h 恒 EXIT) */
|
||||
CHECK(np_gesture_decide(NP_PAGE_PLAY, 200, 100, 80, 5) == NP_GEST_EXIT,
|
||||
"play: non-edge right-swipe -> EXIT");
|
||||
/* 歌词页:左→右滑 → 回播放页(不是回桌面) */
|
||||
CHECK(np_gesture_decide(NP_PAGE_LYRIC, 200, 100, 60, 5) == NP_GEST_PREV,
|
||||
"lyric: right-swipe -> play");
|
||||
|
||||
@@ -22,8 +22,11 @@ meow_img *meow_img_load_file(const char *path); /* 内部读文件 + stb 解
|
||||
meow_img *meow_img_load_mem(const void *buf, int len);
|
||||
void meow_img_free(meow_img *img);
|
||||
|
||||
int meow_img_w(meow_img *img);
|
||||
int meow_img_h(meow_img *img);
|
||||
int meow_img_w(const meow_img *img);
|
||||
int meow_img_h(const meow_img *img);
|
||||
/* 访问器:取 RGBA 像素指针(4 通道 straight alpha;供取色/直读像素)。meow_img 对外 opaque,
|
||||
* 本函数为其唯一像素读入口;NULL 返回 NULL。 */
|
||||
const unsigned char *meow_img_pixels(const meow_img *img);
|
||||
|
||||
void meow_ui_img(int x, int y, meow_img *img); /* 原始尺寸 */
|
||||
/* 内存瘦身:最近邻等比缩放到最长边 ≤maxdim,返回新图;原图已 ≤maxdim 返回 NULL。
|
||||
|
||||
@@ -1,21 +1,16 @@
|
||||
/*
|
||||
* meow_img_color.c — MeowOS SDK 封面双色渐变取色实现(见 meow_img_color.h 契约)。
|
||||
*
|
||||
* 独立源码,不并入 meow_ui.a(铁律:避免并发重编/四 App 重链)。纯函数,无任何 meow_* 调用,
|
||||
* 宿主单测零链接重(仅需本 .c + meow_img_color.h 及其 include 链)。
|
||||
*
|
||||
* 布局耦合说明:meow_img 为 opaque(对外仅前向声明,结构体私有于 meow_ui_img.c)。为在不动
|
||||
* meow_ui.a 二进制的前提下直读封面像素(批5 取色),本 TU 按 meow_ui_img.c 自 A1 起稳定的
|
||||
* `struct meow_img { int w, h; unsigned char *rgba; };` 未布局局部补全。两 TU 各持同一定义,
|
||||
* 链接后字段偏移一致(本项目内 ABI 稳定)。主会话下次重建 SDK 时可上收为 meow_ui_img.c 的
|
||||
* 正式访问器,届时本补全即删除。
|
||||
* 独立源码,不并入 meow_ui.a(铁律:避免并发重编/四 App 重链)。取色算法纯函数(无 GPU/浮点/堆)。
|
||||
* 唯一 meow_* 依赖:仅 meow_img_pixels(SDK 正式访问器,meow_ui_img.c §4),并经 meow_img_w/h 取宽高
|
||||
* ——三者读 meow_img 的唯一入口,本 TU 不再局部补全其结构体(agent-402 遗留点已上收)。App/宿主
|
||||
* 链入 meow_img_color.c 时需能解析 meow_img_pixels/w/h(宿主测试已链 meow_ui_img.c,实际 App 恒链
|
||||
* meow_ui.a)。
|
||||
*/
|
||||
#include "meow_img_color.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
struct meow_img { int w, h; unsigned char *rgba; }; /* 见上:局部补全(与 meow_ui_img.c 一致) */
|
||||
|
||||
#define MIC_BUCKETS 4 /* 每通道色阶数 ⇒ 4×4×4=64 桶 */
|
||||
#define MIC_NBUCKET (MIC_BUCKETS*MIC_BUCKETS*MIC_BUCKETS)
|
||||
#define MIC_ALPHA_MIN 64 /* 跳过近透明(alpha<64) */
|
||||
@@ -120,8 +115,10 @@ int meow_img_duocolor_rgba(const uint8_t *rgba, int w, int h,
|
||||
int meow_img_duocolor(const meow_img *im, uint32_t *main, uint32_t *second)
|
||||
{
|
||||
if (!im) return -1;
|
||||
/* 局部补全 struct 视图直读像素(布局与 meow_ui_img.c 一致,见顶部说明)。 */
|
||||
return meow_img_duocolor_rgba(im->rgba, im->w, im->h, main, second);
|
||||
/* 经 SDK 正式访问器读像素(meow_img opaque;meow_img_pixels 为唯一读入口)。 */
|
||||
const unsigned char *rgba = meow_img_pixels(im);
|
||||
if (!rgba) return -1;
|
||||
return meow_img_duocolor_rgba(rgba, meow_img_w(im), meow_img_h(im), main, second);
|
||||
}
|
||||
|
||||
void meow_img_color_derive(uint32_t main, uint32_t second, const meow_theme *th,
|
||||
|
||||
@@ -9,11 +9,11 @@
|
||||
* `#include "meow_img_color.h"` 并在构建时单链 meow_img_color.c(宿主单测同法)。
|
||||
*
|
||||
* 约束(0 warning / 最小侵入):
|
||||
* - 不修改 meow_ui.a 任何成员(meow_img 保持 opaque 对外)。为直读封面像素,本 TU 按
|
||||
* meow_ui_img.c 自 A1 起稳定的 `struct meow_img { int w,h; unsigned char *rgba; }` 布局
|
||||
* 局部补全(见 .c 顶部说明)。主会话下次重建 SDK 时可上收为 meow_ui_img.c 的正式访问器。
|
||||
* - 纯函数:meow_img_duocolor_rgba / meow_img_duocolor / meow_img_color_derive 不调用任何
|
||||
* meow_* 符号,宿主单测可零链接重(仅需本头 + 本 .c)。
|
||||
* - meow_img 对外保持 opaque;像素直读经 SDK 正式访问器 `meow_img_pixels`(meow_ui_img.c §4,
|
||||
* 已上收「局部补全结构体」遗留),宽高经 `meow_img_w`/`meow_img_h`。本 TU 不再局部补全布局。
|
||||
* - 取色算法纯函数:meow_img_duocolor_rgba / meow_img_color_derive 纯 C、无 meow_* 依赖;
|
||||
* meow_img_duocolor(句柄版)仅经上述三访问器读,不触碰 meow_ui.a 内部实现。宿主单测链
|
||||
* meow_img_color.c + meow_ui_img.c 即可。
|
||||
*
|
||||
* 色彩语义:
|
||||
* - 输入 RGBA(stb_image 输出,4 通道 straight alpha),w×h,最多遍历 ~3.6k 采样(内部自适
|
||||
@@ -37,7 +37,7 @@ extern "C" {
|
||||
int meow_img_duocolor_rgba(const uint8_t *rgba, int w, int h,
|
||||
uint32_t *main, uint32_t *second);
|
||||
|
||||
/* 从 meow_img 句柄取主色+次色(内部直读 rgba 缓冲,见 .c 布局说明)。返回 0=成功;-1=失败。 */
|
||||
/* 从 meow_img 句柄取主色+次色(经 meow_img_pixels 读像素,见 .c)。返回 0=成功;-1=失败。 */
|
||||
int meow_img_duocolor(const meow_img *im, uint32_t *main, uint32_t *second);
|
||||
|
||||
/* 由主/次色派生播放页 + 歌词页封面主题(纯函数,可宿主单测)。
|
||||
|
||||
@@ -49,8 +49,12 @@ void meow_img_free(meow_img *im)
|
||||
free(im);
|
||||
}
|
||||
|
||||
int meow_img_w(meow_img *im) { return im ? im->w : 0; }
|
||||
int meow_img_h(meow_img *im) { return im ? im->h : 0; }
|
||||
int meow_img_w(const meow_img *im) { return im ? im->w : 0; }
|
||||
int meow_img_h(const meow_img *im) { return im ? im->h : 0; }
|
||||
|
||||
/* 访问器:取 RGBA 像素指针(meow_img 对外 opaque,本函数为唯一像素读入口;供取色/直读像素)。
|
||||
* NULL 返回 NULL。 */
|
||||
const unsigned char *meow_img_pixels(const meow_img *im) { return im ? im->rgba : NULL; }
|
||||
|
||||
/* 最近邻采样缩放(cover=1 居中裁方),返回 dw*dh*4 临时 RGBA 缓冲 */
|
||||
static unsigned char *scale_buf(const meow_img *im, int dw, int dh, int cover)
|
||||
@@ -70,13 +74,16 @@ static unsigned char *scale_buf(const meow_img *im, int dw, int dh, int cover)
|
||||
s = sx < sy ? sx : sy; /* 源像素/目标像素(铺满 → 取小) */
|
||||
float oxs = ((float)im->w - (float)dw * s) * 0.5f; /* 居中裁剪起点(源像素,≥0) */
|
||||
float oys = ((float)im->h - (float)dh * s) * 0.5f;
|
||||
if (oxs < 0) oxs = 0; if (oys < 0) oys = 0;
|
||||
if (oxs < 0) oxs = 0;
|
||||
if (oys < 0) oys = 0;
|
||||
for (int dy = 0; dy < dh; dy++) {
|
||||
int syi = (int)((float)dy * s + oys);
|
||||
if (syi < 0) syi = 0; if (syi >= im->h) syi = im->h - 1;
|
||||
if (syi < 0) syi = 0;
|
||||
if (syi >= im->h) syi = im->h - 1;
|
||||
for (int dx = 0; dx < dw; dx++) {
|
||||
int sxi = (int)((float)dx * s + oxs);
|
||||
if (sxi < 0) sxi = 0; if (sxi >= im->w) sxi = im->w - 1;
|
||||
if (sxi < 0) sxi = 0;
|
||||
if (sxi >= im->w) sxi = im->w - 1;
|
||||
memcpy(out + ((size_t)dy * dw + dx) * 4,
|
||||
im->rgba + ((size_t)syi * im->w + sxi) * 4, 4);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user