@shopify/react-native-skia 0.1.123 → 0.1.126
Sign up to get free protection for your applications and to get access to all the features.
- package/android/CMakeLists.txt +3 -0
- package/android/build.gradle +1 -1
- package/android/cpp/rnskia-android/RNSkDrawViewImpl.cpp +5 -5
- package/android/cpp/rnskia-android/RNSkDrawViewImpl.h +4 -4
- package/cpp/api/JsiSkApi.h +3 -1
- package/cpp/api/JsiSkCanvas.h +1 -1
- package/cpp/api/JsiSkColor.h +41 -7
- package/cpp/api/JsiSkColorFilterFactory.h +2 -1
- package/cpp/api/JsiSkImageFilter.h +0 -2
- package/cpp/api/JsiSkImageFilterFactory.h +37 -17
- package/cpp/api/JsiSkMatrix.h +44 -2
- package/cpp/api/JsiSkPaint.h +4 -7
- package/cpp/api/JsiSkRuntimeEffect.h +7 -0
- package/cpp/api/JsiSkRuntimeEffectFactory.h +3 -2
- package/cpp/api/JsiSkRuntimeShaderBuilder.h +70 -0
- package/cpp/api/JsiSkShaderFactory.h +2 -2
- package/cpp/api/JsiSkVertices.h +1 -1
- package/cpp/api/third_party/CSSColorParser.cpp +194 -0
- package/cpp/api/third_party/CSSColorParser.h +1 -191
- package/cpp/jsi/JsiSimpleValueWrapper.h +108 -0
- package/cpp/rnskia/RNSkAnimation.h +0 -2
- package/cpp/rnskia/RNSkDrawView.cpp +10 -13
- package/cpp/rnskia/RNSkDrawView.h +2 -2
- package/cpp/rnskia/RNSkValueApi.h +6 -2
- package/cpp/rnskia/values/RNSkClockValue.h +2 -2
- package/cpp/rnskia/values/RNSkDerivedValue.h +12 -5
- package/cpp/rnskia/values/RNSkReadonlyValue.h +14 -12
- package/cpp/rnskia/values/RNSkValue.h +8 -3
- package/ios/RNSkia-iOS/PlatformContext.h +30 -4
- package/ios/RNSkia-iOS/RNSkDrawViewImpl.h +4 -4
- package/ios/RNSkia-iOS/SkiaDrawView.mm +9 -13
- package/lib/commonjs/{values/animation → animation}/decay/decay.js +0 -0
- package/lib/commonjs/{values/animation → animation}/decay/decay.js.map +0 -0
- package/lib/commonjs/{values/animation → animation}/decay/index.js +0 -0
- package/lib/commonjs/{values/animation → animation}/decay/index.js.map +0 -0
- package/lib/commonjs/{values/animation → animation}/decay/runDecay.js +1 -1
- package/lib/commonjs/animation/decay/runDecay.js.map +1 -0
- package/lib/commonjs/{values/animation → animation}/decay/types.js +0 -0
- package/lib/commonjs/{values/animation → animation}/decay/types.js.map +0 -0
- package/lib/commonjs/{values/animation → animation}/functions/index.js +0 -0
- package/lib/commonjs/{values/animation → animation}/functions/index.js.map +0 -0
- package/lib/commonjs/animation/functions/interpolate.js +141 -0
- package/lib/commonjs/animation/functions/interpolate.js.map +1 -0
- package/lib/commonjs/animation/functions/interpolateColors.js +39 -0
- package/lib/commonjs/animation/functions/interpolateColors.js.map +1 -0
- package/lib/commonjs/{values/animation → animation}/index.js +0 -0
- package/lib/commonjs/{values/animation → animation}/index.js.map +0 -0
- package/lib/commonjs/{values/animation → animation}/spring/Spring.js +0 -0
- package/lib/commonjs/{values/animation → animation}/spring/Spring.js.map +0 -0
- package/lib/commonjs/{values/animation → animation}/spring/functions/index.js +0 -0
- package/lib/commonjs/{values/animation → animation}/spring/functions/index.js.map +0 -0
- package/lib/commonjs/{values/animation → animation}/spring/functions/spring.js +0 -0
- package/lib/commonjs/{values/animation → animation}/spring/functions/spring.js.map +0 -0
- package/lib/commonjs/{values/animation → animation}/spring/index.js +0 -0
- package/lib/commonjs/{values/animation → animation}/spring/index.js.map +0 -0
- package/lib/commonjs/{values/animation → animation}/spring/runSpring.js +0 -0
- package/lib/commonjs/animation/spring/runSpring.js.map +1 -0
- package/lib/commonjs/{values/animation → animation}/spring/types.js +0 -0
- package/lib/commonjs/{values/animation → animation}/spring/types.js.map +0 -0
- package/lib/commonjs/{values/animation → animation}/spring/useSpring.js +0 -0
- package/lib/commonjs/animation/spring/useSpring.js.map +1 -0
- package/lib/commonjs/{values/animation → animation}/timing/Easing.js +0 -0
- package/lib/commonjs/{values/animation → animation}/timing/Easing.js.map +0 -0
- package/lib/commonjs/{values/animation → animation}/timing/createTiming.js +1 -1
- package/lib/commonjs/animation/timing/createTiming.js.map +1 -0
- package/lib/commonjs/{values/animation → animation}/timing/functions/bezier.js +0 -0
- package/lib/commonjs/{values/animation → animation}/timing/functions/bezier.js.map +0 -0
- package/lib/commonjs/{values/animation → animation}/timing/functions/getResolvedParams.js +3 -3
- package/lib/commonjs/animation/timing/functions/getResolvedParams.js.map +1 -0
- package/lib/commonjs/{values/animation → animation}/timing/functions/index.js +0 -0
- package/lib/commonjs/{values/animation → animation}/timing/functions/index.js.map +0 -0
- package/lib/commonjs/{values/animation → animation}/timing/functions/timing.js +0 -0
- package/lib/commonjs/{values/animation → animation}/timing/functions/timing.js.map +1 -1
- package/lib/commonjs/{values/animation → animation}/timing/functions/types.js +0 -0
- package/lib/commonjs/{values/animation → animation}/timing/functions/types.js.map +0 -0
- package/lib/commonjs/{values/animation → animation}/timing/index.js +0 -0
- package/lib/commonjs/{values/animation → animation}/timing/index.js.map +0 -0
- package/lib/commonjs/{values/animation → animation}/timing/runTiming.js +0 -0
- package/lib/commonjs/animation/timing/runTiming.js.map +1 -0
- package/lib/commonjs/{values/animation → animation}/timing/useLoop.js +0 -0
- package/lib/commonjs/{values/animation → animation}/timing/useLoop.js.map +0 -0
- package/lib/commonjs/{values/animation → animation}/timing/useTiming.js +1 -1
- package/lib/commonjs/animation/timing/useTiming.js.map +1 -0
- package/lib/commonjs/{values/animation → animation}/types.js +0 -0
- package/lib/commonjs/{values/animation → animation}/types.js.map +0 -0
- package/lib/commonjs/index.js +13 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/renderer/Canvas.js +14 -5
- package/lib/commonjs/renderer/Canvas.js.map +1 -1
- package/lib/commonjs/renderer/components/colorFilters/BlendColor.js.map +1 -1
- package/lib/commonjs/renderer/components/colorFilters/Lerp.js +1 -1
- package/lib/commonjs/renderer/components/colorFilters/Lerp.js.map +1 -1
- package/lib/commonjs/renderer/components/imageFilters/InnerShadow.js +4 -2
- package/lib/commonjs/renderer/components/imageFilters/InnerShadow.js.map +1 -1
- package/lib/commonjs/renderer/components/imageFilters/RuntimeShader.js +37 -0
- package/lib/commonjs/renderer/components/imageFilters/RuntimeShader.js.map +1 -0
- package/lib/commonjs/renderer/components/imageFilters/index.js +13 -0
- package/lib/commonjs/renderer/components/imageFilters/index.js.map +1 -1
- package/lib/commonjs/renderer/components/shaders/Gradient.js +1 -1
- package/lib/commonjs/renderer/components/shaders/Gradient.js.map +1 -1
- package/lib/commonjs/renderer/components/shaders/Shader.js +2 -2
- package/lib/commonjs/renderer/components/shaders/Shader.js.map +1 -1
- package/lib/commonjs/renderer/processors/Circles.js +3 -2
- package/lib/commonjs/renderer/processors/Circles.js.map +1 -1
- package/lib/commonjs/renderer/processors/Font.js +1 -1
- package/lib/commonjs/renderer/processors/Font.js.map +1 -1
- package/lib/commonjs/renderer/processors/Rects.js +11 -21
- package/lib/commonjs/renderer/processors/Rects.js.map +1 -1
- package/lib/commonjs/renderer/processors/math/Matrix3.js +42 -63
- package/lib/commonjs/renderer/processors/math/Matrix3.js.map +1 -1
- package/lib/commonjs/renderer/processors/math/Vector.js +4 -5
- package/lib/commonjs/renderer/processors/math/Vector.js.map +1 -1
- package/lib/commonjs/skia/Color.js +14 -38
- package/lib/commonjs/skia/Color.js.map +1 -1
- package/lib/commonjs/skia/ImageFilter/ImageFilterFactory.js.map +1 -1
- package/lib/commonjs/skia/Matrix.js.map +1 -1
- package/lib/commonjs/skia/Shader/useShader.js +4 -1
- package/lib/commonjs/skia/Shader/useShader.js.map +1 -1
- package/lib/commonjs/skia/Skia.js +3 -45
- package/lib/commonjs/skia/Skia.js.map +1 -1
- package/lib/commonjs/skia/SkiaApi.js +4 -0
- package/lib/commonjs/skia/SkiaApi.js.map +1 -0
- package/lib/commonjs/values/api.js +4 -6
- package/lib/commonjs/values/api.js.map +1 -1
- package/lib/commonjs/values/api.web.js +18 -0
- package/lib/commonjs/values/api.web.js.map +1 -0
- package/lib/commonjs/values/index.js +0 -13
- package/lib/commonjs/values/index.js.map +1 -1
- package/lib/commonjs/values/web/RNSkAnimation.js +46 -0
- package/lib/commonjs/values/web/RNSkAnimation.js.map +1 -0
- package/lib/commonjs/values/web/RNSkClockValue.js +75 -0
- package/lib/commonjs/values/web/RNSkClockValue.js.map +1 -0
- package/lib/commonjs/values/web/RNSkDerivedValue.js +51 -0
- package/lib/commonjs/values/web/RNSkDerivedValue.js.map +1 -0
- package/lib/commonjs/values/web/RNSkReadonlyValue.js +45 -0
- package/lib/commonjs/values/web/RNSkReadonlyValue.js.map +1 -0
- package/lib/commonjs/values/web/RNSkValue.js +73 -0
- package/lib/commonjs/values/web/RNSkValue.js.map +1 -0
- package/lib/commonjs/values/web/api.js +31 -0
- package/lib/commonjs/values/web/api.js.map +1 -0
- package/lib/commonjs/values/web/index.js +19 -0
- package/lib/commonjs/values/web/index.js.map +1 -0
- package/lib/commonjs/views/SkiaView.js +13 -10
- package/lib/commonjs/views/SkiaView.js.map +1 -1
- package/lib/commonjs/views/api.js +11 -0
- package/lib/commonjs/views/api.js.map +1 -0
- package/lib/commonjs/views/types.js.map +1 -1
- package/lib/module/{values/animation → animation}/decay/decay.js +0 -0
- package/lib/module/{values/animation → animation}/decay/decay.js.map +0 -0
- package/lib/module/{values/animation → animation}/decay/index.js +0 -0
- package/lib/module/{values/animation → animation}/decay/index.js.map +0 -0
- package/lib/module/{values/animation → animation}/decay/runDecay.js +1 -1
- package/lib/module/animation/decay/runDecay.js.map +1 -0
- package/lib/module/{values/animation → animation}/decay/types.js +0 -0
- package/lib/module/{values/animation → animation}/decay/types.js.map +0 -0
- package/lib/module/{values/animation → animation}/functions/index.js +0 -0
- package/lib/module/{values/animation → animation}/functions/index.js.map +0 -0
- package/lib/module/animation/functions/interpolate.js +132 -0
- package/lib/module/animation/functions/interpolate.js.map +1 -0
- package/lib/module/animation/functions/interpolateColors.js +23 -0
- package/lib/module/animation/functions/interpolateColors.js.map +1 -0
- package/lib/module/{values/animation → animation}/index.js +0 -0
- package/lib/module/{values/animation → animation}/index.js.map +0 -0
- package/lib/module/{values/animation → animation}/spring/Spring.js +0 -0
- package/lib/module/{values/animation → animation}/spring/Spring.js.map +0 -0
- package/lib/module/{values/animation → animation}/spring/functions/index.js +0 -0
- package/lib/module/{values/animation → animation}/spring/functions/index.js.map +0 -0
- package/lib/module/{values/animation → animation}/spring/functions/spring.js +0 -0
- package/lib/module/{values/animation → animation}/spring/functions/spring.js.map +0 -0
- package/lib/module/{values/animation → animation}/spring/index.js +0 -0
- package/lib/module/{values/animation → animation}/spring/index.js.map +0 -0
- package/lib/module/{values/animation → animation}/spring/runSpring.js +0 -0
- package/lib/module/animation/spring/runSpring.js.map +1 -0
- package/lib/module/{values/animation → animation}/spring/types.js +0 -0
- package/lib/module/{values/animation → animation}/spring/types.js.map +0 -0
- package/lib/module/{values/animation → animation}/spring/useSpring.js +0 -0
- package/lib/module/animation/spring/useSpring.js.map +1 -0
- package/lib/module/{values/animation → animation}/timing/Easing.js +0 -0
- package/lib/module/{values/animation → animation}/timing/Easing.js.map +0 -0
- package/lib/module/{values/animation → animation}/timing/createTiming.js +1 -1
- package/lib/module/animation/timing/createTiming.js.map +1 -0
- package/lib/module/{values/animation → animation}/timing/functions/bezier.js +0 -0
- package/lib/module/{values/animation → animation}/timing/functions/bezier.js.map +0 -0
- package/lib/module/{values/animation → animation}/timing/functions/getResolvedParams.js +3 -3
- package/lib/module/animation/timing/functions/getResolvedParams.js.map +1 -0
- package/lib/module/{values/animation → animation}/timing/functions/index.js +0 -0
- package/lib/module/{values/animation → animation}/timing/functions/index.js.map +0 -0
- package/lib/module/{values/animation → animation}/timing/functions/timing.js +0 -0
- package/lib/module/{values/animation → animation}/timing/functions/timing.js.map +1 -1
- package/lib/module/{values/animation → animation}/timing/functions/types.js +0 -0
- package/lib/module/{values/animation → animation}/timing/functions/types.js.map +0 -0
- package/lib/module/{values/animation → animation}/timing/index.js +0 -0
- package/lib/module/{values/animation → animation}/timing/index.js.map +0 -0
- package/lib/module/{values/animation → animation}/timing/runTiming.js +0 -0
- package/lib/module/animation/timing/runTiming.js.map +1 -0
- package/lib/module/{values/animation → animation}/timing/useLoop.js +0 -0
- package/lib/module/{values/animation → animation}/timing/useLoop.js.map +0 -0
- package/lib/module/{values/animation → animation}/timing/useTiming.js +1 -1
- package/lib/module/animation/timing/useTiming.js.map +1 -0
- package/lib/module/{values/animation → animation}/types.js +0 -0
- package/lib/module/{values/animation → animation}/types.js.map +0 -0
- package/lib/module/index.js +1 -0
- package/lib/module/index.js.map +1 -1
- package/lib/module/renderer/Canvas.js +10 -4
- package/lib/module/renderer/Canvas.js.map +1 -1
- package/lib/module/renderer/components/colorFilters/BlendColor.js.map +1 -1
- package/lib/module/renderer/components/colorFilters/Lerp.js +1 -1
- package/lib/module/renderer/components/colorFilters/Lerp.js.map +1 -1
- package/lib/module/renderer/components/imageFilters/InnerShadow.js +3 -2
- package/lib/module/renderer/components/imageFilters/InnerShadow.js.map +1 -1
- package/lib/module/renderer/components/imageFilters/RuntimeShader.js +19 -0
- package/lib/module/renderer/components/imageFilters/RuntimeShader.js.map +1 -0
- package/lib/module/renderer/components/imageFilters/index.js +1 -0
- package/lib/module/renderer/components/imageFilters/index.js.map +1 -1
- package/lib/module/renderer/components/shaders/Gradient.js +2 -2
- package/lib/module/renderer/components/shaders/Gradient.js.map +1 -1
- package/lib/module/renderer/components/shaders/Shader.js +3 -2
- package/lib/module/renderer/components/shaders/Shader.js.map +1 -1
- package/lib/module/renderer/processors/Circles.js +3 -2
- package/lib/module/renderer/processors/Circles.js.map +1 -1
- package/lib/module/renderer/processors/Font.js +1 -1
- package/lib/module/renderer/processors/Font.js.map +1 -1
- package/lib/module/renderer/processors/Rects.js +9 -21
- package/lib/module/renderer/processors/Rects.js.map +1 -1
- package/lib/module/renderer/processors/math/Matrix3.js +52 -72
- package/lib/module/renderer/processors/math/Matrix3.js.map +1 -1
- package/lib/module/renderer/processors/math/Vector.js +3 -5
- package/lib/module/renderer/processors/math/Vector.js.map +1 -1
- package/lib/module/skia/Color.js +9 -25
- package/lib/module/skia/Color.js.map +1 -1
- package/lib/module/skia/ImageFilter/ImageFilterFactory.js.map +1 -1
- package/lib/module/skia/Matrix.js.map +1 -1
- package/lib/module/skia/Shader/useShader.js +4 -1
- package/lib/module/skia/Shader/useShader.js.map +1 -1
- package/lib/module/skia/Skia.js +2 -46
- package/lib/module/skia/Skia.js.map +1 -1
- package/lib/module/skia/SkiaApi.js +2 -0
- package/lib/module/skia/SkiaApi.js.map +1 -0
- package/lib/module/values/api.js +4 -6
- package/lib/module/values/api.js.map +1 -1
- package/lib/module/values/api.web.js +7 -0
- package/lib/module/values/api.web.js.map +1 -0
- package/lib/module/values/index.js +0 -1
- package/lib/module/values/index.js.map +1 -1
- package/lib/module/values/web/RNSkAnimation.js +36 -0
- package/lib/module/values/web/RNSkAnimation.js.map +1 -0
- package/lib/module/values/web/RNSkClockValue.js +65 -0
- package/lib/module/values/web/RNSkClockValue.js.map +1 -0
- package/lib/module/values/web/RNSkDerivedValue.js +41 -0
- package/lib/module/values/web/RNSkDerivedValue.js.map +1 -0
- package/lib/module/values/web/RNSkReadonlyValue.js +36 -0
- package/lib/module/values/web/RNSkReadonlyValue.js.map +1 -0
- package/lib/module/values/web/RNSkValue.js +63 -0
- package/lib/module/values/web/RNSkValue.js.map +1 -0
- package/lib/module/values/web/api.js +19 -0
- package/lib/module/values/web/api.js.map +1 -0
- package/lib/module/values/web/index.js +2 -0
- package/lib/module/values/web/index.js.map +1 -0
- package/lib/module/views/SkiaView.js +1 -3
- package/lib/module/views/SkiaView.js.map +1 -1
- package/lib/module/views/api.js +4 -0
- package/lib/module/views/api.js.map +1 -0
- package/lib/module/views/types.js.map +1 -1
- package/lib/typescript/src/{values/animation → animation}/decay/decay.d.ts +0 -0
- package/lib/typescript/src/{values/animation → animation}/decay/index.d.ts +0 -0
- package/lib/typescript/src/{values/animation → animation}/decay/runDecay.d.ts +2 -2
- package/lib/typescript/src/{values/animation → animation}/decay/types.d.ts +1 -1
- package/lib/typescript/src/{values/animation → animation}/functions/index.d.ts +0 -0
- package/lib/typescript/src/animation/functions/interpolate.d.ts +11 -0
- package/lib/typescript/src/animation/functions/interpolateColors.d.ts +3 -0
- package/lib/typescript/src/{values/animation → animation}/index.d.ts +0 -0
- package/lib/typescript/src/{values/animation → animation}/spring/Spring.d.ts +0 -0
- package/lib/typescript/src/{values/animation → animation}/spring/functions/index.d.ts +0 -0
- package/lib/typescript/src/{values/animation → animation}/spring/functions/spring.d.ts +0 -0
- package/lib/typescript/src/{values/animation → animation}/spring/index.d.ts +0 -0
- package/lib/typescript/src/{values/animation → animation}/spring/runSpring.d.ts +1 -1
- package/lib/typescript/src/{values/animation → animation}/spring/types.d.ts +0 -0
- package/lib/typescript/src/{values/animation → animation}/spring/useSpring.d.ts +1 -1
- package/lib/typescript/src/{values/animation → animation}/timing/Easing.d.ts +0 -0
- package/lib/typescript/src/{values/animation → animation}/timing/createTiming.d.ts +2 -2
- package/lib/typescript/src/{values/animation → animation}/timing/functions/bezier.d.ts +0 -0
- package/lib/typescript/src/{values/animation → animation}/timing/functions/getResolvedParams.d.ts +0 -0
- package/lib/typescript/src/{values/animation → animation}/timing/functions/index.d.ts +0 -0
- package/lib/typescript/src/{values/animation → animation}/timing/functions/timing.d.ts +1 -1
- package/lib/typescript/src/{values/animation → animation}/timing/functions/types.d.ts +0 -0
- package/lib/typescript/src/{values/animation → animation}/timing/index.d.ts +0 -0
- package/lib/typescript/src/{values/animation → animation}/timing/runTiming.d.ts +1 -1
- package/lib/typescript/src/{values/animation → animation}/timing/useLoop.d.ts +0 -0
- package/lib/typescript/src/{values/animation → animation}/timing/useTiming.d.ts +1 -1
- package/lib/typescript/src/{values/animation → animation}/types.d.ts +5 -5
- package/lib/typescript/src/index.d.ts +1 -0
- package/lib/typescript/src/renderer/Canvas.d.ts +6 -0
- package/lib/typescript/src/renderer/components/colorFilters/BlendColor.d.ts +1 -1
- package/lib/typescript/src/renderer/components/imageFilters/RuntimeShader.d.ts +7 -0
- package/lib/typescript/src/renderer/components/imageFilters/index.d.ts +1 -0
- package/lib/typescript/src/renderer/components/shaders/Gradient.d.ts +1 -1
- package/lib/typescript/src/renderer/components/shaders/Shader.d.ts +2 -2
- package/lib/typescript/src/renderer/components/shapes/Circle.d.ts +1 -4
- package/lib/typescript/src/renderer/processors/Rects.d.ts +9 -41
- package/lib/typescript/src/renderer/processors/math/Matrix3.d.ts +1 -5
- package/lib/typescript/src/renderer/processors/math/Vector.d.ts +5 -17
- package/lib/typescript/src/skia/Color.d.ts +8 -9
- package/lib/typescript/src/skia/ImageFilter/ImageFilterFactory.d.ts +16 -0
- package/lib/typescript/src/skia/Matrix.d.ts +7 -1
- package/lib/typescript/src/skia/RuntimeEffect/RuntimeEffect.d.ts +2 -1
- package/lib/typescript/src/skia/RuntimeEffect/RuntimeEffectFactory.d.ts +2 -2
- package/lib/typescript/src/skia/Shader/useShader.d.ts +1 -1
- package/lib/typescript/src/skia/Skia.d.ts +28 -95
- package/lib/typescript/src/skia/SkiaApi.d.ts +71 -0
- package/lib/typescript/src/skia/Surface/Surface.d.ts +1 -1
- package/lib/typescript/src/skia/Surface/SurfaceFactory.d.ts +2 -2
- package/lib/typescript/src/values/api.d.ts +2 -25
- package/lib/typescript/src/values/api.web.d.ts +2 -0
- package/lib/typescript/src/values/index.d.ts +0 -1
- package/lib/typescript/src/values/types.d.ts +24 -1
- package/lib/typescript/src/values/web/RNSkAnimation.d.ts +9 -0
- package/lib/typescript/src/values/web/RNSkClockValue.d.ts +13 -0
- package/lib/typescript/src/values/web/RNSkDerivedValue.d.ts +9 -0
- package/lib/typescript/src/values/web/RNSkReadonlyValue.d.ts +11 -0
- package/lib/typescript/src/values/web/RNSkValue.d.ts +14 -0
- package/lib/typescript/src/values/web/api.d.ts +2 -0
- package/lib/typescript/src/values/web/index.d.ts +1 -0
- package/lib/typescript/src/views/SkiaView.d.ts +3 -36
- package/lib/typescript/src/views/api.d.ts +5 -0
- package/lib/typescript/src/views/types.d.ts +32 -0
- package/package.json +2 -2
- package/src/{values/animation → animation}/decay/decay.ts +0 -0
- package/src/{values/animation → animation}/decay/index.ts +0 -0
- package/src/{values/animation → animation}/decay/runDecay.ts +2 -2
- package/src/{values/animation → animation}/decay/types.ts +1 -1
- package/src/{values/animation → animation}/functions/index.ts +0 -0
- package/src/animation/functions/interpolate.ts +182 -0
- package/src/animation/functions/interpolateColors.ts +58 -0
- package/src/{values/animation → animation}/index.ts +0 -0
- package/src/{values/animation → animation}/spring/Spring.ts +0 -0
- package/src/{values/animation → animation}/spring/functions/index.ts +0 -0
- package/src/{values/animation → animation}/spring/functions/spring.ts +0 -0
- package/src/{values/animation → animation}/spring/index.ts +0 -0
- package/src/{values/animation → animation}/spring/runSpring.ts +1 -1
- package/src/{values/animation → animation}/spring/types.ts +0 -0
- package/src/{values/animation → animation}/spring/useSpring.ts +1 -1
- package/src/{values/animation → animation}/timing/Easing.ts +0 -0
- package/src/{values/animation → animation}/timing/createTiming.ts +2 -2
- package/src/{values/animation → animation}/timing/functions/__tests__/timing.spec.ts +0 -0
- package/src/{values/animation → animation}/timing/functions/bezier.ts +0 -0
- package/src/{values/animation → animation}/timing/functions/getResolvedParams.ts +2 -2
- package/src/{values/animation → animation}/timing/functions/index.ts +0 -0
- package/src/{values/animation → animation}/timing/functions/timing.ts +1 -1
- package/src/{values/animation → animation}/timing/functions/types.ts +0 -0
- package/src/{values/animation → animation}/timing/index.ts +0 -0
- package/src/{values/animation → animation}/timing/runTiming.ts +1 -1
- package/src/{values/animation → animation}/timing/useLoop.ts +0 -0
- package/src/{values/animation → animation}/timing/useTiming.ts +2 -2
- package/src/{values/animation → animation}/types.ts +5 -5
- package/src/index.ts +1 -0
- package/src/renderer/Canvas.tsx +11 -4
- package/src/renderer/components/colorFilters/BlendColor.tsx +1 -1
- package/src/renderer/components/colorFilters/Lerp.tsx +1 -1
- package/src/renderer/components/imageFilters/InnerShadow.tsx +4 -2
- package/src/renderer/components/imageFilters/RuntimeShader.tsx +23 -0
- package/src/renderer/components/imageFilters/index.ts +1 -0
- package/src/renderer/components/shaders/Gradient.ts +2 -4
- package/src/renderer/components/shaders/Shader.tsx +3 -3
- package/src/renderer/processors/Circles.ts +2 -1
- package/src/renderer/processors/Font.ts +1 -1
- package/src/renderer/processors/Rects.ts +9 -14
- package/src/renderer/processors/math/Matrix3.ts +24 -105
- package/src/renderer/processors/math/Vector.ts +3 -2
- package/src/skia/Color.ts +13 -27
- package/src/skia/ImageFilter/ImageFilterFactory.ts +20 -0
- package/src/skia/Matrix.ts +8 -1
- package/src/skia/RuntimeEffect/RuntimeEffect.ts +3 -1
- package/src/skia/RuntimeEffect/RuntimeEffectFactory.ts +2 -2
- package/src/skia/Shader/useShader.ts +4 -1
- package/src/skia/Skia.ts +4 -126
- package/src/skia/SkiaApi.ts +86 -0
- package/src/skia/Surface/Surface.ts +1 -1
- package/src/skia/Surface/SurfaceFactory.ts +2 -2
- package/src/values/api.ts +3 -42
- package/src/values/api.web.ts +5 -0
- package/src/values/index.ts +0 -1
- package/src/values/types.ts +30 -1
- package/src/values/web/RNSkAnimation.ts +33 -0
- package/src/values/web/RNSkClockValue.ts +58 -0
- package/src/values/web/RNSkDerivedValue.ts +38 -0
- package/src/values/web/RNSkReadonlyValue.ts +32 -0
- package/src/values/web/RNSkValue.ts +57 -0
- package/src/values/web/__tests__/RNSkAnimation.spec.ts +21 -0
- package/src/values/web/__tests__/RNSkDerivedValue.spec.ts +15 -0
- package/src/values/web/__tests__/RNSkReadonlyValue.spec.ts +8 -0
- package/src/values/web/__tests__/RNSkValue.spec.ts +11 -0
- package/src/values/web/api.ts +33 -0
- package/src/values/web/index.ts +1 -0
- package/src/views/SkiaView.tsx +3 -49
- package/src/views/api.ts +7 -0
- package/src/views/types.ts +40 -0
- package/lib/commonjs/values/animation/decay/runDecay.js.map +0 -1
- package/lib/commonjs/values/animation/functions/interpolate.js +0 -139
- package/lib/commonjs/values/animation/functions/interpolate.js.map +0 -1
- package/lib/commonjs/values/animation/functions/interpolateColors.js +0 -47
- package/lib/commonjs/values/animation/functions/interpolateColors.js.map +0 -1
- package/lib/commonjs/values/animation/spring/runSpring.js.map +0 -1
- package/lib/commonjs/values/animation/spring/useSpring.js.map +0 -1
- package/lib/commonjs/values/animation/timing/createTiming.js.map +0 -1
- package/lib/commonjs/values/animation/timing/functions/getResolvedParams.js.map +0 -1
- package/lib/commonjs/values/animation/timing/runTiming.js.map +0 -1
- package/lib/commonjs/values/animation/timing/useTiming.js.map +0 -1
- package/lib/module/values/animation/decay/runDecay.js.map +0 -1
- package/lib/module/values/animation/functions/interpolate.js +0 -132
- package/lib/module/values/animation/functions/interpolate.js.map +0 -1
- package/lib/module/values/animation/functions/interpolateColors.js +0 -32
- package/lib/module/values/animation/functions/interpolateColors.js.map +0 -1
- package/lib/module/values/animation/spring/runSpring.js.map +0 -1
- package/lib/module/values/animation/spring/useSpring.js.map +0 -1
- package/lib/module/values/animation/timing/createTiming.js.map +0 -1
- package/lib/module/values/animation/timing/functions/getResolvedParams.js.map +0 -1
- package/lib/module/values/animation/timing/runTiming.js.map +0 -1
- package/lib/module/values/animation/timing/useTiming.js.map +0 -1
- package/lib/typescript/scripts/install-npm.d.ts +0 -1
- package/lib/typescript/src/values/animation/functions/interpolate.d.ts +0 -7
- package/lib/typescript/src/values/animation/functions/interpolateColors.d.ts +0 -3
- package/src/values/animation/functions/interpolate.ts +0 -169
- package/src/values/animation/functions/interpolateColors.ts +0 -62
@@ -0,0 +1,194 @@
|
|
1
|
+
#include "CSSColorParser.h"
|
2
|
+
|
3
|
+
namespace CSSColorParser {
|
4
|
+
|
5
|
+
template <typename T>
|
6
|
+
uint8_t clamp_css_byte(T i) { // Clamp to integer 0 .. 255.
|
7
|
+
i = ::round(i); // Seems to be what Chrome does (vs truncation).
|
8
|
+
return i < 0 ? 0 : i > 255 ? 255 : uint8_t(i);
|
9
|
+
}
|
10
|
+
|
11
|
+
template <typename T>
|
12
|
+
float clamp_css_float(T f) { // Clamp to float 0.0 .. 1.0.
|
13
|
+
return f < 0 ? 0 : f > 1 ? 1 : float(f);
|
14
|
+
}
|
15
|
+
|
16
|
+
float parseFloat(const std::string& str) {
|
17
|
+
return strtof(str.c_str(), nullptr);
|
18
|
+
}
|
19
|
+
|
20
|
+
int64_t parseInt(const std::string& str, uint8_t base = 10) {
|
21
|
+
return strtoll(str.c_str(), nullptr, base);
|
22
|
+
}
|
23
|
+
|
24
|
+
uint8_t parse_css_int(const std::string& str) { // int or percentage.
|
25
|
+
if (str.length() && str.back() == '%') {
|
26
|
+
return clamp_css_byte(parseFloat(str) / 100.0f * 255.0f);
|
27
|
+
} else {
|
28
|
+
return clamp_css_byte(parseInt(str));
|
29
|
+
}
|
30
|
+
}
|
31
|
+
|
32
|
+
float parse_css_float(const std::string& str) { // float or percentage.
|
33
|
+
if (str.length() && str.back() == '%') {
|
34
|
+
return clamp_css_float(parseFloat(str) / 100.0f);
|
35
|
+
} else {
|
36
|
+
return clamp_css_float(parseFloat(str));
|
37
|
+
}
|
38
|
+
}
|
39
|
+
|
40
|
+
float css_hue_to_rgb(float m1, float m2, float h) {
|
41
|
+
if (h < 0.0f) {
|
42
|
+
h += 1.0f;
|
43
|
+
} else if (h > 1.0f) {
|
44
|
+
h -= 1.0f;
|
45
|
+
}
|
46
|
+
|
47
|
+
if (h * 6.0f < 1.0f) {
|
48
|
+
return m1 + (m2 - m1) * h * 6.0f;
|
49
|
+
}
|
50
|
+
if (h * 2.0f < 1.0f) {
|
51
|
+
return m2;
|
52
|
+
}
|
53
|
+
if (h * 3.0f < 2.0f) {
|
54
|
+
return m1 + (m2 - m1) * (2.0f / 3.0f - h) * 6.0f;
|
55
|
+
}
|
56
|
+
return m1;
|
57
|
+
}
|
58
|
+
|
59
|
+
std::vector<std::string> split(const std::string& s, char delim) {
|
60
|
+
std::vector<std::string> elems;
|
61
|
+
std::stringstream ss(s);
|
62
|
+
std::string item;
|
63
|
+
while (std::getline(ss, item, delim)) {
|
64
|
+
elems.push_back(item);
|
65
|
+
}
|
66
|
+
return elems;
|
67
|
+
}
|
68
|
+
|
69
|
+
Color parse(const std::string& css_str) {
|
70
|
+
std::string str = css_str;
|
71
|
+
|
72
|
+
// Remove all whitespace, not compliant, but should just be more accepting.
|
73
|
+
str.erase(std::remove(str.begin(), str.end(), ' '), str.end());
|
74
|
+
|
75
|
+
// Convert to lowercase.
|
76
|
+
std::transform(str.begin(), str.end(), str.begin(), ::tolower);
|
77
|
+
|
78
|
+
for (const auto& namedColor : namedColors) {
|
79
|
+
if (str == namedColor.name) {
|
80
|
+
return { namedColor.color };
|
81
|
+
}
|
82
|
+
}
|
83
|
+
|
84
|
+
// #abc and #abc123 syntax.
|
85
|
+
if (str.length() && str.front() == '#') {
|
86
|
+
auto iv = parseInt(str.substr(1), 16); // TODO(deanm): Stricter parsing.
|
87
|
+
if (str.length() == 4) {
|
88
|
+
if (!(iv >= 0 && iv <= 0xfff)) {
|
89
|
+
return {};
|
90
|
+
} else {
|
91
|
+
return {
|
92
|
+
static_cast<uint8_t>(((iv & 0xf00) >> 4) | ((iv & 0xf00) >> 8)),
|
93
|
+
static_cast<uint8_t>((iv & 0xf0) | ((iv & 0xf0) >> 4)),
|
94
|
+
static_cast<uint8_t>((iv & 0xf) | ((iv & 0xf) << 4)),
|
95
|
+
1
|
96
|
+
};
|
97
|
+
}
|
98
|
+
} else if (str.length() == 7) {
|
99
|
+
if (!(iv >= 0 && iv <= 0xffffff)) {
|
100
|
+
return {}; // Covers NaN.
|
101
|
+
} else {
|
102
|
+
return {
|
103
|
+
static_cast<uint8_t>((iv & 0xff0000) >> 16),
|
104
|
+
static_cast<uint8_t>((iv & 0xff00) >> 8),
|
105
|
+
static_cast<uint8_t>(iv & 0xff),
|
106
|
+
1
|
107
|
+
};
|
108
|
+
}
|
109
|
+
}else if (str.length() == 5) {
|
110
|
+
// #rgba
|
111
|
+
if (!(iv >= 0 && iv <= 0xffff)) return {}; // Covers NaN.
|
112
|
+
return {
|
113
|
+
static_cast<uint8_t>(((iv & 0xf000) >> 8) | ((iv & 0xf000) >> 12)),
|
114
|
+
static_cast<uint8_t>(((iv & 0x0f00) >> 4) | ((iv & 0x0f00) >> 8)),
|
115
|
+
static_cast<uint8_t>((iv & 0x00f0) | ((iv & 0x00f0) >> 4)),
|
116
|
+
static_cast<uint8_t>(((iv & 0x000f) << 4 | (iv & 0x000f))) / 255.0f
|
117
|
+
};
|
118
|
+
} else if (str.length() == 9) {
|
119
|
+
// #rrggbbaa
|
120
|
+
if (!(iv >= 0 && iv <= 0xffffffff)) return {}; // Covers NaN.
|
121
|
+
return {
|
122
|
+
static_cast<uint8_t>(((iv & 0xff000000) >> 24) & 0xff),
|
123
|
+
static_cast<uint8_t>((iv & 0x00ff0000) >> 16),
|
124
|
+
static_cast<uint8_t>((iv & 0x0000ff00) >> 8),
|
125
|
+
static_cast<uint8_t>((iv & 0x000000ff)) / 255.0f
|
126
|
+
};
|
127
|
+
}
|
128
|
+
|
129
|
+
return {};
|
130
|
+
}
|
131
|
+
|
132
|
+
size_t op = str.find_first_of('('), ep = str.find_first_of(')');
|
133
|
+
if (op != std::string::npos && ep + 1 == str.length()) {
|
134
|
+
const std::string fname = str.substr(0, op);
|
135
|
+
const std::vector<std::string> params = split(str.substr(op + 1, ep - (op + 1)), ',');
|
136
|
+
|
137
|
+
float alpha = 1.0f;
|
138
|
+
|
139
|
+
if (fname == "rgba" || fname == "rgb") {
|
140
|
+
if (fname == "rgba") {
|
141
|
+
if (params.size() != 4) {
|
142
|
+
return { };
|
143
|
+
}
|
144
|
+
alpha = parse_css_float(params.back());
|
145
|
+
} else {
|
146
|
+
if (params.size() != 3) {
|
147
|
+
return { };
|
148
|
+
}
|
149
|
+
}
|
150
|
+
|
151
|
+
return {
|
152
|
+
parse_css_int(params[0]),
|
153
|
+
parse_css_int(params[1]),
|
154
|
+
parse_css_int(params[2]),
|
155
|
+
alpha
|
156
|
+
};
|
157
|
+
|
158
|
+
} else if (fname == "hsla" || fname == "hsl") {
|
159
|
+
if (fname == "hsla") {
|
160
|
+
if (params.size() != 4) {
|
161
|
+
return { };
|
162
|
+
}
|
163
|
+
alpha = parse_css_float(params.back());
|
164
|
+
} else {
|
165
|
+
if (params.size() != 3) {
|
166
|
+
return { };
|
167
|
+
}
|
168
|
+
}
|
169
|
+
|
170
|
+
float h = parseFloat(params[0]) / 360.0f;
|
171
|
+
float i;
|
172
|
+
// Normalize the hue to [0..1[
|
173
|
+
h = std::modf(h, &i);
|
174
|
+
|
175
|
+
// NOTE(deanm): According to the CSS spec s/l should only be
|
176
|
+
// percentages, but we don't bother and let float or percentage.
|
177
|
+
float s = parse_css_float(params[1]);
|
178
|
+
float l = parse_css_float(params[2]);
|
179
|
+
|
180
|
+
float m2 = l <= 0.5f ? l * (s + 1.0f) : l + s - l * s;
|
181
|
+
float m1 = l * 2.0f - m2;
|
182
|
+
|
183
|
+
return {
|
184
|
+
clamp_css_byte(css_hue_to_rgb(m1, m2, h + 1.0f / 3.0f) * 255.0f),
|
185
|
+
clamp_css_byte(css_hue_to_rgb(m1, m2, h) * 255.0f),
|
186
|
+
clamp_css_byte(css_hue_to_rgb(m1, m2, h - 1.0f / 3.0f) * 255.0f),
|
187
|
+
alpha
|
188
|
+
};
|
189
|
+
}
|
190
|
+
}
|
191
|
+
|
192
|
+
return { };
|
193
|
+
}
|
194
|
+
}
|
@@ -122,71 +122,6 @@ namespace CSSColorParser {
|
|
122
122
|
{ "yellow", { 255, 255, 0, 1 } }, { "yellowgreen", { 154, 205, 50, 1 } }
|
123
123
|
};
|
124
124
|
|
125
|
-
template <typename T>
|
126
|
-
uint8_t clamp_css_byte(T i) { // Clamp to integer 0 .. 255.
|
127
|
-
i = ::round(i); // Seems to be what Chrome does (vs truncation).
|
128
|
-
return i < 0 ? 0 : i > 255 ? 255 : uint8_t(i);
|
129
|
-
}
|
130
|
-
|
131
|
-
template <typename T>
|
132
|
-
float clamp_css_float(T f) { // Clamp to float 0.0 .. 1.0.
|
133
|
-
return f < 0 ? 0 : f > 1 ? 1 : float(f);
|
134
|
-
}
|
135
|
-
|
136
|
-
float parseFloat(const std::string& str) {
|
137
|
-
return strtof(str.c_str(), nullptr);
|
138
|
-
}
|
139
|
-
|
140
|
-
int64_t parseInt(const std::string& str, uint8_t base = 10) {
|
141
|
-
return strtoll(str.c_str(), nullptr, base);
|
142
|
-
}
|
143
|
-
|
144
|
-
uint8_t parse_css_int(const std::string& str) { // int or percentage.
|
145
|
-
if (str.length() && str.back() == '%') {
|
146
|
-
return clamp_css_byte(parseFloat(str) / 100.0f * 255.0f);
|
147
|
-
} else {
|
148
|
-
return clamp_css_byte(parseInt(str));
|
149
|
-
}
|
150
|
-
}
|
151
|
-
|
152
|
-
float parse_css_float(const std::string& str) { // float or percentage.
|
153
|
-
if (str.length() && str.back() == '%') {
|
154
|
-
return clamp_css_float(parseFloat(str) / 100.0f);
|
155
|
-
} else {
|
156
|
-
return clamp_css_float(parseFloat(str));
|
157
|
-
}
|
158
|
-
}
|
159
|
-
|
160
|
-
float css_hue_to_rgb(float m1, float m2, float h) {
|
161
|
-
if (h < 0.0f) {
|
162
|
-
h += 1.0f;
|
163
|
-
} else if (h > 1.0f) {
|
164
|
-
h -= 1.0f;
|
165
|
-
}
|
166
|
-
|
167
|
-
if (h * 6.0f < 1.0f) {
|
168
|
-
return m1 + (m2 - m1) * h * 6.0f;
|
169
|
-
}
|
170
|
-
if (h * 2.0f < 1.0f) {
|
171
|
-
return m2;
|
172
|
-
}
|
173
|
-
if (h * 3.0f < 2.0f) {
|
174
|
-
return m1 + (m2 - m1) * (2.0f / 3.0f - h) * 6.0f;
|
175
|
-
}
|
176
|
-
return m1;
|
177
|
-
}
|
178
|
-
|
179
|
-
std::vector<std::string> split(const std::string& s, char delim) {
|
180
|
-
std::vector<std::string> elems;
|
181
|
-
std::stringstream ss(s);
|
182
|
-
std::string item;
|
183
|
-
while (std::getline(ss, item, delim)) {
|
184
|
-
elems.push_back(item);
|
185
|
-
}
|
186
|
-
return elems;
|
187
|
-
}
|
188
|
-
|
189
|
-
|
190
125
|
inline bool operator==(const Color& lhs, const Color& rhs) {
|
191
126
|
return lhs.r == rhs.r && lhs.g == rhs.g && lhs.b == rhs.b && ::fabs(lhs.a - rhs.a) < 0.0001f;
|
192
127
|
}
|
@@ -195,130 +130,5 @@ namespace CSSColorParser {
|
|
195
130
|
return !(lhs == rhs);
|
196
131
|
}
|
197
132
|
|
198
|
-
Color parse(const std::string& css_str)
|
199
|
-
std::string str = css_str;
|
200
|
-
|
201
|
-
// Remove all whitespace, not compliant, but should just be more accepting.
|
202
|
-
str.erase(std::remove(str.begin(), str.end(), ' '), str.end());
|
203
|
-
|
204
|
-
// Convert to lowercase.
|
205
|
-
std::transform(str.begin(), str.end(), str.begin(), ::tolower);
|
206
|
-
|
207
|
-
for (const auto& namedColor : namedColors) {
|
208
|
-
if (str == namedColor.name) {
|
209
|
-
return { namedColor.color };
|
210
|
-
}
|
211
|
-
}
|
212
|
-
|
213
|
-
// #abc and #abc123 syntax.
|
214
|
-
if (str.length() && str.front() == '#') {
|
215
|
-
auto iv = parseInt(str.substr(1), 16); // TODO(deanm): Stricter parsing.
|
216
|
-
if (str.length() == 4) {
|
217
|
-
if (!(iv >= 0 && iv <= 0xfff)) {
|
218
|
-
return {};
|
219
|
-
} else {
|
220
|
-
return {
|
221
|
-
static_cast<uint8_t>(((iv & 0xf00) >> 4) | ((iv & 0xf00) >> 8)),
|
222
|
-
static_cast<uint8_t>((iv & 0xf0) | ((iv & 0xf0) >> 4)),
|
223
|
-
static_cast<uint8_t>((iv & 0xf) | ((iv & 0xf) << 4)),
|
224
|
-
1
|
225
|
-
};
|
226
|
-
}
|
227
|
-
} else if (str.length() == 7) {
|
228
|
-
if (!(iv >= 0 && iv <= 0xffffff)) {
|
229
|
-
return {}; // Covers NaN.
|
230
|
-
} else {
|
231
|
-
return {
|
232
|
-
static_cast<uint8_t>((iv & 0xff0000) >> 16),
|
233
|
-
static_cast<uint8_t>((iv & 0xff00) >> 8),
|
234
|
-
static_cast<uint8_t>(iv & 0xff),
|
235
|
-
1
|
236
|
-
};
|
237
|
-
}
|
238
|
-
}else if (str.length() == 5) {
|
239
|
-
// #rgba
|
240
|
-
if (!(iv >= 0 && iv <= 0xffff)) return {}; // Covers NaN.
|
241
|
-
return {
|
242
|
-
static_cast<uint8_t>(((iv & 0xf000) >> 8) | ((iv & 0xf000) >> 12)),
|
243
|
-
static_cast<uint8_t>(((iv & 0x0f00) >> 4) | ((iv & 0x0f00) >> 8)),
|
244
|
-
static_cast<uint8_t>((iv & 0x00f0) | ((iv & 0x00f0) >> 4)),
|
245
|
-
static_cast<uint8_t>(((iv & 0x000f) << 4 | (iv & 0x000f))) / 255.0f
|
246
|
-
};
|
247
|
-
} else if (str.length() == 9) {
|
248
|
-
// #rrggbbaa
|
249
|
-
if (!(iv >= 0 && iv <= 0xffffffff)) return {}; // Covers NaN.
|
250
|
-
return {
|
251
|
-
static_cast<uint8_t>(((iv & 0xff000000) >> 24) & 0xff),
|
252
|
-
static_cast<uint8_t>((iv & 0x00ff0000) >> 16),
|
253
|
-
static_cast<uint8_t>((iv & 0x0000ff00) >> 8),
|
254
|
-
static_cast<uint8_t>((iv & 0x000000ff)) / 255.0f
|
255
|
-
};
|
256
|
-
}
|
257
|
-
|
258
|
-
return {};
|
259
|
-
}
|
260
|
-
|
261
|
-
size_t op = str.find_first_of('('), ep = str.find_first_of(')');
|
262
|
-
if (op != std::string::npos && ep + 1 == str.length()) {
|
263
|
-
const std::string fname = str.substr(0, op);
|
264
|
-
const std::vector<std::string> params = split(str.substr(op + 1, ep - (op + 1)), ',');
|
265
|
-
|
266
|
-
float alpha = 1.0f;
|
267
|
-
|
268
|
-
if (fname == "rgba" || fname == "rgb") {
|
269
|
-
if (fname == "rgba") {
|
270
|
-
if (params.size() != 4) {
|
271
|
-
return { };
|
272
|
-
}
|
273
|
-
alpha = parse_css_float(params.back());
|
274
|
-
} else {
|
275
|
-
if (params.size() != 3) {
|
276
|
-
return { };
|
277
|
-
}
|
278
|
-
}
|
279
|
-
|
280
|
-
return {
|
281
|
-
parse_css_int(params[0]),
|
282
|
-
parse_css_int(params[1]),
|
283
|
-
parse_css_int(params[2]),
|
284
|
-
alpha
|
285
|
-
};
|
286
|
-
|
287
|
-
} else if (fname == "hsla" || fname == "hsl") {
|
288
|
-
if (fname == "hsla") {
|
289
|
-
if (params.size() != 4) {
|
290
|
-
return { };
|
291
|
-
}
|
292
|
-
alpha = parse_css_float(params.back());
|
293
|
-
} else {
|
294
|
-
if (params.size() != 3) {
|
295
|
-
return { };
|
296
|
-
}
|
297
|
-
}
|
298
|
-
|
299
|
-
float h = parseFloat(params[0]) / 360.0f;
|
300
|
-
float i;
|
301
|
-
// Normalize the hue to [0..1[
|
302
|
-
h = std::modf(h, &i);
|
303
|
-
|
304
|
-
// NOTE(deanm): According to the CSS spec s/l should only be
|
305
|
-
// percentages, but we don't bother and let float or percentage.
|
306
|
-
float s = parse_css_float(params[1]);
|
307
|
-
float l = parse_css_float(params[2]);
|
308
|
-
|
309
|
-
float m2 = l <= 0.5f ? l * (s + 1.0f) : l + s - l * s;
|
310
|
-
float m1 = l * 2.0f - m2;
|
311
|
-
|
312
|
-
return {
|
313
|
-
clamp_css_byte(css_hue_to_rgb(m1, m2, h + 1.0f / 3.0f) * 255.0f),
|
314
|
-
clamp_css_byte(css_hue_to_rgb(m1, m2, h) * 255.0f),
|
315
|
-
clamp_css_byte(css_hue_to_rgb(m1, m2, h - 1.0f / 3.0f) * 255.0f),
|
316
|
-
alpha
|
317
|
-
};
|
318
|
-
}
|
319
|
-
}
|
320
|
-
|
321
|
-
return { };
|
322
|
-
}
|
323
|
-
|
133
|
+
Color parse(const std::string& css_str);
|
324
134
|
} // namespace CSSColorParser
|
@@ -0,0 +1,108 @@
|
|
1
|
+
|
2
|
+
#pragma once
|
3
|
+
|
4
|
+
#include <jsi/jsi.h>
|
5
|
+
|
6
|
+
namespace RNJsi
|
7
|
+
{
|
8
|
+
using namespace facebook;
|
9
|
+
|
10
|
+
enum JsiWrapperValueType
|
11
|
+
{
|
12
|
+
NonInitialized,
|
13
|
+
Undefined,
|
14
|
+
Null,
|
15
|
+
Bool,
|
16
|
+
Number,
|
17
|
+
JsiValue
|
18
|
+
};
|
19
|
+
|
20
|
+
/**
|
21
|
+
Implements a simple wrapper class for JSI primitives like numbers and boolean values. Objects,
|
22
|
+
strings and arrays are stored as values inside a property holder. The class also provides a method
|
23
|
+
for comparing values that will compare numbers, booleans and strings.
|
24
|
+
*/
|
25
|
+
class JsiSimpleValueWrapper
|
26
|
+
{
|
27
|
+
public:
|
28
|
+
JsiSimpleValueWrapper(jsi::Runtime& runtime) :
|
29
|
+
_type(JsiWrapperValueType::NonInitialized),
|
30
|
+
_propNameId(jsi::PropNameID::forUtf8(runtime, "value"))
|
31
|
+
{}
|
32
|
+
|
33
|
+
jsi::Value getCurrent(jsi::Runtime &runtime)
|
34
|
+
{
|
35
|
+
switch (_type)
|
36
|
+
{
|
37
|
+
case JsiWrapperValueType::NonInitialized:
|
38
|
+
return nullptr;
|
39
|
+
case JsiWrapperValueType::Undefined:
|
40
|
+
return jsi::Value::undefined();
|
41
|
+
case JsiWrapperValueType::Null:
|
42
|
+
return jsi::Value::null();
|
43
|
+
case JsiWrapperValueType::Bool:
|
44
|
+
return _boolValue;
|
45
|
+
case JsiWrapperValueType::Number:
|
46
|
+
return _numberValue;
|
47
|
+
case JsiWrapperValueType::JsiValue:
|
48
|
+
if (_valueHolder == nullptr) {
|
49
|
+
return jsi::Value::undefined();
|
50
|
+
}
|
51
|
+
return _valueHolder->getProperty(runtime, _propNameId);
|
52
|
+
}
|
53
|
+
}
|
54
|
+
|
55
|
+
void setCurrent(jsi::Runtime &runtime, const jsi::Value &value)
|
56
|
+
{
|
57
|
+
if(value.isNumber()) {
|
58
|
+
_type = JsiWrapperValueType::Number;
|
59
|
+
_numberValue = value.asNumber();
|
60
|
+
} else if(value.isBool()) {
|
61
|
+
_type = JsiWrapperValueType::Bool;
|
62
|
+
_boolValue = value.getBool();
|
63
|
+
} else if(value.isUndefined()) {
|
64
|
+
_type = JsiWrapperValueType::Undefined;
|
65
|
+
} else if(value.isNull()) {
|
66
|
+
_type = JsiWrapperValueType::Null;
|
67
|
+
} else {
|
68
|
+
_type = JsiWrapperValueType::JsiValue;
|
69
|
+
// Save as javascript object - we don't want to have to copy strings, objects and values
|
70
|
+
if(_valueHolder == nullptr) {
|
71
|
+
_valueHolder = std::make_shared<jsi::Object>(runtime);
|
72
|
+
}
|
73
|
+
_valueHolder->setProperty(runtime, _propNameId, value);
|
74
|
+
}
|
75
|
+
}
|
76
|
+
|
77
|
+
bool equals(jsi::Runtime& runtime, const jsi::Value &value) {
|
78
|
+
if (_type == JsiWrapperValueType::NonInitialized) {
|
79
|
+
return false;
|
80
|
+
}
|
81
|
+
if(value.isNumber() && _type == JsiWrapperValueType::Number) {
|
82
|
+
return _numberValue == value.asNumber();
|
83
|
+
} else if(value.isBool() && _type == JsiWrapperValueType::Bool) {
|
84
|
+
return _boolValue == value.getBool();
|
85
|
+
} else if(value.isUndefined()) {
|
86
|
+
return _type == JsiWrapperValueType::Undefined;
|
87
|
+
} else if(value.isNull()) {
|
88
|
+
return _type == JsiWrapperValueType::Null;
|
89
|
+
} else if(value.isString()) {
|
90
|
+
auto current = getCurrent(runtime);
|
91
|
+
if (current.isString()) {
|
92
|
+
return jsi::String::strictEquals(runtime, value.asString(runtime), current.asString(runtime));
|
93
|
+
}
|
94
|
+
return false;
|
95
|
+
}
|
96
|
+
return false;
|
97
|
+
}
|
98
|
+
|
99
|
+
private:
|
100
|
+
jsi::PropNameID _propNameId;
|
101
|
+
std::shared_ptr<jsi::Object> _valueHolder;
|
102
|
+
|
103
|
+
bool _boolValue;
|
104
|
+
double _numberValue;
|
105
|
+
|
106
|
+
JsiWrapperValueType _type;
|
107
|
+
};
|
108
|
+
}
|
@@ -67,17 +67,9 @@ void RNSkDrawView::setDrawCallback(std::shared_ptr<jsi::Function> callback) {
|
|
67
67
|
_jsTimingInfo.reset();
|
68
68
|
_gpuTimingInfo.reset();
|
69
69
|
|
70
|
-
// Set up debug font/paints
|
71
|
-
auto font = SkFont();
|
72
|
-
font.setSize(14);
|
73
|
-
auto paint = SkPaint();
|
74
|
-
paint.setColor(SkColors::kRed);
|
75
|
-
|
76
70
|
// Create draw drawCallback wrapper
|
77
71
|
_drawCallback = std::make_shared<RNSkDrawCallback>(
|
78
72
|
[weakSelf = weak_from_this(),
|
79
|
-
paint = std::move(paint),
|
80
|
-
font = std::move(font),
|
81
73
|
callback = std::move(callback)](std::shared_ptr<JsiSkCanvas> canvas,
|
82
74
|
int width,
|
83
75
|
int height,
|
@@ -121,7 +113,12 @@ void RNSkDrawView::setDrawCallback(std::shared_ptr<jsi::Function> callback) {
|
|
121
113
|
stream << "js: " << jsAvg << "ms gpu: " << gpuAvg << "ms " << " total: " << total << "ms";
|
122
114
|
|
123
115
|
std::string debugString = stream.str();
|
124
|
-
|
116
|
+
|
117
|
+
// Set up debug font/paints
|
118
|
+
auto font = SkFont();
|
119
|
+
font.setSize(14);
|
120
|
+
auto paint = SkPaint();
|
121
|
+
paint.setColor(SkColors::kRed);
|
125
122
|
canvas->getCanvas()->drawSimpleText(
|
126
123
|
debugString.c_str(), debugString.size(), SkTextEncoding::kUTF8, 8,
|
127
124
|
18, font, paint);
|
@@ -157,7 +154,7 @@ void RNSkDrawView::drawInCanvas(std::shared_ptr<JsiSkCanvas> canvas,
|
|
157
154
|
|
158
155
|
sk_sp<SkImage> RNSkDrawView::makeImageSnapshot(std::shared_ptr<SkRect> bounds) {
|
159
156
|
// Assert width/height
|
160
|
-
auto surface = SkSurface::MakeRasterN32Premul(
|
157
|
+
auto surface = SkSurface::MakeRasterN32Premul(getScaledWidth(), getScaledHeight());
|
161
158
|
auto canvas = surface->getCanvas();
|
162
159
|
auto jsiCanvas = std::make_shared<JsiSkCanvas>(_platformContext);
|
163
160
|
jsiCanvas->setCanvas(canvas);
|
@@ -165,7 +162,7 @@ sk_sp<SkImage> RNSkDrawView::makeImageSnapshot(std::shared_ptr<SkRect> bounds) {
|
|
165
162
|
milliseconds ms = duration_cast<milliseconds>(
|
166
163
|
system_clock::now().time_since_epoch());
|
167
164
|
|
168
|
-
drawInCanvas(jsiCanvas,
|
165
|
+
drawInCanvas(jsiCanvas, getScaledWidth(), getScaledHeight(), ms.count() / 1000);
|
169
166
|
|
170
167
|
if(bounds != nullptr) {
|
171
168
|
SkIRect b = SkIRect::MakeXYWH(bounds->x(), bounds->y(), bounds->width(), bounds->height());
|
@@ -188,7 +185,7 @@ void RNSkDrawView::performDraw() {
|
|
188
185
|
// move the actual drawing onto the render thread later
|
189
186
|
SkPictureRecorder recorder;
|
190
187
|
SkRTreeFactory factory;
|
191
|
-
SkCanvas* canvas = recorder.beginRecording(
|
188
|
+
SkCanvas* canvas = recorder.beginRecording(getScaledWidth(), getScaledHeight(), &factory);
|
192
189
|
_jsiCanvas->setCanvas(canvas);
|
193
190
|
|
194
191
|
// Get current milliseconds
|
@@ -197,7 +194,7 @@ void RNSkDrawView::performDraw() {
|
|
197
194
|
|
198
195
|
try {
|
199
196
|
// Perform the javascript drawing
|
200
|
-
drawInCanvas(_jsiCanvas,
|
197
|
+
drawInCanvas(_jsiCanvas, getScaledWidth(), getScaledHeight(), ms.count() / 1000.0);
|
201
198
|
} catch(...) {
|
202
199
|
_jsTimingInfo.stopTiming();
|
203
200
|
_jsDrawingLock->unlock();
|
@@ -97,12 +97,12 @@ protected:
|
|
97
97
|
/**
|
98
98
|
Returns the scaled width of the view
|
99
99
|
*/
|
100
|
-
virtual
|
100
|
+
virtual float getScaledWidth() = 0;
|
101
101
|
|
102
102
|
/**
|
103
103
|
Returns the scaled height of the view
|
104
104
|
*/
|
105
|
-
virtual
|
105
|
+
virtual float getScaledHeight() = 0;
|
106
106
|
|
107
107
|
/**
|
108
108
|
Override to render picture to GPU
|
@@ -34,8 +34,12 @@ public:
|
|
34
34
|
}
|
35
35
|
|
36
36
|
JSI_HOST_FUNCTION(createDerivedValue) {
|
37
|
-
|
38
|
-
|
37
|
+
// Creation and initialization is done in two steps to be able to use weak references when setting
|
38
|
+
// up dependencies - since weak_from_this needs our instance to be a shared_ptr before calling
|
39
|
+
// weak_from_this().
|
40
|
+
auto derivedValue = std::make_shared<RNSkDerivedValue>(_platformContext, runtime, arguments, count);
|
41
|
+
derivedValue->initializeDependencies(runtime, arguments, count);
|
42
|
+
return jsi::Object::createFromHostObject(runtime, derivedValue);
|
39
43
|
}
|
40
44
|
|
41
45
|
JSI_HOST_FUNCTION(createAnimation) {
|
@@ -32,7 +32,6 @@ public:
|
|
32
32
|
size_t count) : RNSkReadonlyValue(platformContext),
|
33
33
|
_runtime(runtime),
|
34
34
|
_identifier(identifier) {
|
35
|
-
|
36
35
|
// Start by updating to zero (start value)
|
37
36
|
update(_runtime, static_cast<double>(0));
|
38
37
|
}
|
@@ -72,6 +71,7 @@ public:
|
|
72
71
|
_start += timeSinceStop;
|
73
72
|
|
74
73
|
_state = RNSkClockState::Running;
|
74
|
+
|
75
75
|
getContext()->beginDrawLoop(_identifier, [weakSelf = weak_from_this()](bool invalidated){
|
76
76
|
auto self = weakSelf.lock();
|
77
77
|
if(self) {
|
@@ -135,7 +135,7 @@ protected:
|
|
135
135
|
size_t _identifier;
|
136
136
|
std::chrono::time_point<std::chrono::steady_clock> _start;
|
137
137
|
std::chrono::time_point<std::chrono::steady_clock> _stop;
|
138
|
-
std::atomic<RNSkClockState> _state;
|
138
|
+
std::atomic<RNSkClockState> _state = { RNSkClockState::NotStarted };
|
139
139
|
};
|
140
140
|
|
141
141
|
}
|
@@ -39,6 +39,11 @@ public:
|
|
39
39
|
jsi::detail::throwJSError(runtime, "Expected array of dependencies as second parameter");
|
40
40
|
}
|
41
41
|
|
42
|
+
// Get callback for calculating result
|
43
|
+
_callback = std::make_shared<jsi::Function>(arguments[0].asObject(runtime).asFunction(runtime));
|
44
|
+
}
|
45
|
+
|
46
|
+
void initializeDependencies(jsi::Runtime &runtime, const jsi::Value *arguments, size_t count) {
|
42
47
|
// Save dependencies
|
43
48
|
std::vector<std::shared_ptr<RNSkReadonlyValue>> dependencies;
|
44
49
|
|
@@ -59,14 +64,16 @@ public:
|
|
59
64
|
dependencies.push_back(value);
|
60
65
|
}
|
61
66
|
|
62
|
-
// Get callback for calculating result
|
63
|
-
_callback = std::make_shared<jsi::Function>(arguments[0].asObject(runtime).asFunction(runtime));
|
64
|
-
|
65
67
|
// register change handler on dependencies
|
66
68
|
_unsubscribers.reserve(_unsubscribers.size() + size);
|
67
69
|
for(const auto &dep: dependencies) {
|
68
|
-
|
69
|
-
|
70
|
+
_unsubscribers.push_back(dep->addListener([weakSelf = weak_from_this()](jsi::Runtime& runtime) {
|
71
|
+
auto self = weakSelf.lock();
|
72
|
+
if(self) {
|
73
|
+
auto selfAsThis = std::dynamic_pointer_cast<RNSkDerivedValue>(self);
|
74
|
+
selfAsThis->dependencyUpdated(runtime);
|
75
|
+
}
|
76
|
+
}));
|
70
77
|
}
|
71
78
|
|
72
79
|
// Set initial value
|