Skip to content

Record your screen, ship a demo. Free and open-source, GPU-accelerated, no watermarks, no subscriptions. Windows, macOS, Linux. Actively maintained.

fix(layout): measure the padding from the device frame's outer edge

EtienneLescot1d36020a0225
diff --git a/crates/compositor/src/frame_geometry.rs b/crates/compositor/src/frame_geometry.rs
index 59d5ae31f..d91eac0d0 100644
--- a/crates/compositor/src/frame_geometry.rs
+++ b/crates/compositor/src/frame_geometry.rs
@@ -968,10 +968,10 @@ pub(crate) fn screen_corner_radius_px(r: f32, s_px: [f32; 2]) -> f32 {
/// unité du cadre `u` (px) : le filet à gauche, à droite et en bas, la barre de titre en haut (cf.
/// `WindowFrame::margins`).
///
-/// L'écran ne rétrécit plus pour faire place au cadre : **le métrage a la même taille avec et sans
-/// cadre**, et c'est le cadre qui pousse vers l'extérieur — dans le padding, et au-delà du canvas
-/// s'il le faut, où la sortie le coupe. Rétrécir l'image pour loger un objet décoratif, c'était
-/// l'inverse de ce qu'on veut : le métrage est le sujet, le cadre son écrin.
+/// Le compositeur ne rétrécit jamais la boîte écran qu'il reçoit pour loger le cadre : le cadre
+/// pousse vers l'extérieur. C'est le layout de l'app qui lui fait place : le padding se mesure
+/// depuis le bord extérieur de tout ce que le cadre dessine (`computeCompositeLayout`), si bien
+/// qu'au repos il ne sort jamais du canvas, et c'est l'ensemble qui est centré.
pub(crate) fn window_frame_margins(s_px: [f32; 2], u: f32) -> [f32; 4] {
let (bar, line) = (WINDOW_FRAME_BAR_FRAC * u, WINDOW_FRAME_LINE_FRAC * u);
let (sw, sh) = (s_px[0].max(1.0), s_px[1].max(1.0));
@@ -3045,10 +3045,10 @@ pub fn plan_frame(input: &FrameGeometryInput) -> FrameGeometry {
// déborde le padding — c'est la géométrie de `applyZoomTransform` (TS).
let s_box = fit_screen(p.screen.dst);
let s_box_prev = fit_screen(pp.screen.dst);
- // Le cadre ne touche PAS à la boîte écran : le métrage a la même taille avec et sans
- // cadre, et le cadre pousse vers l'extérieur — dans le padding, et au-delà du canvas s'il
- // le faut, où la sortie le coupe. Ombre, masques, annotations et curseurs, ancrés sur
- // `s_dst`, n'ont donc rien à rattraper.
+ // Le cadre ne touche PAS à la boîte écran : il pousse vers l'extérieur, dans la place que
+ // le layout de l'app lui a faite (le padding se mesure depuis son bord extérieur,
+ // `computeCompositeLayout`). Ombre, masques, annotations et curseurs, ancrés sur `s_dst`,
+ // n'ont donc rien à rattraper.
// Le cadre et son thème. `resolved` ramène les anciennes valeurs `window-light` /
// `window-dark` au chrome de fenêtre, et `theme_override` leur rend le thème qu'elles
// nommaient : un projet qui les porte encore rend exactement ce qu'il rendait, sans que
diff --git a/docs/3d-effects-v2.md b/docs/3d-effects-v2.md
index dd99c7167..2cc173f82 100644
--- a/docs/3d-effects-v2.md
+++ b/docs/3d-effects-v2.md
@@ -488,19 +488,29 @@ lisent encore, et se dédoublent en `window` + le thème qu'ils nommaient : côt
un projet écrit par une version antérieure s'ouvre avec le cadre ET le thème qu'il avait, et une
valeur qu'aucune de ces deux familles ne connaît se lit « aucun cadre » des deux côtés.
-### C.2 Le métrage ne bouge pas
-
-**Le métrage a la même boîte et la même coupe avec et sans cadre**, quel qu'il soit. Son rayon, lui,
-suit la course de Roundness propre au cadre (C.5).
-Le cadre pousse vers l'EXTÉRIEUR : dans le padding, et au-delà du canevas s'il le faut, où la sortie
-le coupe. Il n'y a plus de `fit_in_window_frame` ni de `fit_in_device_frame` : rétrécir l'image
-pour loger un objet décoratif, c'était l'inverse de ce qu'on veut. Tout ce qui s'ancre sur `s_dst`
-— ombre de l'écran, masques de confidentialité, annotations, curseurs — n'a donc rien à rattraper,
-et l'overlay de l'éditeur pose ses poignées sur `layout.screenRect` tel quel (le portage TS
-`fitInWindowFrame` a disparu avec lui).
-
-Épinglé par `the_footage_box_is_the_same_under_every_frame` (chaque cadre × plat, iso, orbite ×
-zoom 1 et 2, au bit près) et `a_framed_privacy_mask_covers_what_the_overlay_shows`.
+### C.2 Le compositeur ne touche pas au métrage, le layout fait place au cadre
+
+**Le compositeur donne au métrage la même boîte et la même coupe avec et sans cadre**, quel qu'il
+soit. Son rayon, lui, suit la course de Roundness propre au cadre (C.5). Le cadre pousse vers
+l'EXTÉRIEUR de la boîte qu'il reçoit : il n'y a plus de `fit_in_window_frame` ni de
+`fit_in_device_frame`. Tout ce qui s'ancre sur `s_dst` (ombre de l'écran, masques de
+confidentialité, annotations, curseurs) n'a donc rien à rattraper, et l'overlay de l'éditeur pose
+ses poignées sur `layout.screenRect` tel quel.
+
+**C'est le layout de l'app qui fait place au cadre, dans tous les layouts** (27/09/2026). Le padding
+se mesure depuis le bord extérieur de tout ce que le cadre dessine : barre de fenêtre, socle du
+portable, pied du moniteur (`centerScreen`, `compositeLayout.ts`). L'ensemble tient dans la zone
+paddée et c'est lui qui est centré. Avant, le cadre débordait dans le padding et au-delà du canevas :
+à padding 0 aucun cadre n'était visible, au padding par défaut le pied du moniteur était coupé à
+moitié, et un cadre asymétrique décentrait l'ensemble (moniteur 96 px trop bas en 1080p). Le prix est
+assumé : sous un cadre, le métrage est plus petit (clip 16:9 en sortie 16:9 : −4 % sous la fenêtre
+et le téléphone, −17 % sous le portable, −21 % sous le moniteur). Auto épouse l'appareil de la même
+façon (`autoFormatAspect`).
+
+Épinglé côté compositeur par `the_footage_box_is_the_same_under_every_frame` (chaque cadre × plat,
+iso, orbite × zoom 1 et 2, au bit près) et `a_framed_privacy_mask_covers_what_the_overlay_shows` ;
+côté layout par les tests « the whole frame fits and centres » et « even border around every
+frame » de `compositeLayout.test.ts`.
### C.2 bis L'unité du cadre
diff --git a/src/lib/ai-edition/document/outputFormat.ts b/src/lib/ai-edition/document/outputFormat.ts
index d4b660de9..7727f693b 100644
--- a/src/lib/ai-edition/document/outputFormat.ts
+++ b/src/lib/ai-edition/document/outputFormat.ts
@@ -15,10 +15,9 @@
*/
import {
- autoFrameAspect,
+ autoFormatAspect,
getWebcamLayoutPresetDefinition,
resolveWebcamLayoutPreset,
- restingCompositionAspect,
type WebcamLayoutPreset,
} from "@/lib/compositeLayout";
import { calculateEffectiveSourceDimensions } from "@/lib/exporter/mp4ExportSettings";
@@ -289,7 +288,7 @@ function firstClip(
/**
* What "Auto" resolves to: the frame shaped around the composition instead of the other way
- * round (`autoFrameAspect` over `restingCompositionAspect`).
+ * round (`autoFormatAspect`).
*
* Auto is only offered while the timeline holds one composition (`isAutoFormatAvailable`), so
* any clip describes it, and the first one is read. That choice only matters for a project that
@@ -297,8 +296,9 @@ function firstClip(
* after it, larger or not, moves nothing until the user picks a format. The output's SIZE still
* follows the largest clip (`referenceClipDims`), so no clip is drawn past its own resolution.
*
- * Zoom, device frames, shadow and captions are left out on purpose: they happen inside the
- * frame, in every format alike, and would make the shape move with the playhead.
+ * Zoom, shadow and captions are left out on purpose: they happen inside the frame, in every
+ * format alike, and would make the shape move with the playhead. A device frame is in: every
+ * format measures the padding from its outer edge, so Auto wraps the whole device.
*/
function autoAspectRatioValue(document: AxcutDocument, probedAssetDims: Record<string, Dims>) {
const settings = getEditorSettings(document);
@@ -307,7 +307,7 @@ function autoAspectRatioValue(document: AxcutDocument, probedAssetDims: Record<s
? clipLayoutPreset(first.clip, document.assets, settings.webcamLayoutPreset)
: "no-webcam";
const screen = first?.dims ?? referenceClipDims(document, probedAssetDims);
- return autoFrameAspect(restingCompositionAspect(screen, preset), settings.padding);
+ return autoFormatAspect(screen, preset, settings.frame, settings.padding);
}
/**
diff --git a/src/lib/compositeLayout.test.ts b/src/lib/compositeLayout.test.ts
index 536bd9cc5..383509654 100644
--- a/src/lib/compositeLayout.test.ts
+++ b/src/lib/compositeLayout.test.ts
@@ -1,5 +1,6 @@
import { describe, expect, it } from "vitest";
import {
+ autoFormatAspect,
autoFrameAspect,
computeCameraFullscreenRect,
computeCompositeLayout,
@@ -16,6 +17,14 @@ import {
import { frameFootprint, frameUnit, type Insets } from "./frameFootprint";
import { WEBCAM_SIZE_MAX, WEBCAM_SIZE_MIN, type WebcamAnchor } from "./projectDefaults";
+/** A rect grown by insets: the screen box plus what a frame draws around it. */
+const expand = (r: RenderRect, [left, top, right, bottom]: Insets): RenderRect => ({
+ x: r.x - left,
+ y: r.y - top,
+ width: r.width + left + right,
+ height: r.height + top + bottom,
+});
+
describe("resolveWebcamReactiveZoom", () => {
it("honours the stored setting for picture-in-picture", () => {
expect(resolveWebcamReactiveZoom("picture-in-picture", true)).toBe(true);
@@ -435,12 +444,6 @@ describe("computeCompositeLayout", () => {
// There the frame stays at rest around the screen while the footage zooms inside it (`ScreenMask`),
// so the block lays out the frame, not just the screen: the camera lines up with the frame's
// body, and keeps the gap to everything the frame draws, a laptop's deck or a monitor's stand.
- const expand = (r: RenderRect, [left, top, right, bottom]: Insets): RenderRect => ({
- x: r.x - left,
- y: r.y - top,
- width: r.width + left + right,
- height: r.height + top + bottom,
- });
// Two pixels: every edge is snapped to a whole pixel, the frame measured on the snapped screen.
const near = (actual: number, expected: number, tolerance = 2) =>
expect(Math.abs(actual - expected)).toBeLessThanOrEqual(tolerance);
@@ -512,21 +515,38 @@ describe("computeCompositeLayout", () => {
}
});
- it.each([
- "picture-in-picture",
- "no-webcam",
- ] as const)("leaves %s alone under a frame: the frame grows into the padding there", (layoutPreset) => {
- const args = {
- canvasSize: { width: 1920, height: 1080 },
- maxContentSize: { width: 1536, height: 864 },
- screenSize: { width: 1920, height: 1080 },
- webcamSize: CAM,
- layoutPreset,
- };
+ // Everywhere else the frame zooms and tilts with the screen, but at rest the padding is
+ // measured from its outer edge: at 0% the whole frame touches the scene, never past it, and
+ // a lopsided one (a window's bar, a monitor's stand) is centred as a whole.
+ for (const layoutPreset of ["picture-in-picture", "no-webcam"] as const) {
for (const frame of ["window", "laptop", "phone", "monitor"] as const) {
- expect(computeCompositeLayout({ ...args, frame })).toEqual(computeCompositeLayout(args));
+ for (const scene of SCENES) {
+ it(`${layoutPreset} under a ${frame} in scene ${scene.label}: the whole frame fits and centres`, () => {
+ const padded = paddedContentSize(scene.size, 0, false);
+ const layout = computeCompositeLayout({
+ canvasSize: scene.size,
+ maxContentSize: padded,
+ screenSize: { width: 1920, height: 1080 },
+ webcamSize: CAM,
+ layoutPreset,
+ frame,
+ })!;
+ const screen = layout.screenRect;
+ const { outer } = frameFootprint(frame, screen, frameUnit(screen, scene.size));
+ const drawn = expand(screen, outer);
+
+ expect(screen.width / screen.height).toBeCloseTo(16 / 9, 1);
+ expect(drawn.width).toBeLessThanOrEqual(padded.width + 2);
+ expect(drawn.height).toBeLessThanOrEqual(padded.height + 2);
+ expect(
+ Math.min(padded.width - drawn.width, padded.height - drawn.height),
+ ).toBeLessThanOrEqual(2);
+ near(drawn.x, scene.size.width - (drawn.x + drawn.width));
+ near(drawn.y, scene.size.height - (drawn.y + drawn.height));
+ });
+ }
}
- });
+ }
it("forces circular and square masks to use square dimensions", () => {
const circularLayout = computeCompositeLayout({
@@ -633,9 +653,10 @@ describe("Auto frame", () => {
);
});
- // The whole contract: a frame shaped by `autoFrameAspect`, padded by `paddedContentSize`
+ // The whole contract: a frame shaped by `autoFormatAspect`, padded by `paddedContentSize`
// and laid out by `computeCompositeLayout` gives the composition back, unbent, with the
- // same margin on all four sides. Preview and scene both go through exactly these three.
+ // same margin on all four sides, measured from everything a device frame draws. Preview and
+ // scene both go through exactly these three.
const CASES = [
{ label: "16:9 screen", screen: { width: 1920, height: 1080 }, preset: "no-webcam" },
{
@@ -651,36 +672,43 @@ describe("Auto frame", () => {
] as const;
for (const c of CASES) {
for (const padding of [0, 30, 50, 100]) {
- it(`${c.label}, padding ${padding}%: even border, nothing bent`, () => {
- const aspect = autoFrameAspect(restingCompositionAspect(c.screen, c.preset), padding);
- const canvas =
- aspect >= 1
- ? { width: 1920, height: Math.round(1920 / aspect) }
- : { width: Math.round(1920 * aspect), height: 1920 };
- const layout = computeCompositeLayout({
- canvasSize: canvas,
- maxContentSize: paddedContentSize(canvas, padding, true),
- screenSize: c.screen,
- webcamSize: c.preset === "no-webcam" ? null : { width: 1280, height: 720 },
- layoutPreset: c.preset,
- })!;
- const block = isWebcamBlockLayout(c.preset);
- const rects = block ? [layout.screenRect, layout.webcamRect!] : [layout.screenRect];
- const border = ((1 - paddingFit(padding)) / 2) * Math.min(canvas.width, canvas.height);
- const sides = [
- Math.min(...rects.map((r) => r.x)),
- Math.min(...rects.map((r) => r.y)),
- canvas.width - Math.max(...rects.map((r) => r.x + r.width)),
- canvas.height - Math.max(...rects.map((r) => r.y + r.height)),
- ];
- for (const side of sides) expect(Math.abs(side - border)).toBeLessThanOrEqual(1.5);
- expect(layout.screenRect.width / layout.screenRect.height).toBeCloseTo(
- c.screen.width / c.screen.height,
- 1,
- );
- if (block) {
- const cam = layout.webcamRect!;
- expect(cam.width / cam.height).toBeCloseTo(1, 1);
+ it(`${c.label}, padding ${padding}%: even border around every frame, nothing bent`, () => {
+ for (const frame of ["none", "window", "laptop", "phone", "monitor"] as const) {
+ const aspect = autoFormatAspect(c.screen, c.preset, frame, padding);
+ const canvas =
+ aspect >= 1
+ ? { width: 1920, height: Math.round(1920 / aspect) }
+ : { width: Math.round(1920 * aspect), height: 1920 };
+ const layout = computeCompositeLayout({
+ canvasSize: canvas,
+ maxContentSize: paddedContentSize(canvas, padding, true),
+ screenSize: c.screen,
+ webcamSize: c.preset === "no-webcam" ? null : { width: 1280, height: 720 },
+ layoutPreset: c.preset,
+ frame,
+ })!;
+ const screen = layout.screenRect;
+ const drawn = expand(
+ screen,
+ frameFootprint(frame, screen, frameUnit(screen, canvas)).outer,
+ );
+ const block = isWebcamBlockLayout(c.preset);
+ const rects = block ? [drawn, layout.webcamRect!] : [drawn];
+ const border = ((1 - paddingFit(padding)) / 2) * Math.min(canvas.width, canvas.height);
+ const sides = [
+ Math.min(...rects.map((r) => r.x)),
+ Math.min(...rects.map((r) => r.y)),
+ canvas.width - Math.max(...rects.map((r) => r.x + r.width)),
+ canvas.height - Math.max(...rects.map((r) => r.y + r.height)),
+ ];
+ for (const side of sides) {
+ expect(Math.abs(side - border), `${frame}: ${sides}`).toBeLessThanOrEqual(2);
+ }
+ expect(screen.width / screen.height).toBeCloseTo(c.screen.width / c.screen.height, 1);
+ if (block) {
+ const cam = layout.webcamRect!;
+ expect(cam.width / cam.height, frame).toBeCloseTo(1, 1);
+ }
}
});
}
diff --git a/src/lib/compositeLayout.ts b/src/lib/compositeLayout.ts
index ba055525d..ad52114d4 100644
--- a/src/lib/compositeLayout.ts
+++ b/src/lib/compositeLayout.ts
@@ -290,18 +290,51 @@ function blockUnitSize(element: Size, block: BlockTransform, cameraAlong: number
: { width: element.width, height: element.height + block.gapFraction + cameraAlong };
}
+/**
+ * The screen and its frame at rest, in UNIT space where the screen is exactly 1 wide: the
+ * frame's body, everything it draws, and the box of the whole (`element`). The frame's thickness
+ * follows the scene it is drawn in (`frameUnit`), of which only the shape counts. Without a
+ * frame every inset is 0 and the element is the screen.
+ */
+function framedScreen(screenAspect: number, canvas: Size, frame: RecordingFrame) {
+ const screen = { width: 1, height: 1 / screenAspect };
+ const { body, outer } = frameFootprint(frame, screen, frameUnit(screen, canvas));
+ const element = {
+ width: outer[0] + screen.width + outer[2],
+ height: outer[1] + screen.height + outer[3],
+ };
+ return { screen, body, outer, element };
+}
+
/**
* The composition's own shape (width / height) before any frame constrains it — what the
* Auto format frames. Nothing is bent to fit: the screen keeps its ratio, and a block
* layout's camera takes its resting shape, square, beside or under it. A picture-in-picture
* bubble floats over the screen, so the composition is the screen alone.
+ *
+ * The screen wears its device frame: every layout measures the padding from what that frame
+ * draws, so it is part of the shape. Its thickness follows the scene's shape, `canvas`, which
+ * `autoFormatAspect` settles.
*/
-export function restingCompositionAspect(screenSize: Size, preset: WebcamLayoutPreset): number {
- const screenAspect = screenSize.width / screenSize.height;
+export function restingCompositionAspect(
+ screenSize: Size,
+ preset: WebcamLayoutPreset,
+ frame: RecordingFrame = "none",
+ canvas: Size = screenSize,
+): number {
+ const { screen, body, element } = framedScreen(
+ screenSize.width / screenSize.height,
+ canvas,
+ frame,
+ );
const transform = getWebcamLayoutPresetDefinition(preset).transform;
- if (transform.type !== "block") return screenAspect;
- const cameraCross = transform.direction === "row" ? 1 / screenAspect : 1;
- const block = blockUnitSize({ width: 1, height: 1 / screenAspect }, transform, cameraCross);
+ if (transform.type !== "block") return element.width / element.height;
+ // Square, lined up with the frame's body, as `computeCompositeLayout` lays it at rest.
+ const cameraCross =
+ transform.direction === "row"
+ ? body[1] + screen.height + body[3]
+ : body[0] + screen.width + body[2];
+ const block = blockUnitSize(element, transform, cameraCross);
return block.width / block.height;
}
@@ -344,6 +377,30 @@ export function autoFrameAspect(compositionAspect: number, padding: number): num
return compositionAspect >= 1 ? framed : 1 / framed;
}
+/**
+ * What the Auto format resolves to: `autoFrameAspect` over `restingCompositionAspect`.
+ *
+ * Under a device frame the two depend on each other: the device's thickness follows the shape of
+ * the scene it is drawn in (`frameUnit`), and Auto shapes that scene around the device. Each pass
+ * lays the device out in the scene the previous one gave. A device is thin next to its screen, so
+ * each pass moves the shape by a small fraction of the one before, and a few leave nothing a pixel
+ * could show.
+ */
+export function autoFormatAspect(
+ screenSize: Size,
+ preset: WebcamLayoutPreset,
+ frame: RecordingFrame,
+ padding: number,
+): number {
+ let aspect = autoFrameAspect(restingCompositionAspect(screenSize, preset), padding);
+ if (frame === "none") return aspect;
+ for (let pass = 0; pass < 8; pass++) {
+ const canvas = { width: aspect, height: 1 };
+ aspect = autoFrameAspect(restingCompositionAspect(screenSize, preset, frame, canvas), padding);
+ }
+ return aspect;
+}
+
export function computeCompositeLayout(params: {
canvasSize: Size;
maxContentSize?: Size;
@@ -357,8 +414,9 @@ export function computeCompositeLayout(params: {
/** Picture-in-picture only: 0 square corners to 1 fully round. */
webcamRoundness?: number;
/**
- * Block layouts only: the frame around the screen. There it is the screen's fixed container,
- * so the block makes room for it; everywhere else it grows into the padding.
+ * The frame around the screen. Every layout makes room for everything it draws: the padding
+ * is measured from its outer edge. In the block layouts it is also the screen's fixed
+ * container, and the camera lines up with its body.
*/
frame?: RecordingFrame;
}): WebcamCompositeLayout | null {
@@ -379,11 +437,7 @@ export function computeCompositeLayout(params: {
// no-webcam: hide the webcam, screen fills the canvas normally.
if (layoutPreset === "no-webcam") {
- const screenRect = centerRect({
- canvasSize,
- size: screenSize,
- maxSize: maxContentSize,
- });
+ const screenRect = centerScreen(canvasSize, screenSize, maxContentSize, frame);
return { screenRect, webcamRect: null };
}
@@ -404,7 +458,7 @@ export function computeCompositeLayout(params: {
// No camera on this clip: the block degenerates to the screen alone, which
// contain-fits the padded area like every other preset does.
return {
- screenRect: centerRect({ canvasSize, size: screenSize, maxSize: maxContentSize }),
+ screenRect: centerScreen(canvasSize, screenSize, maxContentSize, frame),
webcamRect: null,
};
}
@@ -428,12 +482,7 @@ export function computeCompositeLayout(params: {
// the screen itself. Its BODY is what the camera lines up with; what sticks out of the
// body (a laptop's deck, a monitor's stand) keeps the gap to the camera. Without a frame
// every inset is 0 and the arithmetic below is the frameless one, term for term.
- const unitScreen = { width: 1, height: unitScreenHeight };
- const { body, outer } = frameFootprint(frame, unitScreen, frameUnit(unitScreen, canvasSize));
- const element = {
- width: outer[0] + 1 + outer[2],
- height: outer[1] + unitScreenHeight + outer[3],
- };
+ const { body, outer, element } = framedScreen(screenAspect, canvasSize, frame);
// The camera shares the screen's cross-edge (same height beside it, same
// width under it — the aligned edge that makes them one solid block), so its
@@ -516,11 +565,7 @@ export function computeCompositeLayout(params: {
}
const transform = preset.transform;
- const screenRect = centerRect({
- canvasSize,
- size: screenSize,
- maxSize: maxContentSize,
- });
+ const screenRect = centerScreen(canvasSize, screenSize, maxContentSize, frame);
if (!webcamWidth || !webcamHeight || webcamWidth <= 0 || webcamHeight <= 0) {
return { screenRect, webcamRect: null };
@@ -593,6 +638,42 @@ function snapRect(x: number, y: number, width: number, height: number): RenderRe
};
}
+/**
+ * The screen with nothing welded to it, contain-fitted into the padded area and centred.
+ *
+ * Under a frame, what fits and centres is everything the frame draws: a window's bar, a laptop's
+ * deck, a monitor's stand. The padding is measured from the frame's outer edge, so at 0% the frame
+ * touches the scene and never goes past it, and a lopsided frame sits in the middle as a whole.
+ * The screen pays for it: it is smaller under a frame than without one.
+ */
+function centerScreen(
+ canvasSize: Size,
+ screenSize: Size,
+ maxContentSize: Size,
+ frame: RecordingFrame,
+): RenderRect {
+ if (frame === "none") {
+ return centerRect({ canvasSize, size: screenSize, maxSize: maxContentSize });
+ }
+ const { screen, outer, element } = framedScreen(
+ screenSize.width / screenSize.height,
+ canvasSize,
+ frame,
+ );
+ const scale = Math.min(
+ maxContentSize.width / element.width,
+ maxContentSize.height / element.height,
+ );
+ const originX = (canvasSize.width - element.width * scale) / 2;
+ const originY = (canvasSize.height - element.height * scale) / 2;
+ return snapRect(
+ originX + outer[0] * scale,
+ originY + outer[1] * scale,
+ scale,
+ screen.height * scale,
+ );
+}
+
function centerRect(params: { canvasSize: Size; size: Size; maxSize: Size }): RenderRect {
const { canvasSize, size, maxSize } = params;
return centerRectInBounds({
diff --git a/src/lib/frameFootprint.ts b/src/lib/frameFootprint.ts
index e625f6514..c1e49d92a 100644
--- a/src/lib/frameFootprint.ts
+++ b/src/lib/frameFootprint.ts
@@ -11,10 +11,10 @@ export type Insets = [number, number, number, number];
/**
* What a frame draws around the screen AT REST (flat, unzoomed), as insets from the screen box.
*
- * The native compositor draws the frames (`frame_geometry.rs`); this only measures them, for the
- * one layout family that must keep them clear of something: the block layouts, where the frame
- * is the screen's fixed container and sits next to the camera (`ScreenMask`). Everywhere else a
- * frame grows outward into the padding and zooms with the screen, and nothing lays out around it.
+ * The native compositor draws the frames (`frame_geometry.rs`) outward from the screen box it is
+ * given; this only measures them, for the layout that makes room for them: every layout measures
+ * the padding from what the frame draws, and the block layouts line the camera up with its body
+ * (`ScreenMask`).
*/
export interface FrameFootprint {
/** The frame's body: the window chrome, or a device's front face around its screen. */
diff --git a/technical-documentation/architecture/export-pipeline.md b/technical-documentation/architecture/export-pipeline.md
index 8df173ea1..54e872e4d 100644
--- a/technical-documentation/architecture/export-pipeline.md
+++ b/technical-documentation/architecture/export-pipeline.md
@@ -136,9 +136,12 @@ and **one** encoder + muxer pair:
1080p, whatever its frame rate.
Only "Source" quality targets those source dims; 720p / 1080p target a
fixed short side regardless.
- **Auto** resolves in that same function: the first clip's cropped screen,
- laid out with the camera layout at rest (`restingCompositionAspect`), plus
- an even padding border (`autoFrameAspect`). The preview and the scene pad an
+ **Auto** resolves in that same function: the first clip's cropped screen
+ inside its device frame, laid out with the camera layout at rest
+ (`restingCompositionAspect`), plus an even padding border
+ (`autoFrameAspect`). A device's thickness follows the output's shape, which
+ Auto shapes around the device, so `autoFormatAspect` settles the two in a
+ few passes. The preview and the scene pad an
Auto frame with the matching border (`paddedContentSize`,
`compositeLayout.ts`), so the composition fills it with the same margin on
all four sides. Auto is only offered while every clip has the same ratio,
diff --git a/technical-documentation/architecture/native-compositor.md b/technical-documentation/architecture/native-compositor.md
index 90ef193ab..b8ac7ffac 100644
--- a/technical-documentation/architecture/native-compositor.md
+++ b/technical-documentation/architecture/native-compositor.md
@@ -103,7 +103,9 @@ what `shaders.hlsl` actually implements:
and the 3D tilt act on the footage and are cropped to the slot. Under a window
or device frame, the frame is that container, drawn at rest around the slot and
never zoomed or tilted, and `computeCompositeLayout` makes room for it beside the
- camera. Everywhere else the frame zooms and tilts with the screen.
+ camera. Everywhere else the frame zooms and tilts with the screen. In every layout
+ the padding is measured from the frame's outer edge, so at rest the whole frame
+ stays on the canvas and is what gets centred.
4. **Cursor.** A sprite picked from `cursor.cursorSprites` by the OS cursor state
recorded in the `.cursor.json` track (`arrow`, `text`, `pointer`, the resize
handles…), anchored so the sprite's hotspot — a 0..1 fraction of its own image,