{-# LANGUAGE TypeApplications #-}


-- | Copyright  : Will Thompson and Iñaki García Etxebarria
-- License    : LGPL-2.1
-- Maintainer : Iñaki García Etxebarria
-- 
-- A facility to replay a t'GI.Gsk.Objects.RenderNode.RenderNode' and its children, potentially
-- modifying them.
-- 
-- This is a utility tool to walk a rendernode tree. The most powerful way
-- is to provide a function via 'GI.Gsk.Structs.RenderReplay.renderReplaySetNodeFilter'
-- to filter each individual node and then run
-- 'GI.Gsk.Structs.RenderReplay.renderReplayFilterNode' on the nodes you want to filter.
-- 
-- If you want to just walk the node tree and extract information
-- without any modifications, you can also use 'GI.Gsk.Objects.RenderNode.renderNodeGetChildren'.
-- 
-- Here is a little example application that redacts text in a node file:
-- 
-- 
-- 	
-- >#include <gtk/gtk.h>
-- >
-- >static GskRenderNode *
-- >redact_nodes (GskRenderReplay *replay,
-- >              GskRenderNode   *node,
-- >              gpointer         user_data)
-- >{
-- >  GskRenderNode *result;
-- >
-- >  if (gsk_render_node_get_node_type (node) == GSK_TEXT_NODE)
-- >    {
-- >      graphene_rect_t bounds;
-- >      const GdkRGBA *color;
-- >
-- >      gsk_render_node_get_bounds (node, &bounds);
-- >      color = gsk_text_node_get_color (node);
-- >
-- >      result = gsk_color_node_new (color, &bounds);
-- >    }
-- >  else
-- >    {
-- >      result = gsk_render_replay_default (replay, node);
-- >    }
-- >
-- >  return result;
-- >}
-- >
-- >int
-- >main (int argc, char *argv[])
-- >{
-- >  GFile *file;
-- >  GBytes *bytes;
-- >  GskRenderNode *result, *node;
-- >  GskRenderReplay *replay;
-- >
-- >  gtk_init ();
-- >
-- >  if (argc != 3)
-- >    {
-- >      g_print ("usage: %s INFILE OUTFILE\n", argv[0]);
-- >      return 0;
-- >    }
-- >
-- >  file = g_file_new_for_commandline_arg (argv[1]);
-- >  bytes = g_file_load_bytes (file, NULL, NULL, NULL);
-- >  g_object_unref (file);
-- >  if (bytes == NULL)
-- >    return 1;
-- >
-- >  node = gsk_render_node_deserialize (bytes, NULL, NULL);
-- >  g_bytes_unref (bytes);
-- >  if (node == NULL)
-- >    return 1;
-- >
-- >  replay = gsk_render_replay_new ();
-- >  gsk_render_replay_set_node_filter (replay, redact_nodes, NULL, NULL);
-- >  result = gsk_render_replay_filter_node (replay, node);
-- >  gsk_render_replay_free (replay);
-- >
-- >  if (!gsk_render_node_write_to_file (result, argv[2], NULL))
-- >    return 1;
-- >
-- >  gsk_render_node_unref (result);
-- >  gsk_render_node_unref (node);
-- >
-- >  return 0;
-- >}
-- 
-- 
-- /Since: 4.22/

#if (MIN_VERSION_haskell_gi_overloading(1,0,0) && !defined(__HADDOCK_VERSION__))
#define ENABLE_OVERLOADING
#endif

module GI.Gsk.Structs.RenderReplay
    ( 

-- * Exported types
    RenderReplay(..)                        ,


 -- * Methods
-- | 
-- 
--  === __Click to display all available methods, including inherited ones__
-- ==== Methods
-- [default]("GI.Gsk.Structs.RenderReplay#g:method:default"), [filterFont]("GI.Gsk.Structs.RenderReplay#g:method:filterFont"), [filterNode]("GI.Gsk.Structs.RenderReplay#g:method:filterNode"), [filterTexture]("GI.Gsk.Structs.RenderReplay#g:method:filterTexture"), [free]("GI.Gsk.Structs.RenderReplay#g:method:free").
-- 
-- ==== Getters
-- /None/.
-- 
-- ==== Setters
-- [setFontFilter]("GI.Gsk.Structs.RenderReplay#g:method:setFontFilter"), [setNodeFilter]("GI.Gsk.Structs.RenderReplay#g:method:setNodeFilter"), [setTextureFilter]("GI.Gsk.Structs.RenderReplay#g:method:setTextureFilter").

#if defined(ENABLE_OVERLOADING)
    ResolveRenderReplayMethod               ,
#endif

-- ** default #method:default#

#if defined(ENABLE_OVERLOADING)
    RenderReplayDefaultMethodInfo           ,
#endif
    renderReplayDefault                     ,


-- ** filterFont #method:filterFont#

#if defined(ENABLE_OVERLOADING)
    RenderReplayFilterFontMethodInfo        ,
#endif
    renderReplayFilterFont                  ,


-- ** filterNode #method:filterNode#

#if defined(ENABLE_OVERLOADING)
    RenderReplayFilterNodeMethodInfo        ,
#endif
    renderReplayFilterNode                  ,


-- ** filterTexture #method:filterTexture#

#if defined(ENABLE_OVERLOADING)
    RenderReplayFilterTextureMethodInfo     ,
#endif
    renderReplayFilterTexture               ,


-- ** free #method:free#

#if defined(ENABLE_OVERLOADING)
    RenderReplayFreeMethodInfo              ,
#endif
    renderReplayFree                        ,


-- ** new #method:new#

    renderReplayNew                         ,


-- ** setFontFilter #method:setFontFilter#

#if defined(ENABLE_OVERLOADING)
    RenderReplaySetFontFilterMethodInfo     ,
#endif
    renderReplaySetFontFilter               ,


-- ** setNodeFilter #method:setNodeFilter#

#if defined(ENABLE_OVERLOADING)
    RenderReplaySetNodeFilterMethodInfo     ,
#endif
    renderReplaySetNodeFilter               ,


-- ** setTextureFilter #method:setTextureFilter#

#if defined(ENABLE_OVERLOADING)
    RenderReplaySetTextureFilterMethodInfo  ,
#endif
    renderReplaySetTextureFilter            ,




    ) where

import Data.GI.Base.ShortPrelude
import qualified Data.GI.Base.ShortPrelude as SP
import qualified Data.GI.Base.Overloading as O
import qualified Prelude as P

import qualified Data.GI.Base.Attributes as GI.Attributes
import qualified Data.GI.Base.BasicTypes as B.Types
import qualified Data.GI.Base.ManagedPtr as B.ManagedPtr
import qualified Data.GI.Base.GArray as B.GArray
import qualified Data.GI.Base.GClosure as B.GClosure
import qualified Data.GI.Base.GError as B.GError
import qualified Data.GI.Base.GHashTable as B.GHT
import qualified Data.GI.Base.GVariant as B.GVariant
import qualified Data.GI.Base.GValue as B.GValue
import qualified Data.GI.Base.GParamSpec as B.GParamSpec
import qualified Data.GI.Base.CallStack as B.CallStack
import qualified Data.GI.Base.Properties as B.Properties
import qualified Data.GI.Base.Signals as B.Signals
import qualified Control.Monad.IO.Class as MIO
import qualified Data.Coerce as Coerce
import qualified Data.Text as T
import qualified Data.Kind as DK
import qualified Data.ByteString.Char8 as B
import qualified Data.Map as Map
import qualified Foreign.Ptr as FP
import qualified GHC.OverloadedLabels as OL
import qualified GHC.Records as R
import qualified Data.Word as DW
import qualified Data.Int as DI
import qualified System.Posix.Types as SPT
import qualified Foreign.C.Types as FCT

-- Workaround for https://gitlab.haskell.org/ghc/ghc/-/issues/23392
#if MIN_VERSION_base(4,18,0)
import qualified GI.Cairo.Structs.Context as Cairo.Context
import qualified GI.GLib.Callbacks as GLib.Callbacks
import qualified GI.GLib.Structs.Bytes as GLib.Bytes
import qualified GI.Gdk.Objects.Texture as Gdk.Texture
import qualified GI.Graphene.Structs.Rect as Graphene.Rect
import qualified GI.Gsk.Callbacks as Gsk.Callbacks
import {-# SOURCE #-} qualified GI.Gsk.Enums as Gsk.Enums
import {-# SOURCE #-} qualified GI.Gsk.Objects.RenderNode as Gsk.RenderNode
import qualified GI.Pango.Objects.Font as Pango.Font

#else
import qualified GI.GLib.Callbacks as GLib.Callbacks
import qualified GI.Gdk.Objects.Texture as Gdk.Texture
import qualified GI.Gsk.Callbacks as Gsk.Callbacks
import {-# SOURCE #-} qualified GI.Gsk.Objects.RenderNode as Gsk.RenderNode
import qualified GI.Pango.Objects.Font as Pango.Font

#endif

-- | Memory-managed wrapper type.
newtype RenderReplay = RenderReplay (SP.ManagedPtr RenderReplay)
    deriving (Eq)

instance SP.ManagedPtrNewtype RenderReplay where
    toManagedPtr (RenderReplay p) = p

-- XXX Wrapping a foreign struct/union with no known destructor or size, leak?
instance BoxedPtr RenderReplay where
    boxedPtrCopy = return
    boxedPtrFree = \_x -> return ()


#if defined(ENABLE_OVERLOADING)
instance O.HasAttributeList RenderReplay
type instance O.AttributeList RenderReplay = RenderReplayAttributeList
type RenderReplayAttributeList = ('[ ] :: [(Symbol, DK.Type)])
#endif

-- method RenderReplay::new
-- method type : Constructor
-- Args: []
-- Lengths: []
-- returnType: Just
--               (TInterface Name { namespace = "Gsk" , name = "RenderReplay" })
-- throws : False
-- Skip return : False

foreign import ccall "gsk_render_replay_new" gsk_render_replay_new :: 
    IO (Ptr RenderReplay)

-- | Creates a new replay object to replay nodes.
-- 
-- /Since: 4.22/
renderReplayNew ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    m RenderReplay
    -- ^ __Returns:__ A new replay object to replay nodes
renderReplayNew  = liftIO $ do
    result <- gsk_render_replay_new
    checkUnexpectedReturnNULL "renderReplayNew" result
    result' <- (wrapPtr RenderReplay) result
    return result'

#if defined(ENABLE_OVERLOADING)
#endif

-- method RenderReplay::default
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "self"
--           , argType =
--               TInterface Name { namespace = "Gsk" , name = "RenderReplay" }
--           , argCType = Just "GskRenderReplay*"
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the replay" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "node"
--           , argType =
--               TInterface Name { namespace = "Gsk" , name = "RenderNode" }
--           , argCType = Just "GskRenderNode*"
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the node to replay" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TInterface Name { namespace = "Gsk" , name = "RenderNode" })
-- throws : False
-- Skip return : False

foreign import ccall "gsk_render_replay_default" gsk_render_replay_default :: 
    Ptr RenderReplay ->                     -- self : TInterface (Name {namespace = "Gsk", name = "RenderReplay"})
    Ptr Gsk.RenderNode.RenderNode ->        -- node : TInterface (Name {namespace = "Gsk", name = "RenderNode"})
    IO (Ptr Gsk.RenderNode.RenderNode)

-- | Replays the node using the default method.
-- 
-- The default method calls 'GI.Gsk.Structs.RenderReplay.renderReplayFilterNode'
-- on all its child nodes and the filter functions for all its
-- properties. If none of them are changed, it returns the passed
-- in node. Otherwise it constructs a new node with the changed
-- children and properties.
-- 
-- It may not be possible to construct a new node when any of the
-- callbacks return NULL. In that case, this function will return
-- NULL, too.
-- 
-- /Since: 4.22/
renderReplayDefault ::
    (B.CallStack.HasCallStack, MonadIO m, Gsk.RenderNode.IsRenderNode a) =>
    RenderReplay
    -- ^ /@self@/: the replay
    -> a
    -- ^ /@node@/: the node to replay
    -> m (Maybe Gsk.RenderNode.RenderNode)
    -- ^ __Returns:__ The replayed node
renderReplayDefault self node = liftIO $ do
    self' <- unsafeManagedPtrGetPtr self
    node' <- unsafeManagedPtrCastPtr node
    result <- gsk_render_replay_default self' node'
    maybeResult <- convertIfNonNull result $ \result' -> do
        result'' <- (wrapPtr Gsk.RenderNode.RenderNode) result'
        return result''
    touchManagedPtr self
    touchManagedPtr node
    return maybeResult

#if defined(ENABLE_OVERLOADING)
data RenderReplayDefaultMethodInfo
instance (signature ~ (a -> m (Maybe Gsk.RenderNode.RenderNode)), MonadIO m, Gsk.RenderNode.IsRenderNode a) => O.OverloadedMethod RenderReplayDefaultMethodInfo RenderReplay signature where
    overloadedMethod = renderReplayDefault

instance O.OverloadedMethodInfo RenderReplayDefaultMethodInfo RenderReplay where
    overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
        O.resolvedSymbolName = "GI.Gsk.Structs.RenderReplay.renderReplayDefault",
        O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-gsk-4.0.8/docs/GI-Gsk-Structs-RenderReplay.html#v:renderReplayDefault"
        })


#endif

-- method RenderReplay::filter_font
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "self"
--           , argType =
--               TInterface Name { namespace = "Gsk" , name = "RenderReplay" }
--           , argCType = Just "GskRenderReplay*"
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the replay" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "font"
--           , argType = TInterface Name { namespace = "Pango" , name = "Font" }
--           , argCType = Just "PangoFont*"
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "The font to filter" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TInterface Name { namespace = "Pango" , name = "Font" })
-- throws : False
-- Skip return : False

foreign import ccall "gsk_render_replay_filter_font" gsk_render_replay_filter_font :: 
    Ptr RenderReplay ->                     -- self : TInterface (Name {namespace = "Gsk", name = "RenderReplay"})
    Ptr Pango.Font.Font ->                  -- font : TInterface (Name {namespace = "Pango", name = "Font"})
    IO (Ptr Pango.Font.Font)

-- | Filters a font using the current filter function.
-- 
-- /Since: 4.22/
renderReplayFilterFont ::
    (B.CallStack.HasCallStack, MonadIO m, Pango.Font.IsFont a) =>
    RenderReplay
    -- ^ /@self@/: the replay
    -> a
    -- ^ /@font@/: The font to filter
    -> m Pango.Font.Font
    -- ^ __Returns:__ the filtered font
renderReplayFilterFont self font = liftIO $ do
    self' <- unsafeManagedPtrGetPtr self
    font' <- unsafeManagedPtrCastPtr font
    result <- gsk_render_replay_filter_font self' font'
    checkUnexpectedReturnNULL "renderReplayFilterFont" result
    result' <- (wrapObject Pango.Font.Font) result
    touchManagedPtr self
    touchManagedPtr font
    return result'

#if defined(ENABLE_OVERLOADING)
data RenderReplayFilterFontMethodInfo
instance (signature ~ (a -> m Pango.Font.Font), MonadIO m, Pango.Font.IsFont a) => O.OverloadedMethod RenderReplayFilterFontMethodInfo RenderReplay signature where
    overloadedMethod = renderReplayFilterFont

instance O.OverloadedMethodInfo RenderReplayFilterFontMethodInfo RenderReplay where
    overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
        O.resolvedSymbolName = "GI.Gsk.Structs.RenderReplay.renderReplayFilterFont",
        O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-gsk-4.0.8/docs/GI-Gsk-Structs-RenderReplay.html#v:renderReplayFilterFont"
        })


