vexflow-native 1.4.0 → 1.6.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 +4 -0
- package/lib/module/base/FontManager.js +0 -0
- package/lib/module/base/FontManager.js.map +1 -1
- package/lib/module/base/VexflowRecordingIndex.js +13 -0
- package/lib/module/base/VexflowRecordingIndex.js.map +1 -0
- package/lib/module/base/VexflowRecordingReplay.js +58 -15
- package/lib/module/base/VexflowRecordingReplay.js.map +1 -1
- package/lib/module/base/index.js +2 -0
- package/lib/module/base/index.js.map +1 -1
- package/lib/module/renderer/ScoreRenderer/ScoreOverlayPicture.js +81 -0
- package/lib/module/renderer/ScoreRenderer/ScoreOverlayPicture.js.map +1 -0
- package/lib/module/renderer/ScoreRenderer/ScoreRenderer.js +36 -152
- package/lib/module/renderer/ScoreRenderer/ScoreRenderer.js.map +1 -1
- package/lib/module/renderer/ScoreRenderer/index.js +2 -1
- package/lib/module/renderer/ScoreRenderer/index.js.map +1 -1
- package/lib/module/renderer/ScoreRenderer/utils.js +207 -0
- package/lib/module/renderer/ScoreRenderer/utils.js.map +1 -0
- package/lib/module/renderer/index.js +1 -0
- package/lib/module/renderer/index.js.map +1 -1
- package/lib/module/renderer/useScoreRecording.js +9 -7
- package/lib/module/renderer/useScoreRecording.js.map +1 -1
- package/lib/module/shared/debug.js +24 -0
- package/lib/module/shared/debug.js.map +1 -0
- package/lib/typescript/src/base/FontManager.d.ts +3 -0
- package/lib/typescript/src/base/FontManager.d.ts.map +1 -1
- package/lib/typescript/src/base/VexflowRecordingIndex.d.ts +4 -0
- package/lib/typescript/src/base/VexflowRecordingIndex.d.ts.map +1 -0
- package/lib/typescript/src/base/VexflowRecordingReplay.d.ts +8 -1
- package/lib/typescript/src/base/VexflowRecordingReplay.d.ts.map +1 -1
- package/lib/typescript/src/base/index.d.ts +2 -0
- package/lib/typescript/src/base/index.d.ts.map +1 -1
- package/lib/typescript/src/renderer/ScoreRenderer/ScoreOverlayPicture.d.ts +11 -0
- package/lib/typescript/src/renderer/ScoreRenderer/ScoreOverlayPicture.d.ts.map +1 -0
- package/lib/typescript/src/renderer/ScoreRenderer/ScoreRenderer.d.ts +1 -17
- package/lib/typescript/src/renderer/ScoreRenderer/ScoreRenderer.d.ts.map +1 -1
- package/lib/typescript/src/renderer/ScoreRenderer/index.d.ts +2 -1
- package/lib/typescript/src/renderer/ScoreRenderer/index.d.ts.map +1 -1
- package/lib/typescript/src/renderer/ScoreRenderer/types.d.ts +34 -1
- package/lib/typescript/src/renderer/ScoreRenderer/types.d.ts.map +1 -1
- package/lib/typescript/src/renderer/ScoreRenderer/utils.d.ts +40 -0
- package/lib/typescript/src/renderer/ScoreRenderer/utils.d.ts.map +1 -0
- package/lib/typescript/src/renderer/index.d.ts +1 -0
- package/lib/typescript/src/renderer/index.d.ts.map +1 -1
- package/lib/typescript/src/renderer/types.d.ts +1 -0
- package/lib/typescript/src/renderer/types.d.ts.map +1 -1
- package/lib/typescript/src/renderer/useScoreRecording.d.ts +6 -0
- package/lib/typescript/src/renderer/useScoreRecording.d.ts.map +1 -1
- package/lib/typescript/src/shared/debug.d.ts +3 -0
- package/lib/typescript/src/shared/debug.d.ts.map +1 -0
- package/package.json +1 -1
- package/src/base/FontManager.ts +0 -0
- package/src/base/VexflowRecordingIndex.ts +21 -0
- package/src/base/VexflowRecordingReplay.ts +103 -19
- package/src/base/index.ts +9 -0
- package/src/renderer/ScoreRenderer/ScoreOverlayPicture.tsx +118 -0
- package/src/renderer/ScoreRenderer/ScoreRenderer.tsx +61 -207
- package/src/renderer/ScoreRenderer/index.ts +2 -1
- package/src/renderer/ScoreRenderer/types.ts +47 -1
- package/src/renderer/ScoreRenderer/utils.ts +285 -0
- package/src/renderer/index.ts +5 -0
- package/src/renderer/types.ts +1 -0
- package/src/renderer/useScoreRecording.ts +18 -9
- package/src/shared/debug.ts +27 -0
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { type SkPicture, type SkTypefaceFontProvider, type Transforms3d } from '@shopify/react-native-skia';
|
|
2
|
+
import type { SharedValue } from 'react-native-reanimated';
|
|
3
|
+
import FontManager from '../../base/FontManager';
|
|
4
|
+
import type { RendererSize, RendererType, ScoreOptions, ScoreRendererOptions, Viewport } from '../types';
|
|
5
|
+
import type { CreateScorePictureParams, OverlayDisposalState, OverlayFontManagerSlot, OverlayProfileState } from './types';
|
|
6
|
+
export declare function nowMsWorklet(): number;
|
|
7
|
+
export declare function withDefaultOptions(options: ScoreRendererOptions): ScoreOptions;
|
|
8
|
+
export declare function createScorePicture({ contentSize, defaultFont, fontManager, recordedCommands, replayFontManager, styleOverrides, }: CreateScorePictureParams): SkPicture;
|
|
9
|
+
export declare function createScorePictureWorklet({ contentSize, defaultFont, fontManager, recordedCommands, replayFontManager, styleOverrides, }: CreateScorePictureParams): SkPicture;
|
|
10
|
+
/**
|
|
11
|
+
* Maps the content-space picture into the view. Skia applies the transform
|
|
12
|
+
* array right-to-left, so the trailing scale entry runs first and the
|
|
13
|
+
* translate entries then shift by the view-space scroll offset; `contentSize`
|
|
14
|
+
* must be the view-space content size.
|
|
15
|
+
*/
|
|
16
|
+
export declare function createPictureTransform(scrollOffset: number, rendererType: RendererType, viewport: Viewport, contentSize: RendererSize, scale?: number): Transforms3d;
|
|
17
|
+
/**
|
|
18
|
+
* Runtime-local lazy FontManager: worklets cannot copy a class instance into
|
|
19
|
+
* a closure, so each runtime constructs its own on first use and keeps it in
|
|
20
|
+
* the slot (slot contents never cross runtimes; only the initial `null` is
|
|
21
|
+
* serialized).
|
|
22
|
+
*/
|
|
23
|
+
export declare function getOverlayFontManager(slot: SharedValue<OverlayFontManagerSlot>, fontProvider: SkTypefaceFontProvider, defaultFont: string): FontManager;
|
|
24
|
+
/**
|
|
25
|
+
* Shared blank picture returned while no override matches. One per app,
|
|
26
|
+
* never disposed — PictureProps.picture is non-nullable and declarative Skia
|
|
27
|
+
* can't unmount from the UI thread, so an "empty" frame needs a real picture.
|
|
28
|
+
*/
|
|
29
|
+
export declare function getEmptyOverlayPicture(): SkPicture;
|
|
30
|
+
/**
|
|
31
|
+
* Two-generation deferred disposal: the retiring picture may still be
|
|
32
|
+
* referenced by the committed Picture node or a frame in flight, so only
|
|
33
|
+
* pictures two supersessions old are disposed. The shared blank picture never
|
|
34
|
+
* enters the ring (`next === null` marks an empty frame).
|
|
35
|
+
*/
|
|
36
|
+
export declare function retireOverlayPicture(disposal: SharedValue<OverlayDisposalState>, next: SkPicture | null): void;
|
|
37
|
+
export declare function disposeOverlayPictures(disposal: SharedValue<OverlayDisposalState>): void;
|
|
38
|
+
/** Throttled (≤1/s) UI-thread record timing; debug flag only. */
|
|
39
|
+
export declare function logOverlayProfile(profile: SharedValue<OverlayProfileState>, commandCount: number, durationMs: number): void;
|
|
40
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../../src/renderer/ScoreRenderer/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,SAAS,EACd,KAAK,sBAAsB,EAC3B,KAAK,YAAY,EAClB,MAAM,4BAA4B,CAAC;AACpC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAE3D,OAAO,WAAW,MAAM,wBAAwB,CAAC;AAIjD,OAAO,KAAK,EACV,YAAY,EACZ,YAAY,EACZ,YAAY,EACZ,oBAAoB,EACpB,QAAQ,EACT,MAAM,UAAU,CAAC;AAElB,OAAO,KAAK,EACV,wBAAwB,EACxB,oBAAoB,EACpB,sBAAsB,EACtB,mBAAmB,EACpB,MAAM,SAAS,CAAC;AAKjB,wBAAgB,YAAY,IAAI,MAAM,CAIrC;AAUD,wBAAgB,kBAAkB,CAChC,OAAO,EAAE,oBAAoB,GAC5B,YAAY,CAMd;AAED,wBAAgB,kBAAkB,CAAC,EACjC,WAAW,EACX,WAAW,EACX,WAAW,EACX,gBAAgB,EAChB,iBAAiB,EACjB,cAAc,GACf,EAAE,wBAAwB,aAuB1B;AAED,wBAAgB,yBAAyB,CAAC,EACxC,WAAW,EACX,WAAW,EACX,WAAW,EACX,gBAAgB,EAChB,iBAAiB,EACjB,cAAc,GACf,EAAE,wBAAwB,GAAG,SAAS,CAkBtC;AAED;;;;;GAKG;AACH,wBAAgB,sBAAsB,CACpC,YAAY,EAAE,MAAM,EACpB,YAAY,EAAE,YAAY,EAC1B,QAAQ,EAAE,QAAQ,EAClB,WAAW,EAAE,YAAY,EACzB,KAAK,GAAE,MAAU,GAChB,YAAY,CAwBd;AAED;;;;;GAKG;AACH,wBAAgB,qBAAqB,CACnC,IAAI,EAAE,WAAW,CAAC,sBAAsB,CAAC,EACzC,YAAY,EAAE,sBAAsB,EACpC,WAAW,EAAE,MAAM,GAClB,WAAW,CAMb;AAID;;;;GAIG;AACH,wBAAgB,sBAAsB,IAAI,SAAS,CAQlD;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAClC,QAAQ,EAAE,WAAW,CAAC,oBAAoB,CAAC,EAC3C,IAAI,EAAE,SAAS,GAAG,IAAI,QAsBvB;AAED,wBAAgB,sBAAsB,CACpC,QAAQ,EAAE,WAAW,CAAC,oBAAoB,CAAC,QAa5C;AAED,iEAAiE;AACjE,wBAAgB,iBAAiB,CAC/B,OAAO,EAAE,WAAW,CAAC,mBAAmB,CAAC,EACzC,YAAY,EAAE,MAAM,EACpB,UAAU,EAAE,MAAM,QA0BnB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/renderer/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAC3D,cAAc,eAAe,CAAC;AAC9B,cAAc,SAAS,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/renderer/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OA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'@shopify/react-native-skia';
|
|
2
2
|
import type { VexflowRecordingCommand } from '../base';
|
|
3
|
+
import { type VexflowRecordingGroupIndex } from '../base/VexflowRecordingIndex';
|
|
3
4
|
import type { Score } from '../state';
|
|
4
5
|
import { type ScoreLayoutPlan } from './layout';
|
|
5
6
|
import type { ResolvedScoreColorScheme } from './colorScheme';
|
|
@@ -7,6 +8,11 @@ import type { RendererRect, RendererType, ScoreItemsLayout, ScoreOptions } from
|
|
|
7
8
|
export interface ScoreRecording {
|
|
8
9
|
/** Recorded draw commands, content-space coordinates. */
|
|
9
10
|
commands: readonly VexflowRecordingCommand[];
|
|
11
|
+
/**
|
|
12
|
+
* `commands` bucketed by `groupId` so a style-override replay can redraw
|
|
13
|
+
* just the overridden items instead of the whole recording.
|
|
14
|
+
*/
|
|
15
|
+
groupIndex: VexflowRecordingGroupIndex;
|
|
10
16
|
/**
|
|
11
17
|
* Layout plan in content space; multiply its `contentSize` by the render
|
|
12
18
|
* scale for the view-space size that drives scrolling.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useScoreRecording.d.ts","sourceRoot":"","sources":["../../../../src/renderer/useScoreRecording.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AAEzE,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,SAAS,CAAC;AAEvD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"useScoreRecording.d.ts","sourceRoot":"","sources":["../../../../src/renderer/useScoreRecording.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AAEzE,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,SAAS,CAAC;AAEvD,OAAO,EAEL,KAAK,0BAA0B,EAChC,MAAM,+BAA+B,CAAC;AACvC,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AAEtC,OAAO,EAAe,KAAK,eAAe,EAAE,MAAM,UAAU,CAAC;AAQ7D,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,eAAe,CAAC;AAC9D,OAAO,KAAK,EACV,YAAY,EACZ,YAAY,EACZ,gBAAgB,EAChB,YAAY,EACb,MAAM,SAAS,CAAC;AAEjB,MAAM,WAAW,cAAc;IAC7B,yDAAyD;IACzD,QAAQ,EAAE,SAAS,uBAAuB,EAAE,CAAC;IAC7C;;;OAGG;IACH,UAAU,EAAE,0BAA0B,CAAC;IACvC;;;OAGG;IACH,UAAU,EAAE,eAAe,CAAC;IAC5B,yDAAyD;IACzD,WAAW,EAAE,gBAAgB,CAAC;CAC/B;AAED,wBAAgB,iBAAiB,CAAC,EAChC,WAAW,EACX,OAAc,EACd,WAAW,EACX,WAAW,EACX,OAAO,EACP,YAAY,EACZ,KAAK,EACL,QAAQ,GACT,EAAE;IACD,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,WAAW,EAAE,sBAAsB,CAAC;IACpC,WAAW,EAAE,wBAAwB,CAAC;IACtC,OAAO,EAAE,YAAY,CAAC;IACtB,YAAY,EAAE,YAAY,CAAC;IAC3B,KAAK,EAAE,KAAK,CAAC;IACb,QAAQ,EAAE,YAAY,CAAC;CACxB,GAAG,cAAc,CA8EjB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"debug.d.ts","sourceRoot":"","sources":["../../../../src/shared/debug.ts"],"names":[],"mappings":"AAaA,wBAAgB,4BAA4B,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAEnE;AAED,wBAAgB,2BAA2B,IAAI,OAAO,CASrD"}
|
package/package.json
CHANGED
package/src/base/FontManager.ts
CHANGED
|
Binary file
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { VexflowRecordingCommand } from './VexflowRecordingTypes';
|
|
2
|
+
|
|
3
|
+
export type VexflowRecordingGroupIndex = Readonly<
|
|
4
|
+
Record<string, readonly VexflowRecordingCommand[]>
|
|
5
|
+
>;
|
|
6
|
+
|
|
7
|
+
export function buildVexflowGroupIndex(
|
|
8
|
+
commands: readonly VexflowRecordingCommand[]
|
|
9
|
+
): VexflowRecordingGroupIndex {
|
|
10
|
+
const index: Record<string, VexflowRecordingCommand[]> = {};
|
|
11
|
+
|
|
12
|
+
for (const command of commands) {
|
|
13
|
+
if (command.groupId == null) {
|
|
14
|
+
continue;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
(index[command.groupId] ??= []).push(command);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
return index;
|
|
21
|
+
}
|
|
@@ -5,6 +5,7 @@ import {
|
|
|
5
5
|
Skia,
|
|
6
6
|
StrokeCap,
|
|
7
7
|
type SkCanvas,
|
|
8
|
+
type SkColor,
|
|
8
9
|
type SkPaint,
|
|
9
10
|
type SkPathBuilder,
|
|
10
11
|
type SkTypefaceFontProvider,
|
|
@@ -33,16 +34,35 @@ function shadowBlurToSigma(shadowBlur: number): number {
|
|
|
33
34
|
return shadowBlur / 2;
|
|
34
35
|
}
|
|
35
36
|
|
|
37
|
+
/**
|
|
38
|
+
* Per-replay `css color -> SkColor` cache: a recording uses a handful of
|
|
39
|
+
* distinct colors but references them thousands of times.
|
|
40
|
+
*/
|
|
41
|
+
type SkColorCache = Record<string, SkColor>;
|
|
42
|
+
|
|
43
|
+
function getCachedColor(color: string, cache: SkColorCache): SkColor {
|
|
44
|
+
'worklet';
|
|
45
|
+
|
|
46
|
+
return (cache[color] ??= Skia.Color(color));
|
|
47
|
+
}
|
|
48
|
+
|
|
36
49
|
/**
|
|
37
50
|
* Apply the recorded glow (CSS shadow) to a Skia paint as a drop-shadow image
|
|
38
51
|
* filter. `dx = dy = 0` turns the drop shadow into a symmetric glow centred on
|
|
39
52
|
* the ink; `MakeDropShadow` (not `…Only`) keeps the source content, so the note
|
|
40
53
|
* still draws on top of its halo. No-op unless a `shadowColor` resolved.
|
|
41
54
|
*/
|
|
42
|
-
function applyGlow(
|
|
55
|
+
function applyGlow(
|
|
56
|
+
skPaint: SkPaint,
|
|
57
|
+
paint: VexflowRecordingPaint,
|
|
58
|
+
colorCache: SkColorCache
|
|
59
|
+
) {
|
|
43
60
|
'worklet';
|
|
44
61
|
|
|
45
62
|
if (paint.shadowColor == null) {
|
|
63
|
+
// Pooled paints carry state between commands — explicitly clear a filter
|
|
64
|
+
// a previous command may have set.
|
|
65
|
+
skPaint.setImageFilter(null);
|
|
46
66
|
return;
|
|
47
67
|
}
|
|
48
68
|
|
|
@@ -54,7 +74,7 @@ function applyGlow(skPaint: SkPaint, paint: VexflowRecordingPaint) {
|
|
|
54
74
|
0,
|
|
55
75
|
sigma,
|
|
56
76
|
sigma,
|
|
57
|
-
|
|
77
|
+
getCachedColor(paint.shadowColor, colorCache)
|
|
58
78
|
)
|
|
59
79
|
);
|
|
60
80
|
}
|
|
@@ -79,31 +99,62 @@ function mapRecordingLineCap(cap: VexflowRecordingLineCap): StrokeCap {
|
|
|
79
99
|
}
|
|
80
100
|
}
|
|
81
101
|
|
|
82
|
-
|
|
102
|
+
/**
|
|
103
|
+
* One fill and one stroke paint are pooled per replay call and reconfigured
|
|
104
|
+
* per command — Skia snapshots paint state into the canvas/display list at
|
|
105
|
+
* each draw call, so mutating the pooled paint afterwards is safe. Optional
|
|
106
|
+
* state (glow filter, dash effect) is explicitly reset on every configure so
|
|
107
|
+
* nothing bleeds between commands.
|
|
108
|
+
*/
|
|
109
|
+
function createPooledFillPaint(): SkPaint {
|
|
83
110
|
'worklet';
|
|
84
111
|
|
|
85
112
|
const skPaint = Skia.Paint();
|
|
86
113
|
skPaint.setStyle(PaintStyle.Fill);
|
|
87
114
|
skPaint.setAntiAlias(true);
|
|
88
|
-
skPaint.setColor(Skia.Color(paint.color));
|
|
89
|
-
applyGlow(skPaint, paint);
|
|
90
115
|
|
|
91
116
|
return skPaint;
|
|
92
117
|
}
|
|
93
118
|
|
|
94
|
-
function
|
|
119
|
+
function createPooledStrokePaint(): SkPaint {
|
|
95
120
|
'worklet';
|
|
96
121
|
|
|
97
122
|
const skPaint = Skia.Paint();
|
|
98
123
|
skPaint.setStyle(PaintStyle.Stroke);
|
|
99
124
|
skPaint.setAntiAlias(true);
|
|
100
|
-
|
|
125
|
+
|
|
126
|
+
return skPaint;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
function configureFillPaint(
|
|
130
|
+
skPaint: SkPaint,
|
|
131
|
+
paint: VexflowRecordingPaint,
|
|
132
|
+
colorCache: SkColorCache
|
|
133
|
+
): SkPaint {
|
|
134
|
+
'worklet';
|
|
135
|
+
|
|
136
|
+
skPaint.setColor(getCachedColor(paint.color, colorCache));
|
|
137
|
+
applyGlow(skPaint, paint, colorCache);
|
|
138
|
+
|
|
139
|
+
return skPaint;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
function configureStrokePaint(
|
|
143
|
+
skPaint: SkPaint,
|
|
144
|
+
paint: VexflowRecordingPaint,
|
|
145
|
+
colorCache: SkColorCache
|
|
146
|
+
): SkPaint {
|
|
147
|
+
'worklet';
|
|
148
|
+
|
|
149
|
+
skPaint.setColor(getCachedColor(paint.color, colorCache));
|
|
101
150
|
skPaint.setStrokeWidth(paint.strokeWidth ?? 1);
|
|
102
151
|
skPaint.setStrokeCap(mapRecordingLineCap(paint.strokeCap ?? 'butt'));
|
|
103
|
-
applyGlow(skPaint, paint);
|
|
152
|
+
applyGlow(skPaint, paint, colorCache);
|
|
104
153
|
|
|
105
154
|
if (paint.lineDash != null && paint.lineDash.length > 0) {
|
|
106
155
|
skPaint.setPathEffect(Skia.PathEffect.MakeDash(paint.lineDash));
|
|
156
|
+
} else {
|
|
157
|
+
skPaint.setPathEffect(null);
|
|
107
158
|
}
|
|
108
159
|
|
|
109
160
|
return skPaint;
|
|
@@ -251,16 +302,26 @@ export function renderVexflowRecordingCommands(
|
|
|
251
302
|
* colours, a glow (shadow), and a stroke dash are all expressible. Omit for a
|
|
252
303
|
* byte-identical replay of the recorded style.
|
|
253
304
|
*/
|
|
254
|
-
styleOverrides?: Record<string, VexflowStyleOverride
|
|
305
|
+
styleOverrides?: Record<string, VexflowStyleOverride>,
|
|
306
|
+
/**
|
|
307
|
+
* Optional pre-built FontManager to reuse across replays so its SkFont /
|
|
308
|
+
* family caches survive between calls (e.g. one overlay replay per note).
|
|
309
|
+
* Omitted, one is constructed per call — the original behavior.
|
|
310
|
+
*/
|
|
311
|
+
replayFontManager?: FontManager
|
|
255
312
|
) {
|
|
256
313
|
'worklet';
|
|
257
314
|
|
|
258
|
-
const fontManager =
|
|
315
|
+
const fontManager =
|
|
316
|
+
replayFontManager ?? new FontManager(fontProvider, defaultFont);
|
|
317
|
+
const colorCache: SkColorCache = {};
|
|
318
|
+
const fillPaint = createPooledFillPaint();
|
|
319
|
+
const strokePaint = createPooledStrokePaint();
|
|
259
320
|
|
|
260
321
|
for (const command of commands) {
|
|
261
322
|
switch (command.type) {
|
|
262
323
|
case 'clear':
|
|
263
|
-
canvas.clear(
|
|
324
|
+
canvas.clear(getCachedColor(command.color, colorCache));
|
|
264
325
|
break;
|
|
265
326
|
case 'save':
|
|
266
327
|
canvas.save();
|
|
@@ -280,8 +341,15 @@ export function renderVexflowRecordingCommands(
|
|
|
280
341
|
case 'fillRect':
|
|
281
342
|
canvas.drawRect(
|
|
282
343
|
toSkiaRect(command.rect),
|
|
283
|
-
|
|
284
|
-
|
|
344
|
+
configureFillPaint(
|
|
345
|
+
fillPaint,
|
|
346
|
+
resolveStyle(
|
|
347
|
+
command.paint,
|
|
348
|
+
command.groupId,
|
|
349
|
+
'fill',
|
|
350
|
+
styleOverrides
|
|
351
|
+
),
|
|
352
|
+
colorCache
|
|
285
353
|
)
|
|
286
354
|
);
|
|
287
355
|
break;
|
|
@@ -291,21 +359,30 @@ export function renderVexflowRecordingCommands(
|
|
|
291
359
|
case 'fillPath':
|
|
292
360
|
canvas.drawPath(
|
|
293
361
|
buildPath(command.path),
|
|
294
|
-
|
|
295
|
-
|
|
362
|
+
configureFillPaint(
|
|
363
|
+
fillPaint,
|
|
364
|
+
resolveStyle(
|
|
365
|
+
command.paint,
|
|
366
|
+
command.groupId,
|
|
367
|
+
'fill',
|
|
368
|
+
styleOverrides
|
|
369
|
+
),
|
|
370
|
+
colorCache
|
|
296
371
|
)
|
|
297
372
|
);
|
|
298
373
|
break;
|
|
299
374
|
case 'strokePath':
|
|
300
375
|
canvas.drawPath(
|
|
301
376
|
buildPath(command.path),
|
|
302
|
-
|
|
377
|
+
configureStrokePaint(
|
|
378
|
+
strokePaint,
|
|
303
379
|
resolveStyle(
|
|
304
380
|
command.paint,
|
|
305
381
|
command.groupId,
|
|
306
382
|
'stroke',
|
|
307
383
|
styleOverrides
|
|
308
|
-
)
|
|
384
|
+
),
|
|
385
|
+
colorCache
|
|
309
386
|
)
|
|
310
387
|
);
|
|
311
388
|
break;
|
|
@@ -314,8 +391,15 @@ export function renderVexflowRecordingCommands(
|
|
|
314
391
|
command.text,
|
|
315
392
|
command.x,
|
|
316
393
|
command.y,
|
|
317
|
-
|
|
318
|
-
|
|
394
|
+
configureFillPaint(
|
|
395
|
+
fillPaint,
|
|
396
|
+
resolveStyle(
|
|
397
|
+
command.paint,
|
|
398
|
+
command.groupId,
|
|
399
|
+
'fill',
|
|
400
|
+
styleOverrides
|
|
401
|
+
),
|
|
402
|
+
colorCache
|
|
319
403
|
),
|
|
320
404
|
createFont(fontManager, command.font)
|
|
321
405
|
);
|
package/src/base/index.ts
CHANGED
|
@@ -1,7 +1,16 @@
|
|
|
1
1
|
export { default as VexflowCanvas } from './VexflowCanvas';
|
|
2
2
|
export { default as VexflowRecordingContext } from './VexflowRecordingContext';
|
|
3
3
|
export { renderVexflowRecordingCommands } from './VexflowRecordingReplay';
|
|
4
|
+
export {
|
|
5
|
+
buildVexflowGroupIndex,
|
|
6
|
+
type VexflowRecordingGroupIndex,
|
|
7
|
+
} from './VexflowRecordingIndex';
|
|
4
8
|
|
|
5
9
|
export * from './VexflowColorScheme';
|
|
6
10
|
export * from './VexflowRecordingTypes';
|
|
7
11
|
export * from './types';
|
|
12
|
+
|
|
13
|
+
export {
|
|
14
|
+
isVexflowNativeDebugEnabled,
|
|
15
|
+
setVexflowNativeDebugEnabled,
|
|
16
|
+
} from '../shared/debug';
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { useEffect, useMemo } from 'react';
|
|
2
|
+
import { Picture, type SkPicture } from '@shopify/react-native-skia';
|
|
3
|
+
import {
|
|
4
|
+
runOnUI,
|
|
5
|
+
useDerivedValue,
|
|
6
|
+
useSharedValue,
|
|
7
|
+
} from 'react-native-reanimated';
|
|
8
|
+
|
|
9
|
+
import type { VexflowRecordingCommand } from '../../base';
|
|
10
|
+
import { isVexflowNativeDebugEnabled } from '../../shared/debug';
|
|
11
|
+
import type {
|
|
12
|
+
OverlayDisposalState,
|
|
13
|
+
OverlayFontManagerSlot,
|
|
14
|
+
OverlayProfileState,
|
|
15
|
+
ScoreOverlayPictureProps,
|
|
16
|
+
} from './types';
|
|
17
|
+
import {
|
|
18
|
+
createScorePictureWorklet,
|
|
19
|
+
disposeOverlayPictures,
|
|
20
|
+
getEmptyOverlayPicture,
|
|
21
|
+
getOverlayFontManager,
|
|
22
|
+
logOverlayProfile,
|
|
23
|
+
nowMsWorklet,
|
|
24
|
+
retireOverlayPicture,
|
|
25
|
+
} from './utils';
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Draws the style-overridden items on top of the static base picture. Only
|
|
29
|
+
* the overridden groups' commands are re-recorded per override write — the
|
|
30
|
+
* full command array never reaches the UI runtime. Overridden items are drawn
|
|
31
|
+
* opaque over their base-colored twins at identical coordinates; with an
|
|
32
|
+
* opaque override color the result matches an in-place recolor up to a ≤1px
|
|
33
|
+
* anti-aliasing fringe of base ink at glyph edges.
|
|
34
|
+
*/
|
|
35
|
+
export default function ScoreOverlayPicture({
|
|
36
|
+
contentSize,
|
|
37
|
+
defaultFont,
|
|
38
|
+
fontManager,
|
|
39
|
+
groupIndex,
|
|
40
|
+
itemStyleOverrides,
|
|
41
|
+
}: ScoreOverlayPictureProps) {
|
|
42
|
+
const emptyPicture = useMemo(getEmptyOverlayPicture, []);
|
|
43
|
+
// A FontManager instance cannot be serialized into a worklet closure, so
|
|
44
|
+
// each runtime lazily constructs its own in this slot (never crossing
|
|
45
|
+
// runtimes) — its SkFont caches still persist across onsets.
|
|
46
|
+
const fontManagerSlot = useSharedValue<OverlayFontManagerSlot>({
|
|
47
|
+
manager: null,
|
|
48
|
+
});
|
|
49
|
+
const disposal = useSharedValue<OverlayDisposalState>({
|
|
50
|
+
prev: null,
|
|
51
|
+
pending: [],
|
|
52
|
+
});
|
|
53
|
+
const profile = useSharedValue<OverlayProfileState>({
|
|
54
|
+
windowStartMs: 0,
|
|
55
|
+
maxMs: 0,
|
|
56
|
+
count: 0,
|
|
57
|
+
});
|
|
58
|
+
// Read on JS and captured: the debug singleton lives on the JS runtime, so
|
|
59
|
+
// a toggle takes effect on the overlay's next render.
|
|
60
|
+
const enableProfiling = isVexflowNativeDebugEnabled();
|
|
61
|
+
|
|
62
|
+
const picture = useDerivedValue<SkPicture>(() => {
|
|
63
|
+
const overrides = itemStyleOverrides.value;
|
|
64
|
+
|
|
65
|
+
let commands: VexflowRecordingCommand[] | null = null;
|
|
66
|
+
for (const groupId in overrides) {
|
|
67
|
+
const group = groupIndex[groupId];
|
|
68
|
+
if (group != null) {
|
|
69
|
+
(commands ??= []).push(...group);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
if (commands == null) {
|
|
74
|
+
retireOverlayPicture(disposal, null);
|
|
75
|
+
return emptyPicture;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
const start = enableProfiling ? nowMsWorklet() : 0;
|
|
79
|
+
const next = createScorePictureWorklet({
|
|
80
|
+
contentSize,
|
|
81
|
+
defaultFont,
|
|
82
|
+
fontManager,
|
|
83
|
+
recordedCommands: commands,
|
|
84
|
+
replayFontManager: getOverlayFontManager(
|
|
85
|
+
fontManagerSlot,
|
|
86
|
+
fontManager,
|
|
87
|
+
defaultFont
|
|
88
|
+
),
|
|
89
|
+
styleOverrides: overrides,
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
if (enableProfiling) {
|
|
93
|
+
logOverlayProfile(profile, commands.length, nowMsWorklet() - start);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
retireOverlayPicture(disposal, next);
|
|
97
|
+
return next;
|
|
98
|
+
}, [
|
|
99
|
+
contentSize,
|
|
100
|
+
defaultFont,
|
|
101
|
+
disposal,
|
|
102
|
+
emptyPicture,
|
|
103
|
+
enableProfiling,
|
|
104
|
+
fontManager,
|
|
105
|
+
fontManagerSlot,
|
|
106
|
+
groupIndex,
|
|
107
|
+
itemStyleOverrides,
|
|
108
|
+
profile,
|
|
109
|
+
]);
|
|
110
|
+
|
|
111
|
+
useEffect(() => {
|
|
112
|
+
return () => {
|
|
113
|
+
runOnUI(disposeOverlayPictures)(disposal);
|
|
114
|
+
};
|
|
115
|
+
}, [disposal]);
|
|
116
|
+
|
|
117
|
+
return <Picture picture={picture} />;
|
|
118
|
+
}
|