@kurot/core 2.1.1 → 2.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (57) hide show
  1. package/CHANGELOG.md +41 -0
  2. package/README.md +37 -2
  3. package/dist/kurot/display/DisplayObject.d.ts +2 -1
  4. package/dist/kurot/display/DisplayObject.d.ts.map +1 -1
  5. package/dist/kurot/display/DisplayObject.js.map +1 -1
  6. package/dist/kurot/player/canvas/CanvasRenderer.d.ts +2 -0
  7. package/dist/kurot/player/canvas/CanvasRenderer.d.ts.map +1 -1
  8. package/dist/kurot/player/canvas/CanvasRenderer.js +37 -1
  9. package/dist/kurot/player/canvas/CanvasRenderer.js.map +1 -1
  10. package/dist/kurot/player/pipes/BitmapTextPipe.d.ts +20 -0
  11. package/dist/kurot/player/pipes/BitmapTextPipe.d.ts.map +1 -0
  12. package/dist/kurot/player/pipes/BitmapTextPipe.js +27 -0
  13. package/dist/kurot/player/pipes/BitmapTextPipe.js.map +1 -0
  14. package/dist/kurot/player/pipes/index.d.ts +2 -0
  15. package/dist/kurot/player/pipes/index.d.ts.map +1 -1
  16. package/dist/kurot/player/pipes/index.js +1 -0
  17. package/dist/kurot/player/pipes/index.js.map +1 -1
  18. package/dist/kurot/player/webgl/WebGLRenderer.d.ts +1 -0
  19. package/dist/kurot/player/webgl/WebGLRenderer.d.ts.map +1 -1
  20. package/dist/kurot/player/webgl/WebGLRenderer.js +8 -0
  21. package/dist/kurot/player/webgl/WebGLRenderer.js.map +1 -1
  22. package/dist/kurot/resource/Resource.d.ts.map +1 -1
  23. package/dist/kurot/resource/Resource.js +4 -0
  24. package/dist/kurot/resource/Resource.js.map +1 -1
  25. package/dist/kurot/resource/ResourceItem.d.ts +1 -0
  26. package/dist/kurot/resource/ResourceItem.d.ts.map +1 -1
  27. package/dist/kurot/resource/ResourceItem.js +1 -0
  28. package/dist/kurot/resource/ResourceItem.js.map +1 -1
  29. package/dist/kurot/resource/analyzers/FontAnalyzer.d.ts +16 -0
  30. package/dist/kurot/resource/analyzers/FontAnalyzer.d.ts.map +1 -0
  31. package/dist/kurot/resource/analyzers/FontAnalyzer.js +75 -0
  32. package/dist/kurot/resource/analyzers/FontAnalyzer.js.map +1 -0
  33. package/dist/kurot/resource/analyzers/index.d.ts +1 -0
  34. package/dist/kurot/resource/analyzers/index.d.ts.map +1 -1
  35. package/dist/kurot/resource/analyzers/index.js +1 -0
  36. package/dist/kurot/resource/analyzers/index.js.map +1 -1
  37. package/dist/kurot/resource/index.d.ts +1 -0
  38. package/dist/kurot/resource/index.d.ts.map +1 -1
  39. package/dist/kurot/resource/index.js +1 -0
  40. package/dist/kurot/resource/index.js.map +1 -1
  41. package/dist/kurot/text/BitmapFont.d.ts +15 -21
  42. package/dist/kurot/text/BitmapFont.d.ts.map +1 -1
  43. package/dist/kurot/text/BitmapFont.js +59 -66
  44. package/dist/kurot/text/BitmapFont.js.map +1 -1
  45. package/dist/kurot/text/BitmapText.d.ts +29 -19
  46. package/dist/kurot/text/BitmapText.d.ts.map +1 -1
  47. package/dist/kurot/text/BitmapText.js +93 -141
  48. package/dist/kurot/text/BitmapText.js.map +1 -1
  49. package/dist/kurot/text/index.d.ts +1 -0
  50. package/dist/kurot/text/index.d.ts.map +1 -1
  51. package/dist/kurot/text/index.js.map +1 -1
  52. package/docs/ai-context.md +22 -7
  53. package/docs/architecture.md +322 -276
  54. package/docs/bitmap-fonts.md +85 -0
  55. package/docs/resource.md +185 -156
  56. package/docs/text-layout.md +8 -6
  57. package/package.json +3 -2
@@ -1,228 +1,253 @@
1
- # @kurot/core 架构文档
1
+ # @kurot/core architecture
2
2
 
3
- > 当前版本:2.0.1。逐条变更记录见 [CHANGELOG.md](../CHANGELOG.md)。
4
- > 面向 AI 智能体的速查文档见 [ai-context.md](./ai-context.md)(目录地图、反直觉行为清单、术语表、任务→文件速查表)。本文档面向人类读者,讲设计动机与内部机制,两份文档不重复内容,互相引用。
3
+ > Package version: 2.2.0. See [CHANGELOG.md](../CHANGELOG.md) for release notes.
4
+ > The [AI context map](./ai-context.md) covers directories, non-obvious behavior,
5
+ > terminology and task-to-file references. This document explains design choices
6
+ > and internal mechanisms for contributors; the two documents complement each other.
5
7
 
6
8
  ---
7
9
 
8
- ## 一、项目概述
10
+ ## 1. Overview
9
11
 
10
- `@kurot/core` 是 Kurot 引擎的核心运行时,提供显示对象、渲染、事件、几何、文本、资源、网络与媒体能力。对外 API 沿用 Egret 的 `DisplayObject`/事件模型,渲染内核则重写为 Pixi.js 8 风格的扁平 "InstructionSet + RenderPipe" 管线。
12
+ `@kurot/core` provides Kurot's display objects, rendering, events, geometry, text,
13
+ resources, networking and media runtime. Public APIs follow Egret's
14
+ `DisplayObject` and event model, while rendering uses a flat
15
+ `InstructionSet + RenderPipe` pipeline inspired by Pixi.js 8.
11
16
 
12
- | 维度 | 说明 |
13
- | -------- | ----------------------------------------------- |
14
- | 模块系统 | ES Module(`@kurot/core` npm 包) |
15
- | 类型系统 | `strict: true`,全量类型安全,零 `any` |
16
- | 编译目标 | ES2022,仅支持现代浏览器 |
17
- | 渲染架构 | InstructionSet 指令驱动(借鉴 Pixi.js 8) |
18
- | 批处理 | 多纹理批处理(8 张/批) |
19
- | 包管理 | `@kurot/core` workspace 包,pnpm |
20
- | 资源管理 | Resource 完整资源生命周期 |
21
- | WebGL | WebGL 1 + WebGL 2 双后端,运行时自动选择 |
17
+ Version 2.2.0 uses published `@kurot/bitmap-font ^0.1.0` as the headless font-data
18
+ and layout kernel. Core manages font resources, image-page ownership and glyph
19
+ drawing in both backends. UI components belong to the UI package.
22
20
 
