anvil: Update to new apis
This commit is contained in:
parent
fafbf300dc
commit
36d910056c
|
@ -178,6 +178,7 @@ where
|
||||||
buffer_scale,
|
buffer_scale,
|
||||||
output_scale as f64,
|
output_scale as f64,
|
||||||
Transform::Normal, /* TODO */
|
Transform::Normal, /* TODO */
|
||||||
|
&[Rectangle::from_loc_and_size((0, 0), (i32::MAX, i32::MAX))],
|
||||||
1.0,
|
1.0,
|
||||||
) {
|
) {
|
||||||
result = Err(err.into());
|
result = Err(err.into());
|
||||||
|
@ -355,6 +356,7 @@ where
|
||||||
_ => unreachable!(),
|
_ => unreachable!(),
|
||||||
},
|
},
|
||||||
Rectangle::from_loc_and_size((offset_x, 0.0), (22.0 * output_scale, 35.0 * output_scale)),
|
Rectangle::from_loc_and_size((offset_x, 0.0), (22.0 * output_scale, 35.0 * output_scale)),
|
||||||
|
&[Rectangle::from_loc_and_size((0, 0), (i32::MAX, i32::MAX))],
|
||||||
Transform::Normal,
|
Transform::Normal,
|
||||||
1.0,
|
1.0,
|
||||||
)
|
)
|
||||||
|
|
|
@ -24,7 +24,10 @@ pub fn render_layers_and_windows(
|
||||||
output_scale: f32,
|
output_scale: f32,
|
||||||
logger: &Logger,
|
logger: &Logger,
|
||||||
) -> Result<(), SwapBuffersError> {
|
) -> Result<(), SwapBuffersError> {
|
||||||
frame.clear([0.8, 0.8, 0.9, 1.0], None)?;
|
frame.clear(
|
||||||
|
[0.8, 0.8, 0.9, 1.0],
|
||||||
|
&[Rectangle::from_loc_and_size((0, 0), (i32::MAX, i32::MAX))],
|
||||||
|
)?;
|
||||||
|
|
||||||
for layer in [Layer::Background, Layer::Bottom] {
|
for layer in [Layer::Background, Layer::Bottom] {
|
||||||
draw_layers(
|
draw_layers(
|
||||||
|
|
|
@ -50,7 +50,7 @@ use smithay::{
|
||||||
},
|
},
|
||||||
utils::{
|
utils::{
|
||||||
signaling::{Linkable, SignalToken, Signaler},
|
signaling::{Linkable, SignalToken, Signaler},
|
||||||
Logical, Point,
|
Logical, Point, Rectangle,
|
||||||
},
|
},
|
||||||
wayland::{
|
wayland::{
|
||||||
output::{Mode, PhysicalProperties},
|
output::{Mode, PhysicalProperties},
|
||||||
|
@ -797,6 +797,7 @@ fn render_surface(
|
||||||
1,
|
1,
|
||||||
output_scale as f64,
|
output_scale as f64,
|
||||||
Transform::Normal,
|
Transform::Normal,
|
||||||
|
&[Rectangle::from_loc_and_size((0, 0), (i32::MAX, i32::MAX))],
|
||||||
1.0,
|
1.0,
|
||||||
)?;
|
)?;
|
||||||
}
|
}
|
||||||
|
@ -862,7 +863,10 @@ fn initial_render(surface: &mut RenderSurface, renderer: &mut Gles2Renderer) ->
|
||||||
renderer
|
renderer
|
||||||
.render((1, 1).into(), Transform::Normal, |_, frame| {
|
.render((1, 1).into(), Transform::Normal, |_, frame| {
|
||||||
frame
|
frame
|
||||||
.clear([0.8, 0.8, 0.9, 1.0], None)
|
.clear(
|
||||||
|
[0.8, 0.8, 0.9, 1.0],
|
||||||
|
&[Rectangle::from_loc_and_size((0, 0), (i32::MAX, i32::MAX))],
|
||||||
|
)
|
||||||
.map_err(Into::<SwapBuffersError>::into)
|
.map_err(Into::<SwapBuffersError>::into)
|
||||||
})
|
})
|
||||||
.map_err(Into::<SwapBuffersError>::into)
|
.map_err(Into::<SwapBuffersError>::into)
|
||||||
|
|
|
@ -9,6 +9,7 @@ use smithay::{
|
||||||
};
|
};
|
||||||
use smithay::{
|
use smithay::{
|
||||||
backend::{
|
backend::{
|
||||||
|
renderer::{Renderer, Transform},
|
||||||
winit::{self, WinitEvent},
|
winit::{self, WinitEvent},
|
||||||
SwapBuffersError,
|
SwapBuffersError,
|
||||||
},
|
},
|
||||||
|
@ -46,39 +47,39 @@ pub fn run_winit(log: Logger) {
|
||||||
let mut event_loop = EventLoop::try_new().unwrap();
|
let mut event_loop = EventLoop::try_new().unwrap();
|
||||||
let display = Rc::new(RefCell::new(Display::new()));
|
let display = Rc::new(RefCell::new(Display::new()));
|
||||||
|
|
||||||
let (renderer, mut winit) = match winit::init(log.clone()) {
|
let (backend, mut winit) = match winit::init(log.clone()) {
|
||||||
Ok(ret) => ret,
|
Ok(ret) => ret,
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
slog::crit!(log, "Failed to initialize Winit backend: {}", err);
|
slog::crit!(log, "Failed to initialize Winit backend: {}", err);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
let renderer = Rc::new(RefCell::new(renderer));
|
let backend = Rc::new(RefCell::new(backend));
|
||||||
|
|
||||||
#[cfg(feature = "egl")]
|
#[cfg(feature = "egl")]
|
||||||
if renderer
|
if backend
|
||||||
.borrow_mut()
|
.borrow_mut()
|
||||||
.renderer()
|
.renderer()
|
||||||
.bind_wl_display(&display.borrow())
|
.bind_wl_display(&display.borrow())
|
||||||
.is_ok()
|
.is_ok()
|
||||||
{
|
{
|
||||||
info!(log, "EGL hardware-acceleration enabled");
|
info!(log, "EGL hardware-acceleration enabled");
|
||||||
let dmabuf_formats = renderer
|
let dmabuf_formats = backend
|
||||||
.borrow_mut()
|
.borrow_mut()
|
||||||
.renderer()
|
.renderer()
|
||||||
.dmabuf_formats()
|
.dmabuf_formats()
|
||||||
.cloned()
|
.cloned()
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
let renderer = renderer.clone();
|
let backend = backend.clone();
|
||||||
init_dmabuf_global(
|
init_dmabuf_global(
|
||||||
&mut *display.borrow_mut(),
|
&mut *display.borrow_mut(),
|
||||||
dmabuf_formats,
|
dmabuf_formats,
|
||||||
move |buffer, _| renderer.borrow_mut().renderer().import_dmabuf(buffer).is_ok(),
|
move |buffer, _| backend.borrow_mut().renderer().import_dmabuf(buffer).is_ok(),
|
||||||
log.clone(),
|
log.clone(),
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
let size = renderer.borrow().window_size().physical_size;
|
let size = backend.borrow().window_size().physical_size;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Initialize the globals
|
* Initialize the globals
|
||||||
|
@ -87,7 +88,7 @@ pub fn run_winit(log: Logger) {
|
||||||
let data = WinitData {
|
let data = WinitData {
|
||||||
#[cfg(feature = "debug")]
|
#[cfg(feature = "debug")]
|
||||||
fps_texture: import_bitmap(
|
fps_texture: import_bitmap(
|
||||||
renderer.borrow_mut().renderer(),
|
backend.borrow_mut().renderer(),
|
||||||
&image::io::Reader::with_format(std::io::Cursor::new(FPS_NUMBERS_PNG), image::ImageFormat::Png)
|
&image::io::Reader::with_format(std::io::Cursor::new(FPS_NUMBERS_PNG), image::ImageFormat::Png)
|
||||||
.decode()
|
.decode()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
|
@ -153,7 +154,7 @@ pub fn run_winit(log: Logger) {
|
||||||
|
|
||||||
// drawing logic
|
// drawing logic
|
||||||
{
|
{
|
||||||
let mut renderer = renderer.borrow_mut();
|
let mut backend = backend.borrow_mut();
|
||||||
// This is safe to do as with winit we are guaranteed to have exactly one output
|
// This is safe to do as with winit we are guaranteed to have exactly one output
|
||||||
let (output_geometry, output_scale) = state
|
let (output_geometry, output_scale) = state
|
||||||
.output_map
|
.output_map
|
||||||
|
@ -162,82 +163,88 @@ pub fn run_winit(log: Logger) {
|
||||||
.map(|output| (output.geometry(), output.scale()))
|
.map(|output| (output.geometry(), output.scale()))
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
let result = renderer
|
let result = backend
|
||||||
.render(|renderer, frame| {
|
.bind()
|
||||||
render_layers_and_windows(
|
.and_then(|_| {
|
||||||
renderer,
|
backend
|
||||||
frame,
|
.renderer()
|
||||||
&*state.window_map.borrow(),
|
.render(size, Transform::Flipped180, |renderer, frame| {
|
||||||
output_geometry,
|
render_layers_and_windows(
|
||||||
output_scale,
|
|
||||||
&log,
|
|
||||||
)?;
|
|
||||||
|
|
||||||
let (x, y) = state.pointer_location.into();
|
|
||||||
|
|
||||||
// draw the dnd icon if any
|
|
||||||
{
|
|
||||||
let guard = state.dnd_icon.lock().unwrap();
|
|
||||||
if let Some(ref surface) = *guard {
|
|
||||||
if surface.as_ref().is_alive() {
|
|
||||||
draw_dnd_icon(
|
|
||||||
renderer,
|
|
||||||
frame,
|
|
||||||
surface,
|
|
||||||
(x as i32, y as i32).into(),
|
|
||||||
output_scale,
|
|
||||||
&log,
|
|
||||||
)?;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// draw the cursor as relevant
|
|
||||||
{
|
|
||||||
let mut guard = state.cursor_status.lock().unwrap();
|
|
||||||
// reset the cursor if the surface is no longer alive
|
|
||||||
let mut reset = false;
|
|
||||||
if let CursorImageStatus::Image(ref surface) = *guard {
|
|
||||||
reset = !surface.as_ref().is_alive();
|
|
||||||
}
|
|
||||||
if reset {
|
|
||||||
*guard = CursorImageStatus::Default;
|
|
||||||
}
|
|
||||||
|
|
||||||
// draw as relevant
|
|
||||||
if let CursorImageStatus::Image(ref surface) = *guard {
|
|
||||||
cursor_visible = false;
|
|
||||||
draw_cursor(
|
|
||||||
renderer,
|
renderer,
|
||||||
frame,
|
frame,
|
||||||
surface,
|
&*state.window_map.borrow(),
|
||||||
(x as i32, y as i32).into(),
|
output_geometry,
|
||||||
output_scale,
|
output_scale,
|
||||||
&log,
|
&log,
|
||||||
)?;
|
)?;
|
||||||
} else {
|
|
||||||
cursor_visible = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(feature = "debug")]
|
let (x, y) = state.pointer_location.into();
|
||||||
{
|
|
||||||
let fps = state.backend_data.fps.avg().round() as u32;
|
|
||||||
|
|
||||||
draw_fps(
|
// draw the dnd icon if any
|
||||||
renderer,
|
{
|
||||||
frame,
|
let guard = state.dnd_icon.lock().unwrap();
|
||||||
&state.backend_data.fps_texture,
|
if let Some(ref surface) = *guard {
|
||||||
output_scale as f64,
|
if surface.as_ref().is_alive() {
|
||||||
fps,
|
draw_dnd_icon(
|
||||||
)?;
|
renderer,
|
||||||
}
|
frame,
|
||||||
|
surface,
|
||||||
|
(x as i32, y as i32).into(),
|
||||||
|
output_scale,
|
||||||
|
&log,
|
||||||
|
)?;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// draw the cursor as relevant
|
||||||
|
{
|
||||||
|
let mut guard = state.cursor_status.lock().unwrap();
|
||||||
|
// reset the cursor if the surface is no longer alive
|
||||||
|
let mut reset = false;
|
||||||
|
if let CursorImageStatus::Image(ref surface) = *guard {
|
||||||
|
reset = !surface.as_ref().is_alive();
|
||||||
|
}
|
||||||
|
if reset {
|
||||||
|
*guard = CursorImageStatus::Default;
|
||||||
|
}
|
||||||
|
|
||||||
Ok(())
|
// draw as relevant
|
||||||
|
if let CursorImageStatus::Image(ref surface) = *guard {
|
||||||
|
cursor_visible = false;
|
||||||
|
draw_cursor(
|
||||||
|
renderer,
|
||||||
|
frame,
|
||||||
|
surface,
|
||||||
|
(x as i32, y as i32).into(),
|
||||||
|
output_scale,
|
||||||
|
&log,
|
||||||
|
)?;
|
||||||
|
} else {
|
||||||
|
cursor_visible = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "debug")]
|
||||||
|
{
|
||||||
|
let fps = state.backend_data.fps.avg().round() as u32;
|
||||||
|
|
||||||
|
draw_fps(
|
||||||
|
renderer,
|
||||||
|
frame,
|
||||||
|
&state.backend_data.fps_texture,
|
||||||
|
output_scale as f64,
|
||||||
|
fps,
|
||||||
|
)?;
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
})
|
||||||
|
.map_err(Into::<SwapBuffersError>::into)
|
||||||
|
.and_then(|x| x)
|
||||||
})
|
})
|
||||||
.map_err(Into::<SwapBuffersError>::into)
|
.and_then(|_| backend.submit(None, 1.0));
|
||||||
.and_then(|x| x);
|
|
||||||
|
|
||||||
renderer.window().set_cursor_visible(cursor_visible);
|
backend.window().set_cursor_visible(cursor_visible);
|
||||||
|
|
||||||
if let Err(SwapBuffersError::ContextLost(err)) = result {
|
if let Err(SwapBuffersError::ContextLost(err)) = result {
|
||||||
error!(log, "Critical Rendering Error: {}", err);
|
error!(log, "Critical Rendering Error: {}", err);
|
||||||
|
|
Loading…
Reference in New Issue