anvil: Use buffer transformations
This commit is contained in:
parent
439d5a7820
commit
4b22624e74
|
@ -7,9 +7,11 @@ use image::{ImageBuffer, Rgba};
|
||||||
use slog::Logger;
|
use slog::Logger;
|
||||||
#[cfg(feature = "image")]
|
#[cfg(feature = "image")]
|
||||||
use smithay::backend::renderer::gles2::{Gles2Error, Gles2Renderer, Gles2Texture};
|
use smithay::backend::renderer::gles2::{Gles2Error, Gles2Renderer, Gles2Texture};
|
||||||
|
#[cfg(feature = "debug")]
|
||||||
|
use smithay::utils::Transform;
|
||||||
use smithay::{
|
use smithay::{
|
||||||
backend::{
|
backend::{
|
||||||
renderer::{buffer_type, BufferType, Frame, ImportAll, Renderer, Texture, Transform},
|
renderer::{buffer_type, BufferType, Frame, ImportAll, Renderer, Texture},
|
||||||
SwapBuffersError,
|
SwapBuffersError,
|
||||||
},
|
},
|
||||||
reexports::wayland_server::protocol::{wl_buffer, wl_surface},
|
reexports::wayland_server::protocol::{wl_buffer, wl_surface},
|
||||||
|
@ -111,7 +113,11 @@ where
|
||||||
.map(|dmg| match dmg {
|
.map(|dmg| match dmg {
|
||||||
Damage::Buffer(rect) => *rect,
|
Damage::Buffer(rect) => *rect,
|
||||||
// TODO also apply transformations
|
// TODO also apply transformations
|
||||||
Damage::Surface(rect) => rect.to_buffer(attributes.buffer_scale),
|
Damage::Surface(rect) => rect.to_buffer(
|
||||||
|
attributes.buffer_scale,
|
||||||
|
attributes.buffer_transform.into(),
|
||||||
|
&data.size().unwrap(),
|
||||||
|
),
|
||||||
})
|
})
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
|
|
||||||
|
@ -161,6 +167,7 @@ where
|
||||||
if let Some(data) = states.data_map.get::<RefCell<SurfaceData>>() {
|
if let Some(data) = states.data_map.get::<RefCell<SurfaceData>>() {
|
||||||
let mut data = data.borrow_mut();
|
let mut data = data.borrow_mut();
|
||||||
let buffer_scale = data.buffer_scale;
|
let buffer_scale = data.buffer_scale;
|
||||||
|
let buffer_transform = data.buffer_transform;
|
||||||
if let Some(texture) = data
|
if let Some(texture) = data
|
||||||
.texture
|
.texture
|
||||||
.as_mut()
|
.as_mut()
|
||||||
|
@ -177,7 +184,7 @@ where
|
||||||
location.to_f64().to_physical(output_scale as f64).to_i32_round(),
|
location.to_f64().to_physical(output_scale as f64).to_i32_round(),
|
||||||
buffer_scale,
|
buffer_scale,
|
||||||
output_scale as f64,
|
output_scale as f64,
|
||||||
Transform::Normal, /* TODO */
|
buffer_transform,
|
||||||
&[Rectangle::from_loc_and_size((0, 0), (i32::MAX, i32::MAX))],
|
&[Rectangle::from_loc_and_size((0, 0), (i32::MAX, i32::MAX))],
|
||||||
1.0,
|
1.0,
|
||||||
) {
|
) {
|
||||||
|
|
|
@ -13,7 +13,7 @@ use smithay::{
|
||||||
Display,
|
Display,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
utils::{Logical, Physical, Point, Rectangle, Size},
|
utils::{Buffer, Logical, Point, Rectangle, Size, Transform},
|
||||||
wayland::{
|
wayland::{
|
||||||
compositor::{
|
compositor::{
|
||||||
compositor_init, is_sync_subsurface, with_states, with_surface_tree_upward, BufferAssignment,
|
compositor_init, is_sync_subsurface, with_states, with_surface_tree_upward, BufferAssignment,
|
||||||
|
@ -947,8 +947,9 @@ pub struct SurfaceData {
|
||||||
pub texture: Option<Box<dyn std::any::Any + 'static>>,
|
pub texture: Option<Box<dyn std::any::Any + 'static>>,
|
||||||
pub geometry: Option<Rectangle<i32, Logical>>,
|
pub geometry: Option<Rectangle<i32, Logical>>,
|
||||||
pub resize_state: ResizeState,
|
pub resize_state: ResizeState,
|
||||||
pub buffer_dimensions: Option<Size<i32, Physical>>,
|
pub buffer_dimensions: Option<Size<i32, Buffer>>,
|
||||||
pub buffer_scale: i32,
|
pub buffer_scale: i32,
|
||||||
|
pub buffer_transform: Transform,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl SurfaceData {
|
impl SurfaceData {
|
||||||
|
@ -958,6 +959,7 @@ impl SurfaceData {
|
||||||
// new contents
|
// new contents
|
||||||
self.buffer_dimensions = buffer_dimensions(&buffer);
|
self.buffer_dimensions = buffer_dimensions(&buffer);
|
||||||
self.buffer_scale = attrs.buffer_scale;
|
self.buffer_scale = attrs.buffer_scale;
|
||||||
|
self.buffer_transform = attrs.buffer_transform.into();
|
||||||
if let Some(old_buffer) = std::mem::replace(&mut self.buffer, Some(buffer)) {
|
if let Some(old_buffer) = std::mem::replace(&mut self.buffer, Some(buffer)) {
|
||||||
old_buffer.release();
|
old_buffer.release();
|
||||||
}
|
}
|
||||||
|
@ -976,7 +978,7 @@ impl SurfaceData {
|
||||||
/// Returns the size of the surface.
|
/// Returns the size of the surface.
|
||||||
pub fn size(&self) -> Option<Size<i32, Logical>> {
|
pub fn size(&self) -> Option<Size<i32, Logical>> {
|
||||||
self.buffer_dimensions
|
self.buffer_dimensions
|
||||||
.map(|dims| dims.to_logical(self.buffer_scale))
|
.map(|dims| dims.to_logical(self.buffer_scale, self.buffer_transform))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Checks if the surface's input region contains the point.
|
/// Checks if the surface's input region contains the point.
|
||||||
|
|
|
@ -20,7 +20,7 @@ use smithay::{
|
||||||
libinput::{LibinputInputBackend, LibinputSessionInterface},
|
libinput::{LibinputInputBackend, LibinputSessionInterface},
|
||||||
renderer::{
|
renderer::{
|
||||||
gles2::{Gles2Renderer, Gles2Texture},
|
gles2::{Gles2Renderer, Gles2Texture},
|
||||||
Bind, Frame, Renderer, Transform,
|
Bind, Frame, Renderer,
|
||||||
},
|
},
|
||||||
session::{auto::AutoSession, Session, Signal as SessionSignal},
|
session::{auto::AutoSession, Session, Signal as SessionSignal},
|
||||||
udev::{UdevBackend, UdevEvent},
|
udev::{UdevBackend, UdevEvent},
|
||||||
|
@ -50,7 +50,7 @@ use smithay::{
|
||||||
},
|
},
|
||||||
utils::{
|
utils::{
|
||||||
signaling::{Linkable, SignalToken, Signaler},
|
signaling::{Linkable, SignalToken, Signaler},
|
||||||
Logical, Point, Rectangle,
|
Logical, Point, Rectangle, Transform,
|
||||||
},
|
},
|
||||||
wayland::{
|
wayland::{
|
||||||
output::{Mode, PhysicalProperties},
|
output::{Mode, PhysicalProperties},
|
||||||
|
|
|
@ -9,7 +9,7 @@ use smithay::{
|
||||||
};
|
};
|
||||||
use smithay::{
|
use smithay::{
|
||||||
backend::{
|
backend::{
|
||||||
renderer::{Renderer, Transform},
|
renderer::Renderer,
|
||||||
winit::{self, WinitEvent},
|
winit::{self, WinitEvent},
|
||||||
SwapBuffersError,
|
SwapBuffersError,
|
||||||
},
|
},
|
||||||
|
@ -17,6 +17,7 @@ use smithay::{
|
||||||
calloop::EventLoop,
|
calloop::EventLoop,
|
||||||
wayland_server::{protocol::wl_output, Display},
|
wayland_server::{protocol::wl_output, Display},
|
||||||
},
|
},
|
||||||
|
utils::Transform,
|
||||||
wayland::{
|
wayland::{
|
||||||
output::{Mode, PhysicalProperties},
|
output::{Mode, PhysicalProperties},
|
||||||
seat::CursorImageStatus,
|
seat::CursorImageStatus,
|
||||||
|
|
|
@ -11,7 +11,7 @@ use smithay::{backend::renderer::ImportDma, wayland::dmabuf::init_dmabuf_global}
|
||||||
use smithay::{
|
use smithay::{
|
||||||
backend::{
|
backend::{
|
||||||
egl::{EGLContext, EGLDisplay},
|
egl::{EGLContext, EGLDisplay},
|
||||||
renderer::{gles2::Gles2Renderer, Bind, ImportEgl, Renderer, Transform, Unbind},
|
renderer::{gles2::Gles2Renderer, Bind, ImportEgl, Renderer, Unbind},
|
||||||
x11::{WindowBuilder, X11Backend, X11Event, X11Surface},
|
x11::{WindowBuilder, X11Backend, X11Event, X11Surface},
|
||||||
SwapBuffersError,
|
SwapBuffersError,
|
||||||
},
|
},
|
||||||
|
@ -20,6 +20,7 @@ use smithay::{
|
||||||
gbm,
|
gbm,
|
||||||
wayland_server::{protocol::wl_output, Display},
|
wayland_server::{protocol::wl_output, Display},
|
||||||
},
|
},
|
||||||
|
utils::Transform,
|
||||||
wayland::{
|
wayland::{
|
||||||
output::{Mode, PhysicalProperties},
|
output::{Mode, PhysicalProperties},
|
||||||
seat::CursorImageStatus,
|
seat::CursorImageStatus,
|
||||||
|
|
Loading…
Reference in New Issue