@kurot/core 1.0.14 → 1.0.15
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.
- package/README.md +63 -1
- package/dist/kurot/display/Bitmap.d.ts +0 -1
- package/dist/kurot/display/Bitmap.d.ts.map +1 -1
- package/dist/kurot/display/Bitmap.js +0 -3
- package/dist/kurot/display/Bitmap.js.map +1 -1
- package/dist/kurot/display/DisplayObject.d.ts +16 -35
- package/dist/kurot/display/DisplayObject.d.ts.map +1 -1
- package/dist/kurot/display/DisplayObject.js +6 -41
- package/dist/kurot/display/DisplayObject.js.map +1 -1
- package/dist/kurot/display/DisplayObjectContainer.d.ts +0 -10
- package/dist/kurot/display/DisplayObjectContainer.d.ts.map +1 -1
- package/dist/kurot/display/DisplayObjectContainer.js +0 -14
- package/dist/kurot/display/DisplayObjectContainer.js.map +1 -1
- package/dist/kurot/display/Graphics.d.ts +0 -1
- package/dist/kurot/display/Graphics.d.ts.map +1 -1
- package/dist/kurot/display/Graphics.js +0 -3
- package/dist/kurot/display/Graphics.js.map +1 -1
- package/dist/kurot/display/Mesh.d.ts +9 -3
- package/dist/kurot/display/Mesh.d.ts.map +1 -1
- package/dist/kurot/display/Mesh.js +9 -3
- package/dist/kurot/display/Mesh.js.map +1 -1
- package/dist/kurot/display/Stage.d.ts +0 -1
- package/dist/kurot/display/Stage.d.ts.map +1 -1
- package/dist/kurot/display/Stage.js +0 -2
- package/dist/kurot/display/Stage.js.map +1 -1
- package/dist/kurot/display/enums/BlendMode.d.ts.map +1 -1
- package/dist/kurot/display/enums/BlendMode.js +0 -2
- package/dist/kurot/display/enums/BlendMode.js.map +1 -1
- package/dist/kurot/display/texture/RenderTexture.d.ts +0 -1
- package/dist/kurot/display/texture/RenderTexture.d.ts.map +1 -1
- package/dist/kurot/display/texture/RenderTexture.js +0 -4
- package/dist/kurot/display/texture/RenderTexture.js.map +1 -1
- package/dist/kurot/display/texture/Texture.d.ts +9 -3
- package/dist/kurot/display/texture/Texture.d.ts.map +1 -1
- package/dist/kurot/display/texture/Texture.js +9 -3
- package/dist/kurot/display/texture/Texture.js.map +1 -1
- package/dist/kurot/events/Event.d.ts +3 -1
- package/dist/kurot/events/Event.d.ts.map +1 -1
- package/dist/kurot/events/Event.js +0 -2
- package/dist/kurot/events/Event.js.map +1 -1
- package/dist/kurot/events/EventDispatcher.d.ts.map +1 -1
- package/dist/kurot/events/EventDispatcher.js +0 -2
- package/dist/kurot/events/EventDispatcher.js.map +1 -1
- package/dist/kurot/events/TimerEvent.d.ts +0 -1
- package/dist/kurot/events/TimerEvent.d.ts.map +1 -1
- package/dist/kurot/events/TimerEvent.js +0 -1
- package/dist/kurot/events/TimerEvent.js.map +1 -1
- package/dist/kurot/events/TouchEvent.d.ts +0 -1
- package/dist/kurot/events/TouchEvent.d.ts.map +1 -1
- package/dist/kurot/events/TouchEvent.js +0 -1
- package/dist/kurot/events/TouchEvent.js.map +1 -1
- package/dist/kurot/filters/BlurFilter.d.ts.map +1 -1
- package/dist/kurot/filters/BlurFilter.js +0 -3
- package/dist/kurot/filters/BlurFilter.js.map +1 -1
- package/dist/kurot/filters/DropShadowFilter.d.ts.map +1 -1
- package/dist/kurot/filters/DropShadowFilter.js +0 -2
- package/dist/kurot/filters/DropShadowFilter.js.map +1 -1
- package/dist/kurot/geom/Matrix.d.ts +3 -9
- package/dist/kurot/geom/Matrix.d.ts.map +1 -1
- package/dist/kurot/geom/Matrix.js +3 -9
- package/dist/kurot/geom/Matrix.js.map +1 -1
- package/dist/kurot/geom/Point.d.ts +3 -1
- package/dist/kurot/geom/Point.d.ts.map +1 -1
- package/dist/kurot/geom/Point.js +3 -1
- package/dist/kurot/geom/Point.js.map +1 -1
- package/dist/kurot/geom/Rectangle.d.ts +3 -3
- package/dist/kurot/geom/Rectangle.d.ts.map +1 -1
- package/dist/kurot/geom/Rectangle.js +3 -3
- package/dist/kurot/geom/Rectangle.js.map +1 -1
- package/dist/kurot/media/Sound.d.ts.map +1 -1
- package/dist/kurot/media/Sound.js +1 -8
- package/dist/kurot/media/Sound.js.map +1 -1
- package/dist/kurot/media/SoundChannel.d.ts +0 -1
- package/dist/kurot/media/SoundChannel.d.ts.map +1 -1
- package/dist/kurot/media/SoundChannel.js +0 -3
- package/dist/kurot/media/SoundChannel.js.map +1 -1
- package/dist/kurot/player/InstructionSet.d.ts +4 -17
- package/dist/kurot/player/InstructionSet.d.ts.map +1 -1
- package/dist/kurot/player/InstructionSet.js +3 -20
- package/dist/kurot/player/InstructionSet.js.map +1 -1
- package/dist/kurot/player/KurotOptions.d.ts +24 -9
- package/dist/kurot/player/KurotOptions.d.ts.map +1 -1
- package/dist/kurot/player/Player.d.ts +15 -9
- package/dist/kurot/player/Player.d.ts.map +1 -1
- package/dist/kurot/player/Player.js +20 -22
- package/dist/kurot/player/Player.js.map +1 -1
- package/dist/kurot/player/RenderBuffer.d.ts +4 -14
- package/dist/kurot/player/RenderBuffer.d.ts.map +1 -1
- package/dist/kurot/player/RenderContext.d.ts +11 -27
- package/dist/kurot/player/RenderContext.d.ts.map +1 -1
- package/dist/kurot/player/RenderPipe.d.ts +3 -13
- package/dist/kurot/player/RenderPipe.d.ts.map +1 -1
- package/dist/kurot/player/ScreenAdapter.d.ts +6 -5
- package/dist/kurot/player/ScreenAdapter.d.ts.map +1 -1
- package/dist/kurot/player/ScreenAdapter.js +6 -15
- package/dist/kurot/player/ScreenAdapter.js.map +1 -1
- package/dist/kurot/player/SystemTicker.d.ts +13 -9
- package/dist/kurot/player/SystemTicker.d.ts.map +1 -1
- package/dist/kurot/player/SystemTicker.js +10 -13
- package/dist/kurot/player/SystemTicker.js.map +1 -1
- package/dist/kurot/player/TouchHandler.d.ts +3 -4
- package/dist/kurot/player/TouchHandler.d.ts.map +1 -1
- package/dist/kurot/player/TouchHandler.js +3 -12
- package/dist/kurot/player/TouchHandler.js.map +1 -1
- package/dist/kurot/player/canvas/CanvasBuffer.d.ts.map +1 -1
- package/dist/kurot/player/canvas/CanvasBuffer.js +0 -3
- package/dist/kurot/player/canvas/CanvasBuffer.js.map +1 -1
- package/dist/kurot/player/canvas/CanvasRenderer.d.ts +9 -17
- package/dist/kurot/player/canvas/CanvasRenderer.d.ts.map +1 -1
- package/dist/kurot/player/canvas/CanvasRenderer.js +182 -74
- package/dist/kurot/player/canvas/CanvasRenderer.js.map +1 -1
- package/dist/kurot/player/canvas/DisplayList.d.ts +1 -5
- package/dist/kurot/player/canvas/DisplayList.d.ts.map +1 -1
- package/dist/kurot/player/canvas/DisplayList.js +1 -5
- package/dist/kurot/player/canvas/DisplayList.js.map +1 -1
- package/dist/kurot/player/createPlayer.d.ts.map +1 -1
- package/dist/kurot/player/createPlayer.js +0 -2
- package/dist/kurot/player/createPlayer.js.map +1 -1
- package/dist/kurot/player/pipes/BitmapPipe.d.ts +3 -9
- package/dist/kurot/player/pipes/BitmapPipe.d.ts.map +1 -1
- package/dist/kurot/player/pipes/BitmapPipe.js +19 -33
- package/dist/kurot/player/pipes/BitmapPipe.js.map +1 -1
- package/dist/kurot/player/pipes/FilterPipe.d.ts +11 -28
- package/dist/kurot/player/pipes/FilterPipe.d.ts.map +1 -1
- package/dist/kurot/player/pipes/FilterPipe.js +8 -51
- package/dist/kurot/player/pipes/FilterPipe.js.map +1 -1
- package/dist/kurot/player/pipes/GraphicsPipe.d.ts +2 -7
- package/dist/kurot/player/pipes/GraphicsPipe.d.ts.map +1 -1
- package/dist/kurot/player/pipes/GraphicsPipe.js +28 -38
- package/dist/kurot/player/pipes/GraphicsPipe.js.map +1 -1
- package/dist/kurot/player/pipes/MaskPipe.d.ts +9 -14
- package/dist/kurot/player/pipes/MaskPipe.d.ts.map +1 -1
- package/dist/kurot/player/pipes/MaskPipe.js +24 -46
- package/dist/kurot/player/pipes/MaskPipe.js.map +1 -1
- package/dist/kurot/player/pipes/MeshPipe.d.ts +4 -1
- package/dist/kurot/player/pipes/MeshPipe.d.ts.map +1 -1
- package/dist/kurot/player/pipes/MeshPipe.js +20 -22
- package/dist/kurot/player/pipes/MeshPipe.js.map +1 -1
- package/dist/kurot/player/pipes/ParticlePipe.d.ts +1 -2
- package/dist/kurot/player/pipes/ParticlePipe.d.ts.map +1 -1
- package/dist/kurot/player/pipes/ParticlePipe.js +6 -14
- package/dist/kurot/player/pipes/ParticlePipe.js.map +1 -1
- package/dist/kurot/player/pipes/TextPipe.d.ts +3 -23
- package/dist/kurot/player/pipes/TextPipe.d.ts.map +1 -1
- package/dist/kurot/player/pipes/TextPipe.js +31 -74
- package/dist/kurot/player/pipes/TextPipe.js.map +1 -1
- package/dist/kurot/player/webgl/MultiTextureBatcher.d.ts +1 -12
- package/dist/kurot/player/webgl/MultiTextureBatcher.d.ts.map +1 -1
- package/dist/kurot/player/webgl/MultiTextureBatcher.js +2 -11
- package/dist/kurot/player/webgl/MultiTextureBatcher.js.map +1 -1
- package/dist/kurot/player/webgl/WebGLDrawCmdManager.d.ts +4 -4
- package/dist/kurot/player/webgl/WebGLDrawCmdManager.d.ts.map +1 -1
- package/dist/kurot/player/webgl/WebGLDrawCmdManager.js +11 -10
- package/dist/kurot/player/webgl/WebGLDrawCmdManager.js.map +1 -1
- package/dist/kurot/player/webgl/WebGLProgram.d.ts.map +1 -1
- package/dist/kurot/player/webgl/WebGLProgram.js.map +1 -1
- package/dist/kurot/player/webgl/WebGLRenderBuffer.d.ts +2 -0
- package/dist/kurot/player/webgl/WebGLRenderBuffer.d.ts.map +1 -1
- package/dist/kurot/player/webgl/WebGLRenderBuffer.js +9 -6
- package/dist/kurot/player/webgl/WebGLRenderBuffer.js.map +1 -1
- package/dist/kurot/player/webgl/WebGLRenderContext.d.ts +14 -43
- package/dist/kurot/player/webgl/WebGLRenderContext.d.ts.map +1 -1
- package/dist/kurot/player/webgl/WebGLRenderContext.js +34 -114
- package/dist/kurot/player/webgl/WebGLRenderContext.js.map +1 -1
- package/dist/kurot/player/webgl/WebGLRenderTarget.d.ts +2 -0
- package/dist/kurot/player/webgl/WebGLRenderTarget.d.ts.map +1 -1
- package/dist/kurot/player/webgl/WebGLRenderTarget.js +6 -0
- package/dist/kurot/player/webgl/WebGLRenderTarget.js.map +1 -1
- package/dist/kurot/player/webgl/WebGLRenderer.d.ts +3 -147
- package/dist/kurot/player/webgl/WebGLRenderer.d.ts.map +1 -1
- package/dist/kurot/player/webgl/WebGLRenderer.js +6 -210
- package/dist/kurot/player/webgl/WebGLRenderer.js.map +1 -1
- package/dist/kurot/player/webgl/WebGLUtils.d.ts +4 -4
- package/dist/kurot/player/webgl/WebGLUtils.d.ts.map +1 -1
- package/dist/kurot/player/webgl/WebGLUtils.js +3 -2
- package/dist/kurot/player/webgl/WebGLUtils.js.map +1 -1
- package/dist/kurot/player/webgl/WebGLVertexArrayObject.d.ts +6 -2
- package/dist/kurot/player/webgl/WebGLVertexArrayObject.d.ts.map +1 -1
- package/dist/kurot/player/webgl/WebGLVertexArrayObject.js +6 -11
- package/dist/kurot/player/webgl/WebGLVertexArrayObject.js.map +1 -1
- package/dist/kurot/player/webgl/shaders/ShaderLib.d.ts +1 -2
- package/dist/kurot/player/webgl/shaders/ShaderLib.d.ts.map +1 -1
- package/dist/kurot/player/webgl/shaders/ShaderLib.js +1 -6
- package/dist/kurot/player/webgl/shaders/ShaderLib.js.map +1 -1
- package/dist/kurot/player/webgl/shaders/ShaderLib2.d.ts +1 -2
- package/dist/kurot/player/webgl/shaders/ShaderLib2.d.ts.map +1 -1
- package/dist/kurot/player/webgl/shaders/ShaderLib2.js +1 -13
- package/dist/kurot/player/webgl/shaders/ShaderLib2.js.map +1 -1
- package/dist/kurot/player/webgl/shaders/index.d.ts.map +1 -1
- package/dist/kurot/player/webgl/shaders/index.js +0 -2
- package/dist/kurot/player/webgl/shaders/index.js.map +1 -1
- package/dist/kurot/resource/Resource.d.ts +1 -1
- package/dist/kurot/resource/Resource.d.ts.map +1 -1
- package/dist/kurot/resource/Resource.js +1 -12
- package/dist/kurot/resource/Resource.js.map +1 -1
- package/dist/kurot/resource/ResourceEvent.d.ts +15 -5
- package/dist/kurot/resource/ResourceEvent.d.ts.map +1 -1
- package/dist/kurot/resource/ResourceLoader.d.ts +15 -24
- package/dist/kurot/resource/ResourceLoader.d.ts.map +1 -1
- package/dist/kurot/resource/ResourceLoader.js +17 -35
- package/dist/kurot/resource/ResourceLoader.js.map +1 -1
- package/dist/kurot/resource/analyzers/AnalyzerBase.d.ts +3 -4
- package/dist/kurot/resource/analyzers/AnalyzerBase.d.ts.map +1 -1
- package/dist/kurot/resource/analyzers/AnalyzerBase.js +3 -5
- package/dist/kurot/resource/analyzers/AnalyzerBase.js.map +1 -1
- package/dist/kurot/resource/analyzers/ImageAnalyzer.d.ts.map +1 -1
- package/dist/kurot/resource/analyzers/ImageAnalyzer.js +0 -1
- package/dist/kurot/resource/analyzers/ImageAnalyzer.js.map +1 -1
- package/dist/kurot/resource/analyzers/SheetAnalyzer.d.ts +6 -5
- package/dist/kurot/resource/analyzers/SheetAnalyzer.d.ts.map +1 -1
- package/dist/kurot/resource/analyzers/SheetAnalyzer.js +6 -12
- package/dist/kurot/resource/analyzers/SheetAnalyzer.js.map +1 -1
- package/dist/kurot/resource/analyzers/SoundAnalyzer.d.ts.map +1 -1
- package/dist/kurot/resource/analyzers/SoundAnalyzer.js +0 -1
- package/dist/kurot/resource/analyzers/SoundAnalyzer.js.map +1 -1
- package/dist/kurot/resource/index.d.ts.map +1 -1
- package/dist/kurot/resource/index.js +0 -3
- package/dist/kurot/resource/index.js.map +1 -1
- package/dist/kurot/system/Capabilities.d.ts +11 -13
- package/dist/kurot/system/Capabilities.d.ts.map +1 -1
- package/dist/kurot/system/Capabilities.js +12 -18
- package/dist/kurot/system/Capabilities.js.map +1 -1
- package/dist/kurot/text/BitmapFont.d.ts +0 -1
- package/dist/kurot/text/BitmapFont.d.ts.map +1 -1
- package/dist/kurot/text/BitmapFont.js +0 -2
- package/dist/kurot/text/BitmapFont.js.map +1 -1
- package/dist/kurot/text/BitmapText.d.ts +0 -5
- package/dist/kurot/text/BitmapText.d.ts.map +1 -1
- package/dist/kurot/text/BitmapText.js +0 -6
- package/dist/kurot/text/BitmapText.js.map +1 -1
- package/dist/kurot/text/HtmlTextParser.d.ts +3 -1
- package/dist/kurot/text/HtmlTextParser.d.ts.map +1 -1
- package/dist/kurot/text/HtmlTextParser.js +3 -1
- package/dist/kurot/text/HtmlTextParser.js.map +1 -1
- package/dist/kurot/text/InputController.d.ts.map +1 -1
- package/dist/kurot/text/InputController.js +0 -2
- package/dist/kurot/text/InputController.js.map +1 -1
- package/dist/kurot/text/StageText.d.ts +1 -20
- package/dist/kurot/text/StageText.d.ts.map +1 -1
- package/dist/kurot/text/StageText.js +2 -46
- package/dist/kurot/text/StageText.js.map +1 -1
- package/dist/kurot/text/TextField.d.ts +0 -12
- package/dist/kurot/text/TextField.d.ts.map +1 -1
- package/dist/kurot/text/TextField.js +0 -41
- package/dist/kurot/text/TextField.js.map +1 -1
- package/dist/kurot/text/WordWrap.d.ts +0 -1
- package/dist/kurot/text/WordWrap.d.ts.map +1 -1
- package/dist/kurot/text/WordWrap.js +0 -3
- package/dist/kurot/text/WordWrap.js.map +1 -1
- package/dist/kurot/utils/Base64Util.d.ts +1 -6
- package/dist/kurot/utils/Base64Util.d.ts.map +1 -1
- package/dist/kurot/utils/Base64Util.js +1 -7
- package/dist/kurot/utils/Base64Util.js.map +1 -1
- package/dist/kurot/utils/DebugLog.js +0 -1
- package/dist/kurot/utils/DebugLog.js.map +1 -1
- package/dist/kurot/utils/FontManager.d.ts.map +1 -1
- package/dist/kurot/utils/FontManager.js +3 -1
- package/dist/kurot/utils/FontManager.js.map +1 -1
- package/dist/kurot/utils/NumberUtils.d.ts.map +1 -1
- package/dist/kurot/utils/NumberUtils.js +0 -1
- package/dist/kurot/utils/NumberUtils.js.map +1 -1
- package/package.json +14 -3
- package/dist/kurot/benchmark/BenchmarkRunner.d.ts +0 -60
- package/dist/kurot/benchmark/BenchmarkRunner.d.ts.map +0 -1
- package/dist/kurot/benchmark/BenchmarkRunner.js +0 -112
- package/dist/kurot/benchmark/BenchmarkRunner.js.map +0 -1
- package/dist/kurot/benchmark/MetricsCollector.d.ts +0 -34
- package/dist/kurot/benchmark/MetricsCollector.d.ts.map +0 -1
- package/dist/kurot/benchmark/MetricsCollector.js +0 -123
- package/dist/kurot/benchmark/MetricsCollector.js.map +0 -1
- package/dist/kurot/benchmark/PerfPanel.d.ts +0 -24
- package/dist/kurot/benchmark/PerfPanel.d.ts.map +0 -1
- package/dist/kurot/benchmark/PerfPanel.js +0 -131
- package/dist/kurot/benchmark/PerfPanel.js.map +0 -1
- package/dist/kurot/benchmark/ReportExporter.d.ts +0 -8
- package/dist/kurot/benchmark/ReportExporter.d.ts.map +0 -1
- package/dist/kurot/benchmark/ReportExporter.js +0 -54
- package/dist/kurot/benchmark/ReportExporter.js.map +0 -1
- package/dist/kurot/benchmark/SceneRegistry.d.ts +0 -16
- package/dist/kurot/benchmark/SceneRegistry.d.ts.map +0 -1
- package/dist/kurot/benchmark/SceneRegistry.js +0 -233
- package/dist/kurot/benchmark/SceneRegistry.js.map +0 -1
- package/dist/kurot/benchmark/types.d.ts +0 -47
- package/dist/kurot/benchmark/types.d.ts.map +0 -1
- package/dist/kurot/benchmark/types.js +0 -2
- package/dist/kurot/benchmark/types.js.map +0 -1
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { ColorMatrixFilter } from '../../filters/ColorMatrixFilter.js';
|
|
2
2
|
import { WebGLRenderBuffer as WGLBuf } from '../webgl/WebGLRenderBuffer.js';
|
|
3
|
-
// ── Pipe ──────────────────────────────────────────────────────────────────────
|
|
4
3
|
const BLEND_MODES = {
|
|
5
4
|
0: 'source-over',
|
|
6
5
|
1: 'lighter',
|
|
@@ -8,14 +7,7 @@ const BLEND_MODES = {
|
|
|
8
7
|
};
|
|
9
8
|
const INSTRUCTION_POOL_LIMIT = 256;
|
|
10
9
|
/**
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
* The renderer calls pushFilter() before traversing the filtered subtree and
|
|
14
|
-
* popFilter() after. The pop instruction composites the offscreen buffer back
|
|
15
|
-
* onto the main buffer with the filter applied.
|
|
16
|
-
*
|
|
17
|
-
* This mirrors the old WebGLRenderer._drawWithFilter() logic but expressed as
|
|
18
|
-
* a pair of instructions so the traversal and execution phases are separated.
|
|
10
|
+
* Renders filtered subtrees through paired push and pop instructions.
|
|
19
11
|
*/
|
|
20
12
|
export class FilterPipe {
|
|
21
13
|
// ── Static fields ─────────────────────────────────────────────────────────
|
|
@@ -23,13 +15,9 @@ export class FilterPipe {
|
|
|
23
15
|
static POP_ID = 'filterPop';
|
|
24
16
|
static _pushPool = [];
|
|
25
17
|
static _popPool = [];
|
|
26
|
-
// ──
|
|
27
|
-
addToInstructionSet(_renderable, _set) {
|
|
28
|
-
// FilterPipe instructions are added by the renderer's traversal logic,
|
|
29
|
-
// not by this method — see WebGLRenderer._buildInstructions().
|
|
30
|
-
}
|
|
18
|
+
// ── Public methods ────────────────────────────────────────────────────────
|
|
19
|
+
addToInstructionSet(_renderable, _set) { }
|
|
31
20
|
updateRenderable(_renderable) { }
|
|
32
|
-
// ── Factory helpers used by the renderer ─────────────────────────────────
|
|
33
21
|
static makePush(renderable, filters, offsetX, offsetY) {
|
|
34
22
|
const inst = FilterPipe._pushPool.pop();
|
|
35
23
|
if (inst) {
|
|
@@ -63,19 +51,10 @@ export class FilterPipe {
|
|
|
63
51
|
if (FilterPipe._popPool.length < INSTRUCTION_POOL_LIMIT)
|
|
64
52
|
FilterPipe._popPool.push(inst);
|
|
65
53
|
}
|
|
66
|
-
// ── Execute ───────────────────────────────────────────────────────────────
|
|
67
54
|
/**
|
|
68
|
-
*
|
|
69
|
-
*
|
|
70
|
-
*
|
|
71
|
-
* - ColorMatrix inline: sets activeFilter on the main buffer, returns undefined.
|
|
72
|
-
* Subsequent leaf instructions draw directly to the main buffer with the
|
|
73
|
-
* filter applied per-draw-call.
|
|
74
|
-
* - All other filters: allocates an offscreen buffer and activates it via
|
|
75
|
-
* pushBuffer so that ALL subsequent draw calls (until filterPop) land in
|
|
76
|
-
* the offscreen buffer, not the main buffer.
|
|
77
|
-
*
|
|
78
|
-
* Returns the offscreen buffer (or undefined for inline path).
|
|
55
|
+
* Activates inline color-matrix rendering or an offscreen filter buffer.
|
|
56
|
+
* Pending commands are flushed before inline rendering so the framebuffer
|
|
57
|
+
* and activation command match the current buffer.
|
|
79
58
|
*/
|
|
80
59
|
executePush(inst, buffer) {
|
|
81
60
|
const filters = inst.filters;
|
|
@@ -84,28 +63,17 @@ export class FilterPipe {
|
|
|
84
63
|
const bounds = inst.renderable.$getOriginalBounds();
|
|
85
64
|
if (bounds.width <= 0 || bounds.height <= 0)
|
|
86
65
|
return undefined;
|
|
87
|
-
// Inline ColorMatrix optimisation: no offscreen buffer needed.
|
|
88
|
-
// Flush any pending commands first, then re-activate the current buffer
|
|
89
|
-
// so the GL FBO + viewport/projection are in a known-good state before
|
|
90
|
-
// the leaf draw commands are queued. Without this, the colorTransform
|
|
91
|
-
// draw may execute against a stale FBO left by a previous filter pass.
|
|
92
66
|
if (!inst.renderable.$mask && filters.length === 1 && filters[0] instanceof ColorMatrixFilter) {
|
|
93
67
|
const hasBlend = inst.renderable.$blendMode !== 0;
|
|
94
68
|
if (hasBlend) {
|
|
95
69
|
inst.savedBlendMode = buffer.context.currentBlendMode;
|
|
96
70
|
buffer.context.setGlobalCompositeOperation(BLEND_MODES[inst.renderable.$blendMode] ?? 'source-over');
|
|
97
71
|
}
|
|
98
|
-
// Flush pending batched commands so the GL state is clean, then
|
|
99
|
-
// re-push the current buffer to guarantee an ACT_BUFFER command
|
|
100
|
-
// precedes the upcoming leaf draw in the next flush.
|
|
101
72
|
buffer.context.flush();
|
|
102
73
|
buffer.context.pushBuffer(buffer);
|
|
103
74
|
buffer.context.activeFilter = filters[0];
|
|
104
|
-
return undefined;
|
|
75
|
+
return undefined;
|
|
105
76
|
}
|
|
106
|
-
// Offscreen path: redirect all subsequent draw calls into this buffer.
|
|
107
|
-
// Expand the buffer by the union of all filters' padding so blur/glow
|
|
108
|
-
// has room to bleed outside the content bounds.
|
|
109
77
|
let padL = 0, padR = 0, padT = 0, padB = 0;
|
|
110
78
|
for (const f of filters) {
|
|
111
79
|
const p = f.getPadding();
|
|
@@ -121,24 +89,19 @@ export class FilterPipe {
|
|
|
121
89
|
const offW = Math.ceil(bounds.width + padL + padR);
|
|
122
90
|
const offH = Math.ceil(bounds.height + padT + padB);
|
|
123
91
|
const offscreen = WGLBuf.create(buffer.context, offW, offH);
|
|
124
|
-
// Store padding offsets so the renderer can adjust the offscreen origin.
|
|
125
92
|
offscreen.filterPadX = padL;
|
|
126
93
|
offscreen.filterPadY = padT;
|
|
127
|
-
// pushBuffer activates the offscreen FBO so WebGL draws land there.
|
|
128
94
|
offscreen.context.pushBuffer(offscreen);
|
|
129
95
|
return offscreen;
|
|
130
96
|
}
|
|
131
97
|
/**
|
|
132
|
-
*
|
|
133
|
-
* Deactivates the offscreen buffer and composites it back onto the main buffer.
|
|
98
|
+
* Restores the parent buffer and composites an offscreen filter result.
|
|
134
99
|
*/
|
|
135
100
|
executePop(inst, buffer, offscreen) {
|
|
136
101
|
const { renderable, push } = inst;
|
|
137
102
|
const filters = push.filters;
|
|
138
103
|
const hasBlend = renderable.$blendMode !== 0;
|
|
139
104
|
const blendOp = BLEND_MODES[renderable.$blendMode] ?? 'source-over';
|
|
140
|
-
// Inline ColorMatrix path — clear the filter flag and pop the buffer
|
|
141
|
-
// that was pushed in executePush to balance the stack.
|
|
142
105
|
if (!offscreen) {
|
|
143
106
|
buffer.context.flush();
|
|
144
107
|
buffer.context.popBuffer();
|
|
@@ -147,19 +110,13 @@ export class FilterPipe {
|
|
|
147
110
|
buffer.context.setGlobalCompositeOperation(push.savedBlendMode);
|
|
148
111
|
return;
|
|
149
112
|
}
|
|
150
|
-
// Deactivate the offscreen buffer, restoring the main buffer as active.
|
|
151
113
|
offscreen.context.popBuffer();
|
|
152
114
|
const bounds = renderable.$getOriginalBounds();
|
|
153
115
|
const bx = bounds.x;
|
|
154
116
|
const by = bounds.y;
|
|
155
|
-
// Save the current blend mode before applying the filter's blend mode,
|
|
156
|
-
// so we can restore it after compositing.
|
|
157
117
|
const prevBlend = buffer.context.currentBlendMode;
|
|
158
118
|
if (hasBlend)
|
|
159
119
|
buffer.context.setGlobalCompositeOperation(blendOp);
|
|
160
|
-
// Position the offscreen result.
|
|
161
|
-
// The offscreen texture's top-left is (padL, padT) above/left of
|
|
162
|
-
// the content bounds origin, so we offset by (bx - padL, by - padT).
|
|
163
120
|
const padX = offscreen.filterPadX;
|
|
164
121
|
const padY = offscreen.filterPadY;
|
|
165
122
|
buffer.offsetX = bx - padX;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FilterPipe.js","sourceRoot":"","sources":["../../../../src/kurot/player/pipes/FilterPipe.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAE,MAAM,oCAAoC,CAAC;AAKvE,OAAO,EAAE,iBAAiB,IAAI,MAAM,EAAE,MAAM,+BAA+B,CAAC;
|
|
1
|
+
{"version":3,"file":"FilterPipe.js","sourceRoot":"","sources":["../../../../src/kurot/player/pipes/FilterPipe.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAE,MAAM,oCAAoC,CAAC;AAKvE,OAAO,EAAE,iBAAiB,IAAI,MAAM,EAAE,MAAM,+BAA+B,CAAC;AAuB5E,MAAM,WAAW,GAA2B;IAC3C,CAAC,EAAE,aAAa;IAChB,CAAC,EAAE,SAAS;IACZ,CAAC,EAAE,iBAAiB;CACpB,CAAC;AAEF,MAAM,sBAAsB,GAAG,GAAG,CAAC;AAEnC;;GAEG;AACH,MAAM,OAAO,UAAU;IAEtB,6EAA6E;IACtE,MAAM,CAAU,OAAO,GAAG,YAAY,CAAC;IACpC,MAAM,CAAU,MAAM,GAAG,WAAW,CAAC;IAEvC,MAAM,CAAU,SAAS,GAA4B,EAAE,CAAC;IACxD,MAAM,CAAU,QAAQ,GA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B,EAAE,CAAC;QAE1B,IAAI,QAAQ;YAAE,MAAM,CAAC,OAAO,CAAC,2BAA2B,CAAC,SAAS,CAAC,CAAC;QAEpE,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IAC3B,CAAC"}
|
|
@@ -8,17 +8,12 @@ import type { CanvasRenderer } from '../canvas/index.js';
|
|
|
8
8
|
export interface GraphicsInstruction extends Instruction {
|
|
9
9
|
readonly renderPipeId: 'graphics';
|
|
10
10
|
renderable: DisplayObject;
|
|
11
|
-
/** The Graphics object attached to the renderable. */
|
|
12
11
|
graphics: Graphics;
|
|
13
12
|
offsetX: number;
|
|
14
13
|
offsetY: number;
|
|
15
14
|
}
|
|
16
15
|
/**
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
* Rasterizes the Graphics commands to an offscreen Canvas, uploads as a
|
|
20
|
-
* WebGL texture, and caches it. The cache is invalidated when
|
|
21
|
-
* `graphics.canvasCacheDirty` is true (set by Graphics.dirty()).
|
|
16
|
+
* Rasterizes graphics into cached textures for render-buffer drawing.
|
|
22
17
|
*/
|
|
23
18
|
export declare class GraphicsPipe implements RenderPipe<DisplayObject> {
|
|
24
19
|
static readonly PIPE_ID = "graphics";
|
|
@@ -28,11 +23,11 @@ export declare class GraphicsPipe implements RenderPipe<DisplayObject> {
|
|
|
28
23
|
private readonly _registryTokens;
|
|
29
24
|
private _context?;
|
|
30
25
|
constructor(canvasRenderer: CanvasRenderer);
|
|
31
|
-
private static _alloc;
|
|
32
26
|
static release(inst: GraphicsInstruction): void;
|
|
33
27
|
addToInstructionSet(renderable: DisplayObject, set: InstructionSet): void;
|
|
34
28
|
updateRenderable(_renderable: DisplayObject): void;
|
|
35
29
|
destroyRenderable(renderable: DisplayObject): void;
|
|
36
30
|
execute(inst: GraphicsInstruction, buffer: RenderBuffer): void;
|
|
31
|
+
private static _alloc;
|
|
37
32
|
}
|
|
38
33
|
//# sourceMappingURL=GraphicsPipe.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GraphicsPipe.d.ts","sourceRoot":"","sources":["../../../../src/kurot/player/pipes/GraphicsPipe.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAC1D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAEpE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAEnD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"GraphicsPipe.d.ts","sourceRoot":"","sources":["../../../../src/kurot/player/pipes/GraphicsPipe.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAC1D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAEpE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAEnD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAKzD,MAAM,WAAW,mBAAoB,SAAQ,WAAW;IACvD,QAAQ,CAAC,YAAY,EAAE,UAAU,CAAC;IAClC,UAAU,EAAE,aAAa,CAAC;IAC1B,QAAQ,EAAE,QAAQ,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;CAChB;AAYD;;GAEG;AACH,qBAAa,YAAa,YAAW,UAAU,CAAC,aAAa,CAAC;IAG7D,gBAAuB,OAAO,cAAc;IAEzC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAA6B;IAG7D,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAiB;IACjD,OAAO,CAAC,QAAQ,CAAC,MAAM,CAA0C;IACjE,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAmC;IAEhE,OAAO,CAAC,QAAQ,CAAC,CAAgB;gBAGjB,cAAc,EAAE,cAAc;WAMnC,OAAO,CAAC,IAAI,EAAE,mBAAmB,GAAG,IAAI;IAI/C,mBAAmB,CAAC,UAAU,EAAE,aAAa,EAAE,GAAG,EAAE,cAAc,GAAG,IAAI;IAQzE,gBAAgB,CAAC,WAAW,EAAE,aAAa,GAAG,IAAI;IAElD,iBAAiB,CAAC,UAAU,EAAE,aAAa,GAAG,IAAI;IAelD,OAAO,CAAC,IAAI,EAAE,mBAAmB,EAAE,MAAM,EAAE,YAAY,GAAG,IAAI;IAgGrE,OAAO,CAAC,MAAM,CAAC,MAAM;CAcrB"}
|
|
@@ -1,14 +1,8 @@
|
|
|
1
1
|
import { Rectangle } from '../../geom/Rectangle.js';
|
|
2
2
|
import { CanvasBuffer } from '../canvas/index.js';
|
|
3
|
-
// Shared scratch rectangle — avoids per-execute allocation.
|
|
4
3
|
const _scratchBounds = new Rectangle();
|
|
5
|
-
// ── Pipe ──────────────────────────────────────────────────────────────────────
|
|
6
4
|
/**
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* Rasterizes the Graphics commands to an offscreen Canvas, uploads as a
|
|
10
|
-
* WebGL texture, and caches it. The cache is invalidated when
|
|
11
|
-
* `graphics.canvasCacheDirty` is true (set by Graphics.dirty()).
|
|
5
|
+
* Rasterizes graphics into cached textures for render-buffer drawing.
|
|
12
6
|
*/
|
|
13
7
|
export class GraphicsPipe {
|
|
14
8
|
// ── Static fields ─────────────────────────────────────────────────────────
|
|
@@ -23,24 +17,10 @@ export class GraphicsPipe {
|
|
|
23
17
|
constructor(canvasRenderer) {
|
|
24
18
|
this._canvasRenderer = canvasRenderer;
|
|
25
19
|
}
|
|
26
|
-
|
|
27
|
-
const inst = GraphicsPipe._pool.pop() ?? {
|
|
28
|
-
renderPipeId: 'graphics',
|
|
29
|
-
renderable,
|
|
30
|
-
graphics,
|
|
31
|
-
offsetX: ox,
|
|
32
|
-
offsetY: oy,
|
|
33
|
-
};
|
|
34
|
-
inst.renderable = renderable;
|
|
35
|
-
inst.graphics = graphics;
|
|
36
|
-
inst.offsetX = ox;
|
|
37
|
-
inst.offsetY = oy;
|
|
38
|
-
return inst;
|
|
39
|
-
}
|
|
20
|
+
// ── Public methods ────────────────────────────────────────────────────────
|
|
40
21
|
static release(inst) {
|
|
41
22
|
GraphicsPipe._pool.push(inst);
|
|
42
23
|
}
|
|
43
|
-
// ── RenderPipe impl ───────────────────────────────────────────────────────
|
|
44
24
|
addToInstructionSet(renderable, set) {
|
|
45
25
|
const graphics = renderable.graphics;
|
|
46
26
|
if (!graphics || graphics.commands.length === 0) {
|
|
@@ -48,17 +28,13 @@ export class GraphicsPipe {
|
|
|
48
28
|
}
|
|
49
29
|
set.add(GraphicsPipe._alloc(renderable, graphics, 0, 0));
|
|
50
30
|
}
|
|
51
|
-
updateRenderable(_renderable) {
|
|
52
|
-
// Cache invalidation is driven by graphics.canvasCacheDirty,
|
|
53
|
-
// which is checked at execute time — nothing to pre-upload here.
|
|
54
|
-
}
|
|
31
|
+
updateRenderable(_renderable) { }
|
|
55
32
|
destroyRenderable(renderable) {
|
|
56
33
|
const graphics = renderable.graphics;
|
|
57
34
|
if (!graphics)
|
|
58
35
|
return;
|
|
59
36
|
const cache = this._cache.get(graphics);
|
|
60
37
|
if (cache?.texture) {
|
|
61
|
-
// Unregister from GC registry and delete texture immediately.
|
|
62
38
|
const token = this._registryTokens.get(graphics);
|
|
63
39
|
if (token) {
|
|
64
40
|
this._context?.unregisterTextureGC(token);
|
|
@@ -68,13 +44,11 @@ export class GraphicsPipe {
|
|
|
68
44
|
}
|
|
69
45
|
this._cache.delete(graphics);
|
|
70
46
|
}
|
|
71
|
-
// ── Execute ───────────────────────────────────────────────────────────────
|
|
72
47
|
execute(inst, buffer) {
|
|
73
48
|
const { graphics } = inst;
|
|
74
49
|
if (graphics.commands.length === 0) {
|
|
75
50
|
return;
|
|
76
51
|
}
|
|
77
|
-
// Cache the render context for use in destroyRenderable.
|
|
78
52
|
if (!this._context)
|
|
79
53
|
this._context = buffer.context;
|
|
80
54
|
const bounds = _scratchBounds;
|
|
@@ -89,8 +63,16 @@ export class GraphicsPipe {
|
|
|
89
63
|
const oy = inst.offsetY;
|
|
90
64
|
buffer.offsetX = 0;
|
|
91
65
|
buffer.offsetY = 0;
|
|
92
|
-
// ── Cache lookup / rebuild ────────────────────────────────────────────
|
|
93
66
|
let cache = this._cache.get(graphics);
|
|
67
|
+
if (cache && cache.contextVersion !== buffer.context.contextVersion) {
|
|
68
|
+
const oldToken = this._registryTokens.get(graphics);
|
|
69
|
+
if (oldToken)
|
|
70
|
+
buffer.context.unregisterTextureGC(oldToken);
|
|
71
|
+
this._registryTokens.delete(graphics);
|
|
72
|
+
cache.texture = undefined;
|
|
73
|
+
cache.contextVersion = buffer.context.contextVersion;
|
|
74
|
+
graphics.canvasCacheDirty = true;
|
|
75
|
+
}
|
|
94
76
|
if (!cache) {
|
|
95
77
|
cache = {
|
|
96
78
|
canvasBuffer: new CanvasBuffer(w, h),
|
|
@@ -99,6 +81,7 @@ export class GraphicsPipe {
|
|
|
99
81
|
textureHeight: 0,
|
|
100
82
|
boundsX: bounds.x,
|
|
101
83
|
boundsY: bounds.y,
|
|
84
|
+
contextVersion: buffer.context.contextVersion,
|
|
102
85
|
};
|
|
103
86
|
this._cache.set(graphics, cache);
|
|
104
87
|
}
|
|
@@ -108,19 +91,15 @@ export class GraphicsPipe {
|
|
|
108
91
|
cache.canvasBuffer.resize(w, h);
|
|
109
92
|
}
|
|
110
93
|
cache.canvasBuffer.clear();
|
|
111
|
-
// skipCache=true: we are the cache owner, bypass CanvasRenderer's own
|
|
112
|
-
// offscreen canvas layer to avoid a redundant intermediate rasterization.
|
|
113
94
|
this._canvasRenderer.renderGraphicsToContext(graphics, cache.canvasBuffer.context, -bounds.x, -bounds.y, false, true);
|
|
114
95
|
const surface = cache.canvasBuffer.surface;
|
|
115
96
|
if (!cache.texture) {
|
|
116
97
|
cache.texture = buffer.context.createTexture(surface);
|
|
117
|
-
// Register for GC-based cleanup.
|
|
118
98
|
const token = {};
|
|
119
99
|
buffer.context.registerTextureForGC(graphics, cache.texture, token);
|
|
120
100
|
this._registryTokens.set(graphics, token);
|
|
121
101
|
}
|
|
122
102
|
else {
|
|
123
|
-
// Unregister old texture, create new registration for updated texture.
|
|
124
103
|
const oldToken = this._registryTokens.get(graphics);
|
|
125
104
|
if (oldToken)
|
|
126
105
|
buffer.context.unregisterTextureGC(oldToken);
|
|
@@ -133,15 +112,11 @@ export class GraphicsPipe {
|
|
|
133
112
|
cache.textureHeight = h;
|
|
134
113
|
cache.boundsX = bounds.x;
|
|
135
114
|
cache.boundsY = bounds.y;
|
|
136
|
-
// Consume the dirty flag — Phase 1 set it, we've now rebuilt.
|
|
137
115
|
graphics.canvasCacheDirty = false;
|
|
138
116
|
}
|
|
139
117
|
if (!cache.texture) {
|
|
140
118
|
return;
|
|
141
119
|
}
|
|
142
|
-
// ── Draw cached texture ───────────────────────────────────────────────
|
|
143
|
-
// ox/oy are already baked into globalMatrix via _applyTransform.
|
|
144
|
-
// Only add bounds origin (content may start at non-zero local coords).
|
|
145
120
|
buffer.saveTransform();
|
|
146
121
|
if (cache.boundsX !== 0 || cache.boundsY !== 0) {
|
|
147
122
|
buffer.globalMatrix.append(1, 0, 0, 1, cache.boundsX, cache.boundsY);
|
|
@@ -149,5 +124,20 @@ export class GraphicsPipe {
|
|
|
149
124
|
buffer.context.drawTexture(cache.texture, 0, 0, w, h, 0, 0, w, h, w, h);
|
|
150
125
|
buffer.restoreTransform();
|
|
151
126
|
}
|
|
127
|
+
// ── Private methods ───────────────────────────────────────────────────────
|
|
128
|
+
static _alloc(renderable, graphics, ox, oy) {
|
|
129
|
+
const inst = GraphicsPipe._pool.pop() ?? {
|
|
130
|
+
renderPipeId: 'graphics',
|
|
131
|
+
renderable,
|
|
132
|
+
graphics,
|
|
133
|
+
offsetX: ox,
|
|
134
|
+
offsetY: oy,
|
|
135
|
+
};
|
|
136
|
+
inst.renderable = renderable;
|
|
137
|
+
inst.graphics = graphics;
|
|
138
|
+
inst.offsetX = ox;
|
|
139
|
+
inst.offsetY = oy;
|
|
140
|
+
return inst;
|
|
141
|
+
}
|
|
152
142
|
}
|
|
153
143
|
//# sourceMappingURL=GraphicsPipe.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GraphicsPipe.js","sourceRoot":"","sources":["../../../../src/kurot/player/pipes/GraphicsPipe.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAOpD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAElD,
|
|
1
|
+
{"version":3,"file":"GraphicsPipe.js","sourceRoot":"","sources":["../../../../src/kurot/player/pipes/GraphicsPipe.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAOpD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAElD,MAAM,cAAc,GAAG,IAAI,SAAS,EAAE,CAAC;AAoBvC;;GAEG;AACH,MAAM,OAAO,YAAY;IAExB,6EAA6E;IACtE,MAAM,CAAU,OAAO,GAAG,UAAU,CAAC;IAEjC,MAAM,CAAU,KAAK,GAA0B,EAAE,CAAC;IAE7D,6EAA6E;IAC5D,eAAe,CAAiB;IAChC,MAAM,GAAG,IAAI,OAAO,EAA2B,CAAC;IAChD,eAAe,GAAG,IAAI,OAAO,EAAoB,CAAC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AO,KAAK,CAAC,IAAI,KAAK,CAAC,OAAO,KAAK,CAAC,EAAE,CAAC;YAChD,MAAM,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,KAAK,CAAC,OAAO,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC;QACtE,CAAC;QAED,MAAM,CAAC,OAAO,CAAC,WAAW,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;QAExE,MAAM,CAAC,gBAAgB,EAAE,CAAC;IAC3B,CAAC;IAED,6EAA6E;IAErE,MAAM,CAAC,MAAM,CAAC,UAAyB,EAAE,QAAkB,EAAE,EAAU,EAAE,EAAU;QAC1F,MAAM,IAAI,GAAG,YAAY,CAAC,KAAK,CAAC,GAAG,EAAE,IAAI;YACxC,YAAY,EAAE,UAAU;YACxB,UAAU;YACV,QAAQ;YACR,OAAO,EAAE,EAAE;YACX,OAAO,EAAE,EAAE;SACX,CAAC;QACF,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,OAAO,GAAG,EAAE,CAAC;QAClB,IAAI,CAAC,OAAO,GAAG,EAAE,CAAC;QAClB,OAAO,IAAI,CAAC;IACb,CAAC"}
|
|
@@ -10,6 +10,7 @@ export interface MaskPushInstruction extends Instruction {
|
|
|
10
10
|
offsetX: number;
|
|
11
11
|
offsetY: number;
|
|
12
12
|
isScrollRect?: boolean;
|
|
13
|
+
savedBlendMode?: string;
|
|
13
14
|
}
|
|
14
15
|
export interface MaskPopInstruction extends Instruction {
|
|
15
16
|
readonly renderPipeId: 'maskPop';
|
|
@@ -17,10 +18,7 @@ export interface MaskPopInstruction extends Instruction {
|
|
|
17
18
|
push: MaskPushInstruction;
|
|
18
19
|
}
|
|
19
20
|
/**
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
* Mirrors the old WebGLRenderer._drawWithClip() and _drawWithScrollRect()
|
|
23
|
-
* logic as a push/pop instruction pair.
|
|
21
|
+
* Renders masks and clipping regions through paired push and pop instructions.
|
|
24
22
|
*/
|
|
25
23
|
export declare class MaskPipe implements RenderPipe<DisplayObject> {
|
|
26
24
|
static readonly PUSH_ID = "maskPush";
|
|
@@ -36,22 +34,19 @@ export declare class MaskPipe implements RenderPipe<DisplayObject> {
|
|
|
36
34
|
static releasePush(inst: MaskPushInstruction): void;
|
|
37
35
|
static releasePop(inst: MaskPopInstruction): void;
|
|
38
36
|
/**
|
|
39
|
-
*
|
|
40
|
-
* Returns true if a scissor was used (caller must call executePopScissor).
|
|
37
|
+
* Pushes a rectangular clip and reports whether it used the scissor path.
|
|
41
38
|
*/
|
|
42
39
|
executeScrollRectPush(inst: MaskPushInstruction, buffer: WebGLRenderBuffer): boolean;
|
|
43
40
|
executeScrollRectPop(buffer: WebGLRenderBuffer, usedScissor: boolean): void;
|
|
44
41
|
/**
|
|
45
|
-
*
|
|
46
|
-
*
|
|
47
|
-
* Allocates an offscreen buffer and activates it via pushBuffer so that
|
|
48
|
-
* all subsequent leaf instructions (the masked subtree) draw into it.
|
|
49
|
-
* The mask object itself is rendered separately in executeClipPop because
|
|
50
|
-
* it is not part of the main InstructionSet.
|
|
51
|
-
*
|
|
52
|
-
* Returns the offscreen buffer, or undefined if the object has zero bounds.
|
|
42
|
+
* Activates an offscreen buffer when object masking requires compositing.
|
|
53
43
|
*/
|
|
54
44
|
executeClipPush(inst: MaskPushInstruction, buffer: WebGLRenderBuffer): WebGLRenderBuffer | undefined;
|
|
45
|
+
/**
|
|
46
|
+
* Applies an object mask and composites the clipped subtree into its parent.
|
|
47
|
+
* Mask and display buffers are flushed before their textures are sampled or
|
|
48
|
+
* returned to the pool so later effects cannot overwrite pending input.
|
|
49
|
+
*/
|
|
55
50
|
executeClipPop(inst: MaskPopInstruction, buffer: WebGLRenderBuffer, displayBuffer: WebGLRenderBuffer | undefined): void;
|
|
56
51
|
}
|
|
57
52
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MaskPipe.d.ts","sourceRoot":"","sources":["../../../../src/kurot/player/pipes/MaskPipe.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAEpE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AACvE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAKnD,KAAK,cAAc,GAAG,CAAC,GAAG,EAAE,aAAa,EAAE,MAAM,EAAE,iBAAiB,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"MaskPipe.d.ts","sourceRoot":"","sources":["../../../../src/kurot/player/pipes/MaskPipe.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAEpE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AACvE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAKnD,KAAK,cAAc,GAAG,CAAC,GAAG,EAAE,aAAa,EAAE,MAAM,EAAE,iBAAiB,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;AAEhH,MAAM,WAAW,mBAAoB,SAAQ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W,EAAE,OAAO,GAAG,IAAI;IAQlF;;OAEG;IACI,eAAe,CACrB,IAAI,EAAE,mBAAmB,EACzB,MAAM,EAAE,iBAAiB,GACvB,iBAAiB,GAAG,SAAS;IAmChC;;;;OAIG;IACI,cAAc,CACpB,IAAI,EAAE,kBAAkB,EACxB,MAAM,EAAE,iBAAiB,EACzB,aAAa,EAAE,iBAAiB,GAAG,SAAS,GAC1C,IAAI;CAqGP"}
|
|
@@ -1,12 +1,8 @@
|
|
|
1
1
|
import { Matrix } from '../../geom/Matrix.js';
|
|
2
2
|
import { WebGLRenderBuffer as WGLBuf } from '../webgl/WebGLRenderBuffer.js';
|
|
3
3
|
const INSTRUCTION_POOL_LIMIT = 256;
|
|
4
|
-
// ── Pipe ──────────────────────────────────────────────────────────────────────
|
|
5
4
|
/**
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* Mirrors the old WebGLRenderer._drawWithClip() and _drawWithScrollRect()
|
|
9
|
-
* logic as a push/pop instruction pair.
|
|
5
|
+
* Renders masks and clipping regions through paired push and pop instructions.
|
|
10
6
|
*/
|
|
11
7
|
export class MaskPipe {
|
|
12
8
|
// ── Static fields ─────────────────────────────────────────────────────────
|
|
@@ -14,18 +10,15 @@ export class MaskPipe {
|
|
|
14
10
|
static POP_ID = 'maskPop';
|
|
15
11
|
static _pushPool = [];
|
|
16
12
|
static _popPool = [];
|
|
17
|
-
//
|
|
13
|
+
// ── Instance fields ───────────────────────────────────────────────────────
|
|
18
14
|
_drawMaskObject;
|
|
19
15
|
// ── Constructor ───────────────────────────────────────────────────────────
|
|
20
16
|
constructor(drawMaskObject) {
|
|
21
17
|
this._drawMaskObject = drawMaskObject;
|
|
22
18
|
}
|
|
23
|
-
// ──
|
|
24
|
-
addToInstructionSet(_renderable, _set) {
|
|
25
|
-
// Added by the renderer traversal, not here.
|
|
26
|
-
}
|
|
19
|
+
// ── Public methods ────────────────────────────────────────────────────────
|
|
20
|
+
addToInstructionSet(_renderable, _set) { }
|
|
27
21
|
updateRenderable(_renderable) { }
|
|
28
|
-
// ── Factory helpers ───────────────────────────────────────────────────────
|
|
29
22
|
static makePush(renderable, offsetX, offsetY) {
|
|
30
23
|
const inst = MaskPipe._pushPool.pop();
|
|
31
24
|
if (inst) {
|
|
@@ -33,6 +26,7 @@ export class MaskPipe {
|
|
|
33
26
|
inst.offsetX = offsetX;
|
|
34
27
|
inst.offsetY = offsetY;
|
|
35
28
|
inst.isScrollRect = undefined;
|
|
29
|
+
inst.savedBlendMode = undefined;
|
|
36
30
|
return inst;
|
|
37
31
|
}
|
|
38
32
|
return { renderPipeId: 'maskPush', renderable, offsetX, offsetY };
|
|
@@ -57,10 +51,8 @@ export class MaskPipe {
|
|
|
57
51
|
if (MaskPipe._popPool.length < INSTRUCTION_POOL_LIMIT)
|
|
58
52
|
MaskPipe._popPool.push(inst);
|
|
59
53
|
}
|
|
60
|
-
// ── Execute ───────────────────────────────────────────────────────────────
|
|
61
54
|
/**
|
|
62
|
-
*
|
|
63
|
-
* Returns true if a scissor was used (caller must call executePopScissor).
|
|
55
|
+
* Pushes a rectangular clip and reports whether it used the scissor path.
|
|
64
56
|
*/
|
|
65
57
|
executeScrollRectPush(inst, buffer) {
|
|
66
58
|
const { renderable } = inst;
|
|
@@ -70,23 +62,17 @@ export class MaskPipe {
|
|
|
70
62
|
}
|
|
71
63
|
const m = buffer.globalMatrix;
|
|
72
64
|
if (buffer.hasScissor || m.b !== 0 || m.c !== 0) {
|
|
73
|
-
// Stencil path: offsetX/Y are already baked into m.tx/ty via _applyTransform,
|
|
74
|
-
// so pass rect coords directly (no extra offset needed).
|
|
75
65
|
buffer.context.pushMask(rect.x, rect.y, rect.width, rect.height);
|
|
76
|
-
return false;
|
|
66
|
+
return false;
|
|
77
67
|
}
|
|
78
68
|
const a = m.a, d = m.d, tx = m.tx, ty = m.ty;
|
|
79
|
-
// The scissor rectangle is the viewport's screen-space position and size.
|
|
80
|
-
// rect.x/y is the content scroll offset (already applied to child offsets
|
|
81
|
-
// in _buildScrollRect via ox -= rect.x / oy -= rect.y), NOT a screen offset.
|
|
82
|
-
// So we scissor at (0,0,rect.width,rect.height) in local space.
|
|
83
69
|
const xMax = rect.width, yMax = rect.height;
|
|
84
70
|
const minX = Math.min(tx, a * xMax + tx);
|
|
85
71
|
const maxX = Math.max(tx, a * xMax + tx);
|
|
86
72
|
const minY = Math.min(ty, d * yMax + ty);
|
|
87
73
|
const maxY = Math.max(ty, d * yMax + ty);
|
|
88
74
|
buffer.context.enableScissor(minX, -maxY + buffer.height, maxX - minX, maxY - minY);
|
|
89
|
-
return true;
|
|
75
|
+
return true;
|
|
90
76
|
}
|
|
91
77
|
executeScrollRectPop(buffer, usedScissor) {
|
|
92
78
|
if (usedScissor) {
|
|
@@ -97,20 +83,16 @@ export class MaskPipe {
|
|
|
97
83
|
}
|
|
98
84
|
}
|
|
99
85
|
/**
|
|
100
|
-
*
|
|
101
|
-
*
|
|
102
|
-
* Allocates an offscreen buffer and activates it via pushBuffer so that
|
|
103
|
-
* all subsequent leaf instructions (the masked subtree) draw into it.
|
|
104
|
-
* The mask object itself is rendered separately in executeClipPop because
|
|
105
|
-
* it is not part of the main InstructionSet.
|
|
106
|
-
*
|
|
107
|
-
* Returns the offscreen buffer, or undefined if the object has zero bounds.
|
|
86
|
+
* Activates an offscreen buffer when object masking requires compositing.
|
|
108
87
|
*/
|
|
109
88
|
executeClipPush(inst, buffer) {
|
|
110
89
|
const { renderable } = inst;
|
|
111
90
|
const scrollRect = renderable.$scrollRect ?? renderable.$maskRect;
|
|
112
|
-
// Simple case: no mask object, no $children — stencil/scissor only.
|
|
113
91
|
if (!renderable.$mask && (!renderable.$children || renderable.$children.length === 0)) {
|
|
92
|
+
if (renderable.$blendMode !== 0) {
|
|
93
|
+
inst.savedBlendMode = buffer.context.currentBlendMode;
|
|
94
|
+
buffer.context.setGlobalCompositeOperation(({ 1: 'lighter', 2: 'destination-out' }[renderable.$blendMode] ?? 'source-over'));
|
|
95
|
+
}
|
|
114
96
|
if (scrollRect) {
|
|
115
97
|
buffer.context.pushMask(scrollRect.x + inst.offsetX, scrollRect.y + inst.offsetY, scrollRect.width, scrollRect.height);
|
|
116
98
|
}
|
|
@@ -122,12 +104,15 @@ export class MaskPipe {
|
|
|
122
104
|
}
|
|
123
105
|
const bw = bounds.width;
|
|
124
106
|
const bh = bounds.height;
|
|
125
|
-
// Allocate and activate the offscreen buffer.
|
|
126
|
-
// All subsequent draw calls (the masked subtree instructions) will land here.
|
|
127
107
|
const displayBuffer = WGLBuf.create(buffer.context, bw, bh);
|
|
128
108
|
displayBuffer.context.pushBuffer(displayBuffer);
|
|
129
109
|
return displayBuffer;
|
|
130
110
|
}
|
|
111
|
+
/**
|
|
112
|
+
* Applies an object mask and composites the clipped subtree into its parent.
|
|
113
|
+
* Mask and display buffers are flushed before their textures are sampled or
|
|
114
|
+
* returned to the pool so later effects cannot overwrite pending input.
|
|
115
|
+
*/
|
|
131
116
|
executeClipPop(inst, buffer, displayBuffer) {
|
|
132
117
|
const { renderable, push } = inst;
|
|
133
118
|
const { offsetX, offsetY } = push;
|
|
@@ -137,10 +122,12 @@ export class MaskPipe {
|
|
|
137
122
|
? ({ 0: 'source-over', 1: 'lighter', 2: 'destination-out' }[renderable.$blendMode] ?? 'source-over')
|
|
138
123
|
: 'source-over';
|
|
139
124
|
if (!displayBuffer) {
|
|
140
|
-
// Simple stencil path — just pop the mask.
|
|
141
125
|
if (scrollRect) {
|
|
142
126
|
buffer.context.popMask();
|
|
143
127
|
}
|
|
128
|
+
if (push.savedBlendMode !== undefined) {
|
|
129
|
+
buffer.context.setGlobalCompositeOperation(push.savedBlendMode);
|
|
130
|
+
}
|
|
144
131
|
return;
|
|
145
132
|
}
|
|
146
133
|
const bounds = renderable.$getOriginalBounds();
|
|
@@ -148,7 +135,6 @@ export class MaskPipe {
|
|
|
148
135
|
const by = bounds.y;
|
|
149
136
|
const bw = bounds.width;
|
|
150
137
|
const bh = bounds.height;
|
|
151
|
-
// Apply the mask object (if any) to the displayBuffer via destination-in.
|
|
152
138
|
const mask = renderable.$mask;
|
|
153
139
|
if (mask) {
|
|
154
140
|
const maskBuffer = WGLBuf.create(buffer.context, bw, bh);
|
|
@@ -159,27 +145,22 @@ export class MaskPipe {
|
|
|
159
145
|
maskMatrix.translate(-bx, -by);
|
|
160
146
|
maskBuffer.setTransform(maskMatrix.a, maskMatrix.b, maskMatrix.c, maskMatrix.d, maskMatrix.tx, maskMatrix.ty);
|
|
161
147
|
Matrix.release(maskMatrix);
|
|
162
|
-
// Render the mask shape directly — it is not in the InstructionSet.
|
|
163
148
|
this._drawMaskObject(mask, maskBuffer, 0, 0);
|
|
164
149
|
maskBuffer.context.popBuffer();
|
|
165
|
-
// Finish producing the mask texture before sampling it from the
|
|
166
|
-
// destination-in pass. This also isolates the framebuffer switch from
|
|
167
|
-
// the blend-state commands used by the composite.
|
|
168
150
|
maskBuffer.context.flush();
|
|
151
|
+
displayBuffer.setTransform(1, 0, 0, 1, 0, 0);
|
|
152
|
+
displayBuffer.globalAlpha = 1;
|
|
153
|
+
displayBuffer.globalTintColor = 0xffffff;
|
|
169
154
|
displayBuffer.context.setGlobalCompositeOperation('destination-in');
|
|
170
155
|
const mw = maskBuffer.rootRenderTarget.width;
|
|
171
156
|
const mh = maskBuffer.rootRenderTarget.height;
|
|
172
157
|
if (maskBuffer.rootRenderTarget.texture) {
|
|
173
158
|
displayBuffer.context.drawFramebufferTexture(maskBuffer.rootRenderTarget.texture, mw, mh, 0, 0, mw, mh);
|
|
174
159
|
}
|
|
175
|
-
// Execute destination-in while displayBuffer is still the active target.
|
|
176
|
-
// Deferring this past the source-over restoration can render the mask
|
|
177
|
-
// texture as an ordinary white child instead of clipping the content.
|
|
178
160
|
displayBuffer.context.flush();
|
|
179
161
|
displayBuffer.context.setGlobalCompositeOperation('source-over');
|
|
180
162
|
WGLBuf.release(maskBuffer);
|
|
181
163
|
}
|
|
182
|
-
// Deactivate the offscreen buffer, restoring the main buffer as active.
|
|
183
164
|
displayBuffer.context.popBuffer();
|
|
184
165
|
const prevBlend = buffer.context.currentBlendMode;
|
|
185
166
|
if (hasBlend)
|
|
@@ -196,9 +177,6 @@ export class MaskPipe {
|
|
|
196
177
|
buffer.context.popMask();
|
|
197
178
|
if (hasBlend)
|
|
198
179
|
buffer.context.setGlobalCompositeOperation(prevBlend);
|
|
199
|
-
// The composite samples displayBuffer's texture. Finish that draw before
|
|
200
|
-
// returning the buffer to the pool, where a later effect may resize and
|
|
201
|
-
// overwrite the same framebuffer texture during this frame.
|
|
202
180
|
buffer.context.flush();
|
|
203
181
|
WGLBuf.release(displayBuffer);
|
|
204
182
|
}
|