From 9ad7f7270eadd0041c93587b6bf978e649bfaebd Mon Sep 17 00:00:00 2001 From: Chad Brokaw Date: Sat, 26 Nov 2022 16:00:34 -0500 Subject: [PATCH] revert rename of SceneBuilder ctors --- piet-scene/src/scene/builder.rs | 37 ++-------------------- piet-wgsl/examples/winit/src/main.rs | 2 +- piet-wgsl/examples/winit/src/test_scene.rs | 2 +- 3 files changed, 5 insertions(+), 36 deletions(-) diff --git a/piet-scene/src/scene/builder.rs b/piet-scene/src/scene/builder.rs index 3417b97..17a236a 100644 --- a/piet-scene/src/scene/builder.rs +++ b/piet-scene/src/scene/builder.rs @@ -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>) -> 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 } diff --git a/piet-wgsl/examples/winit/src/main.rs b/piet-wgsl/examples/winit/src/main.rs index 3537dce..ba6226c 100644 --- a/piet-wgsl/examples/winit/src/main.rs +++ b/piet-wgsl/examples/winit/src/main.rs @@ -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), diff --git a/piet-wgsl/examples/winit/src/test_scene.rs b/piet-wgsl/examples/winit/src/test_scene.rs index e57dce8..4c90829 100644 --- a/piet-wgsl/examples/winit/src/test_scene.rs +++ b/piet-wgsl/examples/winit/src/test_scene.rs @@ -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