#endif

-- method RenderReplay::filter_node
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "self"
--           , argType =
--               TInterface Name { namespace = "Gsk" , name = "RenderReplay" }
--           , argCType = Just "GskRenderReplay*"
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the replay" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "node"
--           , argType =
--               TInterface Name { namespace = "Gsk" , name = "RenderNode" }
--           , argCType = Just "GskRenderNode*"
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the node to replay" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TInterface Name { namespace = "Gsk" , name = "RenderNode" })
-- throws : False
-- Skip return : False

foreign import ccall "gsk_render_replay_filter_node" gsk_render_replay_filter_node :: 
    Ptr RenderReplay ->                     -- self : TInterface (Name {namespace = "Gsk", name = "RenderReplay"})
    Ptr Gsk.RenderNode.RenderNode ->        -- node : TInterface (Name {namespace = "Gsk", name = "RenderNode"})
    IO (Ptr Gsk.RenderNode.RenderNode)

-- | Replays a node using the replay\'s filter function.
-- 
-- After the replay the node may be unchanged, or it may be
-- removed, which will result in 'P.Nothing' being returned.
-- 
-- If no filter node is set, 'GI.Gsk.Structs.RenderReplay.renderReplayDefault' is
-- called instead.
-- 
-- /Since: 4.22/
renderReplayFilterNode ::
    (B.CallStack.HasCallStack, MonadIO m, Gsk.RenderNode.IsRenderNode a) =>
    RenderReplay
    -- ^ /@self@/: the replay
    -> a
    -- ^ /@node@/: the node to replay
    -> m (Maybe Gsk.RenderNode.RenderNode)
    -- ^ __Returns:__ The replayed node
