diff --git a/src/gfx_api.rs b/src/gfx_api.rs index 659821bf..e0c4c28e 100644 --- a/src/gfx_api.rs +++ b/src/gfx_api.rs @@ -1,11 +1,13 @@ use { crate::{ allocator::Allocator, + clientmem::ClientMemOffset, + cpu_worker::CpuWorker, cursor::Cursor, damage::DamageVisualizer, fixed::Fixed, format::Format, - rect::Rect, + rect::{Rect, Region}, renderer::{renderer_base::RendererBase, RenderResult, Renderer}, scale::Scale, state::State, @@ -535,6 +537,45 @@ pub trait ShmGfxTexture: GfxTexture { fn into_texture(self: Rc) -> Rc; } +#[expect(dead_code)] +pub trait AsyncShmGfxTextureCallback { + fn completed(self: Rc, res: Result<(), GfxError>); +} + +pub trait AsyncShmGfxTextureUploadCancellable { + fn cancel(&self, id: u64); +} + +pub struct PendingShmUpload { + cancel: Rc, + id: u64, +} + +pub trait AsyncShmGfxTexture: GfxTexture { + #[expect(dead_code)] + fn async_upload( + self: Rc, + callback: Rc, + mem: &Rc, + damage: Region, + ) -> Result, GfxError>; + + #[expect(dead_code)] + fn sync_upload(self: Rc, shm: &[Cell], damage: Region) -> Result<(), GfxError>; + + #[expect(dead_code)] + fn compatible_with( + &self, + format: &'static Format, + width: i32, + height: i32, + stride: i32, + ) -> bool; + + #[expect(dead_code)] + fn into_texture(self: Rc) -> Rc; +} + pub trait GfxContext: Debug { fn reset_status(&self) -> Option; @@ -559,6 +600,16 @@ pub trait GfxContext: Debug { damage: Option<&[Rect]>, ) -> Result, GfxError>; + #[expect(dead_code)] + fn async_shmem_texture( + self: Rc, + format: &'static Format, + width: i32, + height: i32, + stride: i32, + cpu_worker: &Rc, + ) -> Result, GfxError>; + fn allocator(&self) -> Rc; fn gfx_api(&self) -> GfxApi; @@ -637,3 +688,16 @@ pub fn cross_intersect_formats( } res } + +impl PendingShmUpload { + #[expect(dead_code)] + pub fn new(cancel: Rc, id: u64) -> Self { + Self { cancel, id } + } +} + +impl Drop for PendingShmUpload { + fn drop(&mut self) { + self.cancel.cancel(self.id); + } +} diff --git a/src/gfx_apis/gl/renderer/context.rs b/src/gfx_apis/gl/renderer/context.rs index 1948ac16..8ff76a27 100644 --- a/src/gfx_apis/gl/renderer/context.rs +++ b/src/gfx_apis/gl/renderer/context.rs @@ -1,10 +1,11 @@ use { crate::{ allocator::Allocator, + cpu_worker::CpuWorker, format::{Format, XRGB8888}, gfx_api::{ - BufferResvUser, GfxApiOpt, GfxContext, GfxError, GfxFormat, GfxFramebuffer, GfxImage, - ResetStatus, ShmGfxTexture, + AsyncShmGfxTexture, BufferResvUser, GfxApiOpt, GfxContext, GfxError, GfxFormat, + GfxFramebuffer, GfxImage, ResetStatus, ShmGfxTexture, }, gfx_apis::gl::{ egl::{context::EglContext, display::EglDisplay, image::EglImage}, @@ -279,6 +280,17 @@ impl GfxContext for GlRenderContext { .map_err(|e| e.into()) } + fn async_shmem_texture( + self: Rc, + _format: &'static Format, + _width: i32, + _height: i32, + _stride: i32, + _cpu_worker: &Rc, + ) -> Result, GfxError> { + todo!() + } + fn allocator(&self) -> Rc { self.gbm.clone() } diff --git a/src/gfx_apis/vulkan.rs b/src/gfx_apis/vulkan.rs index 09827d4e..5e24fc8d 100644 --- a/src/gfx_apis/vulkan.rs +++ b/src/gfx_apis/vulkan.rs @@ -19,9 +19,11 @@ use { crate::{ allocator::{Allocator, AllocatorError}, async_engine::AsyncEngine, + cpu_worker::CpuWorker, format::Format, gfx_api::{ - GfxContext, GfxError, GfxFormat, GfxFramebuffer, GfxImage, ResetStatus, ShmGfxTexture, + AsyncShmGfxTexture, GfxContext, GfxError, GfxFormat, GfxFramebuffer, GfxImage, + ResetStatus, ShmGfxTexture, }, gfx_apis::vulkan::{ image::VulkanImageMemory, instance::VulkanInstance, renderer::VulkanRenderer, @@ -278,6 +280,17 @@ impl GfxContext for Context { Ok(tex as _) } + fn async_shmem_texture( + self: Rc, + _format: &'static Format, + _width: i32, + _height: i32, + _stride: i32, + _cpu_worker: &Rc, + ) -> Result, GfxError> { + todo!() + } + fn allocator(&self) -> Rc { self.0.device.gbm.clone() } diff --git a/src/it/test_gfx_api.rs b/src/it/test_gfx_api.rs index ef37188c..abae7a07 100644 --- a/src/it/test_gfx_api.rs +++ b/src/it/test_gfx_api.rs @@ -1,11 +1,12 @@ use { crate::{ allocator::{Allocator, AllocatorError, BufferObject, BufferUsage}, + cpu_worker::CpuWorker, format::{Format, ARGB8888, XRGB8888}, gfx_api::{ - CopyTexture, FillRect, FramebufferRect, GfxApiOpt, GfxContext, GfxError, GfxFormat, - GfxFramebuffer, GfxImage, GfxTexture, GfxWriteModifier, ResetStatus, ShmGfxTexture, - SyncFile, + AsyncShmGfxTexture, CopyTexture, FillRect, FramebufferRect, GfxApiOpt, GfxContext, + GfxError, GfxFormat, GfxFramebuffer, GfxImage, GfxTexture, GfxWriteModifier, + ResetStatus, ShmGfxTexture, SyncFile, }, rect::Rect, theme::Color, @@ -133,6 +134,17 @@ impl GfxContext for TestGfxCtx { }))) } + fn async_shmem_texture( + self: Rc, + _format: &'static Format, + _width: i32, + _height: i32, + _stride: i32, + _cpu_worker: &Rc, + ) -> Result, GfxError> { + todo!() + } + fn allocator(&self) -> Rc { self.allocator.clone() }