gif retry respects budget priority (resolution=only adjust fps, framerate=only adjust resolution, balanced=adjust both), gif colors factored into size estimate, overlay queries aspect ratio from rust on resize instead of relying on cross-window events
This commit is contained in:
+2
-1
@@ -69,7 +69,8 @@
|
||||
let previewDims = $derived.by(() => {
|
||||
if (!clip) return ""
|
||||
if (format === "gif") {
|
||||
const bpf = 0.2
|
||||
const colorFactor = Math.sqrt(gifColors / 256)
|
||||
const bpf = 0.2 * colorFactor
|
||||
const requestedFps = fps
|
||||
const aspect = clip.height === 0 ? 16 / 9 : clip.width / clip.height
|
||||
|
||||
|
||||
+13
-19
@@ -15,6 +15,7 @@
|
||||
let timer: number | null = null
|
||||
let lockedRatio: number | null = null
|
||||
let resizeDebounce: number | null = null
|
||||
let enforcing = false
|
||||
|
||||
onMount(() => {
|
||||
const updateSize = async () => {
|
||||
@@ -23,11 +24,19 @@
|
||||
width = Math.round(sz.width / sf)
|
||||
height = Math.round(sz.height / sf)
|
||||
}
|
||||
// Query aspect ratio from Rust on startup
|
||||
const syncRatio = async () => {
|
||||
try { lockedRatio = await invoke<number | null>("get_overlay_aspect") } catch {}
|
||||
}
|
||||
updateSize()
|
||||
syncRatio()
|
||||
let cleanup: (() => void)[] = []
|
||||
|
||||
win.onResized(async () => {
|
||||
if (enforcing) return
|
||||
await updateSize()
|
||||
// Re-sync ratio in case it changed
|
||||
await syncRatio()
|
||||
if (lockedRatio === null) return
|
||||
if (resizeDebounce !== null) clearTimeout(resizeDebounce)
|
||||
resizeDebounce = window.setTimeout(async () => {
|
||||
@@ -35,30 +44,15 @@
|
||||
const targetH = Math.round(width / ratio)
|
||||
const minH = 90
|
||||
const clampedH = Math.max(minH, targetH)
|
||||
if (Math.abs(clampedH - height) > 1) {
|
||||
if (Math.abs(clampedH - height) > 2) {
|
||||
enforcing = true
|
||||
try {
|
||||
await win.setSize({ type: "Logical", width, height: clampedH })
|
||||
await updateSize()
|
||||
} catch {}
|
||||
enforcing = false
|
||||
}
|
||||
}, 150)
|
||||
}).then(fn => cleanup.push(fn))
|
||||
|
||||
listen<{ ratio: number | null }>("overlay-aspect-lock", async (e) => {
|
||||
lockedRatio = e.payload.ratio
|
||||
if (lockedRatio !== null) {
|
||||
// Enforce ratio on current size immediately
|
||||
await updateSize()
|
||||
const targetH = Math.round(width / lockedRatio)
|
||||
const minH = 90
|
||||
const clampedH = Math.max(minH, targetH)
|
||||
if (Math.abs(clampedH - height) > 1) {
|
||||
try {
|
||||
await win.setSize({ type: "Logical", width, height: clampedH })
|
||||
await updateSize()
|
||||
} catch {}
|
||||
}
|
||||
}
|
||||
}, 80)
|
||||
}).then(fn => cleanup.push(fn))
|
||||
|
||||
listen<{ phase: "idle"|"recording"|"paused"; fps: number }>(
|
||||
|
||||
Reference in New Issue
Block a user