skia-motion-runtime 3.4.1 → 3.4.2
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/package.json +1 -1
- package/runtime/asset-draw.ts +8 -8
package/package.json
CHANGED
package/runtime/asset-draw.ts
CHANGED
|
@@ -26,8 +26,8 @@ type DrawableNode =
|
|
|
26
26
|
rowParts?: readonly (Box | undefined)[];
|
|
27
27
|
})
|
|
28
28
|
| DrawableMesh
|
|
29
|
-
| (AssetTextNode & { paragraph?: SkParagraph })
|
|
30
|
-
| (DrawableShape & { preparedPath?: SkPath; preparedPaint?: SkPaint });
|
|
29
|
+
| (AssetTextNode & { paragraph?: SkParagraph; cacheKey?: string })
|
|
30
|
+
| (DrawableShape & { preparedPath?: SkPath; preparedPaint?: SkPaint; cacheKey?: string });
|
|
31
31
|
|
|
32
32
|
type DrawableShape = Exclude<AssetNode, { kind: 'group' | 'mesh' | 'text' }>;
|
|
33
33
|
type TextValues = Readonly<Record<string, string>>;
|
|
@@ -362,11 +362,11 @@ function prepareNode(
|
|
|
362
362
|
provider: SkTypefaceFontProvider | undefined, textBindings: Set<string>, palette: Palette,
|
|
363
363
|
): DrawableNode {
|
|
364
364
|
if (node.kind === 'text') {
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
textBindings.add(
|
|
365
|
+
const { text } = node;
|
|
366
|
+
if (typeof text === 'string') return { ...node, paragraph: makeParagraph(node, text, provider) };
|
|
367
|
+
textBindings.add(text.value);
|
|
368
368
|
if (node.roll) textBindings.add(node.roll.from);
|
|
369
|
-
return node;
|
|
369
|
+
return { ...node, cacheKey: `n${nextNodeKey++}` };
|
|
370
370
|
}
|
|
371
371
|
const commands = node.kind === 'group' ? node.clip : node.kind === 'path' ? node.commands : undefined;
|
|
372
372
|
const prepared = commands?.every(([, ...coordinates]) => coordinates.every((value) => typeof value === 'number'))
|
|
@@ -395,7 +395,7 @@ function prepareNode(
|
|
|
395
395
|
textureCoords: image ? meshTextureCoords(node, image) : undefined,
|
|
396
396
|
};
|
|
397
397
|
}
|
|
398
|
-
if (node.kind === 'image') return { ...node, cacheKey: `n${nextNodeKey++}` }
|
|
398
|
+
if (node.kind === 'image') return { ...node, cacheKey: `n${nextNodeKey++}` };
|
|
399
399
|
return { ...node, preparedPath: prepared, preparedPaint: preparePaint(node, palette) };
|
|
400
400
|
}
|
|
401
401
|
|
|
@@ -730,7 +730,7 @@ function drawNodes(
|
|
|
730
730
|
// The prepared shader only for the image it was made from: a host can pass other images to drawAsset.
|
|
731
731
|
const prepared = shaders.image[node.image];
|
|
732
732
|
const shader = prepared && prepared.image === image ? prepared.shader : imageShader(image);
|
|
733
|
-
const key =
|
|
733
|
+
const key = node.cacheKey;
|
|
734
734
|
// One paint per image node, reset each frame: a picture records a copy of the paint it draws with.
|
|
735
735
|
const filled = cached(key === undefined ? undefined : `paint|${key}`, () => {
|
|
736
736
|
const paint = Skia.Paint();
|