jassub 2.3.3 → 2.4.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.
- package/README.md +3 -3
- package/dist/worker/renderers/2d-renderer.d.ts +16 -0
- package/dist/worker/renderers/2d-renderer.js +71 -0
- package/dist/worker/renderers/2d-renderer.js.map +1 -0
- package/dist/worker/renderers/webgl1-renderer.d.ts +38 -0
- package/dist/worker/renderers/webgl1-renderer.js +363 -0
- package/dist/worker/renderers/webgl1-renderer.js.map +1 -0
- package/dist/worker/renderers/webgl2-renderer.d.ts +32 -0
- package/dist/worker/renderers/webgl2-renderer.js +361 -0
- package/dist/worker/renderers/webgl2-renderer.js.map +1 -0
- package/dist/worker/renderers/webgpu-renderer.d.ts +50 -0
- package/dist/worker/renderers/webgpu-renderer.js +404 -0
- package/dist/worker/renderers/webgpu-renderer.js.map +1 -0
- package/dist/worker/util.d.ts +23 -0
- package/dist/worker/util.js +57 -0
- package/dist/worker/util.js.map +1 -1
- package/dist/worker/worker.d.ts +4 -2
- package/dist/worker/worker.js +19 -5
- package/dist/worker/worker.js.map +1 -1
- package/package.json +1 -1
- package/src/worker/renderers/2d-renderer.ts +81 -0
- package/src/worker/renderers/webgl1-renderer.ts +445 -0
- package/src/worker/{webgl-renderer.ts → renderers/webgl2-renderer.ts} +2 -65
- package/src/worker/{webgpu-renderer.ts → renderers/webgpu-renderer.ts} +1 -1
- package/src/worker/util.ts +64 -0
- package/src/worker/worker.ts +17 -5
package/README.md
CHANGED
|
@@ -38,11 +38,11 @@ The
|
|
|
38
38
|
|
|
39
39
|
headers are recommended to use this library, as it uses SharedArrayBuffer for multi-threading, but if you can't set them, it will fallback automatically to work in single-threaded mode. Firefox doesn't support threading so they are not required there.
|
|
40
40
|
|
|
41
|
-
At minimum WASM +
|
|
41
|
+
At minimum WASM + TextDecoder + OffscreenCanvas + Web Workers + Proxy + AbortController + Fetch + Promise + getVideoPlaybackQuality/requestVideoFrameCallback are required for JASSUB to work.
|
|
42
42
|
|
|
43
43
|
<!--
|
|
44
44
|
WASM: 57 11 52 / 51 11 47
|
|
45
|
-
WebGL2: 56 15 51 / 43 10.1 42
|
|
45
|
+
WebGL2: 56 15 51 / 43 10.1 42 // not necessary anymore as it falls back to WebGL1/Canvas2D
|
|
46
46
|
TextDecoder: 38 10.1 20 / 38 10.1 19
|
|
47
47
|
OffscreenCanvas: 69 17 105 / 58 16.2 44
|
|
48
48
|
BigInt: 67 15 68
|
|
@@ -204,7 +204,7 @@ If you want to support even older engines, then please check the [v1.8.8 tag](ht
|
|
|
204
204
|
[p]npm i jassub@1.8.8
|
|
205
205
|
```
|
|
206
206
|
|
|
207
|
-
Support for older browsers (without
|
|
207
|
+
Support for older browsers (without OffscreenCanvas, WebAssembly threads, etc) has been dropped in v2.0.0 and later.
|
|
208
208
|
|
|
209
209
|
# How to build?
|
|
210
210
|
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { ASSImage } from '../util.ts';
|
|
2
|
+
export declare class Canvas2DRenderer {
|
|
3
|
+
canvas: OffscreenCanvas | null;
|
|
4
|
+
ctx: OffscreenCanvasRenderingContext2D | null;
|
|
5
|
+
bufferCanvas: OffscreenCanvas;
|
|
6
|
+
bufferCtx: OffscreenCanvasRenderingContext2D | null;
|
|
7
|
+
_scheduledResize?: {
|
|
8
|
+
width: number;
|
|
9
|
+
height: number;
|
|
10
|
+
};
|
|
11
|
+
resizeCanvas(width: number, height: number): void;
|
|
12
|
+
setCanvas(canvas: OffscreenCanvas): void;
|
|
13
|
+
setColorMatrix(subtitleColorSpace?: 'BT601' | 'BT709' | 'SMPTE240M' | 'FCC', videoColorSpace?: 'BT601' | 'BT709'): void;
|
|
14
|
+
render(images: ASSImage[], heap: Uint8Array): void;
|
|
15
|
+
destroy(): void;
|
|
16
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
export class Canvas2DRenderer {
|
|
2
|
+
canvas = null;
|
|
3
|
+
ctx = null;
|
|
4
|
+
bufferCanvas = new OffscreenCanvas(1, 1);
|
|
5
|
+
bufferCtx = this.bufferCanvas.getContext('2d', {
|
|
6
|
+
alpha: true,
|
|
7
|
+
desynchronized: true,
|
|
8
|
+
willReadFrequently: false
|
|
9
|
+
});
|
|
10
|
+
_scheduledResize;
|
|
11
|
+
resizeCanvas(width, height) {
|
|
12
|
+
if (width <= 0 || height <= 0)
|
|
13
|
+
return;
|
|
14
|
+
this._scheduledResize = { width, height };
|
|
15
|
+
}
|
|
16
|
+
setCanvas(canvas) {
|
|
17
|
+
this.canvas = canvas;
|
|
18
|
+
this.ctx = canvas.getContext('2d', {
|
|
19
|
+
alpha: true,
|
|
20
|
+
desynchronized: true,
|
|
21
|
+
willReadFrequently: false
|
|
22
|
+
});
|
|
23
|
+
if (!this.ctx)
|
|
24
|
+
throw new Error('Could not get 2D context');
|
|
25
|
+
}
|
|
26
|
+
setColorMatrix(subtitleColorSpace, videoColorSpace) { }
|
|
27
|
+
// this is horribly inefficient, but it's a fallback for systems without a GPU, this is the least of their problems
|
|
28
|
+
render(images, heap) {
|
|
29
|
+
if (!this.ctx || !this.canvas)
|
|
30
|
+
return;
|
|
31
|
+
if (this._scheduledResize) {
|
|
32
|
+
const { width, height } = this._scheduledResize;
|
|
33
|
+
this._scheduledResize = undefined;
|
|
34
|
+
this.canvas.width = width;
|
|
35
|
+
this.canvas.height = height;
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
this.ctx.clearRect(0, 0, this.canvas.width, this.canvas.height);
|
|
39
|
+
}
|
|
40
|
+
for (const img of images) {
|
|
41
|
+
if (img.w <= 0 || img.h <= 0)
|
|
42
|
+
continue;
|
|
43
|
+
const imageData = new ImageData(img.w, img.h);
|
|
44
|
+
const pixels = new Uint32Array(imageData.data.buffer);
|
|
45
|
+
const color = ((img.color << 8) & 0xff0000) | ((img.color >> 8) & 0xff00) | ((img.color >> 24) & 0xff);
|
|
46
|
+
const alpha = (255 - (img.color & 255)) / 255;
|
|
47
|
+
const stride = img.stride;
|
|
48
|
+
const h = img.h;
|
|
49
|
+
const w = img.w;
|
|
50
|
+
for (let y = h + 1, pos = img.bitmap, res = 0; --y; pos += stride) {
|
|
51
|
+
for (let z = 0; z < w; ++z, ++res) {
|
|
52
|
+
const k = heap[pos + z];
|
|
53
|
+
if (k !== 0)
|
|
54
|
+
pixels[res] = ((alpha * k) << 24) | color;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
// Draw the ImageData to canvas at the destination position
|
|
58
|
+
this.bufferCanvas.width = w;
|
|
59
|
+
this.bufferCanvas.height = h;
|
|
60
|
+
this.bufferCtx.putImageData(imageData, 0, 0);
|
|
61
|
+
this.ctx.drawImage(this.bufferCanvas, img.dst_x, img.dst_y);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
destroy() {
|
|
65
|
+
this.ctx = null;
|
|
66
|
+
this.canvas = null;
|
|
67
|
+
this.bufferCtx = null;
|
|
68
|
+
this.bufferCanvas = null;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
//# sourceMappingURL=2d-renderer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"2d-renderer.js","sourceRoot":"","sources":["../../../src/worker/renderers/2d-renderer.ts"],"names":[],"mappings":"AAGA,MAAM,OAAO,gBAAgB;IAC3B,MAAM,GAA2B,IAAI,CAAA;IACrC,GAAG,GAA6C,IAAI,CAAA;IACpD,YAAY,GAAG,IAAI,eAAe,CAAC,CAAC,EAAE,CAAC,CAAC,CAAA;IACxC,SAAS,GAAG,IAAI,CAAC,YAAY,CAAC,UAAU,CAAC,IAAI,EAAE;QAC7C,KAAK,EAAE,IAAI;QACX,cAAc,EAAE,IAAI;QACpB,kBAAkB,EAAE,KAAK;KAC1B,CAAC,CAAA;IAEF,gBAAgB,CAAoC;IAEpD,YAAY,CAAE,KAAa,EAAE,MAAc;QACzC,IAAI,KAAK,IAAI,CAAC,IAAI,MAAM,IAAI,CAAC;YAAE,OAA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C,MAAM,GAAG,CAAC,CAAA;YAC5B,IAAI,CAAC,SAAU,CAAC,YAAY,CAAC,SAAS,EAAE,CAAC,EAAE,CAAC,CAAC,CAAA;YAC7C,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC,IAAI,CAAC,YAAY,EAAE,GAAG,CAAC,KAAK,EAAE,GAAG,CAAC,KAAK,CAAC,CAAA;QAC7D,CAAC;IACH,CAAC;IAED,OAAO;QACL,IAAI,CAAC,GAAG,GAAG,IAAI,CAAA;QACf,IAAI,CAAC,MAAM,GAAG,IAAI,CAAA;QAClB,IAAI,CAAC,SAAS,GAAG,IAAK,CAAA;QACtB,IAAI,CAAC,YAAY,GAAG,IAAK,CAAA;IAC3B,CAAC;CACF"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { type ASSImage } from '../util.ts';
|
|
2
|
+
export declare class WebGL1Renderer {
|
|
3
|
+
canvas: OffscreenCanvas | null;
|
|
4
|
+
gl: WebGLRenderingContext | null;
|
|
5
|
+
program: WebGLProgram | null;
|
|
6
|
+
instancedArraysExt: ANGLE_instanced_arrays | null;
|
|
7
|
+
u_resolution: WebGLUniformLocation | null;
|
|
8
|
+
u_tex: WebGLUniformLocation | null;
|
|
9
|
+
u_colorMatrix: WebGLUniformLocation | null;
|
|
10
|
+
u_texDimensions: WebGLUniformLocation | null;
|
|
11
|
+
a_quadPos: number;
|
|
12
|
+
a_destRect: number;
|
|
13
|
+
a_color: number;
|
|
14
|
+
a_texLayer: number;
|
|
15
|
+
quadPosBuffer: WebGLBuffer | null;
|
|
16
|
+
instanceDestRectBuffer: WebGLBuffer | null;
|
|
17
|
+
instanceColorBuffer: WebGLBuffer | null;
|
|
18
|
+
instanceTexLayerBuffer: WebGLBuffer | null;
|
|
19
|
+
instanceDestRectData: Float32Array;
|
|
20
|
+
instanceColorData: Float32Array;
|
|
21
|
+
instanceTexLayerData: Float32Array;
|
|
22
|
+
textureCache: Map<number, WebGLTexture>;
|
|
23
|
+
textureWidth: number;
|
|
24
|
+
textureHeight: number;
|
|
25
|
+
colorMatrix: Float32Array;
|
|
26
|
+
constructor();
|
|
27
|
+
_scheduledResize?: {
|
|
28
|
+
width: number;
|
|
29
|
+
height: number;
|
|
30
|
+
};
|
|
31
|
+
resizeCanvas(width: number, height: number): void;
|
|
32
|
+
setCanvas(canvas: OffscreenCanvas): void;
|
|
33
|
+
createShader(type: number, source: string): WebGLShader | null;
|
|
34
|
+
setColorMatrix(subtitleColorSpace?: 'BT601' | 'BT709' | 'SMPTE240M' | 'FCC', videoColorSpace?: 'BT601' | 'BT709'): void;
|
|
35
|
+
createTexture(width: number, height: number): WebGLTexture;
|
|
36
|
+
render(images: ASSImage[], heap: Uint8Array): void;
|
|
37
|
+
destroy(): void;
|
|
38
|
+
}
|
|
@@ -0,0 +1,363 @@
|
|
|
1
|
+
import { colorMatrixConversionMap, IDENTITY_MATRIX } from "../util.js";
|
|
2
|
+
// GLSL ES 1.0 Vertex Shader with Instancing (using extension)
|
|
3
|
+
const VERTEX_SHADER = /* glsl */ `
|
|
4
|
+
precision mediump float;
|
|
5
|
+
|
|
6
|
+
// Quad position attribute (0,0), (1,0), (0,1), (1,0), (1,1), (0,1)
|
|
7
|
+
attribute vec2 a_quadPos;
|
|
8
|
+
|
|
9
|
+
uniform vec2 u_resolution;
|
|
10
|
+
|
|
11
|
+
// Instance attributes
|
|
12
|
+
attribute vec4 a_destRect; // x, y, w, h
|
|
13
|
+
attribute vec4 a_color; // r, g, b, a
|
|
14
|
+
attribute float a_texLayer;
|
|
15
|
+
|
|
16
|
+
varying vec2 v_destXY;
|
|
17
|
+
varying vec4 v_color;
|
|
18
|
+
varying vec2 v_texSize;
|
|
19
|
+
varying float v_texLayer;
|
|
20
|
+
varying vec2 v_texCoord;
|
|
21
|
+
|
|
22
|
+
void main() {
|
|
23
|
+
vec2 pixelPos = a_destRect.xy + a_quadPos * a_destRect.zw;
|
|
24
|
+
vec2 clipPos = (pixelPos / u_resolution) * 2.0 - 1.0;
|
|
25
|
+
clipPos.y = -clipPos.y;
|
|
26
|
+
|
|
27
|
+
gl_Position = vec4(clipPos, 0.0, 1.0);
|
|
28
|
+
v_destXY = a_destRect.xy;
|
|
29
|
+
v_color = a_color;
|
|
30
|
+
v_texSize = a_destRect.zw;
|
|
31
|
+
v_texLayer = a_texLayer;
|
|
32
|
+
v_texCoord = a_quadPos;
|
|
33
|
+
}
|
|
34
|
+
`;
|
|
35
|
+
// GLSL ES 1.0 Fragment Shader
|
|
36
|
+
// WebGL1 doesn't support texture arrays or texelFetch, so we use individual textures
|
|
37
|
+
const FRAGMENT_SHADER = /* glsl */ `
|
|
38
|
+
precision mediump float;
|
|
39
|
+
|
|
40
|
+
uniform sampler2D u_tex;
|
|
41
|
+
uniform mat3 u_colorMatrix;
|
|
42
|
+
uniform vec2 u_resolution;
|
|
43
|
+
uniform vec2 u_texDimensions; // Actual texture dimensions
|
|
44
|
+
|
|
45
|
+
varying vec2 v_destXY;
|
|
46
|
+
varying vec4 v_color;
|
|
47
|
+
varying vec2 v_texSize;
|
|
48
|
+
varying float v_texLayer;
|
|
49
|
+
varying vec2 v_texCoord;
|
|
50
|
+
|
|
51
|
+
void main() {
|
|
52
|
+
// v_texCoord is in 0-1 range for the quad
|
|
53
|
+
// We need to map it to the actual image size within the texture
|
|
54
|
+
// The image occupies only (v_texSize.x / u_texDimensions.x, v_texSize.y / u_texDimensions.y) of the texture
|
|
55
|
+
vec2 normalizedImageSize = v_texSize / u_texDimensions;
|
|
56
|
+
vec2 texCoord = v_texCoord * normalizedImageSize;
|
|
57
|
+
|
|
58
|
+
// Sample texture (r channel contains mask)
|
|
59
|
+
float mask = texture2D(u_tex, texCoord).r;
|
|
60
|
+
|
|
61
|
+
// Apply color matrix conversion (identity if no conversion needed)
|
|
62
|
+
vec3 correctedColor = u_colorMatrix * v_color.rgb;
|
|
63
|
+
|
|
64
|
+
// libass color alpha: 0 = opaque, 255 = transparent (inverted)
|
|
65
|
+
float colorAlpha = 1.0 - v_color.a;
|
|
66
|
+
|
|
67
|
+
// Final alpha = colorAlpha * mask
|
|
68
|
+
float a = colorAlpha * mask;
|
|
69
|
+
|
|
70
|
+
// Premultiplied alpha output
|
|
71
|
+
gl_FragColor = vec4(correctedColor * a, a);
|
|
72
|
+
}
|
|
73
|
+
`;
|
|
74
|
+
// Configuration
|
|
75
|
+
const MAX_INSTANCES = 256; // Maximum instances per draw call
|
|
76
|
+
export class WebGL1Renderer {
|
|
77
|
+
canvas = null;
|
|
78
|
+
gl = null;
|
|
79
|
+
program = null;
|
|
80
|
+
// Extensions
|
|
81
|
+
instancedArraysExt = null;
|
|
82
|
+
// Uniform locations
|
|
83
|
+
u_resolution = null;
|
|
84
|
+
u_tex = null;
|
|
85
|
+
u_colorMatrix = null;
|
|
86
|
+
u_texDimensions = null;
|
|
87
|
+
// Attribute locations
|
|
88
|
+
a_quadPos = -1;
|
|
89
|
+
a_destRect = -1;
|
|
90
|
+
a_color = -1;
|
|
91
|
+
a_texLayer = -1;
|
|
92
|
+
// Quad vertex buffer (shared for all instances)
|
|
93
|
+
quadPosBuffer = null;
|
|
94
|
+
// Instance attribute buffers
|
|
95
|
+
instanceDestRectBuffer = null;
|
|
96
|
+
instanceColorBuffer = null;
|
|
97
|
+
instanceTexLayerBuffer = null;
|
|
98
|
+
// Instance data arrays
|
|
99
|
+
instanceDestRectData;
|
|
100
|
+
instanceColorData;
|
|
101
|
+
instanceTexLayerData;
|
|
102
|
+
// Texture cache (since WebGL1 doesn't support texture arrays)
|
|
103
|
+
textureCache = new Map();
|
|
104
|
+
textureWidth = 0;
|
|
105
|
+
textureHeight = 0;
|
|
106
|
+
colorMatrix = IDENTITY_MATRIX;
|
|
107
|
+
constructor() {
|
|
108
|
+
this.instanceDestRectData = new Float32Array(MAX_INSTANCES * 4);
|
|
109
|
+
this.instanceColorData = new Float32Array(MAX_INSTANCES * 4);
|
|
110
|
+
this.instanceTexLayerData = new Float32Array(MAX_INSTANCES);
|
|
111
|
+
}
|
|
112
|
+
_scheduledResize;
|
|
113
|
+
resizeCanvas(width, height) {
|
|
114
|
+
// WebGL doesn't allow 0-sized canvases
|
|
115
|
+
if (width <= 0 || height <= 0)
|
|
116
|
+
return;
|
|
117
|
+
this._scheduledResize = { width, height };
|
|
118
|
+
}
|
|
119
|
+
setCanvas(canvas) {
|
|
120
|
+
this.canvas = canvas;
|
|
121
|
+
this.gl = canvas.getContext('webgl', {
|
|
122
|
+
alpha: true,
|
|
123
|
+
premultipliedAlpha: true,
|
|
124
|
+
antialias: false,
|
|
125
|
+
depth: false,
|
|
126
|
+
preserveDrawingBuffer: false,
|
|
127
|
+
stencil: false,
|
|
128
|
+
desynchronized: true,
|
|
129
|
+
powerPreference: 'high-performance'
|
|
130
|
+
});
|
|
131
|
+
if (!this.gl) {
|
|
132
|
+
throw new Error('Could not get WebGL context');
|
|
133
|
+
}
|
|
134
|
+
// Get instanced arrays extension (required for instancing in WebGL1)
|
|
135
|
+
this.instancedArraysExt = this.gl.getExtension('ANGLE_instanced_arrays');
|
|
136
|
+
if (!this.instancedArraysExt) {
|
|
137
|
+
throw new Error('ANGLE_instanced_arrays extension not supported');
|
|
138
|
+
}
|
|
139
|
+
// Create shaders
|
|
140
|
+
const vertexShader = this.createShader(this.gl.VERTEX_SHADER, VERTEX_SHADER);
|
|
141
|
+
const fragmentShader = this.createShader(this.gl.FRAGMENT_SHADER, FRAGMENT_SHADER);
|
|
142
|
+
if (!vertexShader || !fragmentShader) {
|
|
143
|
+
throw new Error('Failed to create shaders');
|
|
144
|
+
}
|
|
145
|
+
// Create program
|
|
146
|
+
this.program = this.gl.createProgram();
|
|
147
|
+
this.gl.attachShader(this.program, vertexShader);
|
|
148
|
+
this.gl.attachShader(this.program, fragmentShader);
|
|
149
|
+
this.gl.linkProgram(this.program);
|
|
150
|
+
if (!this.gl.getProgramParameter(this.program, this.gl.LINK_STATUS)) {
|
|
151
|
+
const info = this.gl.getProgramInfoLog(this.program);
|
|
152
|
+
throw new Error('Failed to link program: ' + info);
|
|
153
|
+
}
|
|
154
|
+
// Get uniform locations
|
|
155
|
+
this.u_resolution = this.gl.getUniformLocation(this.program, 'u_resolution');
|
|
156
|
+
this.u_tex = this.gl.getUniformLocation(this.program, 'u_tex');
|
|
157
|
+
this.u_colorMatrix = this.gl.getUniformLocation(this.program, 'u_colorMatrix');
|
|
158
|
+
this.u_texDimensions = this.gl.getUniformLocation(this.program, 'u_texDimensions');
|
|
159
|
+
// Get attribute locations
|
|
160
|
+
this.a_quadPos = this.gl.getAttribLocation(this.program, 'a_quadPos');
|
|
161
|
+
this.a_destRect = this.gl.getAttribLocation(this.program, 'a_destRect');
|
|
162
|
+
this.a_color = this.gl.getAttribLocation(this.program, 'a_color');
|
|
163
|
+
this.a_texLayer = this.gl.getAttribLocation(this.program, 'a_texLayer');
|
|
164
|
+
// Create quad position buffer (6 vertices for 2 triangles)
|
|
165
|
+
this.quadPosBuffer = this.gl.createBuffer();
|
|
166
|
+
this.gl.bindBuffer(this.gl.ARRAY_BUFFER, this.quadPosBuffer);
|
|
167
|
+
const quadPositions = new Float32Array([
|
|
168
|
+
0.0, 0.0,
|
|
169
|
+
1.0, 0.0,
|
|
170
|
+
0.0, 1.0,
|
|
171
|
+
1.0, 0.0,
|
|
172
|
+
1.0, 1.0,
|
|
173
|
+
0.0, 1.0
|
|
174
|
+
]);
|
|
175
|
+
this.gl.bufferData(this.gl.ARRAY_BUFFER, quadPositions, this.gl.STATIC_DRAW);
|
|
176
|
+
// Create instance attribute buffers
|
|
177
|
+
this.instanceDestRectBuffer = this.gl.createBuffer();
|
|
178
|
+
this.instanceColorBuffer = this.gl.createBuffer();
|
|
179
|
+
this.instanceTexLayerBuffer = this.gl.createBuffer();
|
|
180
|
+
// Set up vertex attributes
|
|
181
|
+
this.gl.bindBuffer(this.gl.ARRAY_BUFFER, this.quadPosBuffer);
|
|
182
|
+
this.gl.enableVertexAttribArray(this.a_quadPos);
|
|
183
|
+
this.gl.vertexAttribPointer(this.a_quadPos, 2, this.gl.FLOAT, false, 0, 0);
|
|
184
|
+
this.gl.bindBuffer(this.gl.ARRAY_BUFFER, this.instanceDestRectBuffer);
|
|
185
|
+
this.gl.enableVertexAttribArray(this.a_destRect);
|
|
186
|
+
this.gl.vertexAttribPointer(this.a_destRect, 4, this.gl.FLOAT, false, 0, 0);
|
|
187
|
+
this.instancedArraysExt.vertexAttribDivisorANGLE(this.a_destRect, 1);
|
|
188
|
+
this.gl.bindBuffer(this.gl.ARRAY_BUFFER, this.instanceColorBuffer);
|
|
189
|
+
this.gl.enableVertexAttribArray(this.a_color);
|
|
190
|
+
this.gl.vertexAttribPointer(this.a_color, 4, this.gl.FLOAT, false, 0, 0);
|
|
191
|
+
this.instancedArraysExt.vertexAttribDivisorANGLE(this.a_color, 1);
|
|
192
|
+
this.gl.bindBuffer(this.gl.ARRAY_BUFFER, this.instanceTexLayerBuffer);
|
|
193
|
+
this.gl.enableVertexAttribArray(this.a_texLayer);
|
|
194
|
+
this.gl.vertexAttribPointer(this.a_texLayer, 1, this.gl.FLOAT, false, 0, 0);
|
|
195
|
+
this.instancedArraysExt.vertexAttribDivisorANGLE(this.a_texLayer, 1);
|
|
196
|
+
// Set up blending for premultiplied alpha
|
|
197
|
+
this.gl.enable(this.gl.BLEND);
|
|
198
|
+
this.gl.blendFunc(this.gl.ONE, this.gl.ONE_MINUS_SRC_ALPHA);
|
|
199
|
+
// Use the program
|
|
200
|
+
this.gl.useProgram(this.program);
|
|
201
|
+
// Set texture unit
|
|
202
|
+
this.gl.uniform1i(this.u_tex, 0);
|
|
203
|
+
// Set initial color matrix
|
|
204
|
+
this.gl.uniformMatrix3fv(this.u_colorMatrix, false, this.colorMatrix);
|
|
205
|
+
// Set one-time GL state
|
|
206
|
+
this.gl.pixelStorei(this.gl.UNPACK_ALIGNMENT, 1);
|
|
207
|
+
this.gl.clearColor(0, 0, 0, 0);
|
|
208
|
+
this.gl.activeTexture(this.gl.TEXTURE0);
|
|
209
|
+
}
|
|
210
|
+
createShader(type, source) {
|
|
211
|
+
const shader = this.gl.createShader(type);
|
|
212
|
+
this.gl.shaderSource(shader, source);
|
|
213
|
+
this.gl.compileShader(shader);
|
|
214
|
+
if (!this.gl.getShaderParameter(shader, this.gl.COMPILE_STATUS)) {
|
|
215
|
+
const info = this.gl.getShaderInfoLog(shader);
|
|
216
|
+
console.log(info);
|
|
217
|
+
this.gl.deleteShader(shader);
|
|
218
|
+
return null;
|
|
219
|
+
}
|
|
220
|
+
return shader;
|
|
221
|
+
}
|
|
222
|
+
// Set the color matrix for color space conversion.
|
|
223
|
+
// Pass null or undefined to use identity (no conversion).
|
|
224
|
+
setColorMatrix(subtitleColorSpace, videoColorSpace) {
|
|
225
|
+
this.colorMatrix = (subtitleColorSpace && videoColorSpace && colorMatrixConversionMap[subtitleColorSpace]?.[videoColorSpace]) ?? IDENTITY_MATRIX;
|
|
226
|
+
if (this.gl && this.u_colorMatrix && this.program) {
|
|
227
|
+
this.gl.useProgram(this.program);
|
|
228
|
+
this.gl.uniformMatrix3fv(this.u_colorMatrix, false, this.colorMatrix);
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
createTexture(width, height) {
|
|
232
|
+
const texture = this.gl.createTexture();
|
|
233
|
+
this.gl.bindTexture(this.gl.TEXTURE_2D, texture);
|
|
234
|
+
// Allocate storage for texture (WebGL1 uses LUMINANCE instead of R8)
|
|
235
|
+
this.gl.texImage2D(this.gl.TEXTURE_2D, 0, this.gl.LUMINANCE, width, height, 0, this.gl.LUMINANCE, this.gl.UNSIGNED_BYTE, null);
|
|
236
|
+
// Set texture parameters
|
|
237
|
+
this.gl.texParameteri(this.gl.TEXTURE_2D, this.gl.TEXTURE_MIN_FILTER, this.gl.NEAREST);
|
|
238
|
+
this.gl.texParameteri(this.gl.TEXTURE_2D, this.gl.TEXTURE_MAG_FILTER, this.gl.NEAREST);
|
|
239
|
+
this.gl.texParameteri(this.gl.TEXTURE_2D, this.gl.TEXTURE_WRAP_S, this.gl.CLAMP_TO_EDGE);
|
|
240
|
+
this.gl.texParameteri(this.gl.TEXTURE_2D, this.gl.TEXTURE_WRAP_T, this.gl.CLAMP_TO_EDGE);
|
|
241
|
+
return texture;
|
|
242
|
+
}
|
|
243
|
+
render(images, heap) {
|
|
244
|
+
if (!this.gl || !this.program || !this.instancedArraysExt)
|
|
245
|
+
return;
|
|
246
|
+
// we scheduled a resize because changing the canvas size clears it, and we don't want it to flicker
|
|
247
|
+
// so we do it here, right before rendering
|
|
248
|
+
if (this._scheduledResize) {
|
|
249
|
+
const { width, height } = this._scheduledResize;
|
|
250
|
+
this._scheduledResize = undefined;
|
|
251
|
+
this.canvas.width = width;
|
|
252
|
+
this.canvas.height = height;
|
|
253
|
+
// Update viewport and resolution uniform
|
|
254
|
+
this.gl.viewport(0, 0, width, height);
|
|
255
|
+
this.gl.uniform2f(this.u_resolution, width, height);
|
|
256
|
+
}
|
|
257
|
+
else {
|
|
258
|
+
// Clear canvas
|
|
259
|
+
this.gl.clear(this.gl.COLOR_BUFFER_BIT);
|
|
260
|
+
}
|
|
261
|
+
// Find max dimensions needed and filter valid images
|
|
262
|
+
let maxW = this.textureWidth;
|
|
263
|
+
let maxH = this.textureHeight;
|
|
264
|
+
const validImages = [];
|
|
265
|
+
for (const img of images) {
|
|
266
|
+
if (img.w <= 0 || img.h <= 0)
|
|
267
|
+
continue;
|
|
268
|
+
validImages.push(img);
|
|
269
|
+
if (img.w > maxW)
|
|
270
|
+
maxW = img.w;
|
|
271
|
+
if (img.h > maxH)
|
|
272
|
+
maxH = img.h;
|
|
273
|
+
}
|
|
274
|
+
if (validImages.length === 0)
|
|
275
|
+
return;
|
|
276
|
+
// Update texture dimensions if needed
|
|
277
|
+
if (maxW > this.textureWidth || maxH > this.textureHeight) {
|
|
278
|
+
this.textureWidth = maxW;
|
|
279
|
+
this.textureHeight = maxH;
|
|
280
|
+
// Clear texture cache as we need to recreate textures
|
|
281
|
+
for (const texture of this.textureCache.values()) {
|
|
282
|
+
this.gl.deleteTexture(texture);
|
|
283
|
+
}
|
|
284
|
+
this.textureCache.clear();
|
|
285
|
+
}
|
|
286
|
+
// Process images individually (WebGL1 limitation: no texture arrays)
|
|
287
|
+
// We'll render them one by one instead of in batches
|
|
288
|
+
for (let i = 0; i < validImages.length; i++) {
|
|
289
|
+
const img = validImages[i];
|
|
290
|
+
// Get or create texture for this image
|
|
291
|
+
let texture = this.textureCache.get(i);
|
|
292
|
+
if (!texture) {
|
|
293
|
+
texture = this.createTexture(this.textureWidth, this.textureHeight);
|
|
294
|
+
this.textureCache.set(i, texture);
|
|
295
|
+
}
|
|
296
|
+
this.gl.bindTexture(this.gl.TEXTURE_2D, texture);
|
|
297
|
+
// Upload bitmap data to texture
|
|
298
|
+
// WebGL1 doesn't support UNPACK_ROW_LENGTH, so we need to handle strided data manually
|
|
299
|
+
// Strided data - need to copy row by row to remove padding
|
|
300
|
+
const sourceView = new Uint8Array(heap.buffer, img.bitmap, img.stride * img.h);
|
|
301
|
+
const tightData = new Uint8Array(img.w * img.h);
|
|
302
|
+
for (let y = 0; y < img.h; y++) {
|
|
303
|
+
const srcOffset = y * img.stride;
|
|
304
|
+
const dstOffset = y * img.w;
|
|
305
|
+
tightData.set(sourceView.subarray(srcOffset, srcOffset + img.w), dstOffset);
|
|
306
|
+
}
|
|
307
|
+
this.gl.texSubImage2D(this.gl.TEXTURE_2D, 0, 0, 0, // x, y offset
|
|
308
|
+
img.w, img.h, this.gl.LUMINANCE, this.gl.UNSIGNED_BYTE, tightData);
|
|
309
|
+
// Fill instance data (single instance)
|
|
310
|
+
this.instanceDestRectData[0] = img.dst_x;
|
|
311
|
+
this.instanceDestRectData[1] = img.dst_y;
|
|
312
|
+
this.instanceDestRectData[2] = img.w;
|
|
313
|
+
this.instanceDestRectData[3] = img.h;
|
|
314
|
+
this.instanceColorData[0] = ((img.color >>> 24) & 0xFF) / 255;
|
|
315
|
+
this.instanceColorData[1] = ((img.color >>> 16) & 0xFF) / 255;
|
|
316
|
+
this.instanceColorData[2] = ((img.color >>> 8) & 0xFF) / 255;
|
|
317
|
+
this.instanceColorData[3] = (img.color & 0xFF) / 255;
|
|
318
|
+
this.instanceTexLayerData[0] = 0; // Not used in WebGL1 version
|
|
319
|
+
// Upload instance data to buffers
|
|
320
|
+
this.gl.bindBuffer(this.gl.ARRAY_BUFFER, this.instanceDestRectBuffer);
|
|
321
|
+
this.gl.bufferData(this.gl.ARRAY_BUFFER, this.instanceDestRectData.subarray(0, 4), this.gl.DYNAMIC_DRAW);
|
|
322
|
+
this.gl.bindBuffer(this.gl.ARRAY_BUFFER, this.instanceColorBuffer);
|
|
323
|
+
this.gl.bufferData(this.gl.ARRAY_BUFFER, this.instanceColorData.subarray(0, 4), this.gl.DYNAMIC_DRAW);
|
|
324
|
+
this.gl.bindBuffer(this.gl.ARRAY_BUFFER, this.instanceTexLayerBuffer);
|
|
325
|
+
this.gl.bufferData(this.gl.ARRAY_BUFFER, this.instanceTexLayerData.subarray(0, 1), this.gl.DYNAMIC_DRAW);
|
|
326
|
+
// Set texture dimensions uniform
|
|
327
|
+
this.gl.uniform2f(this.u_texDimensions, this.textureWidth, this.textureHeight);
|
|
328
|
+
// Single instanced draw call
|
|
329
|
+
this.instancedArraysExt.drawArraysInstancedANGLE(this.gl.TRIANGLES, 0, 6, 1);
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
destroy() {
|
|
333
|
+
if (this.gl) {
|
|
334
|
+
// Delete all cached textures
|
|
335
|
+
for (const texture of this.textureCache.values()) {
|
|
336
|
+
this.gl.deleteTexture(texture);
|
|
337
|
+
}
|
|
338
|
+
this.textureCache.clear();
|
|
339
|
+
if (this.quadPosBuffer) {
|
|
340
|
+
this.gl.deleteBuffer(this.quadPosBuffer);
|
|
341
|
+
this.quadPosBuffer = null;
|
|
342
|
+
}
|
|
343
|
+
if (this.instanceDestRectBuffer) {
|
|
344
|
+
this.gl.deleteBuffer(this.instanceDestRectBuffer);
|
|
345
|
+
this.instanceDestRectBuffer = null;
|
|
346
|
+
}
|
|
347
|
+
if (this.instanceColorBuffer) {
|
|
348
|
+
this.gl.deleteBuffer(this.instanceColorBuffer);
|
|
349
|
+
this.instanceColorBuffer = null;
|
|
350
|
+
}
|
|
351
|
+
if (this.instanceTexLayerBuffer) {
|
|
352
|
+
this.gl.deleteBuffer(this.instanceTexLayerBuffer);
|
|
353
|
+
this.instanceTexLayerBuffer = null;
|
|
354
|
+
}
|
|
355
|
+
if (this.program) {
|
|
356
|
+
this.gl.deleteProgram(this.program);
|
|
357
|
+
this.program = null;
|
|
358
|
+
}
|
|
359
|
+
this.gl = null;
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
//# sourceMappingURL=webgl1-renderer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"webgl1-renderer.js","sourceRoot":"","sources":["../../../src/worker/renderers/webgl1-renderer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,eAAe,EAAiB,MAAM,YAAY,CAAA;AAErF,8DAA8D;AAC9D,MAAM,aAAa,GAAG,UAAU,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA+B/B,CAAA;AAED,8BAA8B;AAC9B,qFAAqF;AACrF,MAAM,eAAe,GAAG,UAAU,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAoCjC,CAAA;AAED,gBAAgB;AAChB,MAAM,aAAa,GAAG,GAAG,CAAA,CAAC,kCAAkC;AAE5D,MAAM,OAAO,cAAc;IACzB,MAAM,GAA2B,IAAI,CAAA;IACrC,EAAE,GAAiC,IAAI,CAAA;IACvC,OAAO,GAAwB,IAAI,CAAA;IAEnC,aAAa;IACb,kBAAkB,GAAkC,IAAI,CAAA;IAExD,oBAAoB;IACpB,YAAY,GAAgC,IAAI,CAAA;IAChD,KAAK,GAAgC,IAAI,CAAA;IACzC,aAAa,GAAgC,IAAI,CAAA;IACjD,eAAe,GAAgC,IAAI,CAAA;IAEnD,sBAAsB;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YAAY,CAAC,KAAK,EAAE,CAAA;YAEzB,IAAI,IAAI,CAAC,aAAa,EAAE,CAAC;gBACvB,IAAI,CAAC,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC,aAAa,CAAC,CAAA;gBACxC,IAAI,CAAC,aAAa,GAAG,IAAI,CAAA;YAC3B,CAAC;YAED,IAAI,IAAI,CAAC,sBAAsB,EAAE,CAAC;gBAChC,IAAI,CAAC,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC,sBAAsB,CAAC,CAAA;gBACjD,IAAI,CAAC,sBAAsB,GAAG,IAAI,CAAA;YACpC,CAAC;YAED,IAAI,IAAI,CAAC,mBAAmB,EAAE,CAAC;gBAC7B,IAAI,CAAC,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC,mBAAmB,CAAC,CAAA;gBAC9C,IAAI,CAAC,mBAAmB,GAAG,IAAI,CAAA;YACjC,CAAC;YAED,IAAI,IAAI,CAAC,sBAAsB,EAAE,CAAC;gBAChC,IAAI,CAAC,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC,sBAAsB,CAAC,CAAA;gBACjD,IAAI,CAAC,sBAAsB,GAAG,IAAI,CAAA;YACpC,CAAC;YAED,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;gBACjB,IAAI,CAAC,EAAE,CAAC,aAAa,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;gBACnC,IAAI,CAAC,OAAO,GAAG,IAAI,CAAA;YACrB,CAAC;YAED,IAAI,CAAC,EAAE,GAAG,IAAI,CAAA;QAChB,CAAC;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { type ASSImage } from '../util.ts';
|
|
2
|
+
export declare class WebGL2Renderer {
|
|
3
|
+
canvas: OffscreenCanvas | null;
|
|
4
|
+
gl: WebGL2RenderingContext | null;
|
|
5
|
+
program: WebGLProgram | null;
|
|
6
|
+
vao: WebGLVertexArrayObject | null;
|
|
7
|
+
u_resolution: WebGLUniformLocation | null;
|
|
8
|
+
u_texArray: WebGLUniformLocation | null;
|
|
9
|
+
u_colorMatrix: WebGLUniformLocation | null;
|
|
10
|
+
instanceDestRectBuffer: WebGLBuffer | null;
|
|
11
|
+
instanceColorBuffer: WebGLBuffer | null;
|
|
12
|
+
instanceTexLayerBuffer: WebGLBuffer | null;
|
|
13
|
+
instanceDestRectData: Float32Array;
|
|
14
|
+
instanceColorData: Float32Array;
|
|
15
|
+
instanceTexLayerData: Float32Array;
|
|
16
|
+
texArray: WebGLTexture | null;
|
|
17
|
+
texArrayWidth: number;
|
|
18
|
+
texArrayHeight: number;
|
|
19
|
+
colorMatrix: Float32Array;
|
|
20
|
+
constructor();
|
|
21
|
+
_scheduledResize?: {
|
|
22
|
+
width: number;
|
|
23
|
+
height: number;
|
|
24
|
+
};
|
|
25
|
+
resizeCanvas(width: number, height: number): void;
|
|
26
|
+
setCanvas(canvas: OffscreenCanvas): void;
|
|
27
|
+
createShader(type: number, source: string): WebGLShader | null;
|
|
28
|
+
setColorMatrix(subtitleColorSpace?: 'BT601' | 'BT709' | 'SMPTE240M' | 'FCC', videoColorSpace?: 'BT601' | 'BT709'): void;
|
|
29
|
+
createTexArray(width: number, height: number): void;
|
|
30
|
+
render(images: ASSImage[], heap: Uint8Array): void;
|
|
31
|
+
destroy(): void;
|
|
32
|
+
}
|