23
- 与 Egret 的差异、Breaking Changes 及迁移方式见根目录 [egret-migration.md](../../../docs/egret-migration.md)。
21
+ | Aspect | Description |
22
+ | ------------------ | ---------------------------------------------------------- |
23
+ | Modules | ES modules (`@kurot/core` npm package) |
24
+ | Types | Strict TypeScript (`strict: true`) |
25
+ | Target | ES2022 and modern browsers |
26
+ | Rendering | InstructionSet pipeline inspired by Pixi.js 8 |
27
+ | Batching | Multiple textures, up to 8 per batch |
28
+ | Package management | Independent pnpm package |
29
+ | Resources | Loading, caching and lifecycle management through Resource |
30
+ | WebGL | WebGL 1 and WebGL 2, selected at runtime |
31
+
32
+ See [Egret migration](../../../docs/egret-migration.md) for differences,
33
+ breaking changes and migration guidance.
24
34
 
25
35
  ---
26
36
 
27
- ## 二、模块结构
37
+ ## 2. Module structure
28
38
 
29
39
  ```
30
40
  packages/core/src/kurot/
31
- ├── display/ # 显示对象层(场景图)
32
- │ ├── DisplayObject.ts # 基类,含 renderDirty/cacheDirty/renderMode/RenderObjectType/bounds 缓存
33
- │ ├── DisplayObjectContainer.ts # 容器,含 isRenderGroup/sortableChildren/zIndex 排序
34
- │ ├── Bitmap.ts # 位图显示(含 scale9Grid 九宫格)
35
- │ ├── Sprite.ts # 精灵(容器 + Graphics)
36
- │ ├── Shape.ts # 矢量图形
37
- │ ├── Mesh.ts # 网格(vertices/indices/uvs)
38
- │ ├── Stage.ts # 舞台根节点
39
- │ ├── Graphics.ts # 矢量绘图命令
40
- │ ├── GraphicsPath.ts # 命令类型定义(PathCommandType, GraphicsCommand)
41
- │ ├── enums/ # BlendMode, BitmapFillMode, CapsStyle, GradientType, JointStyle, OrientationMode, StageScaleMode
42
- │ └── texture/ # BitmapData, Texture, SpriteSheet, RenderTexture
43
- ├── player/ # 渲染管线 + 游戏循环
44
- │ ├── Player.ts # 播放器(Stage + Renderer 绑定,含 perf 性能指标)
45
- │ ├── SystemTicker.ts # 帧循环(RAF + ENTER_FRAME,含 callLater 延迟调用队列)
46
- │ ├── RenderPipe.ts # RenderPipe 接口定义
47
- │ ├── TouchHandler.ts # 触摸/鼠标输入
48
- │ ├── ScreenAdapter.ts # 屏幕适配(7种缩放模式)
49
- │ ├── createPlayer.ts # 统一创建入口(含 Capabilities 初始化、RenderTexture 渲染器注入)
50
- │ ├── KurotOptions.ts # 配置接口
51
- │ ├── canvas/ # Canvas 2D 渲染后端(降级方案)
52
- │ │ ├── CanvasRenderer.ts # 直接遍历渲染器(支持全部 DisplayObject 类型 + 滤镜降级)
53
- │ │ ├── DisplayList.ts # cacheAsBitmap 离屏缓存
54
- │ │ └── CanvasBuffer.ts # Canvas 2D 缓冲区(含 hitTestBuffer 像素级命中测试)
55
- │ └── webgl/ # WebGL 渲染后端(主渲染器)
56
- │ ├── WebGLRenderer.ts # 两阶段渲染器(build + execute,含 RenderGroup/DisplayListCache 支持)
57
- │ ├── WebGLRenderContext.ts # WebGL 状态管理 + draw 调度(WebGL1/2 自动选择,配合 WebGLFilterSystem 管理效果)
58
- │ ├── WebGLRenderBuffer.ts # WebGL 缓冲区(含对象池,支持 offscreen/stencil/scissor)
59
- │ ├── WebGLRenderTarget.ts # FBO 管理
60
- │ ├── WebGLVertexArrayObject.ts # VAO 顶点管理(单纹理 20B + 多纹理 24B 双布局)
61
- │ ├── WebGLDrawCmdManager.ts # 绘制命令队列(12 种命令类型,含 MULTI_TEXTURE)
62
- │ ├── WebGLProgram.ts # 着色器程序缓存
63
- │ ├── WebGLUtils.ts # WebGL 工具(compileShader, createProgram, premultiplyTint, deleteWebGLTexture)
64
- │ ├── InstructionSet.ts # 指令集(renderableIndex O(1) 查找,dirtyRenderables 增量更新)
65
- │ ├── MultiTextureBatcher.ts # 多纹理批处理(8张/批,slotMap 纹理槽位分配)
66
- │ ├── pipes/ # RenderPipe 实现
67
- │ │ ├── BitmapPipe.ts # 位图渲染指令
68
- │ │ ├── GraphicsPipe.ts # 矢量图形指令(Canvas光栅化 → 纹理上传)
69
- │ │ ├── MeshPipe.ts # 网格渲染指令
70
- │ │ ├── FilterPipe.ts # 滤镜 push/pop 指令(含对象池)
71
- │ │ ├── MaskPipe.ts # 遮罩 push/pop 指令(含对象池)
72
- │ │ ├── TextPipe.ts # 文本 WebGL 渲染(offscreen canvas → 纹理上传)
73
- │ │ └── ParticlePipe.ts # 粒子系统渲染
74
- │ └── shaders/ # GLSL 着色器
75
- │ ├── ShaderLib.ts # GLSL ES 1.00 着色器库(WebGL1)
76
- │ └── ShaderLib2.ts # GLSL ES 3.00 着色器库(WebGL2)
77
- ├── events/ # 事件系统(11 个事件类 + EventPhase + IEventDispatcher 接口)
78
- ├── geom/ # 几何工具(Matrix, Point, Rectangle)
79
- ├── filters/ # 滤镜(Blur, Glow, DropShadow, ColorMatrix, CustomFilter, MultiPassFilter, BloomFilter)
80
- ├── text/ # 文本渲染
81
- │ ├── TextField.ts # 核心文本字段(含 textFlow 富文本、输入模式、密码模式)
82
- │ ├── BitmapText.ts # 位图文本
83
- │ ├── BitmapFont.ts # 位图字体
84
- │ ├── StageText.ts # INPUT 模式 DOM 输入框
85
- │ ├── HtmlTextParser.ts # HTML 文本解析
86
- │ ├── InputController.ts # 输入控制器(选择、光标、键盘处理)
87
- │ ├── TextMeasurer.ts # 文本测量(measureText, getFontString)
88
- │ ├── LineBreaks.ts # Unicode 17.0 UAX #14 断行边界与字典分词
89
- │ ├── TextLineLayout.ts # 整段富文本断行、宽度拟合与 UTF-16 源偏移
90
- │ ├── WordWrap.ts # 独立分词与字素工具(tokenize, splitGraphemes)
91
- │ ├── enums/ # HorizontalAlign, VerticalAlign, TextFieldType, TextFieldInputType
92
- │ └── types/ # ITextElement, IWTextElement, ILineElement, IHitTextElement 等类型定义
93
- ├── resource/ # 资源管理
94
- │ ├── Resource.ts # 资源核心(单例模式,async/await API,加载/缓存/生命周期)
95
- │ ├── ResourceConfig.ts # 资源配置
96
- │ ├── ResourceEvent.ts # 资源事件
97
- │ ├── ResourceItem.ts # 资源项
98
- │ ├── ResourceLoader.ts # 资源加载器
99
- │ └── analyzers/ # 资源分析器(AnalyzerBase, ImageAnalyzer, JsonAnalyzer, SheetAnalyzer, SoundAnalyzer, TextAnalyzer)
100
- ├── system/ # 系统能力
101
- │ └── Capabilities.ts # 运行时 WebGL 扩展/平台能力检测(UA + Client Hints)
102
- ├── net/ # 网络加载(HttpRequest, ImageLoader, HttpMethod, HttpResponseType)
103
- ├── media/ # 媒体(Sound, SoundChannel, Video)
104
- ├── utils/ # 工具类(ByteArray, Timer, Logger, FontManager, DebugLog, Base64Util, NumberUtils, toColorString)
105
- │ # 注:不提供 HashObject,对象身份比较用 === 或 WeakMap 键控查找
106
- ├── localStorage/ # 本地存储
107
- └── external/ # 外部接口(ExternalInterface)
41
+ ├── display/ # scene graph
42
+ │ ├── DisplayObject.ts # base class, dirty flags, render mode/type and cached bounds
43
+ │ ├── DisplayObjectContainer.ts # containers, render groups and zIndex sorting
44
+ │ ├── Bitmap.ts # bitmap display with scale9Grid
45
+ │ ├── Sprite.ts # container with Graphics
46
+ │ ├── Shape.ts # vector shapes
47
+ │ ├── Mesh.ts # vertices, indices and UVs
48
+ │ ├── Stage.ts # scene root
49
+ │ ├── Graphics.ts # vector drawing commands
50
+ │ ├── GraphicsPath.ts # PathCommandType and GraphicsCommand
51
+ │ ├── enums/ # BlendMode, BitmapFillMode, CapsStyle, GradientType, JointStyle, OrientationMode, StageScaleMode
52
+ │ └── texture/ # BitmapData, Texture, SpriteSheet, RenderTexture
53
+ ├── player/ # rendering pipeline and game loop
54
+ │ ├── Player.ts # Stage/renderer integration and performance metrics
55
+ │ ├── SystemTicker.ts # RAF loop, ENTER_FRAME and callLater queue
56
+ │ ├── RenderPipe.ts # RenderPipe interface
57
+ │ ├── InstructionSet.ts # instruction list, renderableIndex and incremental dirty updates
58
+ │ ├── TouchHandler.ts # touch and mouse input
59
+ │ ├── ScreenAdapter.ts # screen adaptation with 7 scale modes
60
+ │ ├── createPlayer.ts # initialization and RenderTexture renderer setup
61
+ │ ├── KurotOptions.ts # player options
62
+ │ ├── pipes/ # RenderPipe implementations
63
+ │ │ ├── BitmapPipe.ts # bitmap instructions
64
+ │ │ ├── BitmapTextPipe.ts # native bitmap-font glyph instructions
65
+ │ │ ├── GraphicsPipe.ts # Canvas rasterization and texture upload
66
+ │ │ ├── MeshPipe.ts # mesh instructions
67
+ │ │ ├── FilterPipe.ts # pooled filter push/pop instructions
68
+ │ │ ├── MaskPipe.ts # pooled mask push/pop instructions
69
+ │ │ ├── TextPipe.ts # offscreen text rasterization and texture upload
70
+ │ │ └── ParticlePipe.ts # particle rendering
71
+ │ ├── canvas/ # Canvas 2D backend and offscreen capture
72
+ │ │ ├── CanvasRenderer.ts # direct traversal with built-in filter approximations
73
+ │ │ ├── DisplayList.ts # offscreen cache for cacheAsBitmap
74
+ │ │ └── CanvasBuffer.ts # Canvas buffers and pixel hit testing
75
+ │ └── webgl/ # primary WebGL backend
76
+ │ ├── WebGLRenderer.ts # build/execute phases and render groups
77
+ │ ├── WebGLRenderContext.ts # WebGL state, draw scheduling and filter execution
78
+ │ ├── WebGLRenderBuffer.ts # pooled offscreen, stencil and scissor buffers
79
+ │ ├── WebGLRenderTarget.ts # framebuffer management
80
+ │ ├── WebGLVertexArrayObject.ts # single-texture 20B and multi-texture 24B vertex layouts
81
+ │ ├── WebGLDrawCmdManager.ts # 12 draw command types, including MULTI_TEXTURE
82
+ │ ├── WebGLProgram.ts # shader program cache
83
+ │ ├── WebGLUtils.ts # shader compilation, program creation, tint and texture helpers
84
+ │ ├── MultiTextureBatcher.ts # 8-texture batches and slotMap assignments
85
+ │ └── shaders/ # GLSL sources
86
+ │ ├── ShaderLib.ts # GLSL ES 1.00 for WebGL 1
87
+ │ └── ShaderLib2.ts # GLSL ES 3.00 for WebGL 2
88
+ ├── events/ # event classes, EventPhase and IEventDispatcher
89
+ ├── geom/ # Matrix, Point, Rectangle
90
+ ├── filters/ # Blur, Glow, DropShadow, ColorMatrix, CustomFilter, MultiPassFilter, BloomFilter
91
+ ├── text/ # text data and layout
92
+ │ ├── TextField.ts # rich text, input mode and password display
93
+ │ ├── BitmapText.ts # bitmap text
94
+ │ ├── BitmapFont.ts # bitmap font and texture ownership
95
+ │ ├── StageText.ts # DOM input for INPUT mode
96
+ │ ├── HtmlTextParser.ts # HTML text parsing
97
+ │ ├── InputController.ts # selection, caret and keyboard input
98
+ │ ├── TextMeasurer.ts # measureText and getFontString
99
+ │ ├── LineBreaks.ts # Unicode 17.0 UAX #14 boundaries and dictionary segmentation
100
+ │ ├── TextLineLayout.ts # rich-text wrapping, width fitting and UTF-16 source offsets
101
+ │ ├── WordWrap.ts # independent token and grapheme utilities
102
+ │ ├── enums/ # HorizontalAlign, VerticalAlign, TextFieldType, TextFieldInputType
103
+ │ └── types/ # ITextElement, IWTextElement, ILineElement, IHitTextElement
104
+ ├── resource/ # resource management
105
+ │ ├── Resource.ts # resource manager, shared instance and async/await API
106
+ │ ├── ResourceConfig.ts # resource configuration
107
+ │ ├── ResourceEvent.ts # resource events
108
+ │ ├── ResourceItem.ts # resource items
109
+ │ ├── ResourceLoader.ts # resource loading queue
110
+ │ └── analyzers/ # AnalyzerBase, Image, Json, Sheet, Sound, Text and Font analyzers
111
+ ├── system/ # environment capabilities
112
+ │ └── Capabilities.ts # runtime capabilities using UA and Client Hints
113
+ ├── net/ # HttpRequest, ImageLoader, HttpMethod, HttpResponseType
114
+ ├── media/ # Sound, SoundChannel, Video
115
+ ├── utils/ # ByteArray, Timer, Logger, FontManager, DebugLog, Base64Util, NumberUtils, toColorString
116
+ │ # object identity uses === or WeakMap; no HashObject
117
+ ├── localStorage/ # local storage functions
118
+ └── external/ # ExternalInterface
108
119
  ```
