@shopify/react-native-skia 2.1.0 → 2.1.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/cpp/api/recorder/Convertor.h +16 -0
- package/cpp/api/recorder/ImageFilters.h +20 -0
- package/cpp/api/recorder/RNRecorder.h +6 -0
- package/lib/commonjs/dom/types/Drawings.d.ts +4 -1
- package/lib/commonjs/dom/types/Drawings.js.map +1 -1
- package/lib/commonjs/dom/types/NodeType.d.ts +2 -1
- package/lib/commonjs/dom/types/NodeType.js +2 -0
- package/lib/commonjs/dom/types/NodeType.js.map +1 -1
- package/lib/commonjs/renderer/__tests__/e2e/ImageFilter.spec.d.ts +1 -0
- package/lib/commonjs/renderer/components/ImageFilter.d.ts +4 -0
- package/lib/commonjs/renderer/components/ImageFilter.js +13 -0
- package/lib/commonjs/renderer/components/ImageFilter.js.map +1 -0
- package/lib/commonjs/renderer/components/index.d.ts +1 -0
- package/lib/commonjs/renderer/components/index.js +11 -0
- package/lib/commonjs/renderer/components/index.js.map +1 -1
- package/lib/commonjs/sksg/Elements.d.ts +2 -1
- package/lib/commonjs/sksg/Elements.js.map +1 -1
- package/lib/commonjs/sksg/Node.d.ts +1 -1
- package/lib/commonjs/sksg/Node.js +1 -1
- package/lib/commonjs/sksg/Node.js.map +1 -1
- package/lib/commonjs/sksg/Recorder/commands/ImageFilters.js +11 -1
- package/lib/commonjs/sksg/Recorder/commands/ImageFilters.js.map +1 -1
- package/lib/module/dom/types/Drawings.d.ts +4 -1
- package/lib/module/dom/types/Drawings.js.map +1 -1
- package/lib/module/dom/types/NodeType.d.ts +2 -1
- package/lib/module/dom/types/NodeType.js +2 -0
- package/lib/module/dom/types/NodeType.js.map +1 -1
- package/lib/module/renderer/__tests__/e2e/ImageFilter.spec.d.ts +1 -0
- package/lib/module/renderer/components/ImageFilter.d.ts +4 -0
- package/lib/module/renderer/components/ImageFilter.js +5 -0
- package/lib/module/renderer/components/ImageFilter.js.map +1 -0
- package/lib/module/renderer/components/index.d.ts +1 -0
- package/lib/module/renderer/components/index.js +1 -0
- package/lib/module/renderer/components/index.js.map +1 -1
- package/lib/module/sksg/Elements.d.ts +2 -1
- package/lib/module/sksg/Elements.js.map +1 -1
- package/lib/module/sksg/Node.d.ts +1 -1
- package/lib/module/sksg/Node.js +1 -1
- package/lib/module/sksg/Node.js.map +1 -1
- package/lib/module/sksg/Recorder/commands/ImageFilters.js +11 -1
- package/lib/module/sksg/Recorder/commands/ImageFilters.js.map +1 -1
- package/lib/typescript/lib/commonjs/renderer/components/ImageFilter.d.ts +2 -0
- package/lib/typescript/lib/module/mock/index.d.ts +1 -0
- package/lib/typescript/lib/module/renderer/components/ImageFilter.d.ts +2 -0
- package/lib/typescript/lib/module/renderer/components/index.d.ts +1 -0
- package/lib/typescript/src/dom/types/Drawings.d.ts +4 -1
- package/lib/typescript/src/dom/types/NodeType.d.ts +2 -1
- package/lib/typescript/src/renderer/__tests__/e2e/ImageFilter.spec.d.ts +1 -0
- package/lib/typescript/src/renderer/components/ImageFilter.d.ts +4 -0
- package/lib/typescript/src/renderer/components/index.d.ts +1 -0
- package/lib/typescript/src/sksg/Elements.d.ts +2 -1
- package/lib/typescript/src/sksg/Node.d.ts +1 -1
- package/package.json +1 -1
- package/src/dom/types/Drawings.ts +5 -0
- package/src/dom/types/NodeType.ts +2 -0
- package/src/renderer/__tests__/e2e/ImageFilter.spec.tsx +99 -0
- package/src/renderer/__tests__/setup.tsx +8 -0
- package/src/renderer/components/ImageFilter.tsx +8 -0
- package/src/renderer/components/index.ts +1 -0
- package/src/sksg/Elements.tsx +2 -0
- package/src/sksg/Node.ts +1 -0
- package/src/sksg/Recorder/commands/ImageFilters.ts +14 -1
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":[],"sources":["Elements.tsx"],"sourcesContent":["import type {\n FractalNoiseProps,\n CircleProps,\n DrawingNodeProps,\n ImageProps,\n PaintProps,\n PathProps,\n LineProps,\n OvalProps,\n DiffRectProps,\n PointsProps,\n RectProps,\n RoundedRectProps,\n TextProps,\n VerticesProps,\n BlurMaskFilterProps,\n BlendImageFilterProps,\n BlurImageFilterProps,\n DisplacementMapImageFilterProps,\n DropShadowImageFilterProps,\n OffsetImageFilterProps,\n RuntimeShaderImageFilterProps,\n MatrixColorFilterProps,\n ShaderProps,\n ImageShaderProps,\n LinearGradientProps,\n GroupProps,\n PatchProps,\n BlendColorFilterProps,\n DashPathEffectProps,\n DiscretePathEffectProps,\n CornerPathEffectProps,\n Line2DPathEffectProps,\n Path1DPathEffectProps,\n Path2DPathEffectProps,\n TextPathProps,\n TextBlobProps,\n GlyphsProps,\n TwoPointConicalGradientProps,\n TurbulenceProps,\n SweepGradientProps,\n RadialGradientProps,\n ColorProps,\n PictureProps,\n ImageSVGProps,\n LerpColorFilterProps,\n BoxProps,\n BoxShadowProps,\n ParagraphProps,\n AtlasProps,\n ChildrenProps,\n MorphologyImageFilterProps,\n BlendProps,\n SkottieProps,\n} from \"../dom/types\";\nimport type { SkiaProps } from \"../renderer\";\n\ndeclare module \"react\" {\n // eslint-disable-next-line @typescript-eslint/no-namespace\n namespace JSX {\n interface IntrinsicElements {\n skGroup: SkiaProps<GroupProps>;\n skLayer: SkiaProps<ChildrenProps>;\n skPaint: SkiaProps<PaintProps>;\n\n // Drawings\n skFill: SkiaProps<DrawingNodeProps>;\n skImage: SkiaProps<ImageProps>;\n skCircle: SkiaProps<CircleProps>;\n skPath: SkiaProps<PathProps>;\n skLine: SkiaProps<LineProps>;\n skOval: SkiaProps<OvalProps>;\n skPatch: SkiaProps<PatchProps>;\n skPoints: SkiaProps<PointsProps>;\n skRect: SkiaProps<RectProps>;\n skRRect: SkiaProps<RoundedRectProps>;\n skAtlas: SkiaProps<AtlasProps>;\n skVertices: SkiaProps<VerticesProps>;\n skText: SkiaProps<TextProps>;\n skTextPath: SkiaProps<TextPathProps>;\n skTextBlob: SkiaProps<TextBlobProps>;\n skGlyphs: SkiaProps<GlyphsProps>;\n skDiffRect: SkiaProps<DiffRectProps>;\n skSkottie: SkiaProps<SkottieProps>;\n skPicture: SkiaProps<PictureProps>;\n skImageSVG: SkiaProps<ImageSVGProps>;\n\n // BlurMaskFilters\n skBlurMaskFilter: SkiaProps<BlurMaskFilterProps>;\n\n // ImageFilters\n skBlendImageFilter: SkiaProps<BlendImageFilterProps>;\n skBlurImageFilter: SkiaProps<BlurImageFilterProps>;\n skOffsetImageFilter: SkiaProps<OffsetImageFilterProps>;\n skDropShadowImageFilter: SkiaProps<DropShadowImageFilterProps>;\n skDisplacementMapImageFilter: SkiaProps<DisplacementMapImageFilterProps>;\n skRuntimeShaderImageFilter: SkiaProps<RuntimeShaderImageFilterProps>;\n skMorphologyImageFilter: SkiaProps<MorphologyImageFilterProps>;\n\n // ColorFilters\n skMatrixColorFilter: SkiaProps<MatrixColorFilterProps>;\n skBlendColorFilter: SkiaProps<BlendColorFilterProps>;\n skLinearToSRGBGammaColorFilter: SkiaProps<ChildrenProps>;\n skSRGBToLinearGammaColorFilter: SkiaProps<ChildrenProps>;\n skLumaColorFilter: SkiaProps<ChildrenProps>;\n skLerpColorFilter: SkiaProps<LerpColorFilterProps>;\n\n // Shaders\n skShader: SkiaProps<ShaderProps>;\n skImageShader: SkiaProps<ImageShaderProps>;\n skColorShader: SkiaProps<ColorProps>;\n skTurbulence: SkiaProps<TurbulenceProps>;\n skFractalNoise: SkiaProps<FractalNoiseProps>;\n skLinearGradient: SkiaProps<LinearGradientProps>;\n skRadialGradient: SkiaProps<RadialGradientProps>;\n skSweepGradient: SkiaProps<SweepGradientProps>;\n skTwoPointConicalGradient: SkiaProps<TwoPointConicalGradientProps>;\n\n // Path Effects\n skDiscretePathEffect: SkiaProps<DiscretePathEffectProps>;\n skDashPathEffect: SkiaProps<DashPathEffectProps>;\n skPath1DPathEffect: SkiaProps<Path1DPathEffectProps>;\n skPath2DPathEffect: SkiaProps<Path2DPathEffectProps>;\n skCornerPathEffect: SkiaProps<CornerPathEffectProps>;\n skSumPathEffect: ChildrenProps;\n skLine2DPathEffect: SkiaProps<Line2DPathEffectProps>;\n\n // Mixed declarations/drawings\n skBlend: SkiaProps<BlendProps>;\n skBackdropFilter: SkiaProps<ChildrenProps>;\n skBox: SkiaProps<BoxProps>;\n skBoxShadow: SkiaProps<BoxShadowProps>;\n\n // Paragraph\n skParagraph: SkiaProps<ParagraphProps>;\n }\n }\n}\n"],"mappings":"","ignoreList":[]}
|
1
|
+
{"version":3,"names":[],"sources":["Elements.tsx"],"sourcesContent":["import type {\n FractalNoiseProps,\n CircleProps,\n DrawingNodeProps,\n ImageProps,\n PaintProps,\n PathProps,\n LineProps,\n OvalProps,\n DiffRectProps,\n PointsProps,\n RectProps,\n RoundedRectProps,\n TextProps,\n VerticesProps,\n BlurMaskFilterProps,\n BlendImageFilterProps,\n BlurImageFilterProps,\n DisplacementMapImageFilterProps,\n DropShadowImageFilterProps,\n OffsetImageFilterProps,\n RuntimeShaderImageFilterProps,\n MatrixColorFilterProps,\n ShaderProps,\n ImageShaderProps,\n LinearGradientProps,\n GroupProps,\n PatchProps,\n BlendColorFilterProps,\n DashPathEffectProps,\n DiscretePathEffectProps,\n CornerPathEffectProps,\n Line2DPathEffectProps,\n Path1DPathEffectProps,\n Path2DPathEffectProps,\n TextPathProps,\n TextBlobProps,\n GlyphsProps,\n TwoPointConicalGradientProps,\n TurbulenceProps,\n SweepGradientProps,\n RadialGradientProps,\n ColorProps,\n PictureProps,\n ImageSVGProps,\n LerpColorFilterProps,\n BoxProps,\n BoxShadowProps,\n ParagraphProps,\n AtlasProps,\n ChildrenProps,\n MorphologyImageFilterProps,\n BlendProps,\n SkottieProps,\n ImageFilterProps,\n} from \"../dom/types\";\nimport type { SkiaProps } from \"../renderer\";\n\ndeclare module \"react\" {\n // eslint-disable-next-line @typescript-eslint/no-namespace\n namespace JSX {\n interface IntrinsicElements {\n skGroup: SkiaProps<GroupProps>;\n skLayer: SkiaProps<ChildrenProps>;\n skPaint: SkiaProps<PaintProps>;\n\n // Drawings\n skFill: SkiaProps<DrawingNodeProps>;\n skImage: SkiaProps<ImageProps>;\n skCircle: SkiaProps<CircleProps>;\n skPath: SkiaProps<PathProps>;\n skLine: SkiaProps<LineProps>;\n skOval: SkiaProps<OvalProps>;\n skPatch: SkiaProps<PatchProps>;\n skPoints: SkiaProps<PointsProps>;\n skRect: SkiaProps<RectProps>;\n skRRect: SkiaProps<RoundedRectProps>;\n skAtlas: SkiaProps<AtlasProps>;\n skVertices: SkiaProps<VerticesProps>;\n skText: SkiaProps<TextProps>;\n skTextPath: SkiaProps<TextPathProps>;\n skTextBlob: SkiaProps<TextBlobProps>;\n skGlyphs: SkiaProps<GlyphsProps>;\n skDiffRect: SkiaProps<DiffRectProps>;\n skSkottie: SkiaProps<SkottieProps>;\n skPicture: SkiaProps<PictureProps>;\n skImageSVG: SkiaProps<ImageSVGProps>;\n\n // BlurMaskFilters\n skBlurMaskFilter: SkiaProps<BlurMaskFilterProps>;\n\n // ImageFilters\n skImageFilter: SkiaProps<ImageFilterProps>;\n skBlendImageFilter: SkiaProps<BlendImageFilterProps>;\n skBlurImageFilter: SkiaProps<BlurImageFilterProps>;\n skOffsetImageFilter: SkiaProps<OffsetImageFilterProps>;\n skDropShadowImageFilter: SkiaProps<DropShadowImageFilterProps>;\n skDisplacementMapImageFilter: SkiaProps<DisplacementMapImageFilterProps>;\n skRuntimeShaderImageFilter: SkiaProps<RuntimeShaderImageFilterProps>;\n skMorphologyImageFilter: SkiaProps<MorphologyImageFilterProps>;\n\n // ColorFilters\n skMatrixColorFilter: SkiaProps<MatrixColorFilterProps>;\n skBlendColorFilter: SkiaProps<BlendColorFilterProps>;\n skLinearToSRGBGammaColorFilter: SkiaProps<ChildrenProps>;\n skSRGBToLinearGammaColorFilter: SkiaProps<ChildrenProps>;\n skLumaColorFilter: SkiaProps<ChildrenProps>;\n skLerpColorFilter: SkiaProps<LerpColorFilterProps>;\n\n // Shaders\n skShader: SkiaProps<ShaderProps>;\n skImageShader: SkiaProps<ImageShaderProps>;\n skColorShader: SkiaProps<ColorProps>;\n skTurbulence: SkiaProps<TurbulenceProps>;\n skFractalNoise: SkiaProps<FractalNoiseProps>;\n skLinearGradient: SkiaProps<LinearGradientProps>;\n skRadialGradient: SkiaProps<RadialGradientProps>;\n skSweepGradient: SkiaProps<SweepGradientProps>;\n skTwoPointConicalGradient: SkiaProps<TwoPointConicalGradientProps>;\n\n // Path Effects\n skDiscretePathEffect: SkiaProps<DiscretePathEffectProps>;\n skDashPathEffect: SkiaProps<DashPathEffectProps>;\n skPath1DPathEffect: SkiaProps<Path1DPathEffectProps>;\n skPath2DPathEffect: SkiaProps<Path2DPathEffectProps>;\n skCornerPathEffect: SkiaProps<CornerPathEffectProps>;\n skSumPathEffect: ChildrenProps;\n skLine2DPathEffect: SkiaProps<Line2DPathEffectProps>;\n\n // Mixed declarations/drawings\n skBlend: SkiaProps<BlendProps>;\n skBackdropFilter: SkiaProps<ChildrenProps>;\n skBox: SkiaProps<BoxProps>;\n skBoxShadow: SkiaProps<BoxShadowProps>;\n\n // Paragraph\n skParagraph: SkiaProps<ParagraphProps>;\n }\n }\n}\n"],"mappings":"","ignoreList":[]}
|
@@ -6,7 +6,7 @@ export interface Node<Props = unknown> {
|
|
6
6
|
}
|
7
7
|
export declare const isColorFilter: (type: NodeType) => type is NodeType.MatrixColorFilter | NodeType.BlendColorFilter | NodeType.LinearToSRGBGammaColorFilter | NodeType.SRGBToLinearGammaColorFilter | NodeType.LumaColorFilter | NodeType.LerpColorFilter;
|
8
8
|
export declare const isPathEffect: (type: NodeType) => type is NodeType.DiscretePathEffect | NodeType.DashPathEffect | NodeType.Path1DPathEffect | NodeType.Path2DPathEffect | NodeType.CornerPathEffect | NodeType.SumPathEffect | NodeType.Line2DPathEffect;
|
9
|
-
export declare const isImageFilter: (type: NodeType) => type is NodeType.OffsetImageFilter | NodeType.DisplacementMapImageFilter | NodeType.BlurImageFilter | NodeType.DropShadowImageFilter | NodeType.MorphologyImageFilter | NodeType.BlendImageFilter | NodeType.RuntimeShaderImageFilter;
|
9
|
+
export declare const isImageFilter: (type: NodeType) => type is NodeType.OffsetImageFilter | NodeType.DisplacementMapImageFilter | NodeType.BlurImageFilter | NodeType.DropShadowImageFilter | NodeType.MorphologyImageFilter | NodeType.BlendImageFilter | NodeType.RuntimeShaderImageFilter | NodeType.ImageFilter;
|
10
10
|
export declare const isShader: (type: NodeType) => type is NodeType.Shader | NodeType.ImageShader | NodeType.ColorShader | NodeType.Turbulence | NodeType.FractalNoise | NodeType.LinearGradient | NodeType.RadialGradient | NodeType.SweepGradient | NodeType.TwoPointConicalGradient;
|
11
11
|
export declare const sortNodeChildren: (parent: Node) => {
|
12
12
|
colorFilters: Node<unknown>[];
|
package/lib/module/sksg/Node.js
CHANGED
@@ -12,7 +12,7 @@ export const isPathEffect = type => {
|
|
12
12
|
export const isImageFilter = type => {
|
13
13
|
"worklet";
|
14
14
|
|
15
|
-
return type === NodeType.OffsetImageFilter || type === NodeType.DisplacementMapImageFilter || type === NodeType.BlurImageFilter || type === NodeType.DropShadowImageFilter || type === NodeType.MorphologyImageFilter || type === NodeType.BlendImageFilter || type === NodeType.RuntimeShaderImageFilter;
|
15
|
+
return type === NodeType.ImageFilter || type === NodeType.OffsetImageFilter || type === NodeType.DisplacementMapImageFilter || type === NodeType.BlurImageFilter || type === NodeType.DropShadowImageFilter || type === NodeType.MorphologyImageFilter || type === NodeType.BlendImageFilter || type === NodeType.RuntimeShaderImageFilter;
|
16
16
|
};
|
17
17
|
export const isShader = type => {
|
18
18
|
"worklet";
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["NodeType","isColorFilter","type","BlendColorFilter","MatrixColorFilter","LerpColorFilter","LumaColorFilter","SRGBToLinearGammaColorFilter","LinearToSRGBGammaColorFilter","isPathEffect","DiscretePathEffect","DashPathEffect","Path1DPathEffect","Path2DPathEffect","CornerPathEffect","SumPathEffect","Line2DPathEffect","isImageFilter","OffsetImageFilter","DisplacementMapImageFilter","BlurImageFilter","DropShadowImageFilter","MorphologyImageFilter","BlendImageFilter","RuntimeShaderImageFilter","isShader","Shader","ImageShader","ColorShader","Turbulence","FractalNoise","LinearGradient","RadialGradient","SweepGradient","TwoPointConicalGradient","sortNodeChildren","parent","maskFilters","colorFilters","shaders","imageFilters","pathEffects","drawings","paints","children","forEach","node","push","BlurMaskFilter","Paint","Blend"],"sources":["Node.ts"],"sourcesContent":["import { NodeType } from \"../dom/types\";\n\nexport interface Node<Props = unknown> {\n type: NodeType;\n props: Props;\n children: Node[];\n}\n\nexport const isColorFilter = (type: NodeType) => {\n \"worklet\";\n return (\n type === NodeType.BlendColorFilter ||\n type === NodeType.MatrixColorFilter ||\n type === NodeType.LerpColorFilter ||\n type === NodeType.LumaColorFilter ||\n type === NodeType.SRGBToLinearGammaColorFilter ||\n type === NodeType.LinearToSRGBGammaColorFilter\n );\n};\n\nexport const isPathEffect = (type: NodeType) => {\n \"worklet\";\n return (\n type === NodeType.DiscretePathEffect ||\n type === NodeType.DashPathEffect ||\n type === NodeType.Path1DPathEffect ||\n type === NodeType.Path2DPathEffect ||\n type === NodeType.CornerPathEffect ||\n type === NodeType.SumPathEffect ||\n type === NodeType.Line2DPathEffect\n );\n};\n\nexport const isImageFilter = (type: NodeType) => {\n \"worklet\";\n return (\n type === NodeType.OffsetImageFilter ||\n type === NodeType.DisplacementMapImageFilter ||\n type === NodeType.BlurImageFilter ||\n type === NodeType.DropShadowImageFilter ||\n type === NodeType.MorphologyImageFilter ||\n type === NodeType.BlendImageFilter ||\n type === NodeType.RuntimeShaderImageFilter\n );\n};\n\nexport const isShader = (type: NodeType) => {\n \"worklet\";\n return (\n type === NodeType.Shader ||\n type === NodeType.ImageShader ||\n type === NodeType.ColorShader ||\n type === NodeType.Turbulence ||\n type === NodeType.FractalNoise ||\n type === NodeType.LinearGradient ||\n type === NodeType.RadialGradient ||\n type === NodeType.SweepGradient ||\n type === NodeType.TwoPointConicalGradient\n );\n};\n\nexport const sortNodeChildren = (parent: Node) => {\n \"worklet\";\n const maskFilters: Node[] = [];\n const colorFilters: Node[] = [];\n const shaders: Node[] = [];\n const imageFilters: Node[] = [];\n const pathEffects: Node[] = [];\n const drawings: Node[] = [];\n const paints: Node[] = [];\n parent.children.forEach((node) => {\n if (isColorFilter(node.type)) {\n colorFilters.push(node);\n } else if (node.type === NodeType.BlurMaskFilter) {\n maskFilters.push(node);\n } else if (isPathEffect(node.type)) {\n pathEffects.push(node);\n } else if (isImageFilter(node.type)) {\n imageFilters.push(node);\n } else if (isShader(node.type)) {\n shaders.push(node);\n } else if (node.type === NodeType.Paint) {\n paints.push(node);\n } else if (node.type === NodeType.Blend) {\n if (node.children[0] && isImageFilter(node.children[0].type)) {\n node.type = NodeType.BlendImageFilter;\n imageFilters.push(node);\n } else {\n node.type = NodeType.Blend;\n shaders.push(node);\n }\n } else {\n drawings.push(node);\n }\n });\n return {\n colorFilters,\n drawings,\n maskFilters,\n shaders,\n pathEffects,\n imageFilters,\n paints,\n };\n};\n"],"mappings":"AAAA,SAASA,QAAQ,QAAQ,cAAc;AAQvC,OAAO,MAAMC,aAAa,GAAIC,IAAc,IAAK;EAC/C,SAAS;;EACT,OACEA,IAAI,KAAKF,QAAQ,CAACG,gBAAgB,IAClCD,IAAI,KAAKF,QAAQ,CAACI,iBAAiB,IACnCF,IAAI,KAAKF,QAAQ,CAACK,eAAe,IACjCH,IAAI,KAAKF,QAAQ,CAACM,eAAe,IACjCJ,IAAI,KAAKF,QAAQ,CAACO,4BAA4B,IAC9CL,IAAI,KAAKF,QAAQ,CAACQ,4BAA4B;AAElD,CAAC;AAED,OAAO,MAAMC,YAAY,GAAIP,IAAc,IAAK;EAC9C,SAAS;;EACT,OACEA,IAAI,KAAKF,QAAQ,CAACU,kBAAkB,IACpCR,IAAI,KAAKF,QAAQ,CAACW,cAAc,IAChCT,IAAI,KAAKF,QAAQ,CAACY,gBAAgB,IAClCV,IAAI,KAAKF,QAAQ,CAACa,gBAAgB,IAClCX,IAAI,KAAKF,QAAQ,CAACc,gBAAgB,IAClCZ,IAAI,KAAKF,QAAQ,CAACe,aAAa,IAC/Bb,IAAI,KAAKF,QAAQ,CAACgB,gBAAgB;AAEtC,CAAC;AAED,OAAO,MAAMC,aAAa,GAAIf,IAAc,IAAK;EAC/C,SAAS;;EACT,OACEA,IAAI,KAAKF,QAAQ,CAACkB,
|
1
|
+
{"version":3,"names":["NodeType","isColorFilter","type","BlendColorFilter","MatrixColorFilter","LerpColorFilter","LumaColorFilter","SRGBToLinearGammaColorFilter","LinearToSRGBGammaColorFilter","isPathEffect","DiscretePathEffect","DashPathEffect","Path1DPathEffect","Path2DPathEffect","CornerPathEffect","SumPathEffect","Line2DPathEffect","isImageFilter","ImageFilter","OffsetImageFilter","DisplacementMapImageFilter","BlurImageFilter","DropShadowImageFilter","MorphologyImageFilter","BlendImageFilter","RuntimeShaderImageFilter","isShader","Shader","ImageShader","ColorShader","Turbulence","FractalNoise","LinearGradient","RadialGradient","SweepGradient","TwoPointConicalGradient","sortNodeChildren","parent","maskFilters","colorFilters","shaders","imageFilters","pathEffects","drawings","paints","children","forEach","node","push","BlurMaskFilter","Paint","Blend"],"sources":["Node.ts"],"sourcesContent":["import { NodeType } from \"../dom/types\";\n\nexport interface Node<Props = unknown> {\n type: NodeType;\n props: Props;\n children: Node[];\n}\n\nexport const isColorFilter = (type: NodeType) => {\n \"worklet\";\n return (\n type === NodeType.BlendColorFilter ||\n type === NodeType.MatrixColorFilter ||\n type === NodeType.LerpColorFilter ||\n type === NodeType.LumaColorFilter ||\n type === NodeType.SRGBToLinearGammaColorFilter ||\n type === NodeType.LinearToSRGBGammaColorFilter\n );\n};\n\nexport const isPathEffect = (type: NodeType) => {\n \"worklet\";\n return (\n type === NodeType.DiscretePathEffect ||\n type === NodeType.DashPathEffect ||\n type === NodeType.Path1DPathEffect ||\n type === NodeType.Path2DPathEffect ||\n type === NodeType.CornerPathEffect ||\n type === NodeType.SumPathEffect ||\n type === NodeType.Line2DPathEffect\n );\n};\n\nexport const isImageFilter = (type: NodeType) => {\n \"worklet\";\n return (\n type === NodeType.ImageFilter ||\n type === NodeType.OffsetImageFilter ||\n type === NodeType.DisplacementMapImageFilter ||\n type === NodeType.BlurImageFilter ||\n type === NodeType.DropShadowImageFilter ||\n type === NodeType.MorphologyImageFilter ||\n type === NodeType.BlendImageFilter ||\n type === NodeType.RuntimeShaderImageFilter\n );\n};\n\nexport const isShader = (type: NodeType) => {\n \"worklet\";\n return (\n type === NodeType.Shader ||\n type === NodeType.ImageShader ||\n type === NodeType.ColorShader ||\n type === NodeType.Turbulence ||\n type === NodeType.FractalNoise ||\n type === NodeType.LinearGradient ||\n type === NodeType.RadialGradient ||\n type === NodeType.SweepGradient ||\n type === NodeType.TwoPointConicalGradient\n );\n};\n\nexport const sortNodeChildren = (parent: Node) => {\n \"worklet\";\n const maskFilters: Node[] = [];\n const colorFilters: Node[] = [];\n const shaders: Node[] = [];\n const imageFilters: Node[] = [];\n const pathEffects: Node[] = [];\n const drawings: Node[] = [];\n const paints: Node[] = [];\n parent.children.forEach((node) => {\n if (isColorFilter(node.type)) {\n colorFilters.push(node);\n } else if (node.type === NodeType.BlurMaskFilter) {\n maskFilters.push(node);\n } else if (isPathEffect(node.type)) {\n pathEffects.push(node);\n } else if (isImageFilter(node.type)) {\n imageFilters.push(node);\n } else if (isShader(node.type)) {\n shaders.push(node);\n } else if (node.type === NodeType.Paint) {\n paints.push(node);\n } else if (node.type === NodeType.Blend) {\n if (node.children[0] && isImageFilter(node.children[0].type)) {\n node.type = NodeType.BlendImageFilter;\n imageFilters.push(node);\n } else {\n node.type = NodeType.Blend;\n shaders.push(node);\n }\n } else {\n drawings.push(node);\n }\n });\n return {\n colorFilters,\n drawings,\n maskFilters,\n shaders,\n pathEffects,\n imageFilters,\n paints,\n };\n};\n"],"mappings":"AAAA,SAASA,QAAQ,QAAQ,cAAc;AAQvC,OAAO,MAAMC,aAAa,GAAIC,IAAc,IAAK;EAC/C,SAAS;;EACT,OACEA,IAAI,KA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IAAIA,IAAI,CAAC7C,IAAI,KAAKF,QAAQ,CAACkD,KAAK,EAAE;MACvCN,MAAM,CAACI,IAAI,CAACD,IAAI,CAAC;IACnB,CAAC,MAAM,IAAIA,IAAI,CAAC7C,IAAI,KAAKF,QAAQ,CAACmD,KAAK,EAAE;MACvC,IAAIJ,IAAI,CAACF,QAAQ,CAAC,CAAC,CAAC,IAAI5B,aAAa,CAAC8B,IAAI,CAACF,QAAQ,CAAC,CAAC,CAAC,CAAC3C,IAAI,CAAC,EAAE;QAC5D6C,IAAI,CAAC7C,IAAI,GAAGF,QAAQ,CAACwB,gBAAgB;QACrCiB,YAAY,CAACO,IAAI,CAACD,IAAI,CAAC;MACzB,CAAC,MAAM;QACLA,IAAI,CAAC7C,IAAI,GAAGF,QAAQ,CAACmD,KAAK;QAC1BX,OAAO,CAACQ,IAAI,CAACD,IAAI,CAAC;MACpB;IACF,CAAC,MAAM;MACLJ,QAAQ,CAACK,IAAI,CAACD,IAAI,CAAC;IACrB;EACF,CAAC,CAAC;EACF,OAAO;IACLR,YAAY;IACZI,QAAQ;IACRL,WAAW;IACXE,OAAO;IACPE,WAAW;IACXD,YAAY;IACZG;EACF,CAAC;AACH,CAAC","ignoreList":[]}
|
@@ -119,6 +119,14 @@ const declareRuntimeShaderImageFilter = (ctx, props) => {
|
|
119
119
|
const imgf = ctx.Skia.ImageFilter.MakeRuntimeShader(rtb, null, null);
|
120
120
|
ctx.imageFilters.push(imgf);
|
121
121
|
};
|
122
|
+
const declareImageFilter = (ctx, props) => {
|
123
|
+
"worklet";
|
124
|
+
|
125
|
+
const {
|
126
|
+
imageFilter
|
127
|
+
} = props;
|
128
|
+
ctx.imageFilters.push(imageFilter);
|
129
|
+
};
|
122
130
|
export const composeImageFilters = ctx => {
|
123
131
|
"worklet";
|
124
132
|
|
@@ -152,7 +160,9 @@ const isImageFilter = (command, type) => {
|
|
152
160
|
export const pushImageFilter = (ctx, command) => {
|
153
161
|
"worklet";
|
154
162
|
|
155
|
-
if (isImageFilter(command, NodeType.
|
163
|
+
if (isImageFilter(command, NodeType.ImageFilter)) {
|
164
|
+
declareImageFilter(ctx, command.props);
|
165
|
+
} else if (isImageFilter(command, NodeType.BlurImageFilter)) {
|
156
166
|
declareBlurImageFilter(ctx, command.props);
|
157
167
|
} else if (isImageFilter(command, NodeType.MorphologyImageFilter)) {
|
158
168
|
declareMorphologyImageFilter(ctx, command.props);
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["enumKey","processColor","processRadius","NodeType","BlendMode","BlurStyle","ColorChannel","processUniforms","TileMode","composeDeclarations","CommandType","MorphologyOperator","Black","Float32Array","of","MakeInnerShadow","Skia","shadowOnly","dx","dy","sigmaX","sigmaY","color","input","sourceGraphic","ImageFilter","MakeColorFilter","ColorFilter","MakeBlend","Dst","sourceAlpha","SrcIn","f1","SrcOut","f2","MakeOffset","f3","MakeBlur","Decal","f4","MakeCompose","SrcOver","declareBlurImageFilter","ctx","props","mode","blur","sigma","imgf","x","y","imageFilters","push","declareMorphologyImageFilter","operator","r","radius","Erode","MakeErode","MakeDilate","declareOffsetImageFilter","declareDropShadowImageFilter","cl","inner","factory","bind","MakeDropShadowOnly","MakeDropShadow","declareBlendImageFilter","blend","splice","length","composer","declareDisplacementMapImageFilter","channelX","channelY","scale","shader","shaders","pop","Error","map","MakeShader","MakeDisplacementMap","declareRuntimeShaderImageFilter","source","uniforms","rtb","RuntimeShaderBuilder","MakeRuntimeShader","composeImageFilters","outer","setBlurMaskFilter","style","respectCTM","mf","MaskFilter","paint","setMaskFilter","isPushImageFilter","command","type","PushImageFilter","isImageFilter","imageFilterType","pushImageFilter","BlurImageFilter","MorphologyImageFilter","BlendImageFilter","DisplacementMapImageFilter","DropShadowImageFilter","OffsetImageFilter","RuntimeShaderImageFilter"],"sources":["ImageFilters.ts"],"sourcesContent":["import { enumKey, processColor, processRadius } from \"../../../dom/nodes\";\nimport type {\n BlendImageFilterProps,\n BlurImageFilterProps,\n BlurMaskFilterProps,\n DisplacementMapImageFilterProps,\n DropShadowImageFilterProps,\n MorphologyImageFilterProps,\n OffsetImageFilterProps,\n RuntimeShaderImageFilterProps,\n} from \"../../../dom/types\";\nimport { NodeType } from \"../../../dom/types\";\nimport type { SkColor, SkImageFilter, Skia } from \"../../../skia/types\";\nimport {\n BlendMode,\n BlurStyle,\n ColorChannel,\n processUniforms,\n TileMode,\n} from \"../../../skia/types\";\nimport { composeDeclarations } from \"../../utils\";\nimport type { Command } from \"../Core\";\nimport { CommandType } from \"../Core\";\nimport type { DrawingContext } from \"../DrawingContext\";\n\nexport enum MorphologyOperator {\n Erode,\n Dilate,\n}\n\nconst Black = Float32Array.of(0, 0, 0, 1);\n\nconst MakeInnerShadow = (\n Skia: Skia,\n shadowOnly: boolean | undefined,\n dx: number,\n dy: number,\n sigmaX: number,\n sigmaY: number,\n color: SkColor,\n input: SkImageFilter | null\n) => {\n \"worklet\";\n const sourceGraphic = Skia.ImageFilter.MakeColorFilter(\n Skia.ColorFilter.MakeBlend(Black, BlendMode.Dst),\n null\n );\n const sourceAlpha = Skia.ImageFilter.MakeColorFilter(\n Skia.ColorFilter.MakeBlend(Black, BlendMode.SrcIn),\n null\n );\n const f1 = Skia.ImageFilter.MakeColorFilter(\n Skia.ColorFilter.MakeBlend(color, BlendMode.SrcOut),\n null\n );\n const f2 = Skia.ImageFilter.MakeOffset(dx, dy, f1);\n const f3 = Skia.ImageFilter.MakeBlur(sigmaX, sigmaY, TileMode.Decal, f2);\n const f4 = Skia.ImageFilter.MakeBlend(BlendMode.SrcIn, sourceAlpha, f3);\n if (shadowOnly) {\n return f4;\n }\n return Skia.ImageFilter.MakeCompose(\n input,\n Skia.ImageFilter.MakeBlend(BlendMode.SrcOver, sourceGraphic, f4)\n );\n};\n\nconst declareBlurImageFilter = (\n ctx: DrawingContext,\n props: BlurImageFilterProps\n) => {\n \"worklet\";\n const { mode, blur } = props;\n const sigma = processRadius(ctx.Skia, blur);\n const imgf = ctx.Skia.ImageFilter.MakeBlur(\n sigma.x,\n sigma.y,\n TileMode[enumKey(mode)],\n null\n );\n ctx.imageFilters.push(imgf);\n};\n\nconst declareMorphologyImageFilter = (\n ctx: DrawingContext,\n props: MorphologyImageFilterProps\n) => {\n \"worklet\";\n const { operator } = props;\n const r = processRadius(ctx.Skia, props.radius);\n let imgf;\n if (MorphologyOperator[enumKey(operator)] === MorphologyOperator.Erode) {\n imgf = ctx.Skia.ImageFilter.MakeErode(r.x, r.y, null);\n } else {\n imgf = ctx.Skia.ImageFilter.MakeDilate(r.x, r.y, null);\n }\n ctx.imageFilters.push(imgf);\n};\n\nconst declareOffsetImageFilter = (\n ctx: DrawingContext,\n props: OffsetImageFilterProps\n) => {\n \"worklet\";\n const { x, y } = props;\n const imgf = ctx.Skia.ImageFilter.MakeOffset(x, y, null);\n ctx.imageFilters.push(imgf);\n};\n\nconst declareDropShadowImageFilter = (\n ctx: DrawingContext,\n props: DropShadowImageFilterProps\n) => {\n \"worklet\";\n const { dx, dy, blur, shadowOnly, color: cl, inner } = props;\n const color = processColor(ctx.Skia, cl);\n let factory;\n if (inner) {\n factory = MakeInnerShadow.bind(null, ctx.Skia, shadowOnly);\n } else {\n factory = shadowOnly\n ? ctx.Skia.ImageFilter.MakeDropShadowOnly.bind(ctx.Skia.ImageFilter)\n : ctx.Skia.ImageFilter.MakeDropShadow.bind(ctx.Skia.ImageFilter);\n }\n const imgf = factory(dx, dy, blur, blur, color, null);\n ctx.imageFilters.push(imgf);\n};\n\nconst declareBlendImageFilter = (\n ctx: DrawingContext,\n props: BlendImageFilterProps\n) => {\n \"worklet\";\n const blend = BlendMode[enumKey(props.mode)];\n // Blend ImageFilters\n const imageFilters = ctx.imageFilters.splice(0, ctx.imageFilters.length);\n const composer = ctx.Skia.ImageFilter.MakeBlend.bind(\n ctx.Skia.ImageFilter,\n blend\n );\n ctx.imageFilters.push(composeDeclarations(imageFilters, composer));\n};\n\nconst declareDisplacementMapImageFilter = (\n ctx: DrawingContext,\n props: DisplacementMapImageFilterProps\n) => {\n \"worklet\";\n const { channelX, channelY, scale } = props;\n const shader = ctx.shaders.pop();\n if (!shader) {\n throw new Error(\"DisplacementMap expects a shader as child\");\n }\n const map = ctx.Skia.ImageFilter.MakeShader(shader);\n const imgf = ctx.Skia.ImageFilter.MakeDisplacementMap(\n ColorChannel[enumKey(channelX)],\n ColorChannel[enumKey(channelY)],\n scale,\n map,\n null\n );\n ctx.imageFilters.push(imgf);\n};\n\nconst declareRuntimeShaderImageFilter = (\n ctx: DrawingContext,\n props: RuntimeShaderImageFilterProps\n) => {\n \"worklet\";\n const { source, uniforms } = props;\n const rtb = ctx.Skia.RuntimeShaderBuilder(source);\n if (uniforms) {\n processUniforms(source, uniforms, rtb);\n }\n const imgf = ctx.Skia.ImageFilter.MakeRuntimeShader(rtb, null, null);\n ctx.imageFilters.push(imgf);\n};\n\nexport const composeImageFilters = (ctx: DrawingContext) => {\n \"worklet\";\n if (ctx.imageFilters.length > 1) {\n const outer = ctx.imageFilters.pop()!;\n const inner = ctx.imageFilters.pop()!;\n ctx.imageFilters.push(ctx.Skia.ImageFilter.MakeCompose(outer, inner));\n }\n};\n\nexport const setBlurMaskFilter = (\n ctx: DrawingContext,\n props: BlurMaskFilterProps\n) => {\n \"worklet\";\n const { blur, style, respectCTM } = props;\n const mf = ctx.Skia.MaskFilter.MakeBlur(\n BlurStyle[enumKey(style)],\n blur,\n respectCTM\n );\n ctx.paint.setMaskFilter(mf);\n};\n\nexport const isPushImageFilter = (\n command: Command\n): command is Command<CommandType.PushImageFilter> => {\n \"worklet\";\n return command.type === CommandType.PushImageFilter;\n};\n\ntype Props = {\n [NodeType.OffsetImageFilter]: OffsetImageFilterProps;\n [NodeType.DisplacementMapImageFilter]: DisplacementMapImageFilterProps;\n [NodeType.BlurImageFilter]: BlurImageFilterProps;\n [NodeType.DropShadowImageFilter]: DropShadowImageFilterProps;\n [NodeType.MorphologyImageFilter]: MorphologyImageFilterProps;\n [NodeType.BlendImageFilter]: BlendImageFilterProps;\n [NodeType.RuntimeShaderImageFilter]: RuntimeShaderImageFilterProps;\n};\n\ninterface PushImageFilter<T extends keyof Props>\n extends Command<CommandType.PushImageFilter> {\n imageFilterType: T;\n props: Props[T];\n}\n\nconst isImageFilter = <T extends keyof Props>(\n command: Command<CommandType.PushImageFilter>,\n type: T\n): command is PushImageFilter<T> => {\n \"worklet\";\n return command.imageFilterType === type;\n};\n\nexport const pushImageFilter = (\n ctx: DrawingContext,\n command: Command<CommandType.PushImageFilter>\n) => {\n \"worklet\";\n if (isImageFilter(command, NodeType.BlurImageFilter)) {\n declareBlurImageFilter(ctx, command.props);\n } else if (isImageFilter(command, NodeType.MorphologyImageFilter)) {\n declareMorphologyImageFilter(ctx, command.props);\n } else if (isImageFilter(command, NodeType.BlendImageFilter)) {\n declareBlendImageFilter(ctx, command.props);\n } else if (isImageFilter(command, NodeType.DisplacementMapImageFilter)) {\n declareDisplacementMapImageFilter(ctx, command.props);\n } else if (isImageFilter(command, NodeType.DropShadowImageFilter)) {\n declareDropShadowImageFilter(ctx, command.props);\n } else if (isImageFilter(command, NodeType.OffsetImageFilter)) {\n declareOffsetImageFilter(ctx, command.props);\n } else if (isImageFilter(command, NodeType.RuntimeShaderImageFilter)) {\n declareRuntimeShaderImageFilter(ctx, command.props);\n } else {\n throw new Error(\"Invalid image filter type: \" + command.imageFilterType);\n }\n};\n"],"mappings":"AAAA,SAASA,OAAO,EAAEC,YAAY,EAAEC,aAAa,QAAQ,oBAAoB;AAWzE,SAASC,QAAQ,QAAQ,oBAAoB;AAE7C,SACEC,SAAS,EACTC,SAAS,EACTC,YAAY,EACZC,eAAe,EACfC,QAAQ,QACH,qBAAqB;AAC5B,SAASC,mBAAmB,QAAQ,aAAa;AAEjD,SAASC,WAAW,QAAQ,SAAS;AAGrC,WAAYC,kBAAkB,0BAAlBA,kBAAkB;EAAlBA,kBAAkB,CAAlBA,kBAAkB;EAAlBA,kBAAkB,CAAlBA,kBAAkB;EAAA,OAAlBA,kBAAkB;AAAA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C4G,iBAAiB,CAAC,EAAE;IAC7DnD,wBAAwB,CAACjB,GAAG,EAAEyD,OAAO,CAACxD,KAAK,CAAC;EAC9C,CAAC,MAAM,IAAI2D,aAAa,CAACH,OAAO,EAAEjG,QAAQ,CAAC6G,wBAAwB,CAAC,EAAE;IACpE5B,+BAA+B,CAACzC,GAAG,EAAEyD,OAAO,CAACxD,KAAK,CAAC;EACrD,CAAC,MAAM;IACL,MAAM,IAAIoC,KAAK,CAAC,6BAA6B,GAAGoB,OAAO,CAACI,eAAe,CAAC;EAC1E;AACF,CAAC","ignoreList":[]}
|
1
|
+
{"version":3,"names":["enumKey","processColor","processRadius","NodeType","BlendMode","BlurStyle","ColorChannel","processUniforms","TileMode","composeDeclarations","CommandType","MorphologyOperator","Black","Float32Array","of","MakeInnerShadow","Skia","shadowOnly","dx","dy","sigmaX","sigmaY","color","input","sourceGraphic","ImageFilter","MakeColorFilter","ColorFilter","MakeBlend","Dst","sourceAlpha","SrcIn","f1","SrcOut","f2","MakeOffset","f3","MakeBlur","Decal","f4","MakeCompose","SrcOver","declareBlurImageFilter","ctx","props","mode","blur","sigma","imgf","x","y","imageFilters","push","declareMorphologyImageFilter","operator","r","radius","Erode","MakeErode","MakeDilate","declareOffsetImageFilter","declareDropShadowImageFilter","cl","inner","factory","bind","MakeDropShadowOnly","MakeDropShadow","declareBlendImageFilter","blend","splice","length","composer","declareDisplacementMapImageFilter","channelX","channelY","scale","shader","shaders","pop","Error","map","MakeShader","MakeDisplacementMap","declareRuntimeShaderImageFilter","source","uniforms","rtb","RuntimeShaderBuilder","MakeRuntimeShader","declareImageFilter","imageFilter","composeImageFilters","outer","setBlurMaskFilter","style","respectCTM","mf","MaskFilter","paint","setMaskFilter","isPushImageFilter","command","type","PushImageFilter","isImageFilter","imageFilterType","pushImageFilter","BlurImageFilter","MorphologyImageFilter","BlendImageFilter","DisplacementMapImageFilter","DropShadowImageFilter","OffsetImageFilter","RuntimeShaderImageFilter"],"sources":["ImageFilters.ts"],"sourcesContent":["import { enumKey, processColor, processRadius } from \"../../../dom/nodes\";\nimport type {\n BlendImageFilterProps,\n BlurImageFilterProps,\n BlurMaskFilterProps,\n DisplacementMapImageFilterProps,\n DropShadowImageFilterProps,\n ImageFilterProps,\n MorphologyImageFilterProps,\n OffsetImageFilterProps,\n RuntimeShaderImageFilterProps,\n} from \"../../../dom/types\";\nimport { NodeType } from \"../../../dom/types\";\nimport type { SkColor, SkImageFilter, Skia } from \"../../../skia/types\";\nimport {\n BlendMode,\n BlurStyle,\n ColorChannel,\n processUniforms,\n TileMode,\n} from \"../../../skia/types\";\nimport { composeDeclarations } from \"../../utils\";\nimport type { Command } from \"../Core\";\nimport { CommandType } from \"../Core\";\nimport type { DrawingContext } from \"../DrawingContext\";\n\nexport enum MorphologyOperator {\n Erode,\n Dilate,\n}\n\nconst Black = Float32Array.of(0, 0, 0, 1);\n\nconst MakeInnerShadow = (\n Skia: Skia,\n shadowOnly: boolean | undefined,\n dx: number,\n dy: number,\n sigmaX: number,\n sigmaY: number,\n color: SkColor,\n input: SkImageFilter | null\n) => {\n \"worklet\";\n const sourceGraphic = Skia.ImageFilter.MakeColorFilter(\n Skia.ColorFilter.MakeBlend(Black, BlendMode.Dst),\n null\n );\n const sourceAlpha = Skia.ImageFilter.MakeColorFilter(\n Skia.ColorFilter.MakeBlend(Black, BlendMode.SrcIn),\n null\n );\n const f1 = Skia.ImageFilter.MakeColorFilter(\n Skia.ColorFilter.MakeBlend(color, BlendMode.SrcOut),\n null\n );\n const f2 = Skia.ImageFilter.MakeOffset(dx, dy, f1);\n const f3 = Skia.ImageFilter.MakeBlur(sigmaX, sigmaY, TileMode.Decal, f2);\n const f4 = Skia.ImageFilter.MakeBlend(BlendMode.SrcIn, sourceAlpha, f3);\n if (shadowOnly) {\n return f4;\n }\n return Skia.ImageFilter.MakeCompose(\n input,\n Skia.ImageFilter.MakeBlend(BlendMode.SrcOver, sourceGraphic, f4)\n );\n};\n\nconst declareBlurImageFilter = (\n ctx: DrawingContext,\n props: BlurImageFilterProps\n) => {\n \"worklet\";\n const { mode, blur } = props;\n const sigma = processRadius(ctx.Skia, blur);\n const imgf = ctx.Skia.ImageFilter.MakeBlur(\n sigma.x,\n sigma.y,\n TileMode[enumKey(mode)],\n null\n );\n ctx.imageFilters.push(imgf);\n};\n\nconst declareMorphologyImageFilter = (\n ctx: DrawingContext,\n props: MorphologyImageFilterProps\n) => {\n \"worklet\";\n const { operator } = props;\n const r = processRadius(ctx.Skia, props.radius);\n let imgf;\n if (MorphologyOperator[enumKey(operator)] === MorphologyOperator.Erode) {\n imgf = ctx.Skia.ImageFilter.MakeErode(r.x, r.y, null);\n } else {\n imgf = ctx.Skia.ImageFilter.MakeDilate(r.x, r.y, null);\n }\n ctx.imageFilters.push(imgf);\n};\n\nconst declareOffsetImageFilter = (\n ctx: DrawingContext,\n props: OffsetImageFilterProps\n) => {\n \"worklet\";\n const { x, y } = props;\n const imgf = ctx.Skia.ImageFilter.MakeOffset(x, y, null);\n ctx.imageFilters.push(imgf);\n};\n\nconst declareDropShadowImageFilter = (\n ctx: DrawingContext,\n props: DropShadowImageFilterProps\n) => {\n \"worklet\";\n const { dx, dy, blur, shadowOnly, color: cl, inner } = props;\n const color = processColor(ctx.Skia, cl);\n let factory;\n if (inner) {\n factory = MakeInnerShadow.bind(null, ctx.Skia, shadowOnly);\n } else {\n factory = shadowOnly\n ? ctx.Skia.ImageFilter.MakeDropShadowOnly.bind(ctx.Skia.ImageFilter)\n : ctx.Skia.ImageFilter.MakeDropShadow.bind(ctx.Skia.ImageFilter);\n }\n const imgf = factory(dx, dy, blur, blur, color, null);\n ctx.imageFilters.push(imgf);\n};\n\nconst declareBlendImageFilter = (\n ctx: DrawingContext,\n props: BlendImageFilterProps\n) => {\n \"worklet\";\n const blend = BlendMode[enumKey(props.mode)];\n // Blend ImageFilters\n const imageFilters = ctx.imageFilters.splice(0, ctx.imageFilters.length);\n const composer = ctx.Skia.ImageFilter.MakeBlend.bind(\n ctx.Skia.ImageFilter,\n blend\n );\n ctx.imageFilters.push(composeDeclarations(imageFilters, composer));\n};\n\nconst declareDisplacementMapImageFilter = (\n ctx: DrawingContext,\n props: DisplacementMapImageFilterProps\n) => {\n \"worklet\";\n const { channelX, channelY, scale } = props;\n const shader = ctx.shaders.pop();\n if (!shader) {\n throw new Error(\"DisplacementMap expects a shader as child\");\n }\n const map = ctx.Skia.ImageFilter.MakeShader(shader);\n const imgf = ctx.Skia.ImageFilter.MakeDisplacementMap(\n ColorChannel[enumKey(channelX)],\n ColorChannel[enumKey(channelY)],\n scale,\n map,\n null\n );\n ctx.imageFilters.push(imgf);\n};\n\nconst declareRuntimeShaderImageFilter = (\n ctx: DrawingContext,\n props: RuntimeShaderImageFilterProps\n) => {\n \"worklet\";\n const { source, uniforms } = props;\n const rtb = ctx.Skia.RuntimeShaderBuilder(source);\n if (uniforms) {\n processUniforms(source, uniforms, rtb);\n }\n const imgf = ctx.Skia.ImageFilter.MakeRuntimeShader(rtb, null, null);\n ctx.imageFilters.push(imgf);\n};\n\nconst declareImageFilter = (\n ctx: DrawingContext,\n props: ImageFilterProps\n) => {\n \"worklet\";\n const { imageFilter } = props;\n ctx.imageFilters.push(imageFilter);\n};\n\nexport const composeImageFilters = (ctx: DrawingContext) => {\n \"worklet\";\n if (ctx.imageFilters.length > 1) {\n const outer = ctx.imageFilters.pop()!;\n const inner = ctx.imageFilters.pop()!;\n ctx.imageFilters.push(ctx.Skia.ImageFilter.MakeCompose(outer, inner));\n }\n};\n\nexport const setBlurMaskFilter = (\n ctx: DrawingContext,\n props: BlurMaskFilterProps\n) => {\n \"worklet\";\n const { blur, style, respectCTM } = props;\n const mf = ctx.Skia.MaskFilter.MakeBlur(\n BlurStyle[enumKey(style)],\n blur,\n respectCTM\n );\n ctx.paint.setMaskFilter(mf);\n};\n\nexport const isPushImageFilter = (\n command: Command\n): command is Command<CommandType.PushImageFilter> => {\n \"worklet\";\n return command.type === CommandType.PushImageFilter;\n};\n\ntype Props = {\n [NodeType.ImageFilter]: ImageFilterProps;\n [NodeType.OffsetImageFilter]: OffsetImageFilterProps;\n [NodeType.DisplacementMapImageFilter]: DisplacementMapImageFilterProps;\n [NodeType.BlurImageFilter]: BlurImageFilterProps;\n [NodeType.DropShadowImageFilter]: DropShadowImageFilterProps;\n [NodeType.MorphologyImageFilter]: MorphologyImageFilterProps;\n [NodeType.BlendImageFilter]: BlendImageFilterProps;\n [NodeType.RuntimeShaderImageFilter]: RuntimeShaderImageFilterProps;\n};\n\ninterface PushImageFilter<T extends keyof Props>\n extends Command<CommandType.PushImageFilter> {\n imageFilterType: T;\n props: Props[T];\n}\n\nconst isImageFilter = <T extends keyof Props>(\n command: Command<CommandType.PushImageFilter>,\n type: T\n): command is PushImageFilter<T> => {\n \"worklet\";\n return command.imageFilterType === type;\n};\n\nexport const pushImageFilter = (\n ctx: DrawingContext,\n command: Command<CommandType.PushImageFilter>\n) => {\n \"worklet\";\n if (isImageFilter(command, NodeType.ImageFilter)) {\n declareImageFilter(ctx, command.props);\n } else if (isImageFilter(command, NodeType.BlurImageFilter)) {\n declareBlurImageFilter(ctx, command.props);\n } else if (isImageFilter(command, NodeType.MorphologyImageFilter)) {\n declareMorphologyImageFilter(ctx, command.props);\n } else if (isImageFilter(command, NodeType.BlendImageFilter)) {\n declareBlendImageFilter(ctx, command.props);\n } else if (isImageFilter(command, NodeType.DisplacementMapImageFilter)) {\n declareDisplacementMapImageFilter(ctx, command.props);\n } else if (isImageFilter(command, NodeType.DropShadowImageFilter)) {\n declareDropShadowImageFilter(ctx, command.props);\n } else if (isImageFilter(command, NodeType.OffsetImageFilter)) {\n declareOffsetImageFilter(ctx, command.props);\n } else if (isImageFilter(command, NodeType.RuntimeShaderImageFilter)) {\n declareRuntimeShaderImageFilter(ctx, command.props);\n } else {\n throw new Error(\"Invalid image filter type: \" + command.imageFilterType);\n }\n};\n"],"mappings":"AAAA,SAASA,OAAO,EAAEC,YAAY,EAAEC,aAAa,QAAQ,oBAAoB;AAYzE,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AAM,IAAI6D,aAAa,CAACH,OAAO,EAAEnG,QAAQ,CAAC0G,qBAAqB,CAAC,EAAE;IACjExD,4BAA4B,CAACV,GAAG,EAAE2D,OAAO,CAAC1D,KAAK,CAAC;EAClD,CAAC,MAAM,IAAI6D,aAAa,CAACH,OAAO,EAAEnG,QAAQ,CAAC2G,gBAAgB,CAAC,EAAE;IAC5D1C,uBAAuB,CAACzB,GAAG,EAAE2D,OAAO,CAAC1D,KAAK,CAAC;EAC7C,CAAC,MAAM,IAAI6D,aAAa,CAACH,OAAO,EAAEnG,QAAQ,CAAC4G,0BAA0B,CAAC,EAAE;IACtEtC,iCAAiC,CAAC9B,GAAG,EAAE2D,OAAO,CAAC1D,KAAK,CAAC;EACvD,CAAC,MAAM,IAAI6D,aAAa,CAACH,OAAO,EAAEnG,QAAQ,CAAC6G,qBAAqB,CAAC,EAAE;IACjEnD,4BAA4B,CAAClB,GAAG,EAAE2D,OAAO,CAAC1D,KAAK,CAAC;EAClD,CAAC,MAAM,IAAI6D,aAAa,CAACH,OAAO,EAAEnG,QAAQ,CAAC8G,iBAAiB,CAAC,EAAE;IAC7DrD,wBAAwB,CAACjB,GAAG,EAAE2D,OAAO,CAAC1D,KAAK,CAAC;EAC9C,CAAC,MAAM,IAAI6D,aAAa,CAACH,OAAO,EAAEnG,QAAQ,CAAC+G,wBAAwB,CAAC,EAAE;IACpE9B,+BAA+B,CAACzC,GAAG,EAAE2D,OAAO,CAAC1D,KAAK,CAAC;EACrD,CAAC,MAAM;IACL,MAAM,IAAIoC,KAAK,CAAC,6BAA6B,GAAGsB,OAAO,CAACI,eAAe,CAAC;EAC1E;AACF,CAAC","ignoreList":[]}
|
@@ -506,5 +506,6 @@ export function Mock(CanvasKit: any): {
|
|
506
506
|
Paint: (props: any) => import("react").DOMElement<any, Element>;
|
507
507
|
Blend: (props: any) => import("react").DOMElement<any, Element>;
|
508
508
|
Skottie: (props: any) => import("react").DOMElement<any, Element>;
|
509
|
+
ImageFilter: (props: any) => import("react").DOMElement<any, Element>;
|
509
510
|
Paragraph: (props: any) => import("react").DOMElement<any, Element>;
|
510
511
|
};
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import type { FillType, SkImage, StrokeOpts, Vector, Color, SkPoint, BlendMode, PointMode, VertexMode, SkFont, SkRRect, SkTextBlob, SkPicture, SkSVG, SkPaint, SkRect, SkRSXform, SkColor, SamplingOptions, SkSkottieAnimation } from "../../skia/types";
|
1
|
+
import type { FillType, SkImage, StrokeOpts, Vector, Color, SkPoint, BlendMode, PointMode, VertexMode, SkFont, SkRRect, SkTextBlob, SkPicture, SkSVG, SkPaint, SkRect, SkRSXform, SkColor, SamplingOptions, SkSkottieAnimation, SkImageFilter } from "../../skia/types";
|
2
2
|
import type { CircleDef, Fit, GroupProps, PathDef, RectDef, RRectDef, SkEnum } from "./Common";
|
3
3
|
export interface DrawingNodeProps extends GroupProps {
|
4
4
|
paint?: SkPaint;
|
@@ -115,3 +115,6 @@ export interface BoxShadowProps {
|
|
115
115
|
color?: Color;
|
116
116
|
inner?: boolean;
|
117
117
|
}
|
118
|
+
export interface ImageFilterProps extends GroupProps {
|
119
|
+
imageFilter: SkImageFilter;
|
120
|
+
}
|
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import type { FractalNoiseProps, CircleProps, DrawingNodeProps, ImageProps, PaintProps, PathProps, LineProps, OvalProps, DiffRectProps, PointsProps, RectProps, RoundedRectProps, TextProps, VerticesProps, BlurMaskFilterProps, BlendImageFilterProps, BlurImageFilterProps, DisplacementMapImageFilterProps, DropShadowImageFilterProps, OffsetImageFilterProps, RuntimeShaderImageFilterProps, MatrixColorFilterProps, ShaderProps, ImageShaderProps, LinearGradientProps, GroupProps, PatchProps, BlendColorFilterProps, DashPathEffectProps, DiscretePathEffectProps, CornerPathEffectProps, Line2DPathEffectProps, Path1DPathEffectProps, Path2DPathEffectProps, TextPathProps, TextBlobProps, GlyphsProps, TwoPointConicalGradientProps, TurbulenceProps, SweepGradientProps, RadialGradientProps, ColorProps, PictureProps, ImageSVGProps, LerpColorFilterProps, BoxProps, BoxShadowProps, ParagraphProps, AtlasProps, ChildrenProps, MorphologyImageFilterProps, BlendProps, SkottieProps } from "../dom/types";
|
1
|
+
import type { FractalNoiseProps, CircleProps, DrawingNodeProps, ImageProps, PaintProps, PathProps, LineProps, OvalProps, DiffRectProps, PointsProps, RectProps, RoundedRectProps, TextProps, VerticesProps, BlurMaskFilterProps, BlendImageFilterProps, BlurImageFilterProps, DisplacementMapImageFilterProps, DropShadowImageFilterProps, OffsetImageFilterProps, RuntimeShaderImageFilterProps, MatrixColorFilterProps, ShaderProps, ImageShaderProps, LinearGradientProps, GroupProps, PatchProps, BlendColorFilterProps, DashPathEffectProps, DiscretePathEffectProps, CornerPathEffectProps, Line2DPathEffectProps, Path1DPathEffectProps, Path2DPathEffectProps, TextPathProps, TextBlobProps, GlyphsProps, TwoPointConicalGradientProps, TurbulenceProps, SweepGradientProps, RadialGradientProps, ColorProps, PictureProps, ImageSVGProps, LerpColorFilterProps, BoxProps, BoxShadowProps, ParagraphProps, AtlasProps, ChildrenProps, MorphologyImageFilterProps, BlendProps, SkottieProps, ImageFilterProps } from "../dom/types";
|
2
2
|
import type { SkiaProps } from "../renderer";
|
3
3
|
declare module "react" {
|
4
4
|
namespace JSX {
|
@@ -27,6 +27,7 @@ declare module "react" {
|
|
27
27
|
skPicture: SkiaProps<PictureProps>;
|
28
28
|
skImageSVG: SkiaProps<ImageSVGProps>;
|
29
29
|
skBlurMaskFilter: SkiaProps<BlurMaskFilterProps>;
|
30
|
+
skImageFilter: SkiaProps<ImageFilterProps>;
|
30
31
|
skBlendImageFilter: SkiaProps<BlendImageFilterProps>;
|
31
32
|
skBlurImageFilter: SkiaProps<BlurImageFilterProps>;
|
32
33
|
skOffsetImageFilter: SkiaProps<OffsetImageFilterProps>;
|
@@ -6,7 +6,7 @@ export interface Node<Props = unknown> {
|
|
6
6
|
}
|
7
7
|
export declare const isColorFilter: (type: NodeType) => type is NodeType.MatrixColorFilter | NodeType.BlendColorFilter | NodeType.LinearToSRGBGammaColorFilter | NodeType.SRGBToLinearGammaColorFilter | NodeType.LumaColorFilter | NodeType.LerpColorFilter;
|
8
8
|
export declare const isPathEffect: (type: NodeType) => type is NodeType.DiscretePathEffect | NodeType.DashPathEffect | NodeType.Path1DPathEffect | NodeType.Path2DPathEffect | NodeType.CornerPathEffect | NodeType.SumPathEffect | NodeType.Line2DPathEffect;
|
9
|
-
export declare const isImageFilter: (type: NodeType) => type is NodeType.OffsetImageFilter | NodeType.DisplacementMapImageFilter | NodeType.BlurImageFilter | NodeType.DropShadowImageFilter | NodeType.MorphologyImageFilter | NodeType.BlendImageFilter | NodeType.RuntimeShaderImageFilter;
|
9
|
+
export declare const isImageFilter: (type: NodeType) => type is NodeType.OffsetImageFilter | NodeType.DisplacementMapImageFilter | NodeType.BlurImageFilter | NodeType.DropShadowImageFilter | NodeType.MorphologyImageFilter | NodeType.BlendImageFilter | NodeType.RuntimeShaderImageFilter | NodeType.ImageFilter;
|
10
10
|
export declare const isShader: (type: NodeType) => type is NodeType.Shader | NodeType.ImageShader | NodeType.ColorShader | NodeType.Turbulence | NodeType.FractalNoise | NodeType.LinearGradient | NodeType.RadialGradient | NodeType.SweepGradient | NodeType.TwoPointConicalGradient;
|
11
11
|
export declare const sortNodeChildren: (parent: Node) => {
|
12
12
|
colorFilters: Node<unknown>[];
|
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.1.
|
11
|
+
"version": "2.1.1",
|
12
12
|
"description": "High-performance React Native Graphics using Skia",
|
13
13
|
"main": "lib/module/index.js",
|
14
14
|
"react-native": "src/index.ts",
|
@@ -19,6 +19,7 @@ import type {
|
|
19
19
|
SkColor,
|
20
20
|
SamplingOptions,
|
21
21
|
SkSkottieAnimation,
|
22
|
+
SkImageFilter,
|
22
23
|
} from "../../skia/types";
|
23
24
|
|
24
25
|
import type {
|
@@ -170,3 +171,7 @@ export interface BoxShadowProps {
|
|
170
171
|
color?: Color;
|
171
172
|
inner?: boolean;
|
172
173
|
}
|
174
|
+
|
175
|
+
export interface ImageFilterProps extends GroupProps {
|
176
|
+
imageFilter: SkImageFilter;
|
177
|
+
}
|
@@ -0,0 +1,99 @@
|
|
1
|
+
import React from "react";
|
2
|
+
|
3
|
+
import { checkImage, docPath } from "../../../__tests__/setup";
|
4
|
+
import { importSkia, surface } from "../setup";
|
5
|
+
import { ImageFilter, Circle, Group } from "../../components";
|
6
|
+
import { TileMode } from "../../../skia/types";
|
7
|
+
|
8
|
+
describe("ImageFilter", () => {
|
9
|
+
it("Should render ImageFilter component with blur filter", async () => {
|
10
|
+
const { Skia } = importSkia();
|
11
|
+
const blurFilter = Skia.ImageFilter.MakeBlur(10, 10, TileMode.Clamp, null);
|
12
|
+
// THIS IS FOR INTERNAL TESTING ONLY
|
13
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
14
|
+
// @ts-expect-error
|
15
|
+
blurFilter.source =
|
16
|
+
"Skia.ImageFilter.MakeBlur(10, 10, TileMode.Clamp, null)";
|
17
|
+
// END OF INTERNAL TESTING ONLY
|
18
|
+
const img = await surface.draw(
|
19
|
+
<Group>
|
20
|
+
<ImageFilter imageFilter={blurFilter} />
|
21
|
+
<Circle cx={50} cy={50} r={30} color="red" />
|
22
|
+
</Group>
|
23
|
+
);
|
24
|
+
|
25
|
+
checkImage(img, docPath("image-filter/blur-filter.png"));
|
26
|
+
});
|
27
|
+
|
28
|
+
it("Should render ImageFilter component with offset filter", async () => {
|
29
|
+
const { Skia } = importSkia();
|
30
|
+
const offsetFilter = Skia.ImageFilter.MakeOffset(20, 20, null);
|
31
|
+
// THIS IS FOR INTERNAL TESTING ONLY
|
32
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
33
|
+
// @ts-expect-error
|
34
|
+
offsetFilter.source = "Skia.ImageFilter.MakeOffset(20, 20, null)";
|
35
|
+
// END OF INTERNAL TESTING ONLY
|
36
|
+
|
37
|
+
const img = await surface.draw(
|
38
|
+
<Group>
|
39
|
+
<ImageFilter imageFilter={offsetFilter} />
|
40
|
+
<Circle cx={50} cy={50} r={30} color="blue" />
|
41
|
+
</Group>
|
42
|
+
);
|
43
|
+
|
44
|
+
checkImage(img, docPath("image-filter/offset-filter.png"));
|
45
|
+
});
|
46
|
+
|
47
|
+
it("Should render ImageFilter component with drop shadow filter", async () => {
|
48
|
+
const { Skia } = importSkia();
|
49
|
+
const dropShadowFilter = Skia.ImageFilter.MakeDropShadow(
|
50
|
+
10,
|
51
|
+
10,
|
52
|
+
5,
|
53
|
+
5,
|
54
|
+
Skia.Color("black"),
|
55
|
+
null
|
56
|
+
);
|
57
|
+
// THIS IS FOR INTERNAL TESTING ONLY
|
58
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
59
|
+
// @ts-expect-error
|
60
|
+
dropShadowFilter.source =
|
61
|
+
'Skia.ImageFilter.MakeDropShadow(10, 10, 5, 5, Skia.Color("black"), null)';
|
62
|
+
// END OF INTERNAL TESTING ONLY
|
63
|
+
|
64
|
+
const img = await surface.draw(
|
65
|
+
<Group>
|
66
|
+
<ImageFilter imageFilter={dropShadowFilter} />
|
67
|
+
<Circle cx={50} cy={50} r={30} color="green" />
|
68
|
+
</Group>
|
69
|
+
);
|
70
|
+
|
71
|
+
checkImage(img, docPath("image-filter/drop-shadow-filter.png"));
|
72
|
+
});
|
73
|
+
|
74
|
+
it("Should render ImageFilter component with composed filters", async () => {
|
75
|
+
const { Skia } = importSkia();
|
76
|
+
const blurFilter = Skia.ImageFilter.MakeBlur(5, 5, TileMode.Clamp, null);
|
77
|
+
// THIS IS FOR INTERNAL TESTING ONLY
|
78
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
79
|
+
// @ts-expect-error
|
80
|
+
blurFilter.source = "Skia.ImageFilter.MakeBlur(5, 5, TileMode.Clamp, null)";
|
81
|
+
// END OF INTERNAL TESTING ONLY
|
82
|
+
const offsetFilter = Skia.ImageFilter.MakeOffset(10, 10, blurFilter);
|
83
|
+
// THIS IS FOR INTERNAL TESTING ONLY
|
84
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
85
|
+
// @ts-expect-error
|
86
|
+
offsetFilter.source =
|
87
|
+
"Skia.ImageFilter.MakeOffset(10, 10, Skia.ImageFilter.MakeBlur(5, 5, TileMode.Clamp, null))";
|
88
|
+
// END OF INTERNAL TESTING ONLY
|
89
|
+
|
90
|
+
const img = await surface.draw(
|
91
|
+
<Group>
|
92
|
+
<ImageFilter imageFilter={offsetFilter} />
|
93
|
+
<Circle cx={50} cy={50} r={30} color="purple" />
|
94
|
+
</Group>
|
95
|
+
);
|
96
|
+
|
97
|
+
checkImage(img, docPath("image-filter/composed-filters.png"));
|
98
|
+
});
|
99
|
+
});
|
@@ -322,6 +322,14 @@ const serializeSkOjects = (obj: any): any => {
|
|
322
322
|
source: obj.source,
|
323
323
|
assets: obj.assets,
|
324
324
|
};
|
325
|
+
} else if (obj.__typename__ === "ImageFilter") {
|
326
|
+
if (!obj.source) {
|
327
|
+
throw new Error("ImageFilter must have a source");
|
328
|
+
}
|
329
|
+
return {
|
330
|
+
__typename__: "Function",
|
331
|
+
source: obj.source,
|
332
|
+
};
|
325
333
|
}
|
326
334
|
} else if (obj && typeof obj === "object") {
|
327
335
|
const result = Object.keys(obj).reduce((acc, key) => {
|
package/src/sksg/Elements.tsx
CHANGED
@@ -52,6 +52,7 @@ import type {
|
|
52
52
|
MorphologyImageFilterProps,
|
53
53
|
BlendProps,
|
54
54
|
SkottieProps,
|
55
|
+
ImageFilterProps,
|
55
56
|
} from "../dom/types";
|
56
57
|
import type { SkiaProps } from "../renderer";
|
57
58
|
|
@@ -89,6 +90,7 @@ declare module "react" {
|
|
89
90
|
skBlurMaskFilter: SkiaProps<BlurMaskFilterProps>;
|
90
91
|
|
91
92
|
// ImageFilters
|
93
|
+
skImageFilter: SkiaProps<ImageFilterProps>;
|
92
94
|
skBlendImageFilter: SkiaProps<BlendImageFilterProps>;
|
93
95
|
skBlurImageFilter: SkiaProps<BlurImageFilterProps>;
|
94
96
|
skOffsetImageFilter: SkiaProps<OffsetImageFilterProps>;
|
package/src/sksg/Node.ts
CHANGED
@@ -34,6 +34,7 @@ export const isPathEffect = (type: NodeType) => {
|
|
34
34
|
export const isImageFilter = (type: NodeType) => {
|
35
35
|
"worklet";
|
36
36
|
return (
|
37
|
+
type === NodeType.ImageFilter ||
|
37
38
|
type === NodeType.OffsetImageFilter ||
|
38
39
|
type === NodeType.DisplacementMapImageFilter ||
|
39
40
|
type === NodeType.BlurImageFilter ||
|
@@ -5,6 +5,7 @@ import type {
|
|
5
5
|
BlurMaskFilterProps,
|
6
6
|
DisplacementMapImageFilterProps,
|
7
7
|
DropShadowImageFilterProps,
|
8
|
+
ImageFilterProps,
|
8
9
|
MorphologyImageFilterProps,
|
9
10
|
OffsetImageFilterProps,
|
10
11
|
RuntimeShaderImageFilterProps,
|
@@ -176,6 +177,15 @@ const declareRuntimeShaderImageFilter = (
|
|
176
177
|
ctx.imageFilters.push(imgf);
|
177
178
|
};
|
178
179
|
|
180
|
+
const declareImageFilter = (
|
181
|
+
ctx: DrawingContext,
|
182
|
+
props: ImageFilterProps
|
183
|
+
) => {
|
184
|
+
"worklet";
|
185
|
+
const { imageFilter } = props;
|
186
|
+
ctx.imageFilters.push(imageFilter);
|
187
|
+
};
|
188
|
+
|
179
189
|
export const composeImageFilters = (ctx: DrawingContext) => {
|
180
190
|
"worklet";
|
181
191
|
if (ctx.imageFilters.length > 1) {
|
@@ -207,6 +217,7 @@ export const isPushImageFilter = (
|
|
207
217
|
};
|
208
218
|
|
209
219
|
type Props = {
|
220
|
+
[NodeType.ImageFilter]: ImageFilterProps;
|
210
221
|
[NodeType.OffsetImageFilter]: OffsetImageFilterProps;
|
211
222
|
[NodeType.DisplacementMapImageFilter]: DisplacementMapImageFilterProps;
|
212
223
|
[NodeType.BlurImageFilter]: BlurImageFilterProps;
|
@@ -235,7 +246,9 @@ export const pushImageFilter = (
|
|
235
246
|
command: Command<CommandType.PushImageFilter>
|
236
247
|
) => {
|
237
248
|
"worklet";
|
238
|
-
if (isImageFilter(command, NodeType.
|
249
|
+
if (isImageFilter(command, NodeType.ImageFilter)) {
|
250
|
+
declareImageFilter(ctx, command.props);
|
251
|
+
} else if (isImageFilter(command, NodeType.BlurImageFilter)) {
|
239
252
|
declareBlurImageFilter(ctx, command.props);
|
240
253
|
} else if (isImageFilter(command, NodeType.MorphologyImageFilter)) {
|
241
254
|
declareMorphologyImageFilter(ctx, command.props);
|