fix(回归优化): 修复浏览器回归并优化内存
build.yaml / build (push) Successful in 49s

This commit is contained in:
xiaoqidun committed 2026-10-21 18:28:57 +08:00
1 parent 974b515374
commit 67f4cf9d2c
13 files changed
+401 -44

No files matched your search

+18
View File
@@ -34,6 +34,9 @@ type canvasFontKey struct {
// canvasClipCacheKey 区分不依赖文档资源的共享裁剪缓存
type canvasClipCacheKey struct{}
// canvasClipUnionKey 区分文字和图形裁剪的共享并集缓存
type canvasClipUnionKey struct{}
// canvasPathCacheKey 区分不依赖文档资源的共享局部路径缓存
type canvasPathCacheKey struct{}
@@ -83,6 +86,21 @@ func (r *Renderer) canvasClipIntersections() *renderCache[[32]byte, *canvas.Path
return cache
}
// canvasClipUnions 复用相同输入轮廓的裁剪并集,不改变布尔运算顺序
// 返回: *renderCache[[32]byte, *canvas.Path] 只读裁剪并集缓存
func (r *Renderer) canvasClipUnions() *renderCache[[32]byte, *canvas.Path] {
key := canvasClipUnionKey{}
if state, ok := r.sharedBackendStates[key]; ok {
return state.(*renderCache[[32]byte, *canvas.Path])
}
if r.sharedBackendStates == nil {
r.sharedBackendStates = make(map[any]any)
}
cache := resourceCache[[32]byte, *canvas.Path](r.Reader.resources, 8<<20)
r.sharedBackendStates[key] = cache
return cache
}
// canvasParsedPaths 获取子渲染器共享的局部路径缓存,不保留对象变换
// 返回: *renderCache[canvasPathKey, *canvas.Path] 路径缓存
func (r *Renderer) canvasParsedPaths() *renderCache[canvasPathKey, *canvas.Path] {