109
120
 
110
121
  ---
111
122
 
112
- ## 三、渲染管线架构
123
+ ## 3. Rendering pipeline
113
124
 
114
- ### 3.1 两阶段渲染(借鉴 Pixi.js 8)
125
+ ### 3.1 Build and execute phases
115
126
 
116
127
  ```
117
- Phase A — Build(仅 structureDirty 时):
118
- 遍历 DisplayObject 树 → 生成 Instruction(含 transform 快照)→ InstructionSet
128
+ Phase A — Build (structureDirty):
129
+ Traverse the display tree → create Instructions with transform snapshots → InstructionSet
119
130
 
120
- Phase A' — Update(仅 renderDirty 时):
121
- 遍历 dirtyRenderables → 刷新 transform 快照(O(1) lookup via renderableIndex Map)
131
+ Phase A' — Update (renderDirty):
132
+ Visit dirtyRenderables → refresh transform snapshots using renderableIndex lookups
122
133
 
123
- Phase B — Execute(每帧):
124
- 按指令顺序分发到 Pipe → 无场景图遍历
134
+ Phase B — Execute (every frame):
135
+ Dispatch instructions to pipes without traversing the scene graph
125
136
  ```
126
137
 
127
- ### 3.2 RenderPipe 体系
138
+ ### 3.2 RenderPipe
128
139
 
