diff options
| author | 2020-04-28 03:18:31 +0200 | |
|---|---|---|
| committer | 2020-04-28 03:52:10 +0200 | |
| commit | 59b1e90661ee9e479f404bae71029db824cc7b46 (patch) | |
| tree | f98949ea315b4e58922be3f2ed333cadcbcbac01 /wgpu/src/renderer | |
| parent | 2381a9310c56f60698653f5fd13f5a0d80fa4f67 (diff) | |
| download | iced-59b1e90661ee9e479f404bae71029db824cc7b46.tar.gz iced-59b1e90661ee9e479f404bae71029db824cc7b46.tar.bz2 iced-59b1e90661ee9e479f404bae71029db824cc7b46.zip | |
Introduce `Translate` primitive in `iced_wgpu`
Diffstat (limited to '')
| -rw-r--r-- | wgpu/src/renderer.rs | 20 | ||||
| -rw-r--r-- | wgpu/src/renderer/widget/pane_grid.rs | 6 | 
2 files changed, 16 insertions, 10 deletions
| diff --git a/wgpu/src/renderer.rs b/wgpu/src/renderer.rs index 481b310c..e93532bc 100644 --- a/wgpu/src/renderer.rs +++ b/wgpu/src/renderer.rs @@ -29,7 +29,7 @@ pub struct Renderer {  struct Layer<'a> {      bounds: Rectangle<u32>,      quads: Vec<Quad>, -    meshes: Vec<(Point, &'a triangle::Mesh2D)>, +    meshes: Vec<(Vector, &'a triangle::Mesh2D)>,      text: Vec<wgpu_glyph::Section<'a>>,      #[cfg(any(feature = "image", feature = "svg"))] @@ -214,10 +214,10 @@ impl Renderer {                      border_color: border_color.into_linear(),                  });              } -            Primitive::Mesh2D { origin, buffers } => { +            Primitive::Mesh2D { buffers } => {                  let layer = layers.last_mut().unwrap(); -                layer.meshes.push((*origin + translation, buffers)); +                layer.meshes.push((translation, buffers));              }              Primitive::Clip {                  bounds, @@ -249,15 +249,21 @@ impl Renderer {                      layers.push(new_layer);                  }              } - -            Primitive::Cached { origin, cache } => { +            Primitive::Translate { +                translation: new_translation, +                content, +            } => {                  self.draw_primitive( -                    translation + Vector::new(origin.x, origin.y), -                    &cache, +                    translation + *new_translation, +                    &content,                      layers,                  );              } +            Primitive::Cached { cache } => { +                self.draw_primitive(translation, &cache, layers); +            } +              #[cfg(feature = "image")]              Primitive::Image { handle, bounds } => {                  let layer = layers.last_mut().unwrap(); diff --git a/wgpu/src/renderer/widget/pane_grid.rs b/wgpu/src/renderer/widget/pane_grid.rs index 2d201fec..11ba6347 100644 --- a/wgpu/src/renderer/widget/pane_grid.rs +++ b/wgpu/src/renderer/widget/pane_grid.rs @@ -59,12 +59,12 @@ impl pane_grid::Renderer for Renderer {                      height: bounds.height + 0.5,                  },                  offset: Vector::new(0, 0), -                content: Box::new(Primitive::Cached { -                    origin: Point::new( +                content: Box::new(Primitive::Translate { +                    translation: Vector::new(                          cursor_position.x - bounds.x - bounds.width / 2.0,                          cursor_position.y - bounds.y - bounds.height / 2.0,                      ), -                    cache: std::sync::Arc::new(pane), +                    content: Box::new(pane),                  }),              }; | 
