cmeissl/pixman-rs

Representation of image types

Closed this issue · 0 comments

Pixman defines different types of images.
Only the bits type can actually be used for composition, using any other type for composition results in a segfault.
This should be encoded in the safe wrapper.

Something like:

pub struct Bits;
pub struct Linear;
...

pub struct Image<'bits, Kind> {
    ptr: *mut ffi::pixman_image_t,
    _type: PhantomData<Kind>,
    _phantom: PhantomData<&'bits ()>,
}

impl<'bits> Image<'bits, Bits> {
  pub fn composite(&mut self, ...) {
     ...
  }
}

BUT image_type_t is not exposed in pixman.h and an implementation detail. And so far the only difference from an api point of view is the difference between an bits image and a non bits image. So maybe a better approach is to split the bits image and the rest.