129
140
  ```
130
141
  RenderPipe<T extends DisplayObject>
131
- ├── addToInstructionSet(renderable, set) — 结构变化时调用
132
- ├── updateRenderable(renderable) — 数据变化时调用
133
- └── destroyRenderable(renderable) — 对象销毁时调用(可选,见下方 GPU 纹理回收说明)
134
-
135
- 实现:
136
- ├── BitmapPipe → BitmapInstruction → drawImage()(含 scale9Grid 九宫格)
137
- ├── GraphicsPipe → GraphicsInstruction → Canvas光栅化 → 纹理上传 → drawTexture()
138
- ├── MeshPipe → MeshInstruction → drawMesh()
139
- ├── TextPipe → TextInstruction → offscreen canvas → 纹理上传 → drawImage()
140
- ├── ParticlePipe → ParticleInstruction → 粒子批处理渲染
141
- ├── FilterPipe → FilterPush/Pop → 离屏FBO → 着色器滤镜
142
- └── MaskPipe → MaskPush/Pop → stencil/scissor/离屏合成
142
+ ├── addToInstructionSet(renderable, set) — build instructions after structure changes
143
+ ├── updateRenderable(renderable) — update visual data
144
+ └── destroyRenderable(renderable) — optional immediate cleanup; see texture GC below
145
+
146
+ Implementations:
147
+ ├── BitmapPipe → BitmapInstruction → drawImage(), including scale9Grid
148
+ ├── BitmapTextPipe → BitmapTextInstruction → shared layout → batched glyph drawImage()
149
+ ├── GraphicsPipe → GraphicsInstruction → Canvas rasterization → texture upload → drawTexture()
150
+ ├── MeshPipe → MeshInstruction → drawMesh()
151
+ ├── TextPipe → TextInstruction → offscreen Canvas → texture upload → drawImage()
152
+ ├── ParticlePipe → ParticleInstruction → particle batches
153
+ ├── FilterPipe → FilterPush/Pop → offscreen FBO → shader effects
154
+ └── MaskPipe → MaskPush/Pop → stencil, scissor or offscreen compositing
143
155
  ```
144
156
 
145
- **GPU 纹理回收**:`destroyRenderable()` 目前不会被 `WebGLRenderer` 自动调用(`DisplayObject` 没有"永久销毁"信号——`$onRemoveFromStage` 会在临时移出舞台又重新加入时反复触发,接上调用链会让虚拟列表等场景反复重新栅格化/上传纹理)。因此 `GraphicsPipe`、`TextPipe` 各自缓存纹理的清理不依赖调用方显式调用,而是用 `FinalizationRegistry` 在对应的 `Graphics` / `TextField` 被 JS 引擎 GC 时自动 `gl.deleteTexture()`。`destroyRenderable()` 仍保留为可选的立即释放路径(调用时会 `unregister` 对应的 GC 回调,避免重复删除),供未来需要显式销毁时机的场景使用。`BitmapPipe` / `MeshPipe` 的 `destroyRenderable` 是 no-op,因为它们绘制用的纹理归属于 `BitmapData` 的生命周期,不由 Pipe 自身管理。
157
+ **GPU texture cleanup.** `WebGLRenderer` does not automatically call
158
+ `destroyRenderable()`. Display objects have no permanent-destruction signal:
159
+ `$onRemoveFromStage` also fires when an object is temporarily removed and later
160
+ reused. Releasing textures at that point would force repeated rasterization and
161
+ uploads, for example when virtual lists reuse renderers.
162
+
163
+ GraphicsPipe and TextPipe use `FinalizationRegistry` to call `gl.deleteTexture()`
164
+ when their Graphics/TextField owners are garbage-collected. Explicit
165
+ `destroyRenderable()` remains an optional immediate-release path; it unregisters
166
+ the GC callback to avoid duplicate deletion. BitmapPipe and MeshPipe have no
167
+ pipe-owned texture cleanup because their textures belong to BitmapData.
146
168
 
147
- ### 3.3 RenderGroup 分层
169
+ ### 3.3 Render groups
148
170
 
149
171
  ```typescript
150
172
  backgroundLayer.isRenderGroup = true;
151
173
  ```
152
174
 
