@shopify/react-native-skia 0.1.129 → 0.1.130
Sign up to get free protection for your applications and to get access to all the features.
- package/android/cpp/rnskia-android/SkiaOpenGLRenderer.h +1 -0
- package/cpp/api/JsiSkRuntimeEffect.h +7 -9
- package/cpp/api/JsiSkVertices.h +0 -2
- package/cpp/rnskia/values/RNSkValue.h +1 -1
- package/cpp/skia/include/codec/SkCodec.h +7 -1
- package/cpp/skia/include/core/SkAlphaType.h +45 -0
- package/cpp/skia/include/core/SkBitmap.h +4 -2
- package/cpp/skia/include/core/SkCanvas.h +31 -20
- package/cpp/skia/include/core/SkColor.h +1 -1
- package/cpp/skia/include/core/SkColorFilter.h +1 -0
- package/cpp/skia/include/core/SkColorType.h +66 -0
- package/cpp/skia/include/core/SkDeferredDisplayListRecorder.h +1 -1
- package/cpp/skia/include/core/SkDrawable.h +7 -0
- package/cpp/skia/include/core/SkEncodedImageFormat.h +1 -0
- package/cpp/skia/include/core/SkFont.h +4 -3
- package/cpp/skia/include/core/SkFontArguments.h +33 -1
- package/cpp/skia/include/core/SkGraphics.h +13 -0
- package/cpp/skia/include/core/SkImage.h +67 -22
- package/cpp/skia/include/core/SkImageEncoder.h +0 -3
- package/cpp/skia/include/core/SkImageGenerator.h +4 -3
- package/cpp/skia/include/core/SkImageInfo.h +35 -142
- package/cpp/skia/include/core/SkMesh.h +303 -0
- package/cpp/skia/include/core/SkMilestone.h +1 -1
- package/cpp/skia/include/core/SkOpenTypeSVGDecoder.h +30 -0
- package/cpp/skia/include/core/SkPaint.h +4 -19
- package/cpp/skia/include/core/SkPath.h +20 -33
- package/cpp/skia/include/core/SkPathBuilder.h +1 -6
- package/cpp/skia/include/core/SkPixelRef.h +1 -1
- package/cpp/skia/include/core/SkPixmap.h +3 -2
- package/cpp/skia/include/core/SkRSXform.h +1 -1
- package/cpp/skia/include/core/SkSamplingOptions.h +16 -5
- package/cpp/skia/include/core/SkSpan.h +5 -5
- package/cpp/skia/include/core/SkString.h +5 -8
- package/cpp/skia/include/core/SkSurface.h +21 -0
- package/cpp/skia/include/core/SkTypeface.h +20 -4
- package/cpp/skia/include/core/SkTypes.h +9 -5
- package/cpp/skia/include/effects/SkGradientShader.h +9 -18
- package/cpp/skia/include/effects/SkRuntimeEffect.h +16 -12
- package/cpp/skia/include/gpu/GpuTypes.h +32 -0
- package/cpp/skia/include/gpu/GrBackendSemaphore.h +1 -1
- package/cpp/skia/include/gpu/GrBackendSurface.h +6 -5
- package/cpp/skia/include/gpu/GrBackendSurfaceMutableState.h +1 -1
- package/cpp/skia/include/gpu/GrContextOptions.h +11 -20
- package/cpp/skia/include/gpu/GrContextThreadSafeProxy.h +7 -0
- package/cpp/skia/include/gpu/GrDirectContext.h +16 -11
- package/cpp/skia/include/gpu/GrDriverBugWorkaroundsAutogen.h +0 -2
- package/cpp/skia/include/gpu/GrRecordingContext.h +14 -7
- package/cpp/skia/include/gpu/GrSurfaceInfo.h +6 -6
- package/cpp/skia/include/gpu/dawn/GrDawnTypes.h +1 -1
- package/cpp/skia/include/gpu/gl/GrGLFunctions.h +3 -1
- package/cpp/skia/include/gpu/gl/GrGLInterface.h +2 -2
- package/cpp/skia/include/gpu/graphite/BackendTexture.h +64 -0
- package/cpp/skia/include/gpu/graphite/Context.h +124 -0
- package/cpp/skia/include/gpu/graphite/GraphiteTypes.h +71 -0
- package/cpp/skia/include/gpu/graphite/Recorder.h +104 -0
- package/cpp/skia/include/gpu/graphite/Recording.h +39 -0
- package/cpp/skia/include/gpu/graphite/SkStuff.h +47 -0
- package/cpp/skia/include/gpu/graphite/TextureInfo.h +91 -0
- package/cpp/skia/include/gpu/graphite/mtl/MtlBackendContext.h +24 -0
- package/cpp/skia/include/gpu/graphite/mtl/MtlTypes.h +68 -0
- package/cpp/skia/include/gpu/mock/GrMockTypes.h +1 -2
- package/cpp/skia/include/ports/SkCFObject.h +0 -4
- package/cpp/skia/include/ports/SkTypeface_win.h +2 -2
- package/cpp/skia/include/private/{GrSingleOwner.h → SingleOwner.h} +17 -10
- package/cpp/skia/include/private/SkChecksum.h +11 -0
- package/cpp/skia/include/private/SkEncodedInfo.h +22 -5
- package/cpp/skia/include/private/SkFloatingPoint.h +0 -53
- package/cpp/skia/include/private/SkImageInfoPriv.h +8 -2
- package/cpp/skia/include/private/SkMacros.h +13 -18
- package/cpp/skia/include/private/SkMutex.h +8 -0
- package/cpp/skia/include/private/SkPathRef.h +2 -16
- package/cpp/skia/include/private/SkSLDefines.h +9 -1
- package/cpp/skia/include/private/SkSLIRNode.h +6 -5
- package/cpp/skia/include/private/SkSLLayout.h +11 -10
- package/cpp/skia/include/private/SkSLModifiers.h +4 -3
- package/cpp/skia/include/private/SkSLProgramElement.h +2 -2
- package/cpp/skia/include/private/SkSLProgramKind.h +8 -5
- package/cpp/skia/include/private/SkSLStatement.h +2 -3
- package/cpp/skia/include/private/SkSLString.h +17 -56
- package/cpp/skia/include/private/SkSLSymbol.h +4 -4
- package/cpp/skia/include/private/SkShadowFlags.h +3 -1
- package/cpp/skia/include/private/SkStringView.h +47 -0
- package/cpp/skia/include/private/SkTArray.h +4 -3
- package/cpp/skia/include/private/SkTHash.h +66 -24
- package/cpp/skia/include/private/SkTLogic.h +2 -32
- package/cpp/skia/include/private/SkTemplates.h +2 -2
- package/cpp/skia/include/private/SkThreadAnnotations.h +4 -4
- package/cpp/skia/include/private/SkVx.h +28 -28
- package/cpp/skia/include/private/chromium/GrSlug.h +40 -3
- package/cpp/skia/include/private/chromium/SkChromeRemoteGlyphCache.h +12 -6
- package/cpp/skia/include/private/{GrContext_Base.h → gpu/ganesh/GrContext_Base.h} +7 -0
- package/cpp/skia/include/private/{GrD3DTypesMinimal.h → gpu/ganesh/GrD3DTypesMinimal.h} +0 -0
- package/cpp/skia/include/private/{GrDawnTypesPriv.h → gpu/ganesh/GrDawnTypesPriv.h} +0 -0
- package/cpp/skia/include/private/{GrGLTypesPriv.h → gpu/ganesh/GrGLTypesPriv.h} +1 -0
- package/cpp/skia/include/private/{GrImageContext.h → gpu/ganesh/GrImageContext.h} +4 -4
- package/cpp/skia/include/private/{GrMockTypesPriv.h → gpu/ganesh/GrMockTypesPriv.h} +0 -0
- package/cpp/skia/include/private/{GrMtlTypesPriv.h → gpu/ganesh/GrMtlTypesPriv.h} +0 -0
- package/cpp/skia/include/private/{GrTypesPriv.h → gpu/ganesh/GrTypesPriv.h} +25 -367
- package/cpp/skia/include/private/{GrVkTypesPriv.h → gpu/ganesh/GrVkTypesPriv.h} +0 -0
- package/cpp/skia/include/private/gpu/graphite/MtlTypesPriv.h +74 -0
- package/cpp/skia/include/sksl/DSL.h +4 -0
- package/cpp/skia/include/sksl/DSLBlock.h +8 -3
- package/cpp/skia/include/sksl/DSLCase.h +6 -6
- package/cpp/skia/include/sksl/DSLCore.h +89 -78
- package/cpp/skia/include/sksl/DSLExpression.h +78 -45
- package/cpp/skia/include/sksl/DSLFunction.h +23 -18
- package/cpp/skia/include/sksl/DSLLayout.h +14 -16
- package/cpp/skia/include/sksl/DSLModifiers.h +7 -5
- package/cpp/skia/include/sksl/DSLRuntimeEffects.h +1 -1
- package/cpp/skia/include/sksl/DSLStatement.h +16 -10
- package/cpp/skia/include/sksl/DSLSymbols.h +7 -7
- package/cpp/skia/include/sksl/DSLType.h +27 -23
- package/cpp/skia/include/sksl/DSLVar.h +72 -61
- package/cpp/skia/include/sksl/SkSLErrorReporter.h +12 -49
- package/cpp/skia/include/sksl/SkSLOperator.h +151 -0
- package/cpp/skia/include/sksl/SkSLPosition.h +102 -0
- package/cpp/skia/include/svg/SkSVGCanvas.h +5 -1
- package/cpp/skia/include/utils/SkAnimCodecPlayer.h +7 -0
- package/cpp/skia/include/utils/SkCamera.h +2 -0
- package/cpp/skia/include/utils/SkCanvasStateUtils.h +4 -1
- package/cpp/skia/include/utils/SkCustomTypeface.h +6 -4
- package/cpp/skia/include/utils/SkNWayCanvas.h +34 -0
- package/cpp/skia/include/utils/SkNullCanvas.h +5 -1
- package/cpp/skia/include/utils/SkOrderedFontMgr.h +12 -0
- package/cpp/skia/include/utils/SkPaintFilterCanvas.h +30 -1
- package/cpp/skia/include/utils/SkParse.h +2 -0
- package/cpp/skia/include/utils/SkShadowUtils.h +3 -2
- package/cpp/skia/include/utils/SkTextUtils.h +8 -4
- package/cpp/skia/modules/svg/include/SkSVGAttributeParser.h +27 -1
- package/cpp/skia/modules/svg/include/SkSVGDOM.h +4 -0
- package/cpp/skia/modules/svg/include/SkSVGOpenTypeSVGDecoder.h +32 -0
- package/cpp/skia/modules/svg/include/SkSVGRenderContext.h +3 -3
- package/cpp/skia/modules/svg/include/SkSVGSVG.h +2 -0
- package/cpp/skia/modules/svg/include/SkSVGTypes.h +48 -9
- package/ios/RNSkia-iOS/PlatformContext.h +1 -1
- package/ios/RNSkia-iOS/RNSkDrawViewImpl.mm +1 -0
- package/ios/RNSkia-iOS/SkiaDrawView.mm +1 -1
- package/lib/commonjs/renderer/components/shaders/Shader.js +1 -2
- package/lib/commonjs/renderer/components/shaders/Shader.js.map +1 -1
- package/lib/module/renderer/components/shaders/Shader.js +1 -2
- package/lib/module/renderer/components/shaders/Shader.js.map +1 -1
- package/lib/typescript/src/renderer/components/shaders/Shader.d.ts +0 -1
- package/lib/typescript/src/skia/types/RuntimeEffect/RuntimeEffect.d.ts +2 -4
- package/libs/android/arm64-v8a/libskia.a +0 -0
- package/libs/android/arm64-v8a/libsvg.a +0 -0
- package/libs/android/armeabi-v7a/libskia.a +0 -0
- package/libs/android/armeabi-v7a/libsvg.a +0 -0
- package/libs/android/x86/libskia.a +0 -0
- package/libs/android/x86/libsvg.a +0 -0
- package/libs/android/x86_64/libskia.a +0 -0
- package/libs/android/x86_64/libsvg.a +0 -0
- package/libs/ios/libskia.xcframework/Info.plist +5 -5
- package/libs/ios/libskia.xcframework/ios-arm64_arm64e/libskia.a +0 -0
- package/libs/ios/libskia.xcframework/ios-arm64_arm64e_x86_64-simulator/libskia.a +0 -0
- package/libs/ios/libskshaper.xcframework/Info.plist +5 -5
- package/libs/ios/libskshaper.xcframework/ios-arm64_arm64e/libskshaper.a +0 -0
- package/libs/ios/libskshaper.xcframework/ios-arm64_arm64e_x86_64-simulator/libskshaper.a +0 -0
- package/libs/ios/libsvg.xcframework/ios-arm64_arm64e/libsvg.a +0 -0
- package/libs/ios/libsvg.xcframework/ios-arm64_arm64e_x86_64-simulator/libsvg.a +0 -0
- package/package.json +2 -2
- package/src/renderer/components/shaders/Shader.tsx +1 -3
- package/src/skia/types/RuntimeEffect/RuntimeEffect.ts +1 -8
- package/cpp/skia/include/core/SkCustomMesh.h +0 -202
- package/cpp/skia/include/core/SkStringView.h +0 -185
- package/cpp/skia/include/private/SkPaintParamsKey.h +0 -110
- package/cpp/skia/include/private/SkShaderCodeDictionary.h +0 -63
- package/cpp/skia/include/private/SkTOptional.h +0 -362
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["Shader.tsx"],"names":["isVector","obj","x","undefined","y","processValue","value","onDeclare","children","uniforms","source","
|
1
|
+
{"version":3,"sources":["Shader.tsx"],"names":["isVector","obj","x","undefined","y","processValue","value","onDeclare","children","uniforms","source","transform","processedUniforms","Array","getUniformCount","fill","flatMap","_","i","name","getUniformName","Error","isArray","names","Object","keys","length","usedUniforms","map","unusedUniform","indexOf","filter","n","console","warn","join","makeShaderWithChildren","isShader","Shader","props","defaultProps"],"mappings":";;;;;;;AAAA;;AAGA;;AAGA;;AACA;;;;;;AAEA,MAAMA,QAAQ,GAAIC,GAAD,IACf;AACA;AACCA,GAAD,CAAaC,CAAb,KAAmBC,SAAnB,IAAiCF,GAAD,CAAaG,CAAb,KAAmBD,SAHrD;;AAaA,MAAME,YAAY,GAAIC,KAAD,IAAqD;AACxE,MAAIN,QAAQ,CAACM,KAAD,CAAZ,EAAqB;AACnB,WAAO,CAACA,KAAK,CAACJ,CAAP,EAAUI,KAAK,CAACF,CAAhB,CAAP;AACD;;AACD,SAAOE,KAAP;AACD,CALD;;AAaA,MAAMC,SAAS,GAAG,oCAChB,OAAqCC,QAArC,KAAkD;AAAA,MAAjD;AAAEC,IAAAA,QAAF;AAAYC,IAAAA,MAAZ;AAAoB,OAAGC;AAAvB,GAAiD;AAChD,QAAMC,iBAAiB,GAAG,IAAIC,KAAJ,CAAUH,MAAM,CAACI,eAAP,EAAV,EACvBC,IADuB,CAClB,CADkB,EAEvBC,OAFuB,CAEf,CAACC,CAAD,EAAIC,CAAJ,KAAU;AACjB,UAAMC,IAAI,GAAGT,MAAM,CAACU,cAAP,CAAsBF,CAAtB,CAAb;AACA,UAAMZ,KAAK,GAAGG,QAAQ,CAACU,IAAD,CAAtB;;AACA,QAAIb,KAAK,KAAKH,SAAd,EAAyB;AACvB,YAAM,IAAIkB,KAAJ,CAAW,kCAAiCF,IAAK,EAAjD,CAAN;AACD;;AACD,QAAIN,KAAK,CAACS,OAAN,CAAchB,KAAd,CAAJ,EAA0B;AACxB,aAAOA,KAAK,CAACU,OAAN,CAAcX,YAAd,CAAP;AACD;;AACD,WAAOA,YAAY,CAACC,KAAD,CAAnB;AACD,GAZuB,CAA1B;AAaA,QAAMiB,KAAK,GAAGC,MAAM,CAACC,IAAP,CAAYhB,QAAZ,CAAd;;AACA,MAAIc,KAAK,CAACG,MAAN,GAAehB,MAAM,CAACI,eAAP,EAAnB,EAA6C;AAC3C,UAAMa,YAAY,GAAG,IAAId,KAAJ,CAAUH,MAAM,CAACI,eAAP,EAAV,EAClBC,IADkB,CACb,CADa,EAElBa,GAFkB,CAEd,CAACX,CAAD,EAAIC,CAAJ,KAAUR,MAAM,CAACU,cAAP,CAAsBF,CAAtB,CAFI,CAArB;AAGA,UAAMW,aAAa,GAAGN,KAAK,CACxBK,GADmB,CACdT,IAAD,IAAU;AACb,UAAIQ,YAAY,CAACG,OAAb,CAAqBX,IAArB,MAA+B,CAAC,CAApC,EAAuC;AACrC,eAAOA,IAAP;AACD;;AACD,aAAO,IAAP;AACD,KANmB,EAOnBY,MAPmB,CAOXC,CAAD,IAAOA,CAAC,KAAK,IAPD,CAAtB;AAQAC,IAAAA,OAAO,CAACC,IAAR,CACE,oCAAoCL,aAAa,CAACM,IAAd,CAAmB,IAAnB,CADtC;AAGD;;AACD,SAAOzB,MAAM,CAAC0B,sBAAP,CACLxB,iBADK,EAELJ,QAAQ,CAACuB,MAAT,CAAgBM,cAAhB,CAFK,EAGL,6BAAY1B,SAAZ,CAHK,CAAP;AAKD,CArCe,CAAlB;;AAwCO,MAAM2B,MAAM,GAAIC,KAAD,IAAuC;AAC3D,sBAAO;AAAe,IAAA,SAAS,EAAEhC;AAA1B,KAAyCgC,KAAzC,EAAP;AACD,CAFM;;;AAIPD,MAAM,CAACE,YAAP,GAAsB;AACpB/B,EAAAA,QAAQ,EAAE;AADU,CAAtB","sourcesContent":["import React from \"react\";\nimport type { ReactNode } from \"react\";\n\nimport { isShader } from \"../../../skia\";\nimport type { SkRuntimeEffect } from \"../../../skia\";\nimport type { Vector, AnimatedProps, TransformProps } from \"../../processors\";\nimport { createDeclaration } from \"../../nodes/Declaration\";\nimport { localMatrix } from \"../../processors\";\n\nconst isVector = (obj: unknown): obj is Vector =>\n // We have an issue to check property existence on JSI backed instances\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (obj as any).x !== undefined && (obj as any).y !== undefined;\n\ntype UniformValue = number | Vector | readonly number[];\n\ntype Uniform = UniformValue | readonly UniformValue[];\n\ninterface Uniforms {\n [name: string]: Uniform;\n}\n\nconst processValue = (value: UniformValue): number | readonly number[] => {\n if (isVector(value)) {\n return [value.x, value.y];\n }\n return value;\n};\n\nexport interface ShaderProps extends TransformProps {\n source: SkRuntimeEffect;\n uniforms: Uniforms;\n children?: ReactNode | ReactNode[];\n}\n\nconst onDeclare = createDeclaration<ShaderProps>(\n ({ uniforms, source, ...transform }, children) => {\n const processedUniforms = new Array(source.getUniformCount())\n .fill(0)\n .flatMap((_, i) => {\n const name = source.getUniformName(i);\n const value = uniforms[name];\n if (value === undefined) {\n throw new Error(`No value specified for uniform ${name}`);\n }\n if (Array.isArray(value)) {\n return value.flatMap(processValue);\n }\n return processValue(value as UniformValue);\n });\n const names = Object.keys(uniforms);\n if (names.length > source.getUniformCount()) {\n const usedUniforms = new Array(source.getUniformCount())\n .fill(0)\n .map((_, i) => source.getUniformName(i));\n const unusedUniform = names\n .map((name) => {\n if (usedUniforms.indexOf(name) === -1) {\n return name;\n }\n return null;\n })\n .filter((n) => n !== null);\n console.warn(\n \"Unused uniforms were provided: \" + unusedUniform.join(\", \")\n );\n }\n return source.makeShaderWithChildren(\n processedUniforms,\n children.filter(isShader),\n localMatrix(transform)\n );\n }\n);\n\nexport const Shader = (props: AnimatedProps<ShaderProps>) => {\n return <skDeclaration onDeclare={onDeclare} {...props} />;\n};\n\nShader.defaultProps = {\n uniforms: [],\n};\n"]}
|
@@ -21,7 +21,6 @@ const onDeclare = createDeclaration((_ref, children) => {
|
|
21
21
|
let {
|
22
22
|
uniforms,
|
23
23
|
source,
|
24
|
-
opaque,
|
25
24
|
...transform
|
26
25
|
} = _ref;
|
27
26
|
const processedUniforms = new Array(source.getUniformCount()).fill(0).flatMap((_, i) => {
|
@@ -52,7 +51,7 @@ const onDeclare = createDeclaration((_ref, children) => {
|
|
52
51
|
console.warn("Unused uniforms were provided: " + unusedUniform.join(", "));
|
53
52
|
}
|
54
53
|
|
55
|
-
return source.makeShaderWithChildren(processedUniforms,
|
54
|
+
return source.makeShaderWithChildren(processedUniforms, children.filter(isShader), localMatrix(transform));
|
56
55
|
});
|
57
56
|
export const Shader = props => {
|
58
57
|
return /*#__PURE__*/React.createElement("skDeclaration", _extends({
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["Shader.tsx"],"names":["React","isShader","createDeclaration","localMatrix","isVector","obj","x","undefined","y","processValue","value","onDeclare","children","uniforms","source","
|
1
|
+
{"version":3,"sources":["Shader.tsx"],"names":["React","isShader","createDeclaration","localMatrix","isVector","obj","x","undefined","y","processValue","value","onDeclare","children","uniforms","source","transform","processedUniforms","Array","getUniformCount","fill","flatMap","_","i","name","getUniformName","Error","isArray","names","Object","keys","length","usedUniforms","map","unusedUniform","indexOf","filter","n","console","warn","join","makeShaderWithChildren","Shader","props","defaultProps"],"mappings":";;AAAA,OAAOA,KAAP,MAAkB,OAAlB;AAGA,SAASC,QAAT,QAAyB,eAAzB;AAGA,SAASC,iBAAT,QAAkC,yBAAlC;AACA,SAASC,WAAT,QAA4B,kBAA5B;;AAEA,MAAMC,QAAQ,GAAIC,GAAD,IACf;AACA;AACCA,GAAD,CAAaC,CAAb,KAAmBC,SAAnB,IAAiCF,GAAD,CAAaG,CAAb,KAAmBD,SAHrD;;AAaA,MAAME,YAAY,GAAIC,KAAD,IAAqD;AACxE,MAAIN,QAAQ,CAACM,KAAD,CAAZ,EAAqB;AACnB,WAAO,CAACA,KAAK,CAACJ,CAAP,EAAUI,KAAK,CAACF,CAAhB,CAAP;AACD;;AACD,SAAOE,KAAP;AACD,CALD;;AAaA,MAAMC,SAAS,GAAGT,iBAAiB,CACjC,OAAqCU,QAArC,KAAkD;AAAA,MAAjD;AAAEC,IAAAA,QAAF;AAAYC,IAAAA,MAAZ;AAAoB,OAAGC;AAAvB,GAAiD;AAChD,QAAMC,iBAAiB,GAAG,IAAIC,KAAJ,CAAUH,MAAM,CAACI,eAAP,EAAV,EACvBC,IADuB,CAClB,CADkB,EAEvBC,OAFuB,CAEf,CAACC,CAAD,EAAIC,CAAJ,KAAU;AACjB,UAAMC,IAAI,GAAGT,MAAM,CAACU,cAAP,CAAsBF,CAAtB,CAAb;AACA,UAAMZ,KAAK,GAAGG,QAAQ,CAACU,IAAD,CAAtB;;AACA,QAAIb,KAAK,KAAKH,SAAd,EAAyB;AACvB,YAAM,IAAIkB,KAAJ,CAAW,kCAAiCF,IAAK,EAAjD,CAAN;AACD;;AACD,QAAIN,KAAK,CAACS,OAAN,CAAchB,KAAd,CAAJ,EAA0B;AACxB,aAAOA,KAAK,CAACU,OAAN,CAAcX,YAAd,CAAP;AACD;;AACD,WAAOA,YAAY,CAACC,KAAD,CAAnB;AACD,GAZuB,CAA1B;AAaA,QAAMiB,KAAK,GAAGC,MAAM,CAACC,IAAP,CAAYhB,QAAZ,CAAd;;AACA,MAAIc,KAAK,CAACG,MAAN,GAAehB,MAAM,CAACI,eAAP,EAAnB,EAA6C;AAC3C,UAAMa,YAAY,GAAG,IAAId,KAAJ,CAAUH,MAAM,CAACI,eAAP,EAAV,EAClBC,IADkB,CACb,CADa,EAElBa,GAFkB,CAEd,CAACX,CAAD,EAAIC,CAAJ,KAAUR,MAAM,CAACU,cAAP,CAAsBF,CAAtB,CAFI,CAArB;AAGA,UAAMW,aAAa,GAAGN,KAAK,CACxBK,GADmB,CACdT,IAAD,IAAU;AACb,UAAIQ,YAAY,CAACG,OAAb,CAAqBX,IAArB,MAA+B,CAAC,CAApC,EAAuC;AACrC,eAAOA,IAAP;AACD;;AACD,aAAO,IAAP;AACD,KANmB,EAOnBY,MAPmB,CAOXC,CAAD,IAAOA,CAAC,KAAK,IAPD,CAAtB;AAQAC,IAAAA,OAAO,CAACC,IAAR,CACE,oCAAoCL,aAAa,CAACM,IAAd,CAAmB,IAAnB,CADtC;AAGD;;AACD,SAAOzB,MAAM,CAAC0B,sBAAP,CACLxB,iBADK,EAELJ,QAAQ,CAACuB,MAAT,CAAgBlC,QAAhB,CAFK,EAGLE,WAAW,CAACY,SAAD,CAHN,CAAP;AAKD,CArCgC,CAAnC;AAwCA,OAAO,MAAM0B,MAAM,GAAIC,KAAD,IAAuC;AAC3D,sBAAO;AAAe,IAAA,SAAS,EAAE/B;AAA1B,KAAyC+B,KAAzC,EAAP;AACD,CAFM;AAIPD,MAAM,CAACE,YAAP,GAAsB;AACpB9B,EAAAA,QAAQ,EAAE;AADU,CAAtB","sourcesContent":["import React from \"react\";\nimport type { ReactNode } from \"react\";\n\nimport { isShader } from \"../../../skia\";\nimport type { SkRuntimeEffect } from \"../../../skia\";\nimport type { Vector, AnimatedProps, TransformProps } from \"../../processors\";\nimport { createDeclaration } from \"../../nodes/Declaration\";\nimport { localMatrix } from \"../../processors\";\n\nconst isVector = (obj: unknown): obj is Vector =>\n // We have an issue to check property existence on JSI backed instances\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (obj as any).x !== undefined && (obj as any).y !== undefined;\n\ntype UniformValue = number | Vector | readonly number[];\n\ntype Uniform = UniformValue | readonly UniformValue[];\n\ninterface Uniforms {\n [name: string]: Uniform;\n}\n\nconst processValue = (value: UniformValue): number | readonly number[] => {\n if (isVector(value)) {\n return [value.x, value.y];\n }\n return value;\n};\n\nexport interface ShaderProps extends TransformProps {\n source: SkRuntimeEffect;\n uniforms: Uniforms;\n children?: ReactNode | ReactNode[];\n}\n\nconst onDeclare = createDeclaration<ShaderProps>(\n ({ uniforms, source, ...transform }, children) => {\n const processedUniforms = new Array(source.getUniformCount())\n .fill(0)\n .flatMap((_, i) => {\n const name = source.getUniformName(i);\n const value = uniforms[name];\n if (value === undefined) {\n throw new Error(`No value specified for uniform ${name}`);\n }\n if (Array.isArray(value)) {\n return value.flatMap(processValue);\n }\n return processValue(value as UniformValue);\n });\n const names = Object.keys(uniforms);\n if (names.length > source.getUniformCount()) {\n const usedUniforms = new Array(source.getUniformCount())\n .fill(0)\n .map((_, i) => source.getUniformName(i));\n const unusedUniform = names\n .map((name) => {\n if (usedUniforms.indexOf(name) === -1) {\n return name;\n }\n return null;\n })\n .filter((n) => n !== null);\n console.warn(\n \"Unused uniforms were provided: \" + unusedUniform.join(\", \")\n );\n }\n return source.makeShaderWithChildren(\n processedUniforms,\n children.filter(isShader),\n localMatrix(transform)\n );\n }\n);\n\nexport const Shader = (props: AnimatedProps<ShaderProps>) => {\n return <skDeclaration onDeclare={onDeclare} {...props} />;\n};\n\nShader.defaultProps = {\n uniforms: [],\n};\n"]}
|
@@ -13,18 +13,16 @@ export interface SkRuntimeEffect extends SkJSIInstance<"RuntimeEffect"> {
|
|
13
13
|
/**
|
14
14
|
* Returns a shader executed using the given uniform data.
|
15
15
|
* @param uniforms
|
16
|
-
* @param isOpaque
|
17
16
|
* @param localMatrix
|
18
17
|
*/
|
19
|
-
makeShader(uniforms: number[],
|
18
|
+
makeShader(uniforms: number[], localMatrix?: SkMatrix): SkShader;
|
20
19
|
/**
|
21
20
|
* Returns a shader executed using the given uniform data and the children as inputs.
|
22
21
|
* @param uniforms
|
23
|
-
* @param isOpaque
|
24
22
|
* @param children
|
25
23
|
* @param localMatrix
|
26
24
|
*/
|
27
|
-
makeShaderWithChildren(uniforms: number[],
|
25
|
+
makeShaderWithChildren(uniforms: number[], children?: SkShader[], localMatrix?: SkMatrix): SkShader;
|
28
26
|
/**
|
29
27
|
* Returns the nth uniform from the effect.
|
30
28
|
* @param index
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -6,32 +6,32 @@
|
|
6
6
|
<array>
|
7
7
|
<dict>
|
8
8
|
<key>LibraryIdentifier</key>
|
9
|
-
<string>ios-
|
9
|
+
<string>ios-arm64_arm64e_x86_64-simulator</string>
|
10
10
|
<key>LibraryPath</key>
|
11
11
|
<string>libskia.a</string>
|
12
12
|
<key>SupportedArchitectures</key>
|
13
13
|
<array>
|
14
14
|
<string>arm64</string>
|
15
15
|
<string>arm64e</string>
|
16
|
+
<string>x86_64</string>
|
16
17
|
</array>
|
17
18
|
<key>SupportedPlatform</key>
|
18
19
|
<string>ios</string>
|
20
|
+
<key>SupportedPlatformVariant</key>
|
21
|
+
<string>simulator</string>
|
19
22
|
</dict>
|
20
23
|
<dict>
|
21
24
|
<key>LibraryIdentifier</key>
|
22
|
-
<string>ios-
|
25
|
+
<string>ios-arm64_arm64e</string>
|
23
26
|
<key>LibraryPath</key>
|
24
27
|
<string>libskia.a</string>
|
25
28
|
<key>SupportedArchitectures</key>
|
26
29
|
<array>
|
27
30
|
<string>arm64</string>
|
28
31
|
<string>arm64e</string>
|
29
|
-
<string>x86_64</string>
|
30
32
|
</array>
|
31
33
|
<key>SupportedPlatform</key>
|
32
34
|
<string>ios</string>
|
33
|
-
<key>SupportedPlatformVariant</key>
|
34
|
-
<string>simulator</string>
|
35
35
|
</dict>
|
36
36
|
</array>
|
37
37
|
<key>CFBundlePackageType</key>
|
Binary file
|
Binary file
|
@@ -6,32 +6,32 @@
|
|
6
6
|
<array>
|
7
7
|
<dict>
|
8
8
|
<key>LibraryIdentifier</key>
|
9
|
-
<string>ios-
|
9
|
+
<string>ios-arm64_arm64e_x86_64-simulator</string>
|
10
10
|
<key>LibraryPath</key>
|
11
11
|
<string>libskshaper.a</string>
|
12
12
|
<key>SupportedArchitectures</key>
|
13
13
|
<array>
|
14
14
|
<string>arm64</string>
|
15
15
|
<string>arm64e</string>
|
16
|
+
<string>x86_64</string>
|
16
17
|
</array>
|
17
18
|
<key>SupportedPlatform</key>
|
18
19
|
<string>ios</string>
|
20
|
+
<key>SupportedPlatformVariant</key>
|
21
|
+
<string>simulator</string>
|
19
22
|
</dict>
|
20
23
|
<dict>
|
21
24
|
<key>LibraryIdentifier</key>
|
22
|
-
<string>ios-
|
25
|
+
<string>ios-arm64_arm64e</string>
|
23
26
|
<key>LibraryPath</key>
|
24
27
|
<string>libskshaper.a</string>
|
25
28
|
<key>SupportedArchitectures</key>
|
26
29
|
<array>
|
27
30
|
<string>arm64</string>
|
28
31
|
<string>arm64e</string>
|
29
|
-
<string>x86_64</string>
|
30
32
|
</array>
|
31
33
|
<key>SupportedPlatform</key>
|
32
34
|
<string>ios</string>
|
33
|
-
<key>SupportedPlatformVariant</key>
|
34
|
-
<string>simulator</string>
|
35
35
|
</dict>
|
36
36
|
</array>
|
37
37
|
<key>CFBundlePackageType</key>
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
package/package.json
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
"access": "public"
|
5
5
|
},
|
6
6
|
"title": "React Native Skia",
|
7
|
-
"version": "0.1.
|
7
|
+
"version": "0.1.130",
|
8
8
|
"description": "High-performance React Native Graphics using Skia",
|
9
9
|
"main": "lib/module/index.js",
|
10
10
|
"files": [
|
@@ -35,7 +35,7 @@
|
|
35
35
|
"tsc": "tsc --noEmit",
|
36
36
|
"lint": "eslint . --ext .ts,.tsx --max-warnings 0",
|
37
37
|
"test": "jest",
|
38
|
-
"postinstall": "node scripts/install-npm.js
|
38
|
+
"postinstall": "node scripts/install-npm.js",
|
39
39
|
"build": "bob build"
|
40
40
|
},
|
41
41
|
"repository": {
|
@@ -30,12 +30,11 @@ const processValue = (value: UniformValue): number | readonly number[] => {
|
|
30
30
|
export interface ShaderProps extends TransformProps {
|
31
31
|
source: SkRuntimeEffect;
|
32
32
|
uniforms: Uniforms;
|
33
|
-
opaque?: boolean;
|
34
33
|
children?: ReactNode | ReactNode[];
|
35
34
|
}
|
36
35
|
|
37
36
|
const onDeclare = createDeclaration<ShaderProps>(
|
38
|
-
({ uniforms, source,
|
37
|
+
({ uniforms, source, ...transform }, children) => {
|
39
38
|
const processedUniforms = new Array(source.getUniformCount())
|
40
39
|
.fill(0)
|
41
40
|
.flatMap((_, i) => {
|
@@ -68,7 +67,6 @@ const onDeclare = createDeclaration<ShaderProps>(
|
|
68
67
|
}
|
69
68
|
return source.makeShaderWithChildren(
|
70
69
|
processedUniforms,
|
71
|
-
opaque,
|
72
70
|
children.filter(isShader),
|
73
71
|
localMatrix(transform)
|
74
72
|
);
|
@@ -16,25 +16,18 @@ export interface SkRuntimeEffect extends SkJSIInstance<"RuntimeEffect"> {
|
|
16
16
|
/**
|
17
17
|
* Returns a shader executed using the given uniform data.
|
18
18
|
* @param uniforms
|
19
|
-
* @param isOpaque
|
20
19
|
* @param localMatrix
|
21
20
|
*/
|
22
|
-
makeShader(
|
23
|
-
uniforms: number[],
|
24
|
-
isOpaque?: boolean,
|
25
|
-
localMatrix?: SkMatrix
|
26
|
-
): SkShader;
|
21
|
+
makeShader(uniforms: number[], localMatrix?: SkMatrix): SkShader;
|
27
22
|
|
28
23
|
/**
|
29
24
|
* Returns a shader executed using the given uniform data and the children as inputs.
|
30
25
|
* @param uniforms
|
31
|
-
* @param isOpaque
|
32
26
|
* @param children
|
33
27
|
* @param localMatrix
|
34
28
|
*/
|
35
29
|
makeShaderWithChildren(
|
36
30
|
uniforms: number[],
|
37
|
-
isOpaque?: boolean,
|
38
31
|
children?: SkShader[],
|
39
32
|
localMatrix?: SkMatrix
|
40
33
|
): SkShader;
|
@@ -1,202 +0,0 @@
|
|
1
|
-
/*
|
2
|
-
* Copyright 2021 Google LLC
|
3
|
-
*
|
4
|
-
* Use of this source code is governed by a BSD-style license that can be
|
5
|
-
* found in the LICENSE file.
|
6
|
-
*/
|
7
|
-
|
8
|
-
#ifndef SkCustomMesh_DEFINED
|
9
|
-
#define SkCustomMesh_DEFINED
|
10
|
-
|
11
|
-
#include "include/core/SkTypes.h"
|
12
|
-
|
13
|
-
#ifdef SK_ENABLE_SKSL
|
14
|
-
#include "include/core/SkColorSpace.h"
|
15
|
-
#include "include/core/SkImageInfo.h"
|
16
|
-
#include "include/core/SkRect.h"
|
17
|
-
#include "include/core/SkRefCnt.h"
|
18
|
-
#include "include/core/SkSpan.h"
|
19
|
-
#include "include/core/SkString.h"
|
20
|
-
|
21
|
-
#include <vector>
|
22
|
-
|
23
|
-
namespace SkSL { struct Program; }
|
24
|
-
|
25
|
-
/**
|
26
|
-
* A specification for custom meshes. Specifies the vertex buffer attributes and stride, the
|
27
|
-
* vertex program that produces a user-defined set of varyings, a fragment program that ingests
|
28
|
-
* the interpolated varyings and produces local coordinates and optionally a color.
|
29
|
-
*
|
30
|
-
* The signature of the vertex program must be:
|
31
|
-
* float2 main(Attributes, out Varyings)
|
32
|
-
* where the return value is a local position that will be transformed by SkCanvas's matrix.
|
33
|
-
*
|
34
|
-
* The signature of the fragment program must be either:
|
35
|
-
* (float2|void) main(Varyings)
|
36
|
-
* or
|
37
|
-
* (float2|void) main(Varyings, out (half4|float4) color)
|
38
|
-
*
|
39
|
-
* where the return value is the local coordinates that will be used to access SkShader. If the
|
40
|
-
* return type is void then the interpolated position from vertex shader return is used as the local
|
41
|
-
* coordinate. If the color variant is used it will be blended with SkShader (or SkPaint color in
|
42
|
-
* absence of a shader) using the SkBlender provided to the SkCanvas draw call.
|
43
|
-
*/
|
44
|
-
class SkCustomMeshSpecification : public SkNVRefCnt<SkCustomMeshSpecification> {
|
45
|
-
public:
|
46
|
-
/** These values are enforced when creating a specification. */
|
47
|
-
static constexpr size_t kMaxStride = 1024;
|
48
|
-
static constexpr size_t kMaxAttributes = 8;
|
49
|
-
static constexpr size_t kStrideAlignment = 4;
|
50
|
-
static constexpr size_t kOffsetAlignment = 4;
|
51
|
-
static constexpr size_t kMaxVaryings = 6;
|
52
|
-
|
53
|
-
struct Attribute {
|
54
|
-
enum class Type : uint32_t { // CPU representation Shader Type
|
55
|
-
kFloat, // float float
|
56
|
-
kFloat2, // two floats float2
|
57
|
-
kFloat3, // three floats float3
|
58
|
-
kFloat4, // four floats float4
|
59
|
-
kUByte4_unorm, // four bytes half4
|
60
|
-
|
61
|
-
kLast = kUByte4_unorm
|
62
|
-
};
|
63
|
-
Type type;
|
64
|
-
size_t offset;
|
65
|
-
SkString name;
|
66
|
-
};
|
67
|
-
|
68
|
-
struct Varying {
|
69
|
-
enum class Type : uint32_t {
|
70
|
-
kFloat, // "float"
|
71
|
-
kFloat2, // "float2"
|
72
|
-
kFloat3, // "float3"
|
73
|
-
kFloat4, // "float4"
|
74
|
-
kHalf, // "half"
|
75
|
-
kHalf2, // "half2"
|
76
|
-
kHalf3, // "half3"
|
77
|
-
kHalf4, // "half4"
|
78
|
-
|
79
|
-
kLast = kHalf4
|
80
|
-
};
|
81
|
-
Type type;
|
82
|
-
SkString name;
|
83
|
-
};
|
84
|
-
|
85
|
-
~SkCustomMeshSpecification();
|
86
|
-
|
87
|
-
struct Result {
|
88
|
-
sk_sp<SkCustomMeshSpecification> specification;
|
89
|
-
SkString error;
|
90
|
-
};
|
91
|
-
|
92
|
-
/**
|
93
|
-
* If successful the return is a specification and an empty error string. Otherwise, it is a
|
94
|
-
* null specification a non-empty error string.
|
95
|
-
*
|
96
|
-
* @param attributes The vertex attributes that will be consumed by 'vs'. Attributes need
|
97
|
-
* not be tightly packed but attribute offsets must be aligned to
|
98
|
-
* kOffsetAlignment and offset + size may not be greater than
|
99
|
-
* 'vertexStride'. At least one attribute is required.
|
100
|
-
* @param vertexStride The offset between successive attribute values. This must be aligned to
|
101
|
-
* kStrideAlignment.
|
102
|
-
* @param varyings The varyings that will be written by 'vs' and read by 'fs'. This may
|
103
|
-
* be empty.
|
104
|
-
* @param vs The vertex shader code that computes a vertex position and the varyings
|
105
|
-
* from the attributes.
|
106
|
-
* @param fs The fragment code that computes a local coordinate and optionally a
|
107
|
-
* color from the varyings. The local coordinate is used to sample
|
108
|
-
* SkShader.
|
109
|
-
* @param cs The colorspace of the color produced by 'fs'. Ignored if 'fs's main()
|
110
|
-
* function does not have a color out param.
|
111
|
-
* @param at The alpha type of the color produced by 'fs'. Ignored if 'fs's main()
|
112
|
-
* function does not have a color out param. Cannot be kUnknown.
|
113
|
-
*/
|
114
|
-
static Result Make(SkSpan<const Attribute> attributes,
|
115
|
-
size_t vertexStride,
|
116
|
-
SkSpan<const Varying> varyings,
|
117
|
-
const SkString& vs,
|
118
|
-
const SkString& fs,
|
119
|
-
sk_sp<SkColorSpace> cs = SkColorSpace::MakeSRGB(),
|
120
|
-
SkAlphaType at = kPremul_SkAlphaType);
|
121
|
-
|
122
|
-
SkSpan<const Attribute> attributes() const { return SkMakeSpan(fAttributes); }
|
123
|
-
|
124
|
-
size_t stride() const { return fStride; }
|
125
|
-
|
126
|
-
private:
|
127
|
-
friend struct SkCustomMeshSpecificationPriv;
|
128
|
-
|
129
|
-
enum class ColorType {
|
130
|
-
kNone,
|
131
|
-
kHalf4,
|
132
|
-
kFloat4,
|
133
|
-
};
|
134
|
-
|
135
|
-
static Result MakeFromSourceWithStructs(SkSpan<const Attribute> attributes,
|
136
|
-
size_t stride,
|
137
|
-
SkSpan<const Varying> varyings,
|
138
|
-
const SkString& vs,
|
139
|
-
const SkString& fs,
|
140
|
-
sk_sp<SkColorSpace> cs,
|
141
|
-
SkAlphaType at);
|
142
|
-
|
143
|
-
SkCustomMeshSpecification(SkSpan<const Attribute>,
|
144
|
-
size_t,
|
145
|
-
SkSpan<const Varying>,
|
146
|
-
std::unique_ptr<SkSL::Program>,
|
147
|
-
std::unique_ptr<SkSL::Program>,
|
148
|
-
ColorType,
|
149
|
-
bool hasLocalCoords,
|
150
|
-
sk_sp<SkColorSpace>,
|
151
|
-
SkAlphaType);
|
152
|
-
|
153
|
-
SkCustomMeshSpecification(const SkCustomMeshSpecification&) = delete;
|
154
|
-
SkCustomMeshSpecification(SkCustomMeshSpecification&&) = delete;
|
155
|
-
|
156
|
-
SkCustomMeshSpecification& operator=(const SkCustomMeshSpecification&) = delete;
|
157
|
-
SkCustomMeshSpecification& operator=(SkCustomMeshSpecification&&) = delete;
|
158
|
-
|
159
|
-
const std::vector<Attribute> fAttributes;
|
160
|
-
const std::vector<Varying> fVaryings;
|
161
|
-
std::unique_ptr<SkSL::Program> fVS;
|
162
|
-
std::unique_ptr<SkSL::Program> fFS;
|
163
|
-
size_t fStride;
|
164
|
-
uint32_t fHash;
|
165
|
-
ColorType fColorType;
|
166
|
-
bool fHasLocalCoords;
|
167
|
-
sk_sp<SkColorSpace> fColorSpace;
|
168
|
-
SkAlphaType fAlphaType;
|
169
|
-
};
|
170
|
-
|
171
|
-
/**
|
172
|
-
* This is a placeholder object. We will want something that allows the client to incrementally
|
173
|
-
* update the mesh that can be synchronized with the GPU backend without requiring extra copies.
|
174
|
-
*
|
175
|
-
* A buffer of vertices, a topology, optionally indices, and a compatible SkCustomMeshSpecification.
|
176
|
-
* The data in 'vb' is expected to contain the attributes described in 'spec' for 'vcount' vertices.
|
177
|
-
* The size of the buffer must be at least spec->stride()*vcount (even if vertex attributes contains
|
178
|
-
* pad at the end of the stride). If 'bounds' does not contain all points output by 'spec''s vertex
|
179
|
-
* program when applied to the vertices in 'vb' a draw of the custom mesh produces undefined
|
180
|
-
* results.
|
181
|
-
*
|
182
|
-
* If indices is null then then 'icount' must be <= 0. 'vcount' vertices will be selected from 'vb'
|
183
|
-
* to create the topology indicated by 'mode'.
|
184
|
-
*
|
185
|
-
* If indices is not null then icount must be >= 3. 'vb' will be indexed by 'icount' successive
|
186
|
-
* values in 'indices' to create the topology indicated by 'mode'. The values in 'indices' must be
|
187
|
-
* less than 'vcount'
|
188
|
-
*/
|
189
|
-
struct SkCustomMesh {
|
190
|
-
enum class Mode { kTriangles, kTriangleStrip };
|
191
|
-
sk_sp<SkCustomMeshSpecification> spec;
|
192
|
-
Mode mode = Mode::kTriangles;
|
193
|
-
SkRect bounds = SkRect::MakeEmpty();
|
194
|
-
const void* vb = nullptr;
|
195
|
-
int vcount = 0;
|
196
|
-
const uint16_t* indices = nullptr;
|
197
|
-
int icount = 0;
|
198
|
-
};
|
199
|
-
|
200
|
-
#endif // SK_ENABLE_SKSL
|
201
|
-
|
202
|
-
#endif
|