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

anvil/udev: Dynamic support for pixman rendererer #1497

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 34 additions & 11 deletions anvil/src/drawing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,31 +123,54 @@ where
pub static FPS_NUMBERS_PNG: &[u8] = include_bytes!("../resources/numbers.png");

#[cfg(feature = "debug")]
#[derive(Debug, Clone)]
pub struct FpsElement<T: Texture> {
#[derive(Debug)]
pub struct Fps {
id: Id,
fps: fps_ticker::Fps,
value: u32,
texture: T,
commit_counter: CommitCounter,
}

#[cfg(feature = "debug")]
impl<T: Texture> FpsElement<T> {
pub fn new(texture: T) -> Self {
FpsElement {
impl Default for Fps {
fn default() -> Self {
Self {
id: Id::new(),
texture,
fps: fps_ticker::Fps::default(),
value: 0,
commit_counter: CommitCounter::default(),
}
}
}

pub fn update_fps(&mut self, fps: u32) {
if self.value != fps {
self.value = fps;
#[cfg(feature = "debug")]
impl Fps {
pub fn tick(&mut self) {
self.fps.tick();
let value = self.fps.avg().round() as u32;
if self.value != value {
self.value = value;
self.commit_counter.increment();
}
}

pub fn render_element<T: Texture>(&self, texture: T) -> FpsElement<T> {
FpsElement {
id: self.id.clone(),
value: self.value,
commit_counter: self.commit_counter,
texture,
}
}
}

#[cfg(feature = "debug")]
#[derive(Debug)]
pub struct FpsElement<T: Texture> {
id: Id,
value: u32,
commit_counter: CommitCounter,
texture: T,
}

#[cfg(feature = "debug")]
Expand Down Expand Up @@ -194,7 +217,7 @@ where
impl<R> RenderElement<R> for FpsElement<<R as Renderer>::TextureId>
where
R: Renderer + ImportAll,
<R as Renderer>::TextureId: 'static,
<R as Renderer>::TextureId: Send + 'static,
{
fn draw(
&self,
Expand Down
8 changes: 5 additions & 3 deletions anvil/src/render.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ use crate::{

smithay::backend::renderer::element::render_elements! {
pub CustomRenderElements<R> where
R: ImportAll + ImportMem;
R: ImportAll + ImportMem,
<R as Renderer>::TextureId: Send;
Pointer=PointerRenderElement<R>,
Surface=WaylandSurfaceRenderElement<R>,
#[cfg(feature = "debug")]
Expand All @@ -51,7 +52,8 @@ impl<R: Renderer> std::fmt::Debug for CustomRenderElements<R> {
}

smithay::backend::renderer::element::render_elements! {
pub OutputRenderElements<R, E> where R: ImportAll + ImportMem;
pub OutputRenderElements<R, E> where R: ImportAll + ImportMem,
<R as Renderer>::TextureId: Send;
Space=SpaceRenderElements<R, E>,
Window=Wrap<E>,
Custom=CustomRenderElements<R>,
Expand Down Expand Up @@ -201,7 +203,7 @@ pub fn render_output<'a, 'd, R>(
) -> Result<RenderOutputResult<'d>, OutputDamageTrackerError<R>>
where
R: Renderer + ImportAll + ImportMem,
R::TextureId: Clone + 'static,
R::TextureId: Clone + Send + 'static,
{
let (elements, clear_color) =
output_elements(output, space, custom_elements, renderer, show_window_preview);
Expand Down
Loading
Loading