renderReplayFilterNode self node = liftIO $ do
    self' <- unsafeManagedPtrGetPtr self
    node' <- unsafeManagedPtrCastPtr node
    result <- gsk_render_replay_filter_node self' node'
    maybeResult <- convertIfNonNull result $ \result' -> do
        result'' <- (wrapPtr Gsk.RenderNode.RenderNode) result'
        return result''
    touchManagedPtr self
    touchManagedPtr node
    return maybeResult

#if defined(ENABLE_OVERLOADING)
data RenderReplayFilterNodeMethodInfo
instance (signature ~ (a -> m (Maybe Gsk.RenderNode.RenderNode)), MonadIO m, Gsk.RenderNode.IsRenderNode a) => O.OverloadedMethod RenderReplayFilterNodeMethodInfo RenderReplay signature where
    overloadedMethod = renderReplayFilterNode

instance O.OverloadedMethodInfo RenderReplayFilterNodeMethodInfo RenderReplay where
    overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
        O.resolvedSymbolName = "GI.Gsk.Structs.RenderReplay.renderReplayFilterNode",
        O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-gsk-4.0.8/docs/GI-Gsk-Structs-RenderReplay.html#v:renderReplayFilterNode"
        })


#endif

-- method RenderReplay::filter_texture
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "self"
--           , argType =
--               TInterface Name { namespace = "Gsk" , name = "RenderReplay" }
--           , argCType = Just "GskRenderReplay*"
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the replay" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "texture"
--           , argType =
--               TInterface Name { namespace = "Gdk" , name = "Texture" }
--           , argCType = Just "GdkTexture*"
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "The texture to filter"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TInterface Name { namespace = "Gdk" , name = "Texture" })
-- throws : False
-- Skip return : False