153
- - 每个 RenderGroup 拥有独立的 InstructionSet
154
- - 父 set 只包含一条 `renderGroup` 指令,指向子树 set
155
- - 子树结构变化只触发自身 set 重建,不影响父 set
156
- - 静态子树的 JS 遍历开销降为零
157
- - 实现通过 `WeakMap<DisplayObjectContainer, InstructionSet>` 管理 group sets
158
- - 使用 `WeakRef` 跟踪 group 生命周期,便于 GC
175
+ - Each render group owns an InstructionSet.
176
+ - Its parent set contains one `renderGroup` instruction referencing that subtree.
177
+ - Structure changes inside the group rebuild its own set, not its parent's set.
178
+ - Static subtrees do not need to be traversed on every WebGL frame.
179
+ - A `WeakMap<DisplayObjectContainer, InstructionSet>` stores group sets.
180
+ - WeakRef tracks group lifetimes without preventing garbage collection.
159
181
 
160
- ### 3.4 多纹理批处理
182
+ ### 3.4 Multi-texture batching
161
183
 
162
- - `MultiTextureBatcher` 管理最多 8 个纹理槽位(WebGL1 最小保证纹理单元数)
163
- - 顶点格式扩展:增加 `aTextureId` float 属性(stride 从 20B 增至 24B)
164
- - Fragment shader 使用 if/else 链采样(WebGL1 兼容)
165
- - mesh、filter、blend 变化自动 flush 回退到单纹理路径
166
- - `WebGLVertexArrayObject` 维护双缓冲区(单纹理 + 多纹理),按需切换 GPU buffer 大小
184
+ - MultiTextureBatcher manages up to 8 texture slots, the WebGL 1 minimum guarantee.
185
+ - The multi-texture vertex layout adds `aTextureId`, increasing the stride from
186
+ 20 to 24 bytes.
187
+ - The fragment shader selects textures with an if/else chain for WebGL 1 support.
188
+ - Mesh, filter and blend changes flush the current batch when needed.
189
+ - WebGLVertexArrayObject maintains single-texture and multi-texture buffers and
190
+ grows GPU buffers as needed.
167
191
 
168
- ### 3.5 脏标记系统
192
+ ### 3.5 Dirty flags
169
193
 
170
194
  ```
171
- DisplayObject 脏标记:
172
- ├── cacheDirty — cacheAsBitmap 缓存失效,向上传播
173
- ├── renderDirty — 视觉数据变化(位置/纹理/alpha/tint),向上传播
174
- └── renderMode — 渲染模式(NONE/FILTER/CLIP/SCROLLRECT)
175
-
176
- 通知机制(单 Player 静态钩子,由 Player 构造函数赋值):
177
- ├── $onStructureChange?: () => void — 结构变化回调
178
- ├── $onRenderableDirty?: (obj: DisplayObject) => void — 渲染脏回调
179
- ├── DisplayObjectContainer.$onContainerStructureChange?: (owner) => void — 容器结构变化回调
195
+ DisplayObject flags:
196
+ ├── cacheDirty — invalidates cacheAsBitmap and propagates upward
197
+ ├── renderDirty — visual changes (position, texture, alpha, tint), propagated upward
198
+ └── renderMode — NONE, FILTER, CLIP or SCROLLRECT
199
+
200
+ Notifications (single-Player static hooks installed by Player):
201
+ ├── $onStructureChange?: () => void — structure changes
202
+ ├── $onRenderableDirty?: (obj: DisplayObject) => void — visual changes
203
+ ├── DisplayObjectContainer.$onContainerStructureChange?: (owner) => void
180
204
  ├── $markDirty()
181
- │ ├── 更新 worldAlpha / worldTint 缓存(O(1) 读取)
182
- │ ├── 调用 $onRenderableDirty?.(this) → WebGLRenderer.markRenderableDirty()
183
- │ └── 向上传播 cacheDirty + renderDirty
205
+ │ ├── refresh worldAlpha/worldTint caches for constant-time reads
206
+ │ ├── $onRenderableDirty?.(this) → WebGLRenderer.markRenderableDirty()
207
+ │ └── propagate cacheDirty and renderDirty upward
184
208
  ├── $updateRenderMode()
185
- │ └── 调用 $onStructureChange?.() → WebGLRenderer.markStructureDirty()
209
+ │ └── $onStructureChange?.() → WebGLRenderer.markStructureDirty()
186
210
  └── DisplayObjectContainer.markDirtyInternal()
187
- └── 调用 $onContainerStructureChange?.(this) → markStructureDirty(owner)
211
+ └── $onContainerStructureChange?.(this) → markStructureDirty(owner)
188
212
  ```
189
213
 
190
- 引擎设计上始终是单 Player:`Player` 的构造函数直接把上述三个静态字段赋值
191
- 为具体的闭包函数(见 `player/Player.ts`),并在 `destroy()` 里清空它们。
214
+ The engine supports one Player per page. Its constructor assigns these static
215
+ hooks to instance closures, and `destroy()` clears them. See `player/Player.ts`.
192
216
 
193
- ### 3.6 RenderObjectType 快速路由
217
+ ### 3.6 RenderObjectType dispatch
194
218
 
195
- 为避免热路径中的 `instanceof` 检查,DisplayObject 使用 `renderObjectType` 枚举:
219
+ DisplayObject uses the `renderObjectType` enum to avoid `instanceof` checks on
220
+ hot rendering paths:
196
221
 
197
- | 枚举值 | 值 | 对应类型 | 路由 Pipe |
198
- | ---------- | --- | --------- | ------------ |
199
- | `NONE` | 0 | 无渲染 | — |
200
- | `BITMAP` | 1 | Bitmap | BitmapPipe |
201
- | `MESH` | 2 | Mesh | MeshPipe |
202
- | `SHAPE` | 3 | Shape | GraphicsPipe |
203
- | `SPRITE` | 4 | Sprite | GraphicsPipe |
204
- | `TEXT` | 5 | TextField | TextPipe |
205
- | `PARTICLE` | 6 | Particle | ParticlePipe |
222
+ | Enum | Value | Display type | Pipe |
223
+ | ------------- | ----- | ------------ | -------------- |
224
+ | `NONE` | 0 | No rendering | — |
225
+ | `BITMAP` | 1 | Bitmap | BitmapPipe |
226
+ | `MESH` | 2 | Mesh | MeshPipe |
227
+ | `SHAPE` | 3 | Shape | GraphicsPipe |
228
+ | `SPRITE` | 4 | Sprite | GraphicsPipe |
229
+ | `TEXT` | 5 | TextField | TextPipe |
230
+ | `PARTICLE` | 6 | Particle | ParticlePipe |
231
+ | `BITMAP_TEXT` | 7 | BitmapText | BitmapTextPipe |
206
232
 
207
233
  ---
208
234
 
209
- ## 四、WebGL 渲染后端
235
+ ## 4. WebGL backend
210
236
 
211
- ### 4.1 WebGL 版本选择
237
+ ### 4.1 WebGL selection
212
238
 
213
- `WebGLRenderContext` 在初始化时自动检测并选择最佳后端:
239
+ WebGLRenderContext selects a backend during initialization:
214
240
 
