@@ -24,41 +24,14 @@ impl GdkCairoSurfaceExt for cairo::Surface {
24
24
25
25
// rustdoc-stripper-ignore-next
26
26
/// Trait containing integration methods with [`cairo::Context`].
27
- pub trait GdkCairoContextExt {
27
+ pub trait GdkCairoContextExt : sealed :: Sealed {
28
28
// rustdoc-stripper-ignore-next
29
29
/// # Safety
30
30
///
31
31
/// It's the responsibility of the caller to ensure that source
32
32
/// is a valid GL resource.
33
33
#[ doc( alias = "gdk_cairo_draw_from_gl" ) ]
34
34
#[ allow( clippy:: too_many_arguments) ]
35
- unsafe fn draw_from_gl (
36
- & self ,
37
- surface : & Surface ,
38
- source : i32 ,
39
- source_type : i32 ,
40
- buffer_scale : i32 ,
41
- x : i32 ,
42
- y : i32 ,
43
- width : i32 ,
44
- height : i32 ,
45
- ) ;
46
-
47
- #[ doc( alias = "gdk_cairo_set_source_rgba" ) ]
48
- #[ doc( alias = "set_source_rgba" ) ]
49
- fn set_source_color ( & self , rgba : & RGBA ) ;
50
-
51
- #[ doc( alias = "gdk_cairo_set_source_pixbuf" ) ]
52
- fn set_source_pixbuf ( & self , pixbuf : & Pixbuf , x : f64 , y : f64 ) ;
53
-
54
- #[ doc( alias = "gdk_cairo_rectangle" ) ]
55
- fn add_rectangle ( & self , rectangle : & Rectangle ) ;
56
-
57
- #[ doc( alias = "gdk_cairo_region" ) ]
58
- fn add_region ( & self , region : & Region ) ;
59
- }
60
-
61
- impl GdkCairoContextExt for Context {
62
35
unsafe fn draw_from_gl (
63
36
& self ,
64
37
surface : & Surface ,
@@ -72,7 +45,7 @@ impl GdkCairoContextExt for Context {
72
45
) {
73
46
skip_assert_initialized ! ( ) ;
74
47
ffi:: gdk_cairo_draw_from_gl (
75
- mut_override ( self . to_glib_none ( ) . 0 ) ,
48
+ self . to_raw ( ) ,
76
49
surface. to_glib_none ( ) . 0 ,
77
50
source,
78
51
source_type,
@@ -84,27 +57,48 @@ impl GdkCairoContextExt for Context {
84
57
) ;
85
58
}
86
59
60
+ #[ doc( alias = "gdk_cairo_set_source_rgba" ) ]
61
+ #[ doc( alias = "set_source_rgba" ) ]
87
62
fn set_source_color ( & self , rgba : & RGBA ) {
88
63
unsafe {
89
- ffi:: gdk_cairo_set_source_rgba ( self . to_glib_none ( ) . 0 , rgba. to_glib_none ( ) . 0 ) ;
64
+ ffi:: gdk_cairo_set_source_rgba ( self . to_raw ( ) , rgba. to_glib_none ( ) . 0 ) ;
90
65
}
91
66
}
92
67
68
+ #[ doc( alias = "gdk_cairo_set_source_pixbuf" ) ]
93
69
fn set_source_pixbuf ( & self , pixbuf : & Pixbuf , x : f64 , y : f64 ) {
94
70
unsafe {
95
- ffi:: gdk_cairo_set_source_pixbuf ( self . to_glib_none ( ) . 0 , pixbuf. to_glib_none ( ) . 0 , x, y) ;
71
+ ffi:: gdk_cairo_set_source_pixbuf ( self . to_raw ( ) , pixbuf. to_glib_none ( ) . 0 , x, y) ;
96
72
}
97
73
}
98
74
75
+ #[ doc( alias = "gdk_cairo_rectangle" ) ]
99
76
fn add_rectangle ( & self , rectangle : & Rectangle ) {
100
77
unsafe {
101
- ffi:: gdk_cairo_rectangle ( self . to_glib_none ( ) . 0 , rectangle. to_glib_none ( ) . 0 ) ;
78
+ ffi:: gdk_cairo_rectangle ( self . to_raw ( ) , rectangle. to_glib_none ( ) . 0 ) ;
102
79
}
103
80
}
104
81
82
+ #[ doc( alias = "gdk_cairo_region" ) ]
105
83
fn add_region ( & self , region : & Region ) {
106
84
unsafe {
107
- ffi:: gdk_cairo_region ( self . to_glib_none ( ) . 0 , region. to_glib_none ( ) . 0 ) ;
85
+ ffi:: gdk_cairo_region ( self . to_raw ( ) , region. to_glib_none ( ) . 0 ) ;
86
+ }
87
+ }
88
+ }
89
+
90
+ impl GdkCairoContextExt for Context { }
91
+
92
+ mod sealed {
93
+ use cairo:: { ffi:: cairo_t, Context } ;
94
+
95
+ pub trait Sealed {
96
+ fn to_raw ( & self ) -> * mut cairo_t ;
97
+ }
98
+
99
+ impl Sealed for Context {
100
+ fn to_raw ( & self ) -> * mut cairo_t {
101
+ self . to_raw_none ( )
108
102
}
109
103
}
110
104
}
0 commit comments