@shopify/react-native-skia 2.11.2 → 2.12.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/Package.swift +117 -0
- package/android/CMakeLists.txt +1 -2
- package/cpp/api/JsiSkSVGFactory.h +4 -0
- package/cpp/jsi/JSICache.cpp +99 -0
- package/cpp/jsi/JSICache.h +90 -0
- package/cpp/jsi/NativeObject.h +30 -97
- package/cpp/jsi/ViewProperty.h +0 -24
- package/cpp/rnskia/RNDawnContext.h +2 -1
- package/cpp/rnskia/RNDawnWindowContext.h +22 -0
- package/cpp/rnskia/RNSkManager.cpp +0 -11
- package/cpp/skia/include/core/RasterContext.h +25 -0
- package/cpp/skia/include/core/SkCanvas.h +0 -1
- package/cpp/skia/include/core/SkContext.h +62 -0
- package/cpp/skia/include/core/SkContextOptions.h +15 -0
- package/cpp/skia/include/core/SkMilestone.h +1 -1
- package/cpp/skia/include/core/SkPicture.h +36 -18
- package/cpp/skia/include/core/SkRecorder.h +8 -0
- package/cpp/skia/include/core/SkSerialProcs.h +2 -6
- package/cpp/skia/include/effects/SkImageFilters.h +15 -2
- package/cpp/skia/include/gpu/ganesh/GrDirectContext.h +73 -47
- package/cpp/skia/include/gpu/ganesh/SkSurfaceGanesh.h +7 -4
- package/cpp/skia/include/gpu/ganesh/d3d/GrD3DDirectContext.h +12 -0
- package/cpp/skia/include/gpu/ganesh/gl/GrGLDirectContext.h +11 -0
- package/cpp/skia/include/gpu/ganesh/mtl/GrMtlDirectContext.h +11 -0
- package/cpp/skia/include/gpu/ganesh/vk/GrVkDirectContext.h +13 -0
- package/cpp/skia/include/gpu/graphite/ContextOptions.h +6 -0
- package/cpp/skia/include/gpu/graphite/GraphiteTypes.h +5 -4
- package/cpp/skia/include/gpu/graphite/PrecompileContext.h +9 -1
- package/cpp/skia/include/gpu/graphite/Recorder.h +0 -2
- package/cpp/skia/include/gpu/graphite/Recording.h +3 -0
- package/cpp/skia/include/gpu/graphite/dawn/DawnBackendContext.h +8 -0
- package/cpp/skia/include/gpu/graphite/mtl/MtlBackendContext.h +11 -0
- package/cpp/skia/include/gpu/graphite/vk/VulkanGraphiteContext.h +11 -0
- package/cpp/skia/include/private/SkLog.h +1 -19
- package/cpp/skia/include/private/chromium/GrVkSecondaryCBDrawContext.h +2 -1
- package/cpp/skia/include/utils/SkLogHandler.h +53 -0
- package/cpp/skia/include/utils/SkNWayCanvas.h +1 -0
- package/cpp/skia/modules/skcms/src/Transform_inl.h +9 -10
- package/cpp/skia/modules/skcms/src/skcms_internals.h +8 -3
- package/cpp/skia/modules/skottie/include/SkottieProperty.h +2 -0
- package/cpp/skia/modules/skottie/include/TextShaper.h +1 -0
- package/cpp/skia/modules/skshaper/include/SkShaper.h +23 -1
- package/include/ReactNativeSkia.h +6 -0
- package/lib/commonjs/skia/web/JsiSkCanvas.js +4 -4
- package/lib/commonjs/skia/web/JsiSkCanvas.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkImage.js +6 -3
- package/lib/commonjs/skia/web/JsiSkImage.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkPathBuilder.d.ts +1 -1
- package/lib/commonjs/skia/web/JsiSkPathBuilder.js +2 -2
- package/lib/commonjs/skia/web/JsiSkPathBuilder.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkTextStyle.js +5 -5
- package/lib/commonjs/skia/web/JsiSkTextStyle.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkottieAnimation.js +8 -8
- package/lib/commonjs/skia/web/JsiSkottieAnimation.js.map +1 -1
- package/lib/commonjs/sksg/Recorder/commands/Drawing.js +2 -1
- package/lib/commonjs/sksg/Recorder/commands/Drawing.js.map +1 -1
- package/lib/commonjs/views/SkiaPictureView.web.js +228 -43
- package/lib/commonjs/views/SkiaPictureView.web.js.map +1 -1
- package/lib/module/skia/web/JsiSkCanvas.js +4 -4
- package/lib/module/skia/web/JsiSkCanvas.js.map +1 -1
- package/lib/module/skia/web/JsiSkImage.js +6 -3
- package/lib/module/skia/web/JsiSkImage.js.map +1 -1
- package/lib/module/skia/web/JsiSkPathBuilder.d.ts +1 -1
- package/lib/module/skia/web/JsiSkPathBuilder.js +2 -2
- package/lib/module/skia/web/JsiSkPathBuilder.js.map +1 -1
- package/lib/module/skia/web/JsiSkTextStyle.js +5 -5
- package/lib/module/skia/web/JsiSkTextStyle.js.map +1 -1
- package/lib/module/skia/web/JsiSkottieAnimation.js +8 -8
- package/lib/module/skia/web/JsiSkottieAnimation.js.map +1 -1
- package/lib/module/sksg/Recorder/commands/Drawing.js +2 -1
- package/lib/module/sksg/Recorder/commands/Drawing.js.map +1 -1
- package/lib/module/views/SkiaPictureView.web.js +228 -43
- package/lib/module/views/SkiaPictureView.web.js.map +1 -1
- package/lib/typescript/lib/commonjs/skia/web/JsiSkPathBuilder.d.ts +1 -1
- package/lib/typescript/lib/module/skia/web/JsiSkPathBuilder.d.ts +1 -1
- package/lib/typescript/react-native.config.d.ts +3 -0
- package/lib/typescript/src/skia/web/JsiSkPathBuilder.d.ts +1 -1
- package/package.json +12 -9
- package/react-native.config.js +5 -0
- package/src/skia/web/JsiSkCanvas.ts +11 -6
- package/src/skia/web/JsiSkImage.ts +6 -3
- package/src/skia/web/JsiSkPathBuilder.ts +2 -2
- package/src/skia/web/JsiSkTextStyle.ts +20 -15
- package/src/skia/web/JsiSkottieAnimation.ts +8 -8
- package/src/sksg/Recorder/commands/Drawing.ts +2 -1
- package/src/views/SkiaPictureView.web.tsx +228 -43
- package/cpp/jsi/RuntimeAwareCache.cpp +0 -8
- package/cpp/jsi/RuntimeAwareCache.h +0 -146
- package/cpp/jsi/RuntimeLifecycleMonitor.cpp +0 -72
- package/cpp/jsi/RuntimeLifecycleMonitor.h +0 -32
|
@@ -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","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","trimmed","Path","Trim","builder","PathBuilder","MakeFromPath","setFillType","build","stroked","Stroke","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 // Trim runs first, so start/end address the path the caller drew. Stroking\n // first would replace it with its outline and leave the offsets walking that\n // outline's perimeter instead. The native recorder orders these the same way.\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 // 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 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,GAAGA,CAACX,GAAmB,EAAEC,KAAiB,KAAK;EACnE,SAAS;;EACT,MAAM;IAAEW,KAAK;IAAEC;EAAS,CAAC,GAAGZ,KAAK;EACjC,IAAIW,KAAK,EAAE;IAAA,IAAAE,UAAA;IACT,MAAMC,GAAG,IAAAD,UAAA,GAAGb,KAAK,CAACc,GAAG,cAAAD,UAAA,cAAAA,UAAA,GAAI,SAAS;IAClC,MAAML,IA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AAC,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":[]}
|
|
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","trimmed","Path","Trim","builder","PathBuilder","MakeFromPath","setFillType","build","stroked","Stroke","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 // Trim runs first, so start/end address the path the caller drew. Stroking\n // first would replace it with its outline and leave the offsets walking that\n // outline's perimeter instead. The native recorder orders these the same way.\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 // 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 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 // An offset of 0 is a valid position, so it must not be read as \"unset\".\n if (x !== undefined && y !== undefined) {\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,CA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AEtG,MAAM;IAAEuG,cAAc;IAAE7H;EAAS,CAAC,GACpEZ,KAAK;EACP,MAAM+C,KAAK,GAAG0F,cAAc,GAAGlJ,SAAS,CAACR,OAAO,CAAC0J,cAAc,CAAC,CAAC,GAAG9F,SAAS;EAC7E,IAAIhC,KAAK,EAAE;IACTZ,GAAG,CAACI,MAAM,CAACmI,SAAS,CAClB3H,KAAK,EACL4H,OAAO,EACPC,UAAU,EACVzI,GAAG,CAACO,KAAK,EACTyC,KAAK,EACLb,MAAM,EACNtB,QACF,CAAC;EACH;AACF,CAAC;AAED,OAAO,MAAM8H,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":[]}
|
|
@@ -17,31 +17,189 @@ const dp2Pixel = (pd, rect) => {
|
|
|
17
17
|
height: rect.height * pd
|
|
18
18
|
};
|
|
19
19
|
};
|
|
20
|
+
|
|
21
|
+
// A <canvas> element owns at most one WebGL context for its whole lifetime.
|
|
22
|
+
// A renderer, on the other hand, lives as long as the layout effect that
|
|
23
|
+
// creates it, which is shorter: React re-runs layout effects on a *preserved*
|
|
24
|
+
// host node under StrictMode's DEV double-invoke and when an Activity/offscreen
|
|
25
|
+
// subtree is hidden and revealed (#3976). What belongs to the element rather
|
|
26
|
+
// than to a renderer is tracked here, per element:
|
|
27
|
+
// - the context, so that a new renderer can tell whether the element already
|
|
28
|
+
// has one (and whether it is lost) without calling getContext() itself,
|
|
29
|
+
// which on a fresh element would create a context with the wrong attributes
|
|
30
|
+
// (CanvasKit.GetWebGLContext requests its own);
|
|
31
|
+
// - the WEBGL_lose_context extension, captured while the context is healthy:
|
|
32
|
+
// getExtension() returns null on a lost context, and this object is the only
|
|
33
|
+
// way to lose a context on purpose or to ask the browser to restore one;
|
|
34
|
+
// - whether the browser has announced the loss of the context yet: a lost
|
|
35
|
+
// context can only be restored once its webglcontextlost event has been
|
|
36
|
+
// dispatched, and that event is asynchronous;
|
|
37
|
+
// - the renderer currently attached to the element, if any.
|
|
38
|
+
|
|
39
|
+
const canvasWebGL = new WeakMap();
|
|
40
|
+
|
|
41
|
+
// Unregisters a context from CanvasKit's registry, which otherwise retains the
|
|
42
|
+
// canvas element (and its detached DOM tree) forever (#3924).
|
|
43
|
+
const deleteContextHandle = handle => {
|
|
44
|
+
CanvasKit.deleteContext(handle);
|
|
45
|
+
// Making the now-deleted handle current clears CanvasKit's current-context
|
|
46
|
+
// globals (GLctx/Module.ctx), which would otherwise keep referencing the
|
|
47
|
+
// context (and the canvas) until another surface becomes current. With a
|
|
48
|
+
// deleted handle this is a no-op that returns null without creating
|
|
49
|
+
// anything.
|
|
50
|
+
CanvasKit.MakeWebGLContext(handle);
|
|
51
|
+
};
|
|
20
52
|
class WebGLRenderer {
|
|
21
|
-
constructor(canvas
|
|
53
|
+
constructor(canvas,
|
|
54
|
+
// Called when the renderer becomes able to paint again and the current
|
|
55
|
+
// picture should be drawn.
|
|
56
|
+
requestRedraw) {
|
|
22
57
|
this.canvas = canvas;
|
|
58
|
+
this.requestRedraw = requestRedraw;
|
|
23
59
|
_defineProperty(this, "surface", null);
|
|
24
60
|
_defineProperty(this, "grContext", null);
|
|
25
61
|
_defineProperty(this, "contextHandle", 0);
|
|
26
62
|
_defineProperty(this, "pd", 1);
|
|
27
|
-
|
|
28
|
-
|
|
63
|
+
// Set while the renderer is waiting for a lost context to be restored.
|
|
64
|
+
_defineProperty(this, "restoreWanted", false);
|
|
65
|
+
_defineProperty(this, "restoreRequest", null);
|
|
66
|
+
_defineProperty(this, "onContextLost", () => {
|
|
67
|
+
// The browser already dropped every GL object; drop our references to
|
|
68
|
+
// them. Restoration is left to the browser (it restores an evicted
|
|
69
|
+
// context as soon as a slot frees up), except when this renderer was
|
|
70
|
+
// built on an already-lost context and is waiting to paint for the first
|
|
71
|
+
// time: chasing an eviction from here would evict the next-oldest context
|
|
72
|
+
// in turn, and with more live canvases than the browser allows the
|
|
73
|
+
// canvases would endlessly evict each other.
|
|
74
|
+
this.release();
|
|
75
|
+
if (this.restoreWanted) {
|
|
76
|
+
// The permission granted by preventDefault() is only recorded by the
|
|
77
|
+
// browser once the event dispatch is over: a restoreContext() call
|
|
78
|
+
// from inside the handler is refused, so ask from a later task.
|
|
79
|
+
this.restoreRequest = setTimeout(() => {
|
|
80
|
+
var _canvasWebGL$get;
|
|
81
|
+
this.restoreRequest = null;
|
|
82
|
+
(_canvasWebGL$get = canvasWebGL.get(this.canvas)) === null || _canvasWebGL$get === void 0 || (_canvasWebGL$get = _canvasWebGL$get.loseContext) === null || _canvasWebGL$get === void 0 || _canvasWebGL$get.restoreContext();
|
|
83
|
+
}, 0);
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
_defineProperty(this, "onContextRestored", () => {
|
|
87
|
+
this.acquire();
|
|
88
|
+
this.requestRedraw();
|
|
89
|
+
});
|
|
90
|
+
const entry = canvasWebGL.get(canvas);
|
|
91
|
+
if (entry) {
|
|
92
|
+
entry.owner = this;
|
|
93
|
+
}
|
|
94
|
+
canvas.addEventListener("webglcontextlost", this.onContextLost);
|
|
95
|
+
canvas.addEventListener("webglcontextrestored", this.onContextRestored);
|
|
96
|
+
this.acquire();
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
// Builds the GrDirectContext and the surface on the element's WebGL
|
|
100
|
+
// context, creating the context first if the element has none.
|
|
101
|
+
acquire() {
|
|
102
|
+
const {
|
|
103
|
+
canvas
|
|
104
|
+
} = this;
|
|
105
|
+
const known = canvasWebGL.get(canvas);
|
|
106
|
+
if (known !== null && known !== void 0 && known.gl.isContextLost()) {
|
|
107
|
+
// Nothing can be built on a lost context: CanvasKit.GetWebGLContext
|
|
108
|
+
// happily registers it, and MakeWebGLContext then faults inside wasm
|
|
109
|
+
// (#3976). Ask the browser for it back and finish in onContextRestored;
|
|
110
|
+
// if the loss hasn't been announced yet, onContextLost asks.
|
|
111
|
+
this.restoreWanted = true;
|
|
112
|
+
if (known.lossAnnounced) {
|
|
113
|
+
var _known$loseContext;
|
|
114
|
+
(_known$loseContext = known.loseContext) === null || _known$loseContext === void 0 || _known$loseContext.restoreContext();
|
|
115
|
+
}
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
const handle = CanvasKit.GetWebGLContext(canvas);
|
|
119
|
+
if (!handle) {
|
|
29
120
|
throw new Error("Could not create a WebGL context");
|
|
30
121
|
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
122
|
+
const entry = known !== null && known !== void 0 ? known : this.trackContext();
|
|
123
|
+
let grContext = null;
|
|
124
|
+
try {
|
|
125
|
+
grContext = CanvasKit.MakeWebGLContext(handle);
|
|
126
|
+
} finally {
|
|
127
|
+
if (!grContext) {
|
|
128
|
+
// Whether it returned null or threw, don't leave the registry
|
|
129
|
+
// holding on to the canvas.
|
|
130
|
+
deleteContextHandle(handle);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
if (!grContext) {
|
|
35
134
|
throw new Error("Could not create a graphics context");
|
|
36
135
|
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
136
|
+
this.restoreWanted = false;
|
|
137
|
+
this.contextHandle = handle;
|
|
138
|
+
this.grContext = grContext;
|
|
139
|
+
if (entry) {
|
|
140
|
+
entry.gl.drawingBufferColorSpace = "display-p3";
|
|
40
141
|
}
|
|
41
142
|
this.onResize();
|
|
42
143
|
}
|
|
144
|
+
|
|
145
|
+
// CanvasKit just created the element's context; asking for it again hands
|
|
146
|
+
// back the same object (the attributes are only honored the first time).
|
|
147
|
+
trackContext() {
|
|
148
|
+
var _canvas$getContext;
|
|
149
|
+
const {
|
|
150
|
+
canvas
|
|
151
|
+
} = this;
|
|
152
|
+
const gl = (_canvas$getContext = canvas.getContext("webgl2")) !== null && _canvas$getContext !== void 0 ? _canvas$getContext : canvas.getContext("webgl");
|
|
153
|
+
if (!gl) {
|
|
154
|
+
return null;
|
|
155
|
+
}
|
|
156
|
+
const entry = {
|
|
157
|
+
gl,
|
|
158
|
+
loseContext: gl.getExtension("WEBGL_lose_context"),
|
|
159
|
+
lossAnnounced: false,
|
|
160
|
+
owner: this
|
|
161
|
+
};
|
|
162
|
+
canvasWebGL.set(canvas, entry);
|
|
163
|
+
// Browsers restore a lost context (evicted as the oldest one when the
|
|
164
|
+
// page exceeds the active-context limit, or lost to a GPU reset) only if
|
|
165
|
+
// the page called preventDefault() on the webglcontextlost event. A
|
|
166
|
+
// renderer isn't necessarily attached when that happens (the canvas may
|
|
167
|
+
// be in a hidden Activity), so these listeners live as long as the
|
|
168
|
+
// element does. They are registered ahead of any renderer's, and the
|
|
169
|
+
// loss can't be announced before they exist since the event is
|
|
170
|
+
// asynchronous.
|
|
171
|
+
canvas.addEventListener("webglcontextlost", event => {
|
|
172
|
+
event.preventDefault();
|
|
173
|
+
entry.lossAnnounced = true;
|
|
174
|
+
});
|
|
175
|
+
canvas.addEventListener("webglcontextrestored", () => {
|
|
176
|
+
entry.lossAnnounced = false;
|
|
177
|
+
});
|
|
178
|
+
return entry;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
// Frees everything built on the context. The context itself belongs to the
|
|
182
|
+
// element, see dispose().
|
|
183
|
+
release() {
|
|
184
|
+
var _this$surface;
|
|
185
|
+
(_this$surface = this.surface) === null || _this$surface === void 0 || _this$surface.ref.delete();
|
|
186
|
+
this.surface = null;
|
|
187
|
+
if (this.grContext) {
|
|
188
|
+
this.grContext.releaseResourcesAndAbandonContext();
|
|
189
|
+
this.grContext.delete();
|
|
190
|
+
this.grContext = null;
|
|
191
|
+
}
|
|
192
|
+
if (this.contextHandle) {
|
|
193
|
+
deleteContextHandle(this.contextHandle);
|
|
194
|
+
this.contextHandle = 0;
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
isContextLost() {
|
|
198
|
+
var _canvasWebGL$get$gl$i, _canvasWebGL$get2;
|
|
199
|
+
return (_canvasWebGL$get$gl$i = (_canvasWebGL$get2 = canvasWebGL.get(this.canvas)) === null || _canvasWebGL$get2 === void 0 ? void 0 : _canvasWebGL$get2.gl.isContextLost()) !== null && _canvasWebGL$get$gl$i !== void 0 ? _canvasWebGL$get$gl$i : false;
|
|
200
|
+
}
|
|
43
201
|
makeImageSnapshot(picture, rect) {
|
|
44
|
-
if (!this.surface) {
|
|
202
|
+
if (!this.surface || this.isContextLost()) {
|
|
45
203
|
return null;
|
|
46
204
|
}
|
|
47
205
|
const canvas = this.surface.getCanvas();
|
|
@@ -51,17 +209,20 @@ class WebGLRenderer {
|
|
|
51
209
|
return this.surface.makeImageSnapshot(dp2Pixel(this.pd, rect));
|
|
52
210
|
}
|
|
53
211
|
onResize() {
|
|
54
|
-
var _this$
|
|
212
|
+
var _this$surface2;
|
|
55
213
|
const {
|
|
56
214
|
canvas
|
|
57
215
|
} = this;
|
|
58
|
-
if (!this.grContext) {
|
|
216
|
+
if (!this.grContext || this.isContextLost()) {
|
|
217
|
+
// Waiting for the context to be restored (the restore path resizes),
|
|
218
|
+
// or the loss hasn't been announced yet and onContextLost is about to
|
|
219
|
+
// release everything: either way there is nothing to build on.
|
|
59
220
|
return;
|
|
60
221
|
}
|
|
61
222
|
this.pd = window.devicePixelRatio;
|
|
62
223
|
canvas.width = canvas.clientWidth * this.pd;
|
|
63
224
|
canvas.height = canvas.clientHeight * this.pd;
|
|
64
|
-
(_this$
|
|
225
|
+
(_this$surface2 = this.surface) === null || _this$surface2 === void 0 || _this$surface2.ref.delete();
|
|
65
226
|
this.surface = null;
|
|
66
227
|
if (canvas.width === 0 || canvas.height === 0) {
|
|
67
228
|
// The canvas hasn't been laid out yet (or is hidden). The view's
|
|
@@ -77,38 +238,55 @@ class WebGLRenderer {
|
|
|
77
238
|
this.surface = new JsiSkSurface(CanvasKit, surface);
|
|
78
239
|
}
|
|
79
240
|
draw(picture) {
|
|
80
|
-
if (this.surface) {
|
|
81
|
-
|
|
82
|
-
canvas.clear(Float32Array.of(0, 0, 0, 0));
|
|
83
|
-
canvas.save();
|
|
84
|
-
canvas.scale(this.pd, this.pd);
|
|
85
|
-
canvas.drawPicture(picture);
|
|
86
|
-
canvas.restore();
|
|
87
|
-
this.surface.ref.flush();
|
|
241
|
+
if (!this.surface || this.isContextLost()) {
|
|
242
|
+
return;
|
|
88
243
|
}
|
|
244
|
+
const canvas = this.surface.getCanvas();
|
|
245
|
+
canvas.clear(Float32Array.of(0, 0, 0, 0));
|
|
246
|
+
canvas.save();
|
|
247
|
+
canvas.scale(this.pd, this.pd);
|
|
248
|
+
canvas.drawPicture(picture);
|
|
249
|
+
canvas.restore();
|
|
250
|
+
this.surface.ref.flush();
|
|
89
251
|
}
|
|
90
252
|
dispose() {
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
this.
|
|
253
|
+
const {
|
|
254
|
+
canvas
|
|
255
|
+
} = this;
|
|
256
|
+
canvas.removeEventListener("webglcontextlost", this.onContextLost);
|
|
257
|
+
canvas.removeEventListener("webglcontextrestored", this.onContextRestored);
|
|
258
|
+
if (this.restoreRequest !== null) {
|
|
259
|
+
clearTimeout(this.restoreRequest);
|
|
260
|
+
this.restoreRequest = null;
|
|
98
261
|
}
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
262
|
+
this.restoreWanted = false;
|
|
263
|
+
this.release();
|
|
264
|
+
// Free the drawing buffer, which CanvasKit requests with depth and stencil
|
|
265
|
+
// attachments (about 8 bytes per pixel): a canvas that stays in the
|
|
266
|
+
// document without a renderer, hidden in an Activity say, would otherwise
|
|
267
|
+
// keep a full-size buffer around. The next renderer's onResize() sizes it
|
|
268
|
+
// again.
|
|
269
|
+
canvas.width = 0;
|
|
270
|
+
canvas.height = 0;
|
|
271
|
+
const entry = canvasWebGL.get(canvas);
|
|
272
|
+
if (!entry) {
|
|
273
|
+
return;
|
|
111
274
|
}
|
|
275
|
+
entry.owner = null;
|
|
276
|
+
// Whether the element is going away is only known once the commit is
|
|
277
|
+
// over: on a real unmount React runs this cleanup *before* removing the
|
|
278
|
+
// node from the document, while StrictMode's double-invoke and an
|
|
279
|
+
// Activity hide keep the node in place (and the former builds the next
|
|
280
|
+
// renderer on it right away). Losing the context of a detached element
|
|
281
|
+
// matters: it would otherwise stay alive until the element is garbage
|
|
282
|
+
// collected, and browsers cap the number of live contexts per page
|
|
283
|
+
// (16 in Chrome, which then evicts the oldest one, visible or not).
|
|
284
|
+
queueMicrotask(() => {
|
|
285
|
+
if (entry.owner === null && !canvas.isConnected && !entry.gl.isContextLost()) {
|
|
286
|
+
var _entry$loseContext;
|
|
287
|
+
(_entry$loseContext = entry.loseContext) === null || _entry$loseContext === void 0 || _entry$loseContext.loseContext();
|
|
288
|
+
}
|
|
289
|
+
});
|
|
112
290
|
}
|
|
113
291
|
}
|
|
114
292
|
class StaticWebGLRenderer {
|
|
@@ -295,6 +473,9 @@ export const SkiaPictureView = props => {
|
|
|
295
473
|
// - A ResizeObserver on the canvas itself recreates the surface and repaints
|
|
296
474
|
// synchronously (its callbacks run after layout, before paint), and is
|
|
297
475
|
// also the source of the user-facing onLayout event.
|
|
476
|
+
// - The renderer belongs to the layout effect, the WebGL context to the
|
|
477
|
+
// <canvas> element, whose lifetime is longer; see WebGLRenderer for how
|
|
478
|
+
// the two are reconciled.
|
|
298
479
|
const redrawPendingRef = useRef(false);
|
|
299
480
|
const flushScheduledRef = useRef(false);
|
|
300
481
|
const onLayoutRef = useRef(onLayout);
|
|
@@ -369,7 +550,7 @@ export const SkiaPictureView = props => {
|
|
|
369
550
|
if (!canvas) {
|
|
370
551
|
return undefined;
|
|
371
552
|
}
|
|
372
|
-
const renderer = isStatic ? new StaticWebGLRenderer(canvas) : new WebGLRenderer(canvas);
|
|
553
|
+
const renderer = isStatic ? new StaticWebGLRenderer(canvas) : new WebGLRenderer(canvas, redraw);
|
|
373
554
|
rendererRef.current = renderer;
|
|
374
555
|
const drawPicture = () => {
|
|
375
556
|
if (pictureRef.current) {
|
|
@@ -448,7 +629,7 @@ export const SkiaPictureView = props => {
|
|
|
448
629
|
rendererRef.current = null;
|
|
449
630
|
renderer.dispose();
|
|
450
631
|
};
|
|
451
|
-
}, [isStatic]);
|
|
632
|
+
}, [isStatic, redraw]);
|
|
452
633
|
|
|
453
634
|
// No flush cancellation is needed on unmount: a microtask queued before
|
|
454
635
|
// unmount runs within the same task, and flushRedraw no-ops once the
|
|
@@ -495,6 +676,10 @@ export const SkiaPictureView = props => {
|
|
|
495
676
|
...viewProps
|
|
496
677
|
} = props;
|
|
497
678
|
return /*#__PURE__*/React.createElement(Platform.View, viewProps, /*#__PURE__*/React.createElement("canvas", {
|
|
679
|
+
// A canvas element is bound to one context kind for life (WebGL for
|
|
680
|
+
// the live renderer, 2D for the static one), so switching renderers
|
|
681
|
+
// needs a fresh element.
|
|
682
|
+
key: isStatic ? "static" : "webgl",
|
|
498
683
|
ref: canvasRef,
|
|
499
684
|
style: {
|
|
500
685
|
display: "block",
|