render: split module into gfx_apis and renderer
This commit is contained in:
parent
5e8a6eb86f
commit
d650b3375d
68 changed files with 219 additions and 222 deletions
|
|
@ -2,8 +2,8 @@ use {
|
|||
crate::{
|
||||
async_engine::SpawnedFuture,
|
||||
fixed::Fixed,
|
||||
gfx_apis::gl::Framebuffer,
|
||||
ifs::wl_seat::wl_pointer::{CONTINUOUS, FINGER, HORIZONTAL_SCROLL, VERTICAL_SCROLL, WHEEL},
|
||||
render::Framebuffer,
|
||||
video::drm::{ConnectorType, DrmError, DrmVersion},
|
||||
},
|
||||
std::{
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ use {
|
|||
},
|
||||
backends::metal::video::{MetalDrmDeviceData, MetalRenderContext, PendingDrmDevice},
|
||||
dbus::{DbusError, SignalHandler},
|
||||
gfx_apis::gl::RenderError,
|
||||
libinput::{
|
||||
consts::{
|
||||
AccelProfile, LIBINPUT_CONFIG_ACCEL_PROFILE_ADAPTIVE,
|
||||
|
|
@ -23,7 +24,6 @@ use {
|
|||
LibInput, LibInputAdapter, LibInputError,
|
||||
},
|
||||
logind::{LogindError, Session},
|
||||
render::RenderError,
|
||||
state::State,
|
||||
time::now_usec,
|
||||
udev::{Udev, UdevError, UdevMonitor},
|
||||
|
|
|
|||
|
|
@ -8,8 +8,9 @@ use {
|
|||
backends::metal::{MetalBackend, MetalError},
|
||||
edid::Descriptor,
|
||||
format::{Format, ARGB8888, XRGB8888},
|
||||
gfx_apis::gl::{Framebuffer, RenderContext, Texture},
|
||||
ifs::wp_presentation_feedback::{KIND_HW_COMPLETION, KIND_VSYNC},
|
||||
render::{Framebuffer, RenderContext, RenderResult, Texture},
|
||||
renderer::RenderResult,
|
||||
state::State,
|
||||
udev::UdevDevice,
|
||||
utils::{
|
||||
|
|
|
|||
|
|
@ -9,7 +9,8 @@ use {
|
|||
},
|
||||
fixed::Fixed,
|
||||
format::XRGB8888,
|
||||
render::{Framebuffer, RenderContext, RenderError, RenderResult, Texture},
|
||||
gfx_apis::gl::{Framebuffer, RenderContext, RenderError, Texture},
|
||||
renderer::RenderResult,
|
||||
state::State,
|
||||
time::now_usec,
|
||||
utils::{
|
||||
|
|
|
|||
|
|
@ -15,12 +15,12 @@ use {
|
|||
config::ConfigProxy,
|
||||
dbus::Dbus,
|
||||
forker,
|
||||
gfx_apis::gl::{self, RenderError},
|
||||
globals::Globals,
|
||||
ifs::{wl_output::WlOutputGlobal, wl_surface::NoneSurfaceExt},
|
||||
io_uring::{IoUring, IoUringError},
|
||||
leaks,
|
||||
logger::Logger,
|
||||
render::{self, RenderError},
|
||||
scale::Scale,
|
||||
sighand::{self, SighandError},
|
||||
state::{ConnectorData, IdleState, ScreenlockState, State, XWaylandState},
|
||||
|
|
@ -112,7 +112,7 @@ fn start_compositor2(
|
|||
log::info!("pid = {}", uapi::getpid());
|
||||
init_fd_limit();
|
||||
leaks::init();
|
||||
render::init()?;
|
||||
gl::init()?;
|
||||
clientmem::init()?;
|
||||
let xkb_ctx = XkbContext::new().unwrap();
|
||||
let xkb_keymap = xkb_ctx.keymap_from_str(include_str!("keymap.xkb")).unwrap();
|
||||
|
|
|
|||
|
|
@ -2,8 +2,9 @@ use {
|
|||
crate::{
|
||||
fixed::Fixed,
|
||||
format::ARGB8888,
|
||||
gfx_apis::gl::{RenderContext, RenderError, Texture},
|
||||
rect::Rect,
|
||||
render::{RenderContext, RenderError, Renderer, Texture},
|
||||
renderer::Renderer,
|
||||
scale::Scale,
|
||||
state::State,
|
||||
time::Time,
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
use {
|
||||
crate::{
|
||||
gfx_apis::gl::sys::{GLint, GL_BGRA_EXT, GL_RGBA, GL_UNSIGNED_BYTE},
|
||||
pipewire::pw_pod::{
|
||||
SPA_VIDEO_FORMAT_BGRx, SPA_VIDEO_FORMAT_RGBx, SpaVideoFormat, SPA_VIDEO_FORMAT_BGRA,
|
||||
SPA_VIDEO_FORMAT_NV12, SPA_VIDEO_FORMAT_RGBA,
|
||||
},
|
||||
render::sys::{GLint, GL_BGRA_EXT, GL_RGBA, GL_UNSIGNED_BYTE},
|
||||
utils::debug_fn::debug_fn,
|
||||
},
|
||||
ahash::AHashMap,
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
use {
|
||||
crate::{format::Format, render::Texture, theme::Color},
|
||||
crate::{format::Format, gfx_apis::gl::Texture, theme::Color},
|
||||
std::rc::Rc,
|
||||
};
|
||||
|
||||
1
src/gfx_apis.rs
Normal file
1
src/gfx_apis.rs
Normal file
|
|
@ -0,0 +1 @@
|
|||
pub mod gl;
|
||||
|
|
@ -1,8 +1,29 @@
|
|||
macro_rules! egl_transparent {
|
||||
($name:ident) => {
|
||||
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
|
||||
#[repr(transparent)]
|
||||
pub struct $name(pub *mut u8);
|
||||
|
||||
impl $name {
|
||||
#[allow(dead_code)]
|
||||
pub const fn none() -> Self {
|
||||
Self(std::ptr::null_mut())
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub fn is_none(self) -> bool {
|
||||
self.0.is_null()
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
pub use renderer::*;
|
||||
use {
|
||||
crate::{
|
||||
format::Format,
|
||||
render::{
|
||||
gfx_api::{BufferPoints, CopyTexture, FillRect, GfxApiOpt},
|
||||
gfx_api::{BufferPoints, CopyTexture, FillRect, GfxApiOpt},
|
||||
gfx_apis::gl::{
|
||||
gl::texture::image_target,
|
||||
sys::{
|
||||
glActiveTexture, glBindTexture, glClear, glClearColor, glDisable,
|
||||
|
|
@ -11,15 +32,90 @@ use {
|
|||
GL_BLEND, GL_COLOR_BUFFER_BIT, GL_FALSE, GL_FLOAT, GL_LINEAR, GL_TEXTURE0,
|
||||
GL_TEXTURE_MIN_FILTER, GL_TRIANGLES, GL_TRIANGLE_STRIP,
|
||||
},
|
||||
Framebuffer, RenderContext, Texture,
|
||||
},
|
||||
theme::Color,
|
||||
utils::{rc_eq::rc_eq, vecstorage::VecStorage},
|
||||
video::{drm::DrmError, gbm::GbmError},
|
||||
},
|
||||
isnt::std_1::vec::IsntVecExt,
|
||||
std::cell::RefCell,
|
||||
thiserror::Error,
|
||||
};
|
||||
|
||||
mod egl;
|
||||
mod ext;
|
||||
mod gl;
|
||||
mod proc;
|
||||
mod renderer;
|
||||
|
||||
pub mod sys {
|
||||
pub use super::{egl::sys::*, gl::sys::*};
|
||||
}
|
||||
|
||||
pub fn init() -> Result<(), RenderError> {
|
||||
egl::init()
|
||||
}
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum RenderError {
|
||||
#[error("EGL library does not support `EGL_EXT_platform_base`")]
|
||||
ExtPlatformBase,
|
||||
#[error("Could not compile a shader")]
|
||||
ShaderCompileFailed,
|
||||
#[error("Could not link a program")]
|
||||
ProgramLink,
|
||||
#[error("Could not bind to `EGL_OPENGL_ES_API`")]
|
||||
BindFailed,
|
||||
#[error("EGL library does not support the GBM platform")]
|
||||
GbmExt,
|
||||
#[error("Could not create a GBM device")]
|
||||
Gbm(#[source] GbmError),
|
||||
#[error("`eglCreateContext` failed")]
|
||||
CreateContext,
|
||||
#[error("`eglMakeCurrent` failed")]
|
||||
MakeCurrent,
|
||||
#[error("`eglCreateImageKHR` failed")]
|
||||
CreateImage,
|
||||
#[error("Image buffer is too small")]
|
||||
SmallImageBuffer,
|
||||
#[error("Binding a renderbuffer to a framebuffer failed")]
|
||||
CreateFramebuffer,
|
||||
#[error("`eglGetPlatformDisplayEXT` failed")]
|
||||
GetDisplay,
|
||||
#[error("`eglInitialize` failed")]
|
||||
Initialize,
|
||||
#[error("EGL display does not support `EGL_EXT_image_dma_buf_import_modifiers`")]
|
||||
DmaBufImport,
|
||||
#[error("GLES driver does not support `GL_OES_EGL_image`")]
|
||||
OesEglImage,
|
||||
#[error("EGL display does not support `EGL_KHR_image_base`")]
|
||||
ImageBase,
|
||||
#[error(
|
||||
"EGL display does not support `EGL_KHR_no_config_context` or `EGL_MESA_configless_context`"
|
||||
)]
|
||||
ConfiglessContext,
|
||||
#[error("EGL display does not support `EGL_KHR_surfaceless_context`")]
|
||||
SurfacelessContext,
|
||||
#[error("`eglQueryDmaBufFormatsEXT` failed")]
|
||||
QueryDmaBufFormats,
|
||||
#[error("`eglQueryDmaBufModifiersEXT` failed")]
|
||||
QueryDmaBufModifiers,
|
||||
#[error(transparent)]
|
||||
DrmError(#[from] DrmError),
|
||||
#[error("The GLES driver does not support the XRGB8888 format")]
|
||||
XRGB888,
|
||||
#[error("The DRM device does not have a render node")]
|
||||
NoRenderNode,
|
||||
#[error("The requested format is not supported")]
|
||||
UnsupportedFormat,
|
||||
#[error("The requested modifier is not supported")]
|
||||
UnsupportedModifier,
|
||||
#[error("Image is external only and cannot be rendered to")]
|
||||
ExternalOnly,
|
||||
#[error("OpenGL context does not support external textures")]
|
||||
ExternalUnsupported,
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct GfxGlState {
|
||||
triangles: RefCell<Vec<f32>>,
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
use {
|
||||
crate::render::{
|
||||
crate::gfx_apis::gl::{
|
||||
egl::sys::{
|
||||
eglBindAPI, EGLAttrib, EGLLabelKHR, EGLenum, EGLint, EGL_DEBUG_MSG_CRITICAL_KHR,
|
||||
EGL_DEBUG_MSG_ERROR_KHR, EGL_DEBUG_MSG_INFO_KHR, EGL_DEBUG_MSG_WARN_KHR, EGL_NONE,
|
||||
|
|
@ -27,9 +27,9 @@ pub mod display;
|
|||
pub mod image;
|
||||
pub mod sys;
|
||||
|
||||
pub(super) static PROCS: Lazy<ExtProc> = Lazy::new(ExtProc::load);
|
||||
pub(crate) static PROCS: Lazy<ExtProc> = Lazy::new(ExtProc::load);
|
||||
|
||||
pub(super) static EXTS: Lazy<ClientExt> = Lazy::new(get_client_ext);
|
||||
pub(crate) static EXTS: Lazy<ClientExt> = Lazy::new(get_client_ext);
|
||||
|
||||
pub fn init() -> Result<(), RenderError> {
|
||||
if !EXTS.contains(ClientExt::EXT_PLATFORM_BASE) {
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
use {
|
||||
crate::render::{
|
||||
crate::gfx_apis::gl::{
|
||||
egl::{
|
||||
display::EglDisplay,
|
||||
sys::{eglDestroyContext, eglMakeCurrent, EGLContext, EGLSurface, EGL_FALSE, EGL_TRUE},
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
use {
|
||||
crate::{
|
||||
format::{formats, Format},
|
||||
render::{
|
||||
gfx_apis::gl::{
|
||||
egl::{
|
||||
context::EglContext,
|
||||
image::EglImage,
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
use {
|
||||
crate::render::egl::{
|
||||
crate::gfx_apis::gl::egl::{
|
||||
display::EglDisplay,
|
||||
sys::{EGLImageKHR, EGL_FALSE},
|
||||
PROCS,
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
use {crate::render::sys::GLenum, uapi::c};
|
||||
use {crate::gfx_apis::gl::sys::GLenum, uapi::c};
|
||||
|
||||
pub type EGLint = i32;
|
||||
pub type EGLenum = c::c_uint;
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
use {
|
||||
crate::{
|
||||
render::{
|
||||
gfx_apis::gl::{
|
||||
egl::sys::{eglQueryString, EGLDisplay, EGL_EXTENSIONS},
|
||||
gl::sys::{glGetString, GL_EXTENSIONS},
|
||||
},
|
||||
|
|
@ -82,7 +82,7 @@ bitflags::bitflags! {
|
|||
}
|
||||
}
|
||||
|
||||
pub(super) unsafe fn get_display_ext(dpy: EGLDisplay) -> DisplayExt {
|
||||
pub(crate) unsafe fn get_display_ext(dpy: EGLDisplay) -> DisplayExt {
|
||||
let map = [
|
||||
("EGL_KHR_image_base", DisplayExt::KHR_IMAGE_BASE),
|
||||
(
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
use {
|
||||
crate::render::{
|
||||
crate::gfx_apis::gl::{
|
||||
egl::context::EglContext,
|
||||
gl::{
|
||||
render_buffer::GlRenderBuffer,
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
use {
|
||||
crate::render::{
|
||||
crate::gfx_apis::gl::{
|
||||
egl::context::EglContext,
|
||||
gl::{
|
||||
shader::GlShader,
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
use {
|
||||
crate::render::{
|
||||
crate::gfx_apis::gl::{
|
||||
egl::{context::EglContext, image::EglImage, PROCS},
|
||||
gl::{
|
||||
frame_buffer::GlFrameBuffer,
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
use {
|
||||
crate::render::{
|
||||
crate::gfx_apis::gl::{
|
||||
egl::context::EglContext,
|
||||
gl::sys::{
|
||||
glCompileShader, glCreateShader, glDeleteShader, glGetShaderiv, glShaderSource, GLenum,
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
use {
|
||||
crate::{
|
||||
format::Format,
|
||||
render::{
|
||||
gfx_apis::gl::{
|
||||
egl::{context::EglContext, image::EglImage, PROCS},
|
||||
ext::GlExt,
|
||||
gl::sys::{
|
||||
|
|
@ -17,7 +17,7 @@ use {
|
|||
};
|
||||
|
||||
pub struct GlTexture {
|
||||
pub(super) ctx: Rc<EglContext>,
|
||||
pub(crate) ctx: Rc<EglContext>,
|
||||
pub img: Option<Rc<EglImage>>,
|
||||
pub tex: GLuint,
|
||||
pub width: i32,
|
||||
6
src/gfx_apis/gl/renderer.rs
Normal file
6
src/gfx_apis/gl/renderer.rs
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
pub use {context::*, framebuffer::*, image::*, texture::*};
|
||||
|
||||
mod context;
|
||||
mod framebuffer;
|
||||
mod image;
|
||||
mod texture;
|
||||
|
|
@ -1,18 +1,18 @@
|
|||
use {
|
||||
crate::{
|
||||
format::{Format, XRGB8888},
|
||||
render::{
|
||||
gfx_api::GfxApiOpt,
|
||||
gfx_apis::gl::{
|
||||
egl::{
|
||||
context::EglContext,
|
||||
display::{EglDisplay, EglFormat},
|
||||
},
|
||||
ext::GlExt,
|
||||
gfx_api::GfxApiOpt,
|
||||
gl::{
|
||||
program::GlProgram, render_buffer::GlRenderBuffer, sys::GLint, texture::GlTexture,
|
||||
},
|
||||
renderer::{framebuffer::Framebuffer, gfx_apis::gl::GfxGlState, image::Image},
|
||||
RenderError, Texture,
|
||||
renderer::{framebuffer::Framebuffer, image::Image},
|
||||
GfxGlState, RenderError, Texture,
|
||||
},
|
||||
video::{
|
||||
dmabuf::DmaBuf,
|
||||
|
|
@ -30,11 +30,11 @@ use {
|
|||
uapi::ustr,
|
||||
};
|
||||
|
||||
pub(super) struct TexProg {
|
||||
pub(super) prog: GlProgram,
|
||||
pub(super) pos: GLint,
|
||||
pub(super) texcoord: GLint,
|
||||
pub(super) tex: GLint,
|
||||
pub(crate) struct TexProg {
|
||||
pub(crate) prog: GlProgram,
|
||||
pub(crate) pos: GLint,
|
||||
pub(crate) texcoord: GLint,
|
||||
pub(crate) tex: GLint,
|
||||
}
|
||||
|
||||
impl TexProg {
|
||||
|
|
@ -48,26 +48,26 @@ impl TexProg {
|
|||
}
|
||||
}
|
||||
|
||||
pub(super) struct TexProgs {
|
||||
pub(crate) struct TexProgs {
|
||||
pub alpha: TexProg,
|
||||
pub solid: TexProg,
|
||||
}
|
||||
|
||||
pub struct RenderContext {
|
||||
pub(super) ctx: Rc<EglContext>,
|
||||
pub(crate) ctx: Rc<EglContext>,
|
||||
pub gbm: Rc<GbmDevice>,
|
||||
|
||||
pub(super) render_node: Rc<CString>,
|
||||
pub(crate) render_node: Rc<CString>,
|
||||
|
||||
pub(super) tex_internal: TexProgs,
|
||||
pub(super) tex_external: Option<TexProgs>,
|
||||
pub(crate) tex_internal: TexProgs,
|
||||
pub(crate) tex_external: Option<TexProgs>,
|
||||
|
||||
pub(super) fill_prog: GlProgram,
|
||||
pub(super) fill_prog_pos: GLint,
|
||||
pub(super) fill_prog_color: GLint,
|
||||
pub(crate) fill_prog: GlProgram,
|
||||
pub(crate) fill_prog_pos: GLint,
|
||||
pub(crate) fill_prog_color: GLint,
|
||||
|
||||
pub(super) gfx_ops: RefCell<Vec<GfxApiOpt>>,
|
||||
pub(super) gl_state: RefCell<GfxGlState>,
|
||||
pub(crate) gfx_ops: RefCell<Vec<GfxApiOpt>>,
|
||||
pub(crate) gl_state: RefCell<GfxGlState>,
|
||||
}
|
||||
|
||||
impl Debug for RenderContext {
|
||||
|
|
@ -3,8 +3,7 @@ use {
|
|||
cursor::Cursor,
|
||||
fixed::Fixed,
|
||||
format::{Format, ARGB8888, XRGB8888},
|
||||
rect::Rect,
|
||||
render::{
|
||||
gfx_apis::gl::{
|
||||
gl::{
|
||||
frame_buffer::GlFrameBuffer,
|
||||
sys::{
|
||||
|
|
@ -12,13 +11,13 @@ use {
|
|||
GL_FRAMEBUFFER,
|
||||
},
|
||||
},
|
||||
renderer::{
|
||||
context::RenderContext, gfx_apis::gl::run_ops, renderer::Renderer,
|
||||
renderer_base::RendererBase,
|
||||
},
|
||||
renderer::context::RenderContext,
|
||||
run_ops,
|
||||
sys::{glBlendFunc, glFlush, glReadnPixels, GL_ONE, GL_ONE_MINUS_SRC_ALPHA},
|
||||
RenderResult, Texture,
|
||||
Texture,
|
||||
},
|
||||
rect::Rect,
|
||||
renderer::{renderer_base::RendererBase, RenderResult, Renderer},
|
||||
scale::Scale,
|
||||
state::State,
|
||||
tree::Node,
|
||||
|
|
@ -31,8 +30,8 @@ use {
|
|||
};
|
||||
|
||||
pub struct Framebuffer {
|
||||
pub(super) ctx: Rc<RenderContext>,
|
||||
pub(super) gl: GlFrameBuffer,
|
||||
pub(crate) ctx: Rc<RenderContext>,
|
||||
pub(crate) gl: GlFrameBuffer,
|
||||
}
|
||||
|
||||
impl Debug for Framebuffer {
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
use {
|
||||
crate::render::{
|
||||
crate::gfx_apis::gl::{
|
||||
egl::image::EglImage,
|
||||
gl::{render_buffer::GlRenderBuffer, texture::GlTexture},
|
||||
Framebuffer, RenderContext, RenderError, Texture,
|
||||
|
|
@ -8,8 +8,8 @@ use {
|
|||
};
|
||||
|
||||
pub struct Image {
|
||||
pub(super) ctx: Rc<RenderContext>,
|
||||
pub(super) gl: Rc<EglImage>,
|
||||
pub(crate) ctx: Rc<RenderContext>,
|
||||
pub(crate) gl: Rc<EglImage>,
|
||||
}
|
||||
|
||||
impl Image {
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
use {
|
||||
crate::render::{gl::texture::GlTexture, renderer::context::RenderContext},
|
||||
crate::gfx_apis::gl::{gl::texture::GlTexture, renderer::context::RenderContext},
|
||||
std::{
|
||||
fmt::{Debug, Formatter},
|
||||
rc::Rc,
|
||||
|
|
@ -7,8 +7,8 @@ use {
|
|||
};
|
||||
|
||||
pub struct Texture {
|
||||
pub(super) ctx: Rc<RenderContext>,
|
||||
pub(super) gl: GlTexture,
|
||||
pub(crate) ctx: Rc<RenderContext>,
|
||||
pub(crate) gl: GlTexture,
|
||||
}
|
||||
|
||||
impl Debug for Texture {
|
||||
|
|
@ -1,9 +1,9 @@
|
|||
use {
|
||||
crate::{
|
||||
client::{Client, ClientError},
|
||||
gfx_apis::gl::RenderContext,
|
||||
leaks::Tracker,
|
||||
object::Object,
|
||||
render::RenderContext,
|
||||
utils::{
|
||||
buffd::{MsgParser, MsgParserError},
|
||||
errorfmt::ErrorFmt,
|
||||
|
|
|
|||
|
|
@ -2,10 +2,10 @@ use {
|
|||
crate::{
|
||||
client::{Client, ClientError},
|
||||
format::XRGB8888,
|
||||
gfx_apis::gl::{Framebuffer, RenderContext, RenderError, Texture},
|
||||
ifs::jay_output::JayOutput,
|
||||
leaks::Tracker,
|
||||
object::Object,
|
||||
render::{Framebuffer, RenderContext, RenderError, Texture},
|
||||
tree::{OutputNode, WorkspaceNodeId},
|
||||
utils::{
|
||||
buffd::{MsgParser, MsgParserError},
|
||||
|
|
|
|||
|
|
@ -3,10 +3,10 @@ use {
|
|||
client::{Client, ClientError},
|
||||
clientmem::{ClientMem, ClientMemError, ClientMemOffset},
|
||||
format::Format,
|
||||
gfx_apis::gl::{Framebuffer, Image, RenderError, Texture},
|
||||
leaks::Tracker,
|
||||
object::Object,
|
||||
rect::Rect,
|
||||
render::{Framebuffer, Image, RenderError, Texture},
|
||||
utils::{
|
||||
buffd::{MsgParser, MsgParserError},
|
||||
clonecell::CloneCell,
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
use {
|
||||
crate::{
|
||||
client::{Client, ClientError},
|
||||
gfx_apis::gl::RenderError,
|
||||
globals::{Global, GlobalName},
|
||||
ifs::wl_buffer::WlBuffer,
|
||||
leaks::Tracker,
|
||||
object::Object,
|
||||
render::RenderError,
|
||||
utils::buffd::{MsgParser, MsgParserError},
|
||||
video::{
|
||||
dmabuf::{DmaBuf, DmaBufPlane},
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ use {
|
|||
backend,
|
||||
client::{Client, ClientError, ClientId},
|
||||
format::XRGB8888,
|
||||
gfx_apis::gl::{Framebuffer, Texture},
|
||||
globals::{Global, GlobalName},
|
||||
ifs::{
|
||||
wl_buffer::WlBufferStorage, wl_surface::WlSurface,
|
||||
|
|
@ -11,7 +12,6 @@ use {
|
|||
leaks::Tracker,
|
||||
object::Object,
|
||||
rect::Rect,
|
||||
render::{Framebuffer, Texture},
|
||||
state::{ConnectorData, State},
|
||||
time::Time,
|
||||
tree::OutputNode,
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ use {
|
|||
backend::KeyState,
|
||||
client::{Client, ClientError, RequestParser},
|
||||
fixed::Fixed,
|
||||
gfx_api::{BufferPoint, BufferPoints},
|
||||
ifs::{
|
||||
wl_buffer::WlBuffer,
|
||||
wl_callback::WlCallback,
|
||||
|
|
@ -38,10 +39,7 @@ use {
|
|||
leaks::Tracker,
|
||||
object::Object,
|
||||
rect::{Rect, Region},
|
||||
render::{
|
||||
gfx_api::{BufferPoint, BufferPoints},
|
||||
Renderer,
|
||||
},
|
||||
renderer::Renderer,
|
||||
tree::{
|
||||
FindTreeResult, FoundNode, Node, NodeId, NodeVisitor, NodeVisitorBase, OutputNode,
|
||||
ToplevelNode,
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ use {
|
|||
ifs::{wl_seat::WlSeatGlobal, wl_surface::WlSurface},
|
||||
leaks::Tracker,
|
||||
rect::Rect,
|
||||
render::Renderer,
|
||||
renderer::Renderer,
|
||||
scale::Scale,
|
||||
tree::{Node, NodeVisitorBase, OutputNode},
|
||||
},
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ use {
|
|||
wl_surface::{x_surface::XSurface, WlSurface, WlSurfaceError},
|
||||
},
|
||||
rect::Rect,
|
||||
render::Renderer,
|
||||
renderer::Renderer,
|
||||
state::State,
|
||||
tree::{
|
||||
Direction, FindTreeResult, FoundNode, Node, NodeId, NodeVisitor, StackedNode,
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ use {
|
|||
leaks::Tracker,
|
||||
object::Object,
|
||||
rect::Rect,
|
||||
render::Renderer,
|
||||
renderer::Renderer,
|
||||
tree::{FindTreeResult, FoundNode, Node, NodeId, NodeVisitor, StackedNode, WorkspaceNode},
|
||||
utils::{
|
||||
buffd::{MsgParser, MsgParserError},
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ use {
|
|||
leaks::Tracker,
|
||||
object::Object,
|
||||
rect::Rect,
|
||||
render::Renderer,
|
||||
renderer::Renderer,
|
||||
state::State,
|
||||
tree::{
|
||||
Direction, FindTreeResult, FoundNode, Node, NodeId, NodeVisitor, ToplevelData,
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ use {
|
|||
leaks::Tracker,
|
||||
object::Object,
|
||||
rect::Rect,
|
||||
render::Renderer,
|
||||
renderer::Renderer,
|
||||
tree::{FindTreeResult, FoundNode, Node, NodeId, NodeVisitor, OutputNode},
|
||||
utils::{
|
||||
bitflags::BitflagsExt,
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
use {
|
||||
crate::{
|
||||
client::ClientError,
|
||||
gfx_apis::gl::RenderError,
|
||||
ifs::{wl_buffer::WlBuffer, zwp_linux_dmabuf_v1::ZwpLinuxDmabufV1},
|
||||
leaks::Tracker,
|
||||
object::Object,
|
||||
render::RenderError,
|
||||
utils::{
|
||||
buffd::{MsgParser, MsgParserError},
|
||||
errorfmt::ErrorFmt,
|
||||
|
|
|
|||
|
|
@ -9,8 +9,8 @@ use {
|
|||
},
|
||||
compositor::TestFuture,
|
||||
fixed::Fixed,
|
||||
gfx_apis::gl::{RenderContext, RenderError},
|
||||
it::test_error::TestResult,
|
||||
render::{RenderContext, RenderError},
|
||||
state::State,
|
||||
time::now_usec,
|
||||
utils::{
|
||||
|
|
|
|||
|
|
@ -62,6 +62,8 @@ mod edid;
|
|||
mod fixed;
|
||||
mod forker;
|
||||
mod format;
|
||||
mod gfx_api;
|
||||
mod gfx_apis;
|
||||
mod globals;
|
||||
mod ifs;
|
||||
mod io_uring;
|
||||
|
|
@ -75,7 +77,7 @@ mod pango;
|
|||
mod pipewire;
|
||||
mod portal;
|
||||
mod rect;
|
||||
mod render;
|
||||
mod renderer;
|
||||
mod scale;
|
||||
mod screenshoter;
|
||||
mod sighand;
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
use {
|
||||
crate::{
|
||||
gfx_apis::gl::RenderContext,
|
||||
ifs::wl_seat::POINTER,
|
||||
portal::{
|
||||
ptl_render_ctx::PortalRenderCtx, ptl_screencast::ScreencastSession,
|
||||
ptr_gui::WindowData, PortalState,
|
||||
},
|
||||
render::RenderContext,
|
||||
utils::{
|
||||
bitflags::BitflagsExt, clonecell::CloneCell, copyhashmap::CopyHashMap,
|
||||
errorfmt::ErrorFmt, oserror::OsError,
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
use {crate::render::RenderContext, std::rc::Rc, uapi::c};
|
||||
use {crate::gfx_apis::gl::RenderContext, std::rc::Rc, uapi::c};
|
||||
|
||||
pub struct PortalRenderCtx {
|
||||
pub dev_id: c::dev_t,
|
||||
|
|
|
|||
|
|
@ -4,9 +4,10 @@ use {
|
|||
cursor::KnownCursor,
|
||||
fixed::Fixed,
|
||||
format::ARGB8888,
|
||||
gfx_apis::gl::{Framebuffer, RenderContext, Texture},
|
||||
ifs::zwlr_layer_shell_v1::OVERLAY,
|
||||
portal::ptl_display::{PortalDisplay, PortalOutput, PortalSeat},
|
||||
render::{Framebuffer, RenderContext, RendererBase, Texture},
|
||||
renderer::renderer_base::RendererBase,
|
||||
scale::Scale,
|
||||
text::{self, TextMeasurement},
|
||||
theme::Color,
|
||||
|
|
|
|||
|
|
@ -1,99 +0,0 @@
|
|||
macro_rules! egl_transparent {
|
||||
($name:ident) => {
|
||||
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
|
||||
#[repr(transparent)]
|
||||
pub struct $name(pub *mut u8);
|
||||
|
||||
impl $name {
|
||||
#[allow(dead_code)]
|
||||
pub const fn none() -> Self {
|
||||
Self(std::ptr::null_mut())
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub fn is_none(self) -> bool {
|
||||
self.0.is_null()
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
pub use renderer::*;
|
||||
use {
|
||||
crate::video::{drm::DrmError, gbm::GbmError},
|
||||
thiserror::Error,
|
||||
};
|
||||
|
||||
mod egl;
|
||||
mod ext;
|
||||
mod gl;
|
||||
mod proc;
|
||||
mod renderer;
|
||||
|
||||
pub mod sys {
|
||||
pub use super::{egl::sys::*, gl::sys::*};
|
||||
}
|
||||
|
||||
pub fn init() -> Result<(), RenderError> {
|
||||
egl::init()
|
||||
}
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum RenderError {
|
||||
#[error("EGL library does not support `EGL_EXT_platform_base`")]
|
||||
ExtPlatformBase,
|
||||
#[error("Could not compile a shader")]
|
||||
ShaderCompileFailed,
|
||||
#[error("Could not link a program")]
|
||||
ProgramLink,
|
||||
#[error("Could not bind to `EGL_OPENGL_ES_API`")]
|
||||
BindFailed,
|
||||
#[error("EGL library does not support the GBM platform")]
|
||||
GbmExt,
|
||||
#[error("Could not create a GBM device")]
|
||||
Gbm(#[source] GbmError),
|
||||
#[error("`eglCreateContext` failed")]
|
||||
CreateContext,
|
||||
#[error("`eglMakeCurrent` failed")]
|
||||
MakeCurrent,
|
||||
#[error("`eglCreateImageKHR` failed")]
|
||||
CreateImage,
|
||||
#[error("Image buffer is too small")]
|
||||
SmallImageBuffer,
|
||||
#[error("Binding a renderbuffer to a framebuffer failed")]
|
||||
CreateFramebuffer,
|
||||
#[error("`eglGetPlatformDisplayEXT` failed")]
|
||||
GetDisplay,
|
||||
#[error("`eglInitialize` failed")]
|
||||
Initialize,
|
||||
#[error("EGL display does not support `EGL_EXT_image_dma_buf_import_modifiers`")]
|
||||
DmaBufImport,
|
||||
#[error("GLES driver does not support `GL_OES_EGL_image`")]
|
||||
OesEglImage,
|
||||
#[error("EGL display does not support `EGL_KHR_image_base`")]
|
||||
ImageBase,
|
||||
#[error(
|
||||
"EGL display does not support `EGL_KHR_no_config_context` or `EGL_MESA_configless_context`"
|
||||
)]
|
||||
ConfiglessContext,
|
||||
#[error("EGL display does not support `EGL_KHR_surfaceless_context`")]
|
||||
SurfacelessContext,
|
||||
#[error("`eglQueryDmaBufFormatsEXT` failed")]
|
||||
QueryDmaBufFormats,
|
||||
#[error("`eglQueryDmaBufModifiersEXT` failed")]
|
||||
QueryDmaBufModifiers,
|
||||
#[error(transparent)]
|
||||
DrmError(#[from] DrmError),
|
||||
#[error("The GLES driver does not support the XRGB8888 format")]
|
||||
XRGB888,
|
||||
#[error("The DRM device does not have a render node")]
|
||||
NoRenderNode,
|
||||
#[error("The requested format is not supported")]
|
||||
UnsupportedFormat,
|
||||
#[error("The requested modifier is not supported")]
|
||||
UnsupportedModifier,
|
||||
#[error("Image is external only and cannot be rendered to")]
|
||||
ExternalOnly,
|
||||
#[error("OpenGL context does not support external textures")]
|
||||
ExternalUnsupported,
|
||||
}
|
||||
|
|
@ -1,10 +0,0 @@
|
|||
pub use {context::*, framebuffer::*, image::*, renderer::*, renderer_base::*, texture::*};
|
||||
|
||||
mod context;
|
||||
mod framebuffer;
|
||||
pub mod gfx_api;
|
||||
mod gfx_apis;
|
||||
mod image;
|
||||
mod renderer;
|
||||
mod renderer_base;
|
||||
mod texture;
|
||||
|
|
@ -1 +0,0 @@
|
|||
pub(super) mod gl;
|
||||
|
|
@ -1,6 +1,7 @@
|
|||
use {
|
||||
crate::{
|
||||
format::ARGB8888,
|
||||
gfx_api::{BufferPoints, GfxApiOpt},
|
||||
ifs::{
|
||||
wl_buffer::WlBuffer,
|
||||
wl_callback::WlCallback,
|
||||
|
|
@ -10,10 +11,7 @@ use {
|
|||
wp_presentation_feedback::WpPresentationFeedback,
|
||||
},
|
||||
rect::Rect,
|
||||
render::{
|
||||
gfx_api::GfxApiOpt,
|
||||
renderer::{gfx_api::BufferPoints, renderer_base::RendererBase},
|
||||
},
|
||||
renderer::renderer_base::RendererBase,
|
||||
scale::Scale,
|
||||
state::State,
|
||||
theme::Color,
|
||||
|
|
@ -30,6 +28,8 @@ use {
|
|||
},
|
||||
};
|
||||
|
||||
pub mod renderer_base;
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct RenderResult {
|
||||
pub frame_requests: Vec<Rc<WlCallback>>,
|
||||
|
|
@ -44,11 +44,11 @@ impl Debug for RenderResult {
|
|||
|
||||
pub struct Renderer<'a> {
|
||||
pub base: RendererBase<'a>,
|
||||
pub(super) state: &'a State,
|
||||
pub(super) on_output: bool,
|
||||
pub(super) result: &'a mut RenderResult,
|
||||
pub(super) logical_extents: Rect,
|
||||
pub(super) physical_extents: Rect,
|
||||
pub state: &'a State,
|
||||
pub on_output: bool,
|
||||
pub result: &'a mut RenderResult,
|
||||
pub logical_extents: Rect,
|
||||
pub physical_extents: Rect,
|
||||
}
|
||||
|
||||
impl Renderer<'_> {
|
||||
|
|
@ -1,14 +1,11 @@
|
|||
use {
|
||||
crate::{
|
||||
format::Format,
|
||||
rect::Rect,
|
||||
render::{
|
||||
gfx_api::Clear,
|
||||
renderer::gfx_api::{
|
||||
AbsoluteRect, BufferPoint, BufferPoints, CopyTexture, FillRect, GfxApiOpt,
|
||||
},
|
||||
Texture,
|
||||
gfx_api::{
|
||||
AbsoluteRect, BufferPoint, BufferPoints, Clear, CopyTexture, FillRect, GfxApiOpt,
|
||||
},
|
||||
gfx_apis::gl::Texture,
|
||||
rect::Rect,
|
||||
scale::Scale,
|
||||
theme::Color,
|
||||
},
|
||||
|
|
@ -16,10 +13,10 @@ use {
|
|||
};
|
||||
|
||||
pub struct RendererBase<'a> {
|
||||
pub(super) ops: &'a mut Vec<GfxApiOpt>,
|
||||
pub(super) scaled: bool,
|
||||
pub(super) scale: Scale,
|
||||
pub(super) scalef: f64,
|
||||
pub ops: &'a mut Vec<GfxApiOpt>,
|
||||
pub scaled: bool,
|
||||
pub scale: Scale,
|
||||
pub scalef: f64,
|
||||
}
|
||||
|
||||
impl RendererBase<'_> {
|
||||
|
|
@ -143,7 +140,7 @@ impl RendererBase<'_> {
|
|||
let (twidth, theight) = if let Some(size) = tsize {
|
||||
size
|
||||
} else {
|
||||
let (mut w, mut h) = (texture.gl.width, texture.gl.height);
|
||||
let (mut w, mut h) = (texture.width(), texture.height());
|
||||
if tscale != self.scale {
|
||||
let tscale = tscale.to_f64();
|
||||
w = (w as f64 * self.scalef / tscale).round() as _;
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
use {
|
||||
crate::{
|
||||
format::XRGB8888,
|
||||
render::RenderError,
|
||||
gfx_apis::gl::RenderError,
|
||||
scale::Scale,
|
||||
state::State,
|
||||
video::{
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ use {
|
|||
cursor::{Cursor, ServerCursors},
|
||||
dbus::Dbus,
|
||||
forker::ForkerProxy,
|
||||
gfx_apis::gl::RenderContext,
|
||||
globals::{Globals, GlobalsError, WaylandGlobal},
|
||||
ifs::{
|
||||
ext_session_lock_v1::ExtSessionLockV1,
|
||||
|
|
@ -31,7 +32,6 @@ use {
|
|||
leaks::Tracker,
|
||||
logger::Logger,
|
||||
rect::Rect,
|
||||
render::RenderContext,
|
||||
scale::Scale,
|
||||
theme::Theme,
|
||||
tree::{
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
use {
|
||||
crate::{
|
||||
format::ARGB8888,
|
||||
gfx_apis::gl::{RenderContext, RenderError, Texture},
|
||||
pango::{
|
||||
consts::{
|
||||
CAIRO_FORMAT_ARGB32, CAIRO_OPERATOR_SOURCE, PANGO_ELLIPSIZE_END, PANGO_SCALE,
|
||||
|
|
@ -9,7 +10,6 @@ use {
|
|||
PangoLayout,
|
||||
},
|
||||
rect::Rect,
|
||||
render::{RenderContext, RenderError, Texture},
|
||||
theme::Color,
|
||||
},
|
||||
std::{ops::Neg, rc::Rc},
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ use {
|
|||
wl_surface::WlSurface,
|
||||
},
|
||||
rect::Rect,
|
||||
render::Renderer,
|
||||
renderer::Renderer,
|
||||
utils::numcell::NumCell,
|
||||
xkbcommon::ModifierState,
|
||||
},
|
||||
|
|
|
|||
|
|
@ -3,12 +3,13 @@ use {
|
|||
backend::KeyState,
|
||||
cursor::KnownCursor,
|
||||
fixed::Fixed,
|
||||
gfx_apis::gl::Texture,
|
||||
ifs::wl_seat::{
|
||||
collect_kb_foci, collect_kb_foci2, wl_pointer::PendingScroll, NodeSeatState, SeatId,
|
||||
WlSeatGlobal, BTN_LEFT,
|
||||
},
|
||||
rect::Rect,
|
||||
render::{Renderer, Texture},
|
||||
renderer::Renderer,
|
||||
scale::Scale,
|
||||
state::State,
|
||||
text,
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ use {
|
|||
cursor::KnownCursor,
|
||||
ifs::wl_seat::{NodeSeatState, WlSeatGlobal},
|
||||
rect::Rect,
|
||||
render::Renderer,
|
||||
renderer::Renderer,
|
||||
tree::{
|
||||
walker::NodeVisitor, FindTreeResult, FoundNode, Node, NodeId, OutputNode, StackedNode,
|
||||
},
|
||||
|
|
|
|||
|
|
@ -3,9 +3,10 @@ use {
|
|||
backend::KeyState,
|
||||
cursor::KnownCursor,
|
||||
fixed::Fixed,
|
||||
gfx_apis::gl::Texture,
|
||||
ifs::wl_seat::{NodeSeatState, SeatId, WlSeatGlobal, BTN_LEFT},
|
||||
rect::Rect,
|
||||
render::{Renderer, Texture},
|
||||
renderer::Renderer,
|
||||
scale::Scale,
|
||||
state::State,
|
||||
text,
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ use {
|
|||
client::ClientId,
|
||||
cursor::KnownCursor,
|
||||
fixed::Fixed,
|
||||
gfx_apis::gl::{Framebuffer, Texture},
|
||||
ifs::{
|
||||
jay_output::JayOutput,
|
||||
jay_screencast::JayScreencast,
|
||||
|
|
@ -19,7 +20,7 @@ use {
|
|||
zwlr_layer_shell_v1::{BACKGROUND, BOTTOM, OVERLAY, TOP},
|
||||
},
|
||||
rect::Rect,
|
||||
render::{Framebuffer, Renderer, Texture},
|
||||
renderer::Renderer,
|
||||
scale::Scale,
|
||||
state::State,
|
||||
text,
|
||||
|
|
|
|||
|
|
@ -3,9 +3,10 @@ use {
|
|||
client::Client,
|
||||
cursor::KnownCursor,
|
||||
fixed::Fixed,
|
||||
gfx_apis::gl::Texture,
|
||||
ifs::wl_seat::{NodeSeatState, WlSeatGlobal},
|
||||
rect::Rect,
|
||||
render::{Renderer, Texture},
|
||||
renderer::Renderer,
|
||||
scale::Scale,
|
||||
state::State,
|
||||
text,
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ use {
|
|||
wl_surface::WlSurface,
|
||||
},
|
||||
rect::Rect,
|
||||
render::Renderer,
|
||||
renderer::Renderer,
|
||||
tree::{
|
||||
container::ContainerNode, walker::NodeVisitor, ContainingNode, Direction,
|
||||
FindTreeResult, FoundNode, Node, NodeId, NodeVisitorBase, OutputNode, StackedNode,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue