jassub 2.2.6 → 2.3.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 +52 -0
- package/dist/default.woff2 +0 -0
- package/dist/jassub.d.ts +14 -14
- package/dist/jassub.js +39 -50
- package/dist/jassub.js.map +1 -1
- package/dist/wasm/jassub-worker.js +4 -0
- package/dist/wasm/jassub-worker.js.map +1 -1
- package/dist/worker/util.d.ts +10 -4
- package/dist/worker/util.js +20 -20
- package/dist/worker/util.js.map +1 -1
- package/dist/worker/webgl-renderer.d.ts +8 -2
- package/dist/worker/webgl-renderer.js +93 -81
- package/dist/worker/webgl-renderer.js.map +1 -1
- package/dist/worker/worker.d.ts +26 -21
- package/dist/worker/worker.js +116 -75
- package/dist/worker/worker.js.map +1 -1
- package/package.json +5 -2
- package/src/jassub.ts +54 -56
- package/src/worker/util.ts +30 -22
- package/src/worker/webgl-renderer.ts +107 -97
- package/src/worker/worker.ts +120 -82
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"worker.js","sourceRoot":"","sources":["../../src/worker/worker.ts"],"names":[],"mappings":"AAAA,8BAA8B;AAC9B,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AACnC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AAEpC,OAAO,IAAI,MAAM,0BAA0B,CAAA;AAE3C,OAAO,EAAE,cAAc,EAAE,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAA;AACrE,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AAMjD,MAAM,UAAU,GAAG,SAAS,CAAC,SAAS,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAA;AAuBxE,MAAM,OAAO,WAAW;IACtB,UAAU,CAAkB;IAC5B,KAAK,CAAS;IACd,mBAAmB,CAAiD;IACpE,gBAAgB,CAAoB;IACpC,OAAO,CAA2B;IAClC,UA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OAAM;QACrC,IAAI,CAAC,gBAAgB,GAAG,eAAe,CAAA;QACvC,IAAI,CAAC,gBAAgB,EAAE,CAAA;IACzB,CAAC;CACF;AAED,IAAI,IAAI,CAAC,IAAI,KAAK,eAAe,EAAE,CAAC;IAClC,MAAM,CAAC,WAAW,CAAC,CAAA;AACrB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "jassub",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.3.0",
|
|
4
4
|
"description": "The Fastest JavaScript SSA/ASS Subtitle Renderer For Browsers",
|
|
5
5
|
"main": "dist/jassub.js",
|
|
6
6
|
"type": "module",
|
|
@@ -9,11 +9,13 @@
|
|
|
9
9
|
"dist/worker/*",
|
|
10
10
|
"dist/jassub.*",
|
|
11
11
|
"dist/debug.*",
|
|
12
|
+
"dist/default.woff2",
|
|
12
13
|
"!dist/wasm/jassub-worker-modern.js",
|
|
13
14
|
"README.md",
|
|
14
15
|
"LICENSE",
|
|
15
16
|
"index.d.ts",
|
|
16
|
-
"src/**/*.ts"
|
|
17
|
+
"src/**/*.ts",
|
|
18
|
+
"!src/default.woff2"
|
|
17
19
|
],
|
|
18
20
|
"repository": {
|
|
19
21
|
"type": "git",
|
|
@@ -39,6 +41,7 @@
|
|
|
39
41
|
"homepage": "https://github.com/ThaUnknown/jassub",
|
|
40
42
|
"dependencies": {
|
|
41
43
|
"abslink": "^1.1.6",
|
|
44
|
+
"lfa-ponyfill": "^1.1.0",
|
|
42
45
|
"rvfc-polyfill": "^1.0.8",
|
|
43
46
|
"throughput": "^1.0.2"
|
|
44
47
|
},
|
package/src/jassub.ts
CHANGED
|
@@ -1,14 +1,18 @@
|
|
|
1
|
-
/* eslint-disable camelcase */
|
|
2
1
|
import 'rvfc-polyfill'
|
|
3
2
|
|
|
4
3
|
import { proxy, releaseProxy } from 'abslink'
|
|
5
4
|
import { wrap } from 'abslink/w3c'
|
|
6
5
|
|
|
7
|
-
import { Debug } from './debug'
|
|
6
|
+
import { Debug } from './debug.ts'
|
|
8
7
|
|
|
9
|
-
import type {
|
|
8
|
+
import type { WeightValue } from './worker/util.ts'
|
|
10
9
|
import type { ASSRenderer } from './worker/worker'
|
|
11
10
|
import type { Remote } from 'abslink'
|
|
11
|
+
import type { queryRemoteFonts } from 'lfa-ponyfill'
|
|
12
|
+
|
|
13
|
+
declare const self: typeof globalThis & {
|
|
14
|
+
queryLocalFonts: (opts?: { postscriptNames?: string[] }) => ReturnType<typeof queryRemoteFonts>
|
|
15
|
+
}
|
|
12
16
|
|
|
13
17
|
const webYCbCrMap = {
|
|
14
18
|
rgb: 'RGB',
|
|
@@ -18,10 +22,6 @@ const webYCbCrMap = {
|
|
|
18
22
|
smpte170m: 'BT601'// alias BT.601 NTSC... whats the difference?
|
|
19
23
|
} as const
|
|
20
24
|
|
|
21
|
-
export type ASSEvent = Omit<ASS_Event, keyof ClassHandle>
|
|
22
|
-
export type ASSStyle = Omit<ASS_Style, keyof ClassHandle>
|
|
23
|
-
export type ASSImage = Omit<ASS_Image, keyof ClassHandle>
|
|
24
|
-
|
|
25
25
|
export type JASSUBOptions = {
|
|
26
26
|
timeOffset?: number
|
|
27
27
|
debug?: boolean
|
|
@@ -31,12 +31,10 @@ export type JASSUBOptions = {
|
|
|
31
31
|
workerUrl?: string
|
|
32
32
|
wasmUrl?: string
|
|
33
33
|
modernWasmUrl?: string
|
|
34
|
-
|
|
35
|
-
subContent?: string
|
|
36
|
-
fonts?: string[] | Uint8Array[]
|
|
34
|
+
fonts?: Array<string | Uint8Array>
|
|
37
35
|
availableFonts?: Record<string, Uint8Array | string>
|
|
38
|
-
|
|
39
|
-
|
|
36
|
+
defaultFont?: string
|
|
37
|
+
queryFonts?: 'local' | 'localandremote' | false
|
|
40
38
|
libassMemoryLimit?: number
|
|
41
39
|
libassGlyphLimit?: number
|
|
42
40
|
} & ({
|
|
@@ -45,6 +43,12 @@ export type JASSUBOptions = {
|
|
|
45
43
|
} | {
|
|
46
44
|
video?: HTMLVideoElement
|
|
47
45
|
canvas: HTMLCanvasElement
|
|
46
|
+
}) & ({
|
|
47
|
+
subUrl: string
|
|
48
|
+
subContent?: string
|
|
49
|
+
} | {
|
|
50
|
+
subUrl?: string
|
|
51
|
+
subContent: string
|
|
48
52
|
})
|
|
49
53
|
|
|
50
54
|
export default class JASSUB {
|
|
@@ -63,7 +67,11 @@ export default class JASSUB {
|
|
|
63
67
|
_canvas
|
|
64
68
|
_canvasParent
|
|
65
69
|
_ctrl = new AbortController()
|
|
66
|
-
_ro = new ResizeObserver(() =>
|
|
70
|
+
_ro = new ResizeObserver(async () => {
|
|
71
|
+
await this.ready
|
|
72
|
+
this.resize()
|
|
73
|
+
})
|
|
74
|
+
|
|
67
75
|
_destroyed = false
|
|
68
76
|
_lastDemandTime!: VideoFrameCallbackMetadata
|
|
69
77
|
_skipped = false
|
|
@@ -107,23 +115,27 @@ export default class JASSUB {
|
|
|
107
115
|
const Renderer = wrap<typeof ASSRenderer>(this._worker)
|
|
108
116
|
|
|
109
117
|
const modern = opts.modernWasmUrl ?? new URL('./wasm/jassub-worker-modern.wasm', import.meta.url).href
|
|
110
|
-
const
|
|
118
|
+
const normal = opts.wasmUrl ?? new URL('./wasm/jassub-worker.wasm', import.meta.url).href
|
|
119
|
+
|
|
120
|
+
const availableFonts = opts.availableFonts ?? {}
|
|
121
|
+
if (!availableFonts['liberation sans'] && !opts.defaultFont) {
|
|
122
|
+
availableFonts['liberation sans'] = new URL('./default.woff2', import.meta.url).href
|
|
123
|
+
}
|
|
111
124
|
|
|
112
125
|
this.ready = (async () => {
|
|
113
126
|
this.renderer = await new Renderer({
|
|
114
|
-
wasmUrl: JASSUB._supportsSIMD ? modern :
|
|
127
|
+
wasmUrl: JASSUB._supportsSIMD ? modern : normal,
|
|
115
128
|
width: ctrl.width,
|
|
116
129
|
height: ctrl.height,
|
|
117
130
|
subUrl: opts.subUrl,
|
|
118
131
|
subContent: opts.subContent ?? null,
|
|
119
132
|
fonts: opts.fonts ?? [],
|
|
120
|
-
availableFonts
|
|
121
|
-
|
|
133
|
+
availableFonts,
|
|
134
|
+
defaultFont: opts.defaultFont ?? 'liberation sans',
|
|
122
135
|
debug: !!opts.debug,
|
|
123
136
|
libassMemoryLimit: opts.libassMemoryLimit ?? 0,
|
|
124
137
|
libassGlyphLimit: opts.libassGlyphLimit ?? 0,
|
|
125
|
-
|
|
126
|
-
useLocalFonts: typeof queryLocalFonts !== 'undefined' && (opts.useLocalFonts ?? true)
|
|
138
|
+
queryFonts: opts.queryFonts ?? 'local'
|
|
127
139
|
}, proxy(font => this._getLocalFont(font))) as unknown as Remote<ASSRenderer>
|
|
128
140
|
|
|
129
141
|
await this.renderer.ready()
|
|
@@ -148,8 +160,7 @@ export default class JASSUB {
|
|
|
148
160
|
if (!(module instanceof WebAssembly.Module) || !(new WebAssembly.Instance(module) instanceof WebAssembly.Instance)) throw new Error('WASM not supported')
|
|
149
161
|
}
|
|
150
162
|
|
|
151
|
-
async resize (
|
|
152
|
-
await this.ready
|
|
163
|
+
async resize (forceRepaint = !!this._video?.paused, width = 0, height = 0, top = 0, left = 0) {
|
|
153
164
|
if ((!width || !height) && this._video) {
|
|
154
165
|
const videoSize = this._getVideoPosition()
|
|
155
166
|
let renderSize = null
|
|
@@ -171,17 +182,19 @@ export default class JASSUB {
|
|
|
171
182
|
this._canvas.style.height = videoSize.height + 'px'
|
|
172
183
|
}
|
|
173
184
|
|
|
174
|
-
this.
|
|
175
|
-
|
|
185
|
+
if (this._canvasParent) {
|
|
186
|
+
this._canvas.style.top = top + 'px'
|
|
187
|
+
this._canvas.style.left = left + 'px'
|
|
188
|
+
}
|
|
176
189
|
|
|
177
|
-
await this.renderer.
|
|
190
|
+
await this.renderer._resizeCanvas(
|
|
178
191
|
width,
|
|
179
192
|
height,
|
|
180
193
|
(this._videoWidth || this._video?.videoWidth) ?? width,
|
|
181
194
|
(this._videoHeight || this._video?.videoHeight) ?? height
|
|
182
195
|
)
|
|
183
196
|
|
|
184
|
-
if (
|
|
197
|
+
if (this._lastDemandTime) await this._demandRender(forceRepaint)
|
|
185
198
|
}
|
|
186
199
|
|
|
187
200
|
_getVideoPosition (width = this._video!.videoWidth, height = this._video!.videoHeight) {
|
|
@@ -228,10 +241,10 @@ export default class JASSUB {
|
|
|
228
241
|
}
|
|
229
242
|
|
|
230
243
|
async setVideo (video: HTMLVideoElement) {
|
|
231
|
-
await this.ready
|
|
232
244
|
if (video instanceof HTMLVideoElement) {
|
|
233
245
|
this._removeListeners()
|
|
234
246
|
this._video = video
|
|
247
|
+
await this.ready
|
|
235
248
|
this._video.requestVideoFrameCallback((now, data) => this._handleRVFC(data))
|
|
236
249
|
// everything else is unreliable for this, loadedmetadata and loadeddata included.
|
|
237
250
|
if ('VideoFrame' in globalThis) {
|
|
@@ -245,36 +258,21 @@ export default class JASSUB {
|
|
|
245
258
|
}
|
|
246
259
|
}
|
|
247
260
|
|
|
248
|
-
async
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
for (const font of fonts) {
|
|
255
|
-
const blob: Blob = await font.blob()
|
|
256
|
-
this.renderer.addFont(new Uint8Array(await blob.arrayBuffer()))
|
|
257
|
-
}
|
|
258
|
-
} catch (e) {
|
|
259
|
-
console.warn('Local fonts API:', e)
|
|
261
|
+
async _getLocalFont (font: string, weight: WeightValue = 'regular') {
|
|
262
|
+
// electron by default has all permissions enabled, and it doesn't have perm query
|
|
263
|
+
// if this happens, just send it
|
|
264
|
+
if (navigator.permissions?.query) {
|
|
265
|
+
const { state } = await navigator.permissions.query({ name: 'local-fonts' as PermissionName })
|
|
266
|
+
if (state !== 'granted') return
|
|
260
267
|
}
|
|
261
|
-
}
|
|
262
268
|
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
const permission = await navigator.permissions.query({ name: 'local-fonts' })
|
|
270
|
-
if (permission.state === 'granted') {
|
|
271
|
-
await this._sendLocalFont(font)
|
|
272
|
-
}
|
|
273
|
-
} else {
|
|
274
|
-
await this._sendLocalFont(font)
|
|
269
|
+
for (const data of await self.queryLocalFonts()) {
|
|
270
|
+
const family = data.family.toLowerCase()
|
|
271
|
+
const style = data.style.toLowerCase()
|
|
272
|
+
if (family === font && style === weight) {
|
|
273
|
+
const blob = await data.blob()
|
|
274
|
+
return new Uint8Array(await blob.arrayBuffer())
|
|
275
275
|
}
|
|
276
|
-
} catch (e) {
|
|
277
|
-
console.warn('Local fonts API:', e)
|
|
278
276
|
}
|
|
279
277
|
}
|
|
280
278
|
|
|
@@ -287,12 +285,12 @@ export default class JASSUB {
|
|
|
287
285
|
this._video!.requestVideoFrameCallback((now, data) => this._handleRVFC(data))
|
|
288
286
|
}
|
|
289
287
|
|
|
290
|
-
async _demandRender () {
|
|
288
|
+
async _demandRender (repaint = false) {
|
|
291
289
|
const { mediaTime, width, height } = this._lastDemandTime
|
|
292
290
|
if (width !== this._videoWidth || height !== this._videoHeight) {
|
|
293
291
|
this._videoWidth = width
|
|
294
292
|
this._videoHeight = height
|
|
295
|
-
await this.resize(
|
|
293
|
+
return await this.resize(repaint)
|
|
296
294
|
}
|
|
297
295
|
|
|
298
296
|
if (this.busy) {
|
|
@@ -305,7 +303,7 @@ export default class JASSUB {
|
|
|
305
303
|
this._skipped = false
|
|
306
304
|
|
|
307
305
|
this.debug?._startFrame()
|
|
308
|
-
await this.renderer._draw(mediaTime + this.timeOffset)
|
|
306
|
+
await this.renderer._draw(mediaTime + this.timeOffset, repaint)
|
|
309
307
|
this.debug?._endFrame(this._lastDemandTime)
|
|
310
308
|
|
|
311
309
|
this.busy = false
|
package/src/worker/util.ts
CHANGED
|
@@ -1,35 +1,43 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
export const read_ = (url: string, ab = false) => {
|
|
4
|
-
const xhr = new XMLHttpRequest()
|
|
5
|
-
xhr.open('GET', url, false)
|
|
6
|
-
xhr.responseType = ab ? 'arraybuffer' : 'text'
|
|
7
|
-
xhr.send(null)
|
|
8
|
-
return xhr.response
|
|
9
|
-
}
|
|
1
|
+
/* eslint-disable camelcase */
|
|
2
|
+
import type { ASS_Event, ASS_Image, ASS_Style, ClassHandle } from '../wasm/types.d.ts'
|
|
10
3
|
|
|
11
|
-
export
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
4
|
+
export type ASSEvent = Omit<ASS_Event, keyof ClassHandle>
|
|
5
|
+
export type ASSStyle = Omit<ASS_Style, keyof ClassHandle>
|
|
6
|
+
export type ASSImage = Omit<ASS_Image, keyof ClassHandle>
|
|
7
|
+
|
|
8
|
+
// offset by 1, 0 = 1, to match CSS font-weight values, but dividing by 100 gives the correct index
|
|
9
|
+
export const WEIGHT_MAP = [
|
|
10
|
+
'thin',
|
|
11
|
+
'extralight',
|
|
12
|
+
'light',
|
|
13
|
+
'regular', // Normal isn't used
|
|
14
|
+
'medium',
|
|
15
|
+
'semibold',
|
|
16
|
+
'bold',
|
|
17
|
+
'extrabold',
|
|
18
|
+
'black',
|
|
19
|
+
'ultrablack'
|
|
20
|
+
] as const
|
|
21
|
+
|
|
22
|
+
export type WeightValue = typeof WEIGHT_MAP[number]
|
|
23
|
+
|
|
24
|
+
export const IS_FIREFOX = navigator.userAgent.toLowerCase().includes('firefox')
|
|
23
25
|
|
|
24
26
|
const a = 'BT601'
|
|
25
27
|
const b = 'BT709'
|
|
26
28
|
const c = 'SMPTE240M'
|
|
27
29
|
const d = 'FCC'
|
|
28
30
|
|
|
29
|
-
export const
|
|
31
|
+
export const LIBASS_YCBCR_MAP = [null, a, null, a, a, b, b, c, c, d, d] as const
|
|
30
32
|
|
|
31
33
|
export function _applyKeys<T extends (ASSEvent | ASSStyle)> (input: T, output: T) {
|
|
32
34
|
for (const v of Object.keys(input) as Array<keyof T>) {
|
|
33
35
|
output[v] = input[v]
|
|
34
36
|
}
|
|
35
37
|
}
|
|
38
|
+
|
|
39
|
+
export const _fetch = globalThis.fetch
|
|
40
|
+
export async function fetchtext (url: string) {
|
|
41
|
+
const res = await _fetch(url)
|
|
42
|
+
return await res.text()
|
|
43
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { IS_FIREFOX, type ASSImage } from './util.ts'
|
|
2
2
|
|
|
3
3
|
declare const self: DedicatedWorkerGlobalScope &
|
|
4
4
|
typeof globalThis & {
|
|
@@ -6,8 +6,6 @@ declare const self: DedicatedWorkerGlobalScope &
|
|
|
6
6
|
WASMMEMORY: WebAssembly.Memory
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
-
const IS_FIREFOX = navigator.userAgent.toLowerCase().includes('firefox')
|
|
10
|
-
|
|
11
9
|
const THREAD_COUNT = !IS_FIREFOX && self.crossOriginIsolated ? Math.min(Math.max(1, navigator.hardwareConcurrency - 2), 8) : 1
|
|
12
10
|
|
|
13
11
|
// @ts-expect-error new experimental API
|
|
@@ -166,6 +164,7 @@ const TEX_INITIAL_SIZE = 256 // Initial width/height
|
|
|
166
164
|
const MAX_INSTANCES = 256 // Maximum instances per draw call
|
|
167
165
|
|
|
168
166
|
export class WebGL2Renderer {
|
|
167
|
+
canvas: OffscreenCanvas | null = null
|
|
169
168
|
gl: WebGL2RenderingContext | null = null
|
|
170
169
|
program: WebGLProgram | null = null
|
|
171
170
|
vao: WebGLVertexArrayObject | null = null
|
|
@@ -197,109 +196,107 @@ export class WebGL2Renderer {
|
|
|
197
196
|
this.instanceTexLayerData = new Float32Array(MAX_INSTANCES)
|
|
198
197
|
}
|
|
199
198
|
|
|
200
|
-
|
|
199
|
+
_scheduledResize?: { width: number, height: number }
|
|
200
|
+
|
|
201
|
+
resizeCanvas (width: number, height: number) {
|
|
201
202
|
// WebGL2 doesn't allow 0-sized canvases
|
|
202
203
|
if (width <= 0 || height <= 0) return
|
|
203
204
|
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
if (!this.gl) {
|
|
208
|
-
this.gl = canvas.getContext('webgl2', {
|
|
209
|
-
alpha: true,
|
|
210
|
-
premultipliedAlpha: true,
|
|
211
|
-
antialias: false,
|
|
212
|
-
depth: false,
|
|
213
|
-
preserveDrawingBuffer: false,
|
|
214
|
-
stencil: false,
|
|
215
|
-
desynchronized: true,
|
|
216
|
-
powerPreference: 'high-performance'
|
|
217
|
-
})
|
|
218
|
-
|
|
219
|
-
if (!this.gl) {
|
|
220
|
-
throw new Error('Could not get WebGL2 context')
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
// Create shaders
|
|
224
|
-
const vertexShader = this.createShader(this.gl.VERTEX_SHADER, VERTEX_SHADER)
|
|
225
|
-
const fragmentShader = this.createShader(this.gl.FRAGMENT_SHADER, FRAGMENT_SHADER)
|
|
226
|
-
|
|
227
|
-
if (!vertexShader || !fragmentShader) {
|
|
228
|
-
throw new Error('Failed to create shaders')
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
// Create program
|
|
232
|
-
this.program = this.gl.createProgram()!
|
|
233
|
-
this.gl.attachShader(this.program, vertexShader)
|
|
234
|
-
this.gl.attachShader(this.program, fragmentShader)
|
|
235
|
-
this.gl.linkProgram(this.program)
|
|
236
|
-
|
|
237
|
-
if (!this.gl.getProgramParameter(this.program, this.gl.LINK_STATUS)) {
|
|
238
|
-
const info = this.gl.getProgramInfoLog(this.program)
|
|
239
|
-
throw new Error('Failed to link program: ' + info)
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
this.gl.deleteShader(vertexShader)
|
|
243
|
-
this.gl.deleteShader(fragmentShader)
|
|
244
|
-
|
|
245
|
-
// Get uniform locations
|
|
246
|
-
this.u_resolution = this.gl.getUniformLocation(this.program, 'u_resolution')
|
|
247
|
-
this.u_texArray = this.gl.getUniformLocation(this.program, 'u_texArray')
|
|
248
|
-
this.u_colorMatrix = this.gl.getUniformLocation(this.program, 'u_colorMatrix')
|
|
249
|
-
|
|
250
|
-
// Create instance attribute buffers
|
|
251
|
-
this.instanceDestRectBuffer = this.gl.createBuffer()
|
|
252
|
-
this.instanceColorBuffer = this.gl.createBuffer()
|
|
253
|
-
this.instanceTexLayerBuffer = this.gl.createBuffer()
|
|
254
|
-
|
|
255
|
-
// Create a VAO (required for WebGL2)
|
|
256
|
-
this.vao = this.gl.createVertexArray()
|
|
257
|
-
this.gl.bindVertexArray(this.vao)
|
|
258
|
-
|
|
259
|
-
// Setup instance attributes
|
|
260
|
-
const destRectLoc = this.gl.getAttribLocation(this.program, 'a_destRect')
|
|
261
|
-
this.gl.bindBuffer(this.gl.ARRAY_BUFFER, this.instanceDestRectBuffer)
|
|
262
|
-
this.gl.enableVertexAttribArray(destRectLoc)
|
|
263
|
-
this.gl.vertexAttribPointer(destRectLoc, 4, this.gl.FLOAT, false, 0, 0)
|
|
264
|
-
this.gl.vertexAttribDivisor(destRectLoc, 1)
|
|
265
|
-
|
|
266
|
-
const colorLoc = this.gl.getAttribLocation(this.program, 'a_color')
|
|
267
|
-
this.gl.bindBuffer(this.gl.ARRAY_BUFFER, this.instanceColorBuffer)
|
|
268
|
-
this.gl.enableVertexAttribArray(colorLoc)
|
|
269
|
-
this.gl.vertexAttribPointer(colorLoc, 4, this.gl.FLOAT, false, 0, 0)
|
|
270
|
-
this.gl.vertexAttribDivisor(colorLoc, 1)
|
|
271
|
-
|
|
272
|
-
const texLayerLoc = this.gl.getAttribLocation(this.program, 'a_texLayer')
|
|
273
|
-
this.gl.bindBuffer(this.gl.ARRAY_BUFFER, this.instanceTexLayerBuffer)
|
|
274
|
-
this.gl.enableVertexAttribArray(texLayerLoc)
|
|
275
|
-
this.gl.vertexAttribPointer(texLayerLoc, 1, this.gl.FLOAT, false, 0, 0)
|
|
276
|
-
this.gl.vertexAttribDivisor(texLayerLoc, 1)
|
|
205
|
+
this._scheduledResize = { width, height }
|
|
206
|
+
}
|
|
277
207
|
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
208
|
+
setCanvas (canvas: OffscreenCanvas) {
|
|
209
|
+
this.canvas = canvas
|
|
210
|
+
this.gl = canvas.getContext('webgl2', {
|
|
211
|
+
alpha: true,
|
|
212
|
+
premultipliedAlpha: true,
|
|
213
|
+
antialias: false,
|
|
214
|
+
depth: false,
|
|
215
|
+
preserveDrawingBuffer: false,
|
|
216
|
+
stencil: false,
|
|
217
|
+
desynchronized: true,
|
|
218
|
+
powerPreference: 'high-performance'
|
|
219
|
+
})
|
|
281
220
|
|
|
282
|
-
|
|
283
|
-
|
|
221
|
+
if (!this.gl) {
|
|
222
|
+
throw new Error('Could not get WebGL2 context')
|
|
223
|
+
}
|
|
284
224
|
|
|
285
|
-
|
|
286
|
-
|
|
225
|
+
// Create shaders
|
|
226
|
+
const vertexShader = this.createShader(this.gl.VERTEX_SHADER, VERTEX_SHADER)
|
|
227
|
+
const fragmentShader = this.createShader(this.gl.FRAGMENT_SHADER, FRAGMENT_SHADER)
|
|
287
228
|
|
|
288
|
-
|
|
289
|
-
|
|
229
|
+
if (!vertexShader || !fragmentShader) {
|
|
230
|
+
throw new Error('Failed to create shaders')
|
|
231
|
+
}
|
|
290
232
|
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
233
|
+
// Create program
|
|
234
|
+
this.program = this.gl.createProgram()!
|
|
235
|
+
this.gl.attachShader(this.program, vertexShader)
|
|
236
|
+
this.gl.attachShader(this.program, fragmentShader)
|
|
237
|
+
this.gl.linkProgram(this.program)
|
|
295
238
|
|
|
296
|
-
|
|
297
|
-
this.
|
|
239
|
+
if (!this.gl.getProgramParameter(this.program, this.gl.LINK_STATUS)) {
|
|
240
|
+
const info = this.gl.getProgramInfoLog(this.program)
|
|
241
|
+
throw new Error('Failed to link program: ' + info)
|
|
298
242
|
}
|
|
299
243
|
|
|
300
|
-
|
|
301
|
-
this.gl.
|
|
302
|
-
|
|
244
|
+
this.gl.deleteShader(vertexShader)
|
|
245
|
+
this.gl.deleteShader(fragmentShader)
|
|
246
|
+
|
|
247
|
+
// Get uniform locations
|
|
248
|
+
this.u_resolution = this.gl.getUniformLocation(this.program, 'u_resolution')
|
|
249
|
+
this.u_texArray = this.gl.getUniformLocation(this.program, 'u_texArray')
|
|
250
|
+
this.u_colorMatrix = this.gl.getUniformLocation(this.program, 'u_colorMatrix')
|
|
251
|
+
|
|
252
|
+
// Create instance attribute buffers
|
|
253
|
+
this.instanceDestRectBuffer = this.gl.createBuffer()
|
|
254
|
+
this.instanceColorBuffer = this.gl.createBuffer()
|
|
255
|
+
this.instanceTexLayerBuffer = this.gl.createBuffer()
|
|
256
|
+
|
|
257
|
+
// Create a VAO (required for WebGL2)
|
|
258
|
+
this.vao = this.gl.createVertexArray()
|
|
259
|
+
this.gl.bindVertexArray(this.vao)
|
|
260
|
+
|
|
261
|
+
// Setup instance attributes
|
|
262
|
+
const destRectLoc = this.gl.getAttribLocation(this.program, 'a_destRect')
|
|
263
|
+
this.gl.bindBuffer(this.gl.ARRAY_BUFFER, this.instanceDestRectBuffer)
|
|
264
|
+
this.gl.enableVertexAttribArray(destRectLoc)
|
|
265
|
+
this.gl.vertexAttribPointer(destRectLoc, 4, this.gl.FLOAT, false, 0, 0)
|
|
266
|
+
this.gl.vertexAttribDivisor(destRectLoc, 1)
|
|
267
|
+
|
|
268
|
+
const colorLoc = this.gl.getAttribLocation(this.program, 'a_color')
|
|
269
|
+
this.gl.bindBuffer(this.gl.ARRAY_BUFFER, this.instanceColorBuffer)
|
|
270
|
+
this.gl.enableVertexAttribArray(colorLoc)
|
|
271
|
+
this.gl.vertexAttribPointer(colorLoc, 4, this.gl.FLOAT, false, 0, 0)
|
|
272
|
+
this.gl.vertexAttribDivisor(colorLoc, 1)
|
|
273
|
+
|
|
274
|
+
const texLayerLoc = this.gl.getAttribLocation(this.program, 'a_texLayer')
|
|
275
|
+
this.gl.bindBuffer(this.gl.ARRAY_BUFFER, this.instanceTexLayerBuffer)
|
|
276
|
+
this.gl.enableVertexAttribArray(texLayerLoc)
|
|
277
|
+
this.gl.vertexAttribPointer(texLayerLoc, 1, this.gl.FLOAT, false, 0, 0)
|
|
278
|
+
this.gl.vertexAttribDivisor(texLayerLoc, 1)
|
|
279
|
+
|
|
280
|
+
// Set up blending for premultiplied alpha
|
|
281
|
+
this.gl.enable(this.gl.BLEND)
|
|
282
|
+
this.gl.blendFunc(this.gl.ONE, this.gl.ONE_MINUS_SRC_ALPHA)
|
|
283
|
+
|
|
284
|
+
// Use the program
|
|
285
|
+
this.gl.useProgram(this.program)
|
|
286
|
+
|
|
287
|
+
// Set texture unit
|
|
288
|
+
this.gl.uniform1i(this.u_texArray, 0)
|
|
289
|
+
|
|
290
|
+
// Set initial color matrix
|
|
291
|
+
this.gl.uniformMatrix3fv(this.u_colorMatrix, false, this.colorMatrix)
|
|
292
|
+
|
|
293
|
+
// Set one-time GL state
|
|
294
|
+
this.gl.pixelStorei(this.gl.UNPACK_ALIGNMENT, 1)
|
|
295
|
+
this.gl.clearColor(0, 0, 0, 0)
|
|
296
|
+
this.gl.activeTexture(this.gl.TEXTURE0)
|
|
297
|
+
|
|
298
|
+
// Create initial texture array
|
|
299
|
+
this.createTexArray(TEX_INITIAL_SIZE, TEX_INITIAL_SIZE)
|
|
303
300
|
}
|
|
304
301
|
|
|
305
302
|
createShader (type: number, source: string): WebGLShader | null {
|
|
@@ -367,8 +364,21 @@ export class WebGL2Renderer {
|
|
|
367
364
|
heap = self.HEAPU8RAW = new Uint8Array(self.WASMMEMORY.buffer)
|
|
368
365
|
}
|
|
369
366
|
|
|
370
|
-
//
|
|
371
|
-
|
|
367
|
+
// we scheduled a resize because changing the canvas size clears it, and we don't want it to flicker
|
|
368
|
+
// so we do it here, right before rendering
|
|
369
|
+
if (this._scheduledResize) {
|
|
370
|
+
const { width, height } = this._scheduledResize
|
|
371
|
+
this._scheduledResize = undefined
|
|
372
|
+
this.canvas!.width = width
|
|
373
|
+
this.canvas!.height = height
|
|
374
|
+
|
|
375
|
+
// Update viewport and resolution uniform
|
|
376
|
+
this.gl.viewport(0, 0, width, height)
|
|
377
|
+
this.gl.uniform2f(this.u_resolution, width, height)
|
|
378
|
+
} else {
|
|
379
|
+
// Clear canvas
|
|
380
|
+
this.gl.clear(this.gl.COLOR_BUFFER_BIT)
|
|
381
|
+
}
|
|
372
382
|
|
|
373
383
|
// Find max dimensions needed and filter valid images
|
|
374
384
|
let maxW = this.texArrayWidth
|