pub struct EditorPreview {
compose: RecordingCompose,
screen_slot: FrameSlot,
cam_slot: FrameSlot,
width: u32,
height: u32,
pad: (f64, f64),
aspect_fit: (f64, f64),
}Expand description
Composes the editor preview frame for a source_w × source_h clip into a
canvas_w × canvas_h output (the project’s aspect-ratio canvas).
Fields§
§compose: RecordingCompose§screen_slot: FrameSlot§cam_slot: FrameSlotAlways empty — the editor source is pre-composited, so the scene’s camera channel never renders.
width: u32§height: u32§pad: (f64, f64)Per-axis screen shrink applied to the transform: the aspect-fit matte
(AUT-513) optionally multiplied by the Self::set_background padding
inset (ED.18). Defaults to the aspect-fit so an un-styled render still
letterboxes the source into a differently-shaped canvas.
aspect_fit: (f64, f64)The aspect-fit-only factor (no padding) — the matte that fits the source
into the canvas. set_background re-derives pad as padding · this.
Implementations§
Source§impl EditorPreview
impl EditorPreview
Sourcepub fn new(width: u32, height: u32) -> Result<Self, Error>
pub fn new(width: u32, height: u32) -> Result<Self, Error>
Allocate the compose pipeline for a clip rendered at its own
dimensions (source aspect == canvas aspect, no matte). Equivalent to
Self::with_canvas(width, height, width, height).
§Errors
Returns the underlying [wisp::Error] if the wgpu device can’t be
created.
Sourcepub fn with_canvas(
source_w: u32,
source_h: u32,
canvas_w: u32,
canvas_h: u32,
) -> Result<Self, Error>
pub fn with_canvas( source_w: u32, source_h: u32, canvas_w: u32, canvas_h: u32, ) -> Result<Self, Error>
Allocate the compose pipeline for a source_w × source_h clip rendered
into a canvas_w × canvas_h output canvas (AUT-513). When the canvas
aspect differs from the source aspect the source is aspect-fit into
the canvas (letterbox / pillarbox) rather than stretched — the matte
area shows the background. Use [EditProject::canvas_dims] for the
canvas; the export path additionally clamps it to the HW-encoder edge cap.
§Errors
Returns the underlying [wisp::Error] if the wgpu device can’t be
created.
Sourcepub fn set_background(&mut self, bg: &BackgroundConfig)
pub fn set_background(&mut self, bg: &BackgroundConfig)
Apply the project’s background framing (ED.18): the backdrop fill,
the padding inset, and the rounded-corner frame window. Call once when
the config changes — the export sets it once at generator construction;
a live preview re-applies it on edit. After this, the per-frame
Self::render_framed folds the stored padding factor into the screen
transform, the screen sprite is clipped to the rounded window, and the
backdrop renders behind it.
Drop-shadow (shadow) lifts the screen off the backdrop; the inset
border (inset) traces a colored edge just inside the frame — both
rendered here (ED.18). A Wallpaper source renders a procedural
backdrop (wallpaper_rgba, ISS-15) — license-clean, no bundled asset.
Sourcefn apply_shadow_and_border(
&mut self,
bg: &BackgroundConfig,
window: Rect,
corner_ndc: f32,
)
fn apply_shadow_and_border( &mut self, bg: &BackgroundConfig, window: Rect, corner_ndc: f32, )
Apply the drop shadow + inset border for the frame window (ED.18).
shadow (0..=100) scales a dark, down-right-offset rounded-rect behind
the screen; inset (px) strokes a colored border tracing the window.
Each hides its node when its value is 0.
Sourcepub fn render_frame(&mut self, bgra: Vec<u8>) -> Option<ComposedFrame>
pub fn render_frame(&mut self, bgra: Vec<u8>) -> Option<ComposedFrame>
Compose a single source frame. bgra is top-down packed BGRA8 of
exactly width * height * 4 bytes (the decoder’s native output);
the scene flips it to wisp’s convention internally. Returns None
if the byte count doesn’t match the configured dimensions.
Sourcepub fn render_framed(
&mut self,
bgra: Vec<u8>,
zoom: ZoomTransform,
crop: CropRect,
) -> Option<ComposedFrame>
pub fn render_framed( &mut self, bgra: Vec<u8>, zoom: ZoomTransform, crop: CropRect, ) -> Option<ComposedFrame>
Compose a source frame with the editor’s framing applied — the
crop/aspect reframe (ED.15), the zoom punch-in (ED.16), and the
background padding inset (ED.18) are written into the screen
sprite’s transform, then the frame composes through the same path as
Self::render_frame. The backdrop + rounded-corner clip are set
once via Self::set_background; this only updates the per-frame
transform. The padding factor is (1, 1) until set_background runs,
so an un-styled call is the plain ED.16 transform. This is the export
generator’s entry point (ED.20), so preview and export agree
frame-for-frame. bgra is top-down packed BGRA8 of width*height*4.
Sourcepub fn render_framed_with_cursor(
&mut self,
bgra: Vec<u8>,
zoom: ZoomTransform,
crop: CropRect,
cursor: Option<(f32, f32)>,
ripples: &[(f32, f32, f32)],
cfg: &CursorConfig,
) -> Option<ComposedFrame>
pub fn render_framed_with_cursor( &mut self, bgra: Vec<u8>, zoom: ZoomTransform, crop: CropRect, cursor: Option<(f32, f32)>, ripples: &[(f32, f32, f32)], cfg: &CursorConfig, ) -> Option<ComposedFrame>
Like Self::render_framed, plus the cursor overlay (ED.19). cursor
is the smoothed normalized position at this frame
([edit::telemetry::cursor_at]); ripples are the active click
ripples ((x, y, age) from [edit::telemetry::ripples_at]). Both the
pointer and each ripple are mapped through the same screen
transform as the frame, so the cursor stays glued to its pixel through
zoom / crop / padding. cursor = None hides the overlay (e.g. before
any sample, or a hide_static gap the caller decides).
Sourcepub fn render_at(
&mut self,
stream: &mut EditorVideoStream,
player: &EditorPlayer,
) -> Option<ComposedFrame>
pub fn render_at( &mut self, stream: &mut EditorVideoStream, player: &EditorPlayer, ) -> Option<ComposedFrame>
Compose the frame at the player’s current playhead, pulling it from
the seekable stream. Returns None past the end of the stream.
Sourcepub fn dimensions(&self) -> (u32, u32)
pub fn dimensions(&self) -> (u32, u32)
Output dimensions in pixels.
Auto Trait Implementations§
impl !Freeze for EditorPreview
impl !RefUnwindSafe for EditorPreview
impl Send for EditorPreview
impl !Sync for EditorPreview
impl Unpin for EditorPreview
impl UnsafeUnpin for EditorPreview
impl !UnwindSafe for EditorPreview
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more