Line data Source code
1 : type CanvasTrackerOwnership =
2 : | { status: 'unbound' }
3 : | { status: 'bound'; tracker: object }
4 : | { status: 'invalidated' }
5 :
6 2356 : let ownership: CanvasTrackerOwnership = { status: 'unbound' }
7 :
8 3897 : export function bindCanvasTracker(tracker: object): void {
9 3897 : ownership = { status: 'bound', tracker }
10 : }
11 :
12 3903 : export function invalidateCanvasTracker(): void {
13 3903 : ownership = { status: 'invalidated' }
14 : }
15 :
16 32 : export function isCanvasOwner(tracker: object): boolean {
17 32 : return ownership.status === 'bound' && ownership.tracker === tracker
18 : }
19 :
20 11358 : export function canCaptureCanvas(tracker: object): boolean {
21 11358 : return (
22 : ownership.status === 'unbound' ||
23 : (ownership.status === 'bound' && ownership.tracker === tracker)
24 : )
25 : }
26 :
27 10257 : export function isCanvasCaptureBlocked(): boolean {
28 10257 : return ownership.status === 'invalidated'
29 : }
30 :
31 0 : export function resetCanvasTrackerForTest(): void {
32 0 : ownership = { status: 'unbound' }
33 : }
|