Reintroduce support for custom primitives in iced_wgpu
This commit is contained in:
parent
6ea763c2a7
commit
d922b47815
11 changed files with 220 additions and 173 deletions
|
|
@ -13,12 +13,13 @@ use crate::core::widget::tree::{self, Tree};
|
|||
use crate::core::widget::{self, Widget};
|
||||
use crate::core::window;
|
||||
use crate::core::{Clipboard, Element, Length, Rectangle, Shell, Size};
|
||||
use crate::renderer::wgpu::primitive::pipeline;
|
||||
use crate::renderer::wgpu::primitive;
|
||||
|
||||
use std::marker::PhantomData;
|
||||
|
||||
pub use crate::graphics::Viewport;
|
||||
pub use crate::renderer::wgpu::wgpu;
|
||||
pub use pipeline::{Primitive, Storage};
|
||||
pub use primitive::{Primitive, Storage};
|
||||
|
||||
/// A widget which can render custom shaders with Iced's `wgpu` backend.
|
||||
///
|
||||
|
|
@ -60,7 +61,7 @@ impl<P, Message, Theme, Renderer> Widget<Message, Theme, Renderer>
|
|||
for Shader<Message, P>
|
||||
where
|
||||
P: Program<Message>,
|
||||
Renderer: pipeline::Renderer,
|
||||
Renderer: primitive::Renderer,
|
||||
{
|
||||
fn tag(&self) -> tree::Tag {
|
||||
struct Tag<T>(T);
|
||||
|
|
@ -160,7 +161,7 @@ where
|
|||
let bounds = layout.bounds();
|
||||
let state = tree.state.downcast_ref::<P::State>();
|
||||
|
||||
renderer.draw_pipeline_primitive(
|
||||
renderer.draw_primitive(
|
||||
bounds,
|
||||
self.program.draw(state, cursor_position, bounds),
|
||||
);
|
||||
|
|
@ -171,7 +172,7 @@ impl<'a, Message, Theme, Renderer, P> From<Shader<Message, P>>
|
|||
for Element<'a, Message, Theme, Renderer>
|
||||
where
|
||||
Message: 'a,
|
||||
Renderer: pipeline::Renderer,
|
||||
Renderer: primitive::Renderer,
|
||||
P: Program<Message> + 'a,
|
||||
{
|
||||
fn from(
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
use crate::core::event;
|
||||
use crate::core::mouse;
|
||||
use crate::core::{Rectangle, Shell};
|
||||
use crate::renderer::wgpu::primitive::pipeline;
|
||||
use crate::renderer::wgpu::Primitive;
|
||||
use crate::shader;
|
||||
|
||||
/// The state and logic of a [`Shader`] widget.
|
||||
|
|
@ -15,7 +15,7 @@ pub trait Program<Message> {
|
|||
type State: Default + 'static;
|
||||
|
||||
/// The type of primitive this [`Program`] can draw.
|
||||
type Primitive: pipeline::Primitive + 'static;
|
||||
type Primitive: Primitive + 'static;
|
||||
|
||||
/// Update the internal [`State`] of the [`Program`]. This can be used to reflect state changes
|
||||
/// based on mouse & other events. You can use the [`Shell`] to publish messages, request a
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue