-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Stencil #128
Conversation
pub(crate) enum PanelRenderElement { | ||
Wayland(WaylandSurfaceRenderElement<GlesRenderer>), | ||
RoundedRectangle(RoundedRectangleShaderElement), | ||
} | ||
|
||
impl Element for PanelRenderElement { | ||
fn id(&self) -> &smithay::backend::renderer::element::Id { | ||
match self { | ||
Self::Wayland(e) => e.id(), | ||
Self::RoundedRectangle(e) => e.id(), | ||
} | ||
} | ||
|
||
fn current_commit(&self) -> smithay::backend::renderer::utils::CommitCounter { | ||
match self { | ||
Self::Wayland(e) => e.current_commit(), | ||
Self::RoundedRectangle(e) => e.current_commit(), | ||
} | ||
} | ||
|
||
fn src(&self) -> Rectangle<f64, Buffer> { | ||
match self { | ||
Self::Wayland(e) => e.src(), | ||
Self::RoundedRectangle(e) => e.src(), | ||
} | ||
} | ||
|
||
fn geometry(&self, scale: smithay::utils::Scale<f64>) -> Rectangle<i32, Physical> { | ||
match self { | ||
Self::Wayland(e) => e.geometry(scale), | ||
Self::RoundedRectangle(e) => e.geometry(scale), | ||
} | ||
} | ||
} | ||
|
||
impl RenderElement<GlesRenderer> for PanelRenderElement { | ||
fn draw( | ||
&self, | ||
frame: &mut GlesFrame<'_>, | ||
src: Rectangle<f64, Buffer>, | ||
dst: Rectangle<i32, Physical>, | ||
damage: &[Rectangle<i32, Physical>], | ||
) -> Result<(), GlesError> { | ||
match self { | ||
Self::Wayland(e) => e.draw(frame, src, dst, damage), | ||
Self::RoundedRectangle(e) => e.draw(frame, src, dst, damage), | ||
} | ||
} | ||
|
||
fn underlying_storage(&self, renderer: &mut GlesRenderer) -> Option<UnderlyingStorage> { | ||
match self { | ||
PanelRenderElement::Wayland(e) => e.underlying_storage(renderer), | ||
PanelRenderElement::RoundedRectangle(e) => e.underlying_storage(renderer), | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given you are using a fixed Renderer type, you can probably use smithays render_elements
-macro to generate all of this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried to do so but I couldn't figure out how to resolve the error when adding the RoundedRectangle variant. I'm not sure exactly why but it believed that it didn't meet the trait bounds.
This fixes an issue of applet overdraw at the corners when there is a border radius, and also simplifies rendering quite a bit by using a shader instead of software rendering for the panel background.