dummy-rustwlc 0.6.2

A dummy version of the functions defined in rust-wlc, to be used in testing and for travis builds
Documentation
//! Contains dummy definitions for wlc render functions (wlc-render.h)

use libc::{c_void, uint32_t, uintptr_t};
use super::types::{Geometry};

/// Number of bits per pixel (RGBA8888)
pub const BITS_PER_PIXEL: u32 = 32;

#[repr(C)]
#[derive(Debug, Clone, Copy, Eq, PartialEq)]
/// Allowed pixel formats
pub enum wlc_pixel_format {
    /// RGBA8888 format
    WLC_RGBA8888
}

#[repr(C)]
#[derive(Debug, Clone, Copy, Eq, PartialEq)]
/// Enabled renderers
pub enum wlc_renderer {
    /// Render using GLE
    WLC_RENDERER_GLES2,
    /// Don't render (headless)
    WLC_NO_RENDERER
}

#[allow(missing_docs)]
#[repr(C)]
#[derive(Debug, Clone, Copy, Eq, PartialEq)]
pub enum wlc_surface_format {
    SURFACE_RGB,
    SURFACE_RGBA,
    SURFACE_EGL,
    SURFACE_Y_UV,
    SURFACE_Y_U_V,
    SURFACE_Y_XUXV,
}


/// Write pixel data with the specific format to output's framebuffer.
/// If the geometry is out of bounds, it will be automatically clamped.
///
/// # Unsafety
/// The data is converted to a *mut c_void and then passed to C to read.
/// The size of it should be the stride of the geometry * height of the geometry.
pub fn write_pixels(_format: wlc_pixel_format, _geometry: Geometry, _data: &[u8]) {
}

/// Reads the pixels at the specified geometry
pub fn read_pixels(_format: wlc_pixel_format, _geometry: Geometry) -> ([u8; 9], Vec<u8>) {
    unimplemented!()
}

/// Calculates the stride for ARGB32 encoded buffers
pub fn calculate_stride(width: u32) -> u32 {
    // function stolen from CAIRO_STRIDE_FOR_WIDTH macro in carioint.h
    // can be found in the most recent version of the cairo source
    let stride_alignment = ::std::mem::size_of::<u32>() as u32;
    ((BITS_PER_PIXEL * width + 7 ) / 8 + (stride_alignment - 1))  & (stride_alignment.overflowing_neg().0)
}