215
- - **WebGL 2 优先**:使用 `canvas.getContext('webgl2')`,加载 `ShaderLib2`(GLSL ES 3.00)
216
- - **WebGL 1 降级**:回退到 `canvas.getContext('webgl')`,加载 `ShaderLib`(GLSL ES 1.00)。
217
- 不使用 `experimental-webgl` 前缀——该别名只有 IE11/早期 Safari/旧版
218
- Android Chrome 才需要,现代浏览器的标准 `'webgl'` 已经足够。
219
- - **无独立探测 canvas**:`Player` 直接在应用方传入的 canvas 上依次尝试
220
- `webgl2` → `webgl`,两者都失败才降级到 Canvas 2D,不额外创建临时 canvas
221
- 探测能力。`checkWebGLSupport()` 函数仍导出,供需要独立探测的调用方使用,
222
- 但 `Player` 自身不调用它。
223
- - 着色器库通过实例属性动态绑定:`ctx.shaders`、`ctx.blurTierFn`、`ctx.makeBlurH`、`ctx.makeBlurV`
241
+ - **WebGL 2 first:** `canvas.getContext('webgl2')` uses ShaderLib2 (GLSL ES 3.00).
242
+ - **WebGL 1 fallback:** `canvas.getContext('webgl')` uses ShaderLib (GLSL ES 1.00).
243
+ No `experimental-webgl` alias is used; the target browsers support `webgl`.
244
+ - **No separate probe canvas:** Player tries WebGL 2 and WebGL 1 directly on the
245
+ application's canvas, then falls back to Canvas 2D if both fail.
246
+ `checkWebGLSupport()` remains available to callers but is not used by Player.
247
+ - Shader helpers are selected through context properties: `ctx.shaders`,
248
+ `ctx.blurTierFn`, `ctx.makeBlurH` and `ctx.makeBlurV`.
224
249
 
225
- ### 4.2 渲染流程
250
+ ### 4.2 Rendering flow
226
251
 
227
252
  ```
228
253
  Player.render()
@@ -231,77 +256,97 @@ Player.render()
231
256
  → Phase B: _executeInstructions()
232
257
  → Pipe.execute() → WebGLRenderContext.drawImage/drawMesh/drawTexture()
233
258
  → WebGLRenderContext.flush() → _flush()
234
- → 上传顶点(bufferSubData)→ 遍历 DrawCmdManager → 分发 draw batch
259
+ → upload vertices with bufferSubData → visit DrawCmdManager → dispatch draw batches
235
260
  ```
236
261
 
237
- ### 4.3 着色器体系
238
-
239
- | 着色器 | 用途 | 来源 |
240
- | ---------------------------------------- | ---------------------------------- | --------- |
241
- | default_vert + texture_frag | 标准纹理绘制 | ShaderLib |
242
- | multi_vert + multi_frag | 多纹理批处理(8单元) | ShaderLib |
243
- | default_vert + colorTransform_frag | ColorMatrixFilter | ShaderLib |
244
- | default_vert + glow_frag | Glow/DropShadow | ShaderLib |
245
- | fullscreen_vert + makeBlurH/ VFrag | 水平/垂直模糊(ping-pong 双 pass) | ShaderLib |
246
- | default_vert + primitive_frag | 纯色矩形(stencil mask) | ShaderLib |
247
- | fullscreen_vert | 全屏 quad blit(滤镜 pass) | ShaderLib |
248
-
249
- WebGL2(ShaderLib2)提供等价的 GLSL ES 3.00 版本着色器,使用 `in`/`out` 语法替代 `attribute`/`varying`,
250
- `texture()` 替代 `texture2D()`,blur 着色器按 4/8/16/32 档生成固定上限循环,仍使用三角权重核。
251
-
252
- ### 4.4 滤镜渲染
253
-
254
- 滤镜通过 FilterPipe 的 push/pop 指令对实现:
255
-
256
- - **push 阶段**:分配离屏 FBO(含 filter padding 扩展),将后续 draw 重定向到离屏 buffer
257
- - **pop 阶段**:调用 `compositeFilterResult()` 将离屏结果合成回父 buffer
258
-
259
- 合成流程(`compositeFilterResult`):
260
-
261
- 1. `flush()` 确保离屏输入完整。
262
- 2. `WebGLFilterSystem` 按数组顺序执行;中间 pass 关闭 blend/stencil/scissor,使用独立输出。
263
- 3. 显式恢复父 FBO、viewport 与裁剪状态。
264
- 4. 使用 `drawFramebufferTexture()` 合成最终结果,不重复应用已经写入子树的 alpha/tint。
265
- 5. 立即 flush 后归还中间纹理;失败时清理 pass 资源与待执行命令,下一帧可以恢复。
266
-
267
- - **ColorMatrixFilter**:无 mask 的叶子、单滤镜、继承分辨率时保留 inline 快速路径;组与组合走离屏。
268
- - **BlurFilter**:横纵分离,quality 控制 pass 对数;大半径先降采样,使 shader 半径不超过 32 物理像素。
269
- - **Glow / DropShadow**:保留原有 `glow_frag`;knockout 绑定与“是否保留原图”的 shader 语义对应。
270
- - **CustomFilter**:显式 GLSL 100/300 源码、按链接类型校验 numeric uniforms、独立采样的辅助 BitmapData 上传。
271
- - **MultiPassFilter / BloomFilter**:有序无环 pass 图,可读取原图或较早输出,支持各 pass 缩放。
272
-
273
- `WebGLFilterTargetPool` 缓存中间 GPU 目标,空闲上限 16 个 / 64 MiB;子树捕获缓冲与辅助图片不计入这个限制。
274
- `WebGLFilterTextures` 管理辅助图像上传和恢复。着色器编译缓存按 GL context 与实际源码隔离。
275
-
276
- Filter padding 按链累加,并包含子级效果的渲染范围,不修改布局 bounds。
277
- 离屏 pass 统一使用 framebuffer UV(左下为 0,0),每一步保持图像方向。
278
- DropShadow 传入正常角度弧度;辅助 DOM 图片的自动 UV 矩阵负责纵向转换。
279
-
280
- 具体 API、示例、Canvas 与缓存限制见 [GPU filters](filters.md)。
281
-
282
- ### 4.5 遮罩渲染
283
-
284
- - scrollRect/maskRect 无旋转且没有外层 scissor:scissor 裁剪(GPU 硬件加速)
285
- - scrollRect/maskRect 有旋转或嵌套在外层 scissor 内:stencil 裁剪;WebGL 主画布与能力探测共用 2D 上下文配置(不申请 depth,申请 stencil)
286
- - DisplayObject mask:离屏 buffer + destination-in 合成
262
+ ### 4.3 Shaders
263
+
264
+ | Shader | Purpose | Source |
265
+ | ---------------------------------- | --------------------------------------- | --------- |
266
+ | default_vert + texture_frag | Standard texture drawing | ShaderLib |
267
+ | multi_vert + multi_frag | Multi-texture batches, up to 8 textures | ShaderLib |
268
+ | default_vert + colorTransform_frag | ColorMatrixFilter | ShaderLib |
269
+ | default_vert + glow_frag | Glow/DropShadow | ShaderLib |
270
+ | fullscreen_vert + makeBlurH/VFrag | Horizontal/vertical blur in two passes | ShaderLib |
271
+ | default_vert + primitive_frag | Solid rectangles for stencil masks | ShaderLib |
272
+ | fullscreen_vert | Fullscreen quad blits for filter passes | ShaderLib |
273
+
274
+ ShaderLib2 supplies equivalent GLSL ES 3.00 shaders for WebGL 2, using `in`/`out`
275
+ instead of `attribute`/`varying`, and `texture()` instead of `texture2D()`.
276
+ Blur shaders use fixed loop limits of 4, 8, 16 or 32 samples with triangular weights.
277
+
278
+ ### 4.4 Filters
279
+
280
+ FilterPipe emits paired push/pop instructions:
281
+
282
+ - **Push:** allocate an offscreen FBO with filter padding and redirect drawing.
283
+ - **Pop:** call `compositeFilterResult()` to composite the result into the parent.
284
+
285
+ The compositing sequence is:
286
+
287
+ 1. Flush pending drawing to complete the captured input.
288
+ 2. WebGLFilterSystem executes filters in array order. Intermediate passes disable
289
+ blending, stencil and scissor and write to separate targets.
290
+ 3. Restore the parent FBO, viewport and clip state explicitly.
291
+ 4. Composite with `drawFramebufferTexture()` without applying inherited alpha/tint
292
+ a second time.
293
+ 5. Flush and return intermediate textures to the pool. Failures release resources
294
+ and queued commands so a later frame can recover.
295
+
296
+ - **ColorMatrixFilter:** an unmasked leaf with one filter and inherited resolution
297
+ can use the inline path; groups and combinations use offscreen targets.
298
+ - **BlurFilter:** horizontal/vertical separation, with quality controlling pass
299
+ pairs. Large radii downsample to stay within the 32-physical-pixel shader tier.
300
+ - **Glow/DropShadow:** retain glow_frag; knockout controls whether the source image
301
+ remains in the output.
302
+ - **CustomFilter:** explicit GLSL 100/300 sources, reflected numeric uniforms and
303
+ auxiliary BitmapData uploads with independent sampling.
304
+ - **MultiPassFilter/BloomFilter:** ordered acyclic pass graphs, with original or
305
+ earlier inputs and per-pass scaling.
306
+
307
+ WebGLFilterTargetPool caches up to 16 idle targets or 64 MiB. Subtree captures and
308
+ auxiliary images are outside this limit. WebGLFilterTextures manages auxiliary
309
+ image uploads and restoration. Shader programs are cached by GL context and source.
310
+
311
+ Filter-chain padding accumulates and includes child effects without changing
312
+ layout bounds. Offscreen passes use framebuffer UVs, with (0,0) at the lower left,
313
+ and preserve orientation. DropShadow angles reach shaders in radians. Auxiliary
314
+ DOM image bindings use UV transforms to account for vertical orientation.
315
+
316
+ See [GPU filters](filters.md) for APIs, examples, Canvas support and cache limits.
317
+
318
+ ### 4.5 Masks
319
+
320
+ - Axis-aligned scrollRect/maskRect without an outer scissor uses scissor clipping.
321
+ - Rotated rectangles or rectangles inside an outer scissor use stencil clipping.
322
+ Both the WebGL canvas and capability checks request stencil without depth.
323
+ - DisplayObject masks use offscreen compositing with destination-in.
287
324
 
