@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,341 +0,0 @@
|
|
|
1
|
-
package expo.modules.localglass
|
|
2
|
-
|
|
3
|
-
import android.content.Context
|
|
4
|
-
import android.graphics.Canvas
|
|
5
|
-
import android.graphics.Color
|
|
6
|
-
import android.graphics.Paint
|
|
7
|
-
import android.graphics.Shader
|
|
8
|
-
import android.os.Build
|
|
9
|
-
import android.util.Log
|
|
10
|
-
import android.view.View
|
|
11
|
-
import android.content.pm.ApplicationInfo
|
|
12
|
-
import java.util.WeakHashMap
|
|
13
|
-
import java.util.concurrent.atomic.AtomicInteger
|
|
14
|
-
import java.util.concurrent.atomic.AtomicLong
|
|
15
|
-
import expo.modules.kotlin.AppContext
|
|
16
|
-
import expo.modules.kotlin.modules.Module
|
|
17
|
-
import expo.modules.kotlin.modules.ModuleDefinition
|
|
18
|
-
import expo.modules.kotlin.views.ExpoView
|
|
19
|
-
|
|
20
|
-
class ExpoLocalGlassModule : Module() {
|
|
21
|
-
override fun definition() = ModuleDefinition {
|
|
22
|
-
Name("ExpoLocalGlass")
|
|
23
|
-
|
|
24
|
-
AsyncFunction("setPerformanceTelemetryEnabled") { enabled: Boolean ->
|
|
25
|
-
val isDebuggable = appContext.currentActivity?.applicationInfo?.let {
|
|
26
|
-
it.flags and ApplicationInfo.FLAG_DEBUGGABLE != 0
|
|
27
|
-
} ?: false
|
|
28
|
-
LocalGlassPerformanceTelemetry.setEnabled(enabled && isDebuggable)
|
|
29
|
-
}
|
|
30
|
-
AsyncFunction("getPerformanceTelemetry") {
|
|
31
|
-
LocalGlassPerformanceTelemetry.snapshot()
|
|
32
|
-
}
|
|
33
|
-
AsyncFunction("setHardwareLayerExperimentEnabled") { enabled: Boolean ->
|
|
34
|
-
val isDebuggable = appContext.currentActivity?.applicationInfo?.let {
|
|
35
|
-
it.flags and ApplicationInfo.FLAG_DEBUGGABLE != 0
|
|
36
|
-
} ?: false
|
|
37
|
-
if (isDebuggable) LocalGlassHardwareLayerExperiment.setEnabled(enabled)
|
|
38
|
-
}
|
|
39
|
-
View(LocalGlassMaterialExpoView::class) {
|
|
40
|
-
Name("LocalGlassMaterial")
|
|
41
|
-
Prop("baseTint") { view: LocalGlassMaterialExpoView, value: List<Double>? ->
|
|
42
|
-
view.baseTint = value.toFloatArrayOr(view.baseTint)
|
|
43
|
-
}
|
|
44
|
-
Prop("accentTint") { view: LocalGlassMaterialExpoView, value: List<Double>? ->
|
|
45
|
-
view.accentTint = value.toFloatArrayOr(view.accentTint)
|
|
46
|
-
}
|
|
47
|
-
Prop("highlightTint") { view: LocalGlassMaterialExpoView, value: List<Double>? ->
|
|
48
|
-
view.highlightTint = value.toFloatArrayOr(view.highlightTint)
|
|
49
|
-
}
|
|
50
|
-
Prop("innerShade") { view: LocalGlassMaterialExpoView, value: List<Double>? ->
|
|
51
|
-
view.innerShade = value.toFloatArrayOr(view.innerShade)
|
|
52
|
-
}
|
|
53
|
-
Prop("surfaceWarp") { view: LocalGlassMaterialExpoView, value: Float? ->
|
|
54
|
-
view.surfaceWarp = value ?: 0f
|
|
55
|
-
}
|
|
56
|
-
Prop("chromatic") { view: LocalGlassMaterialExpoView, value: Float? ->
|
|
57
|
-
view.chromatic = value ?: 0f
|
|
58
|
-
}
|
|
59
|
-
Prop("highlightStrength") { view: LocalGlassMaterialExpoView, value: Float? ->
|
|
60
|
-
view.highlightStrength = value ?: 0f
|
|
61
|
-
}
|
|
62
|
-
Prop("noiseStrength") { view: LocalGlassMaterialExpoView, value: Float? ->
|
|
63
|
-
view.noiseStrength = value ?: 0f
|
|
64
|
-
}
|
|
65
|
-
Prop("materialOpacity") { view: LocalGlassMaterialExpoView, value: Float? ->
|
|
66
|
-
view.materialOpacity = value ?: 1f
|
|
67
|
-
}
|
|
68
|
-
Prop("cornerRadiusPx") { view: LocalGlassMaterialExpoView, value: Float? ->
|
|
69
|
-
view.cornerRadiusPx = value ?: 0f
|
|
70
|
-
}
|
|
71
|
-
OnViewDidUpdateProps { view: LocalGlassMaterialExpoView -> view.onMaterialPropsUpdated() }
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
private fun List<Double>?.toFloatArrayOr(previous: FloatArray): FloatArray {
|
|
77
|
-
if (this == null || size < 4) return previous
|
|
78
|
-
return floatArrayOf(this[0].toFloat(), this[1].toFloat(), this[2].toFloat(), this[3].toFloat())
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
class LocalGlassMaterialExpoView(
|
|
82
|
-
context: Context,
|
|
83
|
-
appContext: AppContext,
|
|
84
|
-
) : ExpoView(context, appContext) {
|
|
85
|
-
private val paint = Paint(Paint.ANTI_ALIAS_FLAG).apply { style = Paint.Style.FILL }
|
|
86
|
-
private var runtimeShader: Shader? = null
|
|
87
|
-
private var hasMaterialProps = false
|
|
88
|
-
private var appliedWidth = -1
|
|
89
|
-
private var appliedHeight = -1
|
|
90
|
-
private var appliedBaseTint: FloatArray? = null
|
|
91
|
-
private var appliedAccentTint: FloatArray? = null
|
|
92
|
-
private var appliedHighlightTint: FloatArray? = null
|
|
93
|
-
private var appliedInnerShade: FloatArray? = null
|
|
94
|
-
private var appliedScalars: FloatArray? = null
|
|
95
|
-
|
|
96
|
-
var baseTint = floatArrayOf(1f, 1f, 1f, 0.2f)
|
|
97
|
-
var accentTint = floatArrayOf(1f, 1f, 1f, 0.2f)
|
|
98
|
-
var highlightTint = floatArrayOf(1f, 1f, 1f, 1f)
|
|
99
|
-
var innerShade = floatArrayOf(0f, 0f, 0f, 1f)
|
|
100
|
-
var surfaceWarp = 0f
|
|
101
|
-
var chromatic = 0f
|
|
102
|
-
var highlightStrength = 0f
|
|
103
|
-
var noiseStrength = 0f
|
|
104
|
-
var materialOpacity = 1f
|
|
105
|
-
var cornerRadiusPx = 0f
|
|
106
|
-
|
|
107
|
-
init {
|
|
108
|
-
setWillNotDraw(false)
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
override fun onAttachedToWindow() {
|
|
112
|
-
super.onAttachedToWindow()
|
|
113
|
-
LocalGlassPerformanceTelemetry.viewMounted()
|
|
114
|
-
LocalGlassHardwareLayerExperiment.register(this)
|
|
115
|
-
applyMaterial()
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
override fun onDetachedFromWindow() {
|
|
119
|
-
LocalGlassHardwareLayerExperiment.unregister(this)
|
|
120
|
-
runtimeShader?.let(LocalGlassRuntimeShaderPool::release)
|
|
121
|
-
runtimeShader = null
|
|
122
|
-
paint.shader = null
|
|
123
|
-
appliedWidth = -1
|
|
124
|
-
appliedHeight = -1
|
|
125
|
-
appliedBaseTint = null
|
|
126
|
-
appliedAccentTint = null
|
|
127
|
-
appliedHighlightTint = null
|
|
128
|
-
appliedInnerShade = null
|
|
129
|
-
appliedScalars = null
|
|
130
|
-
LocalGlassPerformanceTelemetry.viewUnmounted()
|
|
131
|
-
super.onDetachedFromWindow()
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
override fun invalidate() {
|
|
135
|
-
LocalGlassPerformanceTelemetry.invalidated()
|
|
136
|
-
super.invalidate()
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
fun applyMaterial() {
|
|
140
|
-
if (!hasMaterialProps || width <= 0 || height <= 0) return
|
|
141
|
-
LocalGlassPerformanceTelemetry.materialApplied()
|
|
142
|
-
if (Build.VERSION.SDK_INT < 33) return
|
|
143
|
-
val density = resources.displayMetrics.density.coerceAtLeast(1f)
|
|
144
|
-
val resolution = floatArrayOf(width / density, height / density)
|
|
145
|
-
var changed = false
|
|
146
|
-
val existingShader = runtimeShader
|
|
147
|
-
val shader = existingShader ?: LocalGlassRuntimeShaderPool.acquire()?.also {
|
|
148
|
-
runtimeShader = it
|
|
149
|
-
paint.shader = it
|
|
150
|
-
changed = true
|
|
151
|
-
} ?: return
|
|
152
|
-
|
|
153
|
-
if (appliedWidth != width || appliedHeight != height) {
|
|
154
|
-
RuntimeShaderBridge.setFloatUniform(shader, "resolution", resolution)
|
|
155
|
-
appliedWidth = width
|
|
156
|
-
appliedHeight = height
|
|
157
|
-
LocalGlassPerformanceTelemetry.sizeUniformUpdated()
|
|
158
|
-
changed = true
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
val scalars = floatArrayOf(surfaceWarp, chromatic, highlightStrength, noiseStrength, materialOpacity, cornerRadiusPx)
|
|
162
|
-
if (!baseTint.contentEquals(appliedBaseTint) || !accentTint.contentEquals(appliedAccentTint) ||
|
|
163
|
-
!highlightTint.contentEquals(appliedHighlightTint) || !innerShade.contentEquals(appliedInnerShade) ||
|
|
164
|
-
!scalars.contentEquals(appliedScalars)
|
|
165
|
-
) {
|
|
166
|
-
RuntimeShaderBridge.setFloatUniform(shader, "baseTint", baseTint)
|
|
167
|
-
RuntimeShaderBridge.setFloatUniform(shader, "accentTint", accentTint)
|
|
168
|
-
RuntimeShaderBridge.setFloatUniform(shader, "highlightTint", highlightTint)
|
|
169
|
-
RuntimeShaderBridge.setFloatUniform(shader, "innerShade", innerShade)
|
|
170
|
-
RuntimeShaderBridge.setFloatUniform(shader, "surfaceWarp", floatArrayOf(surfaceWarp))
|
|
171
|
-
RuntimeShaderBridge.setFloatUniform(shader, "chromatic", floatArrayOf(chromatic))
|
|
172
|
-
RuntimeShaderBridge.setFloatUniform(shader, "highlightStrength", floatArrayOf(highlightStrength))
|
|
173
|
-
RuntimeShaderBridge.setFloatUniform(shader, "noiseStrength", floatArrayOf(noiseStrength))
|
|
174
|
-
RuntimeShaderBridge.setFloatUniform(shader, "materialOpacity", floatArrayOf(materialOpacity))
|
|
175
|
-
RuntimeShaderBridge.setFloatUniform(shader, "cornerRadiusPx", floatArrayOf(cornerRadiusPx))
|
|
176
|
-
appliedBaseTint = baseTint.copyOf()
|
|
177
|
-
appliedAccentTint = accentTint.copyOf()
|
|
178
|
-
appliedHighlightTint = highlightTint.copyOf()
|
|
179
|
-
appliedInnerShade = innerShade.copyOf()
|
|
180
|
-
appliedScalars = scalars
|
|
181
|
-
LocalGlassPerformanceTelemetry.materialUniformsUpdated()
|
|
182
|
-
changed = true
|
|
183
|
-
}
|
|
184
|
-
if (changed) invalidate()
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
override fun onSizeChanged(width: Int, height: Int, oldWidth: Int, oldHeight: Int) {
|
|
188
|
-
super.onSizeChanged(width, height, oldWidth, oldHeight)
|
|
189
|
-
applyMaterial()
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
fun onMaterialPropsUpdated() {
|
|
193
|
-
hasMaterialProps = true
|
|
194
|
-
applyMaterial()
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
override fun onDraw(canvas: Canvas) {
|
|
198
|
-
super.onDraw(canvas)
|
|
199
|
-
LocalGlassPerformanceTelemetry.nativeOnDraw()
|
|
200
|
-
if (runtimeShader == null) {
|
|
201
|
-
paint.shader = null
|
|
202
|
-
paint.color = Color.argb(
|
|
203
|
-
(baseTint[3] * 255f).toInt().coerceIn(0, 255),
|
|
204
|
-
(baseTint[0] * 255f).toInt().coerceIn(0, 255),
|
|
205
|
-
(baseTint[1] * 255f).toInt().coerceIn(0, 255),
|
|
206
|
-
(baseTint[2] * 255f).toInt().coerceIn(0, 255),
|
|
207
|
-
)
|
|
208
|
-
}
|
|
209
|
-
val scale = resources.displayMetrics.density
|
|
210
|
-
val save = canvas.save()
|
|
211
|
-
canvas.scale(scale, scale)
|
|
212
|
-
canvas.drawRect(0f, 0f, width / scale, height / scale, paint)
|
|
213
|
-
canvas.restoreToCount(save)
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
/** Debug-only A/B switch for this View alone; production defaults to no extra layer. */
|
|
219
|
-
private object LocalGlassHardwareLayerExperiment {
|
|
220
|
-
@Volatile private var enabled = false
|
|
221
|
-
private val views = WeakHashMap<LocalGlassMaterialExpoView, Unit>()
|
|
222
|
-
|
|
223
|
-
fun register(view: LocalGlassMaterialExpoView) {
|
|
224
|
-
synchronized(views) { views[view] = Unit }
|
|
225
|
-
view.setLayerType(if (enabled) View.LAYER_TYPE_HARDWARE else View.LAYER_TYPE_NONE, null)
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
fun unregister(view: LocalGlassMaterialExpoView) {
|
|
229
|
-
synchronized(views) { views.remove(view) }
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
fun setEnabled(value: Boolean) {
|
|
233
|
-
enabled = value
|
|
234
|
-
val attached = synchronized(views) { views.keys.toList() }
|
|
235
|
-
attached.forEach { view ->
|
|
236
|
-
view.post {
|
|
237
|
-
view.setLayerType(if (value) View.LAYER_TYPE_HARDWARE else View.LAYER_TYPE_NONE, null)
|
|
238
|
-
}
|
|
239
|
-
}
|
|
240
|
-
}
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
/** Detached per-view shaders are pooled because RuntimeShader instances carry mutable uniforms. */
|
|
244
|
-
private object LocalGlassRuntimeShaderPool {
|
|
245
|
-
private const val MAX_POOLED_SHADERS = 32
|
|
246
|
-
private val shaders = ArrayDeque<Shader>()
|
|
247
|
-
|
|
248
|
-
fun acquire(): Shader? {
|
|
249
|
-
val pooled = synchronized(shaders) { if (shaders.isEmpty()) null else shaders.removeLast() }
|
|
250
|
-
if (pooled != null) {
|
|
251
|
-
LocalGlassPerformanceTelemetry.runtimeShaderReused()
|
|
252
|
-
return pooled
|
|
253
|
-
}
|
|
254
|
-
return RuntimeShaderBridge.create(LocalGlassShader.SOURCE)?.also {
|
|
255
|
-
LocalGlassPerformanceTelemetry.runtimeShaderCreated()
|
|
256
|
-
}
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
fun release(shader: Shader) {
|
|
260
|
-
synchronized(shaders) {
|
|
261
|
-
if (shaders.size < MAX_POOLED_SHADERS) shaders.addLast(shader)
|
|
262
|
-
}
|
|
263
|
-
}
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
/** Debug-only counters. The default release and app rendering path remain inactive. */
|
|
267
|
-
private object LocalGlassPerformanceTelemetry {
|
|
268
|
-
@Volatile private var enabled = false
|
|
269
|
-
private val attachedViews = AtomicInteger()
|
|
270
|
-
private val nativeOnDraws = AtomicLong()
|
|
271
|
-
private val invalidates = AtomicLong()
|
|
272
|
-
private val uniformUpdates = AtomicLong()
|
|
273
|
-
private val sizeUniformUpdates = AtomicLong()
|
|
274
|
-
private val materialUniformUpdates = AtomicLong()
|
|
275
|
-
private val materialApplies = AtomicLong()
|
|
276
|
-
private val shaderCreates = AtomicLong()
|
|
277
|
-
private val shaderReuses = AtomicLong()
|
|
278
|
-
|
|
279
|
-
fun setEnabled(value: Boolean) {
|
|
280
|
-
enabled = value
|
|
281
|
-
if (value) {
|
|
282
|
-
nativeOnDraws.set(0L)
|
|
283
|
-
invalidates.set(0L)
|
|
284
|
-
uniformUpdates.set(0L)
|
|
285
|
-
sizeUniformUpdates.set(0L)
|
|
286
|
-
materialUniformUpdates.set(0L)
|
|
287
|
-
materialApplies.set(0L)
|
|
288
|
-
shaderCreates.set(0L)
|
|
289
|
-
shaderReuses.set(0L)
|
|
290
|
-
}
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
fun viewMounted() { attachedViews.incrementAndGet() }
|
|
294
|
-
fun viewUnmounted() { attachedViews.updateAndGet { (it - 1).coerceAtLeast(0) } }
|
|
295
|
-
fun invalidated() { if (enabled) invalidates.incrementAndGet() }
|
|
296
|
-
fun nativeOnDraw() { if (enabled) nativeOnDraws.incrementAndGet() }
|
|
297
|
-
fun materialApplied() { if (enabled) materialApplies.incrementAndGet() }
|
|
298
|
-
fun runtimeShaderCreated() { if (enabled) shaderCreates.incrementAndGet() }
|
|
299
|
-
fun runtimeShaderReused() { if (enabled) shaderReuses.incrementAndGet() }
|
|
300
|
-
fun uniformUpdated() { if (enabled) uniformUpdates.incrementAndGet() }
|
|
301
|
-
fun sizeUniformUpdated() { if (enabled) sizeUniformUpdates.incrementAndGet() }
|
|
302
|
-
fun materialUniformsUpdated() { if (enabled) materialUniformUpdates.incrementAndGet() }
|
|
303
|
-
|
|
304
|
-
fun snapshot(): Map<String, Long> = mapOf(
|
|
305
|
-
"mountedNativeViewCount" to attachedViews.get().toLong(),
|
|
306
|
-
"nativeOnDrawCount" to nativeOnDraws.get(),
|
|
307
|
-
"nativeInvalidateCount" to invalidates.get(),
|
|
308
|
-
"materialApplyCount" to materialApplies.get(),
|
|
309
|
-
"runtimeShaderCreateCount" to shaderCreates.get(),
|
|
310
|
-
"runtimeShaderReuseCount" to shaderReuses.get(),
|
|
311
|
-
"uniformUpdateCount" to uniformUpdates.get(),
|
|
312
|
-
"sizeUniformUpdateCount" to sizeUniformUpdates.get(),
|
|
313
|
-
"materialUniformUpdateCount" to materialUniformUpdates.get(),
|
|
314
|
-
)
|
|
315
|
-
}
|
|
316
|
-
|
|
317
|
-
/** Resolve RuntimeShader reflectively so API 24–32 can load the module and keep using Skia. */
|
|
318
|
-
private object RuntimeShaderBridge {
|
|
319
|
-
private val shaderType: Class<*>? by lazy(LazyThreadSafetyMode.PUBLICATION) {
|
|
320
|
-
runCatching { Class.forName("android.graphics.RuntimeShader") }.getOrNull()
|
|
321
|
-
}
|
|
322
|
-
private val constructor by lazy(LazyThreadSafetyMode.PUBLICATION) {
|
|
323
|
-
shaderType?.getConstructor(String::class.java)
|
|
324
|
-
}
|
|
325
|
-
private val setFloatUniform by lazy(LazyThreadSafetyMode.PUBLICATION) {
|
|
326
|
-
shaderType?.getMethod("setFloatUniform", String::class.java, FloatArray::class.java)
|
|
327
|
-
}
|
|
328
|
-
|
|
329
|
-
fun create(source: String): Shader? {
|
|
330
|
-
if (Build.VERSION.SDK_INT < 33) return null
|
|
331
|
-
return constructor?.newInstance(source) as? Shader
|
|
332
|
-
}
|
|
333
|
-
|
|
334
|
-
fun setFloatUniform(shader: Shader, name: String, values: FloatArray) {
|
|
335
|
-
val setter = setFloatUniform ?: return
|
|
336
|
-
setter.invoke(shader, name, values)
|
|
337
|
-
LocalGlassPerformanceTelemetry.uniformUpdated()
|
|
338
|
-
}
|
|
339
|
-
}
|
|
340
|
-
|
|
341
|
-
private const val TAG = "NewHuLocalGlass"
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
package expo.modules.localglass
|
|
2
|
-
|
|
3
|
-
internal object LocalGlassShader {
|
|
4
|
-
const val SOURCE = """
|
|
5
|
-
uniform float2 resolution;
|
|
6
|
-
uniform float4 baseTint;
|
|
7
|
-
uniform float4 accentTint;
|
|
8
|
-
uniform float4 highlightTint;
|
|
9
|
-
uniform float4 innerShade;
|
|
10
|
-
uniform float surfaceWarp;
|
|
11
|
-
uniform float chromatic;
|
|
12
|
-
uniform float highlightStrength;
|
|
13
|
-
uniform float noiseStrength;
|
|
14
|
-
uniform float materialOpacity;
|
|
15
|
-
uniform float cornerRadiusPx;
|
|
16
|
-
|
|
17
|
-
half4 main(float2 position) {
|
|
18
|
-
float2 size = max(resolution, float2(1.0));
|
|
19
|
-
float2 uv = clamp(position / size, float2(0.0), float2(1.0));
|
|
20
|
-
|
|
21
|
-
// Keep the local material's optical field identical to the Skia fallback.
|
|
22
|
-
float bend = sin((uv.x * 1.35 + uv.y * 0.72) * 6.28318) * surfaceWarp * 0.0018;
|
|
23
|
-
float2 lightUv = clamp(uv + float2(bend, -bend * 0.55), float2(0.0), float2(1.0));
|
|
24
|
-
float vertical = 1.0 - smoothstep(0.0, 1.0, lightUv.y);
|
|
25
|
-
float radius = clamp(cornerRadiusPx / min(size.x, size.y), 0.0, 0.5);
|
|
26
|
-
float2 p = uv - float2(0.5);
|
|
27
|
-
float2 q = abs(p) - float2(0.5 - radius);
|
|
28
|
-
float signedEdgeDistance = length(max(q, float2(0.0))) + min(max(q.x, q.y), 0.0) - radius;
|
|
29
|
-
float edgeDepth = max(-signedEdgeDistance, 0.0);
|
|
30
|
-
|
|
31
|
-
float2 outside = max(q, float2(0.0));
|
|
32
|
-
float2 edgeNormal = length(outside) > 0.0001
|
|
33
|
-
? normalize(outside) * sign(p)
|
|
34
|
-
: (q.x > q.y ? float2(sign(p.x), 0.0) : float2(0.0, sign(p.y)));
|
|
35
|
-
float2 lightDirection = normalize(float2(-0.52, -0.85));
|
|
36
|
-
float edgeFacing = max(dot(edgeNormal, lightDirection), 0.0);
|
|
37
|
-
float edgeLight = 0.2 + 0.8 * pow(edgeFacing, 1.35);
|
|
38
|
-
float fresnel = (1.0 - smoothstep(0.0, 0.105, edgeDepth)) * edgeLight;
|
|
39
|
-
float innerShadow = smoothstep(0.005, 0.045, edgeDepth) * (1.0 - smoothstep(0.045, 0.14, edgeDepth));
|
|
40
|
-
float sideReflection = exp(-pow((uv.x - 0.025) * 24.0, 2.0)) + exp(-pow((uv.x - 0.975) * 24.0, 2.0));
|
|
41
|
-
|
|
42
|
-
float3 body = mix(baseTint.rgb, accentTint.rgb, 0.12 + vertical * 0.18);
|
|
43
|
-
float3 color = body;
|
|
44
|
-
color += highlightTint.rgb * sideReflection * 0.035 * highlightStrength;
|
|
45
|
-
color += highlightTint.rgb * fresnel * (0.055 + highlightStrength * 0.11);
|
|
46
|
-
color -= innerShade.rgb * innerShadow * 0.16;
|
|
47
|
-
|
|
48
|
-
float dispersion = fresnel * chromatic * 0.055;
|
|
49
|
-
color += float3(dispersion * 0.82, dispersion * 0.12, -dispersion * 0.48);
|
|
50
|
-
|
|
51
|
-
float grain = fract(sin(dot(floor(position), float2(12.9898, 78.233))) * 43758.5453) - 0.5;
|
|
52
|
-
color += grain * noiseStrength;
|
|
53
|
-
color = clamp(color, float3(0.0), float3(1.0));
|
|
54
|
-
|
|
55
|
-
float alpha = clamp((baseTint.a + accentTint.a * (0.22 + vertical * 0.08)) * materialOpacity, 0.0, 0.72);
|
|
56
|
-
return half4(color * alpha, alpha);
|
|
57
|
-
}
|
|
58
|
-
"""
|
|
59
|
-
}
|
|
@@ -1,226 +0,0 @@
|
|
|
1
|
-
package expo.modules.newhuliquidglass
|
|
2
|
-
|
|
3
|
-
import android.content.Context
|
|
4
|
-
import android.content.pm.ApplicationInfo
|
|
5
|
-
import android.os.Handler
|
|
6
|
-
import android.os.Looper
|
|
7
|
-
import android.provider.Settings
|
|
8
|
-
import com.newhu.liquidglass.backdrop.CORNER_RADIUS_CAPSULE
|
|
9
|
-
import com.newhu.liquidglass.telemetry.EffectiveScrollFpsProbe
|
|
10
|
-
import com.newhu.liquidglass.telemetry.LiquidGlassPerfTelemetry
|
|
11
|
-
import com.newhu.liquidglass.telemetry.LiquidGlassTrace
|
|
12
|
-
import expo.modules.kotlin.AppContext
|
|
13
|
-
import expo.modules.kotlin.modules.Module
|
|
14
|
-
import expo.modules.kotlin.modules.ModuleDefinition
|
|
15
|
-
import expo.modules.kotlin.views.ExpoView
|
|
16
|
-
|
|
17
|
-
internal class ExpoGlassCoreModule : Module() {
|
|
18
|
-
private val pointerEventHandler = Handler(Looper.getMainLooper())
|
|
19
|
-
|
|
20
|
-
private fun setPerformanceTelemetry(enabled: Boolean) {
|
|
21
|
-
val isDebuggable = appContext.currentActivity?.applicationInfo?.let {
|
|
22
|
-
it.flags and ApplicationInfo.FLAG_DEBUGGABLE != 0
|
|
23
|
-
} ?: false
|
|
24
|
-
// Release builds used to be unable to record any engine counter, which
|
|
25
|
-
// made every in-app Release measurement silently read as zero. The
|
|
26
|
-
// explicit global opt-in keeps shipping builds inert while letting a
|
|
27
|
-
// Release measurement build report the same counters as Debug:
|
|
28
|
-
// adb shell settings put global newhu_glass_telemetry 1
|
|
29
|
-
val measurementOptIn = run {
|
|
30
|
-
val resolver = appContext.reactContext?.contentResolver
|
|
31
|
-
?: appContext.currentActivity?.contentResolver
|
|
32
|
-
?: return@run false
|
|
33
|
-
Settings.Global.getInt(resolver, "newhu_glass_telemetry", 0) == 1
|
|
34
|
-
}
|
|
35
|
-
val shouldEnable = enabled && (isDebuggable || measurementOptIn)
|
|
36
|
-
val resolver = appContext.reactContext?.contentResolver ?: appContext.currentActivity?.contentResolver
|
|
37
|
-
LiquidGlassTrace.setDetailedEnabled(resolver == null ||
|
|
38
|
-
Settings.Global.getInt(resolver, "newhu_glass_detailed_trace", 1) != 0)
|
|
39
|
-
val activity = appContext.currentActivity
|
|
40
|
-
EffectiveScrollInputBridge.setActivityInputObservation(activity, shouldEnable)
|
|
41
|
-
LiquidGlassPerfTelemetry.setEnabled(shouldEnable)
|
|
42
|
-
CoreLiquidGlassRegistry.setScrollTelemetryEnabled(shouldEnable)
|
|
43
|
-
if (shouldEnable) {
|
|
44
|
-
val window = activity?.window
|
|
45
|
-
val refreshRate = window?.decorView?.display?.refreshRate ?: 0f
|
|
46
|
-
LiquidGlassPerfTelemetry.displayRefreshRate(refreshRate)
|
|
47
|
-
window?.decorView?.let { EffectiveScrollFpsProbe.start(it, refreshRate, window) }
|
|
48
|
-
} else {
|
|
49
|
-
EffectiveScrollFpsProbe.stop()
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
private fun enableMeasurementOptIn(attempt: Int = 0) {
|
|
54
|
-
val resolver = appContext.reactContext?.contentResolver ?: return
|
|
55
|
-
if (Settings.Global.getInt(resolver, "newhu_glass_telemetry", 0) == 1) {
|
|
56
|
-
val decor = appContext.currentActivity?.window?.decorView
|
|
57
|
-
// Module creation can precede Activity/window attachment on a cold
|
|
58
|
-
// install. Retry the diagnostic opt-in without app-side hooks.
|
|
59
|
-
if (decor?.isAttachedToWindow != true || decor.display == null) {
|
|
60
|
-
if (attempt < 30) pointerEventHandler.postDelayed({ enableMeasurementOptIn(attempt + 1) }, 100)
|
|
61
|
-
return
|
|
62
|
-
}
|
|
63
|
-
setPerformanceTelemetry(true)
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
override fun definition() = ModuleDefinition {
|
|
68
|
-
Name("NewHuLiquidGlassCore")
|
|
69
|
-
|
|
70
|
-
// Fabric's Expo view ref does not support setNativeProps. This sync JSI
|
|
71
|
-
// entrypoint queues the packet to the UI thread and resolves the actual
|
|
72
|
-
// native consumer by its React tag, avoiding a React commit for every MOVE.
|
|
73
|
-
Function("forwardPointerToSurface") { viewTag: Int, payload: String ->
|
|
74
|
-
if (appContext.reactContext == null) return@Function false
|
|
75
|
-
pointerEventHandler.post {
|
|
76
|
-
appContext.findView<ExpoGlassSurfaceCoreView>(viewTag)?.forwardPointer(payload)
|
|
77
|
-
}
|
|
78
|
-
true
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
Function("forwardValueToSurface") { viewTag: Int, payload: String ->
|
|
82
|
-
if (appContext.reactContext == null) return@Function false
|
|
83
|
-
pointerEventHandler.post {
|
|
84
|
-
appContext.findView<ExpoGlassSurfaceCoreView>(viewTag)?.forwardValue(payload)
|
|
85
|
-
}
|
|
86
|
-
true
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
// Engine selection, read once per surface at construction.
|
|
90
|
-
//
|
|
91
|
-
// Exposed as a module function rather than a build flag so the *installed*
|
|
92
|
-
// APK can be measured A/B/A against the chain the new engine replaces: same
|
|
93
|
-
// build, same content, same device, same gesture, which is the only way that
|
|
94
|
-
// comparison means anything. See GlassEngineSelection for why both paths
|
|
95
|
-
// exist.
|
|
96
|
-
Function("setEngineSelection") { useV3: Boolean ->
|
|
97
|
-
com.newhu.liquidglass.rendering.GlassEngineSelection.useV3 = useV3
|
|
98
|
-
}
|
|
99
|
-
Function("getEngineSelection") {
|
|
100
|
-
com.newhu.liquidglass.rendering.GlassEngineSelection.useV3
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
// Same route as the telemetry opt-in, so an installed release APK can be
|
|
104
|
-
// swept from adb without rebuilding:
|
|
105
|
-
// adb shell settings put global newhu_glass_engine 0 # legacy
|
|
106
|
-
// adb shell settings put global newhu_glass_engine 1 # v3
|
|
107
|
-
OnCreate {
|
|
108
|
-
val resolver = appContext.reactContext?.contentResolver ?: return@OnCreate
|
|
109
|
-
val selection = Settings.Global.getInt(resolver, "newhu_glass_engine", 1)
|
|
110
|
-
com.newhu.liquidglass.rendering.GlassEngineSelection.useV3 = selection != 0
|
|
111
|
-
// ADB opt-in observes ordinary consumers without app-side benchmark hooks.
|
|
112
|
-
pointerEventHandler.post { enableMeasurementOptIn() }
|
|
113
|
-
}
|
|
114
|
-
OnActivityEntersForeground {
|
|
115
|
-
pointerEventHandler.post { enableMeasurementOptIn() }
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
View(ExpoGlassProviderCoreView::class) {
|
|
119
|
-
Name("GlassCaptureSource")
|
|
120
|
-
Prop("providerId") { view: ExpoGlassProviderCoreView, id: String -> view.providerId = id }
|
|
121
|
-
Prop("underlayProviderId") { view: ExpoGlassProviderCoreView, id: String? -> view.underlayProviderId = id }
|
|
122
|
-
Prop("captureMode") { view: ExpoGlassProviderCoreView, mode: String? -> view.captureMode = mode ?: "live" }
|
|
123
|
-
Prop("captureOnly") { view: ExpoGlassProviderCoreView, value: Boolean? -> view.captureOnly = value ?: false }
|
|
124
|
-
Prop("snapshotBlurRadiusDp") { view: ExpoGlassProviderCoreView, radius: Float? -> view.snapshotBlurRadiusDp = radius ?: 0f }
|
|
125
|
-
Prop("sourceRevision") { view: ExpoGlassProviderCoreView, revision: String? -> view.sourceRevision = revision }
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
View(ExpoGlassSurfaceCoreView::class) {
|
|
129
|
-
Name("GlassSurface")
|
|
130
|
-
Prop("renderingEnabled") { view: ExpoGlassSurfaceCoreView, value: Boolean? ->
|
|
131
|
-
view.setRenderingEnabled(value ?: true)
|
|
132
|
-
}
|
|
133
|
-
Prop("providerId") { view: ExpoGlassSurfaceCoreView, id: String -> view.providerId = id }
|
|
134
|
-
Prop("sharedPassOrder") { view: ExpoGlassSurfaceCoreView, value: Int? -> view.sharedPassOrder = value ?: 0 }
|
|
135
|
-
Prop("sharedPassZIndex") { view: ExpoGlassSurfaceCoreView, value: Float? -> view.sharedPassZIndex = kotlin.math.round(value ?: 1f).toInt() }
|
|
136
|
-
Prop("cornerRadius") { view: ExpoGlassSurfaceCoreView, value: Float? -> view.setCornerRadius(value) }
|
|
137
|
-
Prop("shapeMaskText") { view: ExpoGlassSurfaceCoreView, value: String? -> view.setShapeMaskText(value) }
|
|
138
|
-
Prop("shapeMaskFontSize") { view: ExpoGlassSurfaceCoreView, value: Float? -> view.setShapeMaskFontSize(value) }
|
|
139
|
-
Prop("shapeMaskFontWeight") { view: ExpoGlassSurfaceCoreView, value: Int? -> view.setShapeMaskFontWeight(value) }
|
|
140
|
-
Prop("progressiveBlurIntensity") { view: ExpoGlassSurfaceCoreView, value: Float? -> view.setProgressiveBlurIntensity(value) }
|
|
141
|
-
Prop("opticsModel") { view: ExpoGlassSurfaceCoreView, value: String? -> view.setOpticsModel(value) }
|
|
142
|
-
Prop("highlightStyle") { view: ExpoGlassSurfaceCoreView, value: String? -> view.setHighlightStyle(value) }
|
|
143
|
-
Prop("interactionProfile") { view: ExpoGlassSurfaceCoreView, value: String? -> view.setInteractionProfile(value) }
|
|
144
|
-
Prop("contentScaleX") { view: ExpoGlassSurfaceCoreView, value: Float? -> view.setContentScaleX(value) }
|
|
145
|
-
Prop("contentScaleY") { view: ExpoGlassSurfaceCoreView, value: Float? -> view.setContentScaleY(value) }
|
|
146
|
-
Prop("sampleOffsetX") { view: ExpoGlassSurfaceCoreView, value: Float? -> view.setSampleOffsetX(value) }
|
|
147
|
-
Prop("sampleOffsetY") { view: ExpoGlassSurfaceCoreView, value: Float? -> view.setSampleOffsetY(value) }
|
|
148
|
-
Prop("toggleFraction") { view: ExpoGlassSurfaceCoreView, value: Float? -> view.setToggleFraction(value) }
|
|
149
|
-
Prop("toggleTrackColorOff") { view: ExpoGlassSurfaceCoreView, value: Int? -> view.setToggleTrackColorOff(value) }
|
|
150
|
-
Prop("toggleTrackColorOn") { view: ExpoGlassSurfaceCoreView, value: Int? -> view.setToggleTrackColorOn(value) }
|
|
151
|
-
Prop("toggleTrackWidth") { view: ExpoGlassSurfaceCoreView, value: Float? -> view.setToggleTrackWidth(value) }
|
|
152
|
-
Prop("toggleTrackHeight") { view: ExpoGlassSurfaceCoreView, value: Float? -> view.setToggleTrackHeight(value) }
|
|
153
|
-
Prop("toggleSolidBackdropColor") { view: ExpoGlassSurfaceCoreView, value: Int? -> view.setToggleSolidBackdropColor(value) }
|
|
154
|
-
Prop("brightness") { view: ExpoGlassSurfaceCoreView, value: Float? -> view.setBrightness(value) }
|
|
155
|
-
Prop("contrast") { view: ExpoGlassSurfaceCoreView, value: Float? -> view.setContrast(value) }
|
|
156
|
-
Prop("highlightFalloff") { view: ExpoGlassSurfaceCoreView, value: Float? -> view.setHighlightFalloff(value) }
|
|
157
|
-
Prop("highlightColor") { view: ExpoGlassSurfaceCoreView, value: Int? -> view.setHighlightColor(value) }
|
|
158
|
-
Prop("surfaceColor") { view: ExpoGlassSurfaceCoreView, value: Int? -> view.setSurfaceColor(value) }
|
|
159
|
-
Prop("sdfContrast") { view: ExpoGlassSurfaceCoreView, value: Float? -> view.setSdfContrast(value) }
|
|
160
|
-
Prop("sdfBrightness") { view: ExpoGlassSurfaceCoreView, value: Float? -> view.setSdfBrightness(value) }
|
|
161
|
-
Prop("sdfSaturation") { view: ExpoGlassSurfaceCoreView, value: Float? -> view.setSdfSaturation(value) }
|
|
162
|
-
Prop("sdfOuterShadowAlpha") { view: ExpoGlassSurfaceCoreView, value: Float? -> view.setSdfOuterShadowAlpha(value) }
|
|
163
|
-
Prop("sdfOuterShadowBlurRadius") { view: ExpoGlassSurfaceCoreView, value: Float? -> view.setSdfOuterShadowBlurRadius(value) }
|
|
164
|
-
Prop("sdfOuterShadowOffsetY") { view: ExpoGlassSurfaceCoreView, value: Float? -> view.setSdfOuterShadowOffsetY(value) }
|
|
165
|
-
Prop("sdfInnerShadowAlpha") { view: ExpoGlassSurfaceCoreView, value: Float? -> view.setSdfInnerShadowAlpha(value) }
|
|
166
|
-
Prop("sdfInnerShadowExtent") { view: ExpoGlassSurfaceCoreView, value: Float? -> view.setSdfInnerShadowExtent(value) }
|
|
167
|
-
Prop("blurRadius") { view: ExpoGlassSurfaceCoreView, value: Float? -> view.setBlurRadius(value) }
|
|
168
|
-
Prop("refractionHeight") { view: ExpoGlassSurfaceCoreView, value: Float? -> view.setRefractionHeight(value) }
|
|
169
|
-
Prop("refractionAmount") { view: ExpoGlassSurfaceCoreView, value: Float? -> view.setRefractionAmount(value) }
|
|
170
|
-
Prop("depthEffect") { view: ExpoGlassSurfaceCoreView, value: Boolean? -> view.setDepthEffect(value) }
|
|
171
|
-
Prop("bodyRefractionAmount") { view: ExpoGlassSurfaceCoreView, value: Float? -> view.setBodyRefractionAmount(value) }
|
|
172
|
-
Prop("interactionPointX") { view: ExpoGlassSurfaceCoreView, value: Float? -> view.setInteractionPointX(value) }
|
|
173
|
-
Prop("interactionPointY") { view: ExpoGlassSurfaceCoreView, value: Float? -> view.setInteractionPointY(value) }
|
|
174
|
-
Prop("interactionProgress") { view: ExpoGlassSurfaceCoreView, value: Float? -> view.setInteractionProgress(value) }
|
|
175
|
-
Prop("pointerEvent") { view: ExpoGlassSurfaceCoreView, value: String? -> view.forwardPointerProp(value) }
|
|
176
|
-
Prop("valueEvent") { view: ExpoGlassSurfaceCoreView, value: String? -> view.forwardValueProp(value) }
|
|
177
|
-
Prop("interactionVelocityX") { view: ExpoGlassSurfaceCoreView, value: Float? -> view.setInteractionVelocityX(value) }
|
|
178
|
-
Prop("interactionVelocityY") { view: ExpoGlassSurfaceCoreView, value: Float? -> view.setInteractionVelocityY(value) }
|
|
179
|
-
Prop("saturation") { view: ExpoGlassSurfaceCoreView, value: Float? -> view.setSaturation(value) }
|
|
180
|
-
Prop("tint") { view: ExpoGlassSurfaceCoreView, value: Int? -> view.setTint(value) }
|
|
181
|
-
Prop("tintAlpha") { view: ExpoGlassSurfaceCoreView, value: Float? -> view.setTintAlpha(value) }
|
|
182
|
-
Prop("chromaticAberration") { view: ExpoGlassSurfaceCoreView, value: Float? -> view.setChromaticAberration(value) }
|
|
183
|
-
Prop("noiseAlpha") { view: ExpoGlassSurfaceCoreView, value: Float? -> view.setNoiseAlpha(value) }
|
|
184
|
-
Prop("highlightAlpha") { view: ExpoGlassSurfaceCoreView, value: Float? -> view.setHighlightAlpha(value) }
|
|
185
|
-
Prop("specularStrength") { view: ExpoGlassSurfaceCoreView, value: Float? -> view.setSpecularStrength(value) }
|
|
186
|
-
Prop("fresnelStrength") { view: ExpoGlassSurfaceCoreView, value: Float? -> view.setFresnelStrength(value) }
|
|
187
|
-
Prop("innerShadowStrength") { view: ExpoGlassSurfaceCoreView, value: Float? -> view.setInnerShadowStrength(value) }
|
|
188
|
-
Prop("shadowOpacity") { view: ExpoGlassSurfaceCoreView, value: Float? -> view.setShadowOpacity(value) }
|
|
189
|
-
Prop("shadowRadius") { view: ExpoGlassSurfaceCoreView, value: Float? -> view.setShadowRadius(value) }
|
|
190
|
-
Prop("shadowOffsetY") { view: ExpoGlassSurfaceCoreView, value: Float? -> view.setShadowOffsetY(value) }
|
|
191
|
-
Prop("highlightWidth") { view: ExpoGlassSurfaceCoreView, value: Float? -> view.setHighlightWidth(value) }
|
|
192
|
-
Prop("lightAngle") { view: ExpoGlassSurfaceCoreView, value: Float? -> view.setLightAngle(value) }
|
|
193
|
-
Prop("interactive") { view: ExpoGlassSurfaceCoreView, value: Boolean? -> view.setInteractive(value) }
|
|
194
|
-
Prop("motionX") { view: ExpoGlassSurfaceCoreView, value: Float? -> view.setMotionX(value) }
|
|
195
|
-
Prop("motionY") { view: ExpoGlassSurfaceCoreView, value: Float? -> view.setMotionY(value) }
|
|
196
|
-
Prop("displacementOnlyDebug") { view: ExpoGlassSurfaceCoreView, value: Boolean? -> view.setDisplacementOnlyDebug(value) }
|
|
197
|
-
Prop("sdfDisplacementMapDebug") { view: ExpoGlassSurfaceCoreView, value: Boolean? -> view.setSdfDisplacementMapDebug(value) }
|
|
198
|
-
Prop("continuous") { view: ExpoGlassSurfaceCoreView, value: Boolean? -> view.setContinuous(value) }
|
|
199
|
-
Prop("sharedSource") { view: ExpoGlassSurfaceCoreView, value: Boolean? -> view.setSharedSource(value) }
|
|
200
|
-
Prop("captureProbe") { view: ExpoGlassSurfaceCoreView, value: Boolean? -> view.setCaptureProbe(value) }
|
|
201
|
-
Prop("syncContentTransform") { view: ExpoGlassSurfaceCoreView, value: Boolean? -> view.syncContentTransform = value ?: false }
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
Function("setPerformanceTelemetryEnabled") { enabled: Boolean ->
|
|
205
|
-
pointerEventHandler.post { setPerformanceTelemetry(enabled) }
|
|
206
|
-
}
|
|
207
|
-
Function("beginEffectiveScrollFpsSession") { page: String ->
|
|
208
|
-
EffectiveScrollFpsProbe.beginSession(page)
|
|
209
|
-
}
|
|
210
|
-
AsyncFunction("getPerformanceStats") {
|
|
211
|
-
LiquidGlassPerfTelemetry.snapshot() + EffectiveScrollFpsProbe.snapshot()
|
|
212
|
-
}
|
|
213
|
-
Function("setSharedPassEnabled") { enabled: Boolean ->
|
|
214
|
-
com.newhu.liquidglass.core.SharedGlassPass.setEnabled(enabled)
|
|
215
|
-
}
|
|
216
|
-
Function("setSharedPassProbe") { enabled: Boolean ->
|
|
217
|
-
com.newhu.liquidglass.core.SharedGlassPass.PROBE = enabled
|
|
218
|
-
}
|
|
219
|
-
Function("setCaptureMode") { providerId: String, mode: String ->
|
|
220
|
-
CoreLiquidGlassRegistry.setCaptureMode(providerId, mode)
|
|
221
|
-
}
|
|
222
|
-
Function("prepareFrozenBackdrop") { providerId: String, blurRadiusDp: Float ->
|
|
223
|
-
CoreLiquidGlassRegistry.prepareFrozenBackdrop(providerId, blurRadiusDp)
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
}
|