@shopify/react-native-skia 2.7.0 → 2.8.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/cpp/api/JsiSkParagraph.h +114 -0
- package/lib/commonjs/external/reanimated/useVideoLoading.js +11 -2
- package/lib/commonjs/external/reanimated/useVideoLoading.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/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/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/external/reanimated/useVideoLoading.js +12 -2
- package/lib/module/external/reanimated/useVideoLoading.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/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/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/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/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/types/Paragraph/Paragraph.d.ts +62 -0
- 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 +1 -1
- package/src/external/reanimated/useVideoLoading.ts +12 -2
- package/src/skia/core/SVG.web.ts +5 -14
- package/src/skia/types/Paragraph/Paragraph.ts +67 -0
- package/src/skia/web/Host.ts +7 -0
- 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":["HostObject","getEnum","JsiSkColorFilter","JsiSkImageFilter","JsiSkMaskFilter","JsiSkPathEffect","JsiSkShader","kBlendModePlusDarker","kBlendModePlusLighter","plusDarkerSkSL","plusLighterSkSL","blenderCache","WeakMap","getBlenderCache","ck","cache","get","plusDarker","plusLighter","set","JsiSkPaint","constructor","CanvasKit","ref","copy","assign","paint","reset","Paint","getAlphaf","getColor","getStrokeCap","value","getStrokeJoin","getStrokeMiter","getStrokeWidth","setAlphaf","alpha","setAntiAlias","aa","setDither","dither","setBlendMode","blendMode","effect","RuntimeEffect","MakeForBlender","makeBlender","setBlender","setColor","color","setColorFilter","filter","fromValue","setImageFilter","setMaskFilter","setPathEffect","setShader","shader","setStrokeCap","cap","setStrokeJoin","join","setStrokeMiter","limit","setStrokeWidth","width","setStyle","style"],"sources":["JsiSkPaint.ts"],"sourcesContent":["import type { Blender, CanvasKit, Paint } from \"canvaskit-wasm\";\n\nimport type {\n StrokeJoin,\n BlendMode,\n SkColor,\n SkColorFilter,\n SkImageFilter,\n SkPaint,\n SkShader,\n StrokeCap,\n PaintStyle,\n SkMaskFilter,\n SkPathEffect,\n} from \"../types\";\n\nimport { HostObject, getEnum } from \"./Host\";\nimport { JsiSkColorFilter } from \"./JsiSkColorFilter\";\nimport { JsiSkImageFilter } from \"./JsiSkImageFilter\";\nimport { JsiSkMaskFilter } from \"./JsiSkMaskFilter\";\nimport { JsiSkPathEffect } from \"./JsiSkPathEffect\";\nimport { JsiSkShader } from \"./JsiSkShader\";\n\n// Custom blend mode values (must match TypeScript BlendMode enum)\nconst kBlendModePlusDarker = 1001;\nconst kBlendModePlusLighter = 1002;\n\n// SkSL for PlusDarker blend mode\n// Formula: rc = max(0, 1 - ((1-dst) + (1-src))) = max(0, src + dst - 1)\nconst plusDarkerSkSL = `\n vec4 main(vec4 src, vec4 dst) {\n float outAlpha = src.a + dst.a - src.a * dst.a;\n vec3 srcUnpremul = src.a > 0.0 ? src.rgb / src.a : vec3(0.0);\n vec3 dstUnpremul = dst.a > 0.0 ? dst.rgb / dst.a : vec3(0.0);\n vec3 blended = max(vec3(0.0), srcUnpremul + dstUnpremul - vec3(1.0));\n return vec4(blended * outAlpha, outAlpha);\n }\n`;\n\n// SkSL for PlusLighter blend mode\n// Formula: rc = min(1, dst + src)\nconst plusLighterSkSL = `\n vec4 main(vec4 src, vec4 dst) {\n float outAlpha = src.a + dst.a - src.a * dst.a;\n vec3 srcUnpremul = src.a > 0.0 ? src.rgb / src.a : vec3(0.0);\n vec3 dstUnpremul = dst.a > 0.0 ? dst.rgb / dst.a : vec3(0.0);\n vec3 blended = min(vec3(1.0), srcUnpremul + dstUnpremul);\n return vec4(blended * outAlpha, outAlpha);\n }\n`;\n\n// Cache for custom blenders per CanvasKit instance\n// Using WeakMap ensures blenders are cleaned up when CanvasKit instance is garbage collected\ninterface BlenderCache {\n plusDarker: Blender | null;\n plusLighter: Blender | null;\n}\nconst blenderCache = new WeakMap<CanvasKit, BlenderCache>();\n\nconst getBlenderCache = (ck: CanvasKit): BlenderCache => {\n let cache = blenderCache.get(ck);\n if (!cache) {\n cache = { plusDarker: null, plusLighter: null };\n blenderCache.set(ck, cache);\n }\n return cache;\n};\n\nexport class JsiSkPaint extends HostObject<Paint, \"Paint\"> implements SkPaint {\n constructor(CanvasKit: CanvasKit, ref: Paint) {\n super(CanvasKit, ref, \"Paint\");\n }\n\n copy() {\n return new JsiSkPaint(this.CanvasKit, this.ref.copy());\n }\n\n assign(paint: JsiSkPaint) {\n this.ref = paint.ref.copy();\n }\n\n reset() {\n this.ref = new this.CanvasKit.Paint();\n }\n\n getAlphaf() {\n return this.getColor()[3];\n }\n\n getColor() {\n return this.ref.getColor();\n }\n\n getStrokeCap() {\n return this.ref.getStrokeCap().value;\n }\n\n getStrokeJoin() {\n return this.ref.getStrokeJoin().value;\n }\n\n getStrokeMiter() {\n return this.ref.getStrokeMiter();\n }\n\n getStrokeWidth() {\n return this.ref.getStrokeWidth();\n }\n\n setAlphaf(alpha: number) {\n this.ref.setAlphaf(alpha);\n }\n\n setAntiAlias(aa: boolean) {\n this.ref.setAntiAlias(aa);\n }\n\n setDither(dither: boolean) {\n this.ref.setDither(dither);\n }\n\n setBlendMode(blendMode: BlendMode) {\n if (blendMode === kBlendModePlusDarker) {\n // Use custom PlusDarker blender via SkRuntimeEffect\n const cache = getBlenderCache(this.CanvasKit);\n if (!cache.plusDarker) {\n const effect =\n this.CanvasKit.RuntimeEffect.MakeForBlender(plusDarkerSkSL);\n if (effect) {\n cache.plusDarker = effect.makeBlender([]);\n }\n }\n if (cache.plusDarker) {\n this.ref.setBlender(cache.plusDarker);\n }\n } else if (blendMode === kBlendModePlusLighter) {\n // Use custom PlusLighter blender via SkRuntimeEffect\n const cache = getBlenderCache(this.CanvasKit);\n if (!cache.plusLighter) {\n const effect =\n this.CanvasKit.RuntimeEffect.MakeForBlender(plusLighterSkSL);\n if (effect) {\n cache.plusLighter = effect.makeBlender([]);\n }\n }\n if (cache.plusLighter) {\n this.ref.setBlender(cache.plusLighter);\n }\n } else {\n this.ref.setBlendMode(getEnum(this.CanvasKit, \"BlendMode\", blendMode));\n }\n }\n\n setColor(color: SkColor) {\n this.ref.setColor(color);\n }\n\n setColorFilter(filter: SkColorFilter | null) {\n this.ref.setColorFilter(filter ? JsiSkColorFilter.fromValue(filter) : null);\n }\n\n setImageFilter(filter: SkImageFilter | null) {\n this.ref.setImageFilter(filter ? JsiSkImageFilter.fromValue(filter) : null);\n }\n\n setMaskFilter(filter: SkMaskFilter | null) {\n this.ref.setMaskFilter(filter ? JsiSkMaskFilter.fromValue(filter) : null);\n }\n\n setPathEffect(effect: SkPathEffect | null) {\n this.ref.setPathEffect(effect ? JsiSkPathEffect.fromValue(effect) : null);\n }\n\n setShader(shader: SkShader | null) {\n this.ref.setShader(shader ? JsiSkShader.fromValue(shader) : null);\n }\n\n setStrokeCap(cap: StrokeCap) {\n this.ref.setStrokeCap(getEnum(this.CanvasKit, \"StrokeCap\", cap));\n }\n\n setStrokeJoin(join: StrokeJoin) {\n this.ref.setStrokeJoin(getEnum(this.CanvasKit, \"StrokeJoin\", join));\n }\n\n setStrokeMiter(limit: number) {\n this.ref.setStrokeMiter(limit);\n }\n\n setStrokeWidth(width: number) {\n this.ref.setStrokeWidth(width);\n }\n\n setStyle(style: PaintStyle) {\n this.ref.setStyle({ value: style });\n }\n}\n"],"mappings":"AAgBA,SAASA,UAAU,EAAEC,OAAO,QAAQ,QAAQ;AAC5C,SAASC,gBAAgB,QAAQ,oBAAoB;AACrD,SAASC,gBAAgB,QAAQ,oBAAoB;AACrD,SAASC,eAAe,QAAQ,mBAAmB;AACnD,SAASC,eAAe,QAAQ,mBAAmB;AACnD,SAASC,WAAW,QAAQ,eAAe;;AAE3C;AACA,MAAMC,oBAAoB,GAAG,IAAI;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GvC,eAAe,CAACgD,SAAS,CAACT,MAAM,CAAC,GAAG,IAAI,CAAC;EAC3E;EAEAa,SAASA,CAACC,MAAuB,EAAE;IACjC,IAAI,CAACnC,GAAG,CAACkC,SAAS,CAACC,MAAM,GAAGpD,WAAW,CAAC+C,SAAS,CAACK,MAAM,CAAC,GAAG,IAAI,CAAC;EACnE;EAEAC,YAAYA,CAACC,GAAc,EAAE;IAC3B,IAAI,CAACrC,GAAG,CAACoC,YAAY,CAAC1D,OAAO,CAAC,IAAI,CAACqB,SAAS,EAAE,WAAW,EAAEsC,GAAG,CAAC,CAAC;EAClE;EAEAC,aAAaA,CAACC,IAAgB,EAAE;IAC9B,IAAI,CAACvC,GAAG,CAACsC,aAAa,CAAC5D,OAAO,CAAC,IAAI,CAACqB,SAAS,EAAE,YAAY,EAAEwC,IAAI,CAAC,CAAC;EACrE;EAEAC,cAAcA,CAACC,KAAa,EAAE;IAC5B,IAAI,CAACzC,GAAG,CAACwC,cAAc,CAACC,KAAK,CAAC;EAChC;EAEAC,cAAcA,CAACC,KAAa,EAAE;IAC5B,IAAI,CAAC3C,GAAG,CAAC0C,cAAc,CAACC,KAAK,CAAC;EAChC;EAEAC,QAAQA,CAACC,KAAiB,EAAE;IAC1B,IAAI,CAAC7C,GAAG,CAAC4C,QAAQ,CAAC;MAAEnC,KAAK,EAAEoC;IAAM,CAAC,CAAC;EACrC;AACF","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["HostObject","getEnum","JsiSkColorFilter","JsiSkImageFilter","JsiSkMaskFilter","JsiSkPathEffect","JsiSkShader","kBlendModePlusDarker","kBlendModePlusLighter","plusDarkerSkSL","plusLighterSkSL","blenderCache","WeakMap","getBlenderCache","ck","cache","get","plusDarker","plusLighter","set","JsiSkPaint","constructor","CanvasKit","ref","copy","assign","paint","previous","delete","reset","Paint","getAlphaf","getColor","getStrokeCap","value","getStrokeJoin","getStrokeMiter","getStrokeWidth","setAlphaf","alpha","setAntiAlias","aa","setDither","dither","setBlendMode","blendMode","effect","RuntimeEffect","MakeForBlender","makeBlender","setBlender","setColor","color","setColorFilter","filter","fromValue","setImageFilter","setMaskFilter","setPathEffect","setShader","shader","setStrokeCap","cap","setStrokeJoin","join","setStrokeMiter","limit","setStrokeWidth","width","setStyle","style"],"sources":["JsiSkPaint.ts"],"sourcesContent":["import type { Blender, CanvasKit, Paint } from \"canvaskit-wasm\";\n\nimport type {\n StrokeJoin,\n BlendMode,\n SkColor,\n SkColorFilter,\n SkImageFilter,\n SkPaint,\n SkShader,\n StrokeCap,\n PaintStyle,\n SkMaskFilter,\n SkPathEffect,\n} from \"../types\";\n\nimport { HostObject, getEnum } from \"./Host\";\nimport { JsiSkColorFilter } from \"./JsiSkColorFilter\";\nimport { JsiSkImageFilter } from \"./JsiSkImageFilter\";\nimport { JsiSkMaskFilter } from \"./JsiSkMaskFilter\";\nimport { JsiSkPathEffect } from \"./JsiSkPathEffect\";\nimport { JsiSkShader } from \"./JsiSkShader\";\n\n// Custom blend mode values (must match TypeScript BlendMode enum)\nconst kBlendModePlusDarker = 1001;\nconst kBlendModePlusLighter = 1002;\n\n// SkSL for PlusDarker blend mode\n// Formula: rc = max(0, 1 - ((1-dst) + (1-src))) = max(0, src + dst - 1)\nconst plusDarkerSkSL = `\n vec4 main(vec4 src, vec4 dst) {\n float outAlpha = src.a + dst.a - src.a * dst.a;\n vec3 srcUnpremul = src.a > 0.0 ? src.rgb / src.a : vec3(0.0);\n vec3 dstUnpremul = dst.a > 0.0 ? dst.rgb / dst.a : vec3(0.0);\n vec3 blended = max(vec3(0.0), srcUnpremul + dstUnpremul - vec3(1.0));\n return vec4(blended * outAlpha, outAlpha);\n }\n`;\n\n// SkSL for PlusLighter blend mode\n// Formula: rc = min(1, dst + src)\nconst plusLighterSkSL = `\n vec4 main(vec4 src, vec4 dst) {\n float outAlpha = src.a + dst.a - src.a * dst.a;\n vec3 srcUnpremul = src.a > 0.0 ? src.rgb / src.a : vec3(0.0);\n vec3 dstUnpremul = dst.a > 0.0 ? dst.rgb / dst.a : vec3(0.0);\n vec3 blended = min(vec3(1.0), srcUnpremul + dstUnpremul);\n return vec4(blended * outAlpha, outAlpha);\n }\n`;\n\n// Cache for custom blenders per CanvasKit instance\n// Using WeakMap ensures blenders are cleaned up when CanvasKit instance is garbage collected\ninterface BlenderCache {\n plusDarker: Blender | null;\n plusLighter: Blender | null;\n}\nconst blenderCache = new WeakMap<CanvasKit, BlenderCache>();\n\nconst getBlenderCache = (ck: CanvasKit): BlenderCache => {\n let cache = blenderCache.get(ck);\n if (!cache) {\n cache = { plusDarker: null, plusLighter: null };\n blenderCache.set(ck, cache);\n }\n return cache;\n};\n\nexport class JsiSkPaint extends HostObject<Paint, \"Paint\"> implements SkPaint {\n constructor(CanvasKit: CanvasKit, ref: Paint) {\n super(CanvasKit, ref, \"Paint\");\n }\n\n copy() {\n return new JsiSkPaint(this.CanvasKit, this.ref.copy());\n }\n\n assign(paint: JsiSkPaint) {\n const previous = this.ref;\n this.ref = paint.ref.copy();\n // The replaced ref is a WASM object the GC will not reclaim.\n previous.delete();\n }\n\n reset() {\n const previous = this.ref;\n this.ref = new this.CanvasKit.Paint();\n previous.delete();\n }\n\n getAlphaf() {\n return this.getColor()[3];\n }\n\n getColor() {\n return this.ref.getColor();\n }\n\n getStrokeCap() {\n return this.ref.getStrokeCap().value;\n }\n\n getStrokeJoin() {\n return this.ref.getStrokeJoin().value;\n }\n\n getStrokeMiter() {\n return this.ref.getStrokeMiter();\n }\n\n getStrokeWidth() {\n return this.ref.getStrokeWidth();\n }\n\n setAlphaf(alpha: number) {\n this.ref.setAlphaf(alpha);\n }\n\n setAntiAlias(aa: boolean) {\n this.ref.setAntiAlias(aa);\n }\n\n setDither(dither: boolean) {\n this.ref.setDither(dither);\n }\n\n setBlendMode(blendMode: BlendMode) {\n if (blendMode === kBlendModePlusDarker) {\n // Use custom PlusDarker blender via SkRuntimeEffect\n const cache = getBlenderCache(this.CanvasKit);\n if (!cache.plusDarker) {\n const effect =\n this.CanvasKit.RuntimeEffect.MakeForBlender(plusDarkerSkSL);\n if (effect) {\n cache.plusDarker = effect.makeBlender([]);\n }\n }\n if (cache.plusDarker) {\n this.ref.setBlender(cache.plusDarker);\n }\n } else if (blendMode === kBlendModePlusLighter) {\n // Use custom PlusLighter blender via SkRuntimeEffect\n const cache = getBlenderCache(this.CanvasKit);\n if (!cache.plusLighter) {\n const effect =\n this.CanvasKit.RuntimeEffect.MakeForBlender(plusLighterSkSL);\n if (effect) {\n cache.plusLighter = effect.makeBlender([]);\n }\n }\n if (cache.plusLighter) {\n this.ref.setBlender(cache.plusLighter);\n }\n } else {\n this.ref.setBlendMode(getEnum(this.CanvasKit, \"BlendMode\", blendMode));\n }\n }\n\n setColor(color: SkColor) {\n this.ref.setColor(color);\n }\n\n setColorFilter(filter: SkColorFilter | null) {\n this.ref.setColorFilter(filter ? JsiSkColorFilter.fromValue(filter) : null);\n }\n\n setImageFilter(filter: SkImageFilter | null) {\n this.ref.setImageFilter(filter ? JsiSkImageFilter.fromValue(filter) : null);\n }\n\n setMaskFilter(filter: SkMaskFilter | null) {\n this.ref.setMaskFilter(filter ? JsiSkMaskFilter.fromValue(filter) : null);\n }\n\n setPathEffect(effect: SkPathEffect | null) {\n this.ref.setPathEffect(effect ? JsiSkPathEffect.fromValue(effect) : null);\n }\n\n setShader(shader: SkShader | null) {\n this.ref.setShader(shader ? JsiSkShader.fromValue(shader) : null);\n }\n\n setStrokeCap(cap: StrokeCap) {\n this.ref.setStrokeCap(getEnum(this.CanvasKit, \"StrokeCap\", cap));\n }\n\n setStrokeJoin(join: StrokeJoin) {\n this.ref.setStrokeJoin(getEnum(this.CanvasKit, \"StrokeJoin\", join));\n }\n\n setStrokeMiter(limit: number) {\n this.ref.setStrokeMiter(limit);\n }\n\n setStrokeWidth(width: number) {\n this.ref.setStrokeWidth(width);\n }\n\n setStyle(style: PaintStyle) {\n this.ref.setStyle({ value: style });\n }\n}\n"],"mappings":"AAgBA,SAASA,UAAU,EAAE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EnC,KAAK,EAAEoC;IAAM,CAAC,CAAC;EACrC;AACF","ignoreList":[]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { CanvasKit, Paragraph } from "canvaskit-wasm";
|
|
2
|
-
import type { SkRect, SkRectWithDirection, SkParagraph, LineMetrics } from "../types";
|
|
2
|
+
import type { SkRect, SkRectWithDirection, SkParagraph, SkPath, LineMetrics, ParagraphExtendedVisitor } from "../types";
|
|
3
3
|
import { HostObject } from "./Host";
|
|
4
4
|
import type { JsiSkCanvas } from "./JsiSkCanvas";
|
|
5
5
|
export declare class JsiSkParagraph extends HostObject<Paragraph, "Paragraph"> implements SkParagraph {
|
|
@@ -15,4 +15,6 @@ export declare class JsiSkParagraph extends HostObject<Paragraph, "Paragraph"> i
|
|
|
15
15
|
getRectsForPlaceholders(): SkRectWithDirection[];
|
|
16
16
|
getRectsForRange(start: number, end: number): SkRect[];
|
|
17
17
|
getLineMetrics(): LineMetrics[];
|
|
18
|
+
getPath(_lineNumber: number): SkPath | null;
|
|
19
|
+
extendedVisit(_visitor: ParagraphExtendedVisitor): void;
|
|
18
20
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { HostObject } from "./Host";
|
|
1
|
+
import { HostObject, throwNotImplementedOnRNWeb } from "./Host";
|
|
2
2
|
import { JsiSkRect } from "./JsiSkRect";
|
|
3
3
|
export class JsiSkParagraph extends HostObject {
|
|
4
4
|
constructor(CanvasKit, ref) {
|
|
@@ -49,5 +49,11 @@ export class JsiSkParagraph extends HostObject {
|
|
|
49
49
|
getLineMetrics() {
|
|
50
50
|
return this.ref.getLineMetrics();
|
|
51
51
|
}
|
|
52
|
+
getPath(_lineNumber) {
|
|
53
|
+
return throwNotImplementedOnRNWeb();
|
|
54
|
+
}
|
|
55
|
+
extendedVisit(_visitor) {
|
|
56
|
+
return throwNotImplementedOnRNWeb();
|
|
57
|
+
}
|
|
52
58
|
}
|
|
53
59
|
//# sourceMappingURL=JsiSkParagraph.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["HostObject","JsiSkRect","JsiSkParagraph","constructor","CanvasKit","ref","getMinIntrinsicWidth","getMaxIntrinsicWidth","getLongestLine","layout","width","paint","canvas","x","y","drawParagraph","getHeight","getMaxWidth","getGlyphPositionAtCoordinate","pos","getRectsForPlaceholders","map","rect","dir","direction","value","getRectsForRange","start","end","getLineMetrics"],"sources":["JsiSkParagraph.ts"],"sourcesContent":["import type { CanvasKit, Paragraph } from \"canvaskit-wasm\";\n\nimport type {\n SkRect,\n SkRectWithDirection,\n SkParagraph,\n LineMetrics,\n} from \"../types\";\n\nimport { HostObject } from \"./Host\";\nimport type { JsiSkCanvas } from \"./JsiSkCanvas\";\nimport { JsiSkRect } from \"./JsiSkRect\";\n\nexport class JsiSkParagraph\n extends HostObject<Paragraph, \"Paragraph\">\n implements SkParagraph\n{\n constructor(CanvasKit: CanvasKit, ref: Paragraph) {\n super(CanvasKit, ref, \"Paragraph\");\n }\n getMinIntrinsicWidth() {\n return this.ref.getMinIntrinsicWidth();\n }\n\n getMaxIntrinsicWidth() {\n return this.ref.getMaxIntrinsicWidth();\n }\n\n getLongestLine() {\n return this.ref.getLongestLine();\n }\n\n layout(width: number) {\n this.ref.layout(width);\n }\n paint(canvas: JsiSkCanvas, x: number, y: number) {\n canvas.ref.drawParagraph(this.ref, x, y);\n }\n getHeight() {\n return this.ref.getHeight();\n }\n getMaxWidth() {\n return this.ref.getMaxWidth();\n }\n getGlyphPositionAtCoordinate(x: number, y: number) {\n return this.ref.getGlyphPositionAtCoordinate(x, y).pos;\n }\n getRectsForPlaceholders(): SkRectWithDirection[] {\n return this.ref.getRectsForPlaceholders().map(({ rect, dir }) => ({\n rect: new JsiSkRect(this.CanvasKit, rect),\n direction: dir.value,\n }));\n }\n getRectsForRange(start: number, end: number): SkRect[] {\n return this.ref\n .getRectsForRange(\n start,\n end,\n { value: 0 } /** kTight */,\n { value: 0 } /** kTight */\n )\n .map(({ rect }) => new JsiSkRect(this.CanvasKit, rect));\n }\n getLineMetrics(): LineMetrics[] {\n return this.ref.getLineMetrics();\n }\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"names":["HostObject","throwNotImplementedOnRNWeb","JsiSkRect","JsiSkParagraph","constructor","CanvasKit","ref","getMinIntrinsicWidth","getMaxIntrinsicWidth","getLongestLine","layout","width","paint","canvas","x","y","drawParagraph","getHeight","getMaxWidth","getGlyphPositionAtCoordinate","pos","getRectsForPlaceholders","map","rect","dir","direction","value","getRectsForRange","start","end","getLineMetrics","getPath","_lineNumber","extendedVisit","_visitor"],"sources":["JsiSkParagraph.ts"],"sourcesContent":["import type { CanvasKit, Paragraph } from \"canvaskit-wasm\";\n\nimport type {\n SkRect,\n SkRectWithDirection,\n SkParagraph,\n SkPath,\n LineMetrics,\n ParagraphExtendedVisitor,\n} from \"../types\";\n\nimport { HostObject, throwNotImplementedOnRNWeb } from \"./Host\";\nimport type { JsiSkCanvas } from \"./JsiSkCanvas\";\nimport { JsiSkRect } from \"./JsiSkRect\";\n\nexport class JsiSkParagraph\n extends HostObject<Paragraph, \"Paragraph\">\n implements SkParagraph\n{\n constructor(CanvasKit: CanvasKit, ref: Paragraph) {\n super(CanvasKit, ref, \"Paragraph\");\n }\n getMinIntrinsicWidth() {\n return this.ref.getMinIntrinsicWidth();\n }\n\n getMaxIntrinsicWidth() {\n return this.ref.getMaxIntrinsicWidth();\n }\n\n getLongestLine() {\n return this.ref.getLongestLine();\n }\n\n layout(width: number) {\n this.ref.layout(width);\n }\n paint(canvas: JsiSkCanvas, x: number, y: number) {\n canvas.ref.drawParagraph(this.ref, x, y);\n }\n getHeight() {\n return this.ref.getHeight();\n }\n getMaxWidth() {\n return this.ref.getMaxWidth();\n }\n getGlyphPositionAtCoordinate(x: number, y: number) {\n return this.ref.getGlyphPositionAtCoordinate(x, y).pos;\n }\n getRectsForPlaceholders(): SkRectWithDirection[] {\n return this.ref.getRectsForPlaceholders().map(({ rect, dir }) => ({\n rect: new JsiSkRect(this.CanvasKit, rect),\n direction: dir.value,\n }));\n }\n getRectsForRange(start: number, end: number): SkRect[] {\n return this.ref\n .getRectsForRange(\n start,\n end,\n { value: 0 } /** kTight */,\n { value: 0 } /** kTight */\n )\n .map(({ rect }) => new JsiSkRect(this.CanvasKit, rect));\n }\n getLineMetrics(): LineMetrics[] {\n return this.ref.getLineMetrics();\n }\n getPath(_lineNumber: number): SkPath | null {\n return throwNotImplementedOnRNWeb<SkPath | null>();\n }\n extendedVisit(_visitor: ParagraphExtendedVisitor): void {\n return throwNotImplementedOnRNWeb<void>();\n }\n}\n"],"mappings":"AAWA,SAASA,UAAU,EAAEC,0BAA0B,QAAQ,QAAQ;AAE/D,SAASC,SAAS,QAAQ,aAAa;AAEvC,OAAO,MAAMC,cAAc,SACjBH,UAAU,CAEpB;EACEI,WAAWA,CAACC,SAAoB,EAAEC,GAAc,EAAE;IAChD,KAAK,CAACD,SAAS,EAAEC,GAAG,EAAE,WAAW,CAAC;EACpC;EACAC,oBAAoBA,CAAA,EAAG;IACrB,OAAO,IAAI,CAACD,GAAG,CAACC,oBAAoB,CAAC,CAAC;EACxC;EAEAC,oBAAoBA,CAAA,EAAG;IACrB,OAAO,IAAI,CAACF,GAAG,CAACE,oBAAoB,CAAC,CAAC;EACxC;EAEAC,cAAcA,CAAA,EAAG;IACf,OAAO,IAAI,CAACH,GAAG,CAACG,cAAc,CAAC,CAAC;EAClC;EAEAC,MAAMA,CAACC,KAAa,EAAE;IACpB,IAAI,CAACL,GAAG,CAACI,MAAM,CAACC,KAAK,CAAC;EACxB;EACAC,KAAKA,CAACC,MAAmB,EAAEC,CAAS,EAAEC,CAAS,EAAE;IAC/CF,MAAM,CAACP,GAAG,CAACU,aAAa,CAAC,IAAI,CAACV,GAAG,EAAEQ,CAAC,EAAEC,CAAC,CAAC;EAC1C;EACAE,SAASA,CAAA,EAAG;IACV,OAAO,IAAI,CAACX,GAAG,CAACW,SAAS,CAAC,CAAC;EAC7B;EACAC,WAAWA,CAAA,EAAG;IACZ,OAAO,IAAI,CAACZ,GAAG,CAACY,WAAW,CAAC,CAAC;EAC/B;EACAC,4BAA4BA,CAACL,CAAS,EAAEC,CAAS,EAAE;IACjD,OAAO,IAAI,CAACT,GAAG,CAACa,4BAA4B,CAACL,CAAC,EAAEC,CAAC,CAAC,CAACK,GAAG;EACxD;EACAC,uBAAuBA,CAAA,EAA0B;IAC/C,OAAO,IAAI,CAACf,GAAG,CAACe,uBAAuB,CAAC,CAAC,CAACC,GAAG,CAAC,CAAC;MAAEC,IAAI;MAAEC;IAAI,CAAC,MAAM;MAChED,IAAI,EAAE,IAAIrB,SAAS,CAAC,IAAI,CAACG,SAAS,EAAEkB,IAAI,CAAC;MACzCE,SAAS,EAAED,GAAG,CAACE;IACjB,CAAC,CAAC,CAAC;EACL;EACAC,gBAAgBA,CAACC,KAAa,EAAEC,GAAW,EAAY;IACrD,OAAO,IAAI,CAACvB,GAAG,CACZqB,gBAAgB,CACfC,KAAK,EACLC,GAAG,EACH;MAAEH,KAAK,EAAE;IAAE,CAAC,CAAC,eACb;MAAEA,KAAK,EAAE;IAAE,CAAC,CAAC,aACf,CAAC,CACAJ,GAAG,CAAC,CAAC;MAAEC;IAAK,CAAC,KAAK,IAAIrB,SAAS,CAAC,IAAI,CAACG,SAAS,EAAEkB,IAAI,CAAC,CAAC;EAC3D;EACAO,cAAcA,CAAA,EAAkB;IAC9B,OAAO,IAAI,CAACxB,GAAG,CAACwB,cAAc,CAAC,CAAC;EAClC;EACAC,OAAOA,CAACC,WAAmB,EAAiB;IAC1C,OAAO/B,0BAA0B,CAAgB,CAAC;EACpD;EACAgC,aAAaA,CAACC,QAAkC,EAAQ;IACtD,OAAOjC,0BAA0B,CAAO,CAAC;EAC3C;AACF","ignoreList":[]}
|
|
@@ -3,7 +3,7 @@ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol"
|
|
|
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
4
|
import Rea from "../external/reanimated/ReanimatedProxy";
|
|
5
5
|
import { HAS_REANIMATED_3 } from "../external/reanimated/renderHelpers";
|
|
6
|
-
import { Recorder } from "./Recorder/Recorder";
|
|
6
|
+
import { Recorder, disposeRecording } from "./Recorder/Recorder";
|
|
7
7
|
import { visit } from "./Recorder/Visitor";
|
|
8
8
|
import { replay } from "./Recorder/Player";
|
|
9
9
|
import { createDrawingContext } from "./Recorder/DrawingContext";
|
|
@@ -18,17 +18,30 @@ const {
|
|
|
18
18
|
const drawOnscreen = (Skia, nativeId, recording) => {
|
|
19
19
|
"worklet";
|
|
20
20
|
|
|
21
|
+
var _recording$lastPictur;
|
|
21
22
|
const rec = Skia.PictureRecorder();
|
|
22
23
|
const canvas = rec.beginRecording();
|
|
23
24
|
//const start = performance.now();
|
|
24
25
|
|
|
25
26
|
const ctx = createDrawingContext(Skia, recording.paintPool, canvas);
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
27
|
+
let picture;
|
|
28
|
+
try {
|
|
29
|
+
replay(ctx, recording.commands);
|
|
30
|
+
picture = rec.finishRecordingAsPicture();
|
|
31
|
+
} finally {
|
|
32
|
+
// Frame-scoped objects (shaders, filters, paint copies, ...) are
|
|
33
|
+
// referenced by the picture once it is finished — delete the JS handles,
|
|
34
|
+
// otherwise they leak on Web where the GC cannot see WASM memory.
|
|
35
|
+
ctx.dispose();
|
|
36
|
+
rec.dispose();
|
|
37
|
+
}
|
|
29
38
|
//const end = performance.now();
|
|
30
39
|
//console.log("Recording time: ", end - start);
|
|
31
40
|
SkiaViewApi.setJsiProperty(nativeId, "picture", picture);
|
|
41
|
+
// The view now references the new picture; the previous one is ours to
|
|
42
|
+
// delete.
|
|
43
|
+
(_recording$lastPictur = recording.lastPicture) === null || _recording$lastPictur === void 0 || _recording$lastPictur.dispose();
|
|
44
|
+
recording.lastPicture = picture;
|
|
32
45
|
};
|
|
33
46
|
class ReanimatedContainer extends Container {
|
|
34
47
|
constructor(Skia, nativeId) {
|
|
@@ -45,6 +58,19 @@ class ReanimatedContainer extends Container {
|
|
|
45
58
|
Rea.stopMapper(this.mapperId);
|
|
46
59
|
this.mapperId = null;
|
|
47
60
|
}
|
|
61
|
+
const {
|
|
62
|
+
recording
|
|
63
|
+
} = this;
|
|
64
|
+
if (recording) {
|
|
65
|
+
this.recording = null;
|
|
66
|
+
// Deferred through the same channel as the draw calls so it runs after
|
|
67
|
+
// any of them that are still queued.
|
|
68
|
+
Rea.runOnUI(() => {
|
|
69
|
+
"worklet";
|
|
70
|
+
|
|
71
|
+
disposeRecording(recording);
|
|
72
|
+
})();
|
|
73
|
+
}
|
|
48
74
|
}
|
|
49
75
|
redraw() {
|
|
50
76
|
if (this.mapperId !== null) {
|
|
@@ -54,6 +80,7 @@ class ReanimatedContainer extends Container {
|
|
|
54
80
|
if (this.unmounted) {
|
|
55
81
|
return;
|
|
56
82
|
}
|
|
83
|
+
const previousRecording = this.recording;
|
|
57
84
|
const recorder = new Recorder();
|
|
58
85
|
visit(recorder, this.root);
|
|
59
86
|
const record = recorder.getRecording();
|
|
@@ -79,6 +106,10 @@ class ReanimatedContainer extends Container {
|
|
|
79
106
|
Rea.runOnUI(() => {
|
|
80
107
|
"worklet";
|
|
81
108
|
|
|
109
|
+
if (previousRecording) {
|
|
110
|
+
// Runs after any still-queued draw of the previous recording.
|
|
111
|
+
disposeRecording(previousRecording);
|
|
112
|
+
}
|
|
82
113
|
drawOnscreen(Skia, nativeId, recording);
|
|
83
114
|
})();
|
|
84
115
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["Rea","HAS_REANIMATED_3","Recorder","visit","replay","createDrawingContext","Container","StaticContainer","SkiaViewApi","globalThis","drawOnscreen","Skia","nativeId","recording","rec","PictureRecorder","canvas","beginRecording","ctx","paintPool","
|
|
1
|
+
{"version":3,"names":["Rea","HAS_REANIMATED_3","Recorder","disposeRecording","visit","replay","createDrawingContext","Container","StaticContainer","SkiaViewApi","globalThis","drawOnscreen","Skia","nativeId","recording","_recording$lastPictur","rec","PictureRecorder","canvas","beginRecording","ctx","paintPool","picture","commands","finishRecordingAsPicture","dispose","setJsiProperty","lastPicture","ReanimatedContainer","constructor","_defineProperty","unmount","mapperId","stopMapper","runOnUI","redraw","unmounted","previousRecording","recorder","root","record","getRecording","animationValues","size","startMapper","Array","from","createContainer"],"sources":["Container.web.ts"],"sourcesContent":["import Rea from \"../external/reanimated/ReanimatedProxy\";\nimport type { Skia } from \"../skia/types\";\nimport { HAS_REANIMATED_3 } from \"../external/reanimated/renderHelpers\";\n\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\";\nimport { Container, StaticContainer } from \"./StaticContainer\";\n\nimport \"../skia/NativeSetup\";\nimport \"../views/api\";\n\n// create local reference for `strictGlobal` option in Worklets\nconst { SkiaViewApi } = globalThis;\n\nconst drawOnscreen = (Skia: Skia, nativeId: number, recording: Recording) => {\n \"worklet\";\n const rec = Skia.PictureRecorder();\n const canvas = rec.beginRecording();\n //const start = performance.now();\n\n const ctx = createDrawingContext(Skia, recording.paintPool, canvas);\n let picture;\n try {\n replay(ctx, recording.commands);\n picture = rec.finishRecordingAsPicture();\n } finally {\n // Frame-scoped objects (shaders, filters, paint copies, ...) are\n // referenced by the picture once it is finished — delete the JS handles,\n // otherwise they leak on Web where the GC cannot see WASM memory.\n ctx.dispose();\n rec.dispose();\n }\n //const end = performance.now();\n //console.log(\"Recording time: \", end - start);\n SkiaViewApi.setJsiProperty(nativeId, \"picture\", picture);\n // The view now references the new picture; the previous one is ours to\n // delete.\n recording.lastPicture?.dispose();\n recording.lastPicture = picture;\n};\n\nclass ReanimatedContainer extends Container {\n private mapperId: number | null = null;\n\n constructor(\n Skia: Skia,\n private nativeId: number\n ) {\n super(Skia);\n }\n\n unmount() {\n super.unmount();\n if (this.mapperId !== null) {\n // The mapper closure retains the recording and keeps updating the\n // picture of an unmounted view — stop it or it leaks for the\n // lifetime of the app.\n Rea.stopMapper(this.mapperId);\n this.mapperId = null;\n }\n const { recording } = this;\n if (recording) {\n this.recording = null;\n // Deferred through the same channel as the draw calls so it runs after\n // any of them that are still queued.\n Rea.runOnUI(() => {\n \"worklet\";\n disposeRecording(recording);\n })();\n }\n }\n\n redraw() {\n if (this.mapperId !== null) {\n Rea.stopMapper(this.mapperId);\n this.mapperId = null;\n }\n if (this.unmounted) {\n return;\n }\n const previousRecording = this.recording;\n const recorder = new Recorder();\n visit(recorder, this.root);\n const record = recorder.getRecording();\n const { animationValues } = record;\n this.recording = {\n commands: record.commands,\n paintPool: record.paintPool,\n };\n const { nativeId, Skia, recording } = this;\n if (animationValues.size > 0) {\n this.mapperId = Rea.startMapper(() => {\n \"worklet\";\n drawOnscreen(Skia, nativeId, recording!);\n }, Array.from(animationValues));\n }\n Rea.runOnUI(() => {\n \"worklet\";\n if (previousRecording) {\n // Runs after any still-queued draw of the previous recording.\n disposeRecording(previousRecording);\n }\n drawOnscreen(Skia, nativeId, recording!);\n })();\n }\n}\n\nexport const createContainer = (Skia: Skia, nativeId: number) => {\n if (HAS_REANIMATED_3 && nativeId !== -1) {\n return new ReanimatedContainer(Skia, nativeId);\n } else {\n return new StaticContainer(Skia, nativeId);\n }\n};\n"],"mappings":";;;AAAA,OAAOA,GAAG,MAAM,wCAAwC;AAExD,SAASC,gBAAgB,QAAQ,sCAAsC;AAGvE,SAASC,QAAQ,EAAEC,gBAAgB,QAAQ,qBAAqB;AAChE,SAASC,KAAK,QAAQ,oBAAoB;AAC1C,SAASC,MAAM,QAAQ,mBAAmB;AAC1C,SAASC,oBAAoB,QAAQ,2BAA2B;AAChE,SAASC,SAAS,EA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AC1C,CAAC,EAAE+B,KAAK,CAACC,IAAI,CAACJ,eAAe,CAAC,CAAC;IACjC;IACA1C,GAAG,CAACkC,OAAO,CAAC,MAAM;MAChB,SAAS;;MACT,IAAIG,iBAAiB,EAAE;QACrB;QACAlC,gBAAgB,CAACkC,iBAAiB,CAAC;MACrC;MACA1B,YAAY,CAACC,IAAI,EAAEC,QAAQ,EAAEC,SAAU,CAAC;IAC1C,CAAC,CAAC,CAAC,CAAC;EACN;AACF;AAEA,OAAO,MAAMiC,eAAe,GAAGA,CAACnC,IAAU,EAAEC,QAAgB,KAAK;EAC/D,IAAIZ,gBAAgB,IAAIY,QAAQ,KAAK,CAAC,CAAC,EAAE;IACvC,OAAO,IAAIe,mBAAmB,CAAChB,IAAI,EAAEC,QAAQ,CAAC;EAChD,CAAC,MAAM;IACL,OAAO,IAAIL,eAAe,CAACI,IAAI,EAAEC,QAAQ,CAAC;EAC5C;AACF,CAAC","ignoreList":[]}
|
|
@@ -2,6 +2,8 @@ import type { Skia, SkCanvas, SkColorFilter, SkPaint, SkShader, SkImageFilter, S
|
|
|
2
2
|
export declare const createDrawingContext: (Skia: Skia, paintPool: SkPaint[], canvas: SkCanvas) => {
|
|
3
3
|
Skia: Skia;
|
|
4
4
|
canvas: SkCanvas;
|
|
5
|
+
track: <T>(value: T) => T;
|
|
6
|
+
dispose: () => void;
|
|
5
7
|
paints: SkPaint[];
|
|
6
8
|
colorFilters: SkColorFilter[];
|
|
7
9
|
shaders: SkShader[];
|
|
@@ -1,6 +1,16 @@
|
|
|
1
|
+
import { createFrameScope } from "./FrameScope";
|
|
1
2
|
export const createDrawingContext = (Skia, paintPool, canvas) => {
|
|
2
3
|
"worklet";
|
|
3
4
|
|
|
5
|
+
// Everything the renderer creates through frameSkia is frame-scoped and
|
|
6
|
+
// deleted by dispose() once the frame has been recorded. The paint pool is
|
|
7
|
+
// recording-scoped and deliberately allocated with the raw Skia instance.
|
|
8
|
+
const {
|
|
9
|
+
Skia: frameSkia,
|
|
10
|
+
track,
|
|
11
|
+
dispose
|
|
12
|
+
} = createFrameScope(Skia);
|
|
13
|
+
|
|
4
14
|
// State (formerly class fields)
|
|
5
15
|
const paints = [];
|
|
6
16
|
const colorFilters = [];
|
|
@@ -12,7 +22,11 @@ export const createDrawingContext = (Skia, paintPool, canvas) => {
|
|
|
12
22
|
let nextPaintIndex = 1;
|
|
13
23
|
|
|
14
24
|
// Initialize first paint and opacity
|
|
15
|
-
paintPool
|
|
25
|
+
if (paintPool.length === 0) {
|
|
26
|
+
paintPool.push(Skia.Paint());
|
|
27
|
+
} else {
|
|
28
|
+
paintPool[0].reset();
|
|
29
|
+
}
|
|
16
30
|
paints.push(paintPool[0]);
|
|
17
31
|
opacities.push(1);
|
|
18
32
|
|
|
@@ -42,7 +56,7 @@ export const createDrawingContext = (Skia, paintPool, canvas) => {
|
|
|
42
56
|
} else {
|
|
43
57
|
const cf = colorFilters.pop();
|
|
44
58
|
if (cf) {
|
|
45
|
-
imageFilter =
|
|
59
|
+
imageFilter = frameSkia.ImageFilter.MakeColorFilter(cf, null);
|
|
46
60
|
}
|
|
47
61
|
}
|
|
48
62
|
canvas.saveLayer(undefined, null, imageFilter);
|
|
@@ -60,7 +74,7 @@ export const createDrawingContext = (Skia, paintPool, canvas) => {
|
|
|
60
74
|
const materializePaint = () => {
|
|
61
75
|
// Color Filters
|
|
62
76
|
if (colorFilters.length > 0) {
|
|
63
|
-
getCurrentPaint().setColorFilter(colorFilters.reduceRight((inner, outer) => inner ?
|
|
77
|
+
getCurrentPaint().setColorFilter(colorFilters.reduceRight((inner, outer) => inner ? frameSkia.ColorFilter.MakeCompose(outer, inner) : outer));
|
|
64
78
|
}
|
|
65
79
|
// Shaders
|
|
66
80
|
if (shaders.length > 0) {
|
|
@@ -68,12 +82,12 @@ export const createDrawingContext = (Skia, paintPool, canvas) => {
|
|
|
68
82
|
}
|
|
69
83
|
// Image Filters
|
|
70
84
|
if (imageFilters.length > 0) {
|
|
71
|
-
getCurrentPaint().setImageFilter(imageFilters.reduceRight((inner, outer) => inner ?
|
|
85
|
+
getCurrentPaint().setImageFilter(imageFilters.reduceRight((inner, outer) => inner ? frameSkia.ImageFilter.MakeCompose(outer, inner) : outer));
|
|
72
86
|
}
|
|
73
87
|
|
|
74
88
|
// Path Effects
|
|
75
89
|
if (pathEffects.length > 0) {
|
|
76
|
-
getCurrentPaint().setPathEffect(pathEffects.reduceRight((inner, outer) => inner ?
|
|
90
|
+
getCurrentPaint().setPathEffect(pathEffects.reduceRight((inner, outer) => inner ? frameSkia.PathEffect.MakeCompose(outer, inner) : outer));
|
|
77
91
|
}
|
|
78
92
|
|
|
79
93
|
// Clear arrays
|
|
@@ -86,8 +100,10 @@ export const createDrawingContext = (Skia, paintPool, canvas) => {
|
|
|
86
100
|
// Return an object containing the Skia reference, the canvas, and the methods
|
|
87
101
|
return {
|
|
88
102
|
// Public fields
|
|
89
|
-
Skia,
|
|
103
|
+
Skia: frameSkia,
|
|
90
104
|
canvas,
|
|
105
|
+
track,
|
|
106
|
+
dispose,
|
|
91
107
|
paints,
|
|
92
108
|
colorFilters,
|
|
93
109
|
shaders,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["createDrawingContext","Skia","paintPool","canvas","paints","colorFilters","shaders","imageFilters","pathEffects","paintDeclarations","opacities","nextPaintIndex","
|
|
1
|
+
{"version":3,"names":["createFrameScope","createDrawingContext","Skia","paintPool","canvas","frameSkia","track","dispose","paints","colorFilters","shaders","imageFilters","pathEffects","paintDeclarations","opacities","nextPaintIndex","length","push","Paint","reset","savePaint","nextPaint","assign","getCurrentPaint","getOpacity","setOpacity","newOpacity","Math","max","min","saveBackdropFilter","imageFilter","imgf","pop","cf","ImageFilter","MakeColorFilter","saveLayer","undefined","restore","restorePaint","materializePaint","setColorFilter","reduceRight","inner","outer","ColorFilter","MakeCompose","setShader","setImageFilter","setPathEffect","PathEffect","paint"],"sources":["DrawingContext.ts"],"sourcesContent":["import type {\n Skia,\n SkCanvas,\n SkColorFilter,\n SkPaint,\n SkShader,\n SkImageFilter,\n SkPathEffect,\n} from \"../../skia/types\";\n\nimport { createFrameScope } from \"./FrameScope\";\n\nexport const createDrawingContext = (\n Skia: Skia,\n paintPool: SkPaint[],\n canvas: SkCanvas\n) => {\n \"worklet\";\n\n // Everything the renderer creates through frameSkia is frame-scoped and\n // deleted by dispose() once the frame has been recorded. The paint pool is\n // recording-scoped and deliberately allocated with the raw Skia instance.\n const { Skia: frameSkia, track, dispose } = createFrameScope(Skia);\n\n // State (formerly class fields)\n const paints: SkPaint[] = [];\n const colorFilters: SkColorFilter[] = [];\n const shaders: SkShader[] = [];\n const imageFilters: SkImageFilter[] = [];\n const pathEffects: SkPathEffect[] = [];\n const paintDeclarations: SkPaint[] = [];\n const opacities: number[] = [];\n\n let nextPaintIndex = 1;\n\n // Initialize first paint and opacity\n if (paintPool.length === 0) {\n paintPool.push(Skia.Paint());\n } else {\n paintPool[0].reset();\n }\n paints.push(paintPool[0]);\n opacities.push(1);\n\n // Methods (formerly class methods)\n const savePaint = () => {\n // Get next available paint from pool or create new one if needed\n if (nextPaintIndex >= paintPool.length) {\n paintPool.push(Skia.Paint());\n }\n\n const nextPaint = paintPool[nextPaintIndex];\n nextPaint.assign(getCurrentPaint()); // Reuse allocation by copying properties\n paints.push(nextPaint);\n opacities.push(opacities[opacities.length - 1]);\n nextPaintIndex++;\n };\n\n const getOpacity = () => {\n return opacities[opacities.length - 1];\n };\n\n const setOpacity = (newOpacity: number) => {\n opacities[opacities.length - 1] = Math.max(0, Math.min(1, newOpacity));\n };\n\n const saveBackdropFilter = () => {\n let imageFilter: SkImageFilter | null = null;\n const imgf = imageFilters.pop();\n if (imgf) {\n imageFilter = imgf;\n } else {\n const cf = colorFilters.pop();\n if (cf) {\n imageFilter = frameSkia.ImageFilter.MakeColorFilter(cf, null);\n }\n }\n canvas.saveLayer(undefined, null, imageFilter);\n canvas.restore();\n };\n\n // Equivalent to the `get paint()` getter in the original class\n const getCurrentPaint = () => {\n return paints[paints.length - 1];\n };\n\n const restorePaint = () => {\n opacities.pop();\n return paints.pop();\n };\n\n const materializePaint = () => {\n // Color Filters\n if (colorFilters.length > 0) {\n getCurrentPaint().setColorFilter(\n colorFilters.reduceRight((inner, outer) =>\n inner ? frameSkia.ColorFilter.MakeCompose(outer, inner) : outer\n )\n );\n }\n // Shaders\n if (shaders.length > 0) {\n getCurrentPaint().setShader(shaders[shaders.length - 1]);\n }\n // Image Filters\n if (imageFilters.length > 0) {\n getCurrentPaint().setImageFilter(\n imageFilters.reduceRight((inner, outer) =>\n inner ? frameSkia.ImageFilter.MakeCompose(outer, inner) : outer\n )\n );\n }\n\n // Path Effects\n if (pathEffects.length > 0) {\n getCurrentPaint().setPathEffect(\n pathEffects.reduceRight((inner, outer) =>\n inner ? frameSkia.PathEffect.MakeCompose(outer, inner) : outer\n )\n );\n }\n\n // Clear arrays\n colorFilters.length = 0;\n shaders.length = 0;\n imageFilters.length = 0;\n pathEffects.length = 0;\n };\n\n // Return an object containing the Skia reference, the canvas, and the methods\n return {\n // Public fields\n Skia: frameSkia,\n canvas,\n track,\n dispose,\n paints,\n colorFilters,\n shaders,\n imageFilters,\n pathEffects,\n paintDeclarations,\n paintPool,\n\n // Public methods\n savePaint,\n saveBackdropFilter,\n get paint() {\n return paints[paints.length - 1];\n }, // the \"getter\" for the current paint\n restorePaint,\n materializePaint,\n getOpacity,\n setOpacity,\n };\n};\n\nexport type DrawingContext = ReturnType<typeof createDrawingContext>;\n"],"mappings":"AAUA,SAASA,gBAAgB,QAAQ,cAAc;AAE/C,OAAO,MAAMC,oBAAoB,GAAGA,CAClCC,IAAU,EACVC,SAAoB,EACpBC,MAAgB,KACb;EACH,SAAS;;EAET;EACA;EACA;EACA,MAAM;IAAEF,IAAI,EAAEG,SAAS;IAAEC,KAAK;IAAEC;EAAQ,CAAC,GAAGP,gBAAgB,CAACE,IAAI,CAAC;;EAElE;EACA,MAAMM,MAAiB,GAAG,EAAE;EAC5B,MAAMC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../skia/types";
|
|
2
|
+
export interface FrameScope {
|
|
3
|
+
Skia: Skia;
|
|
4
|
+
track: <T>(value: T) => T;
|
|
5
|
+
dispose: () => void;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Wraps a Skia instance so that every object created through its factories is
|
|
9
|
+
* collected and deleted when the scope is disposed. The renderer only keeps
|
|
10
|
+
* the objects it creates alive for the duration of a frame: once the frame
|
|
11
|
+
* has been recorded they can be deleted. This is required on Web where
|
|
12
|
+
* CanvasKit objects live in WASM memory that the JS garbage collector does
|
|
13
|
+
* not perceive, so it (almost) never reclaims them on its own.
|
|
14
|
+
*
|
|
15
|
+
* Objects passed in via props are user-owned: they are not created through
|
|
16
|
+
* this facade and are therefore never tracked nor disposed.
|
|
17
|
+
*/
|
|
18
|
+
export declare const createFrameScope: (Skia: Skia) => FrameScope;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
const isDisposable = value => {
|
|
2
|
+
"worklet";
|
|
3
|
+
|
|
4
|
+
return value !== null && typeof value === "object" && typeof value.dispose === "function";
|
|
5
|
+
};
|
|
6
|
+
/**
|
|
7
|
+
* Wraps a Skia instance so that every object created through its factories is
|
|
8
|
+
* collected and deleted when the scope is disposed. The renderer only keeps
|
|
9
|
+
* the objects it creates alive for the duration of a frame: once the frame
|
|
10
|
+
* has been recorded they can be deleted. This is required on Web where
|
|
11
|
+
* CanvasKit objects live in WASM memory that the JS garbage collector does
|
|
12
|
+
* not perceive, so it (almost) never reclaims them on its own.
|
|
13
|
+
*
|
|
14
|
+
* Objects passed in via props are user-owned: they are not created through
|
|
15
|
+
* this facade and are therefore never tracked nor disposed.
|
|
16
|
+
*/
|
|
17
|
+
export const createFrameScope = Skia => {
|
|
18
|
+
"worklet";
|
|
19
|
+
|
|
20
|
+
const disposables = [];
|
|
21
|
+
const track = value => {
|
|
22
|
+
if (isDisposable(value)) {
|
|
23
|
+
disposables.push(value);
|
|
24
|
+
}
|
|
25
|
+
return value;
|
|
26
|
+
};
|
|
27
|
+
const wrap = obj => {
|
|
28
|
+
const cache = new Map();
|
|
29
|
+
return new Proxy(obj, {
|
|
30
|
+
get(target, prop) {
|
|
31
|
+
if (cache.has(prop)) {
|
|
32
|
+
return cache.get(prop);
|
|
33
|
+
}
|
|
34
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
35
|
+
const value = target[prop];
|
|
36
|
+
let wrapped = value;
|
|
37
|
+
if (typeof value === "function") {
|
|
38
|
+
wrapped = (...args) => track(value.apply(target, args));
|
|
39
|
+
} else if (value !== null && typeof value === "object") {
|
|
40
|
+
wrapped = wrap(value);
|
|
41
|
+
}
|
|
42
|
+
cache.set(prop, wrapped);
|
|
43
|
+
return wrapped;
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
};
|
|
47
|
+
const dispose = () => {
|
|
48
|
+
for (let i = 0; i < disposables.length; i++) {
|
|
49
|
+
disposables[i].dispose();
|
|
50
|
+
}
|
|
51
|
+
disposables.length = 0;
|
|
52
|
+
};
|
|
53
|
+
return {
|
|
54
|
+
Skia: wrap(Skia),
|
|
55
|
+
track,
|
|
56
|
+
dispose
|
|
57
|
+
};
|
|
58
|
+
};
|
|
59
|
+
//# sourceMappingURL=FrameScope.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["isDisposable","value","dispose","createFrameScope","Skia","disposables","track","push","wrap","obj","cache","Map","Proxy","get","target","prop","has","wrapped","args","apply","set","i","length"],"sources":["FrameScope.ts"],"sourcesContent":["import type { Skia } from \"../../skia/types\";\n\ninterface Disposable {\n dispose: () => void;\n}\n\nconst isDisposable = (value: unknown): value is Disposable => {\n \"worklet\";\n return (\n value !== null &&\n typeof value === \"object\" &&\n typeof (value as Disposable).dispose === \"function\"\n );\n};\n\nexport interface FrameScope {\n Skia: Skia;\n track: <T>(value: T) => T;\n dispose: () => void;\n}\n\n/**\n * Wraps a Skia instance so that every object created through its factories is\n * collected and deleted when the scope is disposed. The renderer only keeps\n * the objects it creates alive for the duration of a frame: once the frame\n * has been recorded they can be deleted. This is required on Web where\n * CanvasKit objects live in WASM memory that the JS garbage collector does\n * not perceive, so it (almost) never reclaims them on its own.\n *\n * Objects passed in via props are user-owned: they are not created through\n * this facade and are therefore never tracked nor disposed.\n */\nexport const createFrameScope = (Skia: Skia): FrameScope => {\n \"worklet\";\n const disposables: Disposable[] = [];\n const track = <T>(value: T): T => {\n if (isDisposable(value)) {\n disposables.push(value);\n }\n return value;\n };\n const wrap = <T extends object>(obj: T): T => {\n const cache = new Map<PropertyKey, unknown>();\n return new Proxy(obj, {\n get(target, prop) {\n if (cache.has(prop)) {\n return cache.get(prop);\n }\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const value = (target as any)[prop];\n let wrapped: unknown = value;\n if (typeof value === \"function\") {\n wrapped = (...args: unknown[]) => track(value.apply(target, args));\n } else if (value !== null && typeof value === \"object\") {\n wrapped = wrap(value);\n }\n cache.set(prop, wrapped);\n return wrapped;\n },\n }) as T;\n };\n const dispose = () => {\n for (let i = 0; i < disposables.length; i++) {\n disposables[i].dispose();\n }\n disposables.length = 0;\n };\n return { Skia: wrap(Skia), track, dispose };\n};\n"],"mappings":"AAMA,MAAMA,YAAY,GAAIC,KAAc,IAA0B;EAC5D,SAAS;;EACT,OACEA,KAAK,KAAK,IAAI,IACd,OAAOA,KAAK,KAAK,QAAQ,IACzB,OAAQA,KAAK,CAAgBC,OAAO,KAAK,UAAU;AAEvD,CAAC;AAQD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,gBAAgB,GAAIC,IAAU,IAAiB;EAC1D,SAAS;;EACT,MAAMC,WAAyB,GAAG,EAAE;EACpC,MAAMC,KAAK,GAAOL,KAAQ,IAAQ;IAChC,IAAID,YAAY,CAACC,KAAK,CAAC,EAAE;MACvBI,WAAW,CAACE,IAAI,CAACN,KAAK,CAAC;IACzB;IACA,OAAOA,KAAK;EACd,CAAC;EACD,MAAMO,IAAI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FrameScope";
|
|
3
|
+
/**
|
|
4
|
+
* No-op on native. The JSI wrappers report the size of the native objects
|
|
5
|
+
* they hold to the garbage collector (setExternalMemoryPressure), so the GC
|
|
6
|
+
* is aware of the real cost of the objects the renderer creates and reclaims
|
|
7
|
+
* them on its own. The tracking scope is only needed on Web, where CanvasKit
|
|
8
|
+
* objects live in WASM memory the GC cannot see (see FrameScope.ts).
|
|
9
|
+
*/
|
|
10
|
+
export declare const createFrameScope: (Skia: Skia) => FrameScope;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* No-op on native. The JSI wrappers report the size of the native objects
|
|
3
|
+
* they hold to the garbage collector (setExternalMemoryPressure), so the GC
|
|
4
|
+
* is aware of the real cost of the objects the renderer creates and reclaims
|
|
5
|
+
* them on its own. The tracking scope is only needed on Web, where CanvasKit
|
|
6
|
+
* objects live in WASM memory the GC cannot see (see FrameScope.ts).
|
|
7
|
+
*/
|
|
8
|
+
export const createFrameScope = Skia => {
|
|
9
|
+
"worklet";
|
|
10
|
+
|
|
11
|
+
return {
|
|
12
|
+
Skia,
|
|
13
|
+
track: value => value,
|
|
14
|
+
dispose: () => {
|
|
15
|
+
// nothing to dispose: no objects are tracked on native
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
//# sourceMappingURL=FrameScope.native.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["createFrameScope","Skia","track","value","dispose"],"sources":["FrameScope.native.ts"],"sourcesContent":["import type { Skia } from \"../../skia/types\";\n\nimport type { FrameScope } from \"./FrameScope\";\n\n/**\n * No-op on native. The JSI wrappers report the size of the native objects\n * they hold to the garbage collector (setExternalMemoryPressure), so the GC\n * is aware of the real cost of the objects the renderer creates and reclaims\n * them on its own. The tracking scope is only needed on Web, where CanvasKit\n * objects live in WASM memory the GC cannot see (see FrameScope.ts).\n */\nexport const createFrameScope = (Skia: Skia): FrameScope => {\n \"worklet\";\n return {\n Skia,\n track: <T>(value: T): T => value,\n dispose: () => {\n // nothing to dispose: no objects are tracked on native\n },\n };\n};\n"],"mappings":"AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMA,gBAAgB,GAAIC,IAAU,IAAiB;EAC1D,SAAS;;EACT,OAAO;IACLA,IAAI;IACJC,KAAK,EAAMC,KAAQ,IAAQA,KAAK;IAChCC,OAAO,EAAEA,CAAA,KAAM;MACb;IAAA;EAEJ,CAAC;AACH,CAAC","ignoreList":[]}
|
|
@@ -110,9 +110,8 @@ const play = (ctx, _command) => {
|
|
|
110
110
|
} else if (isCommand(command, CommandType.RestoreCTM)) {
|
|
111
111
|
ctx.canvas.restore();
|
|
112
112
|
} else {
|
|
113
|
-
// TODO: is a copy needed here?
|
|
114
113
|
// apply opacity to the current paint.
|
|
115
|
-
const paint = ctx.paint.copy();
|
|
114
|
+
const paint = ctx.track(ctx.paint.copy());
|
|
116
115
|
paint.setAlphaf(paint.getAlphaf() * ctx.getOpacity());
|
|
117
116
|
const paints = [paint, ...ctx.paintDeclarations];
|
|
118
117
|
ctx.paintDeclarations = [];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["drawCircle","drawImage","drawOval","drawPath","drawPoints","drawRect","drawRRect","drawLine","drawAtlas","drawParagraph","drawImageSVG","drawPicture","drawGlyphs","drawTextBlob","drawTextPath","drawText","drawDiffRect","drawVertices","drawPatch","drawSkottie","drawBox","isBoxCommand","composeColorFilters","isPushColorFilter","pushColorFilter","saveCTM","setBlurMaskFilter","isPushImageFilter","pushImageFilter","composeImageFilters","setPaintProperties","composePathEffects","isPushPathEffect","pushPathEffect","isPushShader","pushShader","CommandType","isCommand","isDrawCommand","isGroup","materializeCommand","getZIndex","command","_materialized$props","materialized","zIndex","props","Number","isNaN","flushPendingGroups","ctx","pendingGroups","playFn","length","sort","a","b","order","forEach","playGroup","group","pending","children","child","push","play","_command","SaveBackdropFilter","saveBackdropFilter","SaveLayer","materializePaint","paint","paintDeclarations","pop","canvas","saveLayer","SavePaint","paints","standalone","savePaint","freshPaint","Skia","Paint","assign","RestorePaint","restorePaint","ComposeColorFilter","RestorePaintDeclaration","Error","MaterializePaint","ComposePathEffect","ComposeImageFilter","PushBlurMaskFilter","SaveCTM","RestoreCTM","restore","copy","setAlphaf","getAlphaf","getOpacity","p","DrawPaint","drawPaint","DrawImage","DrawCircle","DrawPoints","DrawPath","DrawRect","DrawRRect","DrawOval","DrawLine","DrawPatch","DrawVertices","DrawDiffRect","DrawText","DrawTextPath","DrawTextBlob","DrawGlyphs","DrawPicture","DrawImageSVG","DrawParagraph","DrawAtlas","DrawSkottie","console","warn","type","replay","commands"],"sources":["Player.ts"],"sourcesContent":["import type { DrawingNodeProps } from \"../../dom/types\";\n\nimport {\n drawCircle,\n drawImage,\n drawOval,\n drawPath,\n drawPoints,\n drawRect,\n drawRRect,\n drawLine,\n drawAtlas,\n drawParagraph,\n drawImageSVG,\n drawPicture,\n drawGlyphs,\n drawTextBlob,\n drawTextPath,\n drawText,\n drawDiffRect,\n drawVertices,\n drawPatch,\n drawSkottie,\n} from \"./commands/Drawing\";\nimport { drawBox, isBoxCommand } from \"./commands/Box\";\nimport {\n composeColorFilters,\n isPushColorFilter,\n pushColorFilter,\n} from \"./commands/ColorFilters\";\nimport { saveCTM } from \"./commands/CTM\";\nimport {\n setBlurMaskFilter,\n isPushImageFilter,\n pushImageFilter,\n composeImageFilters,\n} from \"./commands/ImageFilters\";\nimport { setPaintProperties } from \"./commands/Paint\";\nimport {\n composePathEffects,\n isPushPathEffect,\n pushPathEffect,\n} from \"./commands/PathEffects\";\nimport { isPushShader, pushShader } from \"./commands/Shaders\";\nimport {\n CommandType,\n isCommand,\n isDrawCommand,\n isGroup,\n materializeCommand,\n} from \"./Core\";\nimport type { Command, GroupCommand } from \"./Core\";\nimport type { DrawingContext } from \"./DrawingContext\";\n\ntype PendingGroup = {\n command: GroupCommand;\n zIndex: number;\n order: number;\n};\n\nconst getZIndex = (command: GroupCommand) => {\n \"worklet\";\n const materialized = materializeCommand(command);\n const { zIndex } = (materialized.props ?? {}) as DrawingNodeProps;\n if (typeof zIndex !== \"number\" || Number.isNaN(zIndex)) {\n return 0;\n }\n return zIndex;\n};\n\nconst flushPendingGroups = (\n ctx: DrawingContext,\n pendingGroups: PendingGroup[],\n playFn: (ctx: DrawingContext, cmd: Command) => void\n) => {\n \"worklet\";\n if (pendingGroups.length === 0) {\n return;\n }\n pendingGroups\n .sort((a, b) =>\n a.zIndex === b.zIndex ? a.order - b.order : a.zIndex - b.zIndex\n )\n .forEach(({ command }) => {\n playFn(ctx, command);\n });\n pendingGroups.length = 0;\n};\n\nconst playGroup = (\n ctx: DrawingContext,\n group: GroupCommand,\n playFn: (ctx: DrawingContext, cmd: Command) => void\n) => {\n \"worklet\";\n const pending: PendingGroup[] = [];\n group.children.forEach((child) => {\n if (isGroup(child)) {\n pending.push({\n command: child,\n zIndex: getZIndex(child),\n order: pending.length,\n });\n return;\n }\n flushPendingGroups(ctx, pending, playFn);\n playFn(ctx, child);\n });\n flushPendingGroups(ctx, pending, playFn);\n};\n\nconst play = (ctx: DrawingContext, _command: Command) => {\n if (isGroup(_command)) {\n playGroup(ctx, _command, play);\n return;\n }\n const command = materializeCommand(_command);\n if (isCommand(command, CommandType.SaveBackdropFilter)) {\n ctx.saveBackdropFilter();\n } else if (isCommand(command, CommandType.SaveLayer)) {\n ctx.materializePaint();\n const paint = ctx.paintDeclarations.pop();\n ctx.canvas.saveLayer(paint);\n } else if (isDrawCommand(command, CommandType.SavePaint)) {\n if (command.props.paint) {\n ctx.paints.push(command.props.paint);\n } else {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const { standalone } = command as any;\n ctx.savePaint();\n if (standalone) {\n const freshPaint = ctx.Skia.Paint();\n ctx.paint.assign(freshPaint);\n }\n setPaintProperties(ctx.Skia, ctx, command.props, standalone);\n }\n } else if (isCommand(command, CommandType.RestorePaint)) {\n ctx.restorePaint();\n } else if (isCommand(command, CommandType.ComposeColorFilter)) {\n composeColorFilters(ctx);\n } else if (isCommand(command, CommandType.RestorePaintDeclaration)) {\n ctx.materializePaint();\n const paint = ctx.restorePaint();\n if (!paint) {\n throw new Error(\"No paint declaration to push\");\n }\n ctx.paintDeclarations.push(paint);\n } else if (isCommand(command, CommandType.MaterializePaint)) {\n ctx.materializePaint();\n } else if (isPushColorFilter(command)) {\n pushColorFilter(ctx, command);\n } else if (isPushShader(command)) {\n pushShader(ctx, command);\n } else if (isPushImageFilter(command)) {\n pushImageFilter(ctx, command);\n } else if (isPushPathEffect(command)) {\n pushPathEffect(ctx, command);\n } else if (isCommand(command, CommandType.ComposePathEffect)) {\n composePathEffects(ctx);\n } else if (isCommand(command, CommandType.ComposeImageFilter)) {\n composeImageFilters(ctx);\n } else if (isDrawCommand(command, CommandType.PushBlurMaskFilter)) {\n setBlurMaskFilter(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.SaveCTM)) {\n saveCTM(ctx, command.props);\n } else if (isCommand(command, CommandType.RestoreCTM)) {\n ctx.canvas.restore();\n } else {\n // TODO: is a copy needed here?\n // apply opacity to the current paint.\n const paint = ctx.paint.copy();\n paint.setAlphaf(paint.getAlphaf() * ctx.getOpacity());\n const paints = [paint, ...ctx.paintDeclarations];\n ctx.paintDeclarations = [];\n paints.forEach((p) => {\n ctx.paints.push(p);\n if (isBoxCommand(command)) {\n drawBox(ctx, command);\n } else if (isCommand(command, CommandType.DrawPaint)) {\n ctx.canvas.drawPaint(ctx.paint);\n } else if (isDrawCommand(command, CommandType.DrawImage)) {\n drawImage(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawCircle)) {\n drawCircle(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawPoints)) {\n drawPoints(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawPath)) {\n drawPath(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawRect)) {\n drawRect(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawRRect)) {\n drawRRect(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawOval)) {\n drawOval(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawLine)) {\n drawLine(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawPatch)) {\n drawPatch(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawVertices)) {\n drawVertices(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawDiffRect)) {\n drawDiffRect(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawText)) {\n drawText(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawTextPath)) {\n drawTextPath(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawTextBlob)) {\n drawTextBlob(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawGlyphs)) {\n drawGlyphs(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawPicture)) {\n drawPicture(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawImageSVG)) {\n drawImageSVG(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawParagraph)) {\n drawParagraph(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawAtlas)) {\n drawAtlas(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawSkottie)) {\n drawSkottie(ctx, command.props);\n } else {\n console.warn(`Unknown command: ${command.type}`);\n }\n ctx.paints.pop();\n });\n }\n};\nexport function replay(ctx: DrawingContext, commands: Command[]) {\n \"worklet\";\n //console.log(debugTree(commands));\n commands.forEach((command) => {\n play(ctx, command);\n });\n}\n"],"mappings":"AAEA,SACEA,UAAU,EACVC,SAAS,EACTC,QAAQ,EACRC,QAAQ,EACRC,UAAU,EACVC,QAAQ,EACRC,SAAS,EACTC,QAAQ,EACRC,SAAS,EACTC,aAAa,EACbC,YAAY,EACZC,WAAW,EACXC,UAAU,EACVC,YAAY,EACZC,YAAY,EACZC,QAAQ,EACRC,YAAY,EACZC,YAAY,EACZC,SAAS,EACT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AG,CAAC,CAAC;IAClB,CAAC,CAAC;EACJ;AACF,CAAC;AACD,OAAO,SAASqD,MAAMA,CAAC5E,GAAmB,EAAE6E,QAAmB,EAAE;EAC/D,SAAS;;EACT;EACAA,QAAQ,CAACrE,OAAO,CAAEhB,OAAO,IAAK;IAC5BuB,IAAI,CAACf,GAAG,EAAER,OAAO,CAAC;EACpB,CAAC,CAAC;AACJ","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["drawCircle","drawImage","drawOval","drawPath","drawPoints","drawRect","drawRRect","drawLine","drawAtlas","drawParagraph","drawImageSVG","drawPicture","drawGlyphs","drawTextBlob","drawTextPath","drawText","drawDiffRect","drawVertices","drawPatch","drawSkottie","drawBox","isBoxCommand","composeColorFilters","isPushColorFilter","pushColorFilter","saveCTM","setBlurMaskFilter","isPushImageFilter","pushImageFilter","composeImageFilters","setPaintProperties","composePathEffects","isPushPathEffect","pushPathEffect","isPushShader","pushShader","CommandType","isCommand","isDrawCommand","isGroup","materializeCommand","getZIndex","command","_materialized$props","materialized","zIndex","props","Number","isNaN","flushPendingGroups","ctx","pendingGroups","playFn","length","sort","a","b","order","forEach","playGroup","group","pending","children","child","push","play","_command","SaveBackdropFilter","saveBackdropFilter","SaveLayer","materializePaint","paint","paintDeclarations","pop","canvas","saveLayer","SavePaint","paints","standalone","savePaint","freshPaint","Skia","Paint","assign","RestorePaint","restorePaint","ComposeColorFilter","RestorePaintDeclaration","Error","MaterializePaint","ComposePathEffect","ComposeImageFilter","PushBlurMaskFilter","SaveCTM","RestoreCTM","restore","track","copy","setAlphaf","getAlphaf","getOpacity","p","DrawPaint","drawPaint","DrawImage","DrawCircle","DrawPoints","DrawPath","DrawRect","DrawRRect","DrawOval","DrawLine","DrawPatch","DrawVertices","DrawDiffRect","DrawText","DrawTextPath","DrawTextBlob","DrawGlyphs","DrawPicture","DrawImageSVG","DrawParagraph","DrawAtlas","DrawSkottie","console","warn","type","replay","commands"],"sources":["Player.ts"],"sourcesContent":["import type { DrawingNodeProps } from \"../../dom/types\";\n\nimport {\n drawCircle,\n drawImage,\n drawOval,\n drawPath,\n drawPoints,\n drawRect,\n drawRRect,\n drawLine,\n drawAtlas,\n drawParagraph,\n drawImageSVG,\n drawPicture,\n drawGlyphs,\n drawTextBlob,\n drawTextPath,\n drawText,\n drawDiffRect,\n drawVertices,\n drawPatch,\n drawSkottie,\n} from \"./commands/Drawing\";\nimport { drawBox, isBoxCommand } from \"./commands/Box\";\nimport {\n composeColorFilters,\n isPushColorFilter,\n pushColorFilter,\n} from \"./commands/ColorFilters\";\nimport { saveCTM } from \"./commands/CTM\";\nimport {\n setBlurMaskFilter,\n isPushImageFilter,\n pushImageFilter,\n composeImageFilters,\n} from \"./commands/ImageFilters\";\nimport { setPaintProperties } from \"./commands/Paint\";\nimport {\n composePathEffects,\n isPushPathEffect,\n pushPathEffect,\n} from \"./commands/PathEffects\";\nimport { isPushShader, pushShader } from \"./commands/Shaders\";\nimport {\n CommandType,\n isCommand,\n isDrawCommand,\n isGroup,\n materializeCommand,\n} from \"./Core\";\nimport type { Command, GroupCommand } from \"./Core\";\nimport type { DrawingContext } from \"./DrawingContext\";\n\ntype PendingGroup = {\n command: GroupCommand;\n zIndex: number;\n order: number;\n};\n\nconst getZIndex = (command: GroupCommand) => {\n \"worklet\";\n const materialized = materializeCommand(command);\n const { zIndex } = (materialized.props ?? {}) as DrawingNodeProps;\n if (typeof zIndex !== \"number\" || Number.isNaN(zIndex)) {\n return 0;\n }\n return zIndex;\n};\n\nconst flushPendingGroups = (\n ctx: DrawingContext,\n pendingGroups: PendingGroup[],\n playFn: (ctx: DrawingContext, cmd: Command) => void\n) => {\n \"worklet\";\n if (pendingGroups.length === 0) {\n return;\n }\n pendingGroups\n .sort((a, b) =>\n a.zIndex === b.zIndex ? a.order - b.order : a.zIndex - b.zIndex\n )\n .forEach(({ command }) => {\n playFn(ctx, command);\n });\n pendingGroups.length = 0;\n};\n\nconst playGroup = (\n ctx: DrawingContext,\n group: GroupCommand,\n playFn: (ctx: DrawingContext, cmd: Command) => void\n) => {\n \"worklet\";\n const pending: PendingGroup[] = [];\n group.children.forEach((child) => {\n if (isGroup(child)) {\n pending.push({\n command: child,\n zIndex: getZIndex(child),\n order: pending.length,\n });\n return;\n }\n flushPendingGroups(ctx, pending, playFn);\n playFn(ctx, child);\n });\n flushPendingGroups(ctx, pending, playFn);\n};\n\nconst play = (ctx: DrawingContext, _command: Command) => {\n if (isGroup(_command)) {\n playGroup(ctx, _command, play);\n return;\n }\n const command = materializeCommand(_command);\n if (isCommand(command, CommandType.SaveBackdropFilter)) {\n ctx.saveBackdropFilter();\n } else if (isCommand(command, CommandType.SaveLayer)) {\n ctx.materializePaint();\n const paint = ctx.paintDeclarations.pop();\n ctx.canvas.saveLayer(paint);\n } else if (isDrawCommand(command, CommandType.SavePaint)) {\n if (command.props.paint) {\n ctx.paints.push(command.props.paint);\n } else {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const { standalone } = command as any;\n ctx.savePaint();\n if (standalone) {\n const freshPaint = ctx.Skia.Paint();\n ctx.paint.assign(freshPaint);\n }\n setPaintProperties(ctx.Skia, ctx, command.props, standalone);\n }\n } else if (isCommand(command, CommandType.RestorePaint)) {\n ctx.restorePaint();\n } else if (isCommand(command, CommandType.ComposeColorFilter)) {\n composeColorFilters(ctx);\n } else if (isCommand(command, CommandType.RestorePaintDeclaration)) {\n ctx.materializePaint();\n const paint = ctx.restorePaint();\n if (!paint) {\n throw new Error(\"No paint declaration to push\");\n }\n ctx.paintDeclarations.push(paint);\n } else if (isCommand(command, CommandType.MaterializePaint)) {\n ctx.materializePaint();\n } else if (isPushColorFilter(command)) {\n pushColorFilter(ctx, command);\n } else if (isPushShader(command)) {\n pushShader(ctx, command);\n } else if (isPushImageFilter(command)) {\n pushImageFilter(ctx, command);\n } else if (isPushPathEffect(command)) {\n pushPathEffect(ctx, command);\n } else if (isCommand(command, CommandType.ComposePathEffect)) {\n composePathEffects(ctx);\n } else if (isCommand(command, CommandType.ComposeImageFilter)) {\n composeImageFilters(ctx);\n } else if (isDrawCommand(command, CommandType.PushBlurMaskFilter)) {\n setBlurMaskFilter(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.SaveCTM)) {\n saveCTM(ctx, command.props);\n } else if (isCommand(command, CommandType.RestoreCTM)) {\n ctx.canvas.restore();\n } else {\n // apply opacity to the current paint.\n const paint = ctx.track(ctx.paint.copy());\n paint.setAlphaf(paint.getAlphaf() * ctx.getOpacity());\n const paints = [paint, ...ctx.paintDeclarations];\n ctx.paintDeclarations = [];\n paints.forEach((p) => {\n ctx.paints.push(p);\n if (isBoxCommand(command)) {\n drawBox(ctx, command);\n } else if (isCommand(command, CommandType.DrawPaint)) {\n ctx.canvas.drawPaint(ctx.paint);\n } else if (isDrawCommand(command, CommandType.DrawImage)) {\n drawImage(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawCircle)) {\n drawCircle(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawPoints)) {\n drawPoints(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawPath)) {\n drawPath(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawRect)) {\n drawRect(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawRRect)) {\n drawRRect(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawOval)) {\n drawOval(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawLine)) {\n drawLine(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawPatch)) {\n drawPatch(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawVertices)) {\n drawVertices(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawDiffRect)) {\n drawDiffRect(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawText)) {\n drawText(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawTextPath)) {\n drawTextPath(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawTextBlob)) {\n drawTextBlob(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawGlyphs)) {\n drawGlyphs(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawPicture)) {\n drawPicture(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawImageSVG)) {\n drawImageSVG(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawParagraph)) {\n drawParagraph(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawAtlas)) {\n drawAtlas(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawSkottie)) {\n drawSkottie(ctx, command.props);\n } else {\n console.warn(`Unknown command: ${command.type}`);\n }\n ctx.paints.pop();\n });\n }\n};\nexport function replay(ctx: DrawingContext, commands: Command[]) {\n \"worklet\";\n //console.log(debugTree(commands));\n commands.forEach((command) => {\n play(ctx, command);\n });\n}\n"],"mappings":"AAEA,SACEA,UAAU,EACVC,SAAS,EACTC,QAAQ,EACRC,QAAQ,EACRC,UAAU,EACVC,QAAQ,EACRC,SAAS,EACTC,QAAQ,EACRC,SAAS,EACTC,aAAa,EACbC,YAAY,EACZC,WAAW,EACXC,UAAU,EACVC,YAAY,EACZC,YAAY,EACZC,QAAQ,EACRC,YAAY,EACZC,YAAY,EACZC,SAAS,EACTC,WAAW,QACN,oBAAoB;AAC3B,SAASC,OAAO,EAAEC,YAAY,QAAQ,gBAAgB;AACtD,SACEC,mBAAmB,EACnBC,iBAAiB,EACjBC,eAAe,QACV,yBAAyB;AAChC,SAASC,OAAO,QAAQ,gBAAgB;AACxC,SACEC,iBAAiB,EACjBC,iBAAiB,EACjBC,eAAe,EACfC,mBAAmB,QACd,yBAAyB;AAChC,SAASC,kBAAkB,QAAQ,kBAAkB;AACrD,SACEC,kBAAkB,EAClBC,gBAAgB,EAChBC,cAAc,QACT,wBAAwB;AAC/B,SAASC,YAAY,EAAEC,UAAU,QAAQ,oBAAoB;AAC7D,SACEC,WAAW,EACXC,SAAS,EACTC,aAAa,EACbC,OAAO,EACPC,kBAAkB,QAC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O,EAAEN,WAAW,CAACmF,WAAW,CAAC,EAAE;QAC1D5G,WAAW,CAACuC,GAAG,EAAER,OAAO,CAACI,KAAK,CAAC;MACjC,CAAC,MAAM,IAAIR,aAAa,CAACI,OAAO,EAAEN,WAAW,CAACoF,YAAY,CAAC,EAAE;QAC3D9G,YAAY,CAACwC,GAAG,EAAER,OAAO,CAACI,KAAK,CAAC;MAClC,CAAC,MAAM,IAAIR,aAAa,CAACI,OAAO,EAAEN,WAAW,CAACqF,aAAa,CAAC,EAAE;QAC5DhH,aAAa,CAACyC,GAAG,EAAER,OAAO,CAACI,KAAK,CAAC;MACnC,CAAC,MAAM,IAAIR,aAAa,CAACI,OAAO,EAAEN,WAAW,CAACsF,SAAS,CAAC,EAAE;QACxDlH,SAAS,CAAC0C,GAAG,EAAER,OAAO,CAACI,KAAK,CAAC;MAC/B,CAAC,MAAM,IAAIR,aAAa,CAACI,OAAO,EAAEN,WAAW,CAACuF,WAAW,CAAC,EAAE;QAC1DxG,WAAW,CAAC+B,GAAG,EAAER,OAAO,CAACI,KAAK,CAAC;MACjC,CAAC,MAAM;QACL8E,OAAO,CAACC,IAAI,CAAC,oBAAoBnF,OAAO,CAACoF,IAAI,EAAE,CAAC;MAClD;MACA5E,GAAG,CAAC2B,MAAM,CAACJ,GAAG,CAAC,CAAC;IAClB,CAAC,CAAC;EACJ;AACF,CAAC;AACD,OAAO,SAASsD,MAAMA,CAAC7E,GAAmB,EAAE8E,QAAmB,EAAE;EAC/D,SAAS;;EACT;EACAA,QAAQ,CAACtE,OAAO,CAAEhB,OAAO,IAAK;IAC5BuB,IAAI,CAACf,GAAG,EAAER,OAAO,CAAC;EACpB,CAAC,CAAC;AACJ","ignoreList":[]}
|
|
@@ -2,12 +2,14 @@ import type { SharedValue } from "react-native-reanimated";
|
|
|
2
2
|
import { NodeType } from "../../dom/types";
|
|
3
3
|
import type { BlurMaskFilterProps, CircleProps, CTMProps, ImageProps, PaintProps, PointsProps, PathProps, RectProps, RoundedRectProps, OvalProps, LineProps, PatchProps, VerticesProps, DiffRectProps, TextProps, TextPathProps, TextBlobProps, GlyphsProps, PictureProps, ImageSVGProps, ParagraphProps, AtlasProps, BoxProps, BoxShadowProps, SkottieProps, DrawingNodeProps } from "../../dom/types";
|
|
4
4
|
import type { AnimatedProps } from "../../renderer";
|
|
5
|
-
import type { SkPaint, BaseRecorder } from "../../skia/types";
|
|
5
|
+
import type { SkPaint, SkPicture, BaseRecorder } from "../../skia/types";
|
|
6
6
|
import type { Command } from "./Core";
|
|
7
7
|
export interface Recording {
|
|
8
8
|
commands: Command[];
|
|
9
9
|
paintPool: SkPaint[];
|
|
10
|
+
lastPicture?: SkPicture | null;
|
|
10
11
|
}
|
|
12
|
+
export declare const disposeRecording: (recording: Recording) => void;
|
|
11
13
|
interface AnimationValues {
|
|
12
14
|
animationValues: Set<SharedValue<unknown>>;
|
|
13
15
|
}
|