-
-
Notifications
You must be signed in to change notification settings - Fork 198
Add gsk::RenderReplay bindings manually #2184
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
A6GibKm
wants to merge
2
commits into
gtk-rs:main
Choose a base branch
from
A6GibKm:render-replay-bindings
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+299
−0
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,289 @@ | ||
| // Take a look at the license at the top of the repository in the LICENSE file. | ||
|
|
||
| use crate::{ffi, RenderNode}; | ||
| use glib::{prelude::*, translate::*}; | ||
| use std::boxed::Box as Box_; | ||
|
|
||
| #[repr(C)] | ||
| #[doc(alias = "GskRenderReplay")] | ||
| pub struct RenderReplay(std::ptr::NonNull<ffi::GskRenderReplay>); | ||
|
|
||
| impl Drop for RenderReplay { | ||
| fn drop(&mut self) { | ||
| unsafe { | ||
| ffi::gsk_render_replay_free(self.0.as_ptr()); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| impl RenderReplay { | ||
| #[doc(alias = "gsk_render_replay_default")] | ||
| #[allow(clippy::should_implement_trait)] | ||
| pub fn default(&self, node: impl AsRef<RenderNode>) -> Option<RenderNode> { | ||
| unsafe { | ||
| from_glib_full(ffi::gsk_render_replay_default( | ||
| self.0.as_ptr(), | ||
| node.as_ref().to_glib_none().0, | ||
| )) | ||
| } | ||
| } | ||
|
|
||
| #[doc(alias = "gsk_render_replay_filter_font")] | ||
| pub fn filter_font(&self, font: &impl IsA<pango::Font>) -> pango::Font { | ||
| unsafe { | ||
| from_glib_full(ffi::gsk_render_replay_filter_font( | ||
| self.0.as_ptr(), | ||
| font.as_ref().to_glib_none().0, | ||
| )) | ||
| } | ||
| } | ||
|
|
||
| #[doc(alias = "gsk_render_replay_filter_node")] | ||
| pub fn filter_node(&self, node: impl AsRef<RenderNode>) -> Option<RenderNode> { | ||
| unsafe { | ||
| from_glib_full(ffi::gsk_render_replay_filter_node( | ||
| self.0.as_ptr(), | ||
| node.as_ref().to_glib_none().0, | ||
| )) | ||
| } | ||
| } | ||
|
|
||
| #[doc(alias = "gsk_render_replay_filter_texture")] | ||
| pub fn filter_texture(&self, texture: &impl IsA<gdk::Texture>) -> gdk::Texture { | ||
| unsafe { | ||
| from_glib_full(ffi::gsk_render_replay_filter_texture( | ||
| self.0.as_ptr(), | ||
| texture.as_ref().to_glib_none().0, | ||
| )) | ||
| } | ||
| } | ||
|
|
||
| #[doc(alias = "gsk_render_replay_foreach_node")] | ||
| pub fn foreach_node(&self, node: impl AsRef<RenderNode>) { | ||
| unsafe { | ||
| ffi::gsk_render_replay_foreach_node(self.0.as_ptr(), node.as_ref().to_glib_none().0); | ||
| } | ||
| } | ||
|
|
||
| #[doc(alias = "gsk_render_replay_set_font_filter")] | ||
| pub fn set_font_filter<P: Fn(&RenderReplay, &pango::Font) -> pango::Font + 'static>( | ||
| &mut self, | ||
| filter: P, | ||
| ) { | ||
| let filter_data: Box_<P> = Box_::new(filter); | ||
| unsafe extern "C" fn filter_func< | ||
| P: Fn(&RenderReplay, &pango::Font) -> pango::Font + 'static, | ||
| >( | ||
| replay: *mut ffi::GskRenderReplay, | ||
| font: *mut pango::ffi::PangoFont, | ||
| user_data: glib::ffi::gpointer, | ||
| ) -> *mut pango::ffi::PangoFont { | ||
| let replay = RenderReplay(std::ptr::NonNull::new_unchecked(replay)); | ||
| let font = from_glib_borrow(font); | ||
| let callback = &*(user_data as *mut P); | ||
| (*callback)(&replay, &font).into_glib_ptr() | ||
| } | ||
| let filter = Some(filter_func::<P> as _); | ||
| unsafe extern "C" fn user_destroy_func< | ||
| P: Fn(&RenderReplay, &pango::Font) -> pango::Font + 'static, | ||
| >( | ||
| data: glib::ffi::gpointer, | ||
| ) { | ||
| let _callback = Box_::from_raw(data as *mut P); | ||
| } | ||
| let destroy_call3 = Some(user_destroy_func::<P> as _); | ||
| let super_callback0: Box_<P> = filter_data; | ||
| unsafe { | ||
| ffi::gsk_render_replay_set_font_filter( | ||
| self.0.as_mut(), | ||
| filter, | ||
| Box_::into_raw(super_callback0) as *mut _, | ||
| destroy_call3, | ||
| ); | ||
| } | ||
| } | ||
|
|
||
| #[doc(alias = "gsk_render_replay_set_font_filter")] | ||
| #[doc(alias = "set_font_filter")] | ||
| pub fn unset_font_filter(&mut self) { | ||
| unsafe { | ||
| ffi::gsk_render_replay_set_font_filter( | ||
| self.0.as_mut(), | ||
| None, | ||
| std::ptr::null_mut(), | ||
| None, | ||
| ) | ||
| } | ||
| } | ||
|
|
||
| #[doc(alias = "gsk_render_replay_set_node_filter")] | ||
| pub fn set_node_filter<P: Fn(&RenderReplay, &RenderNode) -> Option<RenderNode> + 'static>( | ||
| &mut self, | ||
| filter: P, | ||
| ) { | ||
| let filter_data: Box_<P> = Box_::new(filter); | ||
| unsafe extern "C" fn filter_func< | ||
| P: Fn(&RenderReplay, &RenderNode) -> Option<RenderNode> + 'static, | ||
| >( | ||
| replay: *mut ffi::GskRenderReplay, | ||
| node: *mut ffi::GskRenderNode, | ||
| user_data: glib::ffi::gpointer, | ||
| ) -> *mut ffi::GskRenderNode { | ||
| let replay = RenderReplay(std::ptr::NonNull::new_unchecked(replay)); | ||
| let node = from_glib_borrow(node); | ||
| let callback = &*(user_data as *mut P); | ||
| (*callback)(&replay, &node).into_glib_ptr() | ||
| } | ||
| let filter = Some(filter_func::<P> as _); | ||
| unsafe extern "C" fn user_destroy_func< | ||
| P: Fn(&RenderReplay, &RenderNode) -> Option<RenderNode> + 'static, | ||
| >( | ||
| data: glib::ffi::gpointer, | ||
| ) { | ||
| let _callback = Box_::from_raw(data as *mut P); | ||
| } | ||
| let destroy_call3 = Some(user_destroy_func::<P> as _); | ||
| let super_callback0: Box_<P> = filter_data; | ||
| unsafe { | ||
| ffi::gsk_render_replay_set_node_filter( | ||
| self.0.as_mut(), | ||
| filter, | ||
| Box_::into_raw(super_callback0) as *mut _, | ||
| destroy_call3, | ||
| ); | ||
| } | ||
| } | ||
|
|
||
| #[doc(alias = "gsk_render_replay_set_node_filter")] | ||
| #[doc(alias = "set_node_filter")] | ||
| pub fn unset_node_filter(&mut self) { | ||
| unsafe { | ||
| ffi::gsk_render_replay_set_node_filter( | ||
| self.0.as_mut(), | ||
| None, | ||
| std::ptr::null_mut(), | ||
| None, | ||
| ) | ||
| } | ||
| } | ||
|
|
||
| #[doc(alias = "gsk_render_replay_set_node_foreach")] | ||
| pub fn set_node_foreach<P: Fn(&RenderReplay, &RenderNode) -> glib::ControlFlow + 'static>( | ||
| &mut self, | ||
| foreach: P, | ||
| ) { | ||
| let foreach_data: Box_<P> = Box_::new(foreach); | ||
| unsafe extern "C" fn foreach_func< | ||
| P: Fn(&RenderReplay, &RenderNode) -> glib::ControlFlow + 'static, | ||
| >( | ||
| replay: *mut ffi::GskRenderReplay, | ||
| node: *mut ffi::GskRenderNode, | ||
| user_data: glib::ffi::gpointer, | ||
| ) -> glib::ffi::gboolean { | ||
| let replay = RenderReplay(std::ptr::NonNull::new_unchecked(replay)); | ||
| let node = from_glib_borrow(node); | ||
| let callback = &*(user_data as *mut P); | ||
| (*callback)(&replay, &node).into_glib() | ||
| } | ||
| let foreach = Some(foreach_func::<P> as _); | ||
| unsafe extern "C" fn user_destroy_func< | ||
| P: Fn(&RenderReplay, &RenderNode) -> glib::ControlFlow + 'static, | ||
| >( | ||
| data: glib::ffi::gpointer, | ||
| ) { | ||
| let _callback = Box_::from_raw(data as *mut P); | ||
| } | ||
| let destroy_call3 = Some(user_destroy_func::<P> as _); | ||
| let super_callback0: Box_<P> = foreach_data; | ||
| unsafe { | ||
| ffi::gsk_render_replay_set_node_foreach( | ||
| self.0.as_mut(), | ||
| foreach, | ||
| Box_::into_raw(super_callback0) as *mut _, | ||
| destroy_call3, | ||
| ); | ||
| } | ||
| } | ||
|
|
||
| #[doc(alias = "gsk_render_replay_set_node_foreach")] | ||
| #[doc(alias = "set_node_foreach")] | ||
| pub fn unset_foreach_node(&mut self) { | ||
| unsafe { | ||
| ffi::gsk_render_replay_set_node_foreach( | ||
| self.0.as_mut(), | ||
| None, | ||
| std::ptr::null_mut(), | ||
| None, | ||
| ) | ||
| } | ||
| } | ||
|
|
||
| #[doc(alias = "gsk_render_replay_set_texture_filter")] | ||
| pub fn set_texture_filter<P: Fn(&RenderReplay, &gdk::Texture) -> gdk::Texture + 'static>( | ||
| &mut self, | ||
| filter: P, | ||
| ) { | ||
| let filter_data: Box_<P> = Box_::new(filter); | ||
| unsafe extern "C" fn filter_func< | ||
| P: Fn(&RenderReplay, &gdk::Texture) -> gdk::Texture + 'static, | ||
| >( | ||
| replay: *mut ffi::GskRenderReplay, | ||
| texture: *mut gdk::ffi::GdkTexture, | ||
| user_data: glib::ffi::gpointer, | ||
| ) -> *mut gdk::ffi::GdkTexture { | ||
| let replay = RenderReplay(std::ptr::NonNull::new_unchecked(replay)); | ||
| let texture = from_glib_borrow(texture); | ||
| let callback = &*(user_data as *mut P); | ||
| (*callback)(&replay, &texture).into_glib_ptr() | ||
| } | ||
| let filter = Some(filter_func::<P> as _); | ||
| unsafe extern "C" fn user_destroy_func< | ||
| P: Fn(&RenderReplay, &gdk::Texture) -> gdk::Texture + 'static, | ||
| >( | ||
| data: glib::ffi::gpointer, | ||
| ) { | ||
| let _callback = Box_::from_raw(data as *mut P); | ||
| } | ||
| let destroy_call3 = Some(user_destroy_func::<P> as _); | ||
| let super_callback0: Box_<P> = filter_data; | ||
| unsafe { | ||
| ffi::gsk_render_replay_set_texture_filter( | ||
| self.0.as_mut(), | ||
| filter, | ||
| Box_::into_raw(super_callback0) as *mut _, | ||
| destroy_call3, | ||
| ); | ||
| } | ||
| } | ||
|
|
||
| #[doc(alias = "gsk_render_replay_set_texture_filter")] | ||
| #[doc(alias = "set_texture_filter")] | ||
| pub fn unset_texture_filter(&mut self) { | ||
| unsafe { | ||
| ffi::gsk_render_replay_set_texture_filter( | ||
| self.0.as_mut(), | ||
| None, | ||
| std::ptr::null_mut(), | ||
| None, | ||
| ) | ||
| } | ||
| } | ||
|
|
||
| #[doc(alias = "gsk_render_replay_new")] | ||
| pub fn new() -> RenderReplay { | ||
| assert_initialized_main_thread!(); | ||
| unsafe { | ||
| RenderReplay(std::ptr::NonNull::new_unchecked( | ||
| ffi::gsk_render_replay_new(), | ||
| )) | ||
| } | ||
| } | ||
| } | ||
|
|
||
| #[cfg(feature = "v4_22")] | ||
| #[cfg_attr(docsrs, doc(cfg(feature = "v4_22")))] | ||
| impl Default for RenderReplay { | ||
| fn default() -> Self { | ||
| Self::new() | ||
| } | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.