foreign import ccall "gsk_render_replay_filter_texture" gsk_render_replay_filter_texture :: 
    Ptr RenderReplay ->                     -- self : TInterface (Name {namespace = "Gsk", name = "RenderReplay"})
    Ptr Gdk.Texture.Texture ->              -- texture : TInterface (Name {namespace = "Gdk", name = "Texture"})
    IO (Ptr Gdk.Texture.Texture)

-- | Filters a texture using the current filter function.
-- 
-- /Since: 4.22/
renderReplayFilterTexture ::
    (B.CallStack.HasCallStack, MonadIO m, Gdk.Texture.IsTexture a) =>
    RenderReplay
    -- ^ /@self@/: the replay
    -> a
    -- ^ /@texture@/: The texture to filter
    -> m Gdk.Texture.Texture
    -- ^ __Returns:__ the filtered texture
renderReplayFilterTexture self texture = liftIO $ do
    self' <- unsafeManagedPtrGetPtr self
    texture' <- unsafeManagedPtrCastPtr texture
    result <- gsk_render_replay_filter_texture self' texture'
    checkUnexpectedReturnNULL "renderReplayFilterTexture" result
    result' <- (wrapObject Gdk.Texture.Texture) result
    touchManagedPtr self
    touchManagedPtr texture
    return result'

