Skip to content
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

Merged
merged 8 commits into from
Mar 16, 2024
Merged

Stencil #128

merged 8 commits into from
Mar 16, 2024

Conversation

wash2
Copy link
Collaborator

@wash2 wash2 commented Mar 15, 2024

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.

@wash2 wash2 requested a review from a team March 16, 2024 00:08
Comment on lines +98 to +152
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),
}
}
Copy link
Member

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.

Copy link
Collaborator Author

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.

@wash2 wash2 merged commit 608503e into master Mar 16, 2024
@wash2 wash2 deleted the stencil branch March 16, 2024 18:48
@wash2 wash2 restored the stencil branch March 17, 2024 01:09
@wash2 wash2 mentioned this pull request Mar 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants