    {-# LINE 1 "Graphics/X11/Xrender.hsc" #-}
    -----------------------------------------------------------------------------
    -- Module      :  Graphics.X11.Xrender
    -- Copyright   :  Clemens Fruhwirth <clemens@endorphin.org> 2007
    --
    -- Haskell bindings for the Xrender extension.
    --
    -----------------------------------------------------------------------------

    module Graphics.X11.Xrender (
      peekCUShort,
      pokeCUShort,
      peekCShort,
      pokeCShort,
      XRenderColor (..),
      XGlyphInfo (..),
      XRenderDirectFormat (..),
    ) where

    import Foreign
    import Foreign.C

    peekCUShort :: Ptr a -> CInt -> IO Int
    peekCUShort :: forall a. Ptr a -> CInt -> IO Int
    peekCUShort Ptr a
    ptr CInt
    off = do
            CUShort
    v <- Ptr a -> Int -> IO CUShort
    forall b. Ptr b -> Int -> IO CUShort
    forall a b. Storable a => Ptr b -> Int -> IO a
    peekByteOff Ptr a
    ptr (CInt -> Int
    forall a b. (Integral a, Num b) => a -> b
    fromIntegral CInt
    off)
            Int -> IO Int
    forall a. a -> IO a
    forall (m :: * -> *) a. Monad m => a -> m a
    return (CUShort -> Int
    forall a b. (Integral a, Num b) => a -> b
    fromIntegral (CUShort
    v::CUShort))

    pokeCUShort :: Ptr a -> CInt -> Int -> IO ()
    pokeCUShort :: forall a. Ptr a -> CInt -> Int -> IO ()
    pokeCUShort Ptr a
    ptr CInt
    off Int
    v =
            Ptr a -> Int -> CUShort -> IO ()
    forall b. Ptr b -> Int -> CUShort -> IO ()
    forall a b. Storable a => Ptr b -> Int -> a -> IO ()
    pokeByteOff Ptr a
    ptr (CInt -> Int
    forall a b. (Integral a, Num b) => a -> b
    fromIntegral CInt
    off) (Int -> CUShort
    forall a b. (Integral a, Num b) => a -> b
    fromIntegral Int
    v::CUShort)

    peekCShort :: Ptr a -> CInt -> IO Int
    peekCShort :: forall a. Ptr a -> CInt -> IO Int
    peekCShort Ptr a
    ptr CInt
    off = do
            CShort
    v <- Ptr a -> Int -> IO CShort
    forall b. Ptr b -> Int -> IO CShort
    forall a b. Storable a => Ptr b -> Int -> IO a
    peekByteOff Ptr a
    ptr (CInt -> Int
    forall a b. (Integral a, Num b) => a -> b
    fromIntegral CInt
    off)
            Int -> IO Int
    forall a. a -> IO a
    forall (m :: * -> *) a. Monad m => a -> m a
    return (CShort -> Int
    forall a b. (Integral a, Num b) => a -> b
    fromIntegral (CShort
    v::CShort))

    pokeCShort :: Ptr a -> CInt -> Int -> IO ()
    pokeCShort :: forall a. Ptr a -> CInt -> Int -> IO ()
    pokeCShort Ptr a
    ptr CInt
    off Int
    v =
            Ptr a -> Int -> CShort -> IO ()
    forall b. Ptr b -> Int -> CShort -> IO ()
    forall a b. Storable a => Ptr b -> Int -> a -> IO ()
    pokeByteOff Ptr a
    ptr (CInt -> Int
    forall a b. (Integral a, Num b) => a -> b
    fromIntegral CInt
    off) (Int -> CShort
    forall a b. (Integral a, Num b) => a -> b
    fromIntegral Int
    v::CShort)

    data XRenderColor = XRenderColor {
          XRenderColor -> Int
    xrendercolor_red   :: Int,
          XRenderColor -> Int
    xrendercolor_green :: Int,
          XRenderColor -> Int
    xrendercolor_blue  :: Int,
          XRenderColor -> Int
    xrendercolor_alpha :: Int
    }

    instance Storable XRenderColor where
            sizeOf :: XRenderColor -> Int
    sizeOf XRenderColor
    _ = (Int
    8)
    {-# LINE 51 "Graphics/X11/Xrender.hsc" #-}
            alignment :: XRenderColor -> Int
    alignment XRenderColor
    _ = CInt -> Int
    forall a. Storable a => a -> Int
    alignment (CInt
    forall a. HasCallStack => a
    undefined::CInt)
            peek :: Ptr XRenderColor -> IO XRenderColor
    peek Ptr XRenderColor
    p = do
                    Int
    red   <- Ptr XRenderColor -> CInt -> IO Int
    forall a. Ptr a -> CInt -> IO Int
    peekCUShort Ptr XRenderColor
    p (CInt
    0)
    {-# LINE 54 "Graphics/X11/Xrender.hsc" #-}
                    Int
    blue  <- Ptr XRenderColor -> CInt -> IO Int
    forall a. Ptr a -> CInt -> IO Int
    peekCUShort Ptr XRenderColor
    p (CInt
    4)
    {-# LINE 55 "Graphics/X11/Xrender.hsc" #-}
                    Int
    green <- Ptr XRenderColor -> CInt -> IO Int
    forall a. Ptr a -> CInt -> IO Int
    peekCUShort Ptr XRenderColor
    p (CInt
    2)
    {-# LINE 56 "Graphics/X11/Xrender.hsc" #-}
                    Int
    alpha <- Ptr XRenderColor -> CInt -> IO Int
    forall a. Ptr a -> CInt -> IO Int
    peekCUShort Ptr XRenderColor
    p (CInt
    6)
    {-# LINE 57 "Graphics/X11/Xrender.hsc" #-}
                    XRenderColor -> IO XRenderColor
    forall a. a -> IO a
    forall (m :: * -> *) a. Monad m => a -> m a
    return (Int -> Int -> Int -> Int -> XRenderColor
    XRenderColor Int
    red Int
    green Int
    blue Int
    alpha)
            poke :: Ptr XRenderColor -> XRenderColor -> IO ()
    poke Ptr XRenderColor
    p (XRenderColor Int
    red Int
    green Int
    blue Int
    alpha) = do
                    Ptr XRenderColor -> CInt -> Int -> IO ()
    forall a. Ptr a -> CInt -> Int -> IO ()
    pokeCUShort Ptr XRenderColor
    p (CInt
    0) Int
    red
    {-# LINE 60 "Graphics/X11/Xrender.hsc" #-}
                    Ptr XRenderColor -> CInt -> Int -> IO ()
    forall a. Ptr a -> CInt -> Int -> IO ()
    pokeCUShort Ptr XRenderColor
    p (CInt
    4) Int
    blue
    {-# LINE 61 "Graphics/X11/Xrender.hsc" #-}
                    Ptr XRenderColor -> CInt -> Int -> IO ()
    forall a. Ptr a -> CInt -> Int -> IO ()
    pokeCUShort Ptr XRenderColor
    p (CInt
    2) Int
    green
    {-# LINE 62 "Graphics/X11/Xrender.hsc" #-}
                    Ptr XRenderColor -> CInt -> Int -> IO ()
    forall a. Ptr a -> CInt -> Int -> IO ()
    pokeCUShort Ptr XRenderColor
    p (CInt
    6) Int
    alpha
    {-# LINE 63 "Graphics/X11/Xrender.hsc" #-}

    data XGlyphInfo = XGlyphInfo {
          XGlyphInfo -> Int
    xglyphinfo_width  :: Int,
          XGlyphInfo -> Int
    xglyphinfo_height :: Int,
          XGlyphInfo -> Int
    xglyphinfo_x      :: Int,
          XGlyphInfo -> Int
    xglyphinfo_y      :: Int,
          XGlyphInfo -> Int
    xglyphinfo_xOff   :: Int,
          XGlyphInfo -> Int
    xglyphinfo_yOff   :: Int
    }

    instance Storable XGlyphInfo where
            sizeOf :: XGlyphInfo -> Int
    sizeOf XGlyphInfo
    _ = (Int
    12)
    {-# LINE 75 "Graphics/X11/Xrender.hsc" #-}
            alignment :: XGlyphInfo -> Int
    alignment XGlyphInfo
    _ = CInt -> Int
    forall a. Storable a => a -> Int
    alignment (CInt
    forall a. HasCallStack => a
    undefined::CInt)
            peek :: Ptr XGlyphInfo -> IO XGlyphInfo
    peek Ptr XGlyphInfo
    p = do
                    Int
    width  <- Ptr XGlyphInfo -> CInt -> IO Int
    forall a. Ptr a -> CInt -> IO Int
    peekCUShort Ptr XGlyphInfo
    p (CInt
    0)
    {-# LINE 78 "Graphics/X11/Xrender.hsc" #-}
                    Int
    height <- Ptr XGlyphInfo -> CInt -> IO Int
    forall a. Ptr a -> CInt -> IO Int
    peekCUShort Ptr XGlyphInfo
    p (CInt
    2)
    {-# LINE 79 "Graphics/X11/Xrender.hsc" #-}
                    Int
    x <- Ptr XGlyphInfo -> CInt -> IO Int
    forall a. Ptr a -> CInt -> IO Int
    peekCShort Ptr XGlyphInfo
    p (CInt
    4)
    {-# LINE 80 "Graphics/X11/Xrender.hsc" #-}
                    Int
    y <- Ptr XGlyphInfo -> CInt -> IO Int
    forall a. Ptr a -> CInt -> IO Int
    peekCShort Ptr XGlyphInfo
    p (CInt
    6)
    {-# LINE 81 "Graphics/X11/Xrender.hsc" #-}
                    Int
    xOff <- Ptr XGlyphInfo -> CInt -> IO Int
    forall a. Ptr a -> CInt -> IO Int
    peekCShort Ptr XGlyphInfo
    p (CInt
    8)
    {-# LINE 82 "Graphics/X11/Xrender.hsc" #-}
                    Int
    yOff <- Ptr XGlyphInfo -> CInt -> IO Int
    forall a. Ptr a -> CInt -> IO Int
    peekCShort Ptr XGlyphInfo
    p (CInt
    10)
    {-# LINE 83 "Graphics/X11/Xrender.hsc" #-}
                    XGlyphInfo -> IO XGlyphInfo
    forall a. a -> IO a
    forall (m :: * -> *) a. Monad m => a -> m a
    return (Int -> Int -> Int -> Int -> Int -> Int -> XGlyphInfo
    XGlyphInfo Int
    width Int
    height Int
    x Int
    y Int
    xOff Int
    yOff)
            poke :: Ptr XGlyphInfo -> XGlyphInfo -> IO ()
    poke Ptr XGlyphInfo
    p (XGlyphInfo Int
    width Int
    height Int
    x Int
    y Int
    xOff Int
    yOff) = do
                    Ptr XGlyphInfo -> CInt -> Int -> IO ()
    forall a. Ptr a -> CInt -> Int -> IO ()
    pokeCUShort Ptr XGlyphInfo
    p (CInt
    0) Int
    width
    {-# LINE 86 "Graphics/X11/Xrender.hsc" #-}
                    Ptr XGlyphInfo -> CInt -> Int -> IO ()
    forall a. Ptr a -> CInt -> Int -> IO ()
    pokeCUShort Ptr XGlyphInfo
    p (CInt
    2) Int
    height
    {-# LINE 87 "Graphics/X11/Xrender.hsc" #-}
                    Ptr XGlyphInfo -> CInt -> Int -> IO ()
    forall a. Ptr a -> CInt -> Int -> IO ()
    pokeCShort Ptr XGlyphInfo
    p (CInt
    4) Int
    x
    {-# LINE 88 "Graphics/X11/Xrender.hsc" #-}
                    Ptr XGlyphInfo -> CInt -> Int -> IO ()
    forall a. Ptr a -> CInt -> Int -> IO ()
    pokeCShort Ptr XGlyphInfo
    p (CInt
    6) Int
    y
    {-# LINE 89 "Graphics/X11/Xrender.hsc" #-}
                    Ptr XGlyphInfo -> CInt -> Int -> IO ()
    forall a. Ptr a -> CInt -> Int -> IO ()
    pokeCShort Ptr XGlyphInfo
    p (CInt
    8) Int
    xOff
    {-# LINE 90 "Graphics/X11/Xrender.hsc" #-}
                    Ptr XGlyphInfo -> CInt -> Int -> IO ()
    forall a. Ptr a -> CInt -> Int -> IO ()
    pokeCShort Ptr XGlyphInfo
    p (CInt
    10) Int
    yOff
    {-# LINE 91 "Graphics/X11/Xrender.hsc" #-}

    data XRenderDirectFormat = XRenderDirectFormat {
         XRenderDirectFormat -> Int
    xrenderdirectformat_red       :: Int,
         XRenderDirectFormat -> Int
    xrenderdirectformat_redMask   :: Int,
         XRenderDirectFormat -> Int
    xrenderdirectformat_green     :: Int,
         XRenderDirectFormat -> Int
    xrenderdirectformat_greenMask :: Int,
         XRenderDirectFormat -> Int
    xrenderdirectformat_blue      :: Int,
         XRenderDirectFormat -> Int
    xrenderdirectformat_blueMask  :: Int,
         XRenderDirectFormat -> Int
    xrenderdirectformat_alpha     :: Int,
         XRenderDirectFormat -> Int
    xrenderdirectformat_alphaMask :: Int
    }

    instance Storable XRenderDirectFormat where
            sizeOf :: XRenderDirectFormat -> Int
    sizeOf XRenderDirectFormat
    _ = (Int
    16)
    {-# LINE 106 "Graphics/X11/Xrender.hsc" #-}
            alignment :: XRenderDirectFormat -> Int
    alignment XRenderDirectFormat
    _ = CInt -> Int
    forall a. Storable a => a -> Int
    alignment (CInt
    forall a. HasCallStack => a
    undefined::CInt)
            peek :: Ptr XRenderDirectFormat -> IO XRenderDirectFormat
    peek Ptr XRenderDirectFormat
    p = do
                    Int
    red  <- Ptr XRenderDirectFormat -> CInt -> IO Int
    forall a. Ptr a -> CInt -> IO Int
    peekCShort Ptr XRenderDirectFormat
    p (CInt
    0)
    {-# LINE 109 "Graphics/X11/Xrender.hsc" #-}
                    Int
    redMask  <- Ptr XRenderDirectFormat -> CInt -> IO Int
    forall a. Ptr a -> CInt -> IO Int
    peekCShort Ptr XRenderDirectFormat
    p (CInt
    2)
    {-# LINE 110 "Graphics/X11/Xrender.hsc" #-}
                    Int
    green  <- Ptr XRenderDirectFormat -> CInt -> IO Int
    forall a. Ptr a -> CInt -> IO Int
    peekCShort Ptr XRenderDirectFormat
    p (CInt
    4)
    {-# LINE 111 "Graphics/X11/Xrender.hsc" #-}
                    Int
    greenMask  <- Ptr XRenderDirectFormat -> CInt -> IO Int
    forall a. Ptr a -> CInt -> IO Int
    peekCShort Ptr XRenderDirectFormat
    p (CInt
    6)
    {-# LINE 112 "Graphics/X11/Xrender.hsc" #-}
                    Int
    blue  <- Ptr XRenderDirectFormat -> CInt -> IO Int
    forall a. Ptr a -> CInt -> IO Int
    peekCShort Ptr XRenderDirectFormat
    p (CInt
    8)
    {-# LINE 113 "Graphics/X11/Xrender.hsc" #-}
                    Int
    blueMask  <- Ptr XRenderDirectFormat -> CInt -> IO Int
    forall a. Ptr a -> CInt -> IO Int
    peekCShort Ptr XRenderDirectFormat
    p (CInt
    10)
    {-# LINE 114 "Graphics/X11/Xrender.hsc" #-}
                    Int
    alpha  <- Ptr XRenderDirectFormat -> CInt -> IO Int
    forall a. Ptr a -> CInt -> IO Int
    peekCShort Ptr XRenderDirectFormat
    p (CInt
    12)
    {-# LINE 115 "Graphics/X11/Xrender.hsc" #-}
                    Int
    alphaMask  <- Ptr XRenderDirectFormat -> CInt -> IO Int
    forall a. Ptr a -> CInt -> IO Int
    peekCShort Ptr XRenderDirectFormat
    p (CInt
    14)
    {-# LINE 116 "Graphics/X11/Xrender.hsc" #-}
                    XRenderDirectFormat -> IO XRenderDirectFormat
    forall a. a -> IO a
    forall (m :: * -> *) a. Monad m => a -> m a
    return (Int
    -> Int
    -> Int
    -> Int
    -> Int
    -> Int
    -> Int
    -> Int
    -> XRenderDirectFormat
    XRenderDirectFormat Int
    red Int
    redMask Int
    green Int
    greenMask Int
    blue Int
    blueMask Int
    alpha Int
    alphaMask)
            poke :: Ptr XRenderDirectFormat -> XRenderDirectFormat -> IO ()
    poke Ptr XRenderDirectFormat
    p (XRenderDirectFormat Int
    red Int
    redMask Int
    green Int
    greenMask Int
    blue Int
    blueMask Int
    alpha Int
    alphaMask) = do
                    Ptr XRenderDirectFormat -> CInt -> Int -> IO ()
    forall a. Ptr a -> CInt -> Int -> IO ()
    pokeCShort Ptr XRenderDirectFormat
    p (CInt
    0) Int
    red
    {-# LINE 119 "Graphics/X11/Xrender.hsc" #-}
                    Ptr XRenderDirectFormat -> CInt -> Int -> IO ()
    forall a. Ptr a -> CInt -> Int -> IO ()
    pokeCShort Ptr XRenderDirectFormat
    p (CInt
    2) Int
    redMask
    {-# LINE 120 "Graphics/X11/Xrender.hsc" #-}
                    Ptr XRenderDirectFormat -> CInt -> Int -> IO ()
    forall a. Ptr a -> CInt -> Int -> IO ()
    pokeCShort Ptr XRenderDirectFormat
    p (CInt
    8) Int
    blue
    {-# LINE 121 "Graphics/X11/Xrender.hsc" #-}
                    Ptr XRenderDirectFormat -> CInt -> Int -> IO ()
    forall a. Ptr a -> CInt -> Int -> IO ()
    pokeCShort Ptr XRenderDirectFormat
    p (CInt
    10) Int
    blueMask
    {-# LINE 122 "Graphics/X11/Xrender.hsc" #-}
                    Ptr XRenderDirectFormat -> CInt -> Int -> IO ()
    forall a. Ptr a -> CInt -> Int -> IO ()
    pokeCShort Ptr XRenderDirectFormat
    p (CInt
    4) Int
    green
    {-# LINE 123 "Graphics/X11/Xrender.hsc" #-}
                    Ptr XRenderDirectFormat -> CInt -> Int -> IO ()
    forall a. Ptr a -> CInt -> Int -> IO ()
    pokeCShort Ptr XRenderDirectFormat
    p (CInt
    6) Int
    greenMask
    {-# LINE 124 "Graphics/X11/Xrender.hsc" #-}
                    Ptr XRenderDirectFormat -> CInt -> Int -> IO ()
    forall a. Ptr a -> CInt -> Int -> IO ()
    pokeCShort Ptr XRenderDirectFormat
    p (CInt
    12) Int
    alpha
    {-# LINE 125 "Graphics/X11/Xrender.hsc" #-}
                    Ptr XRenderDirectFormat -> CInt -> Int -> IO ()
    forall a. Ptr a -> CInt -> Int -> IO ()
    pokeCShort Ptr XRenderDirectFormat
    p (CInt
    14) Int
    alphaMask
    {-# LINE 126 "Graphics/X11/Xrender.hsc" #-}