[refactor] 整理注释
This commit is contained in:
+12
-13
@@ -1,13 +1,12 @@
|
||||
#include "ttf_internal.h"
|
||||
#include <string_utils.h>
|
||||
|
||||
// ---- Outline -> segments ----
|
||||
// 轮廓 → 线段转换
|
||||
//
|
||||
// TrueType contour walk: for each pair of consecutive points, emit either
|
||||
// a line or a quadratic bezier. Two consecutive off-curve points trigger
|
||||
// synthesis of an on-curve midpoint.
|
||||
// TrueType 轮廓遍历:对每对连续点,发射直线或二次贝塞尔曲线。
|
||||
// 两个连续的非曲线点会触发合成一个曲线中点。
|
||||
//
|
||||
// All coordinates remain in 26.6 fp throughout.
|
||||
// 所有坐标全程使用 26.6 定点数。
|
||||
void ttf_outline_to_segments(const ttf_outline_t* outline,
|
||||
ttf_seg_t* segs, SUINT32* num_segs)
|
||||
{
|
||||
@@ -92,7 +91,7 @@ void ttf_outline_to_segments(const ttf_outline_t* outline,
|
||||
}
|
||||
}
|
||||
|
||||
// ---- Integer sqrt (Newton) ----
|
||||
// 整数平方根(牛顿法)
|
||||
static SUINT32 isqrt_u64(SUINT64 n) {
|
||||
if (n == 0) return 0;
|
||||
SUINT32 x = (n > 0xFFFFFFFFu) ? 0xFFFFu : (SUINT32)n;
|
||||
@@ -101,19 +100,19 @@ static SUINT32 isqrt_u64(SUINT64 n) {
|
||||
return x;
|
||||
}
|
||||
|
||||
// ---- Scanline fill with subpixel supersampling ----
|
||||
// 扫描线填充 + 子像素超采样
|
||||
//
|
||||
// For each output row, run N sub-scanlines at offsets (k+0.5)/N. For each
|
||||
// sub-scanline y, collect all x-intersections, sort, fill alternating
|
||||
// x-pairs. Sum over N subsamples yields per-pixel coverage in [0, N].
|
||||
// 对每个输出行,运行 N 条子扫描线,偏移为 (k+0.5)/N。
|
||||
// 对每条子扫描线 y,收集所有 x 交点,排序后交替填充 x 对。
|
||||
// 对 N 个子采样求和得到每个像素的覆盖率 [0, N]。
|
||||
void ttf_rasterize(const ttf_seg_t* segs, SUINT32 num_segs,
|
||||
SSINT32 x0, SSINT32 y0, SUINT32 w, SUINT32 h,
|
||||
SUINT8* coverage, SUINT32 N)
|
||||
{
|
||||
// Clear coverage
|
||||
// 清空覆盖率缓冲区
|
||||
for (SUINT32 i = 0; i < w * h; i++) coverage[i] = 0;
|
||||
|
||||
// Intersection x-buf (per scanline, max possible = num_segs)
|
||||
// 交点 x 缓冲区(每扫描线,最大可能数 = num_segs)
|
||||
f26_6 xs[2048];
|
||||
if (num_segs > 2048) num_segs = 2048;
|
||||
|
||||
@@ -222,6 +221,6 @@ void ttf_rasterize(const ttf_seg_t* segs, SUINT32 num_segs,
|
||||
}
|
||||
}
|
||||
}
|
||||
// (Alpha conversion happens at the caller via N.)
|
||||
// 覆盖率转换在调用端通过 N 完成
|
||||
(void)x0; (void)y0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user