glacia-native 0.5.2 → 0.6.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 +84 -17
- package/lib/module/Accordion.js +58 -0
- package/lib/module/ActionSheet.js +38 -0
- package/lib/module/Alert.js +23 -0
- package/lib/module/AlertDialog.js +47 -0
- package/lib/module/Avatar.js +48 -0
- package/lib/module/Badge.js +36 -0
- package/lib/module/Bars.js +13 -268
- package/lib/module/Button.js +57 -39
- package/lib/module/Card.js +31 -19
- package/lib/module/Checkbox.js +42 -0
- package/lib/module/Chip.js +80 -0
- package/lib/module/Collapsible.js +26 -0
- package/lib/module/ContextMenu.js +33 -0
- package/lib/module/Dialog.js +39 -123
- package/lib/module/DropdownMenu.js +33 -0
- package/lib/module/Field.js +22 -0
- package/lib/module/Glass.js +10 -3
- package/lib/module/Group.js +36 -0
- package/lib/module/IconButton.js +40 -0
- package/lib/module/Input.js +43 -38
- package/lib/module/Label.js +17 -0
- package/lib/module/MorphGroup.js +47 -0
- package/lib/module/Popover.js +29 -0
- package/lib/module/Progress.js +32 -0
- package/lib/module/RadioGroup.js +51 -0
- package/lib/module/Scrim.js +44 -0
- package/lib/module/SegmentedControl.js +70 -63
- package/lib/module/Select.js +51 -0
- package/lib/module/Separator.js +25 -0
- package/lib/module/Sheet.js +51 -0
- package/lib/module/Skeleton.js +48 -0
- package/lib/module/Slider.js +45 -34
- package/lib/module/Stepper.js +167 -0
- package/lib/module/Switch.js +45 -55
- package/lib/module/TabBar.js +50 -44
- package/lib/module/Textarea.js +18 -0
- package/lib/module/Toast.js +55 -0
- package/lib/module/Toggle.js +47 -0
- package/lib/module/ToggleGroup.js +56 -0
- package/lib/module/Toolbar.js +37 -0
- package/lib/module/Tooltip.js +31 -0
- package/lib/module/glass-provider.js +28 -0
- package/lib/module/glass-stack.js +61 -0
- package/lib/module/index.js +78 -109
- package/lib/module/internal/GlassBackdrop.js +36 -0
- package/lib/module/internal/GlassView.js +43 -11
- package/lib/module/internal/blur-community.js +20 -0
- package/lib/module/internal/blur-community.web.js +9 -0
- package/lib/module/internal/blur.js +6 -9
- package/lib/module/internal/glass-routing.js +154 -30
- package/lib/module/internal/initials.js +12 -0
- package/lib/module/internal/overlay.js +147 -0
- package/lib/module/internal/primitives.js +16 -0
- package/lib/typescript/Accordion.d.ts +22 -0
- package/lib/typescript/ActionSheet.d.ts +24 -0
- package/lib/typescript/Alert.d.ts +15 -0
- package/lib/typescript/AlertDialog.d.ts +17 -0
- package/lib/typescript/Avatar.d.ts +22 -0
- package/lib/typescript/Badge.d.ts +12 -0
- package/lib/typescript/Bars.d.ts +3 -188
- package/lib/typescript/Button.d.ts +44 -10
- package/lib/typescript/Card.d.ts +30 -3
- package/lib/typescript/Checkbox.d.ts +14 -0
- package/lib/typescript/Chip.d.ts +19 -0
- package/lib/typescript/Collapsible.d.ts +17 -0
- package/lib/typescript/ContextMenu.d.ts +23 -0
- package/lib/typescript/Dialog.d.ts +8 -68
- package/lib/typescript/DropdownMenu.d.ts +23 -0
- package/lib/typescript/Field.d.ts +19 -0
- package/lib/typescript/Glass.d.ts +11 -2
- package/lib/typescript/Group.d.ts +35 -0
- package/lib/typescript/IconButton.d.ts +21 -0
- package/lib/typescript/Input.d.ts +17 -18
- package/lib/typescript/Label.d.ts +14 -0
- package/lib/typescript/MorphGroup.d.ts +46 -0
- package/lib/typescript/Popover.d.ts +17 -0
- package/lib/typescript/Progress.d.ts +13 -0
- package/lib/typescript/RadioGroup.d.ts +21 -0
- package/lib/typescript/Scrim.d.ts +33 -0
- package/lib/typescript/SegmentedControl.d.ts +24 -13
- package/lib/typescript/Select.d.ts +19 -0
- package/lib/typescript/Separator.d.ts +10 -0
- package/lib/typescript/Sheet.d.ts +45 -0
- package/lib/typescript/Skeleton.d.ts +10 -0
- package/lib/typescript/Slider.d.ts +15 -7
- package/lib/typescript/Stepper.d.ts +49 -0
- package/lib/typescript/Switch.d.ts +19 -12
- package/lib/typescript/TabBar.d.ts +18 -6
- package/lib/typescript/Textarea.d.ts +6 -0
- package/lib/typescript/Toast.d.ts +40 -0
- package/lib/typescript/Toggle.d.ts +21 -0
- package/lib/typescript/ToggleGroup.d.ts +22 -0
- package/lib/typescript/Toolbar.d.ts +35 -0
- package/lib/typescript/Tooltip.d.ts +16 -0
- package/lib/typescript/glass-provider.d.ts +34 -0
- package/lib/typescript/glass-stack.d.ts +54 -0
- package/lib/typescript/index.d.ts +38 -17
- package/lib/typescript/internal/GlassBackdrop.d.ts +33 -0
- package/lib/typescript/internal/GlassView.d.ts +18 -2
- package/lib/typescript/internal/blur-community.d.ts +2 -0
- package/lib/typescript/internal/blur-community.web.d.ts +2 -0
- package/lib/typescript/internal/glass-routing.d.ts +83 -15
- package/lib/typescript/internal/initials.d.ts +2 -0
- package/lib/typescript/internal/overlay.d.ts +74 -0
- package/lib/typescript/internal/primitives.d.ts +11 -0
- package/package.json +4 -2
- package/src/Accordion.tsx +165 -0
- package/src/ActionSheet.tsx +149 -0
- package/src/Alert.tsx +85 -0
- package/src/AlertDialog.tsx +124 -0
- package/src/Avatar.tsx +102 -0
- package/src/Badge.tsx +80 -0
- package/src/Bars.tsx +10 -807
- package/src/Button.tsx +196 -67
- package/src/Card.tsx +105 -32
- package/src/Checkbox.tsx +98 -0
- package/src/Chip.tsx +149 -0
- package/src/Collapsible.tsx +66 -0
- package/src/ContextMenu.tsx +103 -0
- package/src/Dialog.tsx +85 -335
- package/src/DropdownMenu.tsx +103 -0
- package/src/Field.tsx +65 -0
- package/src/Glass.tsx +15 -5
- package/src/Group.tsx +98 -0
- package/src/IconButton.tsx +110 -0
- package/src/Input.tsx +139 -87
- package/src/Label.tsx +56 -0
- package/src/MorphGroup.tsx +134 -0
- package/src/Popover.tsx +81 -0
- package/src/Progress.tsx +83 -0
- package/src/RadioGroup.tsx +122 -0
- package/src/Scrim.tsx +94 -0
- package/src/SegmentedControl.tsx +132 -99
- package/src/Select.tsx +136 -0
- package/src/Separator.tsx +52 -0
- package/src/Sheet.tsx +139 -0
- package/src/Skeleton.tsx +77 -0
- package/src/Slider.tsx +84 -47
- package/src/Stepper.tsx +315 -0
- package/src/Switch.tsx +81 -73
- package/src/TabBar.tsx +106 -93
- package/src/Textarea.tsx +34 -0
- package/src/Toast.tsx +131 -0
- package/src/Toggle.tsx +113 -0
- package/src/ToggleGroup.tsx +129 -0
- package/src/Toolbar.tsx +111 -0
- package/src/Tooltip.tsx +79 -0
- package/src/engine/CHANGELOG.md +430 -0
- package/src/engine/NOTICE +54 -0
- package/src/engine/README.md +975 -0
- package/src/engine/android/build.gradle +18 -0
- package/src/engine/android/src/main/AndroidManifest.xml +2 -0
- package/src/engine/android/src/main/java/expo/modules/liquidglass/ExpoLiquidGlassModule.kt +174 -0
- package/src/engine/android/src/main/java/expo/modules/liquidglass/GlassConstants.kt +7 -0
- package/src/engine/android/src/main/java/expo/modules/liquidglass/LiquidGlassContainerView.kt +16 -0
- package/src/engine/android/src/main/java/expo/modules/liquidglass/LiquidGlassProviderView.kt +165 -0
- package/src/engine/android/src/main/java/expo/modules/liquidglass/LiquidGlassView.kt +1731 -0
- package/src/engine/android/src/main/java/expo/modules/liquidglass/enums/GlassEnums.kt +171 -0
- package/src/engine/android/src/main/java/expo/modules/liquidglass/glass/BackdropGraph.kt +146 -0
- package/src/engine/android/src/main/java/expo/modules/liquidglass/glass/BackdropSource.kt +53 -0
- package/src/engine/android/src/main/java/expo/modules/liquidglass/glass/ContinuousCorners.kt +188 -0
- package/src/engine/android/src/main/java/expo/modules/liquidglass/glass/CornerRadii.kt +62 -0
- package/src/engine/android/src/main/java/expo/modules/liquidglass/glass/GlassAppearance.kt +352 -0
- package/src/engine/android/src/main/java/expo/modules/liquidglass/glass/GlassDebug.kt +109 -0
- package/src/engine/android/src/main/java/expo/modules/liquidglass/glass/GlassEnvironment.kt +139 -0
- package/src/engine/android/src/main/java/expo/modules/liquidglass/glass/GlassHdr.kt +85 -0
- package/src/engine/android/src/main/java/expo/modules/liquidglass/glass/GlassLuminanceProbe.kt +189 -0
- package/src/engine/android/src/main/java/expo/modules/liquidglass/glass/GlassPressAnimator.kt +264 -0
- package/src/engine/android/src/main/java/expo/modules/liquidglass/glass/GlassProgressiveBlur.kt +249 -0
- package/src/engine/android/src/main/java/expo/modules/liquidglass/glass/GlassShaderCache.kt +256 -0
- package/src/engine/android/src/main/java/expo/modules/liquidglass/glass/GlassShaderSource.kt +845 -0
- package/src/engine/android/src/main/java/expo/modules/liquidglass/glass/GlassTier.kt +63 -0
- package/src/engine/android/src/main/java/expo/modules/liquidglass/glass/ProviderRegistry.kt +71 -0
- package/src/engine/android/src/main/java/expo/modules/liquidglass/records/GlassRecords.kt +288 -0
- package/src/engine/index.ts +24 -0
- package/src/engine/ios/Enums/GlassBlurDirection.swift +21 -0
- package/src/engine/ios/Enums/GlassVariant.swift +86 -0
- package/src/engine/ios/ExpoLiquidGlass.podspec +93 -0
- package/src/engine/ios/ExpoLiquidGlassModule.swift +77 -0
- package/src/engine/ios/Glass/BackdropCapturer.swift +811 -0
- package/src/engine/ios/Glass/ContinuousCorners.swift +165 -0
- package/src/engine/ios/Glass/GlassBackdrop.swift +176 -0
- package/src/engine/ios/Glass/GlassFramePhase.swift +126 -0
- package/src/engine/ios/Glass/GlassFrameScheduler.swift +261 -0
- package/src/engine/ios/Glass/GlassPressAnimator.swift +250 -0
- package/src/engine/ios/Glass/GlassRenderContext.swift +168 -0
- package/src/engine/ios/Glass/GlassRenderer.swift +186 -0
- package/src/engine/ios/Glass/GlassSurfaceView.swift +452 -0
- package/src/engine/ios/Glass/NonRenderableView.swift +54 -0
- package/src/engine/ios/Glass/StripCache.swift +545 -0
- package/src/engine/ios/Records/GlassCornerRadii.swift +79 -0
- package/src/engine/ios/Records/GlassMetalOptions.swift +180 -0
- package/src/engine/ios/Records/GlassRefractionCurve.swift +14 -0
- package/src/engine/ios/Shaders/LiquidGlass.metal +480 -0
- package/src/engine/ios/Shaders/bundle-marker.txt +6 -0
- package/src/engine/ios/Views/LiquidGlassContainerView.swift +99 -0
- package/src/engine/ios/Views/LiquidGlassView.swift +859 -0
- package/src/engine/package.json +70 -0
- package/src/engine/src/components/LiquidGlassButton/LiquidGlassButton.tsx +424 -0
- package/src/engine/src/components/LiquidGlassCard/LiquidGlassCard.tsx +98 -0
- package/src/engine/src/components/LiquidGlassChip/LiquidGlassChip.tsx +65 -0
- package/src/engine/src/components/LiquidGlassGroup/LiquidGlassGroup.tsx +350 -0
- package/src/engine/src/components/LiquidGlassIconButton/LiquidGlassIconButton.tsx +24 -0
- package/src/engine/src/components/LiquidGlassMorphGroup/LiquidGlassMorphGroup.tsx +434 -0
- package/src/engine/src/components/LiquidGlassScrim/LiquidGlassScrim.tsx +100 -0
- package/src/engine/src/components/LiquidGlassSegmentedControl/LiquidGlassSegmentedControl.tsx +213 -0
- package/src/engine/src/components/LiquidGlassSheet/LiquidGlassSheet.tsx +218 -0
- package/src/engine/src/components/LiquidGlassSlider/LiquidGlassSlider.tsx +327 -0
- package/src/engine/src/components/LiquidGlassStepper/LiquidGlassStepper.tsx +321 -0
- package/src/engine/src/components/LiquidGlassSwitch/LiquidGlassSwitch.tsx +296 -0
- package/src/engine/src/components/LiquidGlassTabBar/LiquidGlassTabBar.tsx +952 -0
- package/src/engine/src/components/LiquidGlassTextInput/LiquidGlassTextInput.tsx +151 -0
- package/src/engine/src/components/LiquidGlassToast/LiquidGlassToast.tsx +169 -0
- package/src/engine/src/components/LiquidGlassToolbar/LiquidGlassToolbar.tsx +124 -0
- package/src/engine/src/components/index.ts +16 -0
- package/src/engine/src/constants/index.ts +4 -0
- package/src/engine/src/constants/metal.constants.ts +327 -0
- package/src/engine/src/constants/metrics.constants.ts +325 -0
- package/src/engine/src/constants/springs.constants.ts +107 -0
- package/src/engine/src/constants/styles.constants.ts +12 -0
- package/src/engine/src/context/glass-group.context.ts +65 -0
- package/src/engine/src/context/index.ts +6 -0
- package/src/engine/src/core/components/LiquidGlassContainer/LiquidGlassContainer.tsx +32 -0
- package/src/engine/src/core/components/LiquidGlassContainer/index.ts +1 -0
- package/src/engine/src/core/components/LiquidGlassProvider/LiquidGlassProvider.tsx +66 -0
- package/src/engine/src/core/components/LiquidGlassProvider/index.ts +1 -0
- package/src/engine/src/core/components/LiquidGlassStack/LiquidGlassStack.tsx +184 -0
- package/src/engine/src/core/components/LiquidGlassStack/index.ts +1 -0
- package/src/engine/src/core/components/LiquidGlassView/LiquidGlassView.tsx +126 -0
- package/src/engine/src/core/components/LiquidGlassView/index.ts +1 -0
- package/src/engine/src/core/components/index.ts +4 -0
- package/src/engine/src/core/constants/glass.constants.ts +57 -0
- package/src/engine/src/core/constants/index.ts +20 -0
- package/src/engine/src/core/constants/native.constants.ts +16 -0
- package/src/engine/src/core/context/glass-stack.context.ts +30 -0
- package/src/engine/src/core/context/index.ts +4 -0
- package/src/engine/src/core/enum/index.ts +12 -0
- package/src/engine/src/core/index.ts +1 -0
- package/src/engine/src/core/interfaces/glass-hdr.interface.ts +15 -0
- package/src/engine/src/core/interfaces/glass-metal.interface.ts +248 -0
- package/src/engine/src/core/interfaces/glass-surface.interface.ts +9 -0
- package/src/engine/src/core/interfaces/index.ts +31 -0
- package/src/engine/src/core/interfaces/liquid-glass-container.interface.ts +6 -0
- package/src/engine/src/core/interfaces/liquid-glass-provider.interface.ts +14 -0
- package/src/engine/src/core/interfaces/liquid-glass-stack.interface.ts +21 -0
- package/src/engine/src/core/interfaces/liquid-glass-view.interface.ts +129 -0
- package/src/engine/src/core/interfaces/native-liquid-glass-view.interface.ts +19 -0
- package/src/engine/src/core/modules/ExpoLiquidGlassModule.ts +26 -0
- package/src/engine/src/core/modules/index.ts +2 -0
- package/src/engine/src/core/root/index.ts +51 -0
- package/src/engine/src/core/types/glass.types.ts +25 -0
- package/src/engine/src/core/types/index.ts +8 -0
- package/src/engine/src/core/utils/debug.utils.ts +17 -0
- package/src/engine/src/core/utils/dev-warn.utils.ts +17 -0
- package/src/engine/src/core/utils/hdr.utils.ts +37 -0
- package/src/engine/src/core/utils/index.ts +5 -0
- package/src/engine/src/core/utils/native-view.utils.ts +33 -0
- package/src/engine/src/core/utils/platform.utils.ts +34 -0
- package/src/engine/src/core/views/NativeGlassBackdropView.ts +24 -0
- package/src/engine/src/core/views/NativeLiquidGlassContainerView.ts +13 -0
- package/src/engine/src/core/views/NativeLiquidGlassContainerView.web.ts +10 -0
- package/src/engine/src/core/views/NativeLiquidGlassProviderView.ts +13 -0
- package/src/engine/src/core/views/NativeLiquidGlassProviderView.web.ts +10 -0
- package/src/engine/src/core/views/NativeLiquidGlassView.ts +19 -0
- package/src/engine/src/core/views/NativeLiquidGlassView.web.ts +14 -0
- package/src/engine/src/core/views/index.ts +4 -0
- package/src/engine/src/hooks/index.ts +18 -0
- package/src/engine/src/hooks/use-adaptive-glass.ts +91 -0
- package/src/engine/src/hooks/use-damped-drag.ts +332 -0
- package/src/engine/src/hooks/use-echo-filter.ts +55 -0
- package/src/engine/src/hooks/use-glass-group-member.ts +169 -0
- package/src/engine/src/hooks/use-gravity-highlight.ts +79 -0
- package/src/engine/src/hooks/use-press-progress.ts +44 -0
- package/src/engine/src/index.ts +120 -0
- package/src/engine/src/interfaces/index.ts +28 -0
- package/src/engine/src/interfaces/liquid-glass-button.interface.ts +94 -0
- package/src/engine/src/interfaces/liquid-glass-card.interface.ts +40 -0
- package/src/engine/src/interfaces/liquid-glass-chip.interface.ts +29 -0
- package/src/engine/src/interfaces/liquid-glass-group.interface.ts +32 -0
- package/src/engine/src/interfaces/liquid-glass-icon-button.interface.ts +19 -0
- package/src/engine/src/interfaces/liquid-glass-morph-group.interface.ts +59 -0
- package/src/engine/src/interfaces/liquid-glass-scrim.interface.ts +36 -0
- package/src/engine/src/interfaces/liquid-glass-segmented-control.interface.ts +32 -0
- package/src/engine/src/interfaces/liquid-glass-sheet.interface.ts +38 -0
- package/src/engine/src/interfaces/liquid-glass-slider.interface.ts +37 -0
- package/src/engine/src/interfaces/liquid-glass-stepper.interface.ts +35 -0
- package/src/engine/src/interfaces/liquid-glass-switch.interface.ts +27 -0
- package/src/engine/src/interfaces/liquid-glass-tab-bar.interface.ts +116 -0
- package/src/engine/src/interfaces/liquid-glass-text-input.interface.ts +42 -0
- package/src/engine/src/interfaces/liquid-glass-toast.interface.ts +36 -0
- package/src/engine/src/interfaces/liquid-glass-toolbar.interface.ts +33 -0
- package/src/engine/src/theme/glass-ui-theme.ts +100 -0
- package/src/engine/src/theme/index.ts +2 -0
- package/src/engine/src/utils/button-press.utils.ts +63 -0
- package/src/engine/src/utils/index.ts +3 -0
- package/src/engine/src/utils/metal.utils.ts +164 -0
- package/src/glass-provider.tsx +60 -0
- package/src/glass-stack.tsx +115 -0
- package/src/index.ts +47 -190
- package/src/internal/GlassBackdrop.tsx +60 -0
- package/src/internal/GlassView.tsx +53 -18
- package/src/internal/blur-community.ts +19 -0
- package/src/internal/blur-community.web.ts +7 -0
- package/src/internal/blur.ts +7 -8
- package/src/internal/glass-routing.ts +211 -34
- package/src/internal/initials.ts +7 -0
- package/src/internal/overlay.tsx +258 -0
- package/src/internal/primitives.ts +23 -0
- package/lib/module/Carousel.js +0 -103
- package/lib/module/Display.js +0 -318
- package/lib/module/Feedback.js +0 -395
- package/lib/module/Form.js +0 -160
- package/lib/module/Forms2.js +0 -471
- package/lib/module/Message.js +0 -84
- package/lib/module/Overlays.js +0 -344
- package/lib/module/Pickers.js +0 -243
- package/lib/module/Table.js +0 -100
- package/lib/module/ai.js +0 -283
- package/lib/module/charts/AreaChart.js +0 -32
- package/lib/module/charts/BarChart.js +0 -75
- package/lib/module/charts/FunnelChart.js +0 -50
- package/lib/module/charts/HeatmapChart.js +0 -71
- package/lib/module/charts/LineChart.js +0 -81
- package/lib/module/charts/PlotChart.js +0 -52
- package/lib/module/charts/RadarChart.js +0 -78
- package/lib/module/charts/RingChart.js +0 -52
- package/lib/module/charts/ScatterChart.js +0 -95
- package/lib/module/charts/WaterfallChart.js +0 -85
- package/lib/module/charts/advanced.js +0 -313
- package/lib/module/charts/extra.js +0 -108
- package/lib/module/charts/index.js +0 -50
- package/lib/module/charts/scales.js +0 -140
- package/lib/typescript/Carousel.d.ts +0 -47
- package/lib/typescript/Display.d.ts +0 -178
- package/lib/typescript/Feedback.d.ts +0 -196
- package/lib/typescript/Form.d.ts +0 -97
- package/lib/typescript/Forms2.d.ts +0 -209
- package/lib/typescript/Message.d.ts +0 -67
- package/lib/typescript/Overlays.d.ts +0 -146
- package/lib/typescript/Pickers.d.ts +0 -105
- package/lib/typescript/Table.d.ts +0 -64
- package/lib/typescript/ai.d.ts +0 -166
- package/lib/typescript/charts/AreaChart.d.ts +0 -44
- package/lib/typescript/charts/BarChart.d.ts +0 -19
- package/lib/typescript/charts/FunnelChart.d.ts +0 -25
- package/lib/typescript/charts/HeatmapChart.d.ts +0 -23
- package/lib/typescript/charts/LineChart.d.ts +0 -30
- package/lib/typescript/charts/PlotChart.d.ts +0 -31
- package/lib/typescript/charts/RadarChart.d.ts +0 -27
- package/lib/typescript/charts/RingChart.d.ts +0 -28
- package/lib/typescript/charts/ScatterChart.d.ts +0 -34
- package/lib/typescript/charts/WaterfallChart.d.ts +0 -22
- package/lib/typescript/charts/advanced.d.ts +0 -107
- package/lib/typescript/charts/extra.d.ts +0 -63
- package/lib/typescript/charts/index.d.ts +0 -13
- package/lib/typescript/charts/scales.d.ts +0 -35
- package/src/Carousel.tsx +0 -233
- package/src/Display.tsx +0 -781
- package/src/Feedback.tsx +0 -992
- package/src/Form.tsx +0 -445
- package/src/Forms2.tsx +0 -1055
- package/src/Message.tsx +0 -218
- package/src/Overlays.tsx +0 -704
- package/src/Pickers.tsx +0 -595
- package/src/Table.tsx +0 -232
- package/src/ai.tsx +0 -715
- package/src/charts/AreaChart.tsx +0 -73
- package/src/charts/BarChart.tsx +0 -221
- package/src/charts/FunnelChart.tsx +0 -125
- package/src/charts/HeatmapChart.tsx +0 -155
- package/src/charts/LineChart.tsx +0 -247
- package/src/charts/PlotChart.tsx +0 -168
- package/src/charts/RadarChart.tsx +0 -208
- package/src/charts/RingChart.tsx +0 -133
- package/src/charts/ScatterChart.tsx +0 -223
- package/src/charts/WaterfallChart.tsx +0 -201
- package/src/charts/advanced.tsx +0 -676
- package/src/charts/extra.tsx +0 -242
- package/src/charts/index.ts +0 -86
- package/src/charts/scales.ts +0 -163
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
import CoreGraphics
|
|
2
|
+
import UIKit
|
|
3
|
+
import simd
|
|
4
|
+
|
|
5
|
+
/// The continuous-corner ("squircle") curve family, shared by the Core Animation paths and the
|
|
6
|
+
/// Metal SDF — the Swift twin of the Android `ContinuousCorners.kt`, same constants.
|
|
7
|
+
///
|
|
8
|
+
/// One curve, two renderers: a corner is a superellipse quadrant in an E x E cell,
|
|
9
|
+
/// `((E-x)/E)^n + ((E-y)/E)^n = 1`, with the circular corner as its exact (E = r, n = 2) member.
|
|
10
|
+
/// The constants are calibrated against the PaintCode reverse-engineering of Apple's continuous
|
|
11
|
+
/// rounded rect — max deviation 7.3e-3 r, sub-pixel at every UI radius. Method, provenance and
|
|
12
|
+
/// error tables: `docs/android-port/research/05-continuous-corner-calibration.md`.
|
|
13
|
+
///
|
|
14
|
+
/// The resolver and the path builder must stay in lock-step with the shader's `sdGlassRect` /
|
|
15
|
+
/// `gradGlassRect`: the border stroke is drawn on these paths *over* the shader's rim, and at a
|
|
16
|
+
/// 1 pt border against a 0.75 pt rim, disagreement reads as a double edge — which is exactly what
|
|
17
|
+
/// the old circular border did over Apple's continuous content clip, by up to 0.12 r at the
|
|
18
|
+
/// corner apex.
|
|
19
|
+
enum ContinuousCorners {
|
|
20
|
+
|
|
21
|
+
/// Apple's corner extent per unit radius — where the curve departs the straight edge. Exact.
|
|
22
|
+
static let extent: CGFloat = 1.52866483
|
|
23
|
+
|
|
24
|
+
/// Fitted superellipse exponent at full extent (research/05, fit 1).
|
|
25
|
+
static let fullExponent: Float = 3.3418
|
|
26
|
+
|
|
27
|
+
/// Below this an exponent is circular — must match the shader's `n > 2.001` test.
|
|
28
|
+
static let circularExponent: Float = 2
|
|
29
|
+
|
|
30
|
+
struct Resolved: Equatable {
|
|
31
|
+
// Field order TL, TR, BR, BL — the `CornerRadiiValues` order.
|
|
32
|
+
var extentTL: CGFloat = 0
|
|
33
|
+
var extentTR: CGFloat = 0
|
|
34
|
+
var extentBR: CGFloat = 0
|
|
35
|
+
var extentBL: CGFloat = 0
|
|
36
|
+
var shapeTL: Float = ContinuousCorners.circularExponent
|
|
37
|
+
var shapeTR: Float = ContinuousCorners.circularExponent
|
|
38
|
+
var shapeBR: Float = ContinuousCorners.circularExponent
|
|
39
|
+
var shapeBL: Float = ContinuousCorners.circularExponent
|
|
40
|
+
|
|
41
|
+
/// The shader's packing, which is NOT the field order:
|
|
42
|
+
/// `.x` = bottom-left, `.y` = bottom-right, `.z` = top-right, `.w` = top-left.
|
|
43
|
+
var extentsSIMD: SIMD4<Float> {
|
|
44
|
+
SIMD4<Float>(Float(extentBL), Float(extentBR), Float(extentTR), Float(extentTL))
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
var shapesSIMD: SIMD4<Float> {
|
|
48
|
+
SIMD4<Float>(shapeBL, shapeBR, shapeTR, shapeTL)
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/// Resolves per-corner cell extents and exponents for a rect of `size`.
|
|
53
|
+
///
|
|
54
|
+
/// Rules (research/05): desired `E = extent * r`; if the two desired extents on an edge
|
|
55
|
+
/// overflow the side, both scale by `side / sum` and a corner takes the min of its two edges'
|
|
56
|
+
/// scales; then a hard cap at `min(halfW, halfH)` keeps every cell inside its quadrant.
|
|
57
|
+
/// `clamped(to:)` guarantees `r_a + r_b <= side`, so the scale never pushes E below r —
|
|
58
|
+
/// `E/r` stays in `[1, extent]` and the exponent blend never extrapolates. At the capsule
|
|
59
|
+
/// limit (E = r) the exponent lands on exactly 2, which is what makes pills keep true
|
|
60
|
+
/// circular ends.
|
|
61
|
+
static func resolve(_ radii: CornerRadiiValues, continuous: Bool, size: CGSize) -> Resolved {
|
|
62
|
+
let r: [CGFloat] = [radii.topLeft, radii.topRight, radii.bottomRight, radii.bottomLeft]
|
|
63
|
+
var extents = r
|
|
64
|
+
var shapes = [Float](repeating: circularExponent, count: 4)
|
|
65
|
+
|
|
66
|
+
if continuous, !radii.isZero {
|
|
67
|
+
func edgeScale(_ a: CGFloat, _ b: CGFloat, _ side: CGFloat) -> CGFloat {
|
|
68
|
+
let sum = (a + b) * extent
|
|
69
|
+
return (sum > side && sum > 0) ? side / sum : 1
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
let top = edgeScale(r[0], r[1], size.width)
|
|
73
|
+
let bottom = edgeScale(r[3], r[2], size.width)
|
|
74
|
+
let left = edgeScale(r[0], r[3], size.height)
|
|
75
|
+
let right = edgeScale(r[1], r[2], size.height)
|
|
76
|
+
|
|
77
|
+
let scale: [CGFloat] = [
|
|
78
|
+
min(top, left), // TL
|
|
79
|
+
min(top, right), // TR
|
|
80
|
+
min(bottom, right), // BR
|
|
81
|
+
min(bottom, left), // BL
|
|
82
|
+
]
|
|
83
|
+
|
|
84
|
+
let cap = min(size.width, size.height) / 2
|
|
85
|
+
for i in 0..<4 {
|
|
86
|
+
let radius = r[i]
|
|
87
|
+
if radius <= 0 {
|
|
88
|
+
extents[i] = 0
|
|
89
|
+
shapes[i] = circularExponent
|
|
90
|
+
continue
|
|
91
|
+
}
|
|
92
|
+
let e = min(radius * extent * scale[i], cap)
|
|
93
|
+
let blend = min(max((e / radius - 1) / (extent - 1), 0), 1)
|
|
94
|
+
extents[i] = e
|
|
95
|
+
shapes[i] = circularExponent + (fullExponent - circularExponent) * Float(blend)
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
return Resolved(
|
|
100
|
+
extentTL: extents[0], extentTR: extents[1], extentBR: extents[2], extentBL: extents[3],
|
|
101
|
+
shapeTL: shapes[0], shapeTR: shapes[1], shapeBR: shapes[2], shapeBL: shapes[3]
|
|
102
|
+
)
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/// The continuous rounded rect as a clockwise contour.
|
|
106
|
+
///
|
|
107
|
+
/// Corners are sampled from the same superellipse the shader evaluates — a polyline, not the
|
|
108
|
+
/// PaintCode beziers — so path and SDF agree exactly by construction. At `segmentsPerCorner`
|
|
109
|
+
/// steps the chord sagitta stays under ~0.1 px for any extent that fits a phone screen, and
|
|
110
|
+
/// the paths are rebuilt only on geometry change.
|
|
111
|
+
///
|
|
112
|
+
/// The curve is the superellipse about the corner cell's INNER point: `P(theta) = C +
|
|
113
|
+
/// a*E*(1 - sin^(2/n) theta) + b*E*(1 - cos^(2/n) theta)` for corner point C and unit edge
|
|
114
|
+
/// vectors a (incoming, clockwise) and b (outgoing) — at n = 2 the circular arc. The tempting
|
|
115
|
+
/// "polar" form has the same endpoints but bulges into the shape (an inverse squircle; it
|
|
116
|
+
/// shipped once on Android and stroked a hairline inside the glass).
|
|
117
|
+
static func path(in rect: CGRect, resolved c: Resolved) -> UIBezierPath {
|
|
118
|
+
let path = UIBezierPath()
|
|
119
|
+
let l = rect.minX
|
|
120
|
+
let t = rect.minY
|
|
121
|
+
let r = rect.maxX
|
|
122
|
+
let b = rect.maxY
|
|
123
|
+
|
|
124
|
+
path.move(to: CGPoint(x: l + c.extentTL, y: t))
|
|
125
|
+
path.addLine(to: CGPoint(x: r - c.extentTR, y: t))
|
|
126
|
+
corner(path, cx: r, cy: t, ax: -1, ay: 0, bx: 0, by: 1, extent: c.extentTR, n: c.shapeTR)
|
|
127
|
+
path.addLine(to: CGPoint(x: r, y: b - c.extentBR))
|
|
128
|
+
corner(path, cx: r, cy: b, ax: 0, ay: -1, bx: -1, by: 0, extent: c.extentBR, n: c.shapeBR)
|
|
129
|
+
path.addLine(to: CGPoint(x: l + c.extentBL, y: b))
|
|
130
|
+
corner(path, cx: l, cy: b, ax: 1, ay: 0, bx: 0, by: -1, extent: c.extentBL, n: c.shapeBL)
|
|
131
|
+
path.addLine(to: CGPoint(x: l, y: t + c.extentTL))
|
|
132
|
+
corner(path, cx: l, cy: t, ax: 0, ay: 1, bx: 1, by: 0, extent: c.extentTL, n: c.shapeTL)
|
|
133
|
+
path.close()
|
|
134
|
+
return path
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/// One corner: from `C + a*E` to `C + b*E`. `(ax, ay)` points from the corner back along the
|
|
138
|
+
/// incoming edge, `(bx, by)` forward along the outgoing edge, both unit.
|
|
139
|
+
private static func corner(
|
|
140
|
+
_ path: UIBezierPath,
|
|
141
|
+
cx: CGFloat, cy: CGFloat,
|
|
142
|
+
ax: CGFloat, ay: CGFloat,
|
|
143
|
+
bx: CGFloat, by: CGFloat,
|
|
144
|
+
extent: CGFloat,
|
|
145
|
+
n: Float
|
|
146
|
+
) {
|
|
147
|
+
if extent < minExtent {
|
|
148
|
+
path.addLine(to: CGPoint(x: cx, y: cy))
|
|
149
|
+
return
|
|
150
|
+
}
|
|
151
|
+
let exponent = 2.0 / Double(n)
|
|
152
|
+
for i in 1...segmentsPerCorner {
|
|
153
|
+
let theta = (Double(i) / Double(segmentsPerCorner)) * (Double.pi / 2)
|
|
154
|
+
let ca = CGFloat(1 - pow(sin(theta), exponent))
|
|
155
|
+
let sb = CGFloat(1 - pow(cos(theta), exponent))
|
|
156
|
+
path.addLine(to: CGPoint(
|
|
157
|
+
x: cx + (ax * ca + bx * sb) * extent,
|
|
158
|
+
y: cy + (ay * ca + by * sb) * extent
|
|
159
|
+
))
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
private static let segmentsPerCorner = 32
|
|
164
|
+
private static let minExtent: CGFloat = 0.5
|
|
165
|
+
}
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
import ExpoModulesCore
|
|
2
|
+
import UIKit
|
|
3
|
+
|
|
4
|
+
// =============================================================================================
|
|
5
|
+
// GlassBackdrop — a bounded backdrop scope for the pre-iOS-26 renderer.
|
|
6
|
+
//
|
|
7
|
+
// The renderer used to photograph the whole window and let the glass lens read that snapshot.
|
|
8
|
+
// That is fine for a fixed background and wrong for content that scrolls: the snapshot is of
|
|
9
|
+
// the screen, the content moves inside it, and the governor stops capturing during motion, so a
|
|
10
|
+
// dragged pane refracts a stale photograph until the finger lifts.
|
|
11
|
+
//
|
|
12
|
+
// A `GlassBackdrop` narrows the scope instead. Glass inside it photographs the scroll content
|
|
13
|
+
// in CONTENT coordinates (see StripCache) and the two static bands around it in window
|
|
14
|
+
// coordinates. The scroll view to track is found deterministically: an explicit tag wins, then
|
|
15
|
+
// the first descendant UIScrollView (RN's Fabric host `RCTScrollViewComponentView` hosts one),
|
|
16
|
+
// and only with none of those does the window walk fall back to the old whole-window capture.
|
|
17
|
+
//
|
|
18
|
+
// This is the Dart/ArkUI provider contract the Android renderer already uses, expressed for
|
|
19
|
+
// UIKit: the view exists to mark the subtree, it draws nothing and never lays out content.
|
|
20
|
+
// =============================================================================================
|
|
21
|
+
|
|
22
|
+
/// Marks a subtree whose glass should photograph its own scroll content, not the window.
|
|
23
|
+
///
|
|
24
|
+
/// Add it above a glass surface and the scroll view inside it, in any order; the provider and
|
|
25
|
+
/// the surfaces find each other through the registry, so neither needs a ref to the other.
|
|
26
|
+
final class GlassBackdropView: ExpoView {
|
|
27
|
+
|
|
28
|
+
/// The scroll view to photograph in content coordinates. Set it directly when the subtree
|
|
29
|
+
/// holds more than one; otherwise the first descendant scroll view is used.
|
|
30
|
+
weak var trackedScrollView: UIScrollView?
|
|
31
|
+
|
|
32
|
+
/// The strip cache for this scope. One per provider: two providers on screen are two
|
|
33
|
+
/// independent content scopes with their own ring buffers.
|
|
34
|
+
private(set) var strip: StripCache?
|
|
35
|
+
|
|
36
|
+
/// Set while `strip` cannot honour the geometry (an oversized band, a jump, a chip stack of
|
|
37
|
+
/// failures) so the scheduler uses the window capture for this scope and the surface labels
|
|
38
|
+
/// the glass as borrowing a still photograph.
|
|
39
|
+
private(set) var stripIsUsable = true
|
|
40
|
+
|
|
41
|
+
override class var layerClass: AnyClass { NonRenderableLayer.self }
|
|
42
|
+
|
|
43
|
+
override func didMoveToWindow() {
|
|
44
|
+
super.didMoveToWindow()
|
|
45
|
+
if window == nil {
|
|
46
|
+
GlassBackdropRegistry.shared.unregister(self)
|
|
47
|
+
} else {
|
|
48
|
+
GlassBackdropRegistry.shared.register(self)
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/// Resolves once per frame and caches until the view tree changes.
|
|
53
|
+
func resolveScrollView() -> UIScrollView? {
|
|
54
|
+
if let trackedScrollView { return trackedScrollView }
|
|
55
|
+
trackedScrollView = firstScrollView(in: self)
|
|
56
|
+
return trackedScrollView
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
private func firstScrollView(in view: UIView) -> UIScrollView? {
|
|
60
|
+
for child in view.subviews {
|
|
61
|
+
if let scroll = child as? UIScrollView { return scroll }
|
|
62
|
+
if let nested = firstScrollView(in: child) { return nested }
|
|
63
|
+
}
|
|
64
|
+
return nil
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/// The cache for this scope, created on first use. Nil when Metal is unavailable.
|
|
68
|
+
func stripCache(for scroll: UIScrollView) -> StripCache? {
|
|
69
|
+
guard scroll.contentSize.height > scroll.bounds.height else { return nil }
|
|
70
|
+
if let strip { return strip }
|
|
71
|
+
guard let device = GlassRenderContext.shared?.device,
|
|
72
|
+
let cache = StripCache(device: device)
|
|
73
|
+
else { return nil }
|
|
74
|
+
strip = cache
|
|
75
|
+
return cache
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/// Scale the ring is rasterised at. The fallback capture scale, capped: a strip at 3x of a
|
|
79
|
+
/// tall viewport is memory the cache cannot justify, and the lens blurs more than it resolves.
|
|
80
|
+
var stripScale: CGFloat {
|
|
81
|
+
max(1, min(window?.screen.scale ?? 2, 2))
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/// The view whose layer is drawn in content coordinates.
|
|
85
|
+
///
|
|
86
|
+
/// In RN Fabric the scroll view hosts `RCTScrollContentView` as its first child; on UIKit
|
|
87
|
+
/// it is the document view. The tallest direct child is the content container in both, and
|
|
88
|
+
/// the scroll view itself is only the last resort (drawing it would apply the clip and
|
|
89
|
+
/// photograph the window band the strip exists to replace).
|
|
90
|
+
func resolveContentContainer() -> UIView? {
|
|
91
|
+
guard let scroll = resolveScrollView() else { return nil }
|
|
92
|
+
return scroll.subviews
|
|
93
|
+
.filter { !$0.isHidden && $0.alpha > 0.01 }
|
|
94
|
+
.max { $0.frame.height < $1.frame.height } ?? scroll
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/// True when any glass surface on screen is inside this provider.
|
|
98
|
+
var isInUse: Bool { GlassBackdropRegistry.shared.isReferenced(self) }
|
|
99
|
+
|
|
100
|
+
func reportUnusable(_ unusable: Bool) {
|
|
101
|
+
stripIsUsable = !unusable
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/// Finds the provider that owns a given view, and keeps track of live providers.
|
|
106
|
+
///
|
|
107
|
+
/// Walking up from the surface is bounded by the view hierarchy's depth, not by the window's
|
|
108
|
+
/// size, and stops at the first match, so a provider inside a provider scopes the inner glass
|
|
109
|
+
/// only. That is the rule the Android provider has: the nearest scope wins.
|
|
110
|
+
final class GlassBackdropRegistry {
|
|
111
|
+
|
|
112
|
+
static let shared = GlassBackdropRegistry()
|
|
113
|
+
|
|
114
|
+
private struct Entry {
|
|
115
|
+
weak var view: GlassBackdropView?
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
private var entries: [Entry] = []
|
|
119
|
+
|
|
120
|
+
func register(_ view: GlassBackdropView) {
|
|
121
|
+
prune()
|
|
122
|
+
if entries.contains(where: { $0.view === view }) { return }
|
|
123
|
+
entries.append(Entry(view: view))
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
func unregister(_ view: GlassBackdropView) {
|
|
127
|
+
entries.removeAll { $0.view == nil || $0.view === view }
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/// The nearest enclosing provider for `view`, or nil when the view photographs the window.
|
|
131
|
+
func nearestProvider(for view: UIView) -> GlassBackdropView? {
|
|
132
|
+
var node: UIView? = view.superview
|
|
133
|
+
while let current = node {
|
|
134
|
+
if let provider = current as? GlassBackdropView { return provider }
|
|
135
|
+
node = current.superview
|
|
136
|
+
}
|
|
137
|
+
return nil
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/// Providers currently on screen, oldest first. The scheduler only audits referenced ones.
|
|
141
|
+
var providers: [GlassBackdropView] {
|
|
142
|
+
prune()
|
|
143
|
+
return entries.compactMap(\.view)
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
func isReferenced(_ view: GlassBackdropView) -> Bool {
|
|
147
|
+
view.window != nil
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
private func prune() {
|
|
151
|
+
entries.removeAll { $0.view == nil }
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
extension UIView {
|
|
156
|
+
|
|
157
|
+
/// The frame the next commit will present.
|
|
158
|
+
///
|
|
159
|
+
/// `render(in:)` draws the MODEL tree, so a capture taken during an animation shows where
|
|
160
|
+
/// the layer is going, not where it is on screen this frame. Every geometry read on the
|
|
161
|
+
/// capture path goes through the presentation layer for that reason; content still arrives
|
|
162
|
+
/// from the model tree, because presentation layers carry no contents of their own.
|
|
163
|
+
var glaciaPresentationFrame: CGRect {
|
|
164
|
+
layer.presentation()?.frame ?? layer.frame
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
/// The content offset the current frame is presenting, in content coordinates. This is the
|
|
168
|
+
/// number the strip cache must use: the model offset is one frame ahead at 60 Hz.
|
|
169
|
+
var glaciaPresentedContentOffsetY: CGFloat {
|
|
170
|
+
if let scroll = self as? UIScrollView,
|
|
171
|
+
let presented = scroll.layer.presentation() {
|
|
172
|
+
return presented.bounds.origin.y
|
|
173
|
+
}
|
|
174
|
+
return (self as? UIScrollView)?.contentOffset.y ?? 0
|
|
175
|
+
}
|
|
176
|
+
}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import QuartzCore
|
|
2
|
+
import UIKit
|
|
3
|
+
import os
|
|
4
|
+
|
|
5
|
+
// =============================================================================================
|
|
6
|
+
// GlassFramePhase — put the glass pass in the same frame as the content it refracts.
|
|
7
|
+
//
|
|
8
|
+
// Two independent sources of swim live in this file, and both are phase problems rather than
|
|
9
|
+
// shader problems:
|
|
10
|
+
//
|
|
11
|
+
// 1. The glass pass must run BEFORE the CoreAnimation commit for the frame it belongs to. If it
|
|
12
|
+
// runs after, the window capture shows commit N's content while the glass reads commit N-1's
|
|
13
|
+
// positions — at 1,500 pt/s that is 25 pt of misalignment, visible as swimming. The scheduler
|
|
14
|
+
// already drives from a `beforeWaiting` run-loop observer for exactly this reason; this file
|
|
15
|
+
// pins the remaining half: `presentsWithTransaction`, so the drawable is presented inside the
|
|
16
|
+
// same transaction instead of on Metal's own cadence.
|
|
17
|
+
//
|
|
18
|
+
// 2. `render(in:)` draws the MODEL tree. During a scroll, a drag or a spring, the model is where
|
|
19
|
+
// the animation is GOING. Geometry, opacity and transform must therefore be read from
|
|
20
|
+
// `presentation()`, while contents still come from the model layers (presentation layers
|
|
21
|
+
// carry none).
|
|
22
|
+
// =============================================================================================
|
|
23
|
+
|
|
24
|
+
enum GlassFramePhase {
|
|
25
|
+
|
|
26
|
+
private static let log = OSLog(subsystem: "com.glacia.glass", category: "FramePhase")
|
|
27
|
+
|
|
28
|
+
/// Windows whose surfaces have already been switched to transactional presentation.
|
|
29
|
+
///
|
|
30
|
+
/// `presentsWithTransaction` is a per-layer settable property, and switching it on every
|
|
31
|
+
/// frame would flush the CA transaction for no reason, so it is set once per window and
|
|
32
|
+
/// cleared when the last participant unsubscribes. Only windows with an active strip get it:
|
|
33
|
+
/// a still photograph has no phase to align.
|
|
34
|
+
private static var transactionalWindows: [ObjectIdentifier: WeakWindow] = [:]
|
|
35
|
+
|
|
36
|
+
private struct WeakWindow {
|
|
37
|
+
weak var window: UIWindow?
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/// Marks every `CAMetalLayer` in `window` as inside the CA transaction. Idempotent.
|
|
41
|
+
static func beginTransactionalPresentation(in window: UIWindow?) {
|
|
42
|
+
guard let window else { return }
|
|
43
|
+
let key = ObjectIdentifier(window)
|
|
44
|
+
if transactionalWindows[key]?.window === window { return }
|
|
45
|
+
|
|
46
|
+
setPresentsWithTransaction(true, in: window)
|
|
47
|
+
transactionalWindows[key] = WeakWindow(window: window)
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/// Restores Metal's own presentation cadence for a window that no longer has a strip.
|
|
51
|
+
static func endTransactionalPresentation(in window: UIWindow?) {
|
|
52
|
+
guard let window else { return }
|
|
53
|
+
let key = ObjectIdentifier(window)
|
|
54
|
+
guard transactionalWindows[key] != nil else { return }
|
|
55
|
+
setPresentsWithTransaction(false, in: window)
|
|
56
|
+
transactionalWindows.removeValue(forKey: key)
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
private static func setPresentsWithTransaction(_ value: Bool, in window: UIWindow) {
|
|
60
|
+
var stack: [UIView] = [window]
|
|
61
|
+
while let view = stack.popLast() {
|
|
62
|
+
if let metal = view.layer as? CAMetalLayer {
|
|
63
|
+
metal.presentsWithTransaction = value
|
|
64
|
+
}
|
|
65
|
+
stack.append(contentsOf: view.subviews)
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/// The window-space frame a surface will present this commit.
|
|
70
|
+
///
|
|
71
|
+
/// Model frames are one commit ahead during an animation; the presentation layer is what the
|
|
72
|
+
/// display is showing. Falls back to the model layer before the first commit, where both are
|
|
73
|
+
/// the same and there is nothing to present yet.
|
|
74
|
+
static func presentedFrame(of view: UIView, in window: UIWindow) -> CGRect {
|
|
75
|
+
let frame = view.glaciaPresentationFrame
|
|
76
|
+
guard frame.width > 0, frame.height > 0 else {
|
|
77
|
+
return view.convert(view.bounds, to: window)
|
|
78
|
+
}
|
|
79
|
+
// Presentation frames live in the superlayer's coordinate space, which for a view that
|
|
80
|
+
// has not moved relative to its superview is the model space. Convert through the
|
|
81
|
+
// superview, which is the layer whose space the frame is expressed in.
|
|
82
|
+
let anchor = view.superview ?? view
|
|
83
|
+
let bounds = CGRect(origin: .zero, size: frame.size)
|
|
84
|
+
let inAnchor = anchor.convert(bounds, to: window)
|
|
85
|
+
return CGRect(
|
|
86
|
+
x: inAnchor.minX + (frame.minX - view.frame.minX),
|
|
87
|
+
y: inAnchor.minY + (frame.minY - view.frame.minY),
|
|
88
|
+
width: frame.width,
|
|
89
|
+
height: frame.height
|
|
90
|
+
)
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/// The content offset the display is showing, which the strip composite must use.
|
|
94
|
+
static func presentedOffsetY(of scrollView: UIScrollView) -> CGFloat {
|
|
95
|
+
scrollView.glaciaPresentedContentOffsetY
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
// ------------------------------------------------------------------------------- profiling
|
|
99
|
+
|
|
100
|
+
/// Step 1 of the §3 prototype: is the frame's cost the tree walk or the pixels?
|
|
101
|
+
///
|
|
102
|
+
/// Both the capture and the per-participant request build are bracketed, so a device profile
|
|
103
|
+
/// separates "window snapshot" from "glass draw submission" without guessing. The intervals
|
|
104
|
+
/// are named for Instruments' Points of Interest track.
|
|
105
|
+
/// Brackets `body` and returns its result, so a call site keeps its shape.
|
|
106
|
+
static func signpostResult<T>(_ name: StaticString, _ body: () -> T) -> T {
|
|
107
|
+
os_signpost(.begin, log: log, name: name)
|
|
108
|
+
let value = body()
|
|
109
|
+
os_signpost(.end, log: log, name: name)
|
|
110
|
+
return value
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
static func signpost(_ name: StaticString, _ body: () -> Void) {
|
|
114
|
+
os_signpost(.begin, log: log, name: name)
|
|
115
|
+
body()
|
|
116
|
+
os_signpost(.end, log: log, name: name)
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
static func signpostBegin(_ name: StaticString) {
|
|
120
|
+
os_signpost(.begin, log: log, name: name)
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
static func signpostEnd(_ name: StaticString) {
|
|
124
|
+
os_signpost(.end, log: log, name: name)
|
|
125
|
+
}
|
|
126
|
+
}
|