#if defined(ENABLE_OVERLOADING)
data RenderReplayFilterTextureMethodInfo
instance (signature ~ (a -> m Gdk.Texture.Texture), MonadIO m, Gdk.Texture.IsTexture a) => O.OverloadedMethod RenderReplayFilterTextureMethodInfo RenderReplay signature where
    overloadedMethod = renderReplayFilterTexture

instance O.OverloadedMethodInfo RenderReplayFilterTextureMethodInfo RenderReplay where
    overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
        O.resolvedSymbolName = "GI.Gsk.Structs.RenderReplay.renderReplayFilterTexture",
        O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-gsk-4.0.8/docs/GI-Gsk-Structs-RenderReplay.html#v:renderReplayFilterTexture"
        })


#endif

-- method RenderReplay::free
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "self"
--           , argType =
--               TInterface Name { namespace = "Gsk" , name = "RenderReplay" }
--           , argCType = Just "GskRenderReplay*"
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the replay object to free"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Nothing
-- throws : False
-- Skip return : False

foreign import ccall "gsk_render_replay_free" gsk_render_replay_free :: 
    Ptr RenderReplay ->                     -- self : TInterface (Name {namespace = "Gsk", name = "RenderReplay"})
    IO ()

-- | Frees a @GskRenderReplay@.
-- 
-- /Since: 4.22/
renderReplayFree ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    RenderReplay
    -- ^ /@self@/: the replay object to free
    -> m ()
renderReplayFree self = liftIO $ do
    self' <- unsafeManagedPtrGetPtr self
    gsk_render_replay_free self'
    touchManagedPtr self
    return ()

#if defined(ENABLE_OVERLOADING)
data RenderReplayFreeMethodInfo
instance (signature ~ (m ()), MonadIO m) => O.OverloadedMethod RenderReplayFreeMethodInfo RenderReplay signature where
    overloadedMethod = renderReplayFree

instance O.OverloadedMethodInfo RenderReplayFreeMethodInfo RenderReplay where
    overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
        O.resolvedSymbolName = "GI.Gsk.Structs.RenderReplay.renderReplayFree",
        O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-gsk-4.0.8/docs/GI-Gsk-Structs-RenderReplay.html#v:renderReplayFree"
        })


