render: hide graphics API behind traits
This commit is contained in:
parent
d650b3375d
commit
24e410a5b5
40 changed files with 601 additions and 246 deletions
|
|
@ -277,7 +277,7 @@ impl JayCompositor {
|
|||
.render_ctx_watchers
|
||||
.set((self.client.id, req.id), ctx.clone());
|
||||
let rctx = self.client.state.render_ctx.get();
|
||||
ctx.send_render_ctx(rctx.as_ref());
|
||||
ctx.send_render_ctx(rctx);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
use {
|
||||
crate::{
|
||||
client::{Client, ClientError},
|
||||
gfx_apis::gl::RenderContext,
|
||||
gfx_api::GfxContext,
|
||||
leaks::Tracker,
|
||||
object::Object,
|
||||
utils::{
|
||||
|
|
@ -21,10 +21,10 @@ pub struct JayRenderCtx {
|
|||
}
|
||||
|
||||
impl JayRenderCtx {
|
||||
pub fn send_render_ctx(&self, ctx: Option<&Rc<RenderContext>>) {
|
||||
pub fn send_render_ctx(&self, ctx: Option<Rc<dyn GfxContext>>) {
|
||||
let mut fd = None;
|
||||
if let Some(ctx) = ctx {
|
||||
match ctx.gbm.drm.dup_render() {
|
||||
match ctx.gbm().drm.dup_render() {
|
||||
Ok(d) => fd = Some(d.fd().clone()),
|
||||
Err(e) => {
|
||||
log::error!("Could not dup drm fd: {}", ErrorFmt(e));
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ use {
|
|||
crate::{
|
||||
client::{Client, ClientError},
|
||||
format::XRGB8888,
|
||||
gfx_apis::gl::{Framebuffer, RenderContext, RenderError, Texture},
|
||||
gfx_api::{GfxContext, GfxError, GfxFramebuffer, GfxTexture},
|
||||
ifs::jay_output::JayOutput,
|
||||
leaks::Tracker,
|
||||
object::Object,
|
||||
|
|
@ -60,7 +60,7 @@ struct Pending {
|
|||
|
||||
struct ScreencastBuffer {
|
||||
dmabuf: DmaBuf,
|
||||
fb: Rc<Framebuffer>,
|
||||
fb: Rc<dyn GfxFramebuffer>,
|
||||
free: bool,
|
||||
}
|
||||
|
||||
|
|
@ -147,7 +147,7 @@ impl JayScreencast {
|
|||
});
|
||||
}
|
||||
|
||||
pub fn copy_texture(&self, on: &OutputNode, texture: &Rc<Texture>) {
|
||||
pub fn copy_texture(&self, on: &OutputNode, texture: &Rc<dyn GfxTexture>) {
|
||||
if !self.running.get() {
|
||||
return;
|
||||
}
|
||||
|
|
@ -193,7 +193,7 @@ impl JayScreencast {
|
|||
self.client.event(Destroyed { self_id: self.id });
|
||||
}
|
||||
|
||||
pub fn realloc(&self, ctx: &Rc<RenderContext>) -> Result<(), JayScreencastError> {
|
||||
pub fn realloc(&self, ctx: &Rc<dyn GfxContext>) -> Result<(), JayScreencastError> {
|
||||
let mut buffers = vec![];
|
||||
if let Some(output) = self.output.get() {
|
||||
let mode = output.global.mode.get();
|
||||
|
|
@ -207,8 +207,10 @@ impl JayScreencast {
|
|||
if self.linear.get() {
|
||||
flags |= GBM_BO_USE_LINEAR;
|
||||
}
|
||||
let buffer = ctx.gbm.create_bo(mode.width, mode.height, &format, flags)?;
|
||||
let fb = ctx.dmabuf_img(buffer.dmabuf())?.to_framebuffer()?;
|
||||
let buffer = ctx
|
||||
.gbm()
|
||||
.create_bo(mode.width, mode.height, &format, flags)?;
|
||||
let fb = ctx.clone().dmabuf_img(buffer.dmabuf())?.to_framebuffer()?;
|
||||
buffers.push(ScreencastBuffer {
|
||||
dmabuf: buffer.dmabuf().clone(),
|
||||
fb,
|
||||
|
|
@ -444,7 +446,7 @@ pub enum JayScreencastError {
|
|||
#[error(transparent)]
|
||||
GbmError(#[from] GbmError),
|
||||
#[error(transparent)]
|
||||
RenderError(#[from] RenderError),
|
||||
GfxError(#[from] GfxError),
|
||||
}
|
||||
efrom!(JayScreencastError, MsgParserError);
|
||||
efrom!(JayScreencastError, ClientError);
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ use {
|
|||
client::{Client, ClientError},
|
||||
clientmem::{ClientMem, ClientMemError, ClientMemOffset},
|
||||
format::Format,
|
||||
gfx_apis::gl::{Framebuffer, Image, RenderError, Texture},
|
||||
gfx_api::{GfxError, GfxFramebuffer, GfxImage, GfxTexture},
|
||||
leaks::Tracker,
|
||||
object::Object,
|
||||
rect::Rect,
|
||||
|
|
@ -25,7 +25,7 @@ use {
|
|||
|
||||
pub enum WlBufferStorage {
|
||||
Shm { mem: ClientMemOffset, stride: i32 },
|
||||
Dmabuf(Rc<Image>),
|
||||
Dmabuf(Rc<dyn GfxImage>),
|
||||
}
|
||||
|
||||
pub struct WlBuffer {
|
||||
|
|
@ -37,8 +37,8 @@ pub struct WlBuffer {
|
|||
dmabuf: Option<DmaBuf>,
|
||||
render_ctx_version: Cell<u32>,
|
||||
pub storage: RefCell<Option<WlBufferStorage>>,
|
||||
pub texture: CloneCell<Option<Rc<Texture>>>,
|
||||
pub famebuffer: CloneCell<Option<Rc<Framebuffer>>>,
|
||||
pub texture: CloneCell<Option<Rc<dyn GfxTexture>>>,
|
||||
pub famebuffer: CloneCell<Option<Rc<dyn GfxFramebuffer>>>,
|
||||
width: i32,
|
||||
height: i32,
|
||||
pub tracker: Tracker<Self>,
|
||||
|
|
@ -55,7 +55,7 @@ impl WlBuffer {
|
|||
client: &Rc<Client>,
|
||||
format: &'static Format,
|
||||
dmabuf: DmaBuf,
|
||||
img: &Rc<Image>,
|
||||
img: &Rc<dyn GfxImage>,
|
||||
) -> Self {
|
||||
let width = img.width();
|
||||
let height = img.height();
|
||||
|
|
@ -165,7 +165,7 @@ impl WlBuffer {
|
|||
}
|
||||
WlBufferStorage::Dmabuf(img) => {
|
||||
if self.texture.get().is_none() {
|
||||
self.texture.set(Some(img.to_texture()?));
|
||||
self.texture.set(Some(img.clone().to_texture()?));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -184,7 +184,7 @@ impl WlBuffer {
|
|||
}
|
||||
WlBufferStorage::Dmabuf(img) => {
|
||||
if self.famebuffer.get().is_none() {
|
||||
self.famebuffer.set(Some(img.to_framebuffer()?));
|
||||
self.famebuffer.set(Some(img.clone().to_framebuffer()?));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -225,14 +225,13 @@ pub enum WlBufferError {
|
|||
StrideTooSmall,
|
||||
#[error("Could not access the client memory")]
|
||||
ClientMemError(#[source] Box<ClientMemError>),
|
||||
#[error("GLES could not import the client image")]
|
||||
RenderError(#[source] Box<RenderError>),
|
||||
#[error("The graphics library could not import the client image")]
|
||||
GfxError(#[from] GfxError),
|
||||
#[error("Parsing failed")]
|
||||
MsgParserError(#[source] Box<MsgParserError>),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
}
|
||||
efrom!(WlBufferError, ClientMemError);
|
||||
efrom!(WlBufferError, RenderError);
|
||||
efrom!(WlBufferError, MsgParserError);
|
||||
efrom!(WlBufferError, ClientError);
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
use {
|
||||
crate::{
|
||||
client::{Client, ClientError},
|
||||
gfx_apis::gl::RenderError,
|
||||
gfx_api::GfxError,
|
||||
globals::{Global, GlobalName},
|
||||
ifs::wl_buffer::WlBuffer,
|
||||
leaks::Tracker,
|
||||
|
|
@ -190,7 +190,7 @@ pub enum WlDrmError {
|
|||
#[error("The format {0} is not supported")]
|
||||
InvalidFormat(u32),
|
||||
#[error("Could not import the buffer")]
|
||||
ImportError(#[from] RenderError),
|
||||
ImportError(#[from] GfxError),
|
||||
}
|
||||
efrom!(WlDrmError, ClientError);
|
||||
efrom!(WlDrmError, MsgParserError);
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ use {
|
|||
backend,
|
||||
client::{Client, ClientError, ClientId},
|
||||
format::XRGB8888,
|
||||
gfx_apis::gl::{Framebuffer, Texture},
|
||||
gfx_api::{GfxFramebuffer, GfxTexture},
|
||||
globals::{Global, GlobalName},
|
||||
ifs::{
|
||||
wl_buffer::WlBufferStorage, wl_surface::WlSurface,
|
||||
|
|
@ -199,7 +199,7 @@ impl WlOutputGlobal {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
pub fn perform_screencopies(&self, fb: &Framebuffer, tex: &Rc<Texture>) {
|
||||
pub fn perform_screencopies(&self, fb: &dyn GfxFramebuffer, tex: &Rc<dyn GfxTexture>) {
|
||||
if self.pending_captures.is_empty() {
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
use {
|
||||
crate::{
|
||||
client::ClientError,
|
||||
gfx_apis::gl::RenderError,
|
||||
gfx_api::GfxError,
|
||||
ifs::{wl_buffer::WlBuffer, zwp_linux_dmabuf_v1::ZwpLinuxDmabufV1},
|
||||
leaks::Tracker,
|
||||
object::Object,
|
||||
|
|
@ -228,7 +228,7 @@ pub enum ZwpLinuxBufferParamsV1Error {
|
|||
#[error("Plane {0} was not set")]
|
||||
MissingPlane(usize),
|
||||
#[error("Could not import the buffer")]
|
||||
ImportError(#[from] RenderError),
|
||||
ImportError(#[from] GfxError),
|
||||
}
|
||||
efrom!(ZwpLinuxBufferParamsV1Error, ClientError);
|
||||
efrom!(ZwpLinuxBufferParamsV1Error, MsgParserError);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue