mirror of
https://github.com/italicsjenga/vello.git
synced 2025-01-09 20:31:29 +11:00
Updates to scene/fragment builder
* Add impl Into<Affine> for pushing transforms. * Small QOL API changes to Scene and Fragment. * Add some missing docs.
This commit is contained in:
parent
e600bdbbe4
commit
a20dd43b39
|
@ -24,8 +24,8 @@ use core::borrow::Borrow;
|
|||
const MAX_BLEND_STACK: usize = 256;
|
||||
|
||||
/// Creates a new builder for constructing a scene.
|
||||
pub fn build_scene<'a>(scene: &'a mut Scene, resources: &'a mut ResourceContext) -> Builder<'a> {
|
||||
Builder::new(&mut scene.data, ResourceData::Scene(resources))
|
||||
pub fn build_scene<'a>(scene: &'a mut Scene, rcx: &'a mut ResourceContext) -> Builder<'a> {
|
||||
Builder::new(&mut scene.data, ResourceData::Scene(rcx))
|
||||
}
|
||||
|
||||
/// Creates a new builder for construction a scene fragment.
|
||||
|
@ -62,7 +62,8 @@ impl<'a> Builder<'a> {
|
|||
}
|
||||
|
||||
/// Pushes a transform matrix onto the stack.
|
||||
pub fn push_transform(&mut self, transform: Affine) {
|
||||
pub fn push_transform(&mut self, transform: impl Into<Affine>) {
|
||||
let transform = transform.into();
|
||||
self.transform(transform);
|
||||
self.transforms.push(transform);
|
||||
}
|
||||
|
|
|
@ -23,11 +23,13 @@ pub use builder::{build_fragment, build_scene, Builder};
|
|||
pub use style::*;
|
||||
|
||||
use super::brush::*;
|
||||
use super::geometry::{Affine, Point, Rect};
|
||||
use super::geometry::{Affine, Point};
|
||||
use super::path::Element;
|
||||
use super::resource::ResourceContext;
|
||||
|
||||
use core::ops::Range;
|
||||
|
||||
/// Raw data streams describing an encoded scene.
|
||||
#[derive(Default)]
|
||||
pub struct SceneData {
|
||||
pub transform_stream: Vec<Affine>,
|
||||
|
@ -83,6 +85,13 @@ pub struct Scene {
|
|||
}
|
||||
|
||||
impl Scene {
|
||||
/// Creates a new builder for filling the scene. Any current content in
|
||||
/// the scene is cleared.
|
||||
pub fn build<'a>(&'a mut self, rcx: &'a mut ResourceContext) -> Builder<'a> {
|
||||
build_scene(self, rcx)
|
||||
}
|
||||
|
||||
/// Returns the raw encoded scene data streams.
|
||||
pub fn data(&self) -> &SceneData {
|
||||
&self.data
|
||||
}
|
||||
|
@ -96,9 +105,17 @@ pub struct Fragment {
|
|||
}
|
||||
|
||||
impl Fragment {
|
||||
/// Returns the underlying stream of points that defined all encoded path
|
||||
/// segments.
|
||||
pub fn points(&self) -> &[Point] {
|
||||
bytemuck::cast_slice(&self.data.pathseg_stream)
|
||||
}
|
||||
|
||||
/// Creates a new builder for filling the fragment. Any current content in
|
||||
/// the fragment is cleared.
|
||||
pub fn build<'a>(&'a mut self) -> Builder<'a> {
|
||||
build_fragment(self)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
|
|
Loading…
Reference in a new issue