#endif

-- method RenderReplay::set_font_filter
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "self"
--           , argType =
--               TInterface Name { namespace = "Gsk" , name = "RenderReplay" }
--           , argCType = Just "GskRenderReplay*"
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the replay" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "filter"
--           , argType =
--               TInterface
--                 Name { namespace = "Gsk" , name = "RenderReplayFontFilter" }
--           , argCType = Just "GskRenderReplayFontFilter"
--           , direction = DirectionIn
--           , mayBeNull = True
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "\n  the font filter function"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeNotified
--           , argClosure = 2
--           , argDestroy = 3
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "user_data"
--           , argType = TBasicType TPtr
--           , argCType = Just "gpointer"
--           , direction = DirectionIn
--           , mayBeNull = True
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "user data to pass to @filter"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "user_destroy"
--           , argType =
--               TInterface Name { namespace = "GLib" , name = "DestroyNotify" }
--           , argCType = Just "GDestroyNotify"
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just
--                       "destroy notify that will be called to release\n  the user data parameter"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeAsync
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Nothing
-- throws : False
-- Skip return : False

foreign import ccall "gsk_render_replay_set_font_filter" gsk_render_replay_set_font_filter :: 
    Ptr RenderReplay ->                     -- self : TInterface (Name {namespace = "Gsk", name = "RenderReplay"})
    FunPtr Gsk.Callbacks.C_RenderReplayFontFilter -> -- filter : TInterface (Name {namespace = "Gsk", name = "RenderReplayFontFilter"})
    Ptr () ->                               -- user_data : TBasicType TPtr
    FunPtr GLib.Callbacks.C_DestroyNotify -> -- user_destroy : TInterface (Name {namespace = "GLib", name = "DestroyNotify"})
    IO ()

-- | Sets a filter function to be called by 'GI.Gsk.Structs.RenderReplay.renderReplayDefault'
-- for nodes that contain fonts.
-- 
-- You can call [method/@gskRenderReplay@/.filter_font] to filter
-- a font yourself.
-- 
-- /Since: 4.22/
renderReplaySetFontFilter ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    RenderReplay
    -- ^ /@self@/: the replay
    -> Maybe (Gsk.Callbacks.RenderReplayFontFilter)
    -- ^ /@filter@/: 
    --   the font filter function
    -> m ()
renderReplaySetFontFilter self filter = liftIO $ do
    self' <- unsafeManagedPtrGetPtr self
    maybeFilter <- case filter of
        Nothing -> return FP.nullFunPtr
        Just jFilter -> do
            jFilter' <- Gsk.Callbacks.mk_RenderReplayFontFilter (Gsk.Callbacks.wrap_RenderReplayFontFilter Nothing (Gsk.Callbacks.drop_closures_RenderReplayFontFilter jFilter))
            return jFilter'
    let userData = castFunPtrToPtr maybeFilter
    let userDestroy = SP.safeFreeFunPtrPtr
    gsk_render_replay_set_font_filter self' maybeFilter userData userDestroy
    touchManagedPtr self
    return ()

#if defined(ENABLE_OVERLOADING)
data RenderReplaySetFontFilterMethodInfo
instance (signature ~ (Maybe (Gsk.Callbacks.RenderReplayFontFilter) -> m ()), MonadIO m) => O.OverloadedMethod RenderReplaySetFontFilterMethodInfo RenderReplay signature where
    overloadedMethod = renderReplaySetFontFilter

instance O.OverloadedMethodInfo RenderReplaySetFontFilterMethodInfo RenderReplay where
    overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
        O.resolvedSymbolName = "GI.Gsk.Structs.RenderReplay.renderReplaySetFontFilter",
        O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-gsk-4.0.8/docs/GI-Gsk-Structs-RenderReplay.html#v:renderReplaySetFontFilter"
        })


#endif

