@@ -14,10 +14,7 @@ use objc2_app_kit::{
1414} ;
1515use objc2_core_foundation:: { CFRetained , CFString , CGAffineTransform } ;
1616use objc2_core_graphics:: {
17- CGAffineTransformMake , CGColor , CGColorCreateGenericRGB , CGColorGetConstantColor , CGPath ,
18- CGPathAddArc , CGPathAddCurveToPoint , CGPathAddLineToPoint , CGPathCloseSubpath ,
19- CGPathCreateMutable , CGPathCreateWithEllipseInRect , CGPathCreateWithRect ,
20- CGPathCreateWithRoundedRect , CGPathGetBoundingBox , CGPathMoveToPoint , kCGColorClear,
17+ CGAffineTransformMake , CGColor , CGMutablePath as CGMutablePathRaw , CGPath , kCGColorClear,
2118 kCGColorWhite,
2219} ;
2320use objc2_foundation:: {
@@ -329,7 +326,7 @@ impl DrawingContext<'_> {
329326 if let Some ( clip) = clip {
330327 let mask_layer = CALayer :: new ( ) ;
331328 mask_layer. setFrame ( transform_rect ( image_rep. size ( ) , clip) ) ;
332- let white = CGColorGetConstantColor ( Some ( kCGColorWhite) ) ;
329+ let white = CGColor :: constant_color ( Some ( kCGColorWhite) ) ;
333330 mask_layer. setBackgroundColor ( white. as_deref ( ) ) ;
334331 source_layer. setMask ( Some ( & mask_layer) ) ;
335332 }
@@ -347,7 +344,7 @@ pub struct DrawingPath(CFRetained<objc2_core_graphics::CGMutablePath>);
347344
348345impl DrawingPath {
349346 fn bounding ( & self ) -> NSRect {
350- unsafe { CGPathGetBoundingBox ( Some ( & self . 0 ) ) }
347+ unsafe { CGPath :: bounding_box ( Some ( & self . 0 ) ) }
351348 }
352349}
353350
@@ -414,22 +411,22 @@ fn to_ptr<T>(v: Option<&T>) -> *const T {
414411}
415412
416413#[ repr( transparent) ]
417- struct CGMutablePath ( CFRetained < objc2_core_graphics :: CGMutablePath > ) ;
414+ struct CGMutablePath ( CFRetained < CGMutablePathRaw > ) ;
418415
419416impl CGMutablePath {
420417 pub fn new ( ) -> Self {
421- Self ( unsafe { CGPathCreateMutable ( ) } )
418+ Self ( unsafe { CGMutablePathRaw :: new ( ) } )
422419 }
423420
424421 pub fn move_to_point ( & mut self , transform : Option < & CGAffineTransform > , p : NSPoint ) {
425422 unsafe {
426- CGPathMoveToPoint ( Some ( & self . 0 ) , to_ptr ( transform) , p. x , p. y ) ;
423+ CGMutablePathRaw :: move_to_point ( Some ( & self . 0 ) , to_ptr ( transform) , p. x , p. y ) ;
427424 }
428425 }
429426
430427 pub fn line_to_point ( & mut self , transform : Option < & CGAffineTransform > , p : NSPoint ) {
431428 unsafe {
432- CGPathAddLineToPoint ( Some ( & self . 0 ) , to_ptr ( transform) , p. x , p. y ) ;
429+ CGMutablePathRaw :: add_line_to_point ( Some ( & self . 0 ) , to_ptr ( transform) , p. x , p. y ) ;
433430 }
434431 }
435432
@@ -443,7 +440,7 @@ impl CGMutablePath {
443440 clockwise : bool ,
444441 ) {
445442 unsafe {
446- CGPathAddArc (
443+ CGMutablePathRaw :: add_arc (
447444 Some ( & self . 0 ) ,
448445 to_ptr ( transform) ,
449446 center. x ,
@@ -464,7 +461,7 @@ impl CGMutablePath {
464461 p3 : NSPoint ,
465462 ) {
466463 unsafe {
467- CGPathAddCurveToPoint (
464+ CGMutablePathRaw :: add_curve_to_point (
468465 Some ( & self . 0 ) ,
469466 to_ptr ( transform) ,
470467 p1. x ,
@@ -479,7 +476,7 @@ impl CGMutablePath {
479476
480477 pub fn close ( & mut self ) {
481478 unsafe {
482- CGPathCloseSubpath ( Some ( & self . 0 ) ) ;
479+ CGMutablePathRaw :: close_subpath ( Some ( & self . 0 ) ) ;
483480 }
484481 }
485482}
@@ -532,7 +529,7 @@ fn path_arc(s: Size, rect: Rect, start: f64, end: f64, pie: bool) -> CGMutablePa
532529
533530fn path_ellipse ( s : Size , rect : Rect ) -> CFRetained < CGPath > {
534531 let rect = transform_rect ( s, rect) ;
535- unsafe { CGPathCreateWithEllipseInRect ( rect, null ( ) ) }
532+ unsafe { CGPath :: with_ellipse_in_rect ( rect, null ( ) ) }
536533}
537534
538535fn path_line ( s : Size , start : Point , end : Point ) -> CGMutablePath {
@@ -544,12 +541,12 @@ fn path_line(s: Size, start: Point, end: Point) -> CGMutablePath {
544541
545542fn path_rect ( s : Size , rect : Rect ) -> CFRetained < CGPath > {
546543 let rect = transform_rect ( s, rect) ;
547- unsafe { CGPathCreateWithRect ( rect, null ( ) ) }
544+ unsafe { CGPath :: with_rect ( rect, null ( ) ) }
548545}
549546
550547fn path_round_rect ( s : Size , rect : Rect , round : Size ) -> CFRetained < CGPath > {
551548 let rect = transform_rect ( s, rect) ;
552- unsafe { CGPathCreateWithRoundedRect ( rect, round. width , round. height , null ( ) ) }
549+ unsafe { CGPath :: with_rounded_rect ( rect, round. width , round. height , null ( ) ) }
553550}
554551
555552fn measure_str ( font : DrawingFont , pos : Point , text : & str ) -> ( Retained < NSAttributedString > , Rect ) {
@@ -604,7 +601,7 @@ fn create_attr_str(font: &DrawingFont, text: &str) -> Retained<NSAttributedStrin
604601
605602fn to_cgcolor ( c : Color ) -> CFRetained < CGColor > {
606603 unsafe {
607- CGColorCreateGenericRGB (
604+ CGColor :: new_generic_rgb (
608605 c. r as f64 / 255.0 ,
609606 c. g as f64 / 255.0 ,
610607 c. b as f64 / 255.0 ,
@@ -623,9 +620,9 @@ unsafe fn make_layer(
623620 stroke : & CFString ,
624621) -> Retained < CALayer > {
625622 let mask_layer = to_layer ( path) ;
626- let fill = CGColorGetConstantColor ( Some ( fill) ) ;
623+ let fill = CGColor :: constant_color ( Some ( fill) ) ;
627624 mask_layer. setFillColor ( fill. as_deref ( ) ) ;
628- let stroke = CGColorGetConstantColor ( Some ( stroke) ) ;
625+ let stroke = CGColor :: constant_color ( Some ( stroke) ) ;
629626 mask_layer. setStrokeColor ( stroke. as_deref ( ) ) ;
630627 mask_layer. setLineWidth ( width) ;
631628 let mut brush_rect = transform_rect ( size, rect) ;
0 commit comments