288
325
  ---
289
326
 
290
- ## 五、Canvas 2D 渲染后端
327
+ ## 5. Canvas 2D backend
328
+
329
+ CanvasRenderer traverses the scene graph directly and supplies the fallback when
330
+ WebGL is unavailable. It also rasterizes offscreen caches and RenderTexture captures.
291
331
 
292
- Canvas 2D 渲染器保持直接遍历模式,作为 WebGL 不可用时的降级方案。
332
+ - Offscreen Graphics caching through `canvasCacheDirty`.
333
+ - CSS blur/drop-shadow approximations for Blur, DropShadow and Glow.
334
+ - CPU pixel processing for ColorMatrixFilter.
335
+ - DisplayList support for cacheAsBitmap.
336
+ - Pixel hit testing through a 3×3 offscreen buffer.
337
+ - Bitmap, Shape, Sprite, Mesh, TextField and BitmapText rendering.
338
+ - BitmapText draws atlas regions from shared layout, including trim offsets, tint
339
+ and ordinary clipping. See [bitmap fonts](bitmap-fonts.md) for ownership.
340
+ - TextField measurement, line layout and fillText/strokeText drawing. See
341
+ [text layout](./text-layout.md) for wrapping and source-offset contracts.
293
342
 
294
- - Graphics 离屏 Canvas 缓存(`canvasCacheDirty` 脏标记)
295
- - CSS filter 快速路径(Blur → `blur()`,DropShadow → `drop-shadow()`)
296
- - ColorMatrixFilter CPU 像素操作降级
297
- - cacheAsBitmap 支持(通过 DisplayList)
298
- - 像素级命中测试(3x3 离屏 buffer,hitTestBuffer 函数)
299
- - 支持所有 DisplayObject 类型:Bitmap, Shape, Sprite, Mesh, TextField(含样式、对齐、自动换行)
300
- - TextField 渲染:测量 → 分行 → Canvas 2D fillText/strokeText 绘制;断行规则与输入偏移契约见 [text-layout.md](./text-layout.md)
343
+ CustomFilter, MultiPassFilter and BloomFilter are GPU effects and are skipped.
344
+ Built-in Canvas approximations are not pixel-equivalent to WebGL. The same
345
+ boundary applies to cacheAsTexture and RenderTexture capture.
301
346
 
302
347
  ---
303
348
 
304
- ## 六、快速启动 API
349
+ ## 6. Application startup
305
350
 
306
351
  ### `createPlayer(options)`
307
352
 
