1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
use std::convert::TryFrom;
use std::fmt;
use std::ops::Deref;
use enums::{Format, SurfaceType};
use ffi;
#[cfg(feature = "use_glib")]
use glib::translate::*;
use surface::Surface;
use Status;
use ffi::CGContextRef;
declare_surface!(QuartzSurface, SurfaceType::Quartz);
impl QuartzSurface {
pub fn create(format: Format, width: u32, height: u32) -> Result<QuartzSurface, Status> {
unsafe {
Self::from_raw_full(ffi::cairo_quartz_surface_create(
format.into(),
width,
height,
))
}
}
pub fn create_for_cg_context(
cg_context: CGContextRef,
width: u32,
height: u32,
) -> Result<QuartzSurface, Status> {
unsafe {
Self::from_raw_full(ffi::cairo_quartz_surface_create_for_cg_context(
cg_context, width, height,
))
}
}
pub fn get_cg_context(&self) -> CGContextRef {
unsafe { ffi::cairo_quartz_surface_get_cg_context(self.to_raw_none()) }
}
}