@shopify/react-native-skia 2.7.0 → 2.9.0
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/android/build.gradle +10 -4
- package/android/cpp/rnskia-android/OpenGLContext.h +29 -3
- package/android/cpp/rnskia-android/OpenGLWindowContext.cpp +9 -2
- package/android/cpp/rnskia-android/gl/Context.h +3 -0
- package/android/cpp/rnskia-android/gl/Surface.h +1 -1
- package/cpp/api/JsiSkParagraph.h +114 -0
- package/cpp/api/JsiSkiaContext.h +4 -0
- package/cpp/rnskia/RNSkView.h +6 -0
- package/lib/commonjs/Platform/Platform.js +5 -2
- package/lib/commonjs/Platform/Platform.js.map +1 -1
- package/lib/commonjs/Platform/Platform.web.js +8 -7
- package/lib/commonjs/Platform/Platform.web.js.map +1 -1
- package/lib/commonjs/external/reanimated/useVideoLoading.js +11 -2
- package/lib/commonjs/external/reanimated/useVideoLoading.js.map +1 -1
- package/lib/commonjs/skia/core/Font.d.ts +21 -6
- package/lib/commonjs/skia/core/Font.js +24 -4
- package/lib/commonjs/skia/core/Font.js.map +1 -1
- package/lib/commonjs/skia/core/SVG.web.js +4 -5
- package/lib/commonjs/skia/core/SVG.web.js.map +1 -1
- package/lib/commonjs/skia/types/Data/Data.d.ts +5 -4
- package/lib/commonjs/skia/types/Data/Data.js +7 -1
- package/lib/commonjs/skia/types/Data/Data.js.map +1 -1
- package/lib/commonjs/skia/types/Paragraph/Paragraph.d.ts +62 -0
- package/lib/commonjs/skia/types/Paragraph/Paragraph.js.map +1 -1
- package/lib/commonjs/skia/web/Host.js +7 -0
- package/lib/commonjs/skia/web/Host.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkFont.d.ts +1 -1
- package/lib/commonjs/skia/web/JsiSkFont.js +43 -2
- package/lib/commonjs/skia/web/JsiSkFont.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkPaint.js +5 -0
- package/lib/commonjs/skia/web/JsiSkPaint.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkParagraph.d.ts +3 -1
- package/lib/commonjs/skia/web/JsiSkParagraph.js +6 -0
- package/lib/commonjs/skia/web/JsiSkParagraph.js.map +1 -1
- package/lib/commonjs/sksg/Container.web.js +34 -3
- package/lib/commonjs/sksg/Container.web.js.map +1 -1
- package/lib/commonjs/sksg/Recorder/DrawingContext.d.ts +2 -0
- package/lib/commonjs/sksg/Recorder/DrawingContext.js +22 -6
- package/lib/commonjs/sksg/Recorder/DrawingContext.js.map +1 -1
- package/lib/commonjs/sksg/Recorder/FrameScope.d.ts +18 -0
- package/lib/commonjs/sksg/Recorder/FrameScope.js +66 -0
- package/lib/commonjs/sksg/Recorder/FrameScope.js.map +1 -0
- package/lib/commonjs/sksg/Recorder/FrameScope.native.d.ts +10 -0
- package/lib/commonjs/sksg/Recorder/FrameScope.native.js +26 -0
- package/lib/commonjs/sksg/Recorder/FrameScope.native.js.map +1 -0
- package/lib/commonjs/sksg/Recorder/Player.js +1 -2
- package/lib/commonjs/sksg/Recorder/Player.js.map +1 -1
- package/lib/commonjs/sksg/Recorder/Recorder.d.ts +3 -1
- package/lib/commonjs/sksg/Recorder/Recorder.js +12 -1
- package/lib/commonjs/sksg/Recorder/Recorder.js.map +1 -1
- package/lib/commonjs/sksg/Recorder/commands/Drawing.js +3 -3
- package/lib/commonjs/sksg/Recorder/commands/Drawing.js.map +1 -1
- package/lib/commonjs/sksg/Recorder/commands/Shaders.js +3 -3
- package/lib/commonjs/sksg/Recorder/commands/Shaders.js.map +1 -1
- package/lib/commonjs/sksg/StaticContainer.d.ts +1 -0
- package/lib/commonjs/sksg/StaticContainer.js +27 -1
- package/lib/commonjs/sksg/StaticContainer.js.map +1 -1
- package/lib/module/Platform/Platform.js +6 -3
- package/lib/module/Platform/Platform.js.map +1 -1
- package/lib/module/Platform/Platform.web.js +9 -8
- package/lib/module/Platform/Platform.web.js.map +1 -1
- package/lib/module/external/reanimated/useVideoLoading.js +12 -2
- package/lib/module/external/reanimated/useVideoLoading.js.map +1 -1
- package/lib/module/skia/core/Font.d.ts +21 -6
- package/lib/module/skia/core/Font.js +26 -5
- package/lib/module/skia/core/Font.js.map +1 -1
- package/lib/module/skia/core/SVG.web.js +4 -5
- package/lib/module/skia/core/SVG.web.js.map +1 -1
- package/lib/module/skia/types/Data/Data.d.ts +5 -4
- package/lib/module/skia/types/Data/Data.js +5 -0
- package/lib/module/skia/types/Data/Data.js.map +1 -1
- package/lib/module/skia/types/Paragraph/Paragraph.d.ts +62 -0
- package/lib/module/skia/types/Paragraph/Paragraph.js.map +1 -1
- package/lib/module/skia/web/Host.js +7 -0
- package/lib/module/skia/web/Host.js.map +1 -1
- package/lib/module/skia/web/JsiSkFont.d.ts +1 -1
- package/lib/module/skia/web/JsiSkFont.js +44 -3
- package/lib/module/skia/web/JsiSkFont.js.map +1 -1
- package/lib/module/skia/web/JsiSkPaint.js +5 -0
- package/lib/module/skia/web/JsiSkPaint.js.map +1 -1
- package/lib/module/skia/web/JsiSkParagraph.d.ts +3 -1
- package/lib/module/skia/web/JsiSkParagraph.js +7 -1
- package/lib/module/skia/web/JsiSkParagraph.js.map +1 -1
- package/lib/module/sksg/Container.web.js +35 -4
- package/lib/module/sksg/Container.web.js.map +1 -1
- package/lib/module/sksg/Recorder/DrawingContext.d.ts +2 -0
- package/lib/module/sksg/Recorder/DrawingContext.js +22 -6
- package/lib/module/sksg/Recorder/DrawingContext.js.map +1 -1
- package/lib/module/sksg/Recorder/FrameScope.d.ts +18 -0
- package/lib/module/sksg/Recorder/FrameScope.js +59 -0
- package/lib/module/sksg/Recorder/FrameScope.js.map +1 -0
- package/lib/module/sksg/Recorder/FrameScope.native.d.ts +10 -0
- package/lib/module/sksg/Recorder/FrameScope.native.js +19 -0
- package/lib/module/sksg/Recorder/FrameScope.native.js.map +1 -0
- package/lib/module/sksg/Recorder/Player.js +1 -2
- package/lib/module/sksg/Recorder/Player.js.map +1 -1
- package/lib/module/sksg/Recorder/Recorder.d.ts +3 -1
- package/lib/module/sksg/Recorder/Recorder.js +10 -0
- package/lib/module/sksg/Recorder/Recorder.js.map +1 -1
- package/lib/module/sksg/Recorder/commands/Drawing.js +3 -3
- package/lib/module/sksg/Recorder/commands/Drawing.js.map +1 -1
- package/lib/module/sksg/Recorder/commands/Shaders.js +3 -3
- package/lib/module/sksg/Recorder/commands/Shaders.js.map +1 -1
- package/lib/module/sksg/StaticContainer.d.ts +1 -0
- package/lib/module/sksg/StaticContainer.js +28 -2
- package/lib/module/sksg/StaticContainer.js.map +1 -1
- package/lib/typescript/lib/commonjs/skia/types/Data/Data.d.ts +1 -0
- package/lib/typescript/lib/commonjs/skia/web/JsiSkFont.d.ts +1 -1
- package/lib/typescript/lib/commonjs/skia/web/JsiSkParagraph.d.ts +2 -0
- package/lib/typescript/lib/commonjs/sksg/Container.web.d.ts +2 -2
- package/lib/typescript/lib/commonjs/sksg/Recorder/DrawingContext.d.ts +2 -0
- package/lib/typescript/lib/commonjs/sksg/Recorder/FrameScope.d.ts +17 -0
- package/lib/typescript/lib/commonjs/sksg/Recorder/FrameScope.native.d.ts +13 -0
- package/lib/typescript/lib/commonjs/sksg/Recorder/Recorder.d.ts +1 -0
- package/lib/typescript/lib/commonjs/sksg/StaticContainer.d.ts +2 -2
- package/lib/typescript/lib/module/mock/index.d.ts +1 -0
- package/lib/typescript/lib/module/skia/types/Data/Data.d.ts +1 -0
- package/lib/typescript/lib/module/skia/web/JsiSkFont.d.ts +1 -1
- package/lib/typescript/lib/module/skia/web/JsiSkParagraph.d.ts +2 -0
- package/lib/typescript/lib/module/sksg/Container.web.d.ts +2 -2
- package/lib/typescript/lib/module/sksg/Recorder/DrawingContext.d.ts +2 -0
- package/lib/typescript/lib/module/sksg/Recorder/FrameScope.d.ts +5 -0
- package/lib/typescript/lib/module/sksg/Recorder/FrameScope.native.d.ts +5 -0
- package/lib/typescript/lib/module/sksg/Recorder/Recorder.d.ts +1 -0
- package/lib/typescript/lib/module/sksg/StaticContainer.d.ts +2 -2
- package/lib/typescript/src/skia/core/Font.d.ts +21 -6
- package/lib/typescript/src/skia/types/Data/Data.d.ts +5 -4
- package/lib/typescript/src/skia/types/Paragraph/Paragraph.d.ts +62 -0
- package/lib/typescript/src/skia/web/JsiSkFont.d.ts +1 -1
- package/lib/typescript/src/skia/web/JsiSkParagraph.d.ts +3 -1
- package/lib/typescript/src/sksg/Recorder/DrawingContext.d.ts +2 -0
- package/lib/typescript/src/sksg/Recorder/FrameScope.d.ts +18 -0
- package/lib/typescript/src/sksg/Recorder/FrameScope.native.d.ts +10 -0
- package/lib/typescript/src/sksg/Recorder/Recorder.d.ts +3 -1
- package/lib/typescript/src/sksg/StaticContainer.d.ts +1 -0
- package/package.json +8 -2
- package/react-native-skia.podspec +18 -10
- package/src/Platform/Platform.ts +6 -7
- package/src/Platform/Platform.web.tsx +9 -8
- package/src/external/reanimated/useVideoLoading.ts +12 -2
- package/src/skia/core/Font.ts +34 -13
- package/src/skia/core/SVG.web.ts +5 -14
- package/src/skia/types/Data/Data.ts +14 -4
- package/src/skia/types/Paragraph/Paragraph.ts +67 -0
- package/src/skia/web/Host.ts +7 -0
- package/src/skia/web/JsiSkFont.ts +48 -4
- package/src/skia/web/JsiSkPaint.ts +5 -0
- package/src/skia/web/JsiSkParagraph.ts +9 -1
- package/src/sksg/Container.web.ts +31 -4
- package/src/sksg/Recorder/DrawingContext.ts +19 -6
- package/src/sksg/Recorder/FrameScope.native.ts +21 -0
- package/src/sksg/Recorder/FrameScope.ts +69 -0
- package/src/sksg/Recorder/Player.ts +1 -2
- package/src/sksg/Recorder/Recorder.ts +15 -1
- package/src/sksg/Recorder/commands/Drawing.ts +3 -3
- package/src/sksg/Recorder/commands/Shaders.ts +22 -16
- package/src/sksg/StaticContainer.ts +29 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["enumKey","fitRects","processCircle","processColor","processPath","processRect","processRRect","saturate","BlendMode","FillType","FilterMode","isCubicSampling","MipmapMode","PointMode","VertexMode","drawLine","ctx","props","p1","p2","canvas","x","y","paint","drawOval","rect","Skia","drawImage","image","sampling","_props$fit","fit","src","dst","width","height","drawImageRectCubic","B","C","_sampling$filter","_sampling$mipmap","drawImageRectOptions","filter","Linear","mipmap","None","drawPoints","points","mode","drawVertices","textures","colors","indices","blendMode","vertexMode","Triangles","vertices","MakeVertices","map","c","undefined","defaultBlendMode","DstOver","SrcOver","blend","drawDiffRect","outer","inner","drawDRRect","drawTextPath","path","font","initialOffset","text","ids","getGlyphIDs","widths","getGlyphWidths","rsx","meas","ContourMeasureIter","cont","next","dist","i","length","substring","p","t","getPosTan","adjustedX","adjustedY","push","RSXform","derived","TextBlob","MakeFromRSXform","drawTextBlob","drawText","drawPatch","texture","patch","pos","c2","c1","drawPath","start","trimStart","end","trimEnd","fillType","stroke","pathProps","Math","fround","hasStartOffset","hasEndOffset","hasStrokeOptions","hasFillType","builder","PathBuilder","MakeFromPath","setFillType","build","stroked","Path","Stroke","trimmed","Trim","drawRect","drawRRect","blob","drawGlyphs","glyphs","reduce","acc","glyph","id","positions","drawImageSVG","svg","save","translate","drawSvg","restore","drawParagraph","paragraph","layout","drawPicture","picture","drawAtlas","sprites","transforms","colorBlendMode","drawCircle","r","drawSkottie","animation","frame","seekFrame","render"],"sources":["Drawing.ts"],"sourcesContent":["import {\n enumKey,\n fitRects,\n processCircle,\n processColor,\n processPath,\n processRect,\n processRRect,\n} from \"../../../dom/nodes\";\nimport type {\n AtlasProps,\n CircleProps,\n DiffRectProps,\n GlyphsProps,\n ImageProps,\n ImageSVGProps,\n LineProps,\n OvalProps,\n ParagraphProps,\n PatchProps,\n PathProps,\n PictureProps,\n PointsProps,\n RectProps,\n RoundedRectProps,\n SkottieProps,\n TextBlobProps,\n TextPathProps,\n TextProps,\n VerticesProps,\n} from \"../../../dom/types\";\nimport { saturate } from \"../../../renderer/processors\";\nimport type { SkPoint, SkRSXform } from \"../../../skia/types\";\nimport {\n BlendMode,\n FillType,\n FilterMode,\n isCubicSampling,\n MipmapMode,\n PointMode,\n VertexMode,\n} from \"../../../skia/types\";\nimport type { DrawingContext } from \"../DrawingContext\";\n\nexport const drawLine = (ctx: DrawingContext, props: LineProps) => {\n \"worklet\";\n const { p1, p2 } = props;\n ctx.canvas.drawLine(p1.x, p1.y, p2.x, p2.y, ctx.paint);\n};\n\nexport const drawOval = (ctx: DrawingContext, props: OvalProps) => {\n \"worklet\";\n const rect = processRect(ctx.Skia, props);\n ctx.canvas.drawOval(rect, ctx.paint);\n};\n\nexport const drawImage = (ctx: DrawingContext, props: ImageProps) => {\n \"worklet\";\n const { image, sampling } = props;\n if (image) {\n const fit = props.fit ?? \"contain\";\n const rect = processRect(ctx.Skia, props);\n const { src, dst } = fitRects(\n fit,\n {\n x: 0,\n y: 0,\n width: image.width(),\n height: image.height(),\n },\n rect\n );\n if (sampling && isCubicSampling(sampling)) {\n ctx.canvas.drawImageRectCubic(\n image,\n src,\n dst,\n sampling.B,\n sampling.C,\n ctx.paint\n );\n } else {\n ctx.canvas.drawImageRectOptions(\n image,\n src,\n dst,\n sampling?.filter ?? FilterMode.Linear,\n sampling?.mipmap ?? MipmapMode.None,\n ctx.paint\n );\n }\n }\n};\n\nexport const drawPoints = (ctx: DrawingContext, props: PointsProps) => {\n \"worklet\";\n const { points, mode } = props;\n ctx.canvas.drawPoints(PointMode[enumKey(mode)], points, ctx.paint);\n};\n\nexport const drawVertices = (ctx: DrawingContext, props: VerticesProps) => {\n \"worklet\";\n const { mode, textures, colors, indices, blendMode } = props;\n const vertexMode = mode ? VertexMode[enumKey(mode)] : VertexMode.Triangles;\n const vertices = ctx.Skia.MakeVertices(\n vertexMode,\n props.vertices,\n textures,\n colors ? colors.map((c) => processColor(ctx.Skia, c)) : undefined,\n indices\n );\n const defaultBlendMode = colors ? BlendMode.DstOver : BlendMode.SrcOver;\n const blend = blendMode ? BlendMode[enumKey(blendMode)] : defaultBlendMode;\n\n ctx.canvas.drawVertices(vertices, blend, ctx.paint);\n};\n\nexport const drawDiffRect = (ctx: DrawingContext, props: DiffRectProps) => {\n \"worklet\";\n const { outer, inner } = props;\n ctx.canvas.drawDRRect(outer, inner, ctx.paint);\n};\n\nexport const drawTextPath = (ctx: DrawingContext, props: TextPathProps) => {\n \"worklet\";\n const path = processPath(ctx.Skia, props.path);\n const { font, initialOffset } = props;\n if (font) {\n let { text } = props;\n const ids = font.getGlyphIDs(text);\n const widths = font.getGlyphWidths(ids);\n const rsx: SkRSXform[] = [];\n const meas = ctx.Skia.ContourMeasureIter(path, false, 1);\n let cont = meas.next();\n let dist = initialOffset;\n for (let i = 0; i < text.length && cont; i++) {\n const width = widths[i];\n dist += width / 2;\n if (dist > cont.length()) {\n // jump to next contour\n cont = meas.next();\n if (!cont) {\n // We have come to the end of the path - terminate the string\n // right here.\n text = text.substring(0, i);\n break;\n }\n dist = width / 2;\n }\n // Gives us the (x, y) coordinates as well as the cos/sin of the tangent\n // line at that position.\n const [p, t] = cont.getPosTan(dist);\n const adjustedX = p.x - (width / 2) * t.x;\n const adjustedY = p.y - (width / 2) * t.y;\n rsx.push(ctx.Skia.RSXform(t.x, t.y, adjustedX, adjustedY));\n dist += width / 2;\n }\n const derived = ctx.Skia.TextBlob.MakeFromRSXform(text, rsx, font);\n ctx.canvas.drawTextBlob(derived, 0, 0, ctx.paint);\n }\n};\n\nexport const drawText = (ctx: DrawingContext, props: TextProps) => {\n \"worklet\";\n const { text, x, y, font } = props;\n if (font != null) {\n ctx.canvas.drawText(text, x, y, ctx.paint, font);\n }\n};\n\nexport const drawPatch = (ctx: DrawingContext, props: PatchProps) => {\n \"worklet\";\n const { texture, blendMode, patch } = props;\n const defaultBlendMode = props.colors ? BlendMode.DstOver : BlendMode.SrcOver;\n const mode = blendMode ? BlendMode[enumKey(blendMode)] : defaultBlendMode;\n // Patch requires a path with the following constraints:\n // M tl\n // C c1 c2 br\n // C c1 c2 bl\n // C c1 c2 tl (the redundant point in the last command is removed)\n\n const points = [\n patch[0].pos,\n patch[0].c2,\n patch[1].c1,\n patch[1].pos,\n patch[1].c2,\n patch[2].c1,\n patch[2].pos,\n patch[2].c2,\n patch[3].c1,\n patch[3].pos,\n patch[3].c2,\n patch[0].c1,\n ];\n const colors = props.colors\n ? props.colors.map((c) => processColor(ctx.Skia, c))\n : undefined;\n ctx.canvas.drawPatch(points, colors, texture, mode, ctx.paint);\n};\n\nexport const drawPath = (ctx: DrawingContext, props: PathProps) => {\n \"worklet\";\n const {\n start: trimStart,\n end: trimEnd,\n fillType,\n stroke,\n ...pathProps\n } = props;\n const start = Math.fround(saturate(trimStart));\n const end = Math.fround(saturate(trimEnd));\n const hasStartOffset = start !== 0;\n const hasEndOffset = end !== 1;\n const hasStrokeOptions = stroke !== undefined;\n const hasFillType = !!fillType;\n\n let path = processPath(ctx.Skia, pathProps.path);\n\n // Apply fill type using PathBuilder\n if (hasFillType) {\n const builder = ctx.Skia.PathBuilder.MakeFromPath(path);\n builder.setFillType(FillType[enumKey(fillType)]);\n path = builder.build();\n }\n\n // Apply stroke using static Path.Stroke\n if (hasStrokeOptions) {\n const stroked = ctx.Skia.Path.Stroke(path, stroke);\n if (stroked) {\n path = stroked;\n }\n }\n\n // Apply trim using static Path.Trim\n if (hasStartOffset || hasEndOffset) {\n const trimmed = ctx.Skia.Path.Trim(path, start, end, false);\n if (trimmed) {\n path = trimmed;\n }\n }\n\n ctx.canvas.drawPath(path, ctx.paint);\n};\n\nexport const drawRect = (ctx: DrawingContext, props: RectProps) => {\n \"worklet\";\n const derived = processRect(ctx.Skia, props);\n ctx.canvas.drawRect(derived, ctx.paint);\n};\n\nexport const drawRRect = (ctx: DrawingContext, props: RoundedRectProps) => {\n \"worklet\";\n const derived = processRRect(ctx.Skia, props);\n ctx.canvas.drawRRect(derived, ctx.paint);\n};\n\nexport const drawTextBlob = (ctx: DrawingContext, props: TextBlobProps) => {\n \"worklet\";\n const { blob, x, y } = props;\n ctx.canvas.drawTextBlob(blob, x, y, ctx.paint);\n};\n\ninterface ProcessedGlyphs {\n glyphs: number[];\n positions: SkPoint[];\n}\n\nexport const drawGlyphs = (ctx: DrawingContext, props: GlyphsProps) => {\n \"worklet\";\n const derived = props.glyphs.reduce<ProcessedGlyphs>(\n (acc, glyph) => {\n const { id, pos } = glyph;\n acc.glyphs.push(id);\n acc.positions.push(pos);\n return acc;\n },\n { glyphs: [], positions: [] }\n );\n const { glyphs, positions } = derived;\n const { x, y, font } = props;\n if (font) {\n ctx.canvas.drawGlyphs(glyphs, positions, x, y, font, ctx.paint);\n }\n};\n\nexport const drawImageSVG = (ctx: DrawingContext, props: ImageSVGProps) => {\n \"worklet\";\n const { canvas } = ctx;\n const { svg } = props;\n const { x, y, width, height } = props.rect\n ? props.rect\n : { x: props.x, y: props.y, width: props.width, height: props.height };\n if (svg === null) {\n return;\n }\n canvas.save();\n if (x && y) {\n canvas.translate(x, y);\n }\n canvas.drawSvg(svg, width, height);\n canvas.restore();\n};\n\nexport const drawParagraph = (ctx: DrawingContext, props: ParagraphProps) => {\n \"worklet\";\n const { paragraph, x, y, width } = props;\n if (paragraph) {\n paragraph.layout(width);\n paragraph.paint(ctx.canvas, x, y);\n }\n};\n\nexport const drawPicture = (ctx: DrawingContext, props: PictureProps) => {\n \"worklet\";\n const { picture } = props;\n ctx.canvas.drawPicture(picture);\n};\n\nexport const drawAtlas = (ctx: DrawingContext, props: AtlasProps) => {\n \"worklet\";\n const { image, sprites, transforms, colors, colorBlendMode, sampling } =\n props;\n const blend = colorBlendMode ? BlendMode[enumKey(colorBlendMode)] : undefined;\n if (image) {\n ctx.canvas.drawAtlas(\n image,\n sprites,\n transforms,\n ctx.paint,\n blend,\n colors,\n sampling\n );\n }\n};\n\nexport const drawCircle = (ctx: DrawingContext, props: CircleProps) => {\n \"worklet\";\n const { c } = processCircle(props);\n const { r } = props;\n ctx.canvas.drawCircle(c.x, c.y, r, ctx.paint);\n};\n\nexport const drawSkottie = (ctx: DrawingContext, props: SkottieProps) => {\n \"worklet\";\n const { animation, frame } = props;\n if (animation) {\n props.animation.seekFrame(frame);\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AC,GAAG7I,KAAK;EAClC,IAAI4I,SAAS,EAAE;IACb5I,KAAK,CAAC4I,SAAS,CAACE,SAAS,CAACD,KAAK,CAAC;IAChC7I,KAAK,CAAC4I,SAAS,CAACG,MAAM,CAAChJ,GAAG,CAACI,MAAM,CAAC;EACpC;AACF,CAAC","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["enumKey","fitRects","processCircle","processColor","processPath","processRect","processRRect","saturate","BlendMode","FillType","FilterMode","isCubicSampling","MipmapMode","PointMode","VertexMode","drawLine","ctx","props","p1","p2","canvas","x","y","paint","drawOval","rect","Skia","drawImage","image","sampling","_props$fit","fit","src","dst","width","height","drawImageRectCubic","B","C","_sampling$filter","_sampling$mipmap","drawImageRectOptions","filter","Linear","mipmap","None","drawPoints","points","mode","drawVertices","textures","colors","indices","blendMode","vertexMode","Triangles","vertices","MakeVertices","map","c","undefined","defaultBlendMode","DstOver","SrcOver","blend","drawDiffRect","outer","inner","drawDRRect","drawTextPath","path","font","initialOffset","text","ids","getGlyphIDs","widths","getGlyphWidths","rsx","meas","ContourMeasureIter","cont","track","next","dist","i","length","substring","p","t","getPosTan","adjustedX","adjustedY","push","RSXform","derived","TextBlob","MakeFromRSXform","drawTextBlob","drawText","drawPatch","texture","patch","pos","c2","c1","drawPath","start","trimStart","end","trimEnd","fillType","stroke","pathProps","Math","fround","hasStartOffset","hasEndOffset","hasStrokeOptions","hasFillType","builder","PathBuilder","MakeFromPath","setFillType","build","stroked","Path","Stroke","trimmed","Trim","drawRect","drawRRect","blob","drawGlyphs","glyphs","reduce","acc","glyph","id","positions","drawImageSVG","svg","save","translate","drawSvg","restore","drawParagraph","paragraph","layout","drawPicture","picture","drawAtlas","sprites","transforms","colorBlendMode","drawCircle","r","drawSkottie","animation","frame","seekFrame","render"],"sources":["Drawing.ts"],"sourcesContent":["import {\n enumKey,\n fitRects,\n processCircle,\n processColor,\n processPath,\n processRect,\n processRRect,\n} from \"../../../dom/nodes\";\nimport type {\n AtlasProps,\n CircleProps,\n DiffRectProps,\n GlyphsProps,\n ImageProps,\n ImageSVGProps,\n LineProps,\n OvalProps,\n ParagraphProps,\n PatchProps,\n PathProps,\n PictureProps,\n PointsProps,\n RectProps,\n RoundedRectProps,\n SkottieProps,\n TextBlobProps,\n TextPathProps,\n TextProps,\n VerticesProps,\n} from \"../../../dom/types\";\nimport { saturate } from \"../../../renderer/processors\";\nimport type { SkPoint, SkRSXform } from \"../../../skia/types\";\nimport {\n BlendMode,\n FillType,\n FilterMode,\n isCubicSampling,\n MipmapMode,\n PointMode,\n VertexMode,\n} from \"../../../skia/types\";\nimport type { DrawingContext } from \"../DrawingContext\";\n\nexport const drawLine = (ctx: DrawingContext, props: LineProps) => {\n \"worklet\";\n const { p1, p2 } = props;\n ctx.canvas.drawLine(p1.x, p1.y, p2.x, p2.y, ctx.paint);\n};\n\nexport const drawOval = (ctx: DrawingContext, props: OvalProps) => {\n \"worklet\";\n const rect = processRect(ctx.Skia, props);\n ctx.canvas.drawOval(rect, ctx.paint);\n};\n\nexport const drawImage = (ctx: DrawingContext, props: ImageProps) => {\n \"worklet\";\n const { image, sampling } = props;\n if (image) {\n const fit = props.fit ?? \"contain\";\n const rect = processRect(ctx.Skia, props);\n const { src, dst } = fitRects(\n fit,\n {\n x: 0,\n y: 0,\n width: image.width(),\n height: image.height(),\n },\n rect\n );\n if (sampling && isCubicSampling(sampling)) {\n ctx.canvas.drawImageRectCubic(\n image,\n src,\n dst,\n sampling.B,\n sampling.C,\n ctx.paint\n );\n } else {\n ctx.canvas.drawImageRectOptions(\n image,\n src,\n dst,\n sampling?.filter ?? FilterMode.Linear,\n sampling?.mipmap ?? MipmapMode.None,\n ctx.paint\n );\n }\n }\n};\n\nexport const drawPoints = (ctx: DrawingContext, props: PointsProps) => {\n \"worklet\";\n const { points, mode } = props;\n ctx.canvas.drawPoints(PointMode[enumKey(mode)], points, ctx.paint);\n};\n\nexport const drawVertices = (ctx: DrawingContext, props: VerticesProps) => {\n \"worklet\";\n const { mode, textures, colors, indices, blendMode } = props;\n const vertexMode = mode ? VertexMode[enumKey(mode)] : VertexMode.Triangles;\n const vertices = ctx.Skia.MakeVertices(\n vertexMode,\n props.vertices,\n textures,\n colors ? colors.map((c) => processColor(ctx.Skia, c)) : undefined,\n indices\n );\n const defaultBlendMode = colors ? BlendMode.DstOver : BlendMode.SrcOver;\n const blend = blendMode ? BlendMode[enumKey(blendMode)] : defaultBlendMode;\n\n ctx.canvas.drawVertices(vertices, blend, ctx.paint);\n};\n\nexport const drawDiffRect = (ctx: DrawingContext, props: DiffRectProps) => {\n \"worklet\";\n const { outer, inner } = props;\n ctx.canvas.drawDRRect(outer, inner, ctx.paint);\n};\n\nexport const drawTextPath = (ctx: DrawingContext, props: TextPathProps) => {\n \"worklet\";\n const path = processPath(ctx.Skia, props.path);\n const { font, initialOffset } = props;\n if (font) {\n let { text } = props;\n const ids = font.getGlyphIDs(text);\n const widths = font.getGlyphWidths(ids);\n const rsx: SkRSXform[] = [];\n const meas = ctx.Skia.ContourMeasureIter(path, false, 1);\n let cont = ctx.track(meas.next());\n let dist = initialOffset;\n for (let i = 0; i < text.length && cont; i++) {\n const width = widths[i];\n dist += width / 2;\n if (dist > cont.length()) {\n // jump to next contour\n cont = ctx.track(meas.next());\n if (!cont) {\n // We have come to the end of the path - terminate the string\n // right here.\n text = text.substring(0, i);\n break;\n }\n dist = width / 2;\n }\n // Gives us the (x, y) coordinates as well as the cos/sin of the tangent\n // line at that position.\n const [p, t] = cont.getPosTan(dist);\n const adjustedX = p.x - (width / 2) * t.x;\n const adjustedY = p.y - (width / 2) * t.y;\n rsx.push(ctx.Skia.RSXform(t.x, t.y, adjustedX, adjustedY));\n dist += width / 2;\n }\n const derived = ctx.Skia.TextBlob.MakeFromRSXform(text, rsx, font);\n ctx.canvas.drawTextBlob(derived, 0, 0, ctx.paint);\n }\n};\n\nexport const drawText = (ctx: DrawingContext, props: TextProps) => {\n \"worklet\";\n const { text, x, y, font } = props;\n if (font != null) {\n ctx.canvas.drawText(text, x, y, ctx.paint, font);\n }\n};\n\nexport const drawPatch = (ctx: DrawingContext, props: PatchProps) => {\n \"worklet\";\n const { texture, blendMode, patch } = props;\n const defaultBlendMode = props.colors ? BlendMode.DstOver : BlendMode.SrcOver;\n const mode = blendMode ? BlendMode[enumKey(blendMode)] : defaultBlendMode;\n // Patch requires a path with the following constraints:\n // M tl\n // C c1 c2 br\n // C c1 c2 bl\n // C c1 c2 tl (the redundant point in the last command is removed)\n\n const points = [\n patch[0].pos,\n patch[0].c2,\n patch[1].c1,\n patch[1].pos,\n patch[1].c2,\n patch[2].c1,\n patch[2].pos,\n patch[2].c2,\n patch[3].c1,\n patch[3].pos,\n patch[3].c2,\n patch[0].c1,\n ];\n const colors = props.colors\n ? props.colors.map((c) => processColor(ctx.Skia, c))\n : undefined;\n ctx.canvas.drawPatch(points, colors, texture, mode, ctx.paint);\n};\n\nexport const drawPath = (ctx: DrawingContext, props: PathProps) => {\n \"worklet\";\n const {\n start: trimStart,\n end: trimEnd,\n fillType,\n stroke,\n ...pathProps\n } = props;\n const start = Math.fround(saturate(trimStart));\n const end = Math.fround(saturate(trimEnd));\n const hasStartOffset = start !== 0;\n const hasEndOffset = end !== 1;\n const hasStrokeOptions = stroke !== undefined;\n const hasFillType = !!fillType;\n\n let path = processPath(ctx.Skia, pathProps.path);\n\n // Apply fill type using PathBuilder\n if (hasFillType) {\n const builder = ctx.Skia.PathBuilder.MakeFromPath(path);\n builder.setFillType(FillType[enumKey(fillType)]);\n path = ctx.track(builder.build());\n }\n\n // Apply stroke using static Path.Stroke\n if (hasStrokeOptions) {\n const stroked = ctx.Skia.Path.Stroke(path, stroke);\n if (stroked) {\n path = stroked;\n }\n }\n\n // Apply trim using static Path.Trim\n if (hasStartOffset || hasEndOffset) {\n const trimmed = ctx.Skia.Path.Trim(path, start, end, false);\n if (trimmed) {\n path = trimmed;\n }\n }\n\n ctx.canvas.drawPath(path, ctx.paint);\n};\n\nexport const drawRect = (ctx: DrawingContext, props: RectProps) => {\n \"worklet\";\n const derived = processRect(ctx.Skia, props);\n ctx.canvas.drawRect(derived, ctx.paint);\n};\n\nexport const drawRRect = (ctx: DrawingContext, props: RoundedRectProps) => {\n \"worklet\";\n const derived = processRRect(ctx.Skia, props);\n ctx.canvas.drawRRect(derived, ctx.paint);\n};\n\nexport const drawTextBlob = (ctx: DrawingContext, props: TextBlobProps) => {\n \"worklet\";\n const { blob, x, y } = props;\n ctx.canvas.drawTextBlob(blob, x, y, ctx.paint);\n};\n\ninterface ProcessedGlyphs {\n glyphs: number[];\n positions: SkPoint[];\n}\n\nexport const drawGlyphs = (ctx: DrawingContext, props: GlyphsProps) => {\n \"worklet\";\n const derived = props.glyphs.reduce<ProcessedGlyphs>(\n (acc, glyph) => {\n const { id, pos } = glyph;\n acc.glyphs.push(id);\n acc.positions.push(pos);\n return acc;\n },\n { glyphs: [], positions: [] }\n );\n const { glyphs, positions } = derived;\n const { x, y, font } = props;\n if (font) {\n ctx.canvas.drawGlyphs(glyphs, positions, x, y, font, ctx.paint);\n }\n};\n\nexport const drawImageSVG = (ctx: DrawingContext, props: ImageSVGProps) => {\n \"worklet\";\n const { canvas } = ctx;\n const { svg } = props;\n const { x, y, width, height } = props.rect\n ? props.rect\n : { x: props.x, y: props.y, width: props.width, height: props.height };\n if (svg === null) {\n return;\n }\n canvas.save();\n if (x && y) {\n canvas.translate(x, y);\n }\n canvas.drawSvg(svg, width, height);\n canvas.restore();\n};\n\nexport const drawParagraph = (ctx: DrawingContext, props: ParagraphProps) => {\n \"worklet\";\n const { paragraph, x, y, width } = props;\n if (paragraph) {\n paragraph.layout(width);\n paragraph.paint(ctx.canvas, x, y);\n }\n};\n\nexport const drawPicture = (ctx: DrawingContext, props: PictureProps) => {\n \"worklet\";\n const { picture } = props;\n ctx.canvas.drawPicture(picture);\n};\n\nexport const drawAtlas = (ctx: DrawingContext, props: AtlasProps) => {\n \"worklet\";\n const { image, sprites, transforms, colors, colorBlendMode, sampling } =\n props;\n const blend = colorBlendMode ? BlendMode[enumKey(colorBlendMode)] : undefined;\n if (image) {\n ctx.canvas.drawAtlas(\n image,\n sprites,\n transforms,\n ctx.paint,\n blend,\n colors,\n sampling\n );\n }\n};\n\nexport const drawCircle = (ctx: DrawingContext, props: CircleProps) => {\n \"worklet\";\n const { c } = processCircle(props);\n const { r } = props;\n ctx.canvas.drawCircle(c.x, c.y, r, ctx.paint);\n};\n\nexport const drawSkottie = (ctx: DrawingContext, props: SkottieProps) => {\n \"worklet\";\n const { animation, frame } = props;\n if (animation) {\n props.animation.seekFrame(frame);\n props.animation.render(ctx.canvas);\n }\n};\n"],"mappings":"AAAA,SACEA,OAAO,EACPC,QAAQ,EACRC,aAAa,EACbC,YAAY,EACZC,WAAW,EACXC,WAAW,EACXC,YAAY,QACP,oBAAoB;AAuB3B,SAASC,QAAQ,QAAQ,8BAA8B;AAEvD,SACEC,SAAS,EACTC,QAAQ,EACRC,UAAU,EACVC,eAAe,EACfC,UAAU,EACVC,SAAS,EACTC,UAAU,QACL,qBAAqB;AAG5B,OAAO,MAAMC,QAAQ,GAAGA,CAACC,GAAmB,EAAEC,KAAgB,KAAK;EACjE,SAAS;;EACT,MAAM;IAAEC,EAAE;IAAEC;EAAG,CAAC,GAAGF,KAAK;EACxBD,GAAG,CAACI,MAAM,CAACL,QAAQ,CAACG,EAAE,CAACG,CAAC,EAAEH,EAAE,CAACI,CAAC,EAAEH,EAAE,CAACE,CAAC,EAAEF,EAAE,CAACG,CAAC,EAAEN,GAAG,CAACO,KAAK,CAAC;AACxD,CAAC;AAED,OAAO,MAAMC,QAAQ,GAAGA,CAACR,GAAmB,EAAEC,KAAgB,KAAK;EACjE,SAAS;;EACT,MAAMQ,IAAI,GAAGpB,WAAW,CAACW,GAAG,CAACU,IAAI,EAAET,KAAK,CAAC;EACzCD,GAAG,CAACI,MAAM,CAACI,QAAQ,CAACC,IAAI,EAAET,GAAG,CAACO,KAAK,CAAC;AACtC,CAAC;AAED,OAAO,MAAMI,SAAS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AAM8H,UAAU,GAAGA,CAAC3I,GAAmB,EAAEC,KAAkB,KAAK;EACrE,SAAS;;EACT,MAAM;IAAE0C;EAAE,CAAC,GAAGzD,aAAa,CAACe,KAAK,CAAC;EAClC,MAAM;IAAE2I;EAAE,CAAC,GAAG3I,KAAK;EACnBD,GAAG,CAACI,MAAM,CAACuI,UAAU,CAAChG,CAAC,CAACtC,CAAC,EAAEsC,CAAC,CAACrC,CAAC,EAAEsI,CAAC,EAAE5I,GAAG,CAACO,KAAK,CAAC;AAC/C,CAAC;AAED,OAAO,MAAMsI,WAAW,GAAGA,CAAC7I,GAAmB,EAAEC,KAAmB,KAAK;EACvE,SAAS;;EACT,MAAM;IAAE6I,SAAS;IAAEC;EAAM,CAAC,GAAG9I,KAAK;EAClC,IAAI6I,SAAS,EAAE;IACb7I,KAAK,CAAC6I,SAAS,CAACE,SAAS,CAACD,KAAK,CAAC;IAChC9I,KAAK,CAAC6I,SAAS,CAACG,MAAM,CAACjJ,GAAG,CAACI,MAAM,CAAC;EACpC;AACF,CAAC","ignoreList":[]}
|
|
@@ -13,7 +13,7 @@ const declareShader = (ctx, props, children) => {
|
|
|
13
13
|
} = props;
|
|
14
14
|
const m3 = ctx.Skia.Matrix();
|
|
15
15
|
processTransformProps(m3, transform);
|
|
16
|
-
const shader = source.makeShaderWithChildren(processUniforms(source, uniforms), ctx.shaders.splice(0, children), m3);
|
|
16
|
+
const shader = ctx.track(source.makeShaderWithChildren(processUniforms(source, uniforms), ctx.shaders.splice(0, children), m3));
|
|
17
17
|
ctx.shaders.push(shader);
|
|
18
18
|
};
|
|
19
19
|
const declareColorShader = (ctx, props) => {
|
|
@@ -156,10 +156,10 @@ const declareImageShader = (ctx, props) => {
|
|
|
156
156
|
processTransformProps(lm, imageShaderProps);
|
|
157
157
|
let shader;
|
|
158
158
|
if (sampling && isCubicSampling(sampling)) {
|
|
159
|
-
shader = image.makeShaderCubic(TileMode[enumKey(tx)], TileMode[enumKey(ty)], sampling.B, sampling.C, lm);
|
|
159
|
+
shader = ctx.track(image.makeShaderCubic(TileMode[enumKey(tx)], TileMode[enumKey(ty)], sampling.B, sampling.C, lm));
|
|
160
160
|
} else {
|
|
161
161
|
var _sampling$filter, _sampling$mipmap;
|
|
162
|
-
shader = image.makeShaderCubic(TileMode[enumKey(tx)], TileMode[enumKey(ty)], (_sampling$filter = sampling === null || sampling === void 0 ? void 0 : sampling.filter) !== null && _sampling$filter !== void 0 ? _sampling$filter : FilterMode.Linear, (_sampling$mipmap = sampling === null || sampling === void 0 ? void 0 : sampling.mipmap) !== null && _sampling$mipmap !== void 0 ? _sampling$mipmap : MipmapMode.None, lm);
|
|
162
|
+
shader = ctx.track(image.makeShaderCubic(TileMode[enumKey(tx)], TileMode[enumKey(ty)], (_sampling$filter = sampling === null || sampling === void 0 ? void 0 : sampling.filter) !== null && _sampling$filter !== void 0 ? _sampling$filter : FilterMode.Linear, (_sampling$mipmap = sampling === null || sampling === void 0 ? void 0 : sampling.mipmap) !== null && _sampling$mipmap !== void 0 ? _sampling$mipmap : MipmapMode.None, lm));
|
|
163
163
|
}
|
|
164
164
|
ctx.shaders.push(shader);
|
|
165
165
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["enumKey","fitRects","getRect","processColor","processGradientProps","processTransformProps","rect2rect","NodeType","BlendMode","FilterMode","isCubicSampling","MipmapMode","processUniforms","TileMode","composeDeclarations","CommandType","declareShader","ctx","props","children","source","uniforms","transform","m3","Skia","Matrix","shader","makeShaderWithChildren","shaders","splice","push","declareColorShader","color","Shader","MakeColor","declareFractalNoiseShader","freqX","freqY","octaves","seed","tileWidth","tileHeight","MakeFractalNoise","declareTwoPointConicalGradientShader","startR","endR","start","end","colors","positions","mode","localMatrix","flags","MakeTwoPointConicalGradient","declareRadialGradientShader","c","r","MakeRadialGradient","declareSweepGradientShader","MakeSweepGradient","x","y","declareLinearGradientShader","MakeLinearGradient","declareTurbulenceShader","MakeTurbulence","declareImageShader","fit","image","tx","ty","sampling","imageShaderProps","rct","rects","width","height","sx","sy","src","dst","translate","translateX","translateY","scale","scaleX","scaleY","lm","concat","makeShaderCubic","B","C","_sampling$filter","_sampling$mipmap","filter","Linear","mipmap","None","declareBlend","blend","length","composer","MakeBlend","bind","isPushShader","command","type","PushShader","isShader","shaderType","pushShader","ImageShader","ColorShader","Turbulence","FractalNoise","LinearGradient","RadialGradient","SweepGradient","TwoPointConicalGradient","Blend","Error"],"sources":["Shaders.ts"],"sourcesContent":["import {\n enumKey,\n fitRects,\n getRect,\n processColor,\n processGradientProps,\n processTransformProps,\n rect2rect,\n} from \"../../../dom/nodes\";\nimport { NodeType } from \"../../../dom/types\";\nimport type {\n BlendProps,\n ColorProps,\n FractalNoiseProps,\n ImageShaderProps,\n LinearGradientProps,\n RadialGradientProps,\n ShaderProps,\n SweepGradientProps,\n TurbulenceProps,\n TwoPointConicalGradientProps,\n} from \"../../../dom/types\";\nimport type { SkShader } from \"../../../skia/types\";\nimport {\n BlendMode,\n FilterMode,\n isCubicSampling,\n MipmapMode,\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\nconst declareShader = (\n ctx: DrawingContext,\n props: ShaderProps,\n children: number\n) => {\n \"worklet\";\n const { source, uniforms, ...transform } = props;\n const m3 = ctx.Skia.Matrix();\n processTransformProps(m3, transform);\n const shader = source.makeShaderWithChildren(\n processUniforms(source, uniforms),\n ctx.shaders.splice(0, children),\n m3\n );\n ctx.shaders.push(shader);\n};\n\nconst declareColorShader = (ctx: DrawingContext, props: ColorProps) => {\n \"worklet\";\n const { color } = props;\n const shader = ctx.Skia.Shader.MakeColor(processColor(ctx.Skia, color));\n ctx.shaders.push(shader);\n};\n\nconst declareFractalNoiseShader = (\n ctx: DrawingContext,\n props: FractalNoiseProps\n) => {\n \"worklet\";\n const { freqX, freqY, octaves, seed, tileWidth, tileHeight } = props;\n const shader = ctx.Skia.Shader.MakeFractalNoise(\n freqX,\n freqY,\n octaves,\n seed,\n tileWidth,\n tileHeight\n );\n ctx.shaders.push(shader);\n};\n\nconst declareTwoPointConicalGradientShader = (\n ctx: DrawingContext,\n props: TwoPointConicalGradientProps\n) => {\n \"worklet\";\n const { startR, endR, start, end } = props;\n const { colors, positions, mode, localMatrix, flags } = processGradientProps(\n ctx.Skia,\n props\n );\n const shader = ctx.Skia.Shader.MakeTwoPointConicalGradient(\n start,\n startR,\n end,\n endR,\n colors,\n positions,\n mode,\n localMatrix,\n flags\n );\n ctx.shaders.push(shader);\n};\n\nconst declareRadialGradientShader = (\n ctx: DrawingContext,\n props: RadialGradientProps\n) => {\n \"worklet\";\n const { c, r } = props;\n const { colors, positions, mode, localMatrix, flags } = processGradientProps(\n ctx.Skia,\n props\n );\n const shader = ctx.Skia.Shader.MakeRadialGradient(\n c,\n r,\n colors,\n positions,\n mode,\n localMatrix,\n flags\n );\n ctx.shaders.push(shader);\n};\n\nconst declareSweepGradientShader = (\n ctx: DrawingContext,\n props: SweepGradientProps\n) => {\n \"worklet\";\n const { c, start, end } = props;\n const { colors, positions, mode, localMatrix, flags } = processGradientProps(\n ctx.Skia,\n props\n );\n const shader = ctx.Skia.Shader.MakeSweepGradient(\n c.x,\n c.y,\n colors,\n positions,\n mode,\n localMatrix,\n flags,\n start,\n end\n );\n ctx.shaders.push(shader);\n};\n\nconst declareLinearGradientShader = (\n ctx: DrawingContext,\n props: LinearGradientProps\n) => {\n \"worklet\";\n const { start, end } = props;\n const { colors, positions, mode, localMatrix, flags } = processGradientProps(\n ctx.Skia,\n props\n );\n const shader = ctx.Skia.Shader.MakeLinearGradient(\n start,\n end,\n colors,\n positions ?? null,\n mode,\n localMatrix,\n flags\n );\n ctx.shaders.push(shader);\n};\n\nconst declareTurbulenceShader = (\n ctx: DrawingContext,\n props: TurbulenceProps\n) => {\n \"worklet\";\n const { freqX, freqY, octaves, seed, tileWidth, tileHeight } = props;\n const shader = ctx.Skia.Shader.MakeTurbulence(\n freqX,\n freqY,\n octaves,\n seed,\n tileWidth,\n tileHeight\n );\n ctx.shaders.push(shader);\n};\n\nconst declareImageShader = (ctx: DrawingContext, props: ImageShaderProps) => {\n \"worklet\";\n const { fit, image, tx, ty, sampling, ...imageShaderProps } = props;\n if (!image) {\n return;\n }\n\n const rct = getRect(ctx.Skia, imageShaderProps);\n const m3 = ctx.Skia.Matrix();\n if (rct) {\n const rects = fitRects(\n fit,\n { x: 0, y: 0, width: image.width(), height: image.height() },\n rct\n );\n const [x, y, sx, sy] = rect2rect(rects.src, rects.dst);\n m3.translate(x.translateX, y.translateY);\n m3.scale(sx.scaleX, sy.scaleY);\n }\n const lm = ctx.Skia.Matrix();\n lm.concat(m3);\n processTransformProps(lm, imageShaderProps);\n let shader: SkShader;\n if (sampling && isCubicSampling(sampling)) {\n shader = image.makeShaderCubic(\n TileMode[enumKey(tx)],\n TileMode[enumKey(ty)],\n sampling.B,\n sampling.C,\n lm\n );\n } else {\n shader = image.makeShaderCubic(\n TileMode[enumKey(tx)],\n TileMode[enumKey(ty)],\n sampling?.filter ?? FilterMode.Linear,\n sampling?.mipmap ?? MipmapMode.None,\n lm\n );\n }\n ctx.shaders.push(shader);\n};\n\nconst declareBlend = (ctx: DrawingContext, props: BlendProps) => {\n \"worklet\";\n const blend = BlendMode[enumKey(props.mode as BlendProps[\"mode\"])];\n const shaders = ctx.shaders.splice(0, ctx.shaders.length);\n if (shaders.length > 0) {\n const composer = ctx.Skia.Shader.MakeBlend.bind(ctx.Skia.Shader, blend);\n ctx.shaders.push(composeDeclarations(shaders, composer));\n }\n};\n\nexport const isPushShader = (\n command: Command\n): command is Command<CommandType.PushShader> => {\n \"worklet\";\n return command.type === CommandType.PushShader;\n};\n\ntype Props = {\n [NodeType.Shader]: ShaderProps;\n [NodeType.ImageShader]: ImageShaderProps;\n [NodeType.ColorShader]: ColorProps;\n [NodeType.Turbulence]: TurbulenceProps;\n [NodeType.FractalNoise]: FractalNoiseProps;\n [NodeType.LinearGradient]: LinearGradientProps;\n [NodeType.RadialGradient]: RadialGradientProps;\n [NodeType.SweepGradient]: SweepGradientProps;\n [NodeType.TwoPointConicalGradient]: TwoPointConicalGradientProps;\n [NodeType.Blend]: BlendProps;\n};\n\ninterface PushShader<\n T extends keyof Props,\n> extends Command<CommandType.PushShader> {\n shaderType: T;\n props: Props[T];\n children: number;\n}\n\nconst isShader = <T extends keyof Props>(\n command: Command<CommandType.PushShader>,\n type: T\n): command is PushShader<T> => {\n \"worklet\";\n return command.shaderType === type;\n};\n\nexport const pushShader = (\n ctx: DrawingContext,\n command: Command<CommandType.PushShader>\n) => {\n \"worklet\";\n if (isShader(command, NodeType.Shader)) {\n declareShader(ctx, command.props, command.children);\n } else if (isShader(command, NodeType.ImageShader)) {\n declareImageShader(ctx, command.props);\n } else if (isShader(command, NodeType.ColorShader)) {\n declareColorShader(ctx, command.props);\n } else if (isShader(command, NodeType.Turbulence)) {\n declareTurbulenceShader(ctx, command.props);\n } else if (isShader(command, NodeType.FractalNoise)) {\n declareFractalNoiseShader(ctx, command.props);\n } else if (isShader(command, NodeType.LinearGradient)) {\n declareLinearGradientShader(ctx, command.props);\n } else if (isShader(command, NodeType.RadialGradient)) {\n declareRadialGradientShader(ctx, command.props);\n } else if (isShader(command, NodeType.SweepGradient)) {\n declareSweepGradientShader(ctx, command.props);\n } else if (isShader(command, NodeType.TwoPointConicalGradient)) {\n declareTwoPointConicalGradientShader(ctx, command.props);\n } else if (isShader(command, NodeType.Blend)) {\n declareBlend(ctx, command.props);\n } else {\n throw new Error(`Unknown shader type: ${command.shaderType}`);\n }\n};\n"],"mappings":"AAAA,SACEA,OAAO,EACPC,QAAQ,EACRC,OAAO,EACPC,YAAY,EACZC,oBAAoB,EACpBC,qBAAqB,EACrBC,SAAS,QACJ,oBAAoB;AAC3B,SAASC,QAAQ,QAAQ,oBAAoB;AAc7C,SACEC,SAAS,EACTC,UAAU,EACVC,eAAe,E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ientProps","processTransformProps","rect2rect","NodeType","BlendMode","FilterMode","isCubicSampling","MipmapMode","processUniforms","TileMode","composeDeclarations","CommandType","declareShader","ctx","props","children","source","uniforms","transform","m3","Skia","Matrix","shader","track","makeShaderWithChildren","shaders","splice","push","declareColorShader","color","Shader","MakeColor","declareFractalNoiseShader","freqX","freqY","octaves","seed","tileWidth","tileHeight","MakeFractalNoise","declareTwoPointConicalGradientShader","startR","endR","start","end","colors","positions","mode","localMatrix","flags","MakeTwoPointConicalGradient","declareRadialGradientShader","c","r","MakeRadialGradient","declareSweepGradientShader","MakeSweepGradient","x","y","declareLinearGradientShader","MakeLinearGradient","declareTurbulenceShader","MakeTurbulence","declareImageShader","fit","image","tx","ty","sampling","imageShaderProps","rct","rects","width","height","sx","sy","src","dst","translate","translateX","translateY","scale","scaleX","scaleY","lm","concat","makeShaderCubic","B","C","_sampling$filter","_sampling$mipmap","filter","Linear","mipmap","None","declareBlend","blend","length","composer","MakeBlend","bind","isPushShader","command","type","PushShader","isShader","shaderType","pushShader","ImageShader","ColorShader","Turbulence","FractalNoise","LinearGradient","RadialGradient","SweepGradient","TwoPointConicalGradient","Blend","Error"],"sources":["Shaders.ts"],"sourcesContent":["import {\n enumKey,\n fitRects,\n getRect,\n processColor,\n processGradientProps,\n processTransformProps,\n rect2rect,\n} from \"../../../dom/nodes\";\nimport { NodeType } from \"../../../dom/types\";\nimport type {\n BlendProps,\n ColorProps,\n FractalNoiseProps,\n ImageShaderProps,\n LinearGradientProps,\n RadialGradientProps,\n ShaderProps,\n SweepGradientProps,\n TurbulenceProps,\n TwoPointConicalGradientProps,\n} from \"../../../dom/types\";\nimport type { SkShader } from \"../../../skia/types\";\nimport {\n BlendMode,\n FilterMode,\n isCubicSampling,\n MipmapMode,\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\nconst declareShader = (\n ctx: DrawingContext,\n props: ShaderProps,\n children: number\n) => {\n \"worklet\";\n const { source, uniforms, ...transform } = props;\n const m3 = ctx.Skia.Matrix();\n processTransformProps(m3, transform);\n const shader = ctx.track(\n source.makeShaderWithChildren(\n processUniforms(source, uniforms),\n ctx.shaders.splice(0, children),\n m3\n )\n );\n ctx.shaders.push(shader);\n};\n\nconst declareColorShader = (ctx: DrawingContext, props: ColorProps) => {\n \"worklet\";\n const { color } = props;\n const shader = ctx.Skia.Shader.MakeColor(processColor(ctx.Skia, color));\n ctx.shaders.push(shader);\n};\n\nconst declareFractalNoiseShader = (\n ctx: DrawingContext,\n props: FractalNoiseProps\n) => {\n \"worklet\";\n const { freqX, freqY, octaves, seed, tileWidth, tileHeight } = props;\n const shader = ctx.Skia.Shader.MakeFractalNoise(\n freqX,\n freqY,\n octaves,\n seed,\n tileWidth,\n tileHeight\n );\n ctx.shaders.push(shader);\n};\n\nconst declareTwoPointConicalGradientShader = (\n ctx: DrawingContext,\n props: TwoPointConicalGradientProps\n) => {\n \"worklet\";\n const { startR, endR, start, end } = props;\n const { colors, positions, mode, localMatrix, flags } = processGradientProps(\n ctx.Skia,\n props\n );\n const shader = ctx.Skia.Shader.MakeTwoPointConicalGradient(\n start,\n startR,\n end,\n endR,\n colors,\n positions,\n mode,\n localMatrix,\n flags\n );\n ctx.shaders.push(shader);\n};\n\nconst declareRadialGradientShader = (\n ctx: DrawingContext,\n props: RadialGradientProps\n) => {\n \"worklet\";\n const { c, r } = props;\n const { colors, positions, mode, localMatrix, flags } = processGradientProps(\n ctx.Skia,\n props\n );\n const shader = ctx.Skia.Shader.MakeRadialGradient(\n c,\n r,\n colors,\n positions,\n mode,\n localMatrix,\n flags\n );\n ctx.shaders.push(shader);\n};\n\nconst declareSweepGradientShader = (\n ctx: DrawingContext,\n props: SweepGradientProps\n) => {\n \"worklet\";\n const { c, start, end } = props;\n const { colors, positions, mode, localMatrix, flags } = processGradientProps(\n ctx.Skia,\n props\n );\n const shader = ctx.Skia.Shader.MakeSweepGradient(\n c.x,\n c.y,\n colors,\n positions,\n mode,\n localMatrix,\n flags,\n start,\n end\n );\n ctx.shaders.push(shader);\n};\n\nconst declareLinearGradientShader = (\n ctx: DrawingContext,\n props: LinearGradientProps\n) => {\n \"worklet\";\n const { start, end } = props;\n const { colors, positions, mode, localMatrix, flags } = processGradientProps(\n ctx.Skia,\n props\n );\n const shader = ctx.Skia.Shader.MakeLinearGradient(\n start,\n end,\n colors,\n positions ?? null,\n mode,\n localMatrix,\n flags\n );\n ctx.shaders.push(shader);\n};\n\nconst declareTurbulenceShader = (\n ctx: DrawingContext,\n props: TurbulenceProps\n) => {\n \"worklet\";\n const { freqX, freqY, octaves, seed, tileWidth, tileHeight } = props;\n const shader = ctx.Skia.Shader.MakeTurbulence(\n freqX,\n freqY,\n octaves,\n seed,\n tileWidth,\n tileHeight\n );\n ctx.shaders.push(shader);\n};\n\nconst declareImageShader = (ctx: DrawingContext, props: ImageShaderProps) => {\n \"worklet\";\n const { fit, image, tx, ty, sampling, ...imageShaderProps } = props;\n if (!image) {\n return;\n }\n\n const rct = getRect(ctx.Skia, imageShaderProps);\n const m3 = ctx.Skia.Matrix();\n if (rct) {\n const rects = fitRects(\n fit,\n { x: 0, y: 0, width: image.width(), height: image.height() },\n rct\n );\n const [x, y, sx, sy] = rect2rect(rects.src, rects.dst);\n m3.translate(x.translateX, y.translateY);\n m3.scale(sx.scaleX, sy.scaleY);\n }\n const lm = ctx.Skia.Matrix();\n lm.concat(m3);\n processTransformProps(lm, imageShaderProps);\n let shader: SkShader;\n if (sampling && isCubicSampling(sampling)) {\n shader = ctx.track(\n image.makeShaderCubic(\n TileMode[enumKey(tx)],\n TileMode[enumKey(ty)],\n sampling.B,\n sampling.C,\n lm\n )\n );\n } else {\n shader = ctx.track(\n image.makeShaderCubic(\n TileMode[enumKey(tx)],\n TileMode[enumKey(ty)],\n sampling?.filter ?? FilterMode.Linear,\n sampling?.mipmap ?? MipmapMode.None,\n lm\n )\n );\n }\n ctx.shaders.push(shader);\n};\n\nconst declareBlend = (ctx: DrawingContext, props: BlendProps) => {\n \"worklet\";\n const blend = BlendMode[enumKey(props.mode as BlendProps[\"mode\"])];\n const shaders = ctx.shaders.splice(0, ctx.shaders.length);\n if (shaders.length > 0) {\n const composer = ctx.Skia.Shader.MakeBlend.bind(ctx.Skia.Shader, blend);\n ctx.shaders.push(composeDeclarations(shaders, composer));\n }\n};\n\nexport const isPushShader = (\n command: Command\n): command is Command<CommandType.PushShader> => {\n \"worklet\";\n return command.type === CommandType.PushShader;\n};\n\ntype Props = {\n [NodeType.Shader]: ShaderProps;\n [NodeType.ImageShader]: ImageShaderProps;\n [NodeType.ColorShader]: ColorProps;\n [NodeType.Turbulence]: TurbulenceProps;\n [NodeType.FractalNoise]: FractalNoiseProps;\n [NodeType.LinearGradient]: LinearGradientProps;\n [NodeType.RadialGradient]: RadialGradientProps;\n [NodeType.SweepGradient]: SweepGradientProps;\n [NodeType.TwoPointConicalGradient]: TwoPointConicalGradientProps;\n [NodeType.Blend]: BlendProps;\n};\n\ninterface PushShader<\n T extends keyof Props,\n> extends Command<CommandType.PushShader> {\n shaderType: T;\n props: Props[T];\n children: number;\n}\n\nconst isShader = <T extends keyof Props>(\n command: Command<CommandType.PushShader>,\n type: T\n): command is PushShader<T> => {\n \"worklet\";\n return command.shaderType === type;\n};\n\nexport const pushShader = (\n ctx: DrawingContext,\n command: Command<CommandType.PushShader>\n) => {\n \"worklet\";\n if (isShader(command, NodeType.Shader)) {\n declareShader(ctx, command.props, command.children);\n } else if (isShader(command, NodeType.ImageShader)) {\n declareImageShader(ctx, command.props);\n } else if (isShader(command, NodeType.ColorShader)) {\n declareColorShader(ctx, command.props);\n } else if (isShader(command, NodeType.Turbulence)) {\n declareTurbulenceShader(ctx, command.props);\n } else if (isShader(command, NodeType.FractalNoise)) {\n declareFractalNoiseShader(ctx, command.props);\n } else if (isShader(command, NodeType.LinearGradient)) {\n declareLinearGradientShader(ctx, command.props);\n } else if (isShader(command, NodeType.RadialGradient)) {\n declareRadialGradientShader(ctx, command.props);\n } else if (isShader(command, NodeType.SweepGradient)) {\n declareSweepGradientShader(ctx, command.props);\n } else if (isShader(command, NodeType.TwoPointConicalGradient)) {\n declareTwoPointConicalGradientShader(ctx, command.props);\n } else if (isShader(command, NodeType.Blend)) {\n declareBlend(ctx, command.props);\n } else {\n throw new Error(`Unknown shader type: ${command.shaderType}`);\n }\n};\n"],"mappings":"AAAA,SACEA,OAAO,EACPC,QAAQ,EACRC,OAAO,EACPC,YAAY,EACZC,oBAAoB,EACpBC,qBAAqB,EACrBC,SAAS,QACJ,oBAAoB;AAC3B,SAASC,QAAQ,QAAQ,oBAAoB;AAc7C,SACEC,SAAS,EACTC,UAAU,EACVC,eAAe,EACfC,UAAU,EACVC,eAAe,EACfC,QAAQ,QACH,qBAAqB;AAC5B,SAASC,mBAAmB,QAAQ,aAAa;AAEjD,SAASC,WAAW,QAAQ,SAAS;AAGrC,MAAMC,aAAa,GAAGA,CACpBC,GAAmB,EACnBC,KAAkB,EAClBC,QAAgB,KACb;EACH,SAAS;;EACT,MAAM;IAAEC,MAAM;IAAEC,QAAQ;IAAE,GAAGC;EAAU,CAAC,GAAGJ,KAAK;EAChD,MAAMK,EAAE,GAAGN,GAAG,CAACO,IAAI,CAACC,MAAM,CAAC,CAAC;EAC5BpB,qBAAqB,CAACkB,EAAE,EAAED,SAAS,CAAC;EACpC,MAAMI,MAAM,GAAGT,GAAG,CAACU,KAAK,CACtBP,MAAM,CAACQ,sBAAsB,CAC3BhB,eAAe,CAACQ,MAAM,EAAEC,QAAQ,CAAC,EACjCJ,GAAG,CAACY,OAAO,CAACC,MAAM,CAAC,CAAC,EAAEX,QAAQ,CAAC,EAC/BI,EACF,CACF,CAAC;EACDN,GAAG,CAACY,OAAO,CAACE,IAAI,CAACL,MAAM,CAAC;AAC1B,CAAC;AAED,MAAMM,kBAAkB,GAAGA,CAACf,GAAmB,EAAEC,KAAiB,KAAK;E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AAQ,CAAC+G,aAAa,CAAC,EAAE;IACpD3D,0BAA0B,CAAC1C,GAAG,EAAEyF,OAAO,CAACxF,KAAK,CAAC;EAChD,CAAC,MAAM,IAAI2F,QAAQ,CAACH,OAAO,EAAEnG,QAAQ,CAACgH,uBAAuB,CAAC,EAAE;IAC9D3E,oCAAoC,CAAC3B,GAAG,EAAEyF,OAAO,CAACxF,KAAK,CAAC;EAC1D,CAAC,MAAM,IAAI2F,QAAQ,CAACH,OAAO,EAAEnG,QAAQ,CAACiH,KAAK,CAAC,EAAE;IAC5CrB,YAAY,CAAClF,GAAG,EAAEyF,OAAO,CAACxF,KAAK,CAAC;EAClC,CAAC,MAAM;IACL,MAAM,IAAIuG,KAAK,CAAC,wBAAwBf,OAAO,CAACI,UAAU,EAAE,CAAC;EAC/D;AACF,CAAC","ignoreList":[]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
2
2
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
3
3
|
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
4
|
-
import { Recorder } from "./Recorder/Recorder";
|
|
4
|
+
import { Recorder, disposeRecording } from "./Recorder/Recorder";
|
|
5
5
|
import { visit } from "./Recorder/Visitor";
|
|
6
6
|
import { replay } from "./Recorder/Player";
|
|
7
7
|
import { createDrawingContext } from "./Recorder/DrawingContext";
|
|
@@ -30,7 +30,14 @@ export class Container {
|
|
|
30
30
|
throw new Error("No recording to draw");
|
|
31
31
|
}
|
|
32
32
|
const ctx = createDrawingContext(this.Skia, this.recording.paintPool, canvas);
|
|
33
|
-
|
|
33
|
+
try {
|
|
34
|
+
replay(ctx, this.recording.commands);
|
|
35
|
+
} finally {
|
|
36
|
+
// Frame-scoped objects created during the replay are no longer needed
|
|
37
|
+
// once drawn — delete them, otherwise they leak on Web where the GC
|
|
38
|
+
// cannot see WASM memory.
|
|
39
|
+
ctx.dispose();
|
|
40
|
+
}
|
|
34
41
|
}
|
|
35
42
|
}
|
|
36
43
|
export class StaticContainer extends Container {
|
|
@@ -38,7 +45,23 @@ export class StaticContainer extends Container {
|
|
|
38
45
|
super(Skia);
|
|
39
46
|
this.nativeId = nativeId;
|
|
40
47
|
}
|
|
48
|
+
unmount() {
|
|
49
|
+
super.unmount();
|
|
50
|
+
if (this.recording) {
|
|
51
|
+
disposeRecording(this.recording);
|
|
52
|
+
this.recording = null;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
41
55
|
redraw() {
|
|
56
|
+
if (this.unmounted) {
|
|
57
|
+
// The unmount commit triggers a last redraw — recording it would
|
|
58
|
+
// resurrect a recording for a container that has just disposed it.
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
if (this.recording) {
|
|
62
|
+
disposeRecording(this.recording);
|
|
63
|
+
this.recording = null;
|
|
64
|
+
}
|
|
42
65
|
const recorder = new Recorder();
|
|
43
66
|
visit(recorder, this.root);
|
|
44
67
|
this.recording = recorder.getRecording();
|
|
@@ -50,6 +73,9 @@ export class StaticContainer extends Container {
|
|
|
50
73
|
const picture = rec.finishRecordingAsPicture();
|
|
51
74
|
rec.dispose();
|
|
52
75
|
SkiaViewApi.setJsiProperty(this.nativeId, "picture", picture);
|
|
76
|
+
// The view keeps its own reference to the picture it displays; this
|
|
77
|
+
// one is renderer-owned and disposed with the recording.
|
|
78
|
+
this.recording.lastPicture = picture;
|
|
53
79
|
}
|
|
54
80
|
}
|
|
55
81
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["Recorder","visit","replay","createDrawingContext","Container","constructor","Skia","_defineProperty","root","_root","value","mount","unmounted","unmount","drawOnCanvas","canvas","recording","Error","ctx","paintPool","commands","StaticContainer","nativeId","redraw","recorder","getRecording","isOnScreen","rec","PictureRecorder","beginRecording","picture","finishRecordingAsPicture","
|
|
1
|
+
{"version":3,"names":["Recorder","disposeRecording","visit","replay","createDrawingContext","Container","constructor","Skia","_defineProperty","root","_root","value","mount","unmounted","unmount","drawOnCanvas","canvas","recording","Error","ctx","paintPool","commands","dispose","StaticContainer","nativeId","redraw","recorder","getRecording","isOnScreen","rec","PictureRecorder","beginRecording","picture","finishRecordingAsPicture","SkiaViewApi","setJsiProperty","lastPicture"],"sources":["StaticContainer.ts"],"sourcesContent":["import type { Skia, SkCanvas } from \"../skia/types\";\n\nimport type { Node } from \"./Node\";\nimport type { Recording } from \"./Recorder/Recorder\";\nimport { Recorder, disposeRecording } from \"./Recorder/Recorder\";\nimport { visit } from \"./Recorder/Visitor\";\nimport { replay } from \"./Recorder/Player\";\nimport { createDrawingContext } from \"./Recorder/DrawingContext\";\n\nimport \"../views/api\";\n\nexport abstract class Container {\n private _root: Node[] = [];\n protected recording: Recording | null = null;\n protected unmounted = false;\n\n constructor(protected Skia: Skia) {}\n\n get root() {\n return this._root;\n }\n\n set root(value: Node[]) {\n this._root = value;\n }\n\n mount() {\n this.unmounted = false;\n }\n\n unmount() {\n this.unmounted = true;\n }\n\n drawOnCanvas(canvas: SkCanvas) {\n if (!this.recording) {\n throw new Error(\"No recording to draw\");\n }\n const ctx = createDrawingContext(\n this.Skia,\n this.recording.paintPool,\n canvas\n );\n try {\n replay(ctx, this.recording.commands);\n } finally {\n // Frame-scoped objects created during the replay are no longer needed\n // once drawn — delete them, otherwise they leak on Web where the GC\n // cannot see WASM memory.\n ctx.dispose();\n }\n }\n\n abstract redraw(): void;\n}\n\nexport class StaticContainer extends Container {\n constructor(\n Skia: Skia,\n private nativeId: number\n ) {\n super(Skia);\n }\n\n unmount() {\n super.unmount();\n if (this.recording) {\n disposeRecording(this.recording);\n this.recording = null;\n }\n }\n\n redraw() {\n if (this.unmounted) {\n // The unmount commit triggers a last redraw — recording it would\n // resurrect a recording for a container that has just disposed it.\n return;\n }\n if (this.recording) {\n disposeRecording(this.recording);\n this.recording = null;\n }\n const recorder = new Recorder();\n visit(recorder, this.root);\n this.recording = recorder.getRecording();\n const isOnScreen = this.nativeId !== -1;\n if (isOnScreen) {\n const rec = this.Skia.PictureRecorder();\n const canvas = rec.beginRecording();\n this.drawOnCanvas(canvas);\n const picture = rec.finishRecordingAsPicture();\n rec.dispose();\n SkiaViewApi.setJsiProperty(this.nativeId, \"picture\", picture);\n // The view keeps its own reference to the picture it displays; this\n // one is renderer-owned and disposed with the recording.\n this.recording.lastPicture = picture;\n }\n }\n}\n"],"mappings":";;;AAIA,SAASA,QAAQ,EAAEC,gBAAgB,QAAQ,qBAAqB;AAChE,SAASC,KAAK,QAAQ,oBAAoB;AAC1C,SAASC,MAAM,QAAQ,mBAAmB;AAC1C,SAASC,oBAAoB,QAAQ,2BAA2B;AAEhE,OAAO,cAAc;AAErB,OAAO,MAAeC,SAAS,CAAC;EAK9BC,WAAWA,CAAWC,IAAU,EAAE;IAAA,KAAZA,IAAU,GAAVA,IAAU;IAAAC,eAAA,gBAJR,EAAE;IAAAA,eAAA,oBACc,IAAI;IAAAA,eAAA,oBACtB,KAAK;EAEQ;EAEnC,IAAIC,IAAIA,CAAA,EAAG;IACT,OAAO,IAAI,CAACC,KAAK;EACnB;EAEA,IAAID,IAAIA,CAACE,KAAa,EAAE;IACtB,IAAI,CAACD,KAAK,GAAGC,KAAK;EACpB;EAEAC,KAAKA,CAAA,EAAG;IACN,IAAI,CAACC,SAAS,GAAG,KAAK;EACxB;EAEAC,OAAOA,CAAA,EAAG;IACR,IAAI,CAACD,SAAS,GAAG,IAAI;EACvB;EAEAE,YAAYA,CAACC,MAAgB,EAAE;IAC7B,IAAI,CAAC,IAAI,CAACC,SAAS,EAAE;MACnB,MAAM,IAAIC,KAAK,CAAC,sBAAsB,CAA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CAAC,CAAC;MACnC,IAAI,CAAChB,YAAY,CAACC,MAAM,CAAC;MACzB,MAAMgB,OAAO,GAAGH,GAAG,CAACI,wBAAwB,CAAC,CAAC;MAC9CJ,GAAG,CAACP,OAAO,CAAC,CAAC;MACbY,WAAW,CAACC,cAAc,CAAC,IAAI,CAACX,QAAQ,EAAE,SAAS,EAAEQ,OAAO,CAAC;MAC7D;MACA;MACA,IAAI,CAACf,SAAS,CAACmB,WAAW,GAAGJ,OAAO;IACtC;EACF;AACF","ignoreList":[]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export const __esModule: boolean;
|
|
2
2
|
export class JsiSkFont extends _Host.HostObject {
|
|
3
3
|
constructor(CanvasKit: any, ref: any);
|
|
4
|
-
measureText(
|
|
4
|
+
measureText(text: any, paint: any): _JsiSkRect.JsiSkRect;
|
|
5
5
|
getTextWidth(text: any, paint: any): any;
|
|
6
6
|
getMetrics(): {
|
|
7
7
|
ascent: any;
|
|
@@ -12,5 +12,7 @@ export class JsiSkParagraph extends _Host.HostObject {
|
|
|
12
12
|
getRectsForPlaceholders(): any;
|
|
13
13
|
getRectsForRange(start: any, end: any): any;
|
|
14
14
|
getLineMetrics(): any;
|
|
15
|
+
getPath(_lineNumber: any): jest.Mock<any, any, any>;
|
|
16
|
+
extendedVisit(_visitor: any): jest.Mock<any, any, any>;
|
|
15
17
|
}
|
|
16
18
|
import _Host = require("./Host");
|
|
@@ -5,10 +5,10 @@ declare class ReanimatedContainer extends _StaticContainer.Container {
|
|
|
5
5
|
constructor(Skia: any, nativeId: any);
|
|
6
6
|
nativeId: any;
|
|
7
7
|
mapperId: any;
|
|
8
|
-
redraw(): void;
|
|
9
8
|
recording: {
|
|
10
9
|
commands: any;
|
|
11
10
|
paintPool: never[];
|
|
12
|
-
} | undefined;
|
|
11
|
+
} | null | undefined;
|
|
12
|
+
redraw(): void;
|
|
13
13
|
}
|
|
14
14
|
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export const __esModule: boolean;
|
|
2
|
+
/**
|
|
3
|
+
* Wraps a Skia instance so that every object created through its factories is
|
|
4
|
+
* collected and deleted when the scope is disposed. The renderer only keeps
|
|
5
|
+
* the objects it creates alive for the duration of a frame: once the frame
|
|
6
|
+
* has been recorded they can be deleted. This is required on Web where
|
|
7
|
+
* CanvasKit objects live in WASM memory that the JS garbage collector does
|
|
8
|
+
* not perceive, so it (almost) never reclaims them on its own.
|
|
9
|
+
*
|
|
10
|
+
* Objects passed in via props are user-owned: they are not created through
|
|
11
|
+
* this facade and are therefore never tracked nor disposed.
|
|
12
|
+
*/
|
|
13
|
+
export function createFrameScope(Skia: any): {
|
|
14
|
+
Skia: any;
|
|
15
|
+
track: (value: any) => any;
|
|
16
|
+
dispose: () => void;
|
|
17
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export const __esModule: boolean;
|
|
2
|
+
/**
|
|
3
|
+
* No-op on native. The JSI wrappers report the size of the native objects
|
|
4
|
+
* they hold to the garbage collector (setExternalMemoryPressure), so the GC
|
|
5
|
+
* is aware of the real cost of the objects the renderer creates and reclaims
|
|
6
|
+
* them on its own. The tracking scope is only needed on Web, where CanvasKit
|
|
7
|
+
* objects live in WASM memory the GC cannot see (see FrameScope.ts).
|
|
8
|
+
*/
|
|
9
|
+
export function createFrameScope(Skia: any): {
|
|
10
|
+
Skia: any;
|
|
11
|
+
track: (value: any) => any;
|
|
12
|
+
dispose: () => void;
|
|
13
|
+
};
|
|
@@ -13,10 +13,10 @@ export class Container {
|
|
|
13
13
|
export class StaticContainer extends Container {
|
|
14
14
|
constructor(Skia: any, nativeId: any);
|
|
15
15
|
nativeId: any;
|
|
16
|
-
redraw(): void;
|
|
17
16
|
recording: {
|
|
18
17
|
commands: any;
|
|
19
18
|
paintPool: never[];
|
|
20
19
|
animationValues: any;
|
|
21
|
-
} | undefined;
|
|
20
|
+
} | null | undefined;
|
|
21
|
+
redraw(): void;
|
|
22
22
|
}
|
|
@@ -195,6 +195,7 @@ export function Mock(CanvasKit: any): {
|
|
|
195
195
|
rrect: (r: any, rx: any, ry: any) => import("../../..").SkRRect;
|
|
196
196
|
processTransform2d: (transforms: any) => any;
|
|
197
197
|
isRNModule: (mod: any) => mod is number;
|
|
198
|
+
unwrapModule: (mod: any) => any;
|
|
198
199
|
ColorSpace: {
|
|
199
200
|
SRGB: string;
|
|
200
201
|
DisplayP3: string;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export class JsiSkFont extends HostObject {
|
|
2
2
|
constructor(CanvasKit: any, ref: any);
|
|
3
|
-
measureText(
|
|
3
|
+
measureText(text: any, paint: any): JsiSkRect;
|
|
4
4
|
getTextWidth(text: any, paint: any): any;
|
|
5
5
|
getMetrics(): {
|
|
6
6
|
ascent: any;
|
|
@@ -11,5 +11,7 @@ export class JsiSkParagraph extends HostObject {
|
|
|
11
11
|
getRectsForPlaceholders(): any;
|
|
12
12
|
getRectsForRange(start: any, end: any): any;
|
|
13
13
|
getLineMetrics(): any;
|
|
14
|
+
getPath(_lineNumber: any): jest.Mock<any, any, any>;
|
|
15
|
+
extendedVisit(_visitor: any): jest.Mock<any, any, any>;
|
|
14
16
|
}
|
|
15
17
|
import { HostObject } from "./Host";
|
|
@@ -4,11 +4,11 @@ declare class ReanimatedContainer extends Container {
|
|
|
4
4
|
constructor(Skia: any, nativeId: any);
|
|
5
5
|
nativeId: any;
|
|
6
6
|
mapperId: any;
|
|
7
|
-
redraw(): void;
|
|
8
7
|
recording: {
|
|
9
8
|
commands: any;
|
|
10
9
|
paintPool: never[];
|
|
11
|
-
} | undefined;
|
|
10
|
+
} | null | undefined;
|
|
11
|
+
redraw(): void;
|
|
12
12
|
}
|
|
13
13
|
import { Container } from "./StaticContainer";
|
|
14
14
|
export {};
|
|
@@ -12,10 +12,10 @@ export class Container {
|
|
|
12
12
|
export class StaticContainer extends Container {
|
|
13
13
|
constructor(Skia: any, nativeId: any);
|
|
14
14
|
nativeId: any;
|
|
15
|
-
redraw(): void;
|
|
16
15
|
recording: {
|
|
17
16
|
commands: any;
|
|
18
17
|
paintPool: never[];
|
|
19
18
|
animationValues: any;
|
|
20
|
-
} | undefined;
|
|
19
|
+
} | null | undefined;
|
|
20
|
+
redraw(): void;
|
|
21
21
|
}
|
|
@@ -1,18 +1,33 @@
|
|
|
1
|
+
import { FontSlant, FontWeight } from "../types";
|
|
1
2
|
import type { DataModule, DataSourceParam, SkFontMgr } from "../types";
|
|
2
3
|
import type { SkTypefaceFontProvider } from "../types/Paragraph/TypefaceFontProvider";
|
|
3
4
|
/**
|
|
4
5
|
* Returns a Skia Font object
|
|
5
6
|
* */
|
|
6
7
|
export declare const useFont: (font: DataSourceParam, size?: number, onError?: (err: Error) => void) => import("../types").SkFont | null;
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
/**
|
|
9
|
+
* React Native style font slant, as found in the `fontStyle` property of
|
|
10
|
+
* `TextStyle`. The Skia {@link FontSlant} enum is accepted as well.
|
|
11
|
+
*/
|
|
12
|
+
export type RNFontSlant = "normal" | "italic" | "oblique" | FontSlant;
|
|
13
|
+
/**
|
|
14
|
+
* React Native style font weight, as found in the `fontWeight` property of
|
|
15
|
+
* `TextStyle`. Numeric weights such as the {@link FontWeight} enum values
|
|
16
|
+
* used by the Paragraph API are accepted as well.
|
|
17
|
+
*/
|
|
18
|
+
export type RNFontWeight = "normal" | "bold" | "100" | "200" | "300" | "400" | "500" | "600" | "700" | "800" | "900" | FontWeight;
|
|
19
|
+
/**
|
|
20
|
+
* Font style accepted by {@link matchFont}.
|
|
21
|
+
* `fontStyle` and `fontWeight` accept both the React Native string values
|
|
22
|
+
* and the Skia enums ({@link FontSlant} and {@link FontWeight}), so the same
|
|
23
|
+
* values can be shared with the Paragraph API.
|
|
24
|
+
*/
|
|
25
|
+
export interface RNFontStyle {
|
|
10
26
|
fontFamily: string;
|
|
11
27
|
fontSize: number;
|
|
12
|
-
fontStyle:
|
|
13
|
-
fontWeight:
|
|
28
|
+
fontStyle: RNFontSlant;
|
|
29
|
+
fontWeight: RNFontWeight;
|
|
14
30
|
}
|
|
15
31
|
export declare const matchFont: (inputStyle?: Partial<RNFontStyle>, fontMgr?: SkFontMgr) => import("../types").SkFont;
|
|
16
32
|
export declare const listFontFamilies: (fontMgr?: SkFontMgr) => string[];
|
|
17
33
|
export declare const useFonts: (sources: Record<string, DataModule[]>) => SkTypefaceFontProvider | null;
|
|
18
|
-
export {};
|
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
import type { SkJSIInstance } from "../JsiInstance";
|
|
2
2
|
export type SkData = SkJSIInstance<"Data">;
|
|
3
3
|
type RNModule = number;
|
|
4
|
-
type ESModule = {
|
|
5
|
-
__esModule: true;
|
|
6
|
-
default: string;
|
|
7
|
-
};
|
|
8
4
|
type MetroAsset = {
|
|
9
5
|
uri: string;
|
|
10
6
|
width: number;
|
|
11
7
|
height: number;
|
|
12
8
|
};
|
|
9
|
+
type ESModule = {
|
|
10
|
+
__esModule: true;
|
|
11
|
+
default: RNModule | MetroAsset | string;
|
|
12
|
+
};
|
|
13
13
|
export type DataModule = RNModule | ESModule | MetroAsset;
|
|
14
14
|
export type DataSource = DataModule | string | Uint8Array;
|
|
15
15
|
export type DataSourceParam = DataSource | null | undefined;
|
|
16
16
|
export declare const isRNModule: (mod: DataModule) => mod is RNModule;
|
|
17
|
+
export declare const unwrapModule: (mod: DataModule) => RNModule | MetroAsset | string;
|
|
17
18
|
export {};
|