@luckylca/react-native-liquid-glass 0.2.0 → 0.3.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/README.md +20 -33
- package/README.zh-CN.md +20 -33
- package/THIRD_PARTY_NOTICES.md +1 -1
- package/android/build.gradle +4 -4
- package/android/src/main/java/expo/modules/{newhuliquidglass → liquidglass}/EffectiveScrollInputBridge.kt +2 -2
- package/android/src/main/java/expo/modules/{newhuliquidglass/ExpoGlassProviderCoreView.kt → liquidglass/GlassCaptureView.kt} +39 -39
- package/android/src/main/java/expo/modules/{newhuliquidglass/CoreLiquidGlassRegistry.kt → liquidglass/GlassRegistry.kt} +7 -7
- package/android/src/main/java/expo/modules/{newhuliquidglass/ExpoGlassSurfaceCoreView.kt → liquidglass/GlassSurfaceView.kt} +17 -17
- package/android/src/main/java/expo/modules/liquidglass/LiquidGlassModule.kt +205 -0
- package/android/src/main/java/expo/modules/{localglass/ExpoLocalGlassEngineModule.kt → liquidglass/LocalMaterialView.kt} +24 -27
- package/android/src/main/java/expo/modules/{newhuliquidglass → liquidglass}/PassSurfaceSuppression.kt +1 -1
- package/android/src/main/java/expo/modules/{newhuliquidglass → liquidglass}/SharedGlassPassProbeLog.kt +1 -1
- package/android/src/main/java/expo/modules/{newhuliquidglass → liquidglass}/SharedGlassPassWiring.kt +3 -3
- package/android-core/build.gradle +1 -1
- package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/backdrop/BackdropRecorder.kt +4 -4
- package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/backdrop/FrozenBackdrop.kt +1 -1
- package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/backdrop/GlassBackdropCoordinator.kt +5 -5
- package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/backdrop/GlassBackdropSourceHandle.kt +1 -1
- package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/backdrop/GlassScrollSource.kt +1 -1
- package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/backdrop/GlassViewController.kt +119 -722
- package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/backdrop/LiquidGlassProviderLayout.kt +2 -2
- package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/backdrop/LiquidGlassView.kt +2 -2
- package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/backdrop/ReferenceSourceWindowPolicy.kt +1 -1
- package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/backdrop/StableSceneTexturePolicy.kt +1 -1
- package/android-core/src/main/java/io/github/luckylca/liquidglass/backdrop/SurfaceFrameBuilder.kt +278 -0
- package/android-core/src/main/java/io/github/luckylca/liquidglass/backdrop/SurfaceInteraction.kt +359 -0
- package/android-core/src/main/java/io/github/luckylca/liquidglass/backdrop/internal/GlassFrame.kt +110 -0
- package/android-core/src/main/java/io/github/luckylca/liquidglass/backdrop/internal/GlassViewRenderer.kt +728 -0
- package/android-core/src/main/java/io/github/luckylca/liquidglass/backdrop/internal/ReferenceParityPasses.kt +705 -0
- package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/backdrop/internal/ReferenceTabSampling.kt +1 -1
- package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/backdrop/internal/SharedSceneCapture.kt +1 -1
- package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/core/GlassCapabilities.kt +1 -1
- package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/core/GlassEngine.kt +7 -7
- package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/core/GlassMaterial.kt +1 -1
- package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/core/GlassMath.kt +1 -1
- package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/core/GlassOpticalInsets.kt +1 -1
- package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/core/GlassRenderTier.kt +1 -1
- package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/core/GlassShapePacker.kt +1 -1
- package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/core/GlassSurfaceState.kt +1 -1
- package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/core/GlassUniforms.kt +1 -1
- package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/core/LiquidGlassShaders.kt +1 -1
- package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/core/SharedGlassPass.kt +6 -6
- package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/core/geometry/G2RoundedRectangle.kt +2 -2
- package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/core/geometry/ReferenceG2MaskTexture.kt +1 -1
- package/android-core/src/main/java/io/github/luckylca/liquidglass/core/shader/HeightFieldGlassShader.kt +7 -0
- package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/core/shader/ReferenceBackdropBlurShader.kt +1 -1
- package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/core/shader/ReferenceGaussianDiscBackdropBlur.kt +1 -1
- package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/core/shader/ReferenceGlassUniforms.kt +4 -4
- package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/core/shader/ReferenceParityGlassShader.kt +1 -1
- package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/core/shader/ReferenceParityMultiShapeShader.kt +1 -1
- package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/core/shader/SdfScaleLensShader.kt +1 -1
- package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/local/LocalGlassHardwareLayerExperiment.kt +1 -1
- package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/local/LocalGlassMaterial.kt +1 -1
- package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/local/LocalGlassRenderer.kt +2 -2
- package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/local/LocalGlassRuntimeShader.kt +2 -2
- package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/local/LocalGlassShader.kt +1 -1
- package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/local/LocalGlassView.kt +2 -2
- package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/motion/GlassMotionDriver.kt +1 -1
- package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/motion/GlassMotionState.kt +1 -1
- package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/motion/PointerVelocityTracker.kt +1 -1
- package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/motion/SpringSpec.kt +1 -1
- package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/optics/G2Corner.kt +1 -1
- package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/optics/GlassMaterial.kt +3 -3
- package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/optics/GlassOpticsShader.kt +3 -3
- package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/optics/GlassParityProbe.kt +1 -1
- package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/optics/GlassShapeGeometry.kt +1 -1
- package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/optics/GlassUniformBinder.kt +2 -2
- package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/optics/PixelDiff.kt +1 -1
- package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/optics/ReferenceOptics.kt +1 -1
- package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/rendering/GlassSurfaceHost.kt +17 -17
- package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/rendering/GlassSurfaceRenderer.kt +9 -9
- package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/rendering/RetainedBackdropLayer.kt +1 -1
- package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/scheduler/GlassFrameScheduler.kt +2 -2
- package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/telemetry/EffectiveScrollFpsProbe.kt +13 -13
- package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/telemetry/GlassTelemetry.kt +1 -1
- package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/telemetry/LiquidGlassPerfTelemetry.kt +13 -13
- package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/telemetry/LiquidGlassTrace.kt +3 -3
- package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/telemetry/LocalGlassTelemetry.kt +1 -1
- package/docs/architecture.md +61 -0
- package/docs/migration-0.3.md +19 -0
- package/docs/publishing.md +29 -7
- package/expo-module.config.json +4 -4
- package/lib/commonjs/GlassSurface.js +157 -585
- package/lib/commonjs/GlassSurface.js.map +1 -1
- package/lib/commonjs/GlassTabBar.js +18 -957
- package/lib/commonjs/GlassTabBar.js.map +1 -1
- package/lib/commonjs/LocalGlassMaterial.js +3 -9
- package/lib/commonjs/LocalGlassMaterial.js.map +1 -1
- package/lib/commonjs/glassController.js +3 -7
- package/lib/commonjs/glassController.js.map +1 -1
- package/lib/commonjs/glassRuntime.js +7 -19
- package/lib/commonjs/glassRuntime.js.map +1 -1
- package/lib/commonjs/localGlassTelemetry.js +4 -13
- package/lib/commonjs/localGlassTelemetry.js.map +1 -1
- package/lib/commonjs/nativeGlassViews.js +8 -11
- package/lib/commonjs/nativeGlassViews.js.map +1 -1
- package/lib/commonjs/performanceTelemetry.js +2 -6
- package/lib/commonjs/performanceTelemetry.js.map +1 -1
- package/lib/commonjs/surface/InlineSurface.js +134 -0
- package/lib/commonjs/surface/InlineSurface.js.map +1 -0
- package/lib/commonjs/surface/MaterialProvider.js +78 -0
- package/lib/commonjs/surface/MaterialProvider.js.map +1 -0
- package/lib/commonjs/surface/NativeSurface.js +55 -0
- package/lib/commonjs/surface/NativeSurface.js.map +1 -0
- package/lib/commonjs/surface/PortalLayers.js +331 -0
- package/lib/commonjs/surface/PortalLayers.js.map +1 -0
- package/lib/commonjs/surface/contexts.js +108 -0
- package/lib/commonjs/surface/contexts.js.map +1 -0
- package/lib/commonjs/surface/registry.js +113 -0
- package/lib/commonjs/surface/registry.js.map +1 -0
- package/lib/commonjs/surface/styles.js +34 -0
- package/lib/commonjs/surface/styles.js.map +1 -0
- package/lib/commonjs/surface/types.js +3 -0
- package/lib/commonjs/surface/types.js.map +1 -0
- package/lib/commonjs/tabs/GlassTabItem.js +66 -0
- package/lib/commonjs/tabs/GlassTabItem.js.map +1 -0
- package/lib/commonjs/tabs/InlineTabBar.js +867 -0
- package/lib/commonjs/tabs/InlineTabBar.js.map +1 -0
- package/lib/commonjs/tabs/tabConstants.js +22 -0
- package/lib/commonjs/tabs/tabConstants.js.map +1 -0
- package/lib/commonjs/tabs/tabDebug.js +50 -0
- package/lib/commonjs/tabs/tabDebug.js.map +1 -0
- package/lib/commonjs/tabs/tabStyles.js +107 -0
- package/lib/commonjs/tabs/tabStyles.js.map +1 -0
- package/lib/commonjs/tabs/useInlineTabGesture.js +227 -0
- package/lib/commonjs/tabs/useInlineTabGesture.js.map +1 -0
- package/lib/commonjs/theme/buildTheme.js +1 -1
- package/lib/commonjs/theme/buildTheme.js.map +1 -1
- package/lib/module/GlassSurface.js +135 -563
- package/lib/module/GlassSurface.js.map +1 -1
- package/lib/module/GlassTabBar.js +18 -925
- package/lib/module/GlassTabBar.js.map +1 -1
- package/lib/module/LocalGlassMaterial.js +5 -11
- package/lib/module/LocalGlassMaterial.js.map +1 -1
- package/lib/module/glassController.js +3 -7
- package/lib/module/glassController.js.map +1 -1
- package/lib/module/glassRuntime.js +7 -19
- package/lib/module/glassRuntime.js.map +1 -1
- package/lib/module/localGlassTelemetry.js +4 -13
- package/lib/module/localGlassTelemetry.js.map +1 -1
- package/lib/module/nativeGlassViews.js +7 -10
- package/lib/module/nativeGlassViews.js.map +1 -1
- package/lib/module/performanceTelemetry.js +2 -6
- package/lib/module/performanceTelemetry.js.map +1 -1
- package/lib/module/surface/InlineSurface.js +97 -0
- package/lib/module/surface/InlineSurface.js.map +1 -0
- package/lib/module/surface/MaterialProvider.js +74 -0
- package/lib/module/surface/MaterialProvider.js.map +1 -0
- package/lib/module/surface/NativeSurface.js +47 -0
- package/lib/module/surface/NativeSurface.js.map +1 -0
- package/lib/module/surface/PortalLayers.js +292 -0
- package/lib/module/surface/PortalLayers.js.map +1 -0
- package/lib/module/surface/contexts.js +96 -0
- package/lib/module/surface/contexts.js.map +1 -0
- package/lib/module/surface/registry.js +103 -0
- package/lib/module/surface/registry.js.map +1 -0
- package/lib/module/surface/styles.js +31 -0
- package/lib/module/surface/styles.js.map +1 -0
- package/lib/module/surface/types.js +2 -0
- package/lib/module/surface/types.js.map +1 -0
- package/lib/module/tabs/GlassTabItem.js +30 -0
- package/lib/module/tabs/GlassTabItem.js.map +1 -0
- package/lib/module/tabs/InlineTabBar.js +829 -0
- package/lib/module/tabs/InlineTabBar.js.map +1 -0
- package/lib/module/tabs/tabConstants.js +19 -0
- package/lib/module/tabs/tabConstants.js.map +1 -0
- package/lib/module/tabs/tabDebug.js +13 -0
- package/lib/module/tabs/tabDebug.js.map +1 -0
- package/lib/module/tabs/tabStyles.js +104 -0
- package/lib/module/tabs/tabStyles.js.map +1 -0
- package/lib/module/tabs/useInlineTabGesture.js +221 -0
- package/lib/module/tabs/useInlineTabGesture.js.map +1 -0
- package/lib/module/theme/buildTheme.js +1 -1
- package/lib/module/theme/buildTheme.js.map +1 -1
- package/lib/types/GlassSurface.d.ts +17 -86
- package/lib/types/GlassTabBar.d.ts +1 -0
- package/lib/types/glassNativeEngine.d.ts +1 -1
- package/lib/types/glassRuntime.d.ts +5 -2
- package/lib/types/localGlassTelemetry.d.ts +2 -2
- package/lib/types/nativeGlassViews.d.ts +2 -4
- package/lib/types/surface/InlineSurface.d.ts +42 -0
- package/lib/types/surface/MaterialProvider.d.ts +46 -0
- package/lib/types/surface/NativeSurface.d.ts +11 -0
- package/lib/types/surface/PortalLayers.d.ts +33 -0
- package/lib/types/surface/contexts.d.ts +66 -0
- package/lib/types/surface/registry.d.ts +6 -0
- package/lib/types/surface/styles.d.ts +74 -0
- package/lib/types/surface/types.d.ts +118 -0
- package/lib/types/tabs/GlassTabItem.d.ts +20 -0
- package/lib/types/tabs/InlineTabBar.d.ts +5 -0
- package/lib/types/tabs/tabConstants.d.ts +34 -0
- package/lib/types/tabs/tabDebug.d.ts +15 -0
- package/lib/types/tabs/tabStyles.d.ts +119 -0
- package/lib/types/tabs/useInlineTabGesture.d.ts +34 -0
- package/package.json +6 -14
- package/src/GlassSurface.tsx +227 -1337
- package/src/GlassTabBar.tsx +43 -1241
- package/src/LocalGlassMaterial.tsx +5 -11
- package/src/glassController.ts +3 -7
- package/src/glassRuntime.ts +9 -26
- package/src/localGlassTelemetry.ts +6 -15
- package/src/nativeGlassViews.ts +7 -10
- package/src/performanceTelemetry.ts +2 -6
- package/src/surface/InlineSurface.tsx +299 -0
- package/src/surface/MaterialProvider.tsx +235 -0
- package/src/surface/NativeSurface.tsx +115 -0
- package/src/surface/PortalLayers.tsx +574 -0
- package/src/surface/contexts.tsx +188 -0
- package/src/surface/registry.ts +109 -0
- package/src/surface/styles.ts +31 -0
- package/src/surface/types.ts +139 -0
- package/src/tabs/GlassTabItem.tsx +100 -0
- package/src/tabs/InlineTabBar.tsx +1193 -0
- package/src/tabs/tabConstants.ts +35 -0
- package/src/tabs/tabDebug.ts +29 -0
- package/src/tabs/tabStyles.ts +104 -0
- package/src/tabs/useInlineTabGesture.ts +306 -0
- package/src/theme/buildTheme.ts +1 -1
- package/android/src/main/java/expo/modules/localglass/ExpoLocalGlassModule.kt +0 -341
- package/android/src/main/java/expo/modules/localglass/LocalGlassShader.kt +0 -59
- package/android/src/main/java/expo/modules/newhuliquidglass/ExpoGlassCoreModule.kt +0 -226
- package/android-core/src/main/java/com/newhu/liquidglass/backdrop/internal/GlassViewRenderer.kt +0 -1459
- package/android-core/src/main/java/com/newhu/liquidglass/core/shader/HeightFieldGlassShader.kt +0 -7
- package/android-core/src/main/java/com/newhu/liquidglass/rendering/GlassEngineSelection.kt +0 -30
- package/patches/liquid-glass-kit+1.0.0.patch +0 -2015
- package/patches/liquid-glass-kit-invalidation-coalescing.diff +0 -249
- package/patches/liquid-glass-kit-native-infra.diff +0 -624
- package/scripts/apply-legacy-patches.mjs +0 -116
|
@@ -1,2015 +0,0 @@
|
|
|
1
|
-
diff --git a/node_modules/liquid-glass-kit/android/src/main/java/dev/liquidglass/core/GlassUniforms.kt b/node_modules/liquid-glass-kit/android/src/main/java/dev/liquidglass/core/GlassUniforms.kt
|
|
2
|
-
index 2d487bc..2919d37 100644
|
|
3
|
-
--- a/node_modules/liquid-glass-kit/android/src/main/java/dev/liquidglass/core/GlassUniforms.kt
|
|
4
|
-
+++ b/node_modules/liquid-glass-kit/android/src/main/java/dev/liquidglass/core/GlassUniforms.kt
|
|
5
|
-
@@ -37,12 +37,21 @@ public object GlassUniforms {
|
|
6
|
-
/** Peak refraction displacement (px). Positive bends inward, negative outward. */
|
|
7
|
-
public const val REFRACTION_AMOUNT: String = "refractionAmount"
|
|
8
|
-
|
|
9
|
-
+ /** Broad rounded-rect coordinate remapping across the full lens body (px). */
|
|
10
|
-
+ public const val BODY_REFRACTION_AMOUNT: String = "bodyRefractionAmount"
|
|
11
|
-
+
|
|
12
|
-
+ /** 0..1 morph from the quiet idle glass to the pressed/dragged glass. */
|
|
13
|
-
+ public const val INTERACTION_PROGRESS: String = "interactionProgress"
|
|
14
|
-
+
|
|
15
|
-
/** 0..1 dispersion strength; splits RGB along the refraction direction. */
|
|
16
|
-
public const val CHROMATIC_ABERRATION: String = "chromaticAberration"
|
|
17
|
-
|
|
18
|
-
/** `float4` straight (non-premultiplied) RGBA tint; alpha is blend strength. */
|
|
19
|
-
public const val TINT: String = "tint"
|
|
20
|
-
|
|
21
|
-
+ /** Per-material multiplier for the tint alpha. */
|
|
22
|
-
+ public const val TINT_ALPHA: String = "tintAlpha"
|
|
23
|
-
+
|
|
24
|
-
/** Strength of the banding-prevention grain, typically 0.0..0.05. */
|
|
25
|
-
public const val NOISE_ALPHA: String = "noiseAlpha"
|
|
26
|
-
|
|
27
|
-
@@ -52,6 +61,15 @@ public object GlassUniforms {
|
|
28
|
-
/** 0..1 intensity of the specular rim highlight. */
|
|
29
|
-
public const val HIGHLIGHT_ALPHA: String = "highlightAlpha"
|
|
30
|
-
|
|
31
|
-
+ /** Strength of the computed 3D specular highlight. */
|
|
32
|
-
+ public const val SPECULAR_STRENGTH: String = "specularStrength"
|
|
33
|
-
+
|
|
34
|
-
+ /** Strength of the view-angle Fresnel edge reflection. */
|
|
35
|
-
+ public const val FRESNEL_STRENGTH: String = "fresnelStrength"
|
|
36
|
-
+
|
|
37
|
-
+ /** Strength of the narrow compression shade inside the glass rim. */
|
|
38
|
-
+ public const val INNER_SHADOW_STRENGTH: String = "innerShadowStrength"
|
|
39
|
-
+
|
|
40
|
-
/** Thickness (px) of the specular rim band. */
|
|
41
|
-
public const val HIGHLIGHT_WIDTH: String = "highlightWidth"
|
|
42
|
-
|
|
43
|
-
@@ -61,6 +79,12 @@ public object GlassUniforms {
|
|
44
|
-
/** `float2` press location in shader-local pixels. */
|
|
45
|
-
public const val PRESS_POINT: String = "pressPoint"
|
|
46
|
-
|
|
47
|
-
+ /** Normalized screen-space lens velocity, used for subtle shear and light response. */
|
|
48
|
-
+ public const val MOTION: String = "motion"
|
|
49
|
-
+
|
|
50
|
-
+ /** Render only the re-sampled backdrop; suppress tint, dispersion and lighting. */
|
|
51
|
-
+ public const val DISPLACEMENT_ONLY: String = "displacementOnly"
|
|
52
|
-
+
|
|
53
|
-
/** Every scalar/vector uniform name (everything except [CONTENT]). */
|
|
54
|
-
public val ALL_FLOAT_UNIFORMS: List<String> = listOf(
|
|
55
|
-
SHAPES,
|
|
56
|
-
@@ -68,13 +92,21 @@ public object GlassUniforms {
|
|
57
|
-
MERGE_SMOOTHING,
|
|
58
|
-
REFRACTION_HEIGHT,
|
|
59
|
-
REFRACTION_AMOUNT,
|
|
60
|
-
+ BODY_REFRACTION_AMOUNT,
|
|
61
|
-
+ INTERACTION_PROGRESS,
|
|
62
|
-
CHROMATIC_ABERRATION,
|
|
63
|
-
TINT,
|
|
64
|
-
+ TINT_ALPHA,
|
|
65
|
-
NOISE_ALPHA,
|
|
66
|
-
LIGHT_DIRECTION,
|
|
67
|
-
HIGHLIGHT_ALPHA,
|
|
68
|
-
+ SPECULAR_STRENGTH,
|
|
69
|
-
+ FRESNEL_STRENGTH,
|
|
70
|
-
+ INNER_SHADOW_STRENGTH,
|
|
71
|
-
HIGHLIGHT_WIDTH,
|
|
72
|
-
PRESS_AMOUNT,
|
|
73
|
-
PRESS_POINT,
|
|
74
|
-
+ MOTION,
|
|
75
|
-
+ DISPLACEMENT_ONLY,
|
|
76
|
-
)
|
|
77
|
-
}
|
|
78
|
-
diff --git a/node_modules/liquid-glass-kit/android/src/main/java/dev/liquidglass/core/LiquidGlassShaders.kt b/node_modules/liquid-glass-kit/android/src/main/java/dev/liquidglass/core/LiquidGlassShaders.kt
|
|
79
|
-
index aa67cdf..0fc1e9b 100644
|
|
80
|
-
--- a/node_modules/liquid-glass-kit/android/src/main/java/dev/liquidglass/core/LiquidGlassShaders.kt
|
|
81
|
-
+++ b/node_modules/liquid-glass-kit/android/src/main/java/dev/liquidglass/core/LiquidGlassShaders.kt
|
|
82
|
-
@@ -9,13 +9,12 @@ package dev.liquidglass.core
|
|
83
|
-
* 1. **Scene SDF** — smooth union (polynomial smooth-min) of up to
|
|
84
|
-
* [GlassUniforms.MAX_SHAPES] rounded rectangles, which is what lets nearby
|
|
85
|
-
* glass elements melt into one liquid form.
|
|
86
|
-
- * 2. **Edge refraction** — a circular lens profile along the rim displaces the
|
|
87
|
-
- * backdrop sample toward the shape center, bending the world the way a convex
|
|
88
|
-
- * glass slab does.
|
|
89
|
-
- * 3. **Gel press** — a Gaussian bulge around the touch point.
|
|
90
|
-
- * 4. **Chromatic aberration** — optional RGB dispersion along the lens normal.
|
|
91
|
-
- * 5. **Tint, specular rim, grain** — surface color, a thin angle-dependent rim
|
|
92
|
-
- * light, and dither noise that prevents gradient banding.
|
|
93
|
-
+ * 2. **Optical height profile** — derives a continuous convex profile from the
|
|
94
|
-
+ * rounded-rectangle SDF, then estimates its surface normal.
|
|
95
|
-
+ * 3. **Backdrop remapping** — bends source coordinates across the body and
|
|
96
|
-
+ * strengthens the displacement toward the rim (SDF -> field -> resampling).
|
|
97
|
-
+ * 4. **Chromatic aberration** — separate backdrop samples for R, G and B.
|
|
98
|
-
+ * 5. **Fresnel/specular/inner rim** — lighting is secondary to the sampled image.
|
|
99
|
-
*
|
|
100
|
-
* Every formula has a Kotlin twin in [GlassMath]; keep them in lockstep.
|
|
101
|
-
*
|
|
102
|
-
@@ -35,20 +34,37 @@ uniform float ${GlassUniforms.SHAPE_RADII}[$MAX_SHAPES];
|
|
103
|
-
uniform float ${GlassUniforms.MERGE_SMOOTHING};
|
|
104
|
-
uniform float ${GlassUniforms.REFRACTION_HEIGHT};
|
|
105
|
-
uniform float ${GlassUniforms.REFRACTION_AMOUNT};
|
|
106
|
-
+uniform float ${GlassUniforms.BODY_REFRACTION_AMOUNT};
|
|
107
|
-
+uniform float ${GlassUniforms.INTERACTION_PROGRESS};
|
|
108
|
-
uniform float ${GlassUniforms.CHROMATIC_ABERRATION};
|
|
109
|
-
uniform float4 ${GlassUniforms.TINT};
|
|
110
|
-
+uniform float ${GlassUniforms.TINT_ALPHA};
|
|
111
|
-
uniform float ${GlassUniforms.NOISE_ALPHA};
|
|
112
|
-
uniform float2 ${GlassUniforms.LIGHT_DIRECTION};
|
|
113
|
-
uniform float ${GlassUniforms.HIGHLIGHT_ALPHA};
|
|
114
|
-
+uniform float ${GlassUniforms.SPECULAR_STRENGTH};
|
|
115
|
-
+uniform float ${GlassUniforms.FRESNEL_STRENGTH};
|
|
116
|
-
+uniform float ${GlassUniforms.INNER_SHADOW_STRENGTH};
|
|
117
|
-
uniform float ${GlassUniforms.HIGHLIGHT_WIDTH};
|
|
118
|
-
uniform float ${GlassUniforms.PRESS_AMOUNT};
|
|
119
|
-
uniform float2 ${GlassUniforms.PRESS_POINT};
|
|
120
|
-
+uniform float2 ${GlassUniforms.MOTION};
|
|
121
|
-
+uniform float ${GlassUniforms.DISPLACEMENT_ONLY};
|
|
122
|
-
|
|
123
|
-
float sdRoundedBox(float2 p, float2 halfSize, float radius) {
|
|
124
|
-
float2 q = abs(p) - halfSize + radius;
|
|
125
|
-
return min(max(q.x, q.y), 0.0) + length(max(q, float2(0.0))) - radius;
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
+float2 roundedBoxNormal(float2 p, float2 halfSize, float radius) {
|
|
129
|
-
+ float2 q = abs(p) - halfSize + radius;
|
|
130
|
-
+ float2 outside = max(q, float2(0.0));
|
|
131
|
-
+ float2 gradient = length(outside) > 0.0001
|
|
132
|
-
+ ? normalize(outside)
|
|
133
|
-
+ : (q.x > q.y ? float2(1.0, 0.0) : float2(0.0, 1.0));
|
|
134
|
-
+ return sign(p) * gradient;
|
|
135
|
-
+}
|
|
136
|
-
+
|
|
137
|
-
float smin(float a, float b, float k) {
|
|
138
|
-
float kk = max(k, 0.0001);
|
|
139
|
-
float h = clamp(0.5 + 0.5 * (b - a) / kk, 0.0, 1.0);
|
|
140
|
-
@@ -65,15 +81,34 @@ float sceneSd(float2 p) {
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
float2 sceneNormal(float2 p) {
|
|
144
|
-
- float2 e = float2(1.0, 0.0);
|
|
145
|
-
- float gx = sceneSd(p + e.xy) - sceneSd(p - e.xy);
|
|
146
|
-
- float gy = sceneSd(p + e.yx) - sceneSd(p - e.yx);
|
|
147
|
-
- float2 g = float2(gx, gy);
|
|
148
|
-
- float len = length(g);
|
|
149
|
-
+ float d = 1000000.0;
|
|
150
|
-
+ float2 gradient = float2(0.0);
|
|
151
|
-
+ for (int i = 0; i < $MAX_SHAPES; i++) {
|
|
152
|
-
+ float4 s = ${GlassUniforms.SHAPES}[i];
|
|
153
|
-
+ float shapeDistance = sdRoundedBox(p - s.xy, s.zw, ${GlassUniforms.SHAPE_RADII}[i]);
|
|
154
|
-
+ float2 shapeGradient = roundedBoxNormal(p - s.xy, s.zw, ${GlassUniforms.SHAPE_RADII}[i]);
|
|
155
|
-
+ float k = max(${GlassUniforms.MERGE_SMOOTHING}, 0.0001);
|
|
156
|
-
+ float h = clamp(0.5 + 0.5 * (shapeDistance - d) / k, 0.0, 1.0);
|
|
157
|
-
+ gradient = mix(shapeGradient, gradient, h);
|
|
158
|
-
+ d = mix(shapeDistance, d, h) - k * h * (1.0 - h);
|
|
159
|
-
+ }
|
|
160
|
-
+ float len = length(gradient);
|
|
161
|
-
if (len < 0.0001) {
|
|
162
|
-
return float2(0.0);
|
|
163
|
-
}
|
|
164
|
-
- return g / len;
|
|
165
|
-
+ return gradient / len;
|
|
166
|
-
+}
|
|
167
|
-
+
|
|
168
|
-
+// Convex lens height field derived from the rounded-rect SDF. The center is
|
|
169
|
-
+// nearly flat; the slope increases toward the rim, creating a continuous
|
|
170
|
-
+// surface normal across the glass body rather than a detached edge ring.
|
|
171
|
-
+float3 lensSurfaceNormal(float sdf, float2 sdfNormal, float2 halfSize) {
|
|
172
|
-
+ float depthRange = max(min(halfSize.x, halfSize.y), 1.0);
|
|
173
|
-
+ float edgeDepth = clamp(-sdf, 0.0, depthRange);
|
|
174
|
-
+ float inward = 1.0 - edgeDepth / depthRange;
|
|
175
|
-
+ float height = sqrt(max(1.0 - inward * inward, 0.0025));
|
|
176
|
-
+ float slope = clamp(inward / height, 0.0, 3.4);
|
|
177
|
-
+ return normalize(float3(sdfNormal * slope, 1.0));
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
half4 main(float2 fragCoord) {
|
|
181
|
-
@@ -84,16 +119,45 @@ half4 main(float2 fragCoord) {
|
|
182
|
-
return half4(0.0);
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
- float2 normal = sceneNormal(p);
|
|
186
|
-
+ // The first packed shape is the lens. The tab lens is a single rounded
|
|
187
|
-
+ // rectangle, while the scene SDF still supports merged shapes elsewhere.
|
|
188
|
-
+ float4 lensShape = ${GlassUniforms.SHAPES}[0];
|
|
189
|
-
+ float2 lensCenter = lensShape.xy;
|
|
190
|
-
+ float2 lensHalfSize = max(lensShape.zw, float2(1.0));
|
|
191
|
-
+ float2 sdfNormal = sceneNormal(p);
|
|
192
|
-
+ float3 surfaceNormal = lensSurfaceNormal(sd, sdfNormal, lensHalfSize);
|
|
193
|
-
float edgeDist = max(-sd, 0.0);
|
|
194
|
-
|
|
195
|
-
- float lens = 0.0;
|
|
196
|
-
- float2 sampleCoord = p;
|
|
197
|
-
- if (edgeDist < ${GlassUniforms.REFRACTION_HEIGHT}) {
|
|
198
|
-
- float x = 1.0 - edgeDist / max(${GlassUniforms.REFRACTION_HEIGHT}, 0.0001);
|
|
199
|
-
- lens = 1.0 - sqrt(max(1.0 - x * x, 0.0));
|
|
200
|
-
- sampleCoord = p - normal * (${GlassUniforms.REFRACTION_AMOUNT} * lens);
|
|
201
|
-
- }
|
|
202
|
-
+ // Full-body nonlinear remapping: the local coordinates expand gently
|
|
203
|
-
+ // through the lens, then the SDF height-field normal adds stronger
|
|
204
|
-
+ // displacement toward the rounded edge (SDF -> profile -> resampling).
|
|
205
|
-
+ float2 local = p - lensCenter;
|
|
206
|
-
+ float2 normalizedLocal = local / lensHalfSize;
|
|
207
|
-
+ float radial = clamp(max(abs(normalizedLocal.x), abs(normalizedLocal.y)), 0.0, 1.0);
|
|
208
|
-
+ float bodyProfile = 0.28 + 0.72 * pow(radial, 0.72);
|
|
209
|
-
+ float progress = clamp(${GlassUniforms.INTERACTION_PROGRESS}, 0.0, 1.0);
|
|
210
|
-
+ float motionSpeed = min(length(${GlassUniforms.MOTION}), 1.0);
|
|
211
|
-
+ float bodyAmount = ${GlassUniforms.BODY_REFRACTION_AMOUNT} * (1.0 + progress * 0.35);
|
|
212
|
-
+ float edgeReach = clamp(
|
|
213
|
-
+ ${GlassUniforms.REFRACTION_HEIGHT},
|
|
214
|
-
+ 2.0,
|
|
215
|
-
+ min(lensHalfSize.x, lensHalfSize.y) * 0.72
|
|
216
|
-
+ );
|
|
217
|
-
+ // Make the remap meet the untouched scene at the silhouette, rise through
|
|
218
|
-
+ // the first few pixels, and fade before the flat center. The old step was
|
|
219
|
-
+ // full-strength at sdf=0, so the backdrop jumped by a whole offset exactly
|
|
220
|
-
+ // where the mask ended (most visible as torn corner wedges on checker grids).
|
|
221
|
-
+ float edgeEntry = max(min(edgeReach * 0.16, 4.0), 1.0);
|
|
222
|
-
+ float edgeField = smoothstep(0.0, edgeEntry, edgeDist)
|
|
223
|
-
+ * (1.0 - smoothstep(edgeReach * 0.82, edgeReach * 1.42, edgeDist));
|
|
224
|
-
+ float bodyBoundaryFade = smoothstep(0.0, max(bodyAmount * 0.8, 2.0), edgeDist);
|
|
225
|
-
+ float dynamicEdgeAmount = ${GlassUniforms.REFRACTION_AMOUNT} * (1.0 + progress * 0.3 + motionSpeed * progress * 0.08);
|
|
226
|
-
+ float2 bodyWarp = normalizedLocal * (bodyAmount * bodyProfile * bodyBoundaryFade);
|
|
227
|
-
+ float2 edgeWarp = surfaceNormal.xy * (dynamicEdgeAmount * edgeField);
|
|
228
|
-
+ float2 motionShear = float2(-${GlassUniforms.MOTION}.x, ${GlassUniforms.MOTION}.y)
|
|
229
|
-
+ * (bodyAmount * (0.18 + edgeField * 0.24) * progress * bodyBoundaryFade);
|
|
230
|
-
+ float2 displacement = bodyWarp + edgeWarp - motionShear;
|
|
231
|
-
+ float2 sampleCoord = p - displacement;
|
|
232
|
-
|
|
233
|
-
if (${GlassUniforms.PRESS_AMOUNT} > 0.001) {
|
|
234
|
-
float2 toPress = p - ${GlassUniforms.PRESS_POINT};
|
|
235
|
-
@@ -101,10 +165,25 @@ half4 main(float2 fragCoord) {
|
|
236
|
-
sampleCoord -= toPress * (${GlassUniforms.PRESS_AMOUNT} * 0.08 * falloff);
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
- float caShift = ${GlassUniforms.CHROMATIC_ABERRATION} * lens * abs(${GlassUniforms.REFRACTION_AMOUNT}) * 0.12;
|
|
240
|
-
+ // Debug mode shows only one un-tinted backdrop sample. It intentionally
|
|
241
|
-
+ // skips chromatic separation too, so this view isolates displacement alone.
|
|
242
|
-
+ if (${GlassUniforms.DISPLACEMENT_ONLY} > 0.5) {
|
|
243
|
-
+ float4 displacedBackdrop = float4(${GlassUniforms.CONTENT}.eval(sampleCoord));
|
|
244
|
-
+ return half4(displacedBackdrop.rgb * mask, displacedBackdrop.a * mask);
|
|
245
|
-
+ }
|
|
246
|
-
+
|
|
247
|
-
+ float curvature = clamp(1.0 - surfaceNormal.z, 0.0, 1.0);
|
|
248
|
-
+ float dispersionField = clamp(edgeField * 0.72 + curvature * 0.28, 0.0, 1.0);
|
|
249
|
-
+ float caShift = ${GlassUniforms.CHROMATIC_ABERRATION}
|
|
250
|
-
+ * (1.0 + progress * 0.65 + motionSpeed * progress * 0.2)
|
|
251
|
-
+ * dispersionField
|
|
252
|
-
+ * (${GlassUniforms.REFRACTION_HEIGHT} * 0.12 + ${GlassUniforms.BODY_REFRACTION_AMOUNT} * 0.08);
|
|
253
|
-
float4 color;
|
|
254
|
-
if (caShift > 0.001) {
|
|
255
|
-
- float2 caOffset = normal * caShift;
|
|
256
|
-
+ float2 caDirection = length(displacement) > 0.001
|
|
257
|
-
+ ? normalize(displacement)
|
|
258
|
-
+ : sdfNormal;
|
|
259
|
-
+ float2 caOffset = caDirection * caShift;
|
|
260
|
-
float cr = float4(${GlassUniforms.CONTENT}.eval(sampleCoord - caOffset)).r;
|
|
261
|
-
float4 cg = float4(${GlassUniforms.CONTENT}.eval(sampleCoord));
|
|
262
|
-
float cb = float4(${GlassUniforms.CONTENT}.eval(sampleCoord + caOffset)).b;
|
|
263
|
-
@@ -113,12 +192,36 @@ half4 main(float2 fragCoord) {
|
|
264
|
-
color = float4(${GlassUniforms.CONTENT}.eval(sampleCoord));
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
- color.rgb = mix(color.rgb, ${GlassUniforms.TINT}.rgb, ${GlassUniforms.TINT}.a);
|
|
268
|
-
+ float tintAmount = clamp(${GlassUniforms.TINT}.a * ${GlassUniforms.TINT_ALPHA}, 0.0, 1.0);
|
|
269
|
-
+ color.rgb = mix(color.rgb, ${GlassUniforms.TINT}.rgb, tintAmount);
|
|
270
|
-
|
|
271
|
-
float rim = 1.0 - smoothstep(0.0, max(${GlassUniforms.HIGHLIGHT_WIDTH}, 0.0001), edgeDist);
|
|
272
|
-
- float facing = pow(abs(dot(normal, ${GlassUniforms.LIGHT_DIRECTION})), 1.5);
|
|
273
|
-
- float pressBoost = 1.0 + ${GlassUniforms.PRESS_AMOUNT} * 0.6;
|
|
274
|
-
- color.rgb += float3(rim * facing * ${GlassUniforms.HIGHLIGHT_ALPHA} * pressBoost);
|
|
275
|
-
+ float2 reflectedLight = normalize(${GlassUniforms.LIGHT_DIRECTION} - ${GlassUniforms.MOTION} * 0.12);
|
|
276
|
-
+ float3 lightDirection = normalize(float3(reflectedLight, 0.82));
|
|
277
|
-
+ float3 viewDirection = float3(0.0, 0.0, 1.0);
|
|
278
|
-
+ float3 halfDirection = normalize(lightDirection + viewDirection);
|
|
279
|
-
+ float cornerRadius = ${GlassUniforms.SHAPE_RADII}[0];
|
|
280
|
-
+ float2 cornerCoordinates = abs(local) - (lensHalfSize - cornerRadius);
|
|
281
|
-
+ float cornerArc = smoothstep(0.0, max(cornerRadius * 0.35, 1.0), min(cornerCoordinates.x, cornerCoordinates.y));
|
|
282
|
-
+ // Rounded corners catch a point-like glint; flat edges keep only a faint
|
|
283
|
-
+ // Fresnel rim so the specular lobe cannot become a full-width white bar.
|
|
284
|
-
+ float specularEdgeMask = mix(0.05, 1.0, cornerArc);
|
|
285
|
-
+ float specularPower = mix(48.0, 28.0, progress);
|
|
286
|
-
+ float specular = pow(max(dot(surfaceNormal, halfDirection), 0.0), specularPower)
|
|
287
|
-
+ * ${GlassUniforms.HIGHLIGHT_ALPHA}
|
|
288
|
-
+ * ${GlassUniforms.SPECULAR_STRENGTH}
|
|
289
|
-
+ * (1.0 + ${GlassUniforms.PRESS_AMOUNT} * 0.35)
|
|
290
|
-
+ * specularEdgeMask;
|
|
291
|
-
+ float fresnel = pow(clamp(1.0 - surfaceNormal.z, 0.0, 1.0), 5.0)
|
|
292
|
-
+ * ${GlassUniforms.FRESNEL_STRENGTH}
|
|
293
|
-
+ * (1.0 + progress * 0.28);
|
|
294
|
-
+ float innerBandCenter = max(${GlassUniforms.HIGHLIGHT_WIDTH} * 1.65, 2.0);
|
|
295
|
-
+ float innerBand = exp(-pow((edgeDist - innerBandCenter) / max(${GlassUniforms.HIGHLIGHT_WIDTH} * 1.25, 1.0), 2.0))
|
|
296
|
-
+ * ${GlassUniforms.INNER_SHADOW_STRENGTH};
|
|
297
|
-
+ float pressBoost = 1.0 + ${GlassUniforms.PRESS_AMOUNT} * 0.35;
|
|
298
|
-
+ color.rgb += float3(specular + rim * fresnel * 0.22 * pressBoost);
|
|
299
|
-
+ color.rgb += float3(fresnel * 0.12);
|
|
300
|
-
+ color.rgb *= 1.0 - innerBand * (0.28 + progress * 0.08);
|
|
301
|
-
|
|
302
|
-
float noise = fract(sin(dot(p, float2(12.9898, 78.233))) * 43758.5453) - 0.5;
|
|
303
|
-
color.rgb += float3(noise * ${GlassUniforms.NOISE_ALPHA});
|
|
304
|
-
diff --git a/node_modules/liquid-glass-kit/android/src/main/java/dev/liquidglass/view/BackdropRecorder.kt b/node_modules/liquid-glass-kit/android/src/main/java/dev/liquidglass/view/BackdropRecorder.kt
|
|
305
|
-
index ca69095..c19263c 100644
|
|
306
|
-
--- a/node_modules/liquid-glass-kit/android/src/main/java/dev/liquidglass/view/BackdropRecorder.kt
|
|
307
|
-
+++ b/node_modules/liquid-glass-kit/android/src/main/java/dev/liquidglass/view/BackdropRecorder.kt
|
|
308
|
-
@@ -1,6 +1,7 @@
|
|
309
|
-
package dev.liquidglass.view
|
|
310
|
-
|
|
311
|
-
import android.graphics.Canvas
|
|
312
|
-
+import android.graphics.Rect
|
|
313
|
-
import android.graphics.RenderNode
|
|
314
|
-
import android.os.Build
|
|
315
|
-
import android.view.View
|
|
316
|
-
@@ -27,9 +28,27 @@ public interface LiquidGlassBackdropSource {
|
|
317
|
-
/** True once a hardware recording of the backdrop exists. */
|
|
318
|
-
public val hasRecording: Boolean
|
|
319
|
-
|
|
320
|
-
+ /** Crop origin of the current recording in source-view-local pixels. */
|
|
321
|
-
+ public val recordedOriginX: Int
|
|
322
|
-
+ get() = 0
|
|
323
|
-
+ public val recordedOriginY: Int
|
|
324
|
-
+ get() = 0
|
|
325
|
-
+
|
|
326
|
-
public fun registerConsumer(consumer: View)
|
|
327
|
-
|
|
328
|
-
public fun unregisterConsumer(consumer: View)
|
|
329
|
-
+
|
|
330
|
-
+ /** Ask the provider to refresh on the next display frame. */
|
|
331
|
-
+ public fun requestCaptureFrame() {}
|
|
332
|
-
+
|
|
333
|
-
+ /** Whether moving a glass consumer requires a new backdrop recording. */
|
|
334
|
-
+ public val requiresCaptureOnConsumerMovement: Boolean
|
|
335
|
-
+ get() = true
|
|
336
|
-
+
|
|
337
|
-
+ /** Called when sampling geometry moves; full-scene providers can keep the current recording. */
|
|
338
|
-
+ public fun onConsumerGeometryChanged(consumer: View) {
|
|
339
|
-
+ if (requiresCaptureOnConsumerMovement) requestCaptureFrame()
|
|
340
|
-
+ }
|
|
341
|
-
}
|
|
342
|
-
|
|
343
|
-
/**
|
|
344
|
-
@@ -43,6 +62,11 @@ public interface LiquidGlassBackdropSource {
|
|
345
|
-
public class BackdropRecorder {
|
|
346
|
-
|
|
347
|
-
private val consumers = CopyOnWriteArrayList<View>()
|
|
348
|
-
+ // Reused scratch objects: capture runs on the UI thread and may execute every
|
|
349
|
-
+ // display frame, so avoid coordinate-array/Rect allocation per consumer.
|
|
350
|
-
+ private val clampedCaptureBounds = Rect()
|
|
351
|
-
+ public val hasConsumers: Boolean
|
|
352
|
-
+ get() = consumers.isNotEmpty()
|
|
353
|
-
|
|
354
|
-
/** The live recording, exposed through [LiquidGlassBackdropSource]. */
|
|
355
|
-
public var contentNode: RenderNode? = null
|
|
356
|
-
@@ -51,14 +75,105 @@ public class BackdropRecorder {
|
|
357
|
-
public val hasRecording: Boolean
|
|
358
|
-
get() = Build.VERSION.SDK_INT >= 29 && contentNode?.hasDisplayList() == true
|
|
359
|
-
|
|
360
|
-
- public fun register(consumer: View) {
|
|
361
|
-
- consumers.addIfAbsent(consumer)
|
|
362
|
-
- }
|
|
363
|
-
+ /** Crop origin of [contentNode] in provider-local pixels. */
|
|
364
|
-
+ public var originX: Int = 0
|
|
365
|
-
+ private set
|
|
366
|
-
+ public var originY: Int = 0
|
|
367
|
-
+ private set
|
|
368
|
-
+
|
|
369
|
-
+ public fun register(consumer: View) { consumers.addIfAbsent(consumer) }
|
|
370
|
-
|
|
371
|
-
public fun unregister(consumer: View) {
|
|
372
|
-
consumers.remove(consumer)
|
|
373
|
-
}
|
|
374
|
-
|
|
375
|
-
+ /** Re-draw consumers against nested RenderNodes without re-recording the route tree. */
|
|
376
|
-
+ public fun invalidateConsumers() {
|
|
377
|
-
+ for (consumer in consumers) consumer.postInvalidateOnAnimation()
|
|
378
|
-
+ }
|
|
379
|
-
+
|
|
380
|
-
+ /** Record the backdrop while leaving the owner's normal on-screen draw pass intact. */
|
|
381
|
-
+ public fun recordOnly(
|
|
382
|
-
+ width: Int,
|
|
383
|
-
+ height: Int,
|
|
384
|
-
+ captureBounds: Rect? = null,
|
|
385
|
-
+ drawContent: (Canvas) -> Unit,
|
|
386
|
-
+ ) {
|
|
387
|
-
+ if (Build.VERSION.SDK_INT >= 29 && width > 0 && height > 0) {
|
|
388
|
-
+ val node = contentNode
|
|
389
|
-
+ ?: RenderNode("LiquidGlassBackdrop").also { contentNode = it }
|
|
390
|
-
+ val bounds = captureBounds?.let {
|
|
391
|
-
+ clampedCaptureBounds.set(
|
|
392
|
-
+ it.left.coerceIn(0, width),
|
|
393
|
-
+ it.top.coerceIn(0, height),
|
|
394
|
-
+ it.right.coerceIn(0, width),
|
|
395
|
-
+ it.bottom.coerceIn(0, height),
|
|
396
|
-
+ )
|
|
397
|
-
+ clampedCaptureBounds.takeIf { rect -> rect.width() > 0 && rect.height() > 0 }
|
|
398
|
-
+ }
|
|
399
|
-
+ val originX = bounds?.left ?: 0
|
|
400
|
-
+ val originY = bounds?.top ?: 0
|
|
401
|
-
+ val recordedWidth = bounds?.width() ?: width
|
|
402
|
-
+ val recordedHeight = bounds?.height() ?: height
|
|
403
|
-
+ node.setPosition(0, 0, recordedWidth, recordedHeight)
|
|
404
|
-
+ val recording = node.beginRecording(recordedWidth, recordedHeight)
|
|
405
|
-
+ try {
|
|
406
|
-
+ if (bounds != null) {
|
|
407
|
-
+ recording.clipRect(0f, 0f, recordedWidth.toFloat(), recordedHeight.toFloat())
|
|
408
|
-
+ recording.translate(-originX.toFloat(), -originY.toFloat())
|
|
409
|
-
+ }
|
|
410
|
-
+ drawContent(recording)
|
|
411
|
-
+ } finally {
|
|
412
|
-
+ node.endRecording()
|
|
413
|
-
+ }
|
|
414
|
-
+ this.originX = originX
|
|
415
|
-
+ this.originY = originY
|
|
416
|
-
+ }
|
|
417
|
-
+ for (consumer in consumers) consumer.postInvalidateOnAnimation()
|
|
418
|
-
+ }
|
|
419
|
-
+
|
|
420
|
-
+ /**
|
|
421
|
-
+ * Draw a provider's live child tree once into the shared RenderNode, then
|
|
422
|
-
+ * composite that same display list to the screen. Consumers sample the
|
|
423
|
-
+ * exact node that was just presented; no second ViewGroup traversal or
|
|
424
|
-
+ * screen-sized bitmap is created.
|
|
425
|
-
+ *
|
|
426
|
-
+ * Returns true when the hardware RenderNode path was used.
|
|
427
|
-
+ */
|
|
428
|
-
+ public fun drawShared(
|
|
429
|
-
+ canvas: Canvas,
|
|
430
|
-
+ width: Int,
|
|
431
|
-
+ height: Int,
|
|
432
|
-
+ recordBackdrop: Boolean,
|
|
433
|
-
+ drawContent: (Canvas) -> Unit,
|
|
434
|
-
+ ): Boolean {
|
|
435
|
-
+ if (Build.VERSION.SDK_INT < 29 || !canvas.isHardwareAccelerated || width <= 0 || height <= 0) {
|
|
436
|
-
+ drawContent(canvas)
|
|
437
|
-
+ return false
|
|
438
|
-
+ }
|
|
439
|
-
+
|
|
440
|
-
+ val node = contentNode
|
|
441
|
-
+ ?: RenderNode("LiquidGlassRoute").also { contentNode = it }
|
|
442
|
-
+ val shouldRecord = recordBackdrop || !node.hasDisplayList()
|
|
443
|
-
+ if (shouldRecord) {
|
|
444
|
-
+ node.setPosition(0, 0, width, height)
|
|
445
|
-
+ val recording = node.beginRecording(width, height)
|
|
446
|
-
+ try {
|
|
447
|
-
+ drawContent(recording)
|
|
448
|
-
+ } finally {
|
|
449
|
-
+ node.endRecording()
|
|
450
|
-
+ }
|
|
451
|
-
+ originX = 0
|
|
452
|
-
+ originY = 0
|
|
453
|
-
+ }
|
|
454
|
-
+
|
|
455
|
-
+ canvas.drawRenderNode(node)
|
|
456
|
-
+ if (shouldRecord) {
|
|
457
|
-
+ for (consumer in consumers) consumer.postInvalidateOnAnimation()
|
|
458
|
-
+ }
|
|
459
|
-
+ return true
|
|
460
|
-
+ }
|
|
461
|
-
+
|
|
462
|
-
/**
|
|
463
|
-
* Records [drawContent] into the backdrop node and replays it onto [canvas]
|
|
464
|
-
* (or draws straight through when recording isn't possible), then invalidates
|
|
465
|
-
@@ -68,26 +183,63 @@ public class BackdropRecorder {
|
|
466
|
-
canvas: Canvas,
|
|
467
|
-
width: Int,
|
|
468
|
-
height: Int,
|
|
469
|
-
+ recordBackdrop: Boolean = true,
|
|
470
|
-
+ notifyConsumers: Boolean = true,
|
|
471
|
-
+ captureBounds: Rect? = null,
|
|
472
|
-
drawContent: (Canvas) -> Unit,
|
|
473
|
-
) {
|
|
474
|
-
- if (Build.VERSION.SDK_INT >= 29 && canvas.isHardwareAccelerated &&
|
|
475
|
-
+ if (recordBackdrop && Build.VERSION.SDK_INT >= 29 && canvas.isHardwareAccelerated &&
|
|
476
|
-
width > 0 && height > 0
|
|
477
|
-
) {
|
|
478
|
-
val node = contentNode
|
|
479
|
-
?: RenderNode("LiquidGlassBackdrop").also { contentNode = it }
|
|
480
|
-
- node.setPosition(0, 0, width, height)
|
|
481
|
-
- val recording = node.beginRecording(width, height)
|
|
482
|
-
+ val bounds = captureBounds?.let {
|
|
483
|
-
+ clampedCaptureBounds.set(
|
|
484
|
-
+ it.left.coerceIn(0, width),
|
|
485
|
-
+ it.top.coerceIn(0, height),
|
|
486
|
-
+ it.right.coerceIn(0, width),
|
|
487
|
-
+ it.bottom.coerceIn(0, height),
|
|
488
|
-
+ )
|
|
489
|
-
+ clampedCaptureBounds.takeIf { rect -> rect.width() > 0 && rect.height() > 0 }
|
|
490
|
-
+ }
|
|
491
|
-
+ val originX = bounds?.left ?: 0
|
|
492
|
-
+ val originY = bounds?.top ?: 0
|
|
493
|
-
+ val recordedWidth = bounds?.width() ?: width
|
|
494
|
-
+ val recordedHeight = bounds?.height() ?: height
|
|
495
|
-
+ node.setPosition(0, 0, recordedWidth, recordedHeight)
|
|
496
|
-
+ val recording = node.beginRecording(recordedWidth, recordedHeight)
|
|
497
|
-
try {
|
|
498
|
-
+ if (bounds != null) {
|
|
499
|
-
+ recording.clipRect(0f, 0f, recordedWidth.toFloat(), recordedHeight.toFloat())
|
|
500
|
-
+ recording.translate(-originX.toFloat(), -originY.toFloat())
|
|
501
|
-
+ }
|
|
502
|
-
drawContent(recording)
|
|
503
|
-
} finally {
|
|
504
|
-
node.endRecording()
|
|
505
|
-
}
|
|
506
|
-
- canvas.drawRenderNode(node)
|
|
507
|
-
+ this.originX = originX
|
|
508
|
-
+ this.originY = originY
|
|
509
|
-
+ if (bounds == null) {
|
|
510
|
-
+ canvas.drawRenderNode(node)
|
|
511
|
-
+ } else {
|
|
512
|
-
+ // Keep normal page drawing intact outside the optical sampling
|
|
513
|
-
+ // rect, then composite the cropped recording into that rect.
|
|
514
|
-
+ canvas.save()
|
|
515
|
-
+ canvas.clipOutRect(bounds)
|
|
516
|
-
+ drawContent(canvas)
|
|
517
|
-
+ canvas.restore()
|
|
518
|
-
+ canvas.save()
|
|
519
|
-
+ canvas.translate(originX.toFloat(), originY.toFloat())
|
|
520
|
-
+ canvas.drawRenderNode(node)
|
|
521
|
-
+ canvas.restore()
|
|
522
|
-
+ }
|
|
523
|
-
} else {
|
|
524
|
-
drawContent(canvas)
|
|
525
|
-
}
|
|
526
|
-
- for (consumer in consumers) {
|
|
527
|
-
- consumer.postInvalidateOnAnimation()
|
|
528
|
-
+ if (notifyConsumers) {
|
|
529
|
-
+ for (consumer in consumers) {
|
|
530
|
-
+ consumer.postInvalidateOnAnimation()
|
|
531
|
-
+ }
|
|
532
|
-
}
|
|
533
|
-
}
|
|
534
|
-
|
|
535
|
-
@@ -96,5 +248,7 @@ public class BackdropRecorder {
|
|
536
|
-
contentNode?.discardDisplayList()
|
|
537
|
-
}
|
|
538
|
-
contentNode = null
|
|
539
|
-
+ originX = 0
|
|
540
|
-
+ originY = 0
|
|
541
|
-
}
|
|
542
|
-
}
|
|
543
|
-
diff --git a/node_modules/liquid-glass-kit/android/src/main/java/dev/liquidglass/view/GlassViewController.kt b/node_modules/liquid-glass-kit/android/src/main/java/dev/liquidglass/view/GlassViewController.kt
|
|
544
|
-
index e5ad81f..a3c290e 100644
|
|
545
|
-
--- a/node_modules/liquid-glass-kit/android/src/main/java/dev/liquidglass/view/GlassViewController.kt
|
|
546
|
-
+++ b/node_modules/liquid-glass-kit/android/src/main/java/dev/liquidglass/view/GlassViewController.kt
|
|
547
|
-
@@ -13,8 +13,17 @@ import androidx.annotation.ColorInt
|
|
548
|
-
import dev.liquidglass.core.GlassRenderTier
|
|
549
|
-
import dev.liquidglass.view.internal.GlassFrame
|
|
550
|
-
import dev.liquidglass.view.internal.GlassViewRenderer
|
|
551
|
-
+import expo.modules.liquidglass.LiquidGlassPerfTelemetry
|
|
552
|
-
+import kotlin.math.abs
|
|
553
|
-
import kotlin.math.min
|
|
554
|
-
|
|
555
|
-
+internal enum class GlassDirtyKind {
|
|
556
|
-
+ SOURCE_CONTENT_DIRTY,
|
|
557
|
-
+ CONSUMER_GEOMETRY_DIRTY,
|
|
558
|
-
+ OPTICS_DIRTY,
|
|
559
|
-
+ MATERIAL_DIRTY,
|
|
560
|
-
+}
|
|
561
|
-
+
|
|
562
|
-
/** Sentinel corner radius: fully rounded capsule/circle. */
|
|
563
|
-
public const val CORNER_RADIUS_CAPSULE: Float = -1f
|
|
564
|
-
|
|
565
|
-
@@ -45,11 +54,19 @@ public class GlassViewController(private val host: View) {
|
|
566
|
-
private val renderer = GlassViewRenderer()
|
|
567
|
-
private val locationSelf = IntArray(2)
|
|
568
|
-
private val locationProvider = IntArray(2)
|
|
569
|
-
+ private val relativePosition = FloatArray(2)
|
|
570
|
-
+ private val frame = GlassFrame()
|
|
571
|
-
private var pressAmount = 0f
|
|
572
|
-
private var pressX = 0f
|
|
573
|
-
private var pressY = 0f
|
|
574
|
-
private var pressAnimator: ValueAnimator? = null
|
|
575
|
-
-
|
|
576
|
-
+ private var previousRelativeX: Float? = null
|
|
577
|
-
+ private var previousRelativeY: Float? = null
|
|
578
|
-
+ private var previousMotionAtNanos = 0L
|
|
579
|
-
+ private var derivedMotionX = 0f
|
|
580
|
-
+ private var derivedMotionY = 0f
|
|
581
|
-
+ private var explicitMotionX: Float? = null
|
|
582
|
-
+ private var explicitMotionY: Float? = null
|
|
583
|
-
/** The backdrop this glass refracts. Must be drawn below the host. */
|
|
584
|
-
public var provider: LiquidGlassBackdropSource? = null
|
|
585
|
-
set(value) {
|
|
586
|
-
@@ -76,6 +93,14 @@ public class GlassViewController(private val host: View) {
|
|
587
|
-
public var refractionAmountDp: Float = 12f
|
|
588
|
-
set(value) = invalidating(field, value) { field = it }
|
|
589
|
-
|
|
590
|
-
+ /** Full-body rounded-rect coordinate remapping in dp, separate from the rim bend. */
|
|
591
|
-
+ public var bodyRefractionAmountDp: Float = 2.5f
|
|
592
|
-
+ set(value) = invalidating(field, value) { field = it }
|
|
593
|
-
+
|
|
594
|
-
+ /** 0..1 animated material morph from idle to pressed/dragged optics. */
|
|
595
|
-
+ public var interactionProgress: Float = 0f
|
|
596
|
-
+ set(value) = invalidating(field, value.coerceIn(0f, 1f), GlassDirtyKind.OPTICS_DIRTY) { field = it }
|
|
597
|
-
+
|
|
598
|
-
/** Backdrop saturation boost; 1 leaves color untouched. */
|
|
599
|
-
public var saturation: Float = 1.5f
|
|
600
|
-
set(value) = invalidating(field, value) { field = it }
|
|
601
|
-
@@ -85,6 +110,10 @@ public class GlassViewController(private val host: View) {
|
|
602
|
-
public var glassTintColor: Int = Color.TRANSPARENT
|
|
603
|
-
set(value) = invalidating(field, value) { field = it }
|
|
604
|
-
|
|
605
|
-
+ /** Material-specific multiplier applied to the RGBA tint alpha. */
|
|
606
|
-
+ public var tintAlpha: Float = 1f
|
|
607
|
-
+ set(value) = invalidating(field, value.coerceIn(0f, 1f)) { field = it }
|
|
608
|
-
+
|
|
609
|
-
/** 0..1 RGB dispersion along the lens edge. */
|
|
610
|
-
public var chromaticAberration: Float = 0f
|
|
611
|
-
set(value) = invalidating(field, value) { field = it }
|
|
612
|
-
@@ -97,6 +126,18 @@ public class GlassViewController(private val host: View) {
|
|
613
|
-
public var highlightAlpha: Float = 0.45f
|
|
614
|
-
set(value) = invalidating(field, value) { field = it }
|
|
615
|
-
|
|
616
|
-
+ /** Gain for the half-vector specular lobe. */
|
|
617
|
-
+ public var specularStrength: Float = 1f
|
|
618
|
-
+ set(value) = invalidating(field, value) { field = it }
|
|
619
|
-
+
|
|
620
|
-
+ /** Gain for the height-field Fresnel edge response. */
|
|
621
|
-
+ public var fresnelStrength: Float = 0.85f
|
|
622
|
-
+ set(value) = invalidating(field, value) { field = it }
|
|
623
|
-
+
|
|
624
|
-
+ /** Gain for the thin inner compression shadow near the rounded edge. */
|
|
625
|
-
+ public var innerShadowStrength: Float = 0.18f
|
|
626
|
-
+ set(value) = invalidating(field, value) { field = it }
|
|
627
|
-
+
|
|
628
|
-
/** Thickness of the specular rim in dp. */
|
|
629
|
-
public var highlightWidthDp: Float = 2f
|
|
630
|
-
set(value) = invalidating(field, value) { field = it }
|
|
631
|
-
@@ -113,6 +154,25 @@ public class GlassViewController(private val host: View) {
|
|
632
|
-
/** When true the glass answers touch with the gel press response. */
|
|
633
|
-
public var isGlassInteractive: Boolean = false
|
|
634
|
-
|
|
635
|
-
+ /** Keep a cropped backdrop region current while an interactive lens is mounted. */
|
|
636
|
-
+ public var continuousBackdrop: Boolean = false
|
|
637
|
-
+ set(value) {
|
|
638
|
-
+ if (field == value) return
|
|
639
|
-
+ field = value
|
|
640
|
-
+ host.invalidate()
|
|
641
|
-
+ if (value) provider?.requestCaptureFrame()
|
|
642
|
-
+ }
|
|
643
|
-
+
|
|
644
|
-
+ /** Optional UI-thread velocity overrides, normalized to -1..1. */
|
|
645
|
-
+ public var motionX: Float? = null
|
|
646
|
-
+ set(value) = invalidating(field, value?.coerceIn(-1f, 1f), GlassDirtyKind.OPTICS_DIRTY) { field = it }
|
|
647
|
-
+ public var motionY: Float? = null
|
|
648
|
-
+ set(value) = invalidating(field, value?.coerceIn(-1f, 1f), GlassDirtyKind.OPTICS_DIRTY) { field = it }
|
|
649
|
-
+
|
|
650
|
-
+ /** Development-only view of the displaced backdrop without material lighting. */
|
|
651
|
-
+ public var displacementOnlyDebug: Boolean = false
|
|
652
|
-
+ set(value) = invalidating(field, value, GlassDirtyKind.OPTICS_DIRTY) { field = it }
|
|
653
|
-
+
|
|
654
|
-
/** Optional fidelity cap (accessibility, battery, tests). */
|
|
655
|
-
public var tierOverride: GlassRenderTier? = null
|
|
656
|
-
set(value) = invalidating(field, value) { field = it }
|
|
657
|
-
@@ -144,6 +204,8 @@ public class GlassViewController(private val host: View) {
|
|
658
|
-
/** Draws the glass into [canvas]; call before the host's children draw. */
|
|
659
|
-
public fun draw(canvas: Canvas) {
|
|
660
|
-
if (host.width < 1 || host.height < 1) return
|
|
661
|
-
+ LiquidGlassPerfTelemetry.consumerDraw()
|
|
662
|
-
+ if (continuousBackdrop) provider?.requestCaptureFrame()
|
|
663
|
-
val frame = buildFrame()
|
|
664
|
-
val backdrop = provider
|
|
665
|
-
val providerNode =
|
|
666
|
-
@@ -152,6 +214,7 @@ public class GlassViewController(private val host: View) {
|
|
667
|
-
val tier = GlassRenderTier.select(Build.VERSION.SDK_INT, tierOverride)
|
|
668
|
-
val canSample = canvas.isHardwareAccelerated &&
|
|
669
|
-
backdrop?.hasRecording == true && providerNode != null
|
|
670
|
-
+ if (canSample) LiquidGlassPerfTelemetry.backdropSample()
|
|
671
|
-
|
|
672
|
-
when {
|
|
673
|
-
canSample && tier == GlassRenderTier.SHADER && Build.VERSION.SDK_INT >= 33 ->
|
|
674
|
-
@@ -176,36 +239,91 @@ public class GlassViewController(private val host: View) {
|
|
675
|
-
min(cornerRadiusDp * density, maxRadius)
|
|
676
|
-
}
|
|
677
|
-
val relative = relativeToProvider()
|
|
678
|
-
- return GlassFrame(
|
|
679
|
-
- widthPx = width,
|
|
680
|
-
- heightPx = height,
|
|
681
|
-
- cornerRadiusPx = cornerRadiusPx,
|
|
682
|
-
- blurRadiusPx = blurRadiusDp * density,
|
|
683
|
-
- refractionHeightPx = refractionHeightDp * density,
|
|
684
|
-
- refractionAmountPx = refractionAmountDp * density,
|
|
685
|
-
- saturation = saturation,
|
|
686
|
-
- tintColor = glassTintColor,
|
|
687
|
-
- chromaticAberration = chromaticAberration,
|
|
688
|
-
- noiseAlpha = noiseAlpha,
|
|
689
|
-
- highlightAlpha = highlightAlpha * (1f + pressAmount * 0.4f),
|
|
690
|
-
- highlightWidthPx = highlightWidthDp * density,
|
|
691
|
-
- lightAngleDegrees = lightAngleDegrees,
|
|
692
|
-
- pressAmount = pressAmount,
|
|
693
|
-
- pressX = pressX,
|
|
694
|
-
- pressY = pressY,
|
|
695
|
-
- relativeX = relative[0],
|
|
696
|
-
- relativeY = relative[1],
|
|
697
|
-
- )
|
|
698
|
-
+ updateMotion(relative)
|
|
699
|
-
+ val backdrop = provider
|
|
700
|
-
+ val recordedOriginX = backdrop?.recordedOriginX ?: 0
|
|
701
|
-
+ val recordedOriginY = backdrop?.recordedOriginY ?: 0
|
|
702
|
-
+ frame.widthPx = width
|
|
703
|
-
+ frame.heightPx = height
|
|
704
|
-
+ frame.cornerRadiusPx = cornerRadiusPx
|
|
705
|
-
+ frame.blurRadiusPx = blurRadiusDp * density
|
|
706
|
-
+ frame.refractionHeightPx = refractionHeightDp * density
|
|
707
|
-
+ frame.refractionAmountPx = refractionAmountDp * density
|
|
708
|
-
+ frame.bodyRefractionAmountPx = bodyRefractionAmountDp * density
|
|
709
|
-
+ frame.interactionProgress = interactionProgress
|
|
710
|
-
+ frame.saturation = saturation
|
|
711
|
-
+ frame.tintColor = glassTintColor
|
|
712
|
-
+ frame.tintAlpha = tintAlpha
|
|
713
|
-
+ frame.chromaticAberration = chromaticAberration
|
|
714
|
-
+ frame.noiseAlpha = noiseAlpha
|
|
715
|
-
+ frame.highlightAlpha = highlightAlpha * (1f + pressAmount * 0.4f)
|
|
716
|
-
+ frame.specularStrength = specularStrength
|
|
717
|
-
+ frame.fresnelStrength = fresnelStrength
|
|
718
|
-
+ frame.innerShadowStrength = innerShadowStrength
|
|
719
|
-
+ frame.highlightWidthPx = highlightWidthDp * density
|
|
720
|
-
+ frame.displacementOnlyDebug = displacementOnlyDebug
|
|
721
|
-
+ frame.lightAngleDegrees = lightAngleDegrees
|
|
722
|
-
+ frame.pressAmount = pressAmount
|
|
723
|
-
+ frame.pressX = pressX
|
|
724
|
-
+ frame.pressY = pressY
|
|
725
|
-
+ frame.relativeX = relative[0] - recordedOriginX
|
|
726
|
-
+ frame.relativeY = relative[1] - recordedOriginY
|
|
727
|
-
+ frame.motionX = motionX ?: derivedMotionX
|
|
728
|
-
+ frame.motionY = motionY ?: derivedMotionY
|
|
729
|
-
+ return frame
|
|
730
|
-
+ }
|
|
731
|
-
+
|
|
732
|
-
+ private fun updateMotion(relative: FloatArray) {
|
|
733
|
-
+ val now = System.nanoTime()
|
|
734
|
-
+ val previousX = previousRelativeX
|
|
735
|
-
+ val previousY = previousRelativeY
|
|
736
|
-
+ val elapsedSeconds = (now - previousMotionAtNanos) / 1_000_000_000f
|
|
737
|
-
+ if (previousX != null && previousY != null &&
|
|
738
|
-
+ (abs(relative[0] - previousX) > 0.5f || abs(relative[1] - previousY) > 0.5f)
|
|
739
|
-
+ ) {
|
|
740
|
-
+ // Cropped providers need a new recording when the consumer moves.
|
|
741
|
-
+ // Full-scene providers (the Expo/RN host) only need new sampling
|
|
742
|
-
+ // coordinates, so avoid an otherwise redundant full-page re-record.
|
|
743
|
-
+ val backdrop = provider
|
|
744
|
-
+ if (!continuousBackdrop && backdrop?.requiresCaptureOnConsumerMovement == true) {
|
|
745
|
-
+ backdrop.requestCaptureFrame()
|
|
746
|
-
+ }
|
|
747
|
-
+ }
|
|
748
|
-
+ if (previousX != null && previousY != null && elapsedSeconds in 0.004f..0.12f) {
|
|
749
|
-
+ val density = host.resources.displayMetrics.density.coerceAtLeast(1f)
|
|
750
|
-
+ val targetX = (((relative[0] - previousX) / density) / elapsedSeconds / 1800f).coerceIn(-1f, 1f)
|
|
751
|
-
+ val targetY = (((relative[1] - previousY) / density) / elapsedSeconds / 1800f).coerceIn(-1f, 1f)
|
|
752
|
-
+ derivedMotionX = derivedMotionX * 0.62f + targetX * 0.38f
|
|
753
|
-
+ derivedMotionY = derivedMotionY * 0.62f + targetY * 0.38f
|
|
754
|
-
+ } else if (elapsedSeconds > 0.12f || previousX == null) {
|
|
755
|
-
+ derivedMotionX = 0f
|
|
756
|
-
+ derivedMotionY = 0f
|
|
757
|
-
+ }
|
|
758
|
-
+ previousRelativeX = relative[0]
|
|
759
|
-
+ previousRelativeY = relative[1]
|
|
760
|
-
+ previousMotionAtNanos = now
|
|
761
|
-
}
|
|
762
|
-
|
|
763
|
-
private fun relativeToProvider(): FloatArray {
|
|
764
|
-
- val backdrop = provider ?: return floatArrayOf(0f, 0f)
|
|
765
|
-
+ val backdrop = provider
|
|
766
|
-
+ if (backdrop == null) {
|
|
767
|
-
+ relativePosition[0] = 0f
|
|
768
|
-
+ relativePosition[1] = 0f
|
|
769
|
-
+ return relativePosition
|
|
770
|
-
+ }
|
|
771
|
-
+ val previousX = relativePosition[0]
|
|
772
|
-
+ val previousY = relativePosition[1]
|
|
773
|
-
+ LiquidGlassPerfTelemetry.geometryLookup()
|
|
774
|
-
host.getLocationInWindow(locationSelf)
|
|
775
|
-
+ LiquidGlassPerfTelemetry.geometryLookup()
|
|
776
|
-
backdrop.sourceView.getLocationInWindow(locationProvider)
|
|
777
|
-
- return floatArrayOf(
|
|
778
|
-
- (locationSelf[0] - locationProvider[0]).toFloat(),
|
|
779
|
-
- (locationSelf[1] - locationProvider[1]).toFloat(),
|
|
780
|
-
- )
|
|
781
|
-
+ relativePosition[0] = (locationSelf[0] - locationProvider[0]).toFloat()
|
|
782
|
-
+ relativePosition[1] = (locationSelf[1] - locationProvider[1]).toFloat()
|
|
783
|
-
+ if (previousX != relativePosition[0] || previousY != relativePosition[1]) {
|
|
784
|
-
+ LiquidGlassPerfTelemetry.consumerGeometryDirty()
|
|
785
|
-
+ if (!continuousBackdrop) backdrop.onConsumerGeometryChanged(host)
|
|
786
|
-
+ }
|
|
787
|
-
+ return relativePosition
|
|
788
|
-
}
|
|
789
|
-
|
|
790
|
-
private fun resolveScrimColor(): Int =
|
|
791
|
-
@@ -218,6 +336,7 @@ public class GlassViewController(private val host: View) {
|
|
792
|
-
this.interpolator = interpolator
|
|
793
|
-
addUpdateListener {
|
|
794
|
-
pressAmount = it.animatedValue as Float
|
|
795
|
-
+ LiquidGlassPerfTelemetry.opticsDirty()
|
|
796
|
-
val scale = 1f + 0.025f * pressAmount
|
|
797
|
-
host.scaleX = scale
|
|
798
|
-
host.scaleY = scale
|
|
799
|
-
@@ -227,9 +346,20 @@ public class GlassViewController(private val host: View) {
|
|
800
|
-
}
|
|
801
|
-
}
|
|
802
|
-
|
|
803
|
-
- private inline fun <T> invalidating(old: T, new: T, assign: (T) -> Unit) {
|
|
804
|
-
+ private inline fun <T> invalidating(
|
|
805
|
-
+ old: T,
|
|
806
|
-
+ new: T,
|
|
807
|
-
+ kind: GlassDirtyKind = GlassDirtyKind.MATERIAL_DIRTY,
|
|
808
|
-
+ assign: (T) -> Unit,
|
|
809
|
-
+ ) {
|
|
810
|
-
if (old != new) {
|
|
811
|
-
assign(new)
|
|
812
|
-
+ when (kind) {
|
|
813
|
-
+ GlassDirtyKind.SOURCE_CONTENT_DIRTY -> Unit
|
|
814
|
-
+ GlassDirtyKind.CONSUMER_GEOMETRY_DIRTY -> LiquidGlassPerfTelemetry.consumerGeometryDirty()
|
|
815
|
-
+ GlassDirtyKind.OPTICS_DIRTY -> LiquidGlassPerfTelemetry.opticsDirty()
|
|
816
|
-
+ GlassDirtyKind.MATERIAL_DIRTY -> LiquidGlassPerfTelemetry.materialDirty()
|
|
817
|
-
+ }
|
|
818
|
-
host.invalidate()
|
|
819
|
-
}
|
|
820
|
-
}
|
|
821
|
-
diff --git a/node_modules/liquid-glass-kit/android/src/main/java/dev/liquidglass/view/LiquidGlassProviderLayout.kt b/node_modules/liquid-glass-kit/android/src/main/java/dev/liquidglass/view/LiquidGlassProviderLayout.kt
|
|
822
|
-
index 19d1dfc..b50b90b 100644
|
|
823
|
-
--- a/node_modules/liquid-glass-kit/android/src/main/java/dev/liquidglass/view/LiquidGlassProviderLayout.kt
|
|
824
|
-
+++ b/node_modules/liquid-glass-kit/android/src/main/java/dev/liquidglass/view/LiquidGlassProviderLayout.kt
|
|
825
|
-
@@ -23,7 +23,6 @@ public open class LiquidGlassProviderLayout @JvmOverloads constructor(
|
|
826
|
-
) : FrameLayout(context, attrs, defStyleAttr), LiquidGlassBackdropSource {
|
|
827
|
-
|
|
828
|
-
private val recorder = BackdropRecorder()
|
|
829
|
-
-
|
|
830
|
-
override val sourceView: View
|
|
831
|
-
get() = this
|
|
832
|
-
|
|
833
|
-
diff --git a/node_modules/liquid-glass-kit/android/src/main/java/dev/liquidglass/view/internal/GlassViewRenderer.kt b/node_modules/liquid-glass-kit/android/src/main/java/dev/liquidglass/view/internal/GlassViewRenderer.kt
|
|
834
|
-
index 4874b15..42af277 100644
|
|
835
|
-
--- a/node_modules/liquid-glass-kit/android/src/main/java/dev/liquidglass/view/internal/GlassViewRenderer.kt
|
|
836
|
-
+++ b/node_modules/liquid-glass-kit/android/src/main/java/dev/liquidglass/view/internal/GlassViewRenderer.kt
|
|
837
|
-
@@ -13,13 +13,13 @@ import android.graphics.RenderNode
|
|
838
|
-
import android.graphics.RuntimeShader
|
|
839
|
-
import android.graphics.Shader
|
|
840
|
-
import androidx.annotation.RequiresApi
|
|
841
|
-
-import dev.liquidglass.core.GlassShapePacker
|
|
842
|
-
import dev.liquidglass.core.GlassUniforms
|
|
843
|
-
import dev.liquidglass.core.LiquidGlassShaders
|
|
844
|
-
-import dev.liquidglass.core.PackedGlassShape
|
|
845
|
-
+import expo.modules.liquidglass.LiquidGlassPerfTelemetry
|
|
846
|
-
import kotlin.math.abs
|
|
847
|
-
import kotlin.math.cos
|
|
848
|
-
import kotlin.math.max
|
|
849
|
-
+import kotlin.math.min
|
|
850
|
-
import kotlin.math.sin
|
|
851
|
-
|
|
852
|
-
private const val MIN_BLUR_RADIUS_PX = 0.05f
|
|
853
|
-
@@ -27,24 +27,33 @@ private const val SATURATION_EPSILON = 0.01f
|
|
854
|
-
|
|
855
|
-
/** Everything the renderer needs for one frame, resolved to pixels. */
|
|
856
|
-
internal class GlassFrame(
|
|
857
|
-
- val widthPx: Float,
|
|
858
|
-
- val heightPx: Float,
|
|
859
|
-
- val cornerRadiusPx: Float,
|
|
860
|
-
- val blurRadiusPx: Float,
|
|
861
|
-
- val refractionHeightPx: Float,
|
|
862
|
-
- val refractionAmountPx: Float,
|
|
863
|
-
- val saturation: Float,
|
|
864
|
-
- val tintColor: Int,
|
|
865
|
-
- val chromaticAberration: Float,
|
|
866
|
-
- val noiseAlpha: Float,
|
|
867
|
-
- val highlightAlpha: Float,
|
|
868
|
-
- val highlightWidthPx: Float,
|
|
869
|
-
- val lightAngleDegrees: Float,
|
|
870
|
-
- val pressAmount: Float,
|
|
871
|
-
- val pressX: Float,
|
|
872
|
-
- val pressY: Float,
|
|
873
|
-
- val relativeX: Float,
|
|
874
|
-
- val relativeY: Float,
|
|
875
|
-
+ var widthPx: Float = 0f,
|
|
876
|
-
+ var heightPx: Float = 0f,
|
|
877
|
-
+ var cornerRadiusPx: Float = 0f,
|
|
878
|
-
+ var blurRadiusPx: Float = 0f,
|
|
879
|
-
+ var refractionHeightPx: Float = 0f,
|
|
880
|
-
+ var refractionAmountPx: Float = 0f,
|
|
881
|
-
+ var bodyRefractionAmountPx: Float = 0f,
|
|
882
|
-
+ var interactionProgress: Float = 0f,
|
|
883
|
-
+ var saturation: Float = 1f,
|
|
884
|
-
+ var tintColor: Int = Color.TRANSPARENT,
|
|
885
|
-
+ var tintAlpha: Float = 1f,
|
|
886
|
-
+ var chromaticAberration: Float = 0f,
|
|
887
|
-
+ var noiseAlpha: Float = 0f,
|
|
888
|
-
+ var highlightAlpha: Float = 0f,
|
|
889
|
-
+ var specularStrength: Float = 1f,
|
|
890
|
-
+ var fresnelStrength: Float = 0.85f,
|
|
891
|
-
+ var innerShadowStrength: Float = 0.18f,
|
|
892
|
-
+ var highlightWidthPx: Float = 0f,
|
|
893
|
-
+ var displacementOnlyDebug: Boolean = false,
|
|
894
|
-
+ var lightAngleDegrees: Float = 245f,
|
|
895
|
-
+ var pressAmount: Float = 0f,
|
|
896
|
-
+ var pressX: Float = 0f,
|
|
897
|
-
+ var pressY: Float = 0f,
|
|
898
|
-
+ var relativeX: Float = 0f,
|
|
899
|
-
+ var relativeY: Float = 0f,
|
|
900
|
-
+ var motionX: Float = 0f,
|
|
901
|
-
+ var motionY: Float = 0f,
|
|
902
|
-
)
|
|
903
|
-
|
|
904
|
-
/**
|
|
905
|
-
@@ -60,6 +69,27 @@ internal class GlassViewRenderer {
|
|
906
|
-
private val scrimPaint = Paint()
|
|
907
|
-
private val rimPaint = Paint(Paint.ANTI_ALIAS_FLAG).apply { style = Paint.Style.STROKE }
|
|
908
|
-
private val rectF = RectF()
|
|
909
|
-
+ private val packedShapes = FloatArray(GlassUniforms.MAX_SHAPES * GlassUniforms.SHAPE_FLOATS).apply {
|
|
910
|
-
+ for (i in 0 until GlassUniforms.MAX_SHAPES) {
|
|
911
|
-
+ val base = i * GlassUniforms.SHAPE_FLOATS
|
|
912
|
-
+ this[base] = GlassUniforms.SENTINEL_CENTER
|
|
913
|
-
+ this[base + 1] = GlassUniforms.SENTINEL_CENTER
|
|
914
|
-
+ this[base + 2] = 1f
|
|
915
|
-
+ this[base + 3] = 1f
|
|
916
|
-
+ }
|
|
917
|
-
+ }
|
|
918
|
-
+ private val packedRadii = FloatArray(GlassUniforms.MAX_SHAPES)
|
|
919
|
-
+ private var shaderEffect: RenderEffect? = null
|
|
920
|
-
+ private var cachedPrepEffect: RenderEffect? = null
|
|
921
|
-
+ private var cachedPrepBlur = Float.NaN
|
|
922
|
-
+ private var cachedPrepSaturation = Float.NaN
|
|
923
|
-
+ private var cachedPrepValid = false
|
|
924
|
-
+ private var cachedChainEffect: RenderEffect? = null
|
|
925
|
-
+ private var cachedChainPrep: RenderEffect? = null
|
|
926
|
-
+ private var appliedRenderEffect: RenderEffect? = null
|
|
927
|
-
+ private var cachedLightAngle = Float.NaN
|
|
928
|
-
+ private var cachedLightDirX = 0f
|
|
929
|
-
+ private var cachedLightDirY = 0f
|
|
930
|
-
|
|
931
|
-
fun release() {
|
|
932
|
-
if (android.os.Build.VERSION.SDK_INT >= 29) {
|
|
933
|
-
@@ -67,6 +97,15 @@ internal class GlassViewRenderer {
|
|
934
|
-
}
|
|
935
|
-
glassNode = null
|
|
936
|
-
runtimeShader = null
|
|
937
|
-
+ shaderEffect = null
|
|
938
|
-
+ cachedPrepEffect = null
|
|
939
|
-
+ cachedPrepBlur = Float.NaN
|
|
940
|
-
+ cachedPrepSaturation = Float.NaN
|
|
941
|
-
+ cachedPrepValid = false
|
|
942
|
-
+ cachedChainEffect = null
|
|
943
|
-
+ cachedChainPrep = null
|
|
944
|
-
+ appliedRenderEffect = null
|
|
945
|
-
+ cachedLightAngle = Float.NaN
|
|
946
|
-
}
|
|
947
|
-
|
|
948
|
-
/** SHADER (33+) and BLUR (31+) tiers: backdrop slice + RenderEffect. */
|
|
949
|
-
@@ -91,13 +130,15 @@ internal class GlassViewRenderer {
|
|
950
|
-
} finally {
|
|
951
|
-
node.endRecording()
|
|
952
|
-
}
|
|
953
|
-
- node.setRenderEffect(
|
|
954
|
-
- if (useShader && android.os.Build.VERSION.SDK_INT >= 33) {
|
|
955
|
-
- buildShaderEffect(frame, inflate)
|
|
956
|
-
- } else {
|
|
957
|
-
- buildBackdropPrepEffect(frame.blurRadiusPx, frame.saturation)
|
|
958
|
-
- },
|
|
959
|
-
- )
|
|
960
|
-
+ val effect = if (useShader && android.os.Build.VERSION.SDK_INT >= 33) {
|
|
961
|
-
+ buildShaderEffect(frame, inflate)
|
|
962
|
-
+ } else {
|
|
963
|
-
+ buildBackdropPrepEffect(frame.blurRadiusPx, frame.saturation)
|
|
964
|
-
+ }
|
|
965
|
-
+ if (appliedRenderEffect !== effect) {
|
|
966
|
-
+ node.setRenderEffect(effect)
|
|
967
|
-
+ appliedRenderEffect = effect
|
|
968
|
-
+ }
|
|
969
|
-
|
|
970
|
-
canvas.save()
|
|
971
|
-
if (!useShader) {
|
|
972
|
-
@@ -141,22 +182,31 @@ internal class GlassViewRenderer {
|
|
973
|
-
@RequiresApi(33)
|
|
974
|
-
private fun buildShaderEffect(frame: GlassFrame, inflate: Float): RenderEffect {
|
|
975
|
-
val shader = runtimeShader
|
|
976
|
-
- ?: RuntimeShader(LiquidGlassShaders.LIQUID_GLASS).also { runtimeShader = it }
|
|
977
|
-
- val shape = PackedGlassShape(
|
|
978
|
-
- centerX = frame.widthPx / 2f + inflate,
|
|
979
|
-
- centerY = frame.heightPx / 2f + inflate,
|
|
980
|
-
- halfWidth = frame.widthPx / 2f,
|
|
981
|
-
- halfHeight = frame.heightPx / 2f,
|
|
982
|
-
- cornerRadius = frame.cornerRadiusPx,
|
|
983
|
-
- )
|
|
984
|
-
- val shapes = listOf(shape)
|
|
985
|
-
- val angleRadians = Math.toRadians(frame.lightAngleDegrees.toDouble())
|
|
986
|
-
+ ?: RuntimeShader(LiquidGlassShaders.LIQUID_GLASS).also {
|
|
987
|
-
+ runtimeShader = it
|
|
988
|
-
+ LiquidGlassPerfTelemetry.effectBuild()
|
|
989
|
-
+ }
|
|
990
|
-
+ val halfWidth = frame.widthPx / 2f
|
|
991
|
-
+ val halfHeight = frame.heightPx / 2f
|
|
992
|
-
+ packedShapes[0] = halfWidth + inflate
|
|
993
|
-
+ packedShapes[1] = halfHeight + inflate
|
|
994
|
-
+ packedShapes[2] = halfWidth
|
|
995
|
-
+ packedShapes[3] = halfHeight
|
|
996
|
-
+ packedRadii[0] = min(frame.cornerRadiusPx, max(min(halfWidth, halfHeight), 0f))
|
|
997
|
-
+ if (cachedLightAngle != frame.lightAngleDegrees) {
|
|
998
|
-
+ val angleRadians = Math.toRadians(frame.lightAngleDegrees.toDouble())
|
|
999
|
-
+ cachedLightDirX = cos(angleRadians).toFloat()
|
|
1000
|
-
+ cachedLightDirY = sin(angleRadians).toFloat()
|
|
1001
|
-
+ cachedLightAngle = frame.lightAngleDegrees
|
|
1002
|
-
+ }
|
|
1003
|
-
with(shader) {
|
|
1004
|
-
- setFloatUniform(GlassUniforms.SHAPES, GlassShapePacker.packShapes(shapes))
|
|
1005
|
-
- setFloatUniform(GlassUniforms.SHAPE_RADII, GlassShapePacker.packCornerRadii(shapes))
|
|
1006
|
-
+ setFloatUniform(GlassUniforms.SHAPES, packedShapes)
|
|
1007
|
-
+ setFloatUniform(GlassUniforms.SHAPE_RADII, packedRadii)
|
|
1008
|
-
setFloatUniform(GlassUniforms.MERGE_SMOOTHING, 0f)
|
|
1009
|
-
setFloatUniform(GlassUniforms.REFRACTION_HEIGHT, frame.refractionHeightPx)
|
|
1010
|
-
setFloatUniform(GlassUniforms.REFRACTION_AMOUNT, frame.refractionAmountPx)
|
|
1011
|
-
+ setFloatUniform(GlassUniforms.BODY_REFRACTION_AMOUNT, frame.bodyRefractionAmountPx)
|
|
1012
|
-
+ setFloatUniform(GlassUniforms.INTERACTION_PROGRESS, frame.interactionProgress)
|
|
1013
|
-
setFloatUniform(GlassUniforms.CHROMATIC_ABERRATION, frame.chromaticAberration)
|
|
1014
|
-
setFloatUniform(
|
|
1015
|
-
GlassUniforms.TINT,
|
|
1016
|
-
@@ -165,46 +215,77 @@ internal class GlassViewRenderer {
|
|
1017
|
-
Color.blue(frame.tintColor) / 255f,
|
|
1018
|
-
Color.alpha(frame.tintColor) / 255f,
|
|
1019
|
-
)
|
|
1020
|
-
+ setFloatUniform(GlassUniforms.TINT_ALPHA, frame.tintAlpha)
|
|
1021
|
-
setFloatUniform(GlassUniforms.NOISE_ALPHA, frame.noiseAlpha)
|
|
1022
|
-
setFloatUniform(
|
|
1023
|
-
GlassUniforms.LIGHT_DIRECTION,
|
|
1024
|
-
- cos(angleRadians).toFloat(),
|
|
1025
|
-
- sin(angleRadians).toFloat(),
|
|
1026
|
-
+ cachedLightDirX,
|
|
1027
|
-
+ cachedLightDirY,
|
|
1028
|
-
)
|
|
1029
|
-
setFloatUniform(GlassUniforms.HIGHLIGHT_ALPHA, frame.highlightAlpha)
|
|
1030
|
-
+ setFloatUniform(GlassUniforms.SPECULAR_STRENGTH, frame.specularStrength)
|
|
1031
|
-
+ setFloatUniform(GlassUniforms.FRESNEL_STRENGTH, frame.fresnelStrength)
|
|
1032
|
-
+ setFloatUniform(GlassUniforms.INNER_SHADOW_STRENGTH, frame.innerShadowStrength)
|
|
1033
|
-
setFloatUniform(GlassUniforms.HIGHLIGHT_WIDTH, frame.highlightWidthPx)
|
|
1034
|
-
setFloatUniform(GlassUniforms.PRESS_AMOUNT, max(frame.pressAmount, 0f))
|
|
1035
|
-
+ setFloatUniform(GlassUniforms.MOTION, frame.motionX, frame.motionY)
|
|
1036
|
-
+ setFloatUniform(GlassUniforms.DISPLACEMENT_ONLY, if (frame.displacementOnlyDebug) 1f else 0f)
|
|
1037
|
-
setFloatUniform(
|
|
1038
|
-
GlassUniforms.PRESS_POINT,
|
|
1039
|
-
frame.pressX + inflate,
|
|
1040
|
-
frame.pressY + inflate,
|
|
1041
|
-
)
|
|
1042
|
-
}
|
|
1043
|
-
- val shaderEffect =
|
|
1044
|
-
- RenderEffect.createRuntimeShaderEffect(shader, GlassUniforms.CONTENT)
|
|
1045
|
-
- val prep = buildBackdropPrepEffect(frame.blurRadiusPx, frame.saturation)
|
|
1046
|
-
- ?: return shaderEffect
|
|
1047
|
-
- return RenderEffect.createChainEffect(shaderEffect, prep)
|
|
1048
|
-
+ val runtimeEffect = shaderEffect
|
|
1049
|
-
+ ?: RenderEffect.createRuntimeShaderEffect(shader, GlassUniforms.CONTENT).also {
|
|
1050
|
-
+ shaderEffect = it
|
|
1051
|
-
+ LiquidGlassPerfTelemetry.effectBuild()
|
|
1052
|
-
+ }
|
|
1053
|
-
+ val prep = if (frame.displacementOnlyDebug) {
|
|
1054
|
-
+ null
|
|
1055
|
-
+ } else {
|
|
1056
|
-
+ buildBackdropPrepEffect(frame.blurRadiusPx, frame.saturation)
|
|
1057
|
-
+ } ?: return runtimeEffect
|
|
1058
|
-
+ if (cachedChainEffect == null || cachedChainPrep !== prep) {
|
|
1059
|
-
+ cachedChainPrep = prep
|
|
1060
|
-
+ cachedChainEffect = RenderEffect.createChainEffect(runtimeEffect, prep).also {
|
|
1061
|
-
+ LiquidGlassPerfTelemetry.effectBuild()
|
|
1062
|
-
+ }
|
|
1063
|
-
+ }
|
|
1064
|
-
+ return cachedChainEffect!!
|
|
1065
|
-
}
|
|
1066
|
-
|
|
1067
|
-
@RequiresApi(31)
|
|
1068
|
-
private fun buildBackdropPrepEffect(blurRadiusPx: Float, saturation: Float): RenderEffect? {
|
|
1069
|
-
+ if (cachedPrepValid && cachedPrepBlur == blurRadiusPx && cachedPrepSaturation == saturation) {
|
|
1070
|
-
+ return cachedPrepEffect
|
|
1071
|
-
+ }
|
|
1072
|
-
val blur = if (blurRadiusPx > MIN_BLUR_RADIUS_PX) {
|
|
1073
|
-
- RenderEffect.createBlurEffect(blurRadiusPx, blurRadiusPx, Shader.TileMode.CLAMP)
|
|
1074
|
-
+ RenderEffect.createBlurEffect(blurRadiusPx, blurRadiusPx, Shader.TileMode.CLAMP).also {
|
|
1075
|
-
+ LiquidGlassPerfTelemetry.effectBuild()
|
|
1076
|
-
+ }
|
|
1077
|
-
} else {
|
|
1078
|
-
null
|
|
1079
|
-
}
|
|
1080
|
-
- if (abs(saturation - 1f) < SATURATION_EPSILON) return blur
|
|
1081
|
-
- val filter = ColorMatrixColorFilter(ColorMatrix().apply { setSaturation(saturation) })
|
|
1082
|
-
- return if (blur != null) {
|
|
1083
|
-
- RenderEffect.createColorFilterEffect(filter, blur)
|
|
1084
|
-
+ val effect = if (abs(saturation - 1f) < SATURATION_EPSILON) {
|
|
1085
|
-
+ blur
|
|
1086
|
-
} else {
|
|
1087
|
-
- RenderEffect.createColorFilterEffect(filter)
|
|
1088
|
-
+ val filter = ColorMatrixColorFilter(ColorMatrix().apply { setSaturation(saturation) })
|
|
1089
|
-
+ if (blur != null) {
|
|
1090
|
-
+ RenderEffect.createColorFilterEffect(filter, blur).also { LiquidGlassPerfTelemetry.effectBuild() }
|
|
1091
|
-
+ } else {
|
|
1092
|
-
+ RenderEffect.createColorFilterEffect(filter).also { LiquidGlassPerfTelemetry.effectBuild() }
|
|
1093
|
-
+ }
|
|
1094
|
-
}
|
|
1095
|
-
+ cachedPrepBlur = blurRadiusPx
|
|
1096
|
-
+ cachedPrepSaturation = saturation
|
|
1097
|
-
+ cachedPrepEffect = effect
|
|
1098
|
-
+ cachedPrepValid = true
|
|
1099
|
-
+ return effect
|
|
1100
|
-
}
|
|
1101
|
-
|
|
1102
|
-
private fun inflateMargin(frame: GlassFrame): Float =
|
|
1103
|
-
- frame.blurRadiusPx * 2f + abs(frame.refractionAmountPx) + 4f
|
|
1104
|
-
+ frame.blurRadiusPx * 2f + abs(frame.refractionAmountPx) + abs(frame.bodyRefractionAmountPx) + 4f
|
|
1105
|
-
|
|
1106
|
-
private fun shapePath(frame: GlassFrame): Path {
|
|
1107
|
-
clipPath.rewind()
|
|
1108
|
-
diff --git a/node_modules/liquid-glass-kit/android/src/main/java/expo/modules/liquidglass/ExpoLiquidGlassModule.kt b/node_modules/liquid-glass-kit/android/src/main/java/expo/modules/liquidglass/ExpoLiquidGlassModule.kt
|
|
1109
|
-
index fdbc794..c52e594 100644
|
|
1110
|
-
--- a/node_modules/liquid-glass-kit/android/src/main/java/expo/modules/liquidglass/ExpoLiquidGlassModule.kt
|
|
1111
|
-
+++ b/node_modules/liquid-glass-kit/android/src/main/java/expo/modules/liquidglass/ExpoLiquidGlassModule.kt
|
|
1112
|
-
@@ -36,12 +36,21 @@ class ExpoLiquidGlassModule : Module() {
|
|
1113
|
-
Prop("refractionAmount") { view: LiquidGlassExpoView, amount: Float? ->
|
|
1114
|
-
view.glass.refractionAmountDp = amount ?: 12f
|
|
1115
|
-
}
|
|
1116
|
-
+ Prop("bodyRefractionAmount") { view: LiquidGlassExpoView, amount: Float? ->
|
|
1117
|
-
+ view.glass.bodyRefractionAmountDp = amount ?: 2.5f
|
|
1118
|
-
+ }
|
|
1119
|
-
+ Prop("interactionProgress") { view: LiquidGlassExpoView, progress: Float? ->
|
|
1120
|
-
+ view.glass.interactionProgress = progress ?: 0f
|
|
1121
|
-
+ }
|
|
1122
|
-
Prop("saturation") { view: LiquidGlassExpoView, saturation: Float? ->
|
|
1123
|
-
view.glass.saturation = saturation ?: 1.5f
|
|
1124
|
-
}
|
|
1125
|
-
Prop("tint") { view: LiquidGlassExpoView, color: Int? ->
|
|
1126
|
-
view.glass.glassTintColor = color ?: 0
|
|
1127
|
-
}
|
|
1128
|
-
+ Prop("tintAlpha") { view: LiquidGlassExpoView, alpha: Float? ->
|
|
1129
|
-
+ view.glass.tintAlpha = alpha ?: 1f
|
|
1130
|
-
+ }
|
|
1131
|
-
Prop("chromaticAberration") { view: LiquidGlassExpoView, amount: Float? ->
|
|
1132
|
-
view.glass.chromaticAberration = (amount ?: 0f).coerceIn(0f, 1f)
|
|
1133
|
-
}
|
|
1134
|
-
@@ -51,6 +60,15 @@ class ExpoLiquidGlassModule : Module() {
|
|
1135
|
-
Prop("highlightAlpha") { view: LiquidGlassExpoView, alpha: Float? ->
|
|
1136
|
-
view.glass.highlightAlpha = (alpha ?: 0.45f).coerceIn(0f, 1f)
|
|
1137
|
-
}
|
|
1138
|
-
+ Prop("specularStrength") { view: LiquidGlassExpoView, strength: Float? ->
|
|
1139
|
-
+ view.glass.specularStrength = (strength ?: 1f).coerceIn(0f, 2f)
|
|
1140
|
-
+ }
|
|
1141
|
-
+ Prop("fresnelStrength") { view: LiquidGlassExpoView, strength: Float? ->
|
|
1142
|
-
+ view.glass.fresnelStrength = (strength ?: 0.85f).coerceIn(0f, 2f)
|
|
1143
|
-
+ }
|
|
1144
|
-
+ Prop("innerShadowStrength") { view: LiquidGlassExpoView, strength: Float? ->
|
|
1145
|
-
+ view.glass.innerShadowStrength = (strength ?: 0.18f).coerceIn(0f, 1f)
|
|
1146
|
-
+ }
|
|
1147
|
-
Prop("highlightWidth") { view: LiquidGlassExpoView, width: Float? ->
|
|
1148
|
-
view.glass.highlightWidthDp = width ?: 2f
|
|
1149
|
-
}
|
|
1150
|
-
@@ -60,6 +78,18 @@ class ExpoLiquidGlassModule : Module() {
|
|
1151
|
-
Prop("interactive") { view: LiquidGlassExpoView, interactive: Boolean? ->
|
|
1152
|
-
view.glass.isGlassInteractive = interactive ?: false
|
|
1153
|
-
}
|
|
1154
|
-
+ Prop("motionX") { view: LiquidGlassExpoView, motion: Float? ->
|
|
1155
|
-
+ view.glass.motionX = motion
|
|
1156
|
-
+ }
|
|
1157
|
-
+ Prop("motionY") { view: LiquidGlassExpoView, motion: Float? ->
|
|
1158
|
-
+ view.glass.motionY = motion
|
|
1159
|
-
+ }
|
|
1160
|
-
+ Prop("displacementOnlyDebug") { view: LiquidGlassExpoView, enabled: Boolean? ->
|
|
1161
|
-
+ view.glass.displacementOnlyDebug = enabled ?: false
|
|
1162
|
-
+ }
|
|
1163
|
-
+ Prop("continuous") { view: LiquidGlassExpoView, continuous: Boolean? ->
|
|
1164
|
-
+ view.glass.continuousBackdrop = continuous ?: false
|
|
1165
|
-
+ }
|
|
1166
|
-
}
|
|
1167
|
-
}
|
|
1168
|
-
}
|
|
1169
|
-
@@ -71,7 +101,6 @@ class LiquidGlassExpoView(
|
|
1170
|
-
|
|
1171
|
-
/** The embedded glass engine; props from JS are applied to it directly. */
|
|
1172
|
-
val glass = GlassViewController(this)
|
|
1173
|
-
-
|
|
1174
|
-
var providerId: String = "default"
|
|
1175
|
-
set(value) {
|
|
1176
|
-
if (field == value && glass.provider != null) return
|
|
1177
|
-
diff --git a/node_modules/liquid-glass-kit/android/src/main/java/expo/modules/liquidglass/ExpoLiquidGlassProviderModule.kt b/node_modules/liquid-glass-kit/android/src/main/java/expo/modules/liquidglass/ExpoLiquidGlassProviderModule.kt
|
|
1178
|
-
index f1f9584..e5a8077 100644
|
|
1179
|
-
--- a/node_modules/liquid-glass-kit/android/src/main/java/expo/modules/liquidglass/ExpoLiquidGlassProviderModule.kt
|
|
1180
|
-
+++ b/node_modules/liquid-glass-kit/android/src/main/java/expo/modules/liquidglass/ExpoLiquidGlassProviderModule.kt
|
|
1181
|
-
@@ -1,15 +1,32 @@
|
|
1182
|
-
package expo.modules.liquidglass
|
|
1183
|
-
|
|
1184
|
-
import android.content.Context
|
|
1185
|
-
+import android.graphics.Bitmap
|
|
1186
|
-
import android.graphics.Canvas
|
|
1187
|
-
+import android.graphics.ColorSpace
|
|
1188
|
-
+import android.graphics.HardwareBufferRenderer
|
|
1189
|
-
+import android.graphics.RenderEffect
|
|
1190
|
-
+import android.graphics.Rect
|
|
1191
|
-
import android.graphics.RenderNode
|
|
1192
|
-
+import android.graphics.Shader
|
|
1193
|
-
+import android.hardware.HardwareBuffer
|
|
1194
|
-
+import android.os.Handler
|
|
1195
|
-
+import android.os.Looper
|
|
1196
|
-
+import android.os.Build
|
|
1197
|
-
+import android.os.SystemClock
|
|
1198
|
-
import android.view.View
|
|
1199
|
-
+import android.view.ViewGroup
|
|
1200
|
-
+import android.view.ViewTreeObserver
|
|
1201
|
-
import dev.liquidglass.view.BackdropRecorder
|
|
1202
|
-
import dev.liquidglass.view.LiquidGlassBackdropSource
|
|
1203
|
-
import expo.modules.kotlin.AppContext
|
|
1204
|
-
import expo.modules.kotlin.modules.Module
|
|
1205
|
-
import expo.modules.kotlin.modules.ModuleDefinition
|
|
1206
|
-
import expo.modules.kotlin.views.ExpoView
|
|
1207
|
-
+import expo.modules.kotlin.viewevent.EventDispatcher
|
|
1208
|
-
+import java.util.IdentityHashMap
|
|
1209
|
-
+import java.time.Duration
|
|
1210
|
-
+import java.util.concurrent.Executors
|
|
1211
|
-
|
|
1212
|
-
/**
|
|
1213
|
-
* Native side of `<LiquidGlassProvider>`: hosts the React Native children that
|
|
1214
|
-
@@ -21,9 +38,33 @@ class ExpoLiquidGlassProviderModule : Module() {
|
|
1215
|
-
Name("ExpoLiquidGlassProvider")
|
|
1216
|
-
|
|
1217
|
-
View(LiquidGlassProviderExpoView::class) {
|
|
1218
|
-
+ Events("onSnapshotReady")
|
|
1219
|
-
Prop("providerId") { view: LiquidGlassProviderExpoView, id: String ->
|
|
1220
|
-
view.providerId = id
|
|
1221
|
-
}
|
|
1222
|
-
+ Prop("underlayProviderId") { view: LiquidGlassProviderExpoView, id: String? ->
|
|
1223
|
-
+ view.underlayProviderId = id
|
|
1224
|
-
+ }
|
|
1225
|
-
+ Prop("captureMode") { view: LiquidGlassProviderExpoView, mode: String? ->
|
|
1226
|
-
+ view.captureMode = mode ?: "live"
|
|
1227
|
-
+ }
|
|
1228
|
-
+ Prop("snapshotBlurRadiusDp") { view: LiquidGlassProviderExpoView, radius: Float? ->
|
|
1229
|
-
+ view.snapshotBlurRadiusDp = radius ?: 0f
|
|
1230
|
-
+ }
|
|
1231
|
-
+ Prop("sourceRevision") { view: LiquidGlassProviderExpoView, revision: String? ->
|
|
1232
|
-
+ view.sourceRevision = revision
|
|
1233
|
-
+ }
|
|
1234
|
-
+ }
|
|
1235
|
-
+
|
|
1236
|
-
+ Function("setPerformanceTelemetryEnabled") { enabled: Boolean ->
|
|
1237
|
-
+ LiquidGlassPerfTelemetry.setEnabled(enabled)
|
|
1238
|
-
+ if (enabled) {
|
|
1239
|
-
+ val refreshRate = appContext.currentActivity?.window?.decorView?.display?.refreshRate ?: 0f
|
|
1240
|
-
+ LiquidGlassPerfTelemetry.displayRefreshRate(refreshRate)
|
|
1241
|
-
+ }
|
|
1242
|
-
+ }
|
|
1243
|
-
+ AsyncFunction("getPerformanceStats") {
|
|
1244
|
-
+ LiquidGlassPerfTelemetry.snapshot()
|
|
1245
|
-
}
|
|
1246
|
-
}
|
|
1247
|
-
}
|
|
1248
|
-
@@ -33,7 +74,98 @@ class LiquidGlassProviderExpoView(
|
|
1249
|
-
appContext: AppContext,
|
|
1250
|
-
) : ExpoView(context, appContext), LiquidGlassBackdropSource {
|
|
1251
|
-
|
|
1252
|
-
+ private val onSnapshotReady by EventDispatcher<Unit>()
|
|
1253
|
-
+
|
|
1254
|
-
private val recorder = BackdropRecorder()
|
|
1255
|
-
+ private var frozenBlurNode: RenderNode? = null
|
|
1256
|
-
+ private var frozenSnapshotNode: RenderNode? = null
|
|
1257
|
-
+ private var frozenSnapshotBitmap: Bitmap? = null
|
|
1258
|
-
+ private var frozenSnapshotBuffer: HardwareBuffer? = null
|
|
1259
|
-
+ private var snapshotGeneration = 0L
|
|
1260
|
-
+ private var snapshotRenderPending = false
|
|
1261
|
-
+ private val mainHandler = Handler(Looper.getMainLooper())
|
|
1262
|
-
+ private val snapshotExecutor = Executors.newSingleThreadExecutor { task ->
|
|
1263
|
-
+ Thread(task, "LiquidGlassSnapshotFence").apply { isDaemon = true }
|
|
1264
|
-
+ }
|
|
1265
|
-
+ var underlayProviderId: String? = null
|
|
1266
|
-
+ private val drawBackdropContent: (Canvas) -> Unit = { target -> dispatchBackdropContent(target) }
|
|
1267
|
-
+ private val consumerBounds = IdentityHashMap<View, Rect>()
|
|
1268
|
-
+ private val scrollTargets = IdentityHashMap<View, IntArray>()
|
|
1269
|
-
+ private val sourceLocation = IntArray(2)
|
|
1270
|
-
+ private val consumerLocation = IntArray(2)
|
|
1271
|
-
+ private val settleScrollCapture = Runnable {
|
|
1272
|
-
+ if (captureMode == "live" && recorder.hasConsumers) requestCapture()
|
|
1273
|
-
+ }
|
|
1274
|
-
+ private val layoutListener = View.OnLayoutChangeListener { view, _, _, _, _, _, _, _, _ ->
|
|
1275
|
-
+ updateConsumerBounds(view)
|
|
1276
|
-
+ }
|
|
1277
|
-
+ private val scrollChangedListener = ViewTreeObserver.OnScrollChangedListener {
|
|
1278
|
-
+ if (!recorder.hasConsumers) return@OnScrollChangedListener
|
|
1279
|
-
+ // A route may register its first backdrop consumer before a virtualized
|
|
1280
|
-
+ // list has mounted enough cells to report that it can scroll. Keep the
|
|
1281
|
-
+ // one route-level listener attached and discover scroll targets on the
|
|
1282
|
-
+ // first subsequent scroll notification instead of permanently missing
|
|
1283
|
-
+ // that list.
|
|
1284
|
-
+ if (scrollTargets.isEmpty()) refreshScrollTargets()
|
|
1285
|
-
+ if (hasTrackedScrollMoved()) {
|
|
1286
|
-
+ lastScrollReuseUptimeMs = SystemClock.uptimeMillis()
|
|
1287
|
-
+ LiquidGlassPerfTelemetry.sourceContentDirty()
|
|
1288
|
-
+ LiquidGlassPerfTelemetry.routeScrollReuse()
|
|
1289
|
-
+ recorder.invalidateConsumers()
|
|
1290
|
-
+ mainHandler.removeCallbacks(settleScrollCapture)
|
|
1291
|
-
+ mainHandler.postDelayed(settleScrollCapture, 200L)
|
|
1292
|
-
+ }
|
|
1293
|
-
+ }
|
|
1294
|
-
+ private var backdropDirty = false
|
|
1295
|
-
+ private var observingScroll = false
|
|
1296
|
-
+ private var oneShotCaptured = false
|
|
1297
|
-
+ private var lastScrollReuseUptimeMs = 0L
|
|
1298
|
-
+ var snapshotBlurRadiusDp: Float = 0f
|
|
1299
|
-
+ set(value) {
|
|
1300
|
-
+ if (field == value) return
|
|
1301
|
-
+ field = value.coerceAtLeast(0f)
|
|
1302
|
-
+ if (captureMode == "oneShot") {
|
|
1303
|
-
+ oneShotCaptured = false
|
|
1304
|
-
+ invalidateFrozenSnapshot()
|
|
1305
|
-
+ requestCapture()
|
|
1306
|
-
+ }
|
|
1307
|
-
+ }
|
|
1308
|
-
+ var captureMode: String = "live"
|
|
1309
|
-
+ set(value) {
|
|
1310
|
-
+ if (field == value) return
|
|
1311
|
-
+ field = value
|
|
1312
|
-
+ if (value == "oneShot") {
|
|
1313
|
-
+ oneShotCaptured = false
|
|
1314
|
-
+ invalidateFrozenSnapshot()
|
|
1315
|
-
+ updateScrollObservation()
|
|
1316
|
-
+ requestCapture()
|
|
1317
|
-
+ } else if (value == "frozen") {
|
|
1318
|
-
+ mainHandler.removeCallbacks(settleScrollCapture)
|
|
1319
|
-
+ scrollTargets.clear()
|
|
1320
|
-
+ updateScrollObservation()
|
|
1321
|
-
+ } else if (value == "static") {
|
|
1322
|
-
+ mainHandler.removeCallbacks(settleScrollCapture)
|
|
1323
|
-
+ scrollTargets.clear()
|
|
1324
|
-
+ updateScrollObservation()
|
|
1325
|
-
+ if (width > 0 && height > 0 && !recorder.hasRecording) requestCapture()
|
|
1326
|
-
+ } else if (value == "live") {
|
|
1327
|
-
+ oneShotCaptured = false
|
|
1328
|
-
+ invalidateFrozenSnapshot()
|
|
1329
|
-
+ if (recorder.hasConsumers) refreshScrollTargets()
|
|
1330
|
-
+ updateScrollObservation()
|
|
1331
|
-
+ if (recorder.hasConsumers) requestCapture()
|
|
1332
|
-
+ }
|
|
1333
|
-
+ }
|
|
1334
|
-
+ var sourceRevision: String? = null
|
|
1335
|
-
+ set(value) {
|
|
1336
|
-
+ if (field == value) return
|
|
1337
|
-
+ field = value
|
|
1338
|
-
+ if (captureMode == "oneShot") {
|
|
1339
|
-
+ oneShotCaptured = false
|
|
1340
|
-
+ invalidateFrozenSnapshot()
|
|
1341
|
-
+ }
|
|
1342
|
-
+ requestCapture()
|
|
1343
|
-
+ }
|
|
1344
|
-
|
|
1345
|
-
var providerId: String = "default"
|
|
1346
|
-
set(value) {
|
|
1347
|
-
@@ -49,28 +181,404 @@ class LiquidGlassProviderExpoView(
|
|
1348
|
-
get() = this
|
|
1349
|
-
|
|
1350
|
-
override val contentRenderNode: RenderNode?
|
|
1351
|
-
- get() = recorder.contentNode
|
|
1352
|
-
+ get() = frozenSnapshotNode ?: frozenBlurNode ?: recorder.contentNode
|
|
1353
|
-
|
|
1354
|
-
override val hasRecording: Boolean
|
|
1355
|
-
get() = recorder.hasRecording
|
|
1356
|
-
|
|
1357
|
-
- override fun registerConsumer(consumer: View) = recorder.register(consumer)
|
|
1358
|
-
+ // The recorder holds the full scene, so a moved glass view only needs new
|
|
1359
|
-
+ // sampling coordinates and never requests another full-scene recording.
|
|
1360
|
-
+ override val requiresCaptureOnConsumerMovement: Boolean
|
|
1361
|
-
+ get() = false
|
|
1362
|
-
+
|
|
1363
|
-
+ override val recordedOriginX: Int
|
|
1364
|
-
+ get() = recorder.originX
|
|
1365
|
-
+
|
|
1366
|
-
+ override val recordedOriginY: Int
|
|
1367
|
-
+ get() = recorder.originY
|
|
1368
|
-
+
|
|
1369
|
-
+ override fun registerConsumer(consumer: View) {
|
|
1370
|
-
+ val hadRecording = recorder.hasRecording
|
|
1371
|
-
+ recorder.register(consumer)
|
|
1372
|
-
+ if (!consumerBounds.containsKey(consumer)) consumer.addOnLayoutChangeListener(layoutListener)
|
|
1373
|
-
+ updateConsumerBounds(consumer)
|
|
1374
|
-
+ if (captureMode == "live" && (!hadRecording || scrollTargets.isEmpty())) refreshScrollTargets()
|
|
1375
|
-
+ updateScrollObservation()
|
|
1376
|
-
+ if (!hadRecording) {
|
|
1377
|
-
+ if (captureMode == "frozen") captureMode = "oneShot" else requestCapture()
|
|
1378
|
-
+ }
|
|
1379
|
-
+ }
|
|
1380
|
-
+
|
|
1381
|
-
+ override fun unregisterConsumer(consumer: View) {
|
|
1382
|
-
+ recorder.unregister(consumer)
|
|
1383
|
-
+ consumer.removeOnLayoutChangeListener(layoutListener)
|
|
1384
|
-
+ consumerBounds.remove(consumer)
|
|
1385
|
-
+ reportProviderGeometry()
|
|
1386
|
-
+ if (!recorder.hasConsumers) {
|
|
1387
|
-
+ updateScrollObservation()
|
|
1388
|
-
+ scrollTargets.clear()
|
|
1389
|
-
+ if (captureMode != "static") {
|
|
1390
|
-
+ backdropDirty = false
|
|
1391
|
-
+ recorder.release()
|
|
1392
|
-
+ LiquidGlassPerfTelemetry.removeProviderGeometry(providerId)
|
|
1393
|
-
+ }
|
|
1394
|
-
+ } else {
|
|
1395
|
-
+ reportProviderGeometry()
|
|
1396
|
-
+ }
|
|
1397
|
-
+ }
|
|
1398
|
-
+
|
|
1399
|
-
+ override fun onConsumerGeometryChanged(consumer: View) {
|
|
1400
|
-
+ // Geometry is read only after the existing glass controller detects a
|
|
1401
|
-
+ // move. No pre-draw hook or per-frame ancestor traversal is installed.
|
|
1402
|
-
+ updateConsumerBounds(consumer)
|
|
1403
|
-
+ }
|
|
1404
|
-
+
|
|
1405
|
-
+ override fun requestCaptureFrame() {
|
|
1406
|
-
+ requestCapture()
|
|
1407
|
-
+ }
|
|
1408
|
-
+
|
|
1409
|
-
+ override fun onDescendantInvalidated(child: View, target: View) {
|
|
1410
|
-
+ if (captureMode == "live" || captureMode == "static" || (captureMode == "oneShot" && !oneShotCaptured)) {
|
|
1411
|
-
+ LiquidGlassPerfTelemetry.sourceContentDirty()
|
|
1412
|
-
+ val nestedScrollNodeChanged = captureMode == "live" &&
|
|
1413
|
-
+ SystemClock.uptimeMillis() - lastScrollReuseUptimeMs <= 200L
|
|
1414
|
-
+ if (nestedScrollNodeChanged) {
|
|
1415
|
-
+ LiquidGlassPerfTelemetry.routeScrollReuse()
|
|
1416
|
-
+ recorder.invalidateConsumers()
|
|
1417
|
-
+ } else {
|
|
1418
|
-
+ requestCapture()
|
|
1419
|
-
+ }
|
|
1420
|
-
+ }
|
|
1421
|
-
+ super.onDescendantInvalidated(child, target)
|
|
1422
|
-
+ }
|
|
1423
|
-
|
|
1424
|
-
- override fun unregisterConsumer(consumer: View) = recorder.unregister(consumer)
|
|
1425
|
-
+ override fun onSizeChanged(width: Int, height: Int, oldWidth: Int, oldHeight: Int) {
|
|
1426
|
-
+ if ((captureMode == "live" || captureMode == "static" || (captureMode == "oneShot" && !oneShotCaptured)) && width > 0 && height > 0) {
|
|
1427
|
-
+ if (captureMode == "live" && scrollTargets.isEmpty()) refreshScrollTargets()
|
|
1428
|
-
+ updateScrollObservation()
|
|
1429
|
-
+ requestCapture()
|
|
1430
|
-
+ }
|
|
1431
|
-
+ super.onSizeChanged(width, height, oldWidth, oldHeight)
|
|
1432
|
-
+ }
|
|
1433
|
-
|
|
1434
|
-
override fun dispatchDraw(canvas: Canvas) {
|
|
1435
|
-
- recorder.drawRecorded(canvas, width, height) { target ->
|
|
1436
|
-
- super.dispatchDraw(target)
|
|
1437
|
-
+ LiquidGlassPerfTelemetry.routeDraw()
|
|
1438
|
-
+ if (!recorder.hasConsumers && captureMode != "static" && captureMode != "oneShot") {
|
|
1439
|
-
+ LiquidGlassPerfTelemetry.routeTreeTraversal()
|
|
1440
|
-
+ super.dispatchDraw(canvas)
|
|
1441
|
-
+ return
|
|
1442
|
-
+ }
|
|
1443
|
-
+
|
|
1444
|
-
+ val shouldRecord = backdropDirty || !recorder.hasRecording
|
|
1445
|
-
+ if (shouldRecord) {
|
|
1446
|
-
+ backdropDirty = false
|
|
1447
|
-
+ if (Build.VERSION.SDK_INT >= 29 && canvas.isHardwareAccelerated && width > 0 && height > 0) {
|
|
1448
|
-
+ LiquidGlassPerfTelemetry.backdropCapture(width, height)
|
|
1449
|
-
+ LiquidGlassPerfTelemetry.routeRenderNodeRecord()
|
|
1450
|
-
+ }
|
|
1451
|
-
+ }
|
|
1452
|
-
+ val shared = recorder.drawShared(canvas, width, height, shouldRecord, drawBackdropContent)
|
|
1453
|
-
+ if (captureMode == "oneShot" && shouldRecord) {
|
|
1454
|
-
+ oneShotCaptured = true
|
|
1455
|
-
+ recordFrozenSnapshot()
|
|
1456
|
-
+ }
|
|
1457
|
-
+ if (captureMode == "oneShot" && oneShotCaptured) {
|
|
1458
|
-
+ val frozen = frozenSnapshotNode ?: frozenBlurNode
|
|
1459
|
-
+ if (frozen?.hasDisplayList() == true) canvas.drawRenderNode(frozen)
|
|
1460
|
-
+ }
|
|
1461
|
-
+ if (shared) LiquidGlassPerfTelemetry.routeScreenComposite()
|
|
1462
|
-
+ }
|
|
1463
|
-
+
|
|
1464
|
-
+ private fun dispatchBackdropContent(target: Canvas) {
|
|
1465
|
-
+ LiquidGlassPerfTelemetry.routeTreeTraversal()
|
|
1466
|
-
+ super.dispatchDraw(target)
|
|
1467
|
-
+ }
|
|
1468
|
-
+
|
|
1469
|
-
+ private fun recordFrozenSnapshot() {
|
|
1470
|
-
+ LiquidGlassPerfTelemetry.frozenSnapshotRequested()
|
|
1471
|
-
+ val source = recorder.contentNode ?: run {
|
|
1472
|
-
+ LiquidGlassPerfTelemetry.frozenSnapshotFailed()
|
|
1473
|
-
+ onSnapshotReady(Unit)
|
|
1474
|
-
+ return
|
|
1475
|
-
+ }
|
|
1476
|
-
+ val radiusPx = snapshotBlurRadiusDp * resources.displayMetrics.density.coerceAtLeast(1f)
|
|
1477
|
-
+ if (Build.VERSION.SDK_INT < 34 || radiusPx <= 0f || width <= 0 || height <= 0 || !source.hasDisplayList()) {
|
|
1478
|
-
+ recordFrozenBlurNode(source, radiusPx)
|
|
1479
|
-
+ onSnapshotReady(Unit)
|
|
1480
|
-
+ return
|
|
1481
|
-
+ }
|
|
1482
|
-
+ if (snapshotRenderPending) return
|
|
1483
|
-
+
|
|
1484
|
-
+ snapshotRenderPending = true
|
|
1485
|
-
+ val generation = ++snapshotGeneration
|
|
1486
|
-
+ val snapshotWidth = width
|
|
1487
|
-
+ val snapshotHeight = height
|
|
1488
|
-
+ val renderRoot = RenderNode("LiquidGlassFrozenRouteSource")
|
|
1489
|
-
+ renderRoot.setPosition(0, 0, snapshotWidth, snapshotHeight)
|
|
1490
|
-
+ renderRoot.setRenderEffect(
|
|
1491
|
-
+ RenderEffect.createBlurEffect(radiusPx, radiusPx, Shader.TileMode.CLAMP),
|
|
1492
|
-
+ )
|
|
1493
|
-
+ val recording = renderRoot.beginRecording(snapshotWidth, snapshotHeight)
|
|
1494
|
-
+ try {
|
|
1495
|
-
+ val underlay = underlayProviderId?.let { LiquidGlassRegistry.provider(it)?.contentRenderNode }
|
|
1496
|
-
+ if (underlay?.hasDisplayList() == true) recording.drawRenderNode(underlay)
|
|
1497
|
-
+ recording.drawRenderNode(source)
|
|
1498
|
-
+ } finally {
|
|
1499
|
-
+ renderRoot.endRecording()
|
|
1500
|
-
+ }
|
|
1501
|
-
+
|
|
1502
|
-
+ val buffer = try {
|
|
1503
|
-
+ HardwareBuffer.create(
|
|
1504
|
-
+ snapshotWidth,
|
|
1505
|
-
+ snapshotHeight,
|
|
1506
|
-
+ HardwareBuffer.RGBA_8888,
|
|
1507
|
-
+ 1,
|
|
1508
|
-
+ HardwareBuffer.USAGE_GPU_COLOR_OUTPUT or HardwareBuffer.USAGE_GPU_SAMPLED_IMAGE,
|
|
1509
|
-
+ )
|
|
1510
|
-
+ } catch (_: Throwable) {
|
|
1511
|
-
+ snapshotRenderPending = false
|
|
1512
|
-
+ LiquidGlassPerfTelemetry.frozenSnapshotFailed()
|
|
1513
|
-
+ recordFrozenBlurNode(source, radiusPx)
|
|
1514
|
-
+ onSnapshotReady(Unit)
|
|
1515
|
-
+ return
|
|
1516
|
-
+ }
|
|
1517
|
-
+ val renderer = try {
|
|
1518
|
-
+ HardwareBufferRenderer(buffer).apply { setContentRoot(renderRoot) }
|
|
1519
|
-
+ } catch (_: Throwable) {
|
|
1520
|
-
+ buffer.close()
|
|
1521
|
-
+ snapshotRenderPending = false
|
|
1522
|
-
+ LiquidGlassPerfTelemetry.frozenSnapshotFailed()
|
|
1523
|
-
+ recordFrozenBlurNode(source, radiusPx)
|
|
1524
|
-
+ onSnapshotReady(Unit)
|
|
1525
|
-
+ return
|
|
1526
|
-
+ }
|
|
1527
|
-
+
|
|
1528
|
-
+ try {
|
|
1529
|
-
+ renderer.obtainRenderRequest()
|
|
1530
|
-
+ .setColorSpace(ColorSpace.get(ColorSpace.Named.SRGB))
|
|
1531
|
-
+ .draw(snapshotExecutor) { result ->
|
|
1532
|
-
+ val fence = result.fence
|
|
1533
|
-
+ val success = try {
|
|
1534
|
-
+ result.status == HardwareBufferRenderer.RenderResult.SUCCESS &&
|
|
1535
|
-
+ fence?.await(Duration.ofSeconds(2)) == true
|
|
1536
|
-
+ } catch (_: Throwable) {
|
|
1537
|
-
+ false
|
|
1538
|
-
+ } finally {
|
|
1539
|
-
+ try {
|
|
1540
|
-
+ fence?.close()
|
|
1541
|
-
+ } catch (_: Throwable) {
|
|
1542
|
-
+ // Fence ownership is transferred with the render result.
|
|
1543
|
-
+ }
|
|
1544
|
-
+ }
|
|
1545
|
-
+ renderer.close()
|
|
1546
|
-
+ if (!success) {
|
|
1547
|
-
+ buffer.close()
|
|
1548
|
-
+ LiquidGlassPerfTelemetry.frozenSnapshotFailed()
|
|
1549
|
-
+ mainHandler.post {
|
|
1550
|
-
+ if (generation == snapshotGeneration && captureMode == "oneShot") {
|
|
1551
|
-
+ snapshotRenderPending = false
|
|
1552
|
-
+ recordFrozenBlurNode(source, radiusPx)
|
|
1553
|
-
+ onSnapshotReady(Unit)
|
|
1554
|
-
+ }
|
|
1555
|
-
+ }
|
|
1556
|
-
+ return@draw
|
|
1557
|
-
+ }
|
|
1558
|
-
+
|
|
1559
|
-
+ mainHandler.post {
|
|
1560
|
-
+ if (generation != snapshotGeneration || captureMode != "oneShot") {
|
|
1561
|
-
+ buffer.close()
|
|
1562
|
-
+ return@post
|
|
1563
|
-
+ }
|
|
1564
|
-
+ val bitmap = try {
|
|
1565
|
-
+ Bitmap.wrapHardwareBuffer(buffer, ColorSpace.get(ColorSpace.Named.SRGB))
|
|
1566
|
-
+ } catch (_: Throwable) {
|
|
1567
|
-
+ null
|
|
1568
|
-
+ }
|
|
1569
|
-
+ if (bitmap == null) {
|
|
1570
|
-
+ buffer.close()
|
|
1571
|
-
+ snapshotRenderPending = false
|
|
1572
|
-
+ LiquidGlassPerfTelemetry.frozenSnapshotFailed()
|
|
1573
|
-
+ recordFrozenBlurNode(source, radiusPx)
|
|
1574
|
-
+ onSnapshotReady(Unit)
|
|
1575
|
-
+ return@post
|
|
1576
|
-
+ }
|
|
1577
|
-
+
|
|
1578
|
-
+ val node = RenderNode("LiquidGlassFrozenRouteSnapshot")
|
|
1579
|
-
+ node.setPosition(0, 0, snapshotWidth, snapshotHeight)
|
|
1580
|
-
+ val nodeCanvas = node.beginRecording(snapshotWidth, snapshotHeight)
|
|
1581
|
-
+ nodeCanvas.drawBitmap(bitmap, 0f, 0f, null)
|
|
1582
|
-
+ node.endRecording()
|
|
1583
|
-
+ // HardwareBufferRenderer has already rasterized the
|
|
1584
|
-
+ // fixed HWUI blur into this one-shot snapshot.
|
|
1585
|
-
+ clearFrozenSnapshotContents()
|
|
1586
|
-
+ frozenSnapshotNode = node
|
|
1587
|
-
+ frozenSnapshotBitmap = bitmap
|
|
1588
|
-
+ frozenSnapshotBuffer = buffer
|
|
1589
|
-
+ frozenBlurNode = null
|
|
1590
|
-
+ snapshotRenderPending = false
|
|
1591
|
-
+ LiquidGlassPerfTelemetry.frozenSnapshotBlurRecorded()
|
|
1592
|
-
+ recorder.invalidateConsumers()
|
|
1593
|
-
+ invalidate()
|
|
1594
|
-
+ onSnapshotReady(Unit)
|
|
1595
|
-
+ }
|
|
1596
|
-
+ }
|
|
1597
|
-
+ } catch (_: Throwable) {
|
|
1598
|
-
+ renderer.close()
|
|
1599
|
-
+ buffer.close()
|
|
1600
|
-
+ snapshotRenderPending = false
|
|
1601
|
-
+ LiquidGlassPerfTelemetry.frozenSnapshotFailed()
|
|
1602
|
-
+ recordFrozenBlurNode(source, radiusPx)
|
|
1603
|
-
+ onSnapshotReady(Unit)
|
|
1604
|
-
+ }
|
|
1605
|
-
+ }
|
|
1606
|
-
+
|
|
1607
|
-
+ private fun recordFrozenBlurNode(source: RenderNode, radiusPx: Float) {
|
|
1608
|
-
+ frozenBlurNode?.discardDisplayList()
|
|
1609
|
-
+ frozenBlurNode = null
|
|
1610
|
-
+ if (Build.VERSION.SDK_INT < 31 || radiusPx <= 0f || width <= 0 || height <= 0 || !source.hasDisplayList()) return
|
|
1611
|
-
+ val node = RenderNode("LiquidGlassFrozenRouteBlurFallback")
|
|
1612
|
-
+ node.setPosition(0, 0, width, height)
|
|
1613
|
-
+ val recording = node.beginRecording(width, height)
|
|
1614
|
-
+ try {
|
|
1615
|
-
+ val underlay = underlayProviderId?.let { LiquidGlassRegistry.provider(it)?.contentRenderNode }
|
|
1616
|
-
+ if (underlay?.hasDisplayList() == true) recording.drawRenderNode(underlay)
|
|
1617
|
-
+ recording.drawRenderNode(source)
|
|
1618
|
-
+ } finally {
|
|
1619
|
-
+ node.endRecording()
|
|
1620
|
-
+ }
|
|
1621
|
-
+ node.setRenderEffect(RenderEffect.createBlurEffect(radiusPx, radiusPx, Shader.TileMode.CLAMP))
|
|
1622
|
-
+ frozenBlurNode = node
|
|
1623
|
-
+ LiquidGlassPerfTelemetry.frozenSnapshotBlurRecorded()
|
|
1624
|
-
+ }
|
|
1625
|
-
+
|
|
1626
|
-
+ private fun invalidateFrozenSnapshot() {
|
|
1627
|
-
+ snapshotGeneration += 1
|
|
1628
|
-
+ snapshotRenderPending = false
|
|
1629
|
-
+ clearFrozenSnapshotContents()
|
|
1630
|
-
+ }
|
|
1631
|
-
+
|
|
1632
|
-
+ private fun clearFrozenSnapshotContents() {
|
|
1633
|
-
+ frozenSnapshotNode?.discardDisplayList()
|
|
1634
|
-
+ frozenSnapshotNode = null
|
|
1635
|
-
+ frozenSnapshotBitmap?.recycle()
|
|
1636
|
-
+ frozenSnapshotBitmap = null
|
|
1637
|
-
+ try {
|
|
1638
|
-
+ frozenSnapshotBuffer?.close()
|
|
1639
|
-
+ } catch (_: Throwable) {
|
|
1640
|
-
+ // The HardwareBuffer can be released by Bitmap when its display list is discarded.
|
|
1641
|
-
+ }
|
|
1642
|
-
+ frozenSnapshotBuffer = null
|
|
1643
|
-
+ frozenBlurNode?.discardDisplayList()
|
|
1644
|
-
+ frozenBlurNode = null
|
|
1645
|
-
+ }
|
|
1646
|
-
+
|
|
1647
|
-
+ private fun updateConsumerBounds(consumer: View) {
|
|
1648
|
-
+ if (consumer.width <= 0 || consumer.height <= 0 || width <= 0 || height <= 0) return
|
|
1649
|
-
+ consumer.getLocationInWindow(consumerLocation)
|
|
1650
|
-
+ getLocationInWindow(sourceLocation)
|
|
1651
|
-
+ val density = resources.displayMetrics.density.coerceAtLeast(1f)
|
|
1652
|
-
+ val margin = (48f * density).toInt()
|
|
1653
|
-
+ val next = Rect(
|
|
1654
|
-
+ consumerLocation[0] - sourceLocation[0] - margin,
|
|
1655
|
-
+ consumerLocation[1] - sourceLocation[1] - margin,
|
|
1656
|
-
+ consumerLocation[0] - sourceLocation[0] + consumer.width + margin,
|
|
1657
|
-
+ consumerLocation[1] - sourceLocation[1] + consumer.height + margin,
|
|
1658
|
-
+ ).apply {
|
|
1659
|
-
+ left = left.coerceIn(0, width)
|
|
1660
|
-
+ top = top.coerceIn(0, height)
|
|
1661
|
-
+ right = right.coerceIn(0, width)
|
|
1662
|
-
+ bottom = bottom.coerceIn(0, height)
|
|
1663
|
-
+ }
|
|
1664
|
-
+ val previous = consumerBounds[consumer]
|
|
1665
|
-
+ if (previous == next) return
|
|
1666
|
-
+ consumerBounds[consumer] = next
|
|
1667
|
-
+ reportProviderGeometry()
|
|
1668
|
-
+ }
|
|
1669
|
-
+
|
|
1670
|
-
+ private fun reportProviderGeometry() {
|
|
1671
|
-
+ if (LiquidGlassPerfTelemetry.isEnabled()) {
|
|
1672
|
-
+ LiquidGlassPerfTelemetry.updateProviderGeometry(providerId, width, height, consumerBounds.values)
|
|
1673
|
-
+ }
|
|
1674
|
-
+ }
|
|
1675
|
-
+
|
|
1676
|
-
+ private fun requestCapture() {
|
|
1677
|
-
+ if (captureMode == "frozen" || (captureMode == "oneShot" && oneShotCaptured)) return
|
|
1678
|
-
+ if ((!recorder.hasConsumers && captureMode != "static" && captureMode != "oneShot") || backdropDirty) return
|
|
1679
|
-
+ backdropDirty = true
|
|
1680
|
-
+ LiquidGlassPerfTelemetry.backdropRequest()
|
|
1681
|
-
+ LiquidGlassPerfTelemetry.captureScheduled()
|
|
1682
|
-
+ postInvalidateOnAnimation()
|
|
1683
|
-
+ }
|
|
1684
|
-
+
|
|
1685
|
-
+ private fun updateScrollObservation() {
|
|
1686
|
-
+ val shouldObserve = captureMode == "live" && recorder.hasConsumers && isAttachedToWindow
|
|
1687
|
-
+ if (shouldObserve && !observingScroll) {
|
|
1688
|
-
+ val observer = viewTreeObserver
|
|
1689
|
-
+ if (observer.isAlive) {
|
|
1690
|
-
+ observer.addOnScrollChangedListener(scrollChangedListener)
|
|
1691
|
-
+ observingScroll = true
|
|
1692
|
-
+ }
|
|
1693
|
-
+ } else if (!shouldObserve && observingScroll) {
|
|
1694
|
-
+ val observer = viewTreeObserver
|
|
1695
|
-
+ if (observer.isAlive) observer.removeOnScrollChangedListener(scrollChangedListener)
|
|
1696
|
-
+ observingScroll = false
|
|
1697
|
-
+ }
|
|
1698
|
-
+ }
|
|
1699
|
-
+
|
|
1700
|
-
+ private fun refreshScrollTargets() {
|
|
1701
|
-
+ scrollTargets.clear()
|
|
1702
|
-
+ collectScrollTargets(this)
|
|
1703
|
-
+ }
|
|
1704
|
-
+
|
|
1705
|
-
+ private fun collectScrollTargets(view: View) {
|
|
1706
|
-
+ if (view !== this && (
|
|
1707
|
-
+ view.canScrollVertically(-1) || view.canScrollVertically(1) ||
|
|
1708
|
-
+ view.canScrollHorizontally(-1) || view.canScrollHorizontally(1)
|
|
1709
|
-
+ )) {
|
|
1710
|
-
+ scrollTargets[view] = intArrayOf(view.scrollX, view.scrollY)
|
|
1711
|
-
+ }
|
|
1712
|
-
+ if (view is ViewGroup) {
|
|
1713
|
-
+ for (index in 0 until view.childCount) collectScrollTargets(view.getChildAt(index))
|
|
1714
|
-
+ }
|
|
1715
|
-
+ }
|
|
1716
|
-
+
|
|
1717
|
-
+ private fun hasTrackedScrollMoved(): Boolean {
|
|
1718
|
-
+ var moved = false
|
|
1719
|
-
+ val iterator = scrollTargets.entries.iterator()
|
|
1720
|
-
+ while (iterator.hasNext()) {
|
|
1721
|
-
+ val (view, previous) = iterator.next()
|
|
1722
|
-
+ if (!view.isAttachedToWindow) {
|
|
1723
|
-
+ iterator.remove()
|
|
1724
|
-
+ continue
|
|
1725
|
-
+ }
|
|
1726
|
-
+ if (view.scrollX != previous[0] || view.scrollY != previous[1]) {
|
|
1727
|
-
+ previous[0] = view.scrollX
|
|
1728
|
-
+ previous[1] = view.scrollY
|
|
1729
|
-
+ moved = true
|
|
1730
|
-
+ }
|
|
1731
|
-
}
|
|
1732
|
-
+ if (scrollTargets.isEmpty()) updateScrollObservation()
|
|
1733
|
-
+ return moved
|
|
1734
|
-
}
|
|
1735
|
-
|
|
1736
|
-
override fun onAttachedToWindow() {
|
|
1737
|
-
super.onAttachedToWindow()
|
|
1738
|
-
LiquidGlassRegistry.registerProvider(providerId, this)
|
|
1739
|
-
+ if (captureMode == "oneShot") oneShotCaptured = false
|
|
1740
|
-
+ if (captureMode == "frozen" && recorder.hasConsumers && !recorder.hasRecording) captureMode = "oneShot"
|
|
1741
|
-
+ if ((captureMode == "static" || captureMode == "oneShot") && width > 0 && height > 0 && !recorder.hasRecording) requestCapture()
|
|
1742
|
-
+ if (captureMode == "live" && recorder.hasConsumers && scrollTargets.isEmpty()) refreshScrollTargets()
|
|
1743
|
-
+ updateScrollObservation()
|
|
1744
|
-
}
|
|
1745
|
-
|
|
1746
|
-
override fun onDetachedFromWindow() {
|
|
1747
|
-
LiquidGlassRegistry.unregisterProvider(providerId, this)
|
|
1748
|
-
+ mainHandler.removeCallbacks(settleScrollCapture)
|
|
1749
|
-
+ updateScrollObservation()
|
|
1750
|
-
+ LiquidGlassPerfTelemetry.removeProviderGeometry(providerId)
|
|
1751
|
-
+ backdropDirty = false
|
|
1752
|
-
+ oneShotCaptured = false
|
|
1753
|
-
+ invalidateFrozenSnapshot()
|
|
1754
|
-
recorder.release()
|
|
1755
|
-
super.onDetachedFromWindow()
|
|
1756
|
-
}
|
|
1757
|
-
diff --git a/node_modules/liquid-glass-kit/android/src/main/java/expo/modules/liquidglass/LiquidGlassPerfTelemetry.kt b/node_modules/liquid-glass-kit/android/src/main/java/expo/modules/liquidglass/LiquidGlassPerfTelemetry.kt
|
|
1758
|
-
new file mode 100644
|
|
1759
|
-
index 0000000..795f212
|
|
1760
|
-
--- /dev/null
|
|
1761
|
-
+++ b/node_modules/liquid-glass-kit/android/src/main/java/expo/modules/liquidglass/LiquidGlassPerfTelemetry.kt
|
|
1762
|
-
@@ -0,0 +1,240 @@
|
|
1763
|
-
+package expo.modules.liquidglass
|
|
1764
|
-
+
|
|
1765
|
-
+import android.os.Handler
|
|
1766
|
-
+import android.os.Looper
|
|
1767
|
-
+import android.util.Log
|
|
1768
|
-
+import android.graphics.Rect
|
|
1769
|
-
+import java.util.concurrent.atomic.AtomicLong
|
|
1770
|
-
+import java.util.concurrent.ConcurrentHashMap
|
|
1771
|
-
+
|
|
1772
|
-
+/** Opt-in, low-frequency native counters for the development benchmark route. */
|
|
1773
|
-
+internal object LiquidGlassPerfTelemetry {
|
|
1774
|
-
+
|
|
1775
|
-
+ @Volatile
|
|
1776
|
-
+ private var enabled = false
|
|
1777
|
-
+
|
|
1778
|
-
+ private val requests = AtomicLong()
|
|
1779
|
-
+ private val sourceContentDirties = AtomicLong()
|
|
1780
|
-
+ private val consumerGeometryDirties = AtomicLong()
|
|
1781
|
-
+ private val opticsDirties = AtomicLong()
|
|
1782
|
-
+ private val materialDirties = AtomicLong()
|
|
1783
|
-
+ private val captures = AtomicLong()
|
|
1784
|
-
+ private val capturedPixels = AtomicLong()
|
|
1785
|
-
+ private val skippedNoIntersection = AtomicLong()
|
|
1786
|
-
+ private val skippedAlreadyDirty = AtomicLong()
|
|
1787
|
-
+ private val captureSchedules = AtomicLong()
|
|
1788
|
-
+ private val consumerDraws = AtomicLong()
|
|
1789
|
-
+ private val effectBuilds = AtomicLong()
|
|
1790
|
-
+ private val geometryLookups = AtomicLong()
|
|
1791
|
-
+ private val routeDraws = AtomicLong()
|
|
1792
|
-
+ private val routeTreeTraversals = AtomicLong()
|
|
1793
|
-
+ private val routeRenderNodeRecords = AtomicLong()
|
|
1794
|
-
+ private val routeScreenComposites = AtomicLong()
|
|
1795
|
-
+ private val routeScrollReuses = AtomicLong()
|
|
1796
|
-
+ private val frozenSnapshotBlurRecords = AtomicLong()
|
|
1797
|
-
+ private val frozenSnapshotRequests = AtomicLong()
|
|
1798
|
-
+ private val frozenSnapshotFailures = AtomicLong()
|
|
1799
|
-
+ private val backdropSamples = AtomicLong()
|
|
1800
|
-
+ private val providerGeometry = ConcurrentHashMap<String, ProviderGeometry>()
|
|
1801
|
-
+ @Volatile private var displayRefreshRate = 0f
|
|
1802
|
-
+
|
|
1803
|
-
+ private data class ProviderGeometry(
|
|
1804
|
-
+ val width: Int,
|
|
1805
|
-
+ val height: Int,
|
|
1806
|
-
+ val rects: List<Rect>,
|
|
1807
|
-
+ )
|
|
1808
|
-
+
|
|
1809
|
-
+ private val mainHandler = Handler(Looper.getMainLooper())
|
|
1810
|
-
+ private var previousLog = counters()
|
|
1811
|
-
+
|
|
1812
|
-
+ private val logRunnable = object : Runnable {
|
|
1813
|
-
+ override fun run() {
|
|
1814
|
-
+ if (!enabled) return
|
|
1815
|
-
+ val current = counters()
|
|
1816
|
-
+ val previous = previousLog
|
|
1817
|
-
+ Log.i(
|
|
1818
|
-
+ "LiquidGlassPerf",
|
|
1819
|
-
+ "hz=${displayRefreshRate.toInt()} requests=${delta(current, previous, "backdropRequestCount")} " +
|
|
1820
|
-
+ "captures=${delta(current, previous, "backdropCaptureCount")} " +
|
|
1821
|
-
+ "capturePixels=${delta(current, previous, "backdropCapturedPixelCount")} " +
|
|
1822
|
-
+ "sourceDirty=${delta(current, previous, "sourceContentDirtyCount")} " +
|
|
1823
|
-
+ "geometryDirty=${delta(current, previous, "consumerGeometryDirtyCount")} " +
|
|
1824
|
-
+ "opticsDirty=${delta(current, previous, "opticsDirtyCount")} " +
|
|
1825
|
-
+ "materialDirty=${delta(current, previous, "materialDirtyCount")} " +
|
|
1826
|
-
+ "noIntersection=${delta(current, previous, "captureSkippedNoIntersection")} " +
|
|
1827
|
-
+ "alreadyDirty=${delta(current, previous, "captureSkippedAlreadyDirty")} " +
|
|
1828
|
-
+ "scheduled=${delta(current, previous, "captureScheduledCount")} " +
|
|
1829
|
-
+ "glassDraws=${delta(current, previous, "consumerDrawCount")} " +
|
|
1830
|
-
+ "effects=${delta(current, previous, "effectBuildCount")} " +
|
|
1831
|
-
+ "geometryLookups=${delta(current, previous, "geometryLookupCount")} " +
|
|
1832
|
-
+ "routeDispatch=${delta(current, previous, "routeDispatchCount")} " +
|
|
1833
|
-
+ "routeTraversal=${delta(current, previous, "routeTreeTraversalCount")} " +
|
|
1834
|
-
+ "routeNodeRecord=${delta(current, previous, "routeRenderNodeRecordCount")} " +
|
|
1835
|
-
+ "routeScreenComposite=${delta(current, previous, "routeScreenCompositeCount")} " +
|
|
1836
|
-
+ "routeScrollReuse=${delta(current, previous, "routeScrollReuseCount")} " +
|
|
1837
|
-
+ "frozenSnapshotBlur=${delta(current, previous, "frozenSnapshotBlurRecordCount")} " +
|
|
1838
|
-
+ "frozenSnapshotRequests=${delta(current, previous, "frozenSnapshotRequestCount")} " +
|
|
1839
|
-
+ "frozenSnapshotFailures=${delta(current, previous, "frozenSnapshotFailureCount")} " +
|
|
1840
|
-
+ "backdropSamples=${delta(current, previous, "backdropSampleCount")} " +
|
|
1841
|
-
+ "activeConsumers=${current["activeConsumerCount"] ?: 0L} " +
|
|
1842
|
-
+ "consumerAreaPx=${current["totalConsumerPixelArea"] ?: 0L} " +
|
|
1843
|
-
+ "unionAreaPx=${current["unionBoundingRectArea"] ?: 0L} " +
|
|
1844
|
-
+ "unionPercent=${current["unionBoundingRectPercent"] ?: 0L} " +
|
|
1845
|
-
+ "consumerRects=${providerRectSummary()}",
|
|
1846
|
-
+ )
|
|
1847
|
-
+ previousLog = current
|
|
1848
|
-
+ mainHandler.postDelayed(this, 1_000L)
|
|
1849
|
-
+ }
|
|
1850
|
-
+ }
|
|
1851
|
-
+
|
|
1852
|
-
+ fun setEnabled(value: Boolean) {
|
|
1853
|
-
+ if (enabled == value) {
|
|
1854
|
-
+ if (value) mainHandler.post {
|
|
1855
|
-
+ reset()
|
|
1856
|
-
+ previousLog = counters()
|
|
1857
|
-
+ mainHandler.removeCallbacks(logRunnable)
|
|
1858
|
-
+ mainHandler.postDelayed(logRunnable, 1_000L)
|
|
1859
|
-
+ }
|
|
1860
|
-
+ return
|
|
1861
|
-
+ }
|
|
1862
|
-
+ enabled = value
|
|
1863
|
-
+ mainHandler.post {
|
|
1864
|
-
+ if (value) {
|
|
1865
|
-
+ reset()
|
|
1866
|
-
+ previousLog = counters()
|
|
1867
|
-
+ mainHandler.removeCallbacks(logRunnable)
|
|
1868
|
-
+ mainHandler.postDelayed(logRunnable, 1_000L)
|
|
1869
|
-
+ } else {
|
|
1870
|
-
+ mainHandler.removeCallbacks(logRunnable)
|
|
1871
|
-
+ }
|
|
1872
|
-
+ }
|
|
1873
|
-
+ }
|
|
1874
|
-
+
|
|
1875
|
-
+ fun snapshot(): Map<String, Number> = counters() + mapOf("displayRefreshRate" to displayRefreshRate)
|
|
1876
|
-
+
|
|
1877
|
-
+ fun displayRefreshRate(value: Float) {
|
|
1878
|
-
+ if (enabled) displayRefreshRate = value
|
|
1879
|
-
+ }
|
|
1880
|
-
+
|
|
1881
|
-
+ fun backdropRequest() { if (enabled) requests.incrementAndGet() }
|
|
1882
|
-
+ fun sourceContentDirty() { if (enabled) sourceContentDirties.incrementAndGet() }
|
|
1883
|
-
+ fun consumerGeometryDirty() { if (enabled) consumerGeometryDirties.incrementAndGet() }
|
|
1884
|
-
+ fun opticsDirty() { if (enabled) opticsDirties.incrementAndGet() }
|
|
1885
|
-
+ fun materialDirty() { if (enabled) materialDirties.incrementAndGet() }
|
|
1886
|
-
+ fun backdropCapture(width: Int, height: Int) {
|
|
1887
|
-
+ if (!enabled) return
|
|
1888
|
-
+ captures.incrementAndGet()
|
|
1889
|
-
+ capturedPixels.addAndGet(width.coerceAtLeast(0).toLong() * height.coerceAtLeast(0).toLong())
|
|
1890
|
-
+ }
|
|
1891
|
-
+ fun captureSkippedNoIntersection() { if (enabled) skippedNoIntersection.incrementAndGet() }
|
|
1892
|
-
+ fun captureSkippedAlreadyDirty() { if (enabled) skippedAlreadyDirty.incrementAndGet() }
|
|
1893
|
-
+ fun captureScheduled() { if (enabled) captureSchedules.incrementAndGet() }
|
|
1894
|
-
+ fun consumerDraw() { if (enabled) consumerDraws.incrementAndGet() }
|
|
1895
|
-
+ fun routeDraw() { if (enabled) routeDraws.incrementAndGet() }
|
|
1896
|
-
+ fun routeTreeTraversal() { if (enabled) routeTreeTraversals.incrementAndGet() }
|
|
1897
|
-
+ fun routeRenderNodeRecord() { if (enabled) routeRenderNodeRecords.incrementAndGet() }
|
|
1898
|
-
+ fun routeScreenComposite() { if (enabled) routeScreenComposites.incrementAndGet() }
|
|
1899
|
-
+ fun routeScrollReuse() { if (enabled) routeScrollReuses.incrementAndGet() }
|
|
1900
|
-
+ fun frozenSnapshotBlurRecorded() { if (enabled) frozenSnapshotBlurRecords.incrementAndGet() }
|
|
1901
|
-
+ fun frozenSnapshotRequested() { if (enabled) frozenSnapshotRequests.incrementAndGet() }
|
|
1902
|
-
+ fun frozenSnapshotFailed() { if (enabled) frozenSnapshotFailures.incrementAndGet() }
|
|
1903
|
-
+ fun backdropSample() { if (enabled) backdropSamples.incrementAndGet() }
|
|
1904
|
-
+ fun effectBuild() { if (enabled) effectBuilds.incrementAndGet() }
|
|
1905
|
-
+ fun geometryLookup() { if (enabled) geometryLookups.incrementAndGet() }
|
|
1906
|
-
+
|
|
1907
|
-
+ fun isEnabled(): Boolean = enabled
|
|
1908
|
-
+
|
|
1909
|
-
+ fun updateProviderGeometry(providerId: String, width: Int, height: Int, rects: Collection<Rect>) {
|
|
1910
|
-
+ if (!enabled) return
|
|
1911
|
-
+ providerGeometry[providerId] = ProviderGeometry(width, height, rects.map(::Rect))
|
|
1912
|
-
+ }
|
|
1913
|
-
+
|
|
1914
|
-
+ fun removeProviderGeometry(providerId: String) {
|
|
1915
|
-
+ if (enabled) providerGeometry.remove(providerId)
|
|
1916
|
-
+ }
|
|
1917
|
-
+
|
|
1918
|
-
+ private fun counters(): Map<String, Long> {
|
|
1919
|
-
+ var activeConsumerCount = 0L
|
|
1920
|
-
+ var totalConsumerPixelArea = 0L
|
|
1921
|
-
+ var unionBoundingRectArea = 0L
|
|
1922
|
-
+ var providerArea = 0L
|
|
1923
|
-
+ for (geometry in providerGeometry.values) {
|
|
1924
|
-
+ providerArea += geometry.width.coerceAtLeast(0).toLong() * geometry.height.coerceAtLeast(0)
|
|
1925
|
-
+ if (geometry.rects.isEmpty()) continue
|
|
1926
|
-
+ activeConsumerCount += geometry.rects.size
|
|
1927
|
-
+ val union = Rect()
|
|
1928
|
-
+ for ((index, rect) in geometry.rects.withIndex()) {
|
|
1929
|
-
+ val area = rect.width().coerceAtLeast(0).toLong() * rect.height().coerceAtLeast(0)
|
|
1930
|
-
+ totalConsumerPixelArea += area
|
|
1931
|
-
+ if (index == 0) union.set(rect) else union.union(rect)
|
|
1932
|
-
+ }
|
|
1933
|
-
+ unionBoundingRectArea += union.width().coerceAtLeast(0).toLong() * union.height().coerceAtLeast(0)
|
|
1934
|
-
+ }
|
|
1935
|
-
+ val unionPercent = if (providerArea > 0L) (unionBoundingRectArea * 10_000L / providerArea) else 0L
|
|
1936
|
-
+ return mapOf(
|
|
1937
|
-
+ "backdropRequestCount" to requests.get(),
|
|
1938
|
-
+ "sourceContentDirtyCount" to sourceContentDirties.get(),
|
|
1939
|
-
+ "consumerGeometryDirtyCount" to consumerGeometryDirties.get(),
|
|
1940
|
-
+ "opticsDirtyCount" to opticsDirties.get(),
|
|
1941
|
-
+ "materialDirtyCount" to materialDirties.get(),
|
|
1942
|
-
+ "backdropCaptureCount" to captures.get(),
|
|
1943
|
-
+ "backdropCapturedPixelCount" to capturedPixels.get(),
|
|
1944
|
-
+ "captureSkippedNoIntersection" to skippedNoIntersection.get(),
|
|
1945
|
-
+ "captureSkippedAlreadyDirty" to skippedAlreadyDirty.get(),
|
|
1946
|
-
+ "captureScheduledCount" to captureSchedules.get(),
|
|
1947
|
-
+ "consumerDrawCount" to consumerDraws.get(),
|
|
1948
|
-
+ "effectBuildCount" to effectBuilds.get(),
|
|
1949
|
-
+ "geometryLookupCount" to geometryLookups.get(),
|
|
1950
|
-
+ "uiFrameCount" to routeDraws.get(),
|
|
1951
|
-
+ "routeDispatchCount" to routeDraws.get(),
|
|
1952
|
-
+ "routeTreeTraversalCount" to routeTreeTraversals.get(),
|
|
1953
|
-
+ "routeRenderNodeRecordCount" to routeRenderNodeRecords.get(),
|
|
1954
|
-
+ "routeScreenCompositeCount" to routeScreenComposites.get(),
|
|
1955
|
-
+ "routeScrollReuseCount" to routeScrollReuses.get(),
|
|
1956
|
-
+ "frozenSnapshotBlurRecordCount" to frozenSnapshotBlurRecords.get(),
|
|
1957
|
-
+ "frozenSnapshotRequestCount" to frozenSnapshotRequests.get(),
|
|
1958
|
-
+ "frozenSnapshotFailureCount" to frozenSnapshotFailures.get(),
|
|
1959
|
-
+ "backdropSampleCount" to backdropSamples.get(),
|
|
1960
|
-
+ "activeConsumerCount" to activeConsumerCount,
|
|
1961
|
-
+ "totalConsumerPixelArea" to totalConsumerPixelArea,
|
|
1962
|
-
+ "unionBoundingRectArea" to unionBoundingRectArea,
|
|
1963
|
-
+ "unionBoundingRectPercent" to unionPercent,
|
|
1964
|
-
+ )
|
|
1965
|
-
+ }
|
|
1966
|
-
+
|
|
1967
|
-
+ private fun providerRectSummary(): String {
|
|
1968
|
-
+ if (!enabled) return "[]"
|
|
1969
|
-
+ return providerGeometry.entries.sortedBy { it.key }.joinToString(prefix = "[", postfix = "]", separator = ";") { (id, geometry) ->
|
|
1970
|
-
+ val rects = geometry.rects.joinToString(separator = "|") { "${it.left},${it.top},${it.right},${it.bottom}" }
|
|
1971
|
-
+ "$id:${geometry.width}x${geometry.height}:$rects"
|
|
1972
|
-
+ }
|
|
1973
|
-
+ }
|
|
1974
|
-
+
|
|
1975
|
-
+ private fun delta(current: Map<String, Long>, previous: Map<String, Long>, key: String): Long =
|
|
1976
|
-
+ (current[key] ?: 0L) - (previous[key] ?: 0L)
|
|
1977
|
-
+
|
|
1978
|
-
+ private fun reset() {
|
|
1979
|
-
+ requests.set(0L)
|
|
1980
|
-
+ sourceContentDirties.set(0L)
|
|
1981
|
-
+ consumerGeometryDirties.set(0L)
|
|
1982
|
-
+ opticsDirties.set(0L)
|
|
1983
|
-
+ materialDirties.set(0L)
|
|
1984
|
-
+ captures.set(0L)
|
|
1985
|
-
+ capturedPixels.set(0L)
|
|
1986
|
-
+ skippedNoIntersection.set(0L)
|
|
1987
|
-
+ skippedAlreadyDirty.set(0L)
|
|
1988
|
-
+ captureSchedules.set(0L)
|
|
1989
|
-
+ consumerDraws.set(0L)
|
|
1990
|
-
+ effectBuilds.set(0L)
|
|
1991
|
-
+ geometryLookups.set(0L)
|
|
1992
|
-
+ routeDraws.set(0L)
|
|
1993
|
-
+ routeTreeTraversals.set(0L)
|
|
1994
|
-
+ routeRenderNodeRecords.set(0L)
|
|
1995
|
-
+ routeScreenComposites.set(0L)
|
|
1996
|
-
+ routeScrollReuses.set(0L)
|
|
1997
|
-
+ frozenSnapshotBlurRecords.set(0L)
|
|
1998
|
-
+ frozenSnapshotRequests.set(0L)
|
|
1999
|
-
+ frozenSnapshotFailures.set(0L)
|
|
2000
|
-
+ backdropSamples.set(0L)
|
|
2001
|
-
+ }
|
|
2002
|
-
+}
|
|
2003
|
-
diff --git a/node_modules/liquid-glass-kit/android/src/main/java/expo/modules/liquidglass/LiquidGlassRegistry.kt b/node_modules/liquid-glass-kit/android/src/main/java/expo/modules/liquidglass/LiquidGlassRegistry.kt
|
|
2004
|
-
index b5317cf..a711090 100644
|
|
2005
|
-
--- a/node_modules/liquid-glass-kit/android/src/main/java/expo/modules/liquidglass/LiquidGlassRegistry.kt
|
|
2006
|
-
+++ b/node_modules/liquid-glass-kit/android/src/main/java/expo/modules/liquidglass/LiquidGlassRegistry.kt
|
|
2007
|
-
@@ -40,6 +40,8 @@ internal object LiquidGlassRegistry {
|
|
2008
|
-
}
|
|
2009
|
-
}
|
|
2010
|
-
|
|
2011
|
-
+ fun provider(id: String): LiquidGlassBackdropSource? = providers[id]?.get()
|
|
2012
|
-
+
|
|
2013
|
-
fun resolve(id: String, controller: GlassViewController) {
|
|
2014
|
-
val provider = providers[id]?.get()
|
|
2015
|
-
if (provider != null) {
|