vexflow-native 1.3.0 → 1.4.1
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 +16 -1
- 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/ScorePlayhead.js +54 -0
- package/lib/module/renderer/ScoreRenderer/ScorePlayhead.js.map +1 -0
- package/lib/module/renderer/ScoreRenderer/ScoreRenderer.js +54 -151
- package/lib/module/renderer/ScoreRenderer/ScoreRenderer.js.map +1 -1
- package/lib/module/renderer/ScoreRenderer/index.js +3 -1
- package/lib/module/renderer/ScoreRenderer/index.js.map +1 -1
- package/lib/module/renderer/ScoreRenderer/useScoreScroll.js +3 -1
- package/lib/module/renderer/ScoreRenderer/useScoreScroll.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/render.js +5 -1
- package/lib/module/renderer/render.js.map +1 -1
- package/lib/module/renderer/scale.js +5 -1
- package/lib/module/renderer/scale.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/ScorePlayhead.d.ts +32 -0
- package/lib/typescript/src/renderer/ScoreRenderer/ScorePlayhead.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 +3 -1
- package/lib/typescript/src/renderer/ScoreRenderer/index.d.ts.map +1 -1
- package/lib/typescript/src/renderer/ScoreRenderer/types.d.ts +35 -2
- package/lib/typescript/src/renderer/ScoreRenderer/types.d.ts.map +1 -1
- package/lib/typescript/src/renderer/ScoreRenderer/useScoreScroll.d.ts +5 -1
- package/lib/typescript/src/renderer/ScoreRenderer/useScoreScroll.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/render.d.ts.map +1 -1
- package/lib/typescript/src/renderer/scale.d.ts.map +1 -1
- package/lib/typescript/src/renderer/types.d.ts +63 -3
- 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/ScorePlayhead.tsx +123 -0
- package/src/renderer/ScoreRenderer/ScoreRenderer.tsx +86 -206
- package/src/renderer/ScoreRenderer/index.ts +3 -1
- package/src/renderer/ScoreRenderer/types.ts +48 -2
- package/src/renderer/ScoreRenderer/useScoreScroll.ts +7 -1
- package/src/renderer/ScoreRenderer/utils.ts +285 -0
- package/src/renderer/index.ts +5 -0
- package/src/renderer/render.tsx +4 -0
- package/src/renderer/scale.ts +4 -0
- package/src/renderer/types.ts +67 -3
- package/src/renderer/useScoreRecording.ts +18 -9
- package/src/shared/debug.ts +27 -0
|
@@ -6,6 +6,40 @@ import type { ScoreColorScheme } from './colorScheme';
|
|
|
6
6
|
export type RendererType = 'infiniteScore' | 'document' | 'documentEven';
|
|
7
7
|
export type ScoreItemStyleOverride = VexflowStyleOverride;
|
|
8
8
|
export type ScoreItemStyleOverrides = Record<string, ScoreItemStyleOverride>;
|
|
9
|
+
/** Scroll direction of a renderer type: `infiniteScore` pans horizontally,
|
|
10
|
+
* the document types scroll vertically. */
|
|
11
|
+
export type ScrollAxis = 'horizontal' | 'vertical';
|
|
12
|
+
/**
|
|
13
|
+
* Position of the playhead overlay, in the same view-space coordinates as
|
|
14
|
+
* {@link ScoreItemsLayout} (scroll offset 0). `x` is the playhead's center
|
|
15
|
+
* line; `y`/`height` bound the system band it should span. `null` hides it.
|
|
16
|
+
*/
|
|
17
|
+
export interface ScorePlayheadState {
|
|
18
|
+
x: number;
|
|
19
|
+
y: number;
|
|
20
|
+
height: number;
|
|
21
|
+
}
|
|
22
|
+
/** Appearance of the playhead overlay; unset fields use renderer defaults. */
|
|
23
|
+
export interface ScorePlayheadStyle {
|
|
24
|
+
/** Defaults to the resolved color scheme's foreground. */
|
|
25
|
+
color?: string;
|
|
26
|
+
/** Line width in view-space points, default 2. */
|
|
27
|
+
width?: number;
|
|
28
|
+
/** Corner radius, default half the width. */
|
|
29
|
+
borderRadius?: number;
|
|
30
|
+
/** Opacity while visible, default 0.9. */
|
|
31
|
+
opacity?: number;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Scroll envelope of the current recording pass, in view space. `maxScroll`
|
|
35
|
+
* is the largest valid scroll offset along `axis` (0 when content fits).
|
|
36
|
+
*/
|
|
37
|
+
export interface ScoreScrollGeometry {
|
|
38
|
+
axis: ScrollAxis;
|
|
39
|
+
viewportSize: RendererSize;
|
|
40
|
+
contentSize: RendererSize;
|
|
41
|
+
maxScroll: number;
|
|
42
|
+
}
|
|
9
43
|
export interface ScoreRendererProps {
|
|
10
44
|
score: Score;
|
|
11
45
|
defaultFont: string;
|
|
@@ -16,12 +50,30 @@ export interface ScoreRendererProps {
|
|
|
16
50
|
options?: ScoreRendererOptions;
|
|
17
51
|
scrollEnabled?: boolean;
|
|
18
52
|
showScrollbars?: boolean;
|
|
53
|
+
/**
|
|
54
|
+
* Controlled scroll offset along the renderer's {@link ScrollAxis}. When
|
|
55
|
+
* provided, the renderer reads AND writes this value (pan gesture, decay,
|
|
56
|
+
* re-clamping) instead of an internal one, and external writes move the
|
|
57
|
+
* content. Must be the same SharedValue for the component's lifetime.
|
|
58
|
+
*/
|
|
59
|
+
scrollOffset?: SharedValue<number>;
|
|
60
|
+
/**
|
|
61
|
+
* Playhead overlay position in {@link ScoreItemsLayout} view-space
|
|
62
|
+
* coordinates (scroll offset 0); `null` hides the overlay. Drivable from
|
|
63
|
+
* the UI thread — the overlay follows scrolling and clipping on its own.
|
|
64
|
+
*/
|
|
65
|
+
playhead?: SharedValue<ScorePlayheadState | null>;
|
|
66
|
+
playheadStyle?: ScorePlayheadStyle;
|
|
67
|
+
/**
|
|
68
|
+
* Fired whenever the scroll envelope changes: the axis, the viewport size,
|
|
69
|
+
* or the view-space content size (and with it `maxScroll`).
|
|
70
|
+
*/
|
|
71
|
+
onScrollGeometry?: (geometry: ScoreScrollGeometry) => void;
|
|
19
72
|
/**
|
|
20
73
|
* Fired after every recording pass with the final geometry of the rendered
|
|
21
74
|
* score. Coordinates are view-space points at scroll offset 0 and do not
|
|
22
|
-
* track scrolling
|
|
23
|
-
*
|
|
24
|
-
* mapped to on-screen positions.
|
|
75
|
+
* track scrolling; subtract the current scroll offset along the scroll
|
|
76
|
+
* axis to obtain on-screen positions.
|
|
25
77
|
*
|
|
26
78
|
* @param layout Geometry of all rendered items and measures.
|
|
27
79
|
*/
|
|
@@ -110,6 +162,14 @@ export interface ScoreMeasureItemsLayout {
|
|
|
110
162
|
staveNoteStartX: number;
|
|
111
163
|
/** X where the note area of this stave ends. */
|
|
112
164
|
staveNoteEndX: number;
|
|
165
|
+
/** Top of the measure's system block (all staves of the group). */
|
|
166
|
+
y: number;
|
|
167
|
+
/** Height of the measure's system block. */
|
|
168
|
+
height: number;
|
|
169
|
+
/** Top edge of this stave's top staff line. */
|
|
170
|
+
staveLineTopY: number;
|
|
171
|
+
/** Bottom edge of this stave's bottom staff line. */
|
|
172
|
+
staveLineBottomY: number;
|
|
113
173
|
}
|
|
114
174
|
/**
|
|
115
175
|
* Geometry of all rendered items keyed by item id, plus per-stave measure
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/renderer/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AACzE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAE3D,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AACpD,OAAO,KAAK,EA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AAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,MAAM,CAAC;IACpB,sBAAsB;IACtB,CAAC,EAAE,MAAM,CAAC;IACV,mBAAmB;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,oEAAoE;IACpE,eAAe,EAAE,MAAM,CAAC;IACxB,gDAAgD;IAChD,aAAa,EAAE,MAAM,CAAC;IACtB,mEAAmE;IACnE,CAAC,EAAE,MAAM,CAAC;IACV,4CAA4C;IAC5C,MAAM,EAAE,MAAM,CAAC;IACf,+CAA+C;IAC/C,aAAa,EAAE,MAAM,CAAC;IACtB,qDAAqD;IACrD,gBAAgB,EAAE,MAAM,CAAC;CAC1B;AAED;;;GAGG;AACH,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC;IACvC,QAAQ,EAAE,uBAAuB,EAAE,CAAC;IACpC,WAAW,EAAE,YAAY,CAAC;CAC3B;AAED,MAAM,WAAW,aAAa;IAC5B,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX;AAED,MAAM,WAAW,YAAY;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,YAAa,SAAQ,aAAa,EAAE,YAAY;CAAG;AAEpE,MAAM,WAAW,eAAgB,SAAQ,YAAY;CAAG"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { SkTypefaceFontProvider } from '@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
|
+
}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { RoundedRect, Skia, type SkRRect } from '@shopify/react-native-skia';
|
|
3
|
+
import { useDerivedValue, type SharedValue } from 'react-native-reanimated';
|
|
4
|
+
|
|
5
|
+
import type {
|
|
6
|
+
RendererSize,
|
|
7
|
+
RendererType,
|
|
8
|
+
ScorePlayheadState,
|
|
9
|
+
ScorePlayheadStyle,
|
|
10
|
+
} from '../types';
|
|
11
|
+
import { createVisibleViewport } from '../viewport';
|
|
12
|
+
|
|
13
|
+
export interface ResolvedPlayheadStyle {
|
|
14
|
+
color: string;
|
|
15
|
+
width: number;
|
|
16
|
+
borderRadius: number;
|
|
17
|
+
opacity: number;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
type ScorePlayheadProps = {
|
|
21
|
+
playhead: SharedValue<ScorePlayheadState | null>;
|
|
22
|
+
scrollOffset: SharedValue<number>;
|
|
23
|
+
rendererType: RendererType;
|
|
24
|
+
viewportSize: SharedValue<RendererSize>;
|
|
25
|
+
contentSize: SharedValue<RendererSize>;
|
|
26
|
+
style: ResolvedPlayheadStyle;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export function resolvePlayheadStyle(
|
|
30
|
+
style: ScorePlayheadStyle | undefined,
|
|
31
|
+
foreground: string
|
|
32
|
+
): ResolvedPlayheadStyle {
|
|
33
|
+
const width = style?.width ?? 2;
|
|
34
|
+
|
|
35
|
+
return {
|
|
36
|
+
color: style?.color ?? foreground,
|
|
37
|
+
width,
|
|
38
|
+
borderRadius: style?.borderRadius ?? width / 2,
|
|
39
|
+
opacity: style?.opacity ?? 0.9,
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Maps a playhead state (view space at scroll offset 0) to the on-screen
|
|
45
|
+
* rect: the scroll translation along the active axis is subtracted, the
|
|
46
|
+
* render scale is NOT applied — itemsLayout coordinates are already view
|
|
47
|
+
* space. A null state collapses to a zero rect (declarative Skia cannot
|
|
48
|
+
* unmount from the UI thread; a zero rect draws nothing).
|
|
49
|
+
*/
|
|
50
|
+
export function createPlayheadRect(
|
|
51
|
+
state: ScorePlayheadState | null,
|
|
52
|
+
scrollOffset: number,
|
|
53
|
+
rendererType: RendererType,
|
|
54
|
+
viewportSize: RendererSize,
|
|
55
|
+
contentSize: RendererSize,
|
|
56
|
+
width: number,
|
|
57
|
+
borderRadius: number
|
|
58
|
+
): SkRRect {
|
|
59
|
+
'worklet';
|
|
60
|
+
|
|
61
|
+
if (!state) {
|
|
62
|
+
return Skia.RRectXY(Skia.XYWHRect(0, 0, 0, 0), 0, 0);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
const visible = createVisibleViewport(
|
|
66
|
+
scrollOffset,
|
|
67
|
+
rendererType,
|
|
68
|
+
viewportSize,
|
|
69
|
+
contentSize
|
|
70
|
+
);
|
|
71
|
+
|
|
72
|
+
return Skia.RRectXY(
|
|
73
|
+
Skia.XYWHRect(
|
|
74
|
+
state.x - width / 2 - visible.x,
|
|
75
|
+
state.y - visible.y,
|
|
76
|
+
width,
|
|
77
|
+
state.height
|
|
78
|
+
),
|
|
79
|
+
borderRadius,
|
|
80
|
+
borderRadius
|
|
81
|
+
);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/** The playback position line, drawn over the notation inside the viewport
|
|
85
|
+
* clip. Follows scrolling on the UI thread without re-recording the score. */
|
|
86
|
+
const ScorePlayhead: React.FC<ScorePlayheadProps> = ({
|
|
87
|
+
playhead,
|
|
88
|
+
scrollOffset,
|
|
89
|
+
rendererType,
|
|
90
|
+
viewportSize,
|
|
91
|
+
contentSize,
|
|
92
|
+
style,
|
|
93
|
+
}) => {
|
|
94
|
+
const rect = useDerivedValue(
|
|
95
|
+
() =>
|
|
96
|
+
createPlayheadRect(
|
|
97
|
+
playhead.value,
|
|
98
|
+
scrollOffset.value,
|
|
99
|
+
rendererType,
|
|
100
|
+
viewportSize.value,
|
|
101
|
+
contentSize.value,
|
|
102
|
+
style.width,
|
|
103
|
+
style.borderRadius
|
|
104
|
+
),
|
|
105
|
+
[
|
|
106
|
+
contentSize,
|
|
107
|
+
playhead,
|
|
108
|
+
rendererType,
|
|
109
|
+
scrollOffset,
|
|
110
|
+
style.borderRadius,
|
|
111
|
+
style.width,
|
|
112
|
+
viewportSize,
|
|
113
|
+
]
|
|
114
|
+
);
|
|
115
|
+
const opacity = useDerivedValue(
|
|
116
|
+
() => (playhead.value ? style.opacity : 0),
|
|
117
|
+
[playhead, style.opacity]
|
|
118
|
+
);
|
|
119
|
+
|
|
120
|
+
return <RoundedRect rect={rect} color={style.color} opacity={opacity} />;
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
export default ScorePlayhead;
|