-- method RenderReplay::set_node_filter
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "self"
--           , argType =
--               TInterface Name { namespace = "Gsk" , name = "RenderReplay" }
--           , argCType = Just "GskRenderReplay*"
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation { rawDocText = Nothing , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "filter"
--           , argType =
--               TInterface
--                 Name { namespace = "Gsk" , name = "RenderReplayNodeFilter" }
--           , argCType = Just "GskRenderReplayNodeFilter"
--           , direction = DirectionIn
--           , mayBeNull = True
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "\n  the function to call to replay nodes"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeNotified
--           , argClosure = 2
--           , argDestroy = 3
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "user_data"
--           , argType = TBasicType TPtr
--           , argCType = Just "gpointer"
--           , direction = DirectionIn
--           , mayBeNull = True
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "user data to pass to @func"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "user_destroy"
--           , argType =
--               TInterface Name { namespace = "GLib" , name = "DestroyNotify" }
--           , argCType = Just "GDestroyNotify"
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just
--                       "destroy notify that will be called to release\n  the user data parameter"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeAsync
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Nothing
-- throws : False
-- Skip return : False

foreign import ccall "gsk_render_replay_set_node_filter" gsk_render_replay_set_node_filter :: 
    Ptr RenderReplay ->                     -- self : TInterface (Name {namespace = "Gsk", name = "RenderReplay"})
    FunPtr Gsk.Callbacks.C_RenderReplayNodeFilter -> -- filter : TInterface (Name {namespace = "Gsk", name = "RenderReplayNodeFilter"})
    Ptr () ->                               -- user_data : TBasicType TPtr
    FunPtr GLib.Callbacks.C_DestroyNotify -> -- user_destroy : TInterface (Name {namespace = "GLib", name = "DestroyNotify"})
    IO ()

-- | Sets the function to use as a node filter.
-- 
-- This is the most complex function to use for replaying nodes.
-- It can either:
-- 
-- * keep the node and just return it unchanged
-- 
-- * create a replacement node and return that
-- 
-- * discard the node by returning @NULL@
-- 
-- * call 'GI.Gsk.Structs.RenderReplay.renderReplayDefault' to have the default handler
--   run for this node, which calls your function on its children
-- 
-- /Since: 4.22/
renderReplaySetNodeFilter ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    RenderReplay
    -> Maybe (Gsk.Callbacks.RenderReplayNodeFilter)
    -- ^ /@filter@/: 
    --   the function to call to replay nodes
    -> m ()
renderReplaySetNodeFilter self filter = liftIO $ do
    self' <- unsafeManagedPtrGetPtr self
    maybeFilter <- case filter of
        Nothing -> return FP.nullFunPtr
        Just jFilter -> do
            jFilter' <- Gsk.Callbacks.mk_RenderReplayNodeFilter (Gsk.Callbacks.wrap_RenderReplayNodeFilter Nothing (Gsk.Callbacks.drop_closures_RenderReplayNodeFilter jFilter))
            return jFilter'
    let userData = castFunPtrToPtr maybeFilter
    let userDestroy = SP.safeFreeFunPtrPtr
    gsk_render_replay_set_node_filter self' maybeFilter userData userDestroy
    touchManagedPtr self
    return ()

#if defined(ENABLE_OVERLOADING)
data RenderReplaySetNodeFilterMethodInfo
instance (signature ~ (Maybe (Gsk.Callbacks.RenderReplayNodeFilter) -> m ()), MonadIO m) => O.OverloadedMethod RenderReplaySetNodeFilterMethodInfo RenderReplay signature where
    overloadedMethod = renderReplaySetNodeFilter

instance O.OverloadedMethodInfo RenderReplaySetNodeFilterMethodInfo RenderReplay where
    overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
        O.resolvedSymbolName = "GI.Gsk.Structs.RenderReplay.renderReplaySetNodeFilter",
        O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-gsk-4.0.8/docs/GI-Gsk-Structs-RenderReplay.html#v:renderReplaySetNodeFilter"
        })


#endif

-- method RenderReplay::set_texture_filter
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "self"
--           , argType =
--               TInterface Name { namespace = "Gsk" , name = "RenderReplay" }
--           , argCType = Just "GskRenderReplay*"
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the replay" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "filter"
--           , argType =
--               TInterface
--                 Name { namespace = "Gsk" , name = "RenderReplayTextureFilter" }
--           , argCType = Just "GskRenderReplayTextureFilter"
--           , direction = DirectionIn
--           , mayBeNull = True
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "\n  the texture filter function"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeNotified
--           , argClosure = 2
--           , argDestroy = 3
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "user_data"
--           , argType = TBasicType TPtr
--           , argCType = Just "gpointer"
--           , direction = DirectionIn
--           , mayBeNull = True
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "user data to pass to @filter"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "user_destroy"
--           , argType =
--               TInterface Name { namespace = "GLib" , name = "DestroyNotify" }
--           , argCType = Just "GDestroyNotify"
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just
--                       "destroy notify that will be called to release\n  the user data parameter"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeAsync
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Nothing
-- throws : False
-- Skip return : False

