Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement workaround to prevent panics with empty scenes #629

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 26 additions & 1 deletion vello/src/scene.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,39 @@ use vello_encoding::{Encoding, Glyph, GlyphRun, Patch, Transform};
///
/// A Scene stores a sequence of drawing commands, their context, and the
/// associated resources, which can later be rendered.
#[derive(Clone, Default)]
#[derive(Clone)]
pub struct Scene {
encoding: Encoding,
#[cfg(feature = "bump_estimate")]
estimator: vello_encoding::BumpEstimator,
}
static_assertions::assert_impl_all!(Scene: Send, Sync);

impl Default for Scene {
fn default() -> Self {
let mut scene = Self {
encoding: Default::default(),
#[cfg(feature = "bump_estimate")]
estimator: Default::default(),
};

// FIXME - `Render` panics when given an empty scene
// See https://github.com/linebender/vello/issues/291
// Until that panic is fixed, this workaround makes it
// so scenes are never empty by default.
let empty_path = Rect::ZERO;
scene.fill(
Fill::NonZero,
Affine::IDENTITY,
Color::TRANSPARENT,
None,
&empty_path,
);

scene
}
}

impl Scene {
/// Creates a new scene.
pub fn new() -> Self {
Expand Down