@shopify/react-native-skia 2.0.2 → 2.0.4
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/apple/SkiaManager.mm +0 -3
- package/cpp/api/recorder/DrawingCtx.h +3 -3
- package/cpp/api/recorder/JsiRecorder.h +2 -1
- package/cpp/api/recorder/Paint.h +8 -3
- package/cpp/api/recorder/RNRecorder.h +4 -3
- package/cpp/rnskia/RNSkJsiViewApi.h +95 -73
- package/cpp/rnskia/RNSkManager.cpp +3 -18
- package/cpp/rnskia/RNSkManager.h +0 -6
- package/lib/commonjs/skia/types/Recorder.d.ts +1 -1
- package/lib/commonjs/skia/types/Recorder.js.map +1 -1
- package/lib/commonjs/sksg/Recorder/Player.js +3 -1
- package/lib/commonjs/sksg/Recorder/Player.js.map +1 -1
- package/lib/commonjs/sksg/Recorder/ReanimatedRecorder.d.ts +1 -1
- package/lib/commonjs/sksg/Recorder/ReanimatedRecorder.js +2 -2
- package/lib/commonjs/sksg/Recorder/ReanimatedRecorder.js.map +1 -1
- package/lib/commonjs/sksg/Recorder/Recorder.d.ts +1 -1
- package/lib/commonjs/sksg/Recorder/Recorder.js +3 -2
- package/lib/commonjs/sksg/Recorder/Recorder.js.map +1 -1
- package/lib/commonjs/sksg/Recorder/Visitor.js +2 -2
- package/lib/commonjs/sksg/Recorder/Visitor.js.map +1 -1
- package/lib/commonjs/sksg/Recorder/commands/Paint.d.ts +1 -1
- package/lib/commonjs/sksg/Recorder/commands/Paint.js +6 -2
- package/lib/commonjs/sksg/Recorder/commands/Paint.js.map +1 -1
- package/lib/module/skia/types/Recorder.d.ts +1 -1
- package/lib/module/skia/types/Recorder.js.map +1 -1
- package/lib/module/sksg/Recorder/Player.js +3 -1
- package/lib/module/sksg/Recorder/Player.js.map +1 -1
- package/lib/module/sksg/Recorder/ReanimatedRecorder.d.ts +1 -1
- package/lib/module/sksg/Recorder/ReanimatedRecorder.js +2 -2
- package/lib/module/sksg/Recorder/ReanimatedRecorder.js.map +1 -1
- package/lib/module/sksg/Recorder/Recorder.d.ts +1 -1
- package/lib/module/sksg/Recorder/Recorder.js +3 -2
- package/lib/module/sksg/Recorder/Recorder.js.map +1 -1
- package/lib/module/sksg/Recorder/Visitor.js +2 -2
- package/lib/module/sksg/Recorder/Visitor.js.map +1 -1
- package/lib/module/sksg/Recorder/commands/Paint.d.ts +1 -1
- package/lib/module/sksg/Recorder/commands/Paint.js +6 -2
- package/lib/module/sksg/Recorder/commands/Paint.js.map +1 -1
- package/lib/typescript/lib/commonjs/sksg/Recorder/ReanimatedRecorder.d.ts +1 -1
- package/lib/typescript/lib/commonjs/sksg/Recorder/Recorder.d.ts +1 -1
- package/lib/typescript/lib/commonjs/sksg/Recorder/commands/Paint.d.ts +1 -1
- package/lib/typescript/lib/module/sksg/Recorder/ReanimatedRecorder.d.ts +1 -1
- package/lib/typescript/lib/module/sksg/Recorder/Recorder.d.ts +1 -1
- package/lib/typescript/lib/module/sksg/Recorder/commands/Paint.d.ts +1 -1
- package/lib/typescript/src/skia/types/Recorder.d.ts +1 -1
- package/lib/typescript/src/sksg/Recorder/ReanimatedRecorder.d.ts +1 -1
- package/lib/typescript/src/sksg/Recorder/Recorder.d.ts +1 -1
- package/lib/typescript/src/sksg/Recorder/commands/Paint.d.ts +1 -1
- package/package.json +1 -1
- package/src/__tests__/snapshots/drawings/semi-transparent-layer.png +0 -0
- package/src/__tests__/snapshots/drawings/transparent-layer.png +0 -0
- package/src/renderer/__tests__/e2e/Opacity.spec.tsx +23 -0
- package/src/skia/types/Recorder.ts +1 -1
- package/src/sksg/Recorder/Player.ts +7 -1
- package/src/sksg/Recorder/ReanimatedRecorder.ts +2 -2
- package/src/sksg/Recorder/Recorder.ts +2 -2
- package/src/sksg/Recorder/Visitor.ts +2 -2
- package/src/sksg/Recorder/commands/Paint.ts +7 -2
@@ -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","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 { BaseRecorder } from \"../../skia/types/Recorder\";\nimport type { Node } from \"../Node\";\nimport { isImageFilter, isShader, sortNodeChildren } from \"../Node\";\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 = (\n recorder: BaseRecorder,\n colorFilters: Node<any>[]\n) => {\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: BaseRecorder, 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 = (\n recorder: BaseRecorder,\n imageFilters: Node<any>[]\n) => {\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: BaseRecorder, 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: BaseRecorder, maskFilters: Node<any>[]) => {\n if (maskFilters.length > 0) {\n recorder.pushBlurMaskFilter(maskFilters[maskFilters.length - 1].props);\n }\n};\n\nconst pushPaints = (recorder: BaseRecorder, 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: BaseRecorder, 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(props);\n break;\n case NodeType.Circle:\n recorder.drawCircle(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: BaseRecorder, root: Node[]) => {\n root.forEach((node) => {\n visitNode(recorder, node);\n });\n};\n"],"mappings":"AAAA;;AAMA,SAASA,QAAQ,QAAQ,iBAAiB;AAG1C,SAASC,aAAa,EAAEC,QAAQ,EAAEC,gBAAgB,QAAQ,SAAS;AAEnE,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,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AO,CAAE6F,OAAO,IAAK;IAC5B5D,SAAS,CAACnC,QAAQ,EAAE+F,OAAO,CAAC;EAC9B,CAAC,CAAC;EACF,IAAIvD,eAAe,EAAE;IACnBxC,QAAQ,CAACgG,YAAY,CAAC,CAAC;EACzB;EACA,IAAIlD,aAAa,EAAE;IACjB9C,QAAQ,CAACiG,UAAU,CAAC,CAAC;EACvB;EACA,IAAI7D,IAAI,CAAC7B,IAAI,KAAKlC,QAAQ,CAACgE,KAAK,EAAE;IAChCrC,QAAQ,CAACkG,YAAY,CAAC,CAAC;EACzB;AACF,CAAC;AAED,OAAO,MAAMC,KAAK,GAAGA,CAACnG,QAAsB,EAAEoG,IAAY,KAAK;EAC7DA,IAAI,CAAClG,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 { BaseRecorder } from \"../../skia/types/Recorder\";\nimport type { Node } from \"../Node\";\nimport { isImageFilter, isShader, sortNodeChildren } from \"../Node\";\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 = (\n recorder: BaseRecorder,\n colorFilters: Node<any>[]\n) => {\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: BaseRecorder, 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 = (\n recorder: BaseRecorder,\n imageFilters: Node<any>[]\n) => {\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: BaseRecorder, 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: BaseRecorder, maskFilters: Node<any>[]) => {\n if (maskFilters.length > 0) {\n recorder.pushBlurMaskFilter(maskFilters[maskFilters.length - 1].props);\n }\n};\n\nconst pushPaints = (recorder: BaseRecorder, paints: Node<any>[]) => {\n paints.forEach((paint) => {\n recorder.savePaint(paint.props, true);\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: BaseRecorder, 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 ?? {}, false);\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(props);\n break;\n case NodeType.Circle:\n recorder.drawCircle(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: BaseRecorder, root: Node[]) => {\n root.forEach((node) => {\n visitNode(recorder, node);\n });\n};\n"],"mappings":"AAAA;;AAMA,SAASA,QAAQ,QAAQ,iBAAiB;AAG1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
@@ -1,4 +1,4 @@
|
|
1
1
|
import type { PaintProps } from "../../../dom/types";
|
2
2
|
import type { Skia } from "../../../skia/types";
|
3
3
|
import type { DrawingContext } from "../DrawingContext";
|
4
|
-
export declare const setPaintProperties: (Skia: Skia, ctx: DrawingContext, { opacity, color, blendMode, strokeWidth, style, strokeJoin, strokeCap, strokeMiter, antiAlias, dither, }: PaintProps) => void;
|
4
|
+
export declare const setPaintProperties: (Skia: Skia, ctx: DrawingContext, { opacity, color, blendMode, strokeWidth, style, strokeJoin, strokeCap, strokeMiter, antiAlias, dither, }: PaintProps, standalone: boolean) => void;
|
@@ -11,14 +11,18 @@ export const setPaintProperties = (Skia, ctx, {
|
|
11
11
|
strokeMiter,
|
12
12
|
antiAlias,
|
13
13
|
dither
|
14
|
-
}) => {
|
14
|
+
}, standalone) => {
|
15
15
|
"worklet";
|
16
16
|
|
17
17
|
const {
|
18
18
|
paint
|
19
19
|
} = ctx;
|
20
20
|
if (opacity !== undefined) {
|
21
|
-
|
21
|
+
if (standalone) {
|
22
|
+
paint.setAlphaf(paint.getAlphaf() * opacity);
|
23
|
+
} else {
|
24
|
+
ctx.setOpacity(ctx.getOpacity() * opacity);
|
25
|
+
}
|
22
26
|
}
|
23
27
|
if (color !== undefined) {
|
24
28
|
paint.setShader(null);
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["enumKey","processColor","BlendMode","PaintStyle","StrokeCap","StrokeJoin","setPaintProperties","Skia","ctx","opacity","color","blendMode","strokeWidth","style","strokeJoin","strokeCap","strokeMiter","antiAlias","dither","paint","undefined","setOpacity","getOpacity","setShader","setColor","setBlendMode","setStrokeWidth","setStyle","setStrokeJoin","setStrokeCap","setStrokeMiter","setAntiAlias","setDither"],"sources":["Paint.ts"],"sourcesContent":["import { enumKey, processColor } from \"../../../dom/nodes\";\nimport type { PaintProps } from \"../../../dom/types\";\nimport {\n BlendMode,\n PaintStyle,\n StrokeCap,\n StrokeJoin,\n} from \"../../../skia/types\";\nimport type { Skia } from \"../../../skia/types\";\nimport type { DrawingContext } from \"../DrawingContext\";\n\nexport const setPaintProperties = (\n Skia: Skia,\n ctx: DrawingContext,\n {\n opacity,\n color,\n blendMode,\n strokeWidth,\n style,\n strokeJoin,\n strokeCap,\n strokeMiter,\n antiAlias,\n dither,\n }: PaintProps\n) => {\n \"worklet\";\n const { paint } = ctx;\n\n if (opacity !== undefined) {\n ctx.setOpacity(ctx.getOpacity() * opacity);\n }\n if (color !== undefined) {\n paint.setShader(null);\n paint.setColor(processColor(Skia, color));\n }\n if (blendMode !== undefined) {\n paint.setBlendMode(BlendMode[enumKey(blendMode)]);\n }\n if (strokeWidth !== undefined) {\n paint.setStrokeWidth(strokeWidth);\n }\n if (style !== undefined) {\n paint.setStyle(PaintStyle[enumKey(style)]);\n }\n if (strokeJoin !== undefined) {\n paint.setStrokeJoin(StrokeJoin[enumKey(strokeJoin)]);\n }\n if (strokeCap !== undefined) {\n paint.setStrokeCap(StrokeCap[enumKey(strokeCap)]);\n }\n if (strokeMiter !== undefined) {\n paint.setStrokeMiter(strokeMiter);\n }\n if (antiAlias !== undefined) {\n paint.setAntiAlias(antiAlias);\n }\n if (dither !== undefined) {\n paint.setDither(dither);\n }\n};\n"],"mappings":"AAAA,SAASA,OAAO,EAAEC,YAAY,QAAQ,oBAAoB;AAE1D,SACEC,SAAS,EACTC,UAAU,EACVC,SAAS,EACTC,UAAU,QACL,qBAAqB;AAI5B,OAAO,MAAMC,kBAAkB,GAAGA,CAChCC,IAAU,EACVC,GAAmB,EACnB;EACEC,OAAO;EACPC,KAAK;EACLC,SAAS;EACTC,WAAW;EACXC,KAAK;EACLC,UAAU;EACVC,SAAS;EACTC,WAAW;EACXC,SAAS;EACTC;AACU,CAAC,
|
1
|
+
{"version":3,"names":["enumKey","processColor","BlendMode","PaintStyle","StrokeCap","StrokeJoin","setPaintProperties","Skia","ctx","opacity","color","blendMode","strokeWidth","style","strokeJoin","strokeCap","strokeMiter","antiAlias","dither","standalone","paint","undefined","setAlphaf","getAlphaf","setOpacity","getOpacity","setShader","setColor","setBlendMode","setStrokeWidth","setStyle","setStrokeJoin","setStrokeCap","setStrokeMiter","setAntiAlias","setDither"],"sources":["Paint.ts"],"sourcesContent":["import { enumKey, processColor } from \"../../../dom/nodes\";\nimport type { PaintProps } from \"../../../dom/types\";\nimport {\n BlendMode,\n PaintStyle,\n StrokeCap,\n StrokeJoin,\n} from \"../../../skia/types\";\nimport type { Skia } from \"../../../skia/types\";\nimport type { DrawingContext } from \"../DrawingContext\";\n\nexport const setPaintProperties = (\n Skia: Skia,\n ctx: DrawingContext,\n {\n opacity,\n color,\n blendMode,\n strokeWidth,\n style,\n strokeJoin,\n strokeCap,\n strokeMiter,\n antiAlias,\n dither,\n }: PaintProps,\n standalone: boolean\n) => {\n \"worklet\";\n const { paint } = ctx;\n\n if (opacity !== undefined) {\n if (standalone) {\n paint.setAlphaf(paint.getAlphaf() * opacity);\n } else {\n ctx.setOpacity(ctx.getOpacity() * opacity);\n }\n }\n if (color !== undefined) {\n paint.setShader(null);\n paint.setColor(processColor(Skia, color));\n }\n if (blendMode !== undefined) {\n paint.setBlendMode(BlendMode[enumKey(blendMode)]);\n }\n if (strokeWidth !== undefined) {\n paint.setStrokeWidth(strokeWidth);\n }\n if (style !== undefined) {\n paint.setStyle(PaintStyle[enumKey(style)]);\n }\n if (strokeJoin !== undefined) {\n paint.setStrokeJoin(StrokeJoin[enumKey(strokeJoin)]);\n }\n if (strokeCap !== undefined) {\n paint.setStrokeCap(StrokeCap[enumKey(strokeCap)]);\n }\n if (strokeMiter !== undefined) {\n paint.setStrokeMiter(strokeMiter);\n }\n if (antiAlias !== undefined) {\n paint.setAntiAlias(antiAlias);\n }\n if (dither !== undefined) {\n paint.setDither(dither);\n }\n};\n"],"mappings":"AAAA,SAASA,OAAO,EAAEC,YAAY,QAAQ,oBAAoB;AAE1D,SACEC,SAAS,EACTC,UAAU,EACVC,SAAS,EACTC,UAAU,QACL,qBAAqB;AAI5B,OAAO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CAACJ,OAAO,CAACe,SAAS,CAAC,CAAC,CAAC;EACnD;EACA,IAAIC,WAAW,KAAKK,SAAS,EAAE;IAC7BD,KAAK,CAACa,cAAc,CAACjB,WAAW,CAAC;EACnC;EACA,IAAIC,SAAS,KAAKI,SAAS,EAAE;IAC3BD,KAAK,CAACc,YAAY,CAACjB,SAAS,CAAC;EAC/B;EACA,IAAIC,MAAM,KAAKG,SAAS,EAAE;IACxBD,KAAK,CAACe,SAAS,CAACjB,MAAM,CAAC;EACzB;AACF,CAAC","ignoreList":[]}
|
@@ -7,7 +7,7 @@ export class ReanimatedRecorder {
|
|
7
7
|
getSharedValues(): any[];
|
8
8
|
saveGroup(): void;
|
9
9
|
restoreGroup(): void;
|
10
|
-
savePaint(props: any): void;
|
10
|
+
savePaint(props: any, standalone: any): void;
|
11
11
|
restorePaint(): void;
|
12
12
|
restorePaintDeclaration(): void;
|
13
13
|
materializePaint(): void;
|
@@ -12,7 +12,7 @@ export class Recorder {
|
|
12
12
|
add(command: any): void;
|
13
13
|
saveGroup(): void;
|
14
14
|
restoreGroup(): void;
|
15
|
-
savePaint(props: any): void;
|
15
|
+
savePaint(props: any, standalone: any): void;
|
16
16
|
restorePaint(): void;
|
17
17
|
restorePaintDeclaration(): void;
|
18
18
|
materializePaint(): void;
|
@@ -6,7 +6,7 @@ export class ReanimatedRecorder {
|
|
6
6
|
getSharedValues(): any[];
|
7
7
|
saveGroup(): void;
|
8
8
|
restoreGroup(): void;
|
9
|
-
savePaint(props: any): void;
|
9
|
+
savePaint(props: any, standalone: any): void;
|
10
10
|
restorePaint(): void;
|
11
11
|
restorePaintDeclaration(): void;
|
12
12
|
materializePaint(): void;
|
@@ -11,7 +11,7 @@ export class Recorder {
|
|
11
11
|
add(command: any): void;
|
12
12
|
saveGroup(): void;
|
13
13
|
restoreGroup(): void;
|
14
|
-
savePaint(props: any): void;
|
14
|
+
savePaint(props: any, standalone: any): void;
|
15
15
|
restorePaint(): void;
|
16
16
|
restorePaintDeclaration(): void;
|
17
17
|
materializePaint(): void;
|
@@ -5,7 +5,7 @@ import type { SkPicture } from "./Picture";
|
|
5
5
|
export interface BaseRecorder {
|
6
6
|
saveGroup(): void;
|
7
7
|
restoreGroup(): void;
|
8
|
-
savePaint(props: AnimatedProps<PaintProps
|
8
|
+
savePaint(props: AnimatedProps<PaintProps>, standalone: boolean): void;
|
9
9
|
restorePaint(): void;
|
10
10
|
restorePaintDeclaration(): void;
|
11
11
|
materializePaint(): void;
|
@@ -11,7 +11,7 @@ export declare class ReanimatedRecorder implements BaseRecorder {
|
|
11
11
|
getSharedValues(): SharedValue<unknown>[];
|
12
12
|
saveGroup(): void;
|
13
13
|
restoreGroup(): void;
|
14
|
-
savePaint(props: AnimatedProps<PaintProps
|
14
|
+
savePaint(props: AnimatedProps<PaintProps>, standalone: boolean): void;
|
15
15
|
restorePaint(): void;
|
16
16
|
restorePaintDeclaration(): void;
|
17
17
|
materializePaint(): void;
|
@@ -21,7 +21,7 @@ export declare class Recorder implements BaseRecorder {
|
|
21
21
|
private add;
|
22
22
|
saveGroup(): void;
|
23
23
|
restoreGroup(): void;
|
24
|
-
savePaint(props: AnimatedProps<PaintProps
|
24
|
+
savePaint(props: AnimatedProps<PaintProps>, standalone: boolean): void;
|
25
25
|
restorePaint(): void;
|
26
26
|
restorePaintDeclaration(): void;
|
27
27
|
materializePaint(): void;
|
@@ -1,4 +1,4 @@
|
|
1
1
|
import type { PaintProps } from "../../../dom/types";
|
2
2
|
import type { Skia } from "../../../skia/types";
|
3
3
|
import type { DrawingContext } from "../DrawingContext";
|
4
|
-
export declare const setPaintProperties: (Skia: Skia, ctx: DrawingContext, { opacity, color, blendMode, strokeWidth, style, strokeJoin, strokeCap, strokeMiter, antiAlias, dither, }: PaintProps) => void;
|
4
|
+
export declare const setPaintProperties: (Skia: Skia, ctx: DrawingContext, { opacity, color, blendMode, strokeWidth, style, strokeJoin, strokeCap, strokeMiter, antiAlias, dither, }: PaintProps, standalone: boolean) => void;
|
package/package.json
CHANGED
@@ -8,7 +8,7 @@
|
|
8
8
|
"setup-skia-web": "scripts/setup-canvaskit.js"
|
9
9
|
},
|
10
10
|
"title": "React Native Skia",
|
11
|
-
"version": "2.0.
|
11
|
+
"version": "2.0.4",
|
12
12
|
"description": "High-performance React Native Graphics using Skia",
|
13
13
|
"main": "lib/module/index.js",
|
14
14
|
"react-native": "src/index.ts",
|
Binary file
|
Binary file
|
@@ -14,6 +14,7 @@ import {
|
|
14
14
|
Group,
|
15
15
|
Image,
|
16
16
|
ImageShader,
|
17
|
+
Paint,
|
17
18
|
RoundedRect,
|
18
19
|
} from "../../components";
|
19
20
|
import { setupSkia } from "../../../skia/__tests__/setup";
|
@@ -275,4 +276,26 @@ describe("Opacity", () => {
|
|
275
276
|
);
|
276
277
|
checkImage(img, "snapshots/drawings/opacity-image.png");
|
277
278
|
});
|
279
|
+
it("Should apply opacity on a layer (1)", async () => {
|
280
|
+
const {} = importSkia();
|
281
|
+
const img = await surface.draw(
|
282
|
+
<Group>
|
283
|
+
<Group layer={<Paint opacity={0.5} />}>
|
284
|
+
<Fill color="lightblue" />
|
285
|
+
</Group>
|
286
|
+
</Group>
|
287
|
+
);
|
288
|
+
checkImage(img, "snapshots/drawings/semi-transparent-layer.png");
|
289
|
+
});
|
290
|
+
it("Should apply opacity on a layer (2)", async () => {
|
291
|
+
const {} = importSkia();
|
292
|
+
const img = await surface.draw(
|
293
|
+
<Group>
|
294
|
+
<Group layer={<Paint opacity={0} />}>
|
295
|
+
<Fill color="lightblue" />
|
296
|
+
</Group>
|
297
|
+
</Group>
|
298
|
+
);
|
299
|
+
checkImage(img, "snapshots/drawings/transparent-layer.png");
|
300
|
+
});
|
278
301
|
});
|
@@ -34,7 +34,7 @@ import type { SkPicture } from "./Picture";
|
|
34
34
|
export interface BaseRecorder {
|
35
35
|
saveGroup(): void;
|
36
36
|
restoreGroup(): void;
|
37
|
-
savePaint(props: AnimatedProps<PaintProps
|
37
|
+
savePaint(props: AnimatedProps<PaintProps>, standalone: boolean): void;
|
38
38
|
restorePaint(): void;
|
39
39
|
restorePaintDeclaration(): void;
|
40
40
|
materializePaint(): void;
|
@@ -67,7 +67,13 @@ function play(ctx: DrawingContext, _command: Command) {
|
|
67
67
|
ctx.paints.push(command.props.paint);
|
68
68
|
} else {
|
69
69
|
ctx.savePaint();
|
70
|
-
setPaintProperties(
|
70
|
+
setPaintProperties(
|
71
|
+
ctx.Skia,
|
72
|
+
ctx,
|
73
|
+
command.props,
|
74
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
75
|
+
(command as any).standalone
|
76
|
+
);
|
71
77
|
}
|
72
78
|
} else if (isCommand(command, CommandType.RestorePaint)) {
|
73
79
|
ctx.restorePaint();
|
@@ -69,9 +69,9 @@ export class ReanimatedRecorder implements BaseRecorder {
|
|
69
69
|
this.recorder.restoreGroup();
|
70
70
|
}
|
71
71
|
|
72
|
-
savePaint(props: AnimatedProps<PaintProps
|
72
|
+
savePaint(props: AnimatedProps<PaintProps>, standalone: boolean): void {
|
73
73
|
this.processAnimationValues(props);
|
74
|
-
this.recorder.savePaint(props);
|
74
|
+
this.recorder.savePaint(props, standalone);
|
75
75
|
}
|
76
76
|
|
77
77
|
restorePaint(): void {
|
@@ -102,8 +102,8 @@ export class Recorder implements BaseRecorder {
|
|
102
102
|
this.cursors.pop();
|
103
103
|
}
|
104
104
|
|
105
|
-
savePaint(props: AnimatedProps<PaintProps
|
106
|
-
this.add({ type: CommandType.SavePaint, props });
|
105
|
+
savePaint(props: AnimatedProps<PaintProps>, standalone: boolean) {
|
106
|
+
this.add({ type: CommandType.SavePaint, props, standalone });
|
107
107
|
}
|
108
108
|
|
109
109
|
restorePaint() {
|
@@ -188,7 +188,7 @@ const pushMaskFilters = (recorder: BaseRecorder, maskFilters: Node<any>[]) => {
|
|
188
188
|
|
189
189
|
const pushPaints = (recorder: BaseRecorder, paints: Node<any>[]) => {
|
190
190
|
paints.forEach((paint) => {
|
191
|
-
recorder.savePaint(paint.props);
|
191
|
+
recorder.savePaint(paint.props, true);
|
192
192
|
const { colorFilters, maskFilters, shaders, imageFilters, pathEffects } =
|
193
193
|
sortNodeChildren(paint);
|
194
194
|
pushColorFilters(recorder, colorFilters);
|
@@ -223,7 +223,7 @@ const visitNode = (recorder: BaseRecorder, node: Node<any>) => {
|
|
223
223
|
pathEffects.length > 0 ||
|
224
224
|
shaders.length > 0;
|
225
225
|
if (shouldPushPaint) {
|
226
|
-
recorder.savePaint(paint ?? {});
|
226
|
+
recorder.savePaint(paint ?? {}, false);
|
227
227
|
pushColorFilters(recorder, colorFilters);
|
228
228
|
pushImageFilters(recorder, imageFilters);
|
229
229
|
pushMaskFilters(recorder, maskFilters);
|
@@ -23,13 +23,18 @@ export const setPaintProperties = (
|
|
23
23
|
strokeMiter,
|
24
24
|
antiAlias,
|
25
25
|
dither,
|
26
|
-
}: PaintProps
|
26
|
+
}: PaintProps,
|
27
|
+
standalone: boolean
|
27
28
|
) => {
|
28
29
|
"worklet";
|
29
30
|
const { paint } = ctx;
|
30
31
|
|
31
32
|
if (opacity !== undefined) {
|
32
|
-
|
33
|
+
if (standalone) {
|
34
|
+
paint.setAlphaf(paint.getAlphaf() * opacity);
|
35
|
+
} else {
|
36
|
+
ctx.setOpacity(ctx.getOpacity() * opacity);
|
37
|
+
}
|
33
38
|
}
|
34
39
|
if (color !== undefined) {
|
35
40
|
paint.setShader(null);
|