foreign import ccall "gsk_render_replay_set_texture_filter" gsk_render_replay_set_texture_filter :: 
    Ptr RenderReplay ->                     -- self : TInterface (Name {namespace = "Gsk", name = "RenderReplay"})
    FunPtr Gsk.Callbacks.C_RenderReplayTextureFilter -> -- filter : TInterface (Name {namespace = "Gsk", name = "RenderReplayTextureFilter"})
    Ptr () ->                               -- user_data : TBasicType TPtr
    FunPtr GLib.Callbacks.C_DestroyNotify -> -- user_destroy : TInterface (Name {namespace = "GLib", name = "DestroyNotify"})
    IO ()

-- | Sets a filter function to be called by 'GI.Gsk.Structs.RenderReplay.renderReplayDefault'
-- for nodes that contain textures.
-- 
-- You can call [method/@gskRenderReplay@/.filter_texture] to filter
-- a texture yourself.
-- 
-- /Since: 4.22/
renderReplaySetTextureFilter ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    RenderReplay
    -- ^ /@self@/: the replay
    -> Maybe (Gsk.Callbacks.RenderReplayTextureFilter)
    -- ^ /@filter@/: 
    --   the texture filter function
    -> m ()
renderReplaySetTextureFilter self filter = liftIO $ do
    self' <- unsafeManagedPtrGetPtr self
    maybeFilter <- case filter of
        Nothing -> return FP.nullFunPtr
        Just jFilter -> do
            jFilter' <- Gsk.Callbacks.mk_RenderReplayTextureFilter (Gsk.Callbacks.wrap_RenderReplayTextureFilter Nothing (Gsk.Callbacks.drop_closures_RenderReplayTextureFilter jFilter))
            return jFilter'
    let userData = castFunPtrToPtr maybeFilter
    let userDestroy = SP.safeFreeFunPtrPtr
    gsk_render_replay_set_texture_filter self' maybeFilter userData userDestroy
    touchManagedPtr self
    return ()

#if defined(ENABLE_OVERLOADING)
data RenderReplaySetTextureFilterMethodInfo
instance (signature ~ (Maybe (Gsk.Callbacks.RenderReplayTextureFilter) -> m ()), MonadIO m) => O.OverloadedMethod RenderReplaySetTextureFilterMethodInfo RenderReplay signature where
    overloadedMethod = renderReplaySetTextureFilter

instance O.OverloadedMethodInfo RenderReplaySetTextureFilterMethodInfo RenderReplay where
    overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
        O.resolvedSymbolName = "GI.Gsk.Structs.RenderReplay.renderReplaySetTextureFilter",
        O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-gsk-4.0.8/docs/GI-Gsk-Structs-RenderReplay.html#v:renderReplaySetTextureFilter"
        })


#endif

#if defined(ENABLE_OVERLOADING)
type family ResolveRenderReplayMethod (t :: Symbol) (o :: DK.Type) :: DK.Type where
    ResolveRenderReplayMethod "default" o = RenderReplayDefaultMethodInfo
    ResolveRenderReplayMethod "filterFont" o = RenderReplayFilterFontMethodInfo
    ResolveRenderReplayMethod "filterNode" o = RenderReplayFilterNodeMethodInfo
    ResolveRenderReplayMethod "filterTexture" o = RenderReplayFilterTextureMethodInfo
    ResolveRenderReplayMethod "free" o = RenderReplayFreeMethodInfo
    ResolveRenderReplayMethod "setFontFilter" o = RenderReplaySetFontFilterMethodInfo
    ResolveRenderReplayMethod "setNodeFilter" o = RenderReplaySetNodeFilterMethodInfo
    ResolveRenderReplayMethod "setTextureFilter" o = RenderReplaySetTextureFilterMethodInfo
    ResolveRenderReplayMethod l o = O.MethodResolutionFailed l o

instance (info ~ ResolveRenderReplayMethod t RenderReplay, O.OverloadedMethod info RenderReplay p) => OL.IsLabel t (RenderReplay -> p) where
#if MIN_VERSION_base(4,10,0)
    fromLabel = O.overloadedMethod @info
#else
    fromLabel _ = O.overloadedMethod @info
#endif

#if MIN_VERSION_base(4,13,0)
instance (info ~ ResolveRenderReplayMethod t RenderReplay, O.OverloadedMethod info RenderReplay p, R.HasField t RenderReplay p) => R.HasField t RenderReplay p where
    getField = O.overloadedMethod @info

#endif

instance (info ~ ResolveRenderReplayMethod t RenderReplay, O.OverloadedMethodInfo info RenderReplay) => OL.IsLabel t (O.MethodProxy info RenderReplay) where
#if MIN_VERSION_base(4,10,0)
    fromLabel = O.MethodProxy
#else
    fromLabel _ = O.MethodProxy
#endif

#endif


