Skip to content

Commit

Permalink
fixup! WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
Drakulix committed Dec 12, 2024
1 parent 2a4b177 commit 3b7796d
Showing 1 changed file with 19 additions and 16 deletions.
35 changes: 19 additions & 16 deletions src/backend/kms/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use smithay::{
dmabuf::Dmabuf,
gbm::{GbmAllocator, GbmBufferFlags},
},
drm::{DrmDeviceFd, DrmNode, NodeType},
drm::{output::DrmOutputRenderElements, DrmDeviceFd, DrmNode, NodeType},
egl::{context::ContextPriority, EGLContext, EGLDevice, EGLDisplay},
input::InputEvent,
libinput::{LibinputInputBackend, LibinputSessionInterface},
Expand Down Expand Up @@ -57,9 +57,7 @@ pub(crate) use surface::Surface;
use device::*;
pub use surface::Timings;

use super::render::{
element::CosmicElement, init_shaders, output_elements, CursorMode, CLEAR_COLOR,
};
use super::render::{init_shaders, output_elements, CursorMode, CLEAR_COLOR};

#[derive(Debug)]
pub struct KmsState {
Expand Down Expand Up @@ -699,15 +697,14 @@ impl KmsState {
planes.overlay = vec![];
}

let mut builder = drm.initialize_output::<_, CosmicElement<_>>(*crtc);

let mut renderer = self
.api
.single_renderer(&device.render_node)
.with_context(|| "Failed to create renderer")?;

let mut elements = DrmOutputRenderElements::default();
for (crtc, output) in output_map.iter() {
let elements = output_elements(
let output_elements = output_elements(
Some(&device.render_node),
&mut renderer,
&shell,
Expand All @@ -718,11 +715,19 @@ impl KmsState {
)
.with_context(|| "Failed to render outputs")?;

builder.add_render_contents(crtc, CLEAR_COLOR, elements);
elements.add_output(crtc, CLEAR_COLOR, output_elements);
}

let compositor = builder
.build(&mut renderer, *mode, &[conn], &surface.output, Some(planes))
let compositor = drm
.initialize_output(
*crtc,
*mode,
&[conn],
&surface.output,
Some(planes),
&mut renderer,
&elements,
)
.with_context(|| "Failed to create drm surface")?;

let _ = renderer;
Expand Down Expand Up @@ -774,15 +779,14 @@ impl KmsState {
}
}

let mut builder = drm.use_mode(surface.crtc);

let mut renderer = self
.api
.single_renderer(&device.render_node)
.with_context(|| "Failed to create renderer")?;

let mut elements = DrmOutputRenderElements::default();
for (crtc, output) in output_map.iter() {
let elements = output_elements(
let output_elements = output_elements(
Some(&device.render_node),
&mut renderer,
&shell,
Expand All @@ -793,11 +797,10 @@ impl KmsState {
)
.with_context(|| "Failed to render outputs")?;

builder.add_render_contents(crtc, CLEAR_COLOR, elements);
elements.add_output(crtc, CLEAR_COLOR, output_elements);
}

builder
.commit(&mut renderer, *mode)
drm.use_mode(&surface.crtc, *mode, &mut renderer, &elements)
.context("Failed to apply new mode")?;
}
}
Expand Down

0 comments on commit 3b7796d

Please sign in to comment.