Implement ext-image-capture-source and ext-image-copy-capture protocols (staging)#3942
Implement ext-image-capture-source and ext-image-copy-capture protocols (staging)#3942powersemmi wants to merge 2 commits into
Conversation
|
Hi! I'd appreciate some help from the maintainer with reviewing and A few things I'm unsure about and would love feedback on:
Also, a heads-up: this PR was primarily created to test my tool Any guidance would be greatly appreciated! 🙏 |
fa1d16b to
e46fdaa
Compare
…rotocols Implement the following Wayland protocols: - ext_image_capture_source_v1: opaque image capture source objects - ext_image_copy_capture_v1: copy image content to SHM/DMABuf buffers - ext_output_image_capture_source_manager_v1: create capture sources from outputs - ext_foreign_toplevel_image_capture_source_manager_v1: create capture sources from toplevels The ext_foreign_toplevel_list_v1 protocol was already implemented. The implementation provides: - ImageCaptureSourceState for core capture source handling - OutputCaptureSourceState for output capture sources - ToplevelImageCaptureManagerState for toplevel capture sources (custom implementation that integrates with niri's existing foreign_toplevel state) - ImageCopyCaptureState for the copy capture protocol (frame capture fails with Unknown for now, can be extended with actual rendering later)
…opy-capture protocols Complete implementation with actual rendering support: Protocols implemented: - ext_image_capture_source_v1: opaque capture source objects - ext_image_copy_capture_v1: copy image content to SHM/DMABuf buffers - ext_output_image_capture_source_manager_v1: create sources from outputs - ext_foreign_toplevel_image_capture_source_manager_v1: create sources from toplevels Rendering: - Output capture: renders full output content into client-provided buffer - Toplevel capture: renders window content (with popups) into client-provided buffer - Supports both SHM and DMA-BUF buffers - Uses the existing rendering pipeline (glES renderer, damage tracking) Frame capture flow in ImageCopyCaptureHandler::frame(): 1. Determine source type (output or toplevel) from ImageCaptureSource user_data 2. Build render elements using niri's existing rendering infrastructure 3. Create OutputDamageTracker for size/scale info 4. Render to the client buffer via render_to_shm or render_to_dmabuf 5. Signal completion with frame.success() or frame.fail()
e46fdaa to
eeca81b
Compare
Implement the following Wayland protocols from the
ext-image-capture-sourceandext-image-copy-capturestaging protocol families:ext_image_capture_source_v1ImageCaptureSourceStateext_output_image_capture_source_manager_v1OutputCaptureSourceStateext_foreign_toplevel_image_capture_source_manager_v1ext_image_copy_capture_v1ext_foreign_toplevel_list_v1Architecture
Capture Sources
WeakOutputin the source'suser_data. Created viaext_output_image_capture_source_manager_v1.WlSurfacein the source'suser_data. Created viaext_foreign_toplevel_image_capture_source_manager_v1, with a custom handler that looks up the window by itsExtForeignToplevelHandleV1through niri's existingForeignToplevelManagerState.Copy Capture
ImageCopyCaptureStateregistered as a global.capture_constraints()returns the output or window size plus supported SHM formats (Argb8888, Xrgb8888).frame()renders the captured content into the client-provided buffer:Niri::render()withRenderTarget::ScreenCapture.find_root_shell_surface()+Layout::find_window_and_output(), renders viaMapped::render_for_screen_cast().render_to_shm) and DMA-BUF buffers (viarender_to_dmabuf).OutputDamageTrackerwith full damage (age=0) for correct sizing and rendering.frame.success().Toplevel Manager
Since niri implements
ext_foreign_toplevel_list_v1with its own state (not smithay'sForeignToplevelHandle), a customToplevelImageCaptureManagerStatewas implemented that:ExtForeignToplevelImageCaptureSourceManagerV1global.CreateSource, looks up theExtForeignToplevelHandleV1inForeignToplevelManagerState::find_surface_for_handle()to find the correspondingWlSurface.ImageCaptureSourceand stores theWlSurfacein itsuser_data.Notes
ext_foreign_toplevel_list_v1protocol was already fully implemented. A newfind_surface_for_handle()method was added toForeignToplevelManagerStatefor the toplevel capture source manager.self.backend.with_primary_renderer()to access theGlesRenderer.Closes #1558