| 1 |
// Take a look at the license at the top of the repository in the LICENSE file. |
| 2 |
|
| 3 |
use std::{fmt, ops::Deref}; |
| 4 |
|
| 5 |
use ffi::CGContextRef; |
| 6 |
#[cfg(feature = "use_glib")] |
| 7 |
use glib::translate::*; |
| 8 |
|
| 9 |
use crate::{Error, Format, Surface, SurfaceType, ffi}; |
| 10 |
|
| 11 |
declare_surface!(QuartzSurface, SurfaceType::Quartz); |
| 12 |
|
| 13 |
impl QuartzSurface { |
| 14 |
#[doc(alias = "cairo_quartz_surface_create")] |
| 15 |
pub fn create(format: Format, width: u32, height: u32) -> Result<QuartzSurface, Error> { |
| 16 |
unsafe { |
| 17 |
Self::from_raw_full(ffi::cairo_quartz_surface_create( |
| 18 |
format.into(), |
| 19 |
width, |
| 20 |
height, |
| 21 |
)) |
| 22 |
} |
| 23 |
} |
| 24 |
|
| 25 |
#[doc(alias = "cairo_quartz_surface_create_for_cg_context")] |
| 26 |
pub fn create_for_cg_context( |
| 27 |
cg_context: CGContextRef, |
| 28 |
width: u32, |
| 29 |
height: u32, |
| 30 |
) -> Result<QuartzSurface, Error> { |
| 31 |
unsafe { |
| 32 |
Self::from_raw_full(ffi::cairo_quartz_surface_create_for_cg_context( |
| 33 |
cg_context, width, height, |
| 34 |
)) |
| 35 |
} |
| 36 |
} |
| 37 |
|
| 38 |
#[doc(alias = "cairo_quartz_surface_get_cg_context")] |
| 39 |
#[doc(alias = "get_cg_context")] |
| 40 |
pub fn cg_context(&self) -> CGContextRef { |
| 41 |
unsafe { ffi::cairo_quartz_surface_get_cg_context(self.to_raw_none()) } |
| 42 |
} |
| 43 |
} |