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