dummy_rustwlc/render.rs
1//! Contains dummy definitions for wlc render functions (wlc-render.h)
2extern "C" {
3 /// Write pixel data with the specific format to output's framebuffer.
4 /// If the geometry is out of bounds, it will be automatically clamped.
5 pub fn wlc_pixels_write(format: wlc_pixel_format, geometry: *const Geometry, data: *const c_void);
6
7 pub fn wlc_pixels_read(format: wlc_pixel_format,
8 geometry: *const Geometry,
9 out_geo: *mut Geometry,
10 data: *mut c_void);
11
12 /** Renders surface. */
13 pub fn wlc_surface_render(surface: uintptr_t, geometry: *const Geometry);
14
15 /// Read pixel data from output's framebuffer.
16 /// If theif output is currently rendering, it will render immediately after.
17 pub fn wlc_output_schedule_render(output: uintptr_t) -> wlc_renderer;
18
19 /// Adds frame callbacks of the given surface for the next output frame.
20 /// It applies recursively to all subsurfaces.
21 /// Useful when the compositor creates custom animations which require disabling internal rendering,
22 /// but still need to update the surface textures (for ex. video players).
23 pub fn wlc_surface_flush_frame_callbacks(surface: uintptr_t);
24
25 /// Returns currently active renderer on the given output
26 pub fn wlc_output_get_renderer(output: uintptr_t) -> wlc_renderer;
27
28 /// Fills out_textures[] with the textures of a surface. Returns false if surface is invalid.
29 /// Array must have at least 3 elements and should be refreshed at each frame.
30 /// Note that these are not only OpenGL textures but rather render-specific.
31 /// For more info what they are check the renderer's source code */
32 pub fn wlc_surface_get_textures(surface: uintptr_t,
33 out_textures: *mut uint32_t,
34 out_format: *mut wlc_surface_format);
35
36 pub fn wlc_output_set_gamma(output: uintptr_t,
37 size: u16,
38 red: *mut u16,
39 green: *mut u16,
40 blue: *mut u16);
41
42 pub fn wlc_output_get_gamma_size(output: uintptr_t) -> u16 ;
43}
44use libc::{c_void, uint32_t, uintptr_t};
45use super::types::{Geometry};
46
47/// Number of bits per pixel (RGBA8888)
48pub const BITS_PER_PIXEL: u32 = 32;
49
50#[repr(C)]
51#[derive(Debug, Clone, Copy, Eq, PartialEq)]
52/// Allowed pixel formats
53pub enum wlc_pixel_format {
54 /// RGBA8888 format
55 WLC_RGBA8888
56}
57
58#[repr(C)]
59#[derive(Debug, Clone, Copy, Eq, PartialEq)]
60/// Enabled renderers
61pub enum wlc_renderer {
62 /// Render using GLE
63 WLC_RENDERER_GLES2,
64 /// Don't render (headless)
65 WLC_NO_RENDERER
66}
67
68#[allow(missing_docs)]
69#[repr(C)]
70#[derive(Debug, Clone, Copy, Eq, PartialEq)]
71pub enum wlc_surface_format {
72 SURFACE_RGB,
73 SURFACE_RGBA,
74 SURFACE_EGL,
75 SURFACE_Y_UV,
76 SURFACE_Y_U_V,
77 SURFACE_Y_XUXV,
78}
79
80
81/// Write pixel data with the specific format to output's framebuffer.
82/// If the geometry is out of bounds, it will be automatically clamped.
83///
84/// # Unsafety
85/// The data is converted to a *mut c_void and then passed to C to read.
86/// The size of it should be the stride of the geometry * height of the geometry.
87pub fn write_pixels(_format: wlc_pixel_format, _geometry: Geometry, _data: &[u8]) {
88}
89
90/// Reads the pixels at the specified geometry
91pub fn read_pixels(_format: wlc_pixel_format, _geometry: Geometry) -> ([u8; 9], Vec<u8>) {
92 unimplemented!()
93}
94
95/// Calculates the stride for ARGB32 encoded buffers
96pub fn calculate_stride(width: u32) -> u32 {
97 // function stolen from CAIRO_STRIDE_FOR_WIDTH macro in carioint.h
98 // can be found in the most recent version of the cairo source
99 let stride_alignment = ::std::mem::size_of::<u32>() as u32;
100 ((BITS_PER_PIXEL * width + 7 ) / 8 + (stride_alignment - 1)) & (stride_alignment.overflowing_neg().0)
101}