1
0
Fork 0
forked from wry/wry

autocommit 2022-01-28 19:46:23 CET

This commit is contained in:
Julian Orth 2022-01-28 19:46:23 +01:00
parent a5573b8a3a
commit b11a36729c
45 changed files with 1646 additions and 2171 deletions

View file

@ -3,11 +3,10 @@ mod types;
use crate::client::{Client, DynEventFormatter};
use crate::clientmem::{ClientMem, ClientMemOffset};
use crate::format::Format;
use crate::gles2::gl::GlTexture;
use crate::ifs::wl_surface::{WlSurface, WlSurfaceId};
use crate::object::{Interface, Object, ObjectId};
use crate::pixman;
use crate::rect::Rect;
use crate::render::Texture;
use crate::utils::buffd::MsgParser;
use crate::utils::clonecell::CloneCell;
use crate::utils::copyhashmap::CopyHashMap;
@ -27,9 +26,8 @@ pub struct WlBuffer {
pub rect: Rect,
stride: i32,
format: &'static Format,
pub image: Rc<pixman::Image<ClientMemOffset>>,
mem: ClientMemOffset,
pub texture: CloneCell<Option<Rc<GlTexture>>>,
pub texture: CloneCell<Option<Rc<Texture>>>,
pub(super) surfaces: CopyHashMap<WlSurfaceId, Rc<WlSurface>>,
width: i32,
height: i32,
@ -57,13 +55,6 @@ impl WlBuffer {
if (stride as u64) < min_row_size {
return Err(WlBufferError::StrideTooSmall);
}
let image = pixman::Image::new(
mem.clone(),
format.pixman.unwrap(),
width as u32,
height as u32,
stride as u32,
)?;
Ok(Self {
id,
client: client.clone(),
@ -71,7 +62,6 @@ impl WlBuffer {
rect: Rect::new_sized(0, 0, width, height).unwrap(),
stride,
format,
image: Rc::new(image),
mem,
width,
height,
@ -82,9 +72,9 @@ impl WlBuffer {
pub fn update_texture(&self) -> Result<(), WlBufferError> {
self.texture.set(None);
let ctx = self.client.state.egl.get().unwrap();
let ctx = self.client.state.render_ctx.get().unwrap();
let tex = self.mem.access(|mem| {
GlTexture::import_texture(&ctx, mem, self.format, self.width, self.height, self.stride)
ctx.shmem_texture(mem, self.format, self.width, self.height, self.stride)
})??;
self.texture.set(Some(tex));
Ok(())

View file

@ -1,8 +1,7 @@
use crate::client::{ClientError, EventFormatter, RequestParser};
use crate::gles2::GlesError;
use crate::ifs::wl_buffer::{WlBuffer, RELEASE};
use crate::object::Object;
use crate::pixman::PixmanError;
use crate::render::RenderError;
use crate::utils::buffd::{MsgFormatter, MsgParser, MsgParserError};
use crate::ClientMemError;
use std::fmt::{Debug, Formatter};
@ -17,16 +16,13 @@ pub enum WlBufferError {
StrideTooSmall,
#[error("Could not handle a `destroy` request")]
DestroyError(#[from] DestroyError),
#[error("Pixman returned an error")]
PixmanError(#[source] Box<PixmanError>),
#[error("Could not access the client memory")]
ClientMemError(#[source] Box<ClientMemError>),
#[error("GLES could not import the client image")]
GlesError(#[source] Box<GlesError>),
GlesError(#[source] Box<RenderError>),
}
efrom!(WlBufferError, PixmanError, PixmanError);
efrom!(WlBufferError, ClientMemError, ClientMemError);
efrom!(WlBufferError, GlesError, GlesError);
efrom!(WlBufferError, GlesError, RenderError);
#[derive(Debug, Error)]
pub enum DestroyError {

View file

@ -5,7 +5,6 @@ pub mod xdg_surface;
use crate::backend::{KeyState, ScrollAxis};
use crate::client::{Client, RequestParser};
use crate::fixed::Fixed;
use crate::gles2::gl::GlTexture;
use crate::ifs::wl_buffer::WlBuffer;
use crate::ifs::wl_callback::WlCallback;
use crate::ifs::wl_seat::WlSeatGlobal;

View file

@ -367,7 +367,7 @@ impl Node for XdgToplevel {
}
}
fn render(&self, renderer: &mut dyn Renderer, x: i32, y: i32) {
fn render(&self, renderer: &mut Renderer, x: i32, y: i32) {
renderer.render_toplevel(self, x, y)
}