@@ -319,55 +364,56 @@ const app = createPlayer({
319
364
  app.start(root);
320
365
  ```
321
366
 
322
- `createPlayer` 自动完成:
367
+ `createPlayer` initializes:
323
368
 
324
- 1. 调用 `Capabilities._init()` 检测运行环境(OS、isMobile、language)
325
- 2. 首次调用时注入 `RenderTexture.renderer`(Canvas 2D 离屏渲染器)
326
- 3. 创建 Stage、Player(WebGL 优先,Canvas 2D 降级)、TouchHandler、ScreenAdapter
327
- 4. 调用 `setupLifecycle(stage)` 绑定 ENTER_FRAME / RENDER 广播
369
+ 1. Capabilities._init() for OS, isMobile and language detection.
370
+ 2. RenderTexture.renderer on first use, providing offscreen Canvas 2D rendering.
371
+ 3. Stage, Player, TouchHandler and ScreenAdapter, preferring WebGL with Canvas fallback.
372
+ 4. setupLifecycle(stage) for ENTER_FRAME and RENDER broadcasts.
328
373
 
329
374
  ### KurotOptions
330
375
 
331
- | 属性 | 类型 | 默认值 | 说明 |
332
- | --------------- | ------------------- | --------------- | ------------ |
333
- | `canvas` | `HTMLCanvasElement` | (必填) | 渲染画布 |
334
- | `frameRate` | `number` | `60` | 目标帧率 |
335
- | `scaleMode` | `StageScaleMode` | `'showAll'` | 屏幕适配模式 |
336
- | `contentWidth` | `number` | `canvas.width` | 逻辑内容宽度 |
337
- | `contentHeight` | `number` | `canvas.height` | 逻辑内容高度 |
338
- | `resolution` | `number` | `min(DPR, 2)` | 后备缓冲像素密度 |
339
- | `orientation` | `OrientationMode` | `'auto'` | 屏幕方向 |
340
- | `maxTouches` | `number` | `99` | 最大触点数 |
341
- | `background` | `string` | — | CSS 背景色 |
342
-
343
- ### KurotApp 返回值
344
-
345
- | 属性 | 类型 | 说明 |
346
- | --------------- | --------------- | ------------- |
347
- | `player` | `Player` | 渲染播放器 |
348
- | `stage` | `Stage` | 舞台根节点 |
349
- | `touchHandler` | `TouchHandler` | 触摸/鼠标处理 |
350
- | `screenAdapter` | `ScreenAdapter` | 屏幕适配器 |
351
- | `start(root?)` | `() => void` | 启动游戏循环 |
352
- | `stop()` | `() => void` | 停止游戏循环 |
376
+ | Property | Type | Default | Description |
377
+ | --------------- | ------------------- | ------------------------- | --------------------------- |
378
+ | `canvas` | `HTMLCanvasElement` | Required | Rendering canvas |
379
+ | `frameRate` | `number` | `60` | Target frame rate |
380
+ | `scaleMode` | `StageScaleMode` | `'showAll'` | Screen scale mode |
381
+ | `contentWidth` | `number` | `canvas.width` or `640` | Logical content width |
382
+ | `contentHeight` | `number` | `canvas.height` or `1136` | Logical content height |
383
+ | `resolution` | `number` | `min(DPR, 2)` | Backing-store pixel density |
384
+ | `orientation` | `OrientationMode` | `'auto'` | Screen orientation |
385
+ | `maxTouches` | `number` | `99` | Maximum touch points |
386
+ | `background` | `string` | — | CSS background color |
387
+
388
+ ### KurotApp
389
+
390
+ | Property | Type | Description |
391
+ | --------------- | -------------------------------- | ------------------------------------------------------ |
392
+ | `player` | `Player` | Renderer and game loop |
393
+ | `stage` | `Stage` | Scene root |
394
+ | `touchHandler` | `TouchHandler` | Touch and mouse input |
395
+ | `screenAdapter` | `ScreenAdapter` | Screen adaptation |
396
+ | `start(root?)` | `(root?: DisplayObject) => void` | Start or resume the game loop |
397
+ | `stop()` | `() => void` | Stop the loop; it can be resumed |
398
+ | `destroy()` | `() => void` | Release the player, input, adapter and lifecycle hooks |
353
399
 
354
400
  ---
355
401
 
356
- ## 七、测试覆盖
357
-
358
- `test/` 下按模块组织测试文件,运行 `pnpm --dir packages/core test` 查看当前
359
- 文件数与用例数。
360
-
361
- | 模块 | 主要覆盖内容 |
362
- | ---------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
363
- | events/ | Event, EventDispatcher, EventPropagation, EventMap, TouchEvent, HTTPStatusEvent, ProgressEvent |
364
- | geom/ | Matrix, Point, Rectangle |
365
- | utils/ | ByteArray, Base64Util, Logger, DebugLog, NumberUtils, toColorString |
366
- | display/ | DisplayObject, DisplayObjectContainer, DisplayObjectIntegration, Bitmap, BitmapData, Sprite, Shape, Mesh, Stage, StageText, Graphics, Texture, SpriteSheet, BlendMode, DisplayList |
367
- | filters/ | Filter (全部滤镜), CustomFilter, filters(滤镜集成), EffectTransform(离屏效果变换正确性) |
368
- | media/ | Sound, SoundChannel, Video |
369
- | player/ | InstructionSet, InstructionPool, RenderGroup, TextPipe, MaskPipe, WebGLRendererDirty, WebGLRendererLeaf, WebGLVertexArrayObject, WebGLRenderBuffer, WebGLBlurFramebufferPool, CreatePlayer, TouchHandler |
370
- | net/ | HttpRequest, ImageLoader |
371
- | resource/ | Resource(并发 loadGroup 队列化), ResourceLoader(并发/重试/无 analyzer 场景) |
372
- | examples/benchmark/tests/ | 性能基准运行时与跨引擎对比测试 |
373
- | text/ | 通过 display 集成测试覆盖 |
402
+ ## 7. Test coverage
403
+
404
+ Tests are organized by module in `test/`. Run `pnpm --dir packages/core test` for
405
+ current file and test counts.
406
+
407
+ | Module | Main coverage |
408
+ | ------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
409
+ | events/ | Event, EventDispatcher, EventPropagation, EventMap, TouchEvent, HTTPStatusEvent, ProgressEvent |
410
+ | geom/ | Matrix, Point, Rectangle |
411
+ | utils/ | ByteArray, Base64Util, Logger, DebugLog, NumberUtils, toColorString |
412
+ | display/ | DisplayObject, DisplayObjectContainer, DisplayObjectIntegration, Bitmap, BitmapData, Sprite, Shape, Mesh, Stage, StageText, Graphics, Texture, SpriteSheet, BlendMode, DisplayList |
413
+ | filters/ | Filter classes, CustomFilter, filter integration and offscreen effect transforms |
414
+ | media/ | Sound, SoundChannel, Video |
415
+ | player/ | InstructionSet, InstructionPool, RenderGroup, TextPipe, MaskPipe, WebGLRendererDirty, WebGLRendererLeaf, WebGLVertexArrayObject, WebGLRenderBuffer, WebGLBlurFramebufferPool, CreatePlayer, TouchHandler |
416
+ | net/ | HttpRequest, ImageLoader |
417
+ | resource/ | Resource group serialization; ResourceLoader concurrency, retries and missing analyzers; FontAnalyzer loading and ownership |
418
+ | examples/benchmark/tests/ | Benchmark runtime and cross-engine comparisons |
419
+ | text/ | Display integration, BitmapText layout and native glyph geometry |