mirror of
https://github.com/italicsjenga/vello.git
synced 2025-01-09 20:31:29 +11:00
revert rename of SceneBuilder ctors
This commit is contained in:
parent
36fa836735
commit
9ad7f7270e
|
@ -30,30 +30,18 @@ pub struct SceneBuilder<'a> {
|
|||
impl<'a> SceneBuilder<'a> {
|
||||
/// Creates a new builder for filling a scene. Any current content in the scene
|
||||
/// will be cleared.
|
||||
#[deprecated = "use SceneBuilder::new() instead"]
|
||||
pub fn for_scene(scene: &'a mut Scene) -> Self {
|
||||
Self::new_inner(&mut scene.data, false)
|
||||
Self::new(&mut scene.data, false)
|
||||
}
|
||||
|
||||
/// Creates a new builder for filling a scene fragment. Any current content in
|
||||
/// the fragment will be cleared.
|
||||
#[deprecated = "use SceneBuilder::new() instead"]
|
||||
pub fn for_fragment(fragment: &'a mut SceneFragment) -> Self {
|
||||
Self::new_inner(&mut fragment.data, true)
|
||||
}
|
||||
|
||||
/// Creates a new scene builder for a scene or scene fragment. Any content will be
|
||||
/// cleared. The types accepted for the scene parameter are `&mut Scene` or
|
||||
/// `&mut SceneFragment`.
|
||||
pub fn new(scene: impl Into<AnyScene<'a>>) -> Self {
|
||||
match scene.into() {
|
||||
AnyScene::Scene(scene) => Self::new_inner(&mut scene.data, false),
|
||||
AnyScene::Fragment(fragment) => Self::new_inner(&mut fragment.data, true),
|
||||
}
|
||||
Self::new(&mut fragment.data, true)
|
||||
}
|
||||
|
||||
/// Creates a new builder for constructing a scene.
|
||||
fn new_inner(scene: &'a mut SceneData, is_fragment: bool) -> Self {
|
||||
fn new(scene: &'a mut SceneData, is_fragment: bool) -> Self {
|
||||
scene.reset(is_fragment);
|
||||
Self {
|
||||
scene,
|
||||
|
@ -288,25 +276,6 @@ impl<'a> SceneBuilder<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
/// Helper for constructing a scene builder.
|
||||
#[doc(hidden)]
|
||||
pub enum AnyScene<'a> {
|
||||
Scene(&'a mut Scene),
|
||||
Fragment(&'a mut SceneFragment),
|
||||
}
|
||||
|
||||
impl<'a> From<&'a mut Scene> for AnyScene<'a> {
|
||||
fn from(scene: &'a mut Scene) -> Self {
|
||||
Self::Scene(scene)
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> From<&'a mut SceneFragment> for AnyScene<'a> {
|
||||
fn from(scene: &'a mut SceneFragment) -> Self {
|
||||
Self::Fragment(scene)
|
||||
}
|
||||
}
|
||||
|
||||
fn encode_blend_mode(mode: BlendMode) -> u32 {
|
||||
(mode.mix as u32) << 8 | mode.compose as u32
|
||||
}
|
||||
|
|
|
@ -70,7 +70,7 @@ async fn run() -> Result<()> {
|
|||
current_frame += 1;
|
||||
let width = surface.config.width;
|
||||
let height = surface.config.height;
|
||||
let mut builder = SceneBuilder::new(&mut scene);
|
||||
let mut builder = SceneBuilder::for_scene(&mut scene);
|
||||
const N_SCENES: usize = 6;
|
||||
match scene_ix % N_SCENES {
|
||||
0 => test_scene::render_anim_frame(&mut builder, &mut simple_text, current_frame),
|
||||
|
|
|
@ -265,7 +265,7 @@ fn render_blend_square(sb: &mut SceneBuilder, blend: BlendMode, transform: Affin
|
|||
#[allow(unused)]
|
||||
fn blend_square(blend: BlendMode) -> SceneFragment {
|
||||
let mut fragment = SceneFragment::default();
|
||||
let mut sb = SceneBuilder::new(&mut fragment);
|
||||
let mut sb = SceneBuilder::for_fragment(&mut fragment);
|
||||
render_blend_square(&mut sb, blend, Affine::IDENTITY);
|
||||
sb.finish();
|
||||
fragment
|
||||
|
|
Loading…
Reference in a new issue