@shopify/react-native-skia 1.9.0 → 1.9.1
Sign up to get free protection for your applications and to get access to all the features.
- package/cpp/api/JsiSkCanvas.h +1 -1
- package/lib/commonjs/sksg/Container.js +1 -2
- package/lib/commonjs/sksg/Container.js.map +1 -1
- package/lib/commonjs/sksg/Recorder/Core.d.ts +42 -37
- package/lib/commonjs/sksg/Recorder/Core.js +45 -38
- package/lib/commonjs/sksg/Recorder/Core.js.map +1 -1
- package/lib/commonjs/sksg/Recorder/Player.js +4 -0
- package/lib/commonjs/sksg/Recorder/Player.js.map +1 -1
- package/lib/commonjs/sksg/Recorder/Recorder.d.ts +4 -0
- package/lib/commonjs/sksg/Recorder/Recorder.js +14 -1
- package/lib/commonjs/sksg/Recorder/Recorder.js.map +1 -1
- package/lib/commonjs/sksg/Recorder/Visitor.js +6 -0
- package/lib/commonjs/sksg/Recorder/Visitor.js.map +1 -1
- package/lib/module/sksg/Container.js +1 -2
- package/lib/module/sksg/Container.js.map +1 -1
- package/lib/module/sksg/Recorder/Core.d.ts +42 -37
- package/lib/module/sksg/Recorder/Core.js +43 -37
- package/lib/module/sksg/Recorder/Core.js.map +1 -1
- package/lib/module/sksg/Recorder/Player.js +5 -1
- package/lib/module/sksg/Recorder/Player.js.map +1 -1
- package/lib/module/sksg/Recorder/Recorder.d.ts +4 -0
- package/lib/module/sksg/Recorder/Recorder.js +14 -1
- package/lib/module/sksg/Recorder/Recorder.js.map +1 -1
- package/lib/module/sksg/Recorder/Visitor.js +6 -0
- package/lib/module/sksg/Recorder/Visitor.js.map +1 -1
- package/lib/typescript/lib/commonjs/sksg/Recorder/Core.d.ts +1 -0
- package/lib/typescript/lib/commonjs/sksg/Recorder/Recorder.d.ts +2 -0
- package/lib/typescript/lib/module/sksg/Recorder/Core.d.ts +1 -0
- package/lib/typescript/lib/module/sksg/Recorder/Recorder.d.ts +2 -0
- package/lib/typescript/src/sksg/Recorder/Core.d.ts +42 -37
- package/lib/typescript/src/sksg/Recorder/Recorder.d.ts +4 -0
- package/package.json +3 -2
- package/src/sksg/Container.ts +1 -2
- package/src/sksg/Recorder/Core.ts +10 -0
- package/src/sksg/Recorder/Player.ts +5 -1
- package/src/sksg/Recorder/Recorder.ts +16 -1
- package/src/sksg/Recorder/Visitor.ts +6 -0
@@ -158,6 +158,9 @@ const pushPaints = (recorder, paints) => {
|
|
158
158
|
});
|
159
159
|
};
|
160
160
|
const visitNode = (recorder, node) => {
|
161
|
+
if (node.type === NodeType.Group) {
|
162
|
+
recorder.saveGroup();
|
163
|
+
}
|
161
164
|
const {
|
162
165
|
props
|
163
166
|
} = node;
|
@@ -276,6 +279,9 @@ const visitNode = (recorder, node) => {
|
|
276
279
|
if (shouldRestore) {
|
277
280
|
recorder.restoreCTM();
|
278
281
|
}
|
282
|
+
if (node.type === NodeType.Group) {
|
283
|
+
recorder.restoreGroup();
|
284
|
+
}
|
279
285
|
};
|
280
286
|
export const visit = (recorder, root) => {
|
281
287
|
root.forEach(node => {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["NodeType","isImageFilter","isShader","sortNodeChildren","processPaint","opacity","color","strokeWidth","blendMode","style","strokeJoin","strokeCap","strokeMiter","antiAlias","dither","paint","paintRef","undefined","processCTM","clip","invertClip","transform","origin","matrix","layer","ctm","pushColorFilters","recorder","colorFilters","forEach","colorFilter","children","length","pushColorFilter","type","props","needsComposition","LerpColorFilter","composeColorFilter","pushPathEffects","pathEffects","pathEffect","pushPathEffect","SumPathEffect","composePathEffect","pushImageFilters","imageFilters","imageFilter","pushImageFilter","pushShader","BlendImageFilter","composeImageFilter","pushShaders","shaders","shader","pushMaskFilters","maskFilters","pushBlurMaskFilter","pushPaints","paints","savePaint","restorePaintDeclaration","visitNode","node","drawings","shouldPushPaint","BackdropFilter","saveBackdropFilter","materializePaint","Layer","saveLayer","shouldRestore","saveCTM","Box","shadows","filter","n","BoxShadow","map","drawBox","Fill","drawPaint","Image","drawImage","Circle","drawCircle","Points","drawPoints","Path","drawPath","Rect","drawRect","RRect","drawRRect","Oval","drawOval","Line","drawLine","Patch","drawPatch","Vertices","drawVertices","DiffRect","drawDiffRect","Text","drawText","TextPath","drawTextPath","TextBlob","drawTextBlob","Glyphs","drawGlyphs","Picture","drawPicture","ImageSVG","drawImageSVG","Paragraph","drawParagraph","Atlas","drawAtlas","drawing","restorePaint","restoreCTM","visit","root"],"sources":["Visitor.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport type {\n CTMProps,\n DrawingNodeProps,\n BoxShadowProps,\n} from \"../../dom/types\";\nimport { NodeType } from \"../../dom/types\";\nimport type { Node } from \"../Node\";\nimport { isImageFilter, isShader, sortNodeChildren } from \"../Node\";\n\nimport type { Recorder } from \"./Recorder\";\n\nexport const processPaint = ({\n opacity,\n color,\n strokeWidth,\n blendMode,\n style,\n strokeJoin,\n strokeCap,\n strokeMiter,\n antiAlias,\n dither,\n paint: paintRef,\n}: DrawingNodeProps) => {\n const paint: DrawingNodeProps = {};\n if (opacity !== undefined) {\n paint.opacity = opacity;\n }\n if (color !== undefined) {\n paint.color = color;\n }\n if (strokeWidth !== undefined) {\n paint.strokeWidth = strokeWidth;\n }\n if (blendMode !== undefined) {\n paint.blendMode = blendMode;\n }\n if (style !== undefined) {\n paint.style = style;\n }\n if (strokeJoin !== undefined) {\n paint.strokeJoin = strokeJoin;\n }\n if (strokeCap !== undefined) {\n paint.strokeCap = strokeCap;\n }\n if (strokeMiter !== undefined) {\n paint.strokeMiter = strokeMiter;\n }\n if (antiAlias !== undefined) {\n paint.antiAlias = antiAlias;\n }\n if (dither !== undefined) {\n paint.dither = dither;\n }\n\n if (paintRef !== undefined) {\n paint.paint = paintRef;\n }\n\n if (\n opacity !== undefined ||\n color !== undefined ||\n strokeWidth !== undefined ||\n blendMode !== undefined ||\n style !== undefined ||\n strokeJoin !== undefined ||\n strokeCap !== undefined ||\n strokeMiter !== undefined ||\n antiAlias !== undefined ||\n dither !== undefined ||\n paintRef !== undefined\n ) {\n return paint;\n }\n return null;\n};\n\nconst processCTM = ({\n clip,\n invertClip,\n transform,\n origin,\n matrix,\n layer,\n}: CTMProps) => {\n const ctm: CTMProps = {};\n if (clip) {\n ctm.clip = clip;\n }\n if (invertClip) {\n ctm.invertClip = invertClip;\n }\n if (transform) {\n ctm.transform = transform;\n }\n if (origin) {\n ctm.origin = origin;\n }\n if (matrix) {\n ctm.matrix = matrix;\n }\n if (layer) {\n ctm.layer = layer;\n }\n if (\n clip !== undefined ||\n invertClip !== undefined ||\n transform !== undefined ||\n origin !== undefined ||\n matrix !== undefined ||\n layer !== undefined\n ) {\n return ctm;\n }\n return null;\n};\n\nconst pushColorFilters = (recorder: Recorder, colorFilters: Node<any>[]) => {\n colorFilters.forEach((colorFilter) => {\n if (colorFilter.children.length > 0) {\n pushColorFilters(recorder, colorFilter.children);\n }\n recorder.pushColorFilter(colorFilter.type, colorFilter.props);\n const needsComposition =\n colorFilter.type !== NodeType.LerpColorFilter &&\n colorFilter.children.length > 0;\n if (needsComposition) {\n recorder.composeColorFilter();\n }\n });\n};\n\nconst pushPathEffects = (recorder: Recorder, pathEffects: Node<any>[]) => {\n pathEffects.forEach((pathEffect) => {\n if (pathEffect.children.length > 0) {\n pushPathEffects(recorder, pathEffect.children);\n }\n recorder.pushPathEffect(pathEffect.type, pathEffect.props);\n const needsComposition =\n pathEffect.type !== NodeType.SumPathEffect &&\n pathEffect.children.length > 0;\n if (needsComposition) {\n recorder.composePathEffect();\n }\n });\n};\n\nconst pushImageFilters = (recorder: Recorder, imageFilters: Node<any>[]) => {\n imageFilters.forEach((imageFilter) => {\n if (imageFilter.children.length > 0) {\n pushImageFilters(recorder, imageFilter.children);\n }\n if (isImageFilter(imageFilter.type)) {\n recorder.pushImageFilter(imageFilter.type, imageFilter.props);\n } else if (isShader(imageFilter.type)) {\n recorder.pushShader(imageFilter.type, imageFilter.props);\n }\n const needsComposition =\n imageFilter.type !== NodeType.BlendImageFilter &&\n imageFilter.children.length > 0;\n if (needsComposition) {\n recorder.composeImageFilter();\n }\n });\n};\n\nconst pushShaders = (recorder: Recorder, shaders: Node<any>[]) => {\n shaders.forEach((shader) => {\n if (shader.children.length > 0) {\n pushShaders(recorder, shader.children);\n }\n recorder.pushShader(shader.type, shader.props);\n });\n};\n\nconst pushMaskFilters = (recorder: Recorder, maskFilters: Node<any>[]) => {\n if (maskFilters.length > 0) {\n recorder.pushBlurMaskFilter(maskFilters[maskFilters.length - 1].props);\n }\n};\n\nconst pushPaints = (recorder: Recorder, paints: Node<any>[]) => {\n paints.forEach((paint) => {\n recorder.savePaint(paint.props);\n const { colorFilters, maskFilters, shaders, imageFilters, pathEffects } =\n sortNodeChildren(paint);\n pushColorFilters(recorder, colorFilters);\n pushImageFilters(recorder, imageFilters);\n pushMaskFilters(recorder, maskFilters);\n pushShaders(recorder, shaders);\n pushPathEffects(recorder, pathEffects);\n recorder.restorePaintDeclaration();\n });\n};\n\nconst visitNode = (recorder: Recorder, node: Node<any>) => {\n const { props } = node;\n const {\n colorFilters,\n maskFilters,\n drawings,\n shaders,\n imageFilters,\n pathEffects,\n paints,\n } = sortNodeChildren(node);\n const paint = processPaint(props);\n const shouldPushPaint =\n paint ||\n colorFilters.length > 0 ||\n maskFilters.length > 0 ||\n imageFilters.length > 0 ||\n pathEffects.length > 0 ||\n shaders.length > 0;\n if (shouldPushPaint) {\n recorder.savePaint(paint ?? {});\n pushColorFilters(recorder, colorFilters);\n pushImageFilters(recorder, imageFilters);\n pushMaskFilters(recorder, maskFilters);\n pushShaders(recorder, shaders);\n pushPathEffects(recorder, pathEffects);\n // For mixed nodes like BackdropFilters we don't materialize the paint\n if (node.type === NodeType.BackdropFilter) {\n recorder.saveBackdropFilter();\n } else {\n recorder.materializePaint();\n }\n }\n pushPaints(recorder, paints);\n if (node.type === NodeType.Layer) {\n recorder.saveLayer();\n }\n const ctm = processCTM(props);\n const shouldRestore = !!ctm || node.type === NodeType.Layer;\n if (ctm) {\n recorder.saveCTM(ctm);\n }\n switch (node.type) {\n case NodeType.Box:\n const shadows = node.children\n .filter((n) => n.type === NodeType.BoxShadow)\n // eslint-disable-next-line @typescript-eslint/no-shadow\n .map(({ props }) => ({ props } as { props: BoxShadowProps }));\n recorder.drawBox(props, shadows);\n break;\n case NodeType.Fill:\n recorder.drawPaint();\n break;\n case NodeType.Image:\n recorder.drawImage(node.props);\n break;\n case NodeType.Circle:\n recorder.drawCircle(node.props);\n break;\n case NodeType.Points:\n recorder.drawPoints(props);\n break;\n case NodeType.Path:\n recorder.drawPath(props);\n break;\n case NodeType.Rect:\n recorder.drawRect(props);\n break;\n case NodeType.RRect:\n recorder.drawRRect(props);\n break;\n case NodeType.Oval:\n recorder.drawOval(props);\n break;\n case NodeType.Line:\n recorder.drawLine(props);\n break;\n case NodeType.Patch:\n recorder.drawPatch(props);\n break;\n case NodeType.Vertices:\n recorder.drawVertices(props);\n break;\n case NodeType.DiffRect:\n recorder.drawDiffRect(props);\n break;\n case NodeType.Text:\n recorder.drawText(props);\n break;\n case NodeType.TextPath:\n recorder.drawTextPath(props);\n break;\n case NodeType.TextBlob:\n recorder.drawTextBlob(props);\n break;\n case NodeType.Glyphs:\n recorder.drawGlyphs(props);\n break;\n case NodeType.Picture:\n recorder.drawPicture(props);\n break;\n case NodeType.ImageSVG:\n recorder.drawImageSVG(props);\n break;\n case NodeType.Paragraph:\n recorder.drawParagraph(props);\n break;\n case NodeType.Atlas:\n recorder.drawAtlas(props);\n break;\n }\n drawings.forEach((drawing) => {\n visitNode(recorder, drawing);\n });\n if (shouldPushPaint) {\n recorder.restorePaint();\n }\n if (shouldRestore) {\n recorder.restoreCTM();\n }\n};\n\nexport const visit = (recorder: Recorder, root: Node[]) => {\n root.forEach((node) => {\n visitNode(recorder, node);\n });\n};\n"],"mappings":"AAAA;;AAMA,SAASA,QAAQ,QAAQ,iBAAiB;AAE1C,SAASC,aAAa,EAAEC,QAAQ,EAAEC,gBAAgB,QAAQ,SAAS;AAInE,OAAO,MAAMC,YAAY,GAAGA,CAAC;EAC3BC,OAAO;EACP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QAAQ,CAACoF,UAAU,CAAC5E,KAAK,CAAC;MAC1B;IACF,KAAKnC,QAAQ,CAACgH,OAAO;MACnBrF,QAAQ,CAACsF,WAAW,CAAC9E,KAAK,CAAC;MAC3B;IACF,KAAKnC,QAAQ,CAACkH,QAAQ;MACpBvF,QAAQ,CAACwF,YAAY,CAAChF,KAAK,CAAC;MAC5B;IACF,KAAKnC,QAAQ,CAACoH,SAAS;MACrBzF,QAAQ,CAAC0F,aAAa,CAAClF,KAAK,CAAC;MAC7B;IACF,KAAKnC,QAAQ,CAACsH,KAAK;MACjB3F,QAAQ,CAAC4F,SAAS,CAACpF,KAAK,CAAC;MACzB;EACJ;EACA6B,QAAQ,CAACnC,OAAO,CAAE2F,OAAO,IAAK;IAC5B1D,SAAS,CAACnC,QAAQ,EAAE6F,OAAO,CAAC;EAC9B,CAAC,CAAC;EACF,IAAIvD,eAAe,EAAE;IACnBtC,QAAQ,CAAC8F,YAAY,CAAC,CAAC;EACzB;EACA,IAAIlD,aAAa,EAAE;IACjB5C,QAAQ,CAAC+F,UAAU,CAAC,CAAC;EACvB;AACF,CAAC;AAED,OAAO,MAAMC,KAAK,GAAGA,CAAChG,QAAkB,EAAEiG,IAAY,KAAK;EACzDA,IAAI,CAAC/F,OAAO,CAAEkC,IAAI,IAAK;IACrBD,SAAS,CAACnC,QAAQ,EAAEoC,IAAI,CAAC;EAC3B,CAAC,CAAC;AACJ,CAAC","ignoreList":[]}
|
1
|
+
{"version":3,"names":["NodeType","isImageFilter","isShader","sortNodeChildren","processPaint","opacity","color","strokeWidth","blendMode","style","strokeJoin","strokeCap","strokeMiter","antiAlias","dither","paint","paintRef","undefined","processCTM","clip","invertClip","transform","origin","matrix","layer","ctm","pushColorFilters","recorder","colorFilters","forEach","colorFilter","children","length","pushColorFilter","type","props","needsComposition","LerpColorFilter","composeColorFilter","pushPathEffects","pathEffects","pathEffect","pushPathEffect","SumPathEffect","composePathEffect","pushImageFilters","imageFilters","imageFilter","pushImageFilter","pushShader","BlendImageFilter","composeImageFilter","pushShaders","shaders","shader","pushMaskFilters","maskFilters","pushBlurMaskFilter","pushPaints","paints","savePaint","restorePaintDeclaration","visitNode","node","Group","saveGroup","drawings","shouldPushPaint","BackdropFilter","saveBackdropFilter","materializePaint","Layer","saveLayer","shouldRestore","saveCTM","Box","shadows","filter","n","BoxShadow","map","drawBox","Fill","drawPaint","Image","drawImage","Circle","drawCircle","Points","drawPoints","Path","drawPath","Rect","drawRect","RRect","drawRRect","Oval","drawOval","Line","drawLine","Patch","drawPatch","Vertices","drawVertices","DiffRect","drawDiffRect","Text","drawText","TextPath","drawTextPath","TextBlob","drawTextBlob","Glyphs","drawGlyphs","Picture","drawPicture","ImageSVG","drawImageSVG","Paragraph","drawParagraph","Atlas","drawAtlas","drawing","restorePaint","restoreCTM","restoreGroup","visit","root"],"sources":["Visitor.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport type {\n CTMProps,\n DrawingNodeProps,\n BoxShadowProps,\n} from \"../../dom/types\";\nimport { NodeType } from \"../../dom/types\";\nimport type { Node } from \"../Node\";\nimport { isImageFilter, isShader, sortNodeChildren } from \"../Node\";\n\nimport type { Recorder } from \"./Recorder\";\n\nexport const processPaint = ({\n opacity,\n color,\n strokeWidth,\n blendMode,\n style,\n strokeJoin,\n strokeCap,\n strokeMiter,\n antiAlias,\n dither,\n paint: paintRef,\n}: DrawingNodeProps) => {\n const paint: DrawingNodeProps = {};\n if (opacity !== undefined) {\n paint.opacity = opacity;\n }\n if (color !== undefined) {\n paint.color = color;\n }\n if (strokeWidth !== undefined) {\n paint.strokeWidth = strokeWidth;\n }\n if (blendMode !== undefined) {\n paint.blendMode = blendMode;\n }\n if (style !== undefined) {\n paint.style = style;\n }\n if (strokeJoin !== undefined) {\n paint.strokeJoin = strokeJoin;\n }\n if (strokeCap !== undefined) {\n paint.strokeCap = strokeCap;\n }\n if (strokeMiter !== undefined) {\n paint.strokeMiter = strokeMiter;\n }\n if (antiAlias !== undefined) {\n paint.antiAlias = antiAlias;\n }\n if (dither !== undefined) {\n paint.dither = dither;\n }\n\n if (paintRef !== undefined) {\n paint.paint = paintRef;\n }\n\n if (\n opacity !== undefined ||\n color !== undefined ||\n strokeWidth !== undefined ||\n blendMode !== undefined ||\n style !== undefined ||\n strokeJoin !== undefined ||\n strokeCap !== undefined ||\n strokeMiter !== undefined ||\n antiAlias !== undefined ||\n dither !== undefined ||\n paintRef !== undefined\n ) {\n return paint;\n }\n return null;\n};\n\nconst processCTM = ({\n clip,\n invertClip,\n transform,\n origin,\n matrix,\n layer,\n}: CTMProps) => {\n const ctm: CTMProps = {};\n if (clip) {\n ctm.clip = clip;\n }\n if (invertClip) {\n ctm.invertClip = invertClip;\n }\n if (transform) {\n ctm.transform = transform;\n }\n if (origin) {\n ctm.origin = origin;\n }\n if (matrix) {\n ctm.matrix = matrix;\n }\n if (layer) {\n ctm.layer = layer;\n }\n if (\n clip !== undefined ||\n invertClip !== undefined ||\n transform !== undefined ||\n origin !== undefined ||\n matrix !== undefined ||\n layer !== undefined\n ) {\n return ctm;\n }\n return null;\n};\n\nconst pushColorFilters = (recorder: Recorder, colorFilters: Node<any>[]) => {\n colorFilters.forEach((colorFilter) => {\n if (colorFilter.children.length > 0) {\n pushColorFilters(recorder, colorFilter.children);\n }\n recorder.pushColorFilter(colorFilter.type, colorFilter.props);\n const needsComposition =\n colorFilter.type !== NodeType.LerpColorFilter &&\n colorFilter.children.length > 0;\n if (needsComposition) {\n recorder.composeColorFilter();\n }\n });\n};\n\nconst pushPathEffects = (recorder: Recorder, pathEffects: Node<any>[]) => {\n pathEffects.forEach((pathEffect) => {\n if (pathEffect.children.length > 0) {\n pushPathEffects(recorder, pathEffect.children);\n }\n recorder.pushPathEffect(pathEffect.type, pathEffect.props);\n const needsComposition =\n pathEffect.type !== NodeType.SumPathEffect &&\n pathEffect.children.length > 0;\n if (needsComposition) {\n recorder.composePathEffect();\n }\n });\n};\n\nconst pushImageFilters = (recorder: Recorder, imageFilters: Node<any>[]) => {\n imageFilters.forEach((imageFilter) => {\n if (imageFilter.children.length > 0) {\n pushImageFilters(recorder, imageFilter.children);\n }\n if (isImageFilter(imageFilter.type)) {\n recorder.pushImageFilter(imageFilter.type, imageFilter.props);\n } else if (isShader(imageFilter.type)) {\n recorder.pushShader(imageFilter.type, imageFilter.props);\n }\n const needsComposition =\n imageFilter.type !== NodeType.BlendImageFilter &&\n imageFilter.children.length > 0;\n if (needsComposition) {\n recorder.composeImageFilter();\n }\n });\n};\n\nconst pushShaders = (recorder: Recorder, shaders: Node<any>[]) => {\n shaders.forEach((shader) => {\n if (shader.children.length > 0) {\n pushShaders(recorder, shader.children);\n }\n recorder.pushShader(shader.type, shader.props);\n });\n};\n\nconst pushMaskFilters = (recorder: Recorder, maskFilters: Node<any>[]) => {\n if (maskFilters.length > 0) {\n recorder.pushBlurMaskFilter(maskFilters[maskFilters.length - 1].props);\n }\n};\n\nconst pushPaints = (recorder: Recorder, paints: Node<any>[]) => {\n paints.forEach((paint) => {\n recorder.savePaint(paint.props);\n const { colorFilters, maskFilters, shaders, imageFilters, pathEffects } =\n sortNodeChildren(paint);\n pushColorFilters(recorder, colorFilters);\n pushImageFilters(recorder, imageFilters);\n pushMaskFilters(recorder, maskFilters);\n pushShaders(recorder, shaders);\n pushPathEffects(recorder, pathEffects);\n recorder.restorePaintDeclaration();\n });\n};\n\nconst visitNode = (recorder: Recorder, node: Node<any>) => {\n if (node.type === NodeType.Group) {\n recorder.saveGroup();\n }\n const { props } = node;\n const {\n colorFilters,\n maskFilters,\n drawings,\n shaders,\n imageFilters,\n pathEffects,\n paints,\n } = sortNodeChildren(node);\n const paint = processPaint(props);\n const shouldPushPaint =\n paint ||\n colorFilters.length > 0 ||\n maskFilters.length > 0 ||\n imageFilters.length > 0 ||\n pathEffects.length > 0 ||\n shaders.length > 0;\n if (shouldPushPaint) {\n recorder.savePaint(paint ?? {});\n pushColorFilters(recorder, colorFilters);\n pushImageFilters(recorder, imageFilters);\n pushMaskFilters(recorder, maskFilters);\n pushShaders(recorder, shaders);\n pushPathEffects(recorder, pathEffects);\n // For mixed nodes like BackdropFilters we don't materialize the paint\n if (node.type === NodeType.BackdropFilter) {\n recorder.saveBackdropFilter();\n } else {\n recorder.materializePaint();\n }\n }\n pushPaints(recorder, paints);\n if (node.type === NodeType.Layer) {\n recorder.saveLayer();\n }\n const ctm = processCTM(props);\n const shouldRestore = !!ctm || node.type === NodeType.Layer;\n if (ctm) {\n recorder.saveCTM(ctm);\n }\n switch (node.type) {\n case NodeType.Box:\n const shadows = node.children\n .filter((n) => n.type === NodeType.BoxShadow)\n // eslint-disable-next-line @typescript-eslint/no-shadow\n .map(({ props }) => ({ props } as { props: BoxShadowProps }));\n recorder.drawBox(props, shadows);\n break;\n case NodeType.Fill:\n recorder.drawPaint();\n break;\n case NodeType.Image:\n recorder.drawImage(node.props);\n break;\n case NodeType.Circle:\n recorder.drawCircle(node.props);\n break;\n case NodeType.Points:\n recorder.drawPoints(props);\n break;\n case NodeType.Path:\n recorder.drawPath(props);\n break;\n case NodeType.Rect:\n recorder.drawRect(props);\n break;\n case NodeType.RRect:\n recorder.drawRRect(props);\n break;\n case NodeType.Oval:\n recorder.drawOval(props);\n break;\n case NodeType.Line:\n recorder.drawLine(props);\n break;\n case NodeType.Patch:\n recorder.drawPatch(props);\n break;\n case NodeType.Vertices:\n recorder.drawVertices(props);\n break;\n case NodeType.DiffRect:\n recorder.drawDiffRect(props);\n break;\n case NodeType.Text:\n recorder.drawText(props);\n break;\n case NodeType.TextPath:\n recorder.drawTextPath(props);\n break;\n case NodeType.TextBlob:\n recorder.drawTextBlob(props);\n break;\n case NodeType.Glyphs:\n recorder.drawGlyphs(props);\n break;\n case NodeType.Picture:\n recorder.drawPicture(props);\n break;\n case NodeType.ImageSVG:\n recorder.drawImageSVG(props);\n break;\n case NodeType.Paragraph:\n recorder.drawParagraph(props);\n break;\n case NodeType.Atlas:\n recorder.drawAtlas(props);\n break;\n }\n drawings.forEach((drawing) => {\n visitNode(recorder, drawing);\n });\n if (shouldPushPaint) {\n recorder.restorePaint();\n }\n if (shouldRestore) {\n recorder.restoreCTM();\n }\n if (node.type === NodeType.Group) {\n recorder.restoreGroup();\n }\n};\n\nexport const visit = (recorder: Recorder, root: Node[]) => {\n root.forEach((node) => {\n visitNode(recorder, node);\n });\n};\n"],"mappings":"AAAA;;AAMA,SAASA,QAAQ,QAAQ,iBAAiB;AAE1C,SAASC,aAAa,EAAEC,QAAQ,EAAEC,gBAAgB,QAAQ,SAAS;AAInE,OAAO,MAAMC,YAAY,GAAGA,CAAC;EAC3BC,OAAO;EACPC,KAAK;EACLC,WAAW;EACXC,SAAS;EACTC,KAAK;EACLC,UAAU;EACVC,SAAS;EACTC,WAAW;EACXC,SAAS;EACTC,MAAM;EACNC,KAAK,EAAEC;AACS,CAAC,KAAK;EACtB,MAAMD,KAAuB,GAAG,CAAC,CAAC;EAClC,IAAIV,OAAO,KAAKY,SAAS,EAAE;IACzBF,KAAK,CAACV,OAAO,GAAGA,OAAO;EACzB;EACA,IAAIC,KAAK,KAAKW,SAAS,EAAE;IACvBF,KAAK,CAACT,KAAK,GAAGA,KAAK;EACrB;EACA,IAAIC,WAAW,KAAKU,SAAS,EAAE;IAC7BF,KAAK,CAACR,WAAW,GAAGA,WAAW;EACjC;EACA,IAAIC,SAAS,KAAKS,SAAS,EAAE;IAC3BF,KAAK,CAACP,SAAS,GAAGA,SAAS;EAC7B;EACA,IAAIC,KAAK,KAAKQ,SAAS,EAAE;IACvBF,KAAK,CAACN,KAAK,GAAGA,KAAK;EACrB;EACA,IAAIC,UAAU,KAAKO,SAAS,EAAE;IAC5BF,KAAK,CAACL,UAAU,GAAGA,UAAU;EAC/B;EACA,IAAIC,SAAS,KAAKM,SAAS,EAAE;IAC3BF,KAAK,CAACJ,SAAS,GAAGA,SAAS;EAC7B;EACA,IAAIC,WAAW,KAAKK,SAAS,EAAE;IAC7BF,KAAK,CAACH,WAAW,GAAGA,WAAW;EACjC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E,KAAK,EAAE;IAChCrC,QAAQ,CAACkG,YAAY,CAAC,CAAC;EACzB;AACF,CAAC;AAED,OAAO,MAAMC,KAAK,GAAGA,CAACnG,QAAkB,EAAEoG,IAAY,KAAK;EACzDA,IAAI,CAAClG,OAAO,CAAEkC,IAAI,IAAK;IACrBD,SAAS,CAACnC,QAAQ,EAAEoC,IAAI,CAAC;EAC3B,CAAC,CAAC;AACJ,CAAC","ignoreList":[]}
|
@@ -2,4 +2,5 @@ export const __esModule: boolean;
|
|
2
2
|
export const CommandType: {};
|
3
3
|
export function materializeProps(command: any): void;
|
4
4
|
export function isCommand(command: any, type: any): boolean;
|
5
|
+
export function isGroup(command: any): boolean;
|
5
6
|
export function isDrawCommand(command: any, type: any): boolean;
|
@@ -1,43 +1,44 @@
|
|
1
1
|
import type { SharedValue } from "react-native-reanimated";
|
2
2
|
import type { BlurMaskFilterProps, CircleProps, CTMProps, ImageProps, PointsProps, PathProps, RectProps, RoundedRectProps, OvalProps, LineProps, PatchProps, VerticesProps, DiffRectProps, TextProps, TextPathProps, TextBlobProps, GlyphsProps, PictureProps, ImageSVGProps, ParagraphProps, AtlasProps, DrawingNodeProps } from "../../dom/types";
|
3
3
|
export declare enum CommandType {
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
4
|
+
Group = 0,
|
5
|
+
SavePaint = 1,
|
6
|
+
RestorePaint = 2,
|
7
|
+
SaveCTM = 3,
|
8
|
+
RestoreCTM = 4,
|
9
|
+
PushColorFilter = 5,
|
10
|
+
PushBlurMaskFilter = 6,
|
11
|
+
PushImageFilter = 7,
|
12
|
+
PushPathEffect = 8,
|
13
|
+
PushShader = 9,
|
14
|
+
ComposeColorFilter = 10,
|
15
|
+
ComposeImageFilter = 11,
|
16
|
+
ComposePathEffect = 12,
|
17
|
+
MaterializePaint = 13,
|
18
|
+
SaveBackdropFilter = 14,
|
19
|
+
SaveLayer = 15,
|
20
|
+
RestorePaintDeclaration = 16,
|
21
|
+
DrawBox = 17,
|
22
|
+
DrawImage = 18,
|
23
|
+
DrawCircle = 19,
|
24
|
+
DrawPaint = 20,
|
25
|
+
DrawPoints = 21,
|
26
|
+
DrawPath = 22,
|
27
|
+
DrawRect = 23,
|
28
|
+
DrawRRect = 24,
|
29
|
+
DrawOval = 25,
|
30
|
+
DrawLine = 26,
|
31
|
+
DrawPatch = 27,
|
32
|
+
DrawVertices = 28,
|
33
|
+
DrawDiffRect = 29,
|
34
|
+
DrawText = 30,
|
35
|
+
DrawTextPath = 31,
|
36
|
+
DrawTextBlob = 32,
|
37
|
+
DrawGlyphs = 33,
|
38
|
+
DrawPicture = 34,
|
39
|
+
DrawImageSVG = 35,
|
40
|
+
DrawParagraph = 36,
|
41
|
+
DrawAtlas = 37
|
41
42
|
}
|
42
43
|
export type Command<T extends CommandType = CommandType> = {
|
43
44
|
type: T;
|
@@ -48,6 +49,10 @@ export declare const materializeProps: (command: {
|
|
48
49
|
animatedProps?: Record<string, SharedValue<unknown>>;
|
49
50
|
}) => void;
|
50
51
|
export declare const isCommand: <T extends CommandType>(command: Command, type: T) => command is Command<T>;
|
52
|
+
interface GroupCommand extends Command<CommandType.Group> {
|
53
|
+
children: Command[];
|
54
|
+
}
|
55
|
+
export declare const isGroup: (command: Command) => command is GroupCommand;
|
51
56
|
interface Props {
|
52
57
|
[CommandType.DrawImage]: ImageProps;
|
53
58
|
[CommandType.DrawCircle]: CircleProps;
|
@@ -13,10 +13,14 @@ interface AnimationValues {
|
|
13
13
|
}
|
14
14
|
export declare class Recorder {
|
15
15
|
commands: Command[];
|
16
|
+
cursors: Command[][];
|
16
17
|
animationValues: Set<SharedValue<unknown>>;
|
18
|
+
constructor();
|
17
19
|
getRecording(): Recording & AnimationValues;
|
18
20
|
private processProps;
|
19
21
|
private add;
|
22
|
+
saveGroup(): void;
|
23
|
+
restoreGroup(): void;
|
20
24
|
savePaint(props: AnimatedProps<PaintProps>): void;
|
21
25
|
restorePaint(): void;
|
22
26
|
restorePaintDeclaration(): void;
|
package/package.json
CHANGED
@@ -7,7 +7,7 @@
|
|
7
7
|
"setup-skia-web": "./scripts/setup-canvaskit.js"
|
8
8
|
},
|
9
9
|
"title": "React Native Skia",
|
10
|
-
"version": "1.9.
|
10
|
+
"version": "1.9.1",
|
11
11
|
"description": "High-performance React Native Graphics using Skia",
|
12
12
|
"main": "lib/module/index.js",
|
13
13
|
"react-native": "src/index.ts",
|
@@ -49,7 +49,8 @@
|
|
49
49
|
"clang-format-android": "find android/cpp/ -iname '*.h' -o -iname '*.m' -o -iname '*.cpp' | xargs clang-format -i",
|
50
50
|
"clang-format-common": "find cpp/ \\( -path 'cpp//skia' -prune \\) -o \\( -iname '*.h' -o -iname '*.m' -o -iname '*.cpp' \\) -print | xargs clang-format -i",
|
51
51
|
"workflow-copy-libs": "yarn ts-node ./scripts/workflow-copy-libs.ts",
|
52
|
-
"cpplint": "cpplint --linelength=230 --filter=-legal/copyright,-whitespace/indent,-whitespace/comments,-whitespace/ending_newline,-build/include_order,-runtime/references,-readability/todo,-whitespace/blank_line,-whitespace/todo,-runtime/int,-build/c++11,-whitespace/parens --exclude=package/cpp/skia --exclude=package/ios --exclude=package/android/build --exclude=package/node_modules --recursive package"
|
52
|
+
"cpplint": "cpplint --linelength=230 --filter=-legal/copyright,-whitespace/indent,-whitespace/comments,-whitespace/ending_newline,-build/include_order,-runtime/references,-readability/todo,-whitespace/blank_line,-whitespace/todo,-runtime/int,-build/c++11,-whitespace/parens --exclude=package/cpp/skia --exclude=package/ios --exclude=package/android/build --exclude=package/node_modules --recursive package",
|
53
|
+
"download-artifacts": "ts-node ./scripts/download-artifacts.ts"
|
53
54
|
},
|
54
55
|
"repository": {
|
55
56
|
"type": "git",
|
package/src/sksg/Container.ts
CHANGED
@@ -17,7 +17,6 @@ const drawOnscreen = (Skia: Skia, nativeId: number, recording: Recording) => {
|
|
17
17
|
// const start = performance.now();
|
18
18
|
|
19
19
|
const ctx = createDrawingContext(Skia, recording.paintPool, canvas);
|
20
|
-
//console.log(recording.commands);
|
21
20
|
replay(ctx, recording.commands);
|
22
21
|
const picture = rec.finishRecordingAsPicture();
|
23
22
|
//const end = performance.now();
|
@@ -42,7 +41,7 @@ export abstract class Container {
|
|
42
41
|
this.recording.paintPool,
|
43
42
|
canvas
|
44
43
|
);
|
45
|
-
//console.log(this.
|
44
|
+
//console.log(this.recording.commands);
|
46
45
|
replay(ctx, this.recording.commands);
|
47
46
|
}
|
48
47
|
|
@@ -68,6 +68,7 @@ import type {
|
|
68
68
|
// }
|
69
69
|
export enum CommandType {
|
70
70
|
// Context
|
71
|
+
Group,
|
71
72
|
SavePaint,
|
72
73
|
RestorePaint,
|
73
74
|
SaveCTM,
|
@@ -133,6 +134,15 @@ export const isCommand = <T extends CommandType>(
|
|
133
134
|
return command.type === type;
|
134
135
|
};
|
135
136
|
|
137
|
+
interface GroupCommand extends Command<CommandType.Group> {
|
138
|
+
children: Command[];
|
139
|
+
}
|
140
|
+
|
141
|
+
export const isGroup = (command: Command): command is GroupCommand => {
|
142
|
+
"worklet";
|
143
|
+
return command.type === CommandType.Group;
|
144
|
+
};
|
145
|
+
|
136
146
|
interface Props {
|
137
147
|
[CommandType.DrawImage]: ImageProps;
|
138
148
|
[CommandType.DrawCircle]: CircleProps;
|
@@ -43,6 +43,7 @@ import {
|
|
43
43
|
CommandType,
|
44
44
|
isCommand,
|
45
45
|
isDrawCommand,
|
46
|
+
isGroup,
|
46
47
|
materializeProps,
|
47
48
|
type Command,
|
48
49
|
} from "./Core";
|
@@ -50,7 +51,10 @@ import type { DrawingContext } from "./DrawingContext";
|
|
50
51
|
|
51
52
|
const play = (ctx: DrawingContext, command: Command) => {
|
52
53
|
"worklet";
|
53
|
-
|
54
|
+
if (isGroup(command)) {
|
55
|
+
command.children.forEach((child) => play(ctx, child));
|
56
|
+
return;
|
57
|
+
}
|
54
58
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
55
59
|
materializeProps(command as any);
|
56
60
|
if (isCommand(command, CommandType.SaveBackdropFilter)) {
|
@@ -46,8 +46,13 @@ interface AnimationValues {
|
|
46
46
|
|
47
47
|
export class Recorder {
|
48
48
|
commands: Command[] = [];
|
49
|
+
cursors: Command[][] = [];
|
49
50
|
animationValues: Set<SharedValue<unknown>> = new Set();
|
50
51
|
|
52
|
+
constructor() {
|
53
|
+
this.cursors.push(this.commands);
|
54
|
+
}
|
55
|
+
|
51
56
|
getRecording(): Recording & AnimationValues {
|
52
57
|
return {
|
53
58
|
commands: this.commands,
|
@@ -85,7 +90,17 @@ export class Recorder {
|
|
85
90
|
command.animatedProps = animatedProps;
|
86
91
|
}
|
87
92
|
}
|
88
|
-
this.
|
93
|
+
this.cursors[this.cursors.length - 1].push(command);
|
94
|
+
}
|
95
|
+
|
96
|
+
saveGroup() {
|
97
|
+
const children: Command[] = [];
|
98
|
+
this.add({ type: CommandType.Group, children });
|
99
|
+
this.cursors.push(children);
|
100
|
+
}
|
101
|
+
|
102
|
+
restoreGroup() {
|
103
|
+
this.cursors.pop();
|
89
104
|
}
|
90
105
|
|
91
106
|
savePaint(props: AnimatedProps<PaintProps>) {
|
@@ -196,6 +196,9 @@ const pushPaints = (recorder: Recorder, paints: Node<any>[]) => {
|
|
196
196
|
};
|
197
197
|
|
198
198
|
const visitNode = (recorder: Recorder, node: Node<any>) => {
|
199
|
+
if (node.type === NodeType.Group) {
|
200
|
+
recorder.saveGroup();
|
201
|
+
}
|
199
202
|
const { props } = node;
|
200
203
|
const {
|
201
204
|
colorFilters,
|
@@ -315,6 +318,9 @@ const visitNode = (recorder: Recorder, node: Node<any>) => {
|
|
315
318
|
if (shouldRestore) {
|
316
319
|
recorder.restoreCTM();
|
317
320
|
}
|
321
|
+
if (node.type === NodeType.Group) {
|
322
|
+
recorder.restoreGroup();
|
323
|
+
}
|
318
324
|
};
|
319
325
|
|
320
326
|
export const visit = (recorder: Recorder, root: Node[]) => {
|