{-# LANGUAGE StrictData #-}
module NanoUI.Draw.Types
( Layer (..)
, DrawOp (..)
, TextFont (..)
, defaultTextFont
, DrawingBuild
, shiftDrawOp
, DrawCmd (..)
, LayerSlice (..)
, DrawData (..)
, drawCmdCount
, drawCmdNull
, forDrawCmdsInLayer_
, drawCmdElems
, DrawArena (..)
, BufferPool
, vertexSize
, indexSize
, backdropDimTextureId
, glyphAtlasTextureId
) where
import Data.IORef (IORef)
import Data.Primitive.PrimArray (MutablePrimArray, PrimArray, indexPrimArray, sizeofPrimArray)
import Data.Primitive.Types (Prim (..), defaultSetByteArray#, defaultSetOffAddr#)
import qualified Data.Text as T
import Data.Primitive.SmallArray (SmallArray)
import Data.Word (Word32, Word8)
import Foreign.ForeignPtr (ForeignPtr)
import Foreign.Ptr (Ptr)
import GHC.Exts
( Float (F#)
, Int (I#)
, RealWorld
, (*#)
, (+#)
, indexFloatOffAddr#
, indexIntOffAddr#
, indexWord8Array#
, indexWord8ArrayAsFloat#
, indexWord8ArrayAsInt#
, indexWord8ArrayAsWord32#
, indexWord8OffAddr#
, indexWord32OffAddr#
, plusAddr#
, readFloatOffAddr#
, readIntOffAddr#
, readWord8Array#
, readWord8ArrayAsFloat#
, readWord8ArrayAsInt#
, readWord8ArrayAsWord32#
, readWord8OffAddr#
, readWord32OffAddr#
, writeFloatOffAddr#
, writeIntOffAddr#
, writeWord8Array#
, writeWord8ArrayAsFloat#
, writeWord8ArrayAsInt#
, writeWord8ArrayAsWord32#
, writeWord8OffAddr#
, writeWord32OffAddr#
)
import GHC.Word (Word8 (W8#), Word32 (W32#))
import NanoUI.Style (FontStyle (..), FontVariant (..), FontWeight (..), TextDecoration (..))
import NanoUI.Types (Color (..), Rect (..))
data Layer = LayerBackground | LayerContent | LayerOverlay | LayerChrome
deriving (Layer -> Layer -> Bool
(Layer -> Layer -> Bool) -> (Layer -> Layer -> Bool) -> Eq Layer
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: Layer -> Layer -> Bool
== :: Layer -> Layer -> Bool
$c/= :: Layer -> Layer -> Bool
/= :: Layer -> Layer -> Bool
Eq, Int -> Layer -> ShowS
[Layer] -> ShowS
Layer -> String
(Int -> Layer -> ShowS)
-> (Layer -> String) -> ([Layer] -> ShowS) -> Show Layer
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Layer -> ShowS
showsPrec :: Int -> Layer -> ShowS
$cshow :: Layer -> String
show :: Layer -> String
$cshowList :: [Layer] -> ShowS
showList :: [Layer] -> ShowS
Show, Int -> Layer
Layer -> Int
Layer -> [Layer]
Layer -> Layer
Layer -> Layer -> [Layer]
Layer -> Layer -> Layer -> [Layer]
(Layer -> Layer)
-> (Layer -> Layer)
-> (Int -> Layer)
-> (Layer -> Int)
-> (Layer -> [Layer])
-> (Layer -> Layer -> [Layer])
-> (Layer -> Layer -> [Layer])
-> (Layer -> Layer -> Layer -> [Layer])
-> Enum Layer
forall a.
(a -> a)
-> (a -> a)
-> (Int -> a)
-> (a -> Int)
-> (a -> [a])
-> (a -> a -> [a])
-> (a -> a -> [a])
-> (a -> a -> a -> [a])
-> Enum a
$csucc :: Layer -> Layer
succ :: Layer -> Layer
$cpred :: Layer -> Layer
pred :: Layer -> Layer
$ctoEnum :: Int -> Layer
toEnum :: Int -> Layer
$cfromEnum :: Layer -> Int
fromEnum :: Layer -> Int
$cenumFrom :: Layer -> [Layer]
enumFrom :: Layer -> [Layer]
$cenumFromThen :: Layer -> Layer -> [Layer]
enumFromThen :: Layer -> Layer -> [Layer]
$cenumFromTo :: Layer -> Layer -> [Layer]
enumFromTo :: Layer -> Layer -> [Layer]
$cenumFromThenTo :: Layer -> Layer -> Layer -> [Layer]
enumFromThenTo :: Layer -> Layer -> Layer -> [Layer]
Enum, Layer
Layer -> Layer -> Bounded Layer
forall a. a -> a -> Bounded a
$cminBound :: Layer
minBound :: Layer
$cmaxBound :: Layer
maxBound :: Layer
Bounded)
data DrawOp
= FillRect !Rect !Color
| FillRoundedRect !Rect {-# UNPACK #-} !Float !Color
| FillTriangle
{-# UNPACK #-} !Float
{-# UNPACK #-} !Float
{-# UNPACK #-} !Float
{-# UNPACK #-} !Float
{-# UNPACK #-} !Float
{-# UNPACK #-} !Float
!Color
| FillCircle
{-# UNPACK #-} !Float
{-# UNPACK #-} !Float
{-# UNPACK #-} !Float
!Color
| Stroke
{-# UNPACK #-} !Float
{-# UNPACK #-} !Float
{-# UNPACK #-} !Float
{-# UNPACK #-} !Float
{-# UNPACK #-} !Float
!Color
| StrokeRoundedRect !Rect {-# UNPACK #-} !Float {-# UNPACK #-} !Float !Color
| StrokeCircle
{-# UNPACK #-} !Float
{-# UNPACK #-} !Float
{-# UNPACK #-} !Float
{-# UNPACK #-} !Float
!Color
| StrokeLineAA
{-# UNPACK #-} !Float
{-# UNPACK #-} !Float
{-# UNPACK #-} !Float
{-# UNPACK #-} !Float
{-# UNPACK #-} !Float
!Color
| FillQuadGradient !Rect !Color !Color !Color !Color
| DrawImageRect
!Rect
{-# UNPACK #-} !Int
{-# UNPACK #-} !Float
{-# UNPACK #-} !Float
{-# UNPACK #-} !Float
{-# UNPACK #-} !Float
!Color
| DrawText
{-# UNPACK #-} !Float
{-# UNPACK #-} !Float
{-# UNPACK #-} !Float
{-# UNPACK #-} !Float
!T.Text
!Color
| DrawTextStyled
{-# UNPACK #-} !Float
{-# UNPACK #-} !Float
!TextFont
!T.Text
!Color
deriving (DrawOp -> DrawOp -> Bool
(DrawOp -> DrawOp -> Bool)
-> (DrawOp -> DrawOp -> Bool) -> Eq DrawOp
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: DrawOp -> DrawOp -> Bool
== :: DrawOp -> DrawOp -> Bool
$c/= :: DrawOp -> DrawOp -> Bool
/= :: DrawOp -> DrawOp -> Bool
Eq)
data TextFont = TextFont
{ TextFont -> Float
textFontSize :: {-# UNPACK #-} !Float
, TextFont -> FontVariant
textFontVariant :: !FontVariant
, TextFont -> FontWeight
textFontWeight :: !FontWeight
, TextFont -> FontStyle
textFontStyle :: !FontStyle
, TextFont -> TextDecoration
textFontDecoration :: !TextDecoration
}
deriving (TextFont -> TextFont -> Bool
(TextFont -> TextFont -> Bool)
-> (TextFont -> TextFont -> Bool) -> Eq TextFont
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: TextFont -> TextFont -> Bool
== :: TextFont -> TextFont -> Bool
$c/= :: TextFont -> TextFont -> Bool
/= :: TextFont -> TextFont -> Bool
Eq, Int -> TextFont -> ShowS
[TextFont] -> ShowS
TextFont -> String
(Int -> TextFont -> ShowS)
-> (TextFont -> String) -> ([TextFont] -> ShowS) -> Show TextFont
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> TextFont -> ShowS
showsPrec :: Int -> TextFont -> ShowS
$cshow :: TextFont -> String
show :: TextFont -> String
$cshowList :: [TextFont] -> ShowS
showList :: [TextFont] -> ShowS
Show)
defaultTextFont :: TextFont
defaultTextFont :: TextFont
defaultTextFont = Float
-> FontVariant
-> FontWeight
-> FontStyle
-> TextDecoration
-> TextFont
TextFont Float
0 FontVariant
FontRegular FontWeight
WeightNormal FontStyle
FontStyleNormal TextDecoration
DecorationNone
shiftDrawOp :: Float -> Float -> DrawOp -> DrawOp
shiftDrawOp :: Float -> Float -> DrawOp -> DrawOp
shiftDrawOp Float
dx Float
dy DrawOp
op =
case DrawOp
op of
FillRect (Rect Float
x Float
y Float
w Float
h) Color
c -> Rect -> Color -> DrawOp
FillRect (Float -> Float -> Float -> Float -> Rect
Rect (Float
x Float -> Float -> Float
forall a. Num a => a -> a -> a
+ Float
dx) (Float
y Float -> Float -> Float
forall a. Num a => a -> a -> a
+ Float
dy) Float
w Float
h) Color
c
FillRoundedRect (Rect Float
x Float
y Float
w Float
h) Float
r Color
c -> Rect -> Float -> Color -> DrawOp
FillRoundedRect (Float -> Float -> Float -> Float -> Rect
Rect (Float
x Float -> Float -> Float
forall a. Num a => a -> a -> a
+ Float
dx) (Float
y Float -> Float -> Float
forall a. Num a => a -> a -> a
+ Float
dy) Float
w Float
h) Float
r Color
c
FillTriangle Float
x0 Float
y0 Float
x1 Float
y1 Float
x2 Float
y2 Color
c ->
Float
-> Float -> Float -> Float -> Float -> Float -> Color -> DrawOp
FillTriangle (Float
x0 Float -> Float -> Float
forall a. Num a => a -> a -> a
+ Float
dx) (Float
y0 Float -> Float -> Float
forall a. Num a => a -> a -> a
+ Float
dy) (Float
x1 Float -> Float -> Float
forall a. Num a => a -> a -> a
+ Float
dx) (Float
y1 Float -> Float -> Float
forall a. Num a => a -> a -> a
+ Float
dy) (Float
x2 Float -> Float -> Float
forall a. Num a => a -> a -> a
+ Float
dx) (Float
y2 Float -> Float -> Float
forall a. Num a => a -> a -> a
+ Float
dy) Color
c
FillCircle Float
cx Float
cy Float
r Color
c -> Float -> Float -> Float -> Color -> DrawOp
FillCircle (Float
cx Float -> Float -> Float
forall a. Num a => a -> a -> a
+ Float
dx) (Float
cy Float -> Float -> Float
forall a. Num a => a -> a -> a
+ Float
dy) Float
r Color
c
Stroke Float
x0 Float
y0 Float
x1 Float
y1 Float
t Color
c -> Float -> Float -> Float -> Float -> Float -> Color -> DrawOp
Stroke (Float
x0 Float -> Float -> Float
forall a. Num a => a -> a -> a
+ Float
dx) (Float
y0 Float -> Float -> Float
forall a. Num a => a -> a -> a
+ Float
dy) (Float
x1 Float -> Float -> Float
forall a. Num a => a -> a -> a
+ Float
dx) (Float
y1 Float -> Float -> Float
forall a. Num a => a -> a -> a
+ Float
dy) Float
t Color
c
StrokeRoundedRect (Rect Float
x Float
y Float
w Float
h) Float
r Float
bw Color
c -> Rect -> Float -> Float -> Color -> DrawOp
StrokeRoundedRect (Float -> Float -> Float -> Float -> Rect
Rect (Float
x Float -> Float -> Float
forall a. Num a => a -> a -> a
+ Float
dx) (Float
y Float -> Float -> Float
forall a. Num a => a -> a -> a
+ Float
dy) Float
w Float
h) Float
r Float
bw Color
c
StrokeCircle Float
cx Float
cy Float
r Float
bw Color
c -> Float -> Float -> Float -> Float -> Color -> DrawOp
StrokeCircle (Float
cx Float -> Float -> Float
forall a. Num a => a -> a -> a
+ Float
dx) (Float
cy Float -> Float -> Float
forall a. Num a => a -> a -> a
+ Float
dy) Float
r Float
bw Color
c
StrokeLineAA Float
x0 Float
y0 Float
x1 Float
y1 Float
bw Color
c -> Float -> Float -> Float -> Float -> Float -> Color -> DrawOp
StrokeLineAA (Float
x0 Float -> Float -> Float
forall a. Num a => a -> a -> a
+ Float
dx) (Float
y0 Float -> Float -> Float
forall a. Num a => a -> a -> a
+ Float
dy) (Float
x1 Float -> Float -> Float
forall a. Num a => a -> a -> a
+ Float
dx) (Float
y1 Float -> Float -> Float
forall a. Num a => a -> a -> a
+ Float
dy) Float
bw Color
c
FillQuadGradient (Rect Float
x Float
y Float
w Float
h) Color
c0 Color
c1 Color
c2 Color
c3 -> Rect -> Color -> Color -> Color -> Color -> DrawOp
FillQuadGradient (Float -> Float -> Float -> Float -> Rect
Rect (Float
x Float -> Float -> Float
forall a. Num a => a -> a -> a
+ Float
dx) (Float
y Float -> Float -> Float
forall a. Num a => a -> a -> a
+ Float
dy) Float
w Float
h) Color
c0 Color
c1 Color
c2 Color
c3
DrawImageRect (Rect Float
x Float
y Float
w Float
h) Int
tex Float
u0 Float
v0 Float
u1 Float
v1 Color
c -> Rect -> Int -> Float -> Float -> Float -> Float -> Color -> DrawOp
DrawImageRect (Float -> Float -> Float -> Float -> Rect
Rect (Float
x Float -> Float -> Float
forall a. Num a => a -> a -> a
+ Float
dx) (Float
y Float -> Float -> Float
forall a. Num a => a -> a -> a
+ Float
dy) Float
w Float
h) Int
tex Float
u0 Float
v0 Float
u1 Float
v1 Color
c
DrawText Float
x Float
y Float
ax Float
ay Text
t Color
c -> Float -> Float -> Float -> Float -> Text -> Color -> DrawOp
DrawText (Float
x Float -> Float -> Float
forall a. Num a => a -> a -> a
+ Float
dx) (Float
y Float -> Float -> Float
forall a. Num a => a -> a -> a
+ Float
dy) Float
ax Float
ay Text
t Color
c
DrawTextStyled Float
x Float
y TextFont
font Text
t Color
c -> Float -> Float -> TextFont -> Text -> Color -> DrawOp
DrawTextStyled (Float
x Float -> Float -> Float
forall a. Num a => a -> a -> a
+ Float
dx) (Float
y Float -> Float -> Float
forall a. Num a => a -> a -> a
+ Float
dy) TextFont
font Text
t Color
c
type DrawingBuild = Rect -> SmallArray DrawOp
data DrawCmd = DrawCmd
{ DrawCmd -> Float
cmdClipX :: {-# UNPACK #-} !Float
, DrawCmd -> Float
cmdClipY :: {-# UNPACK #-} !Float
, DrawCmd -> Float
cmdClipW :: {-# UNPACK #-} !Float
, DrawCmd -> Float
cmdClipH :: {-# UNPACK #-} !Float
, DrawCmd -> Int
cmdTextureId :: {-# UNPACK #-} !Int
, DrawCmd -> Word32
cmdIndexOffset :: {-# UNPACK #-} !Word32
, DrawCmd -> Word32
cmdIndexCount :: {-# UNPACK #-} !Word32
, DrawCmd -> Layer
cmdLayer :: !Layer
}
deriving (DrawCmd -> DrawCmd -> Bool
(DrawCmd -> DrawCmd -> Bool)
-> (DrawCmd -> DrawCmd -> Bool) -> Eq DrawCmd
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: DrawCmd -> DrawCmd -> Bool
== :: DrawCmd -> DrawCmd -> Bool
$c/= :: DrawCmd -> DrawCmd -> Bool
/= :: DrawCmd -> DrawCmd -> Bool
Eq, Int -> DrawCmd -> ShowS
[DrawCmd] -> ShowS
DrawCmd -> String
(Int -> DrawCmd -> ShowS)
-> (DrawCmd -> String) -> ([DrawCmd] -> ShowS) -> Show DrawCmd
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> DrawCmd -> ShowS
showsPrec :: Int -> DrawCmd -> ShowS
$cshow :: DrawCmd -> String
show :: DrawCmd -> String
$cshowList :: [DrawCmd] -> ShowS
showList :: [DrawCmd] -> ShowS
Show)
data LayerSlice = LayerSlice
{ LayerSlice -> Int
sliceOffset :: {-# UNPACK #-} !Int
, LayerSlice -> Int
sliceCount :: {-# UNPACK #-} !Int
}
deriving (LayerSlice -> LayerSlice -> Bool
(LayerSlice -> LayerSlice -> Bool)
-> (LayerSlice -> LayerSlice -> Bool) -> Eq LayerSlice
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: LayerSlice -> LayerSlice -> Bool
== :: LayerSlice -> LayerSlice -> Bool
$c/= :: LayerSlice -> LayerSlice -> Bool
/= :: LayerSlice -> LayerSlice -> Bool
Eq, Int -> LayerSlice -> ShowS
[LayerSlice] -> ShowS
LayerSlice -> String
(Int -> LayerSlice -> ShowS)
-> (LayerSlice -> String)
-> ([LayerSlice] -> ShowS)
-> Show LayerSlice
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> LayerSlice -> ShowS
showsPrec :: Int -> LayerSlice -> ShowS
$cshow :: LayerSlice -> String
show :: LayerSlice -> String
$cshowList :: [LayerSlice] -> ShowS
showList :: [LayerSlice] -> ShowS
Show)
instance Prim LayerSlice where
sizeOfType# :: Proxy LayerSlice -> Int#
sizeOfType# Proxy LayerSlice
_ = Int#
16#
alignmentOfType# :: Proxy LayerSlice -> Int#
alignmentOfType# Proxy LayerSlice
_ = Int#
8#
indexByteArray# :: ByteArray# -> Int# -> LayerSlice
indexByteArray# ByteArray#
arr# Int#
i# =
let o# :: Int#
o# = Int#
i# Int# -> Int# -> Int#
*# Int#
16#
in Int -> Int -> LayerSlice
LayerSlice
(Int# -> Int
I# (ByteArray# -> Int# -> Int#
indexWord8ArrayAsInt# ByteArray#
arr# Int#
o#))
(Int# -> Int
I# (ByteArray# -> Int# -> Int#
indexWord8ArrayAsInt# ByteArray#
arr# (Int#
o# Int# -> Int# -> Int#
+# Int#
8#)))
readByteArray# :: forall s.
MutableByteArray# s
-> Int# -> State# s -> (# State# s, LayerSlice #)
readByteArray# MutableByteArray# s
arr# Int#
i# State# s
s0 =
let o# :: Int#
o# = Int#
i# Int# -> Int# -> Int#
*# Int#
16#
in case MutableByteArray# s -> Int# -> State# s -> (# State# s, Int# #)
forall d.
MutableByteArray# d -> Int# -> State# d -> (# State# d, Int# #)
readWord8ArrayAsInt# MutableByteArray# s
arr# Int#
o# State# s
s0 of
(# State# s
s1, Int#
off# #) ->
case MutableByteArray# s -> Int# -> State# s -> (# State# s, Int# #)
forall d.
MutableByteArray# d -> Int# -> State# d -> (# State# d, Int# #)
readWord8ArrayAsInt# MutableByteArray# s
arr# (Int#
o# Int# -> Int# -> Int#
+# Int#
8#) State# s
s1 of
(# State# s
s2, Int#
cnt# #) -> (# State# s
s2, Int -> Int -> LayerSlice
LayerSlice (Int# -> Int
I# Int#
off#) (Int# -> Int
I# Int#
cnt#) #)
writeByteArray# :: forall s.
MutableByteArray# s -> Int# -> LayerSlice -> State# s -> State# s
writeByteArray# MutableByteArray# s
arr# Int#
i# (LayerSlice (I# Int#
off#) (I# Int#
cnt#)) State# s
s0 =
let o# :: Int#
o# = Int#
i# Int# -> Int# -> Int#
*# Int#
16#
in MutableByteArray# s -> Int# -> Int# -> State# s -> State# s
forall d.
MutableByteArray# d -> Int# -> Int# -> State# d -> State# d
writeWord8ArrayAsInt# MutableByteArray# s
arr# (Int#
o# Int# -> Int# -> Int#
+# Int#
8#) Int#
cnt# (MutableByteArray# s -> Int# -> Int# -> State# s -> State# s
forall d.
MutableByteArray# d -> Int# -> Int# -> State# d -> State# d
writeWord8ArrayAsInt# MutableByteArray# s
arr# Int#
o# Int#
off# State# s
s0)
setByteArray# :: forall s.
MutableByteArray# s
-> Int# -> Int# -> LayerSlice -> State# s -> State# s
setByteArray# = MutableByteArray# s
-> Int# -> Int# -> LayerSlice -> State# s -> State# s
forall a s.
Prim a =>
MutableByteArray# s -> Int# -> Int# -> a -> State# s -> State# s
defaultSetByteArray#
indexOffAddr# :: Addr# -> Int# -> LayerSlice
indexOffAddr# Addr#
addr# Int#
i# =
let a# :: Addr#
a# = Addr#
addr# Addr# -> Int# -> Addr#
`plusAddr#` (Int#
i# Int# -> Int# -> Int#
*# Int#
16#)
in Int -> Int -> LayerSlice
LayerSlice (Int# -> Int
I# (Addr# -> Int# -> Int#
indexIntOffAddr# Addr#
a# Int#
0#)) (Int# -> Int
I# (Addr# -> Int# -> Int#
indexIntOffAddr# (Addr#
a# Addr# -> Int# -> Addr#
`plusAddr#` Int#
8#) Int#
0#))
readOffAddr# :: forall s. Addr# -> Int# -> State# s -> (# State# s, LayerSlice #)
readOffAddr# Addr#
addr# Int#
i# State# s
s0 =
let a# :: Addr#
a# = Addr#
addr# Addr# -> Int# -> Addr#
`plusAddr#` (Int#
i# Int# -> Int# -> Int#
*# Int#
16#)
in case Addr# -> Int# -> State# s -> (# State# s, Int# #)
forall d. Addr# -> Int# -> State# d -> (# State# d, Int# #)
readIntOffAddr# Addr#
a# Int#
0# State# s
s0 of
(# State# s
s1, Int#
off# #) ->
case Addr# -> Int# -> State# s -> (# State# s, Int# #)
forall d. Addr# -> Int# -> State# d -> (# State# d, Int# #)
readIntOffAddr# (Addr#
a# Addr# -> Int# -> Addr#
`plusAddr#` Int#
8#) Int#
0# State# s
s1 of
(# State# s
s2, Int#
cnt# #) -> (# State# s
s2, Int -> Int -> LayerSlice
LayerSlice (Int# -> Int
I# Int#
off#) (Int# -> Int
I# Int#
cnt#) #)
writeOffAddr# :: forall s. Addr# -> Int# -> LayerSlice -> State# s -> State# s
writeOffAddr# Addr#
addr# Int#
i# (LayerSlice (I# Int#
off#) (I# Int#
cnt#)) State# s
s0 =
let a# :: Addr#
a# = Addr#
addr# Addr# -> Int# -> Addr#
`plusAddr#` (Int#
i# Int# -> Int# -> Int#
*# Int#
16#)
in Addr# -> Int# -> Int# -> State# s -> State# s
forall d. Addr# -> Int# -> Int# -> State# d -> State# d
writeIntOffAddr# (Addr#
a# Addr# -> Int# -> Addr#
`plusAddr#` Int#
8#) Int#
0# Int#
cnt# (Addr# -> Int# -> Int# -> State# s -> State# s
forall d. Addr# -> Int# -> Int# -> State# d -> State# d
writeIntOffAddr# Addr#
a# Int#
0# Int#
off# State# s
s0)
setOffAddr# :: forall s.
Addr# -> Int# -> Int# -> LayerSlice -> State# s -> State# s
setOffAddr# = Addr# -> Int# -> Int# -> LayerSlice -> State# s -> State# s
forall a s.
Prim a =>
Addr# -> Int# -> Int# -> a -> State# s -> State# s
defaultSetOffAddr#
{-# INLINE layerToWord8 #-}
layerToWord8 :: Layer -> Word8
layerToWord8 :: Layer -> Word8
layerToWord8 Layer
ly = Int -> Word8
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Layer -> Int
forall a. Enum a => a -> Int
fromEnum Layer
ly)
{-# INLINE layerFromWord8 #-}
layerFromWord8 :: Word8 -> Layer
layerFromWord8 :: Word8 -> Layer
layerFromWord8 Word8
w = Int -> Layer
forall a. Enum a => Int -> a
toEnum (Word8 -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral Word8
w)
instance Prim DrawCmd where
sizeOfType# :: Proxy DrawCmd -> Int#
sizeOfType# Proxy DrawCmd
_ = Int#
40#
alignmentOfType# :: Proxy DrawCmd -> Int#
alignmentOfType# Proxy DrawCmd
_ = Int#
8#
indexByteArray# :: ByteArray# -> Int# -> DrawCmd
indexByteArray# ByteArray#
arr# Int#
i# =
let o# :: Int#
o# = Int#
i# Int# -> Int# -> Int#
*# Int#
40#
in Float
-> Float
-> Float
-> Float
-> Int
-> Word32
-> Word32
-> Layer
-> DrawCmd
DrawCmd
(Float# -> Float
F# (ByteArray# -> Int# -> Float#
indexWord8ArrayAsFloat# ByteArray#
arr# Int#
o#))
(Float# -> Float
F# (ByteArray# -> Int# -> Float#
indexWord8ArrayAsFloat# ByteArray#
arr# (Int#
o# Int# -> Int# -> Int#
+# Int#
4#)))
(Float# -> Float
F# (ByteArray# -> Int# -> Float#
indexWord8ArrayAsFloat# ByteArray#
arr# (Int#
o# Int# -> Int# -> Int#
+# Int#
8#)))
(Float# -> Float
F# (ByteArray# -> Int# -> Float#
indexWord8ArrayAsFloat# ByteArray#
arr# (Int#
o# Int# -> Int# -> Int#
+# Int#
12#)))
(Int# -> Int
I# (ByteArray# -> Int# -> Int#
indexWord8ArrayAsInt# ByteArray#
arr# (Int#
o# Int# -> Int# -> Int#
+# Int#
16#)))
(Word32# -> Word32
W32# (ByteArray# -> Int# -> Word32#
indexWord8ArrayAsWord32# ByteArray#
arr# (Int#
o# Int# -> Int# -> Int#
+# Int#
24#)))
(Word32# -> Word32
W32# (ByteArray# -> Int# -> Word32#
indexWord8ArrayAsWord32# ByteArray#
arr# (Int#
o# Int# -> Int# -> Int#
+# Int#
28#)))
(Word8 -> Layer
layerFromWord8 (Word8# -> Word8
W8# (ByteArray# -> Int# -> Word8#
indexWord8Array# ByteArray#
arr# (Int#
o# Int# -> Int# -> Int#
+# Int#
32#))))
readByteArray# :: forall s.
MutableByteArray# s -> Int# -> State# s -> (# State# s, DrawCmd #)
readByteArray# MutableByteArray# s
arr# Int#
i# State# s
s0 =
let o# :: Int#
o# = Int#
i# Int# -> Int# -> Int#
*# Int#
40#
in case MutableByteArray# s -> Int# -> State# s -> (# State# s, Float# #)
forall d.
MutableByteArray# d -> Int# -> State# d -> (# State# d, Float# #)
readWord8ArrayAsFloat# MutableByteArray# s
arr# Int#
o# State# s
s0 of
(# State# s
s1, Float#
x# #) ->
case MutableByteArray# s -> Int# -> State# s -> (# State# s, Float# #)
forall d.
MutableByteArray# d -> Int# -> State# d -> (# State# d, Float# #)
readWord8ArrayAsFloat# MutableByteArray# s
arr# (Int#
o# Int# -> Int# -> Int#
+# Int#
4#) State# s
s1 of
(# State# s
s2, Float#
y# #) ->
case MutableByteArray# s -> Int# -> State# s -> (# State# s, Float# #)
forall d.
MutableByteArray# d -> Int# -> State# d -> (# State# d, Float# #)
readWord8ArrayAsFloat# MutableByteArray# s
arr# (Int#
o# Int# -> Int# -> Int#
+# Int#
8#) State# s
s2 of
(# State# s
s3, Float#
w# #) ->
case MutableByteArray# s -> Int# -> State# s -> (# State# s, Float# #)
forall d.
MutableByteArray# d -> Int# -> State# d -> (# State# d, Float# #)
readWord8ArrayAsFloat# MutableByteArray# s
arr# (Int#
o# Int# -> Int# -> Int#
+# Int#
12#) State# s
s3 of
(# State# s
s4, Float#
h# #) ->
case MutableByteArray# s -> Int# -> State# s -> (# State# s, Int# #)
forall d.
MutableByteArray# d -> Int# -> State# d -> (# State# d, Int# #)
readWord8ArrayAsInt# MutableByteArray# s
arr# (Int#
o# Int# -> Int# -> Int#
+# Int#
16#) State# s
s4 of
(# State# s
s5, Int#
tex# #) ->
case MutableByteArray# s -> Int# -> State# s -> (# State# s, Word32# #)
forall d.
MutableByteArray# d -> Int# -> State# d -> (# State# d, Word32# #)
readWord8ArrayAsWord32# MutableByteArray# s
arr# (Int#
o# Int# -> Int# -> Int#
+# Int#
24#) State# s
s5 of
(# State# s
s6, Word32#
off# #) ->
case MutableByteArray# s -> Int# -> State# s -> (# State# s, Word32# #)
forall d.
MutableByteArray# d -> Int# -> State# d -> (# State# d, Word32# #)
readWord8ArrayAsWord32# MutableByteArray# s
arr# (Int#
o# Int# -> Int# -> Int#
+# Int#
28#) State# s
s6 of
(# State# s
s7, Word32#
cnt# #) ->
case MutableByteArray# s -> Int# -> State# s -> (# State# s, Word8# #)
forall d.
MutableByteArray# d -> Int# -> State# d -> (# State# d, Word8# #)
readWord8Array# MutableByteArray# s
arr# (Int#
o# Int# -> Int# -> Int#
+# Int#
32#) State# s
s7 of
(# State# s
s8, Word8#
ly# #) ->
(# State# s
s8
, Float
-> Float
-> Float
-> Float
-> Int
-> Word32
-> Word32
-> Layer
-> DrawCmd
DrawCmd
(Float# -> Float
F# Float#
x#)
(Float# -> Float
F# Float#
y#)
(Float# -> Float
F# Float#
w#)
(Float# -> Float
F# Float#
h#)
(Int# -> Int
I# Int#
tex#)
(Word32# -> Word32
W32# Word32#
off#)
(Word32# -> Word32
W32# Word32#
cnt#)
(Word8 -> Layer
layerFromWord8 (Word8# -> Word8
W8# Word8#
ly#))
#)
writeByteArray# :: forall s.
MutableByteArray# s -> Int# -> DrawCmd -> State# s -> State# s
writeByteArray# MutableByteArray# s
arr# Int#
i# DrawCmd
cmd State# s
s0 =
case DrawCmd
cmd of
DrawCmd (F# Float#
x#) (F# Float#
y#) (F# Float#
w#) (F# Float#
h#) (I# Int#
tex#) (W32# Word32#
off#) (W32# Word32#
cnt#) Layer
ly ->
let o# :: Int#
o# = Int#
i# Int# -> Int# -> Int#
*# Int#
40#
!(W8# Word8#
ly#) = Layer -> Word8
layerToWord8 Layer
ly
in MutableByteArray# s -> Int# -> Word8# -> State# s -> State# s
forall d.
MutableByteArray# d -> Int# -> Word8# -> State# d -> State# d
writeWord8Array# MutableByteArray# s
arr# (Int#
o# Int# -> Int# -> Int#
+# Int#
32#) Word8#
ly# (State# s -> State# s) -> State# s -> State# s
forall a b. (a -> b) -> a -> b
$
MutableByteArray# s -> Int# -> Word32# -> State# s -> State# s
forall d.
MutableByteArray# d -> Int# -> Word32# -> State# d -> State# d
writeWord8ArrayAsWord32# MutableByteArray# s
arr# (Int#
o# Int# -> Int# -> Int#
+# Int#
28#) Word32#
cnt# (State# s -> State# s) -> State# s -> State# s
forall a b. (a -> b) -> a -> b
$
MutableByteArray# s -> Int# -> Word32# -> State# s -> State# s
forall d.
MutableByteArray# d -> Int# -> Word32# -> State# d -> State# d
writeWord8ArrayAsWord32# MutableByteArray# s
arr# (Int#
o# Int# -> Int# -> Int#
+# Int#
24#) Word32#
off# (State# s -> State# s) -> State# s -> State# s
forall a b. (a -> b) -> a -> b
$
MutableByteArray# s -> Int# -> Int# -> State# s -> State# s
forall d.
MutableByteArray# d -> Int# -> Int# -> State# d -> State# d
writeWord8ArrayAsInt# MutableByteArray# s
arr# (Int#
o# Int# -> Int# -> Int#
+# Int#
16#) Int#
tex# (State# s -> State# s) -> State# s -> State# s
forall a b. (a -> b) -> a -> b
$
MutableByteArray# s -> Int# -> Float# -> State# s -> State# s
forall d.
MutableByteArray# d -> Int# -> Float# -> State# d -> State# d
writeWord8ArrayAsFloat# MutableByteArray# s
arr# (Int#
o# Int# -> Int# -> Int#
+# Int#
12#) Float#
h# (State# s -> State# s) -> State# s -> State# s
forall a b. (a -> b) -> a -> b
$
MutableByteArray# s -> Int# -> Float# -> State# s -> State# s
forall d.
MutableByteArray# d -> Int# -> Float# -> State# d -> State# d
writeWord8ArrayAsFloat# MutableByteArray# s
arr# (Int#
o# Int# -> Int# -> Int#
+# Int#
8#) Float#
w# (State# s -> State# s) -> State# s -> State# s
forall a b. (a -> b) -> a -> b
$
MutableByteArray# s -> Int# -> Float# -> State# s -> State# s
forall d.
MutableByteArray# d -> Int# -> Float# -> State# d -> State# d
writeWord8ArrayAsFloat# MutableByteArray# s
arr# (Int#
o# Int# -> Int# -> Int#
+# Int#
4#) Float#
y# (State# s -> State# s) -> State# s -> State# s
forall a b. (a -> b) -> a -> b
$
MutableByteArray# s -> Int# -> Float# -> State# s -> State# s
forall d.
MutableByteArray# d -> Int# -> Float# -> State# d -> State# d
writeWord8ArrayAsFloat# MutableByteArray# s
arr# Int#
o# Float#
x# State# s
s0
setByteArray# :: forall s.
MutableByteArray# s
-> Int# -> Int# -> DrawCmd -> State# s -> State# s
setByteArray# = MutableByteArray# s
-> Int# -> Int# -> DrawCmd -> State# s -> State# s
forall a s.
Prim a =>
MutableByteArray# s -> Int# -> Int# -> a -> State# s -> State# s
defaultSetByteArray#
indexOffAddr# :: Addr# -> Int# -> DrawCmd
indexOffAddr# Addr#
addr# Int#
i# =
let a# :: Addr#
a# = Addr#
addr# Addr# -> Int# -> Addr#
`plusAddr#` (Int#
i# Int# -> Int# -> Int#
*# Int#
40#)
in Float
-> Float
-> Float
-> Float
-> Int
-> Word32
-> Word32
-> Layer
-> DrawCmd
DrawCmd
(Float# -> Float
F# (Addr# -> Int# -> Float#
indexFloatOffAddr# Addr#
a# Int#
0#))
(Float# -> Float
F# (Addr# -> Int# -> Float#
indexFloatOffAddr# (Addr#
a# Addr# -> Int# -> Addr#
`plusAddr#` Int#
4#) Int#
0#))
(Float# -> Float
F# (Addr# -> Int# -> Float#
indexFloatOffAddr# (Addr#
a# Addr# -> Int# -> Addr#
`plusAddr#` Int#
8#) Int#
0#))
(Float# -> Float
F# (Addr# -> Int# -> Float#
indexFloatOffAddr# (Addr#
a# Addr# -> Int# -> Addr#
`plusAddr#` Int#
12#) Int#
0#))
(Int# -> Int
I# (Addr# -> Int# -> Int#
indexIntOffAddr# (Addr#
a# Addr# -> Int# -> Addr#
`plusAddr#` Int#
16#) Int#
0#))
(Word32# -> Word32
W32# (Addr# -> Int# -> Word32#
indexWord32OffAddr# (Addr#
a# Addr# -> Int# -> Addr#
`plusAddr#` Int#
24#) Int#
0#))
(Word32# -> Word32
W32# (Addr# -> Int# -> Word32#
indexWord32OffAddr# (Addr#
a# Addr# -> Int# -> Addr#
`plusAddr#` Int#
28#) Int#
0#))
(Word8 -> Layer
layerFromWord8 (Word8# -> Word8
W8# (Addr# -> Int# -> Word8#
indexWord8OffAddr# (Addr#
a# Addr# -> Int# -> Addr#
`plusAddr#` Int#
32#) Int#
0#)))
readOffAddr# :: forall s. Addr# -> Int# -> State# s -> (# State# s, DrawCmd #)
readOffAddr# Addr#
addr# Int#
i# State# s
s0 =
let a# :: Addr#
a# = Addr#
addr# Addr# -> Int# -> Addr#
`plusAddr#` (Int#
i# Int# -> Int# -> Int#
*# Int#
40#)
in case Addr# -> Int# -> State# s -> (# State# s, Float# #)
forall d. Addr# -> Int# -> State# d -> (# State# d, Float# #)
readFloatOffAddr# Addr#
a# Int#
0# State# s
s0 of
(# State# s
s1, Float#
x# #) ->
case Addr# -> Int# -> State# s -> (# State# s, Float# #)
forall d. Addr# -> Int# -> State# d -> (# State# d, Float# #)
readFloatOffAddr# (Addr#
a# Addr# -> Int# -> Addr#
`plusAddr#` Int#
4#) Int#
0# State# s
s1 of
(# State# s
s2, Float#
y# #) ->
case Addr# -> Int# -> State# s -> (# State# s, Float# #)
forall d. Addr# -> Int# -> State# d -> (# State# d, Float# #)
readFloatOffAddr# (Addr#
a# Addr# -> Int# -> Addr#
`plusAddr#` Int#
8#) Int#
0# State# s
s2 of
(# State# s
s3, Float#
w# #) ->
case Addr# -> Int# -> State# s -> (# State# s, Float# #)
forall d. Addr# -> Int# -> State# d -> (# State# d, Float# #)
readFloatOffAddr# (Addr#
a# Addr# -> Int# -> Addr#
`plusAddr#` Int#
12#) Int#
0# State# s
s3 of
(# State# s
s4, Float#
h# #) ->
case Addr# -> Int# -> State# s -> (# State# s, Int# #)
forall d. Addr# -> Int# -> State# d -> (# State# d, Int# #)
readIntOffAddr# (Addr#
a# Addr# -> Int# -> Addr#
`plusAddr#` Int#
16#) Int#
0# State# s
s4 of
(# State# s
s5, Int#
tex# #) ->
case Addr# -> Int# -> State# s -> (# State# s, Word32# #)
forall d. Addr# -> Int# -> State# d -> (# State# d, Word32# #)
readWord32OffAddr# (Addr#
a# Addr# -> Int# -> Addr#
`plusAddr#` Int#
24#) Int#
0# State# s
s5 of
(# State# s
s6, Word32#
off# #) ->
case Addr# -> Int# -> State# s -> (# State# s, Word32# #)
forall d. Addr# -> Int# -> State# d -> (# State# d, Word32# #)
readWord32OffAddr# (Addr#
a# Addr# -> Int# -> Addr#
`plusAddr#` Int#
28#) Int#
0# State# s
s6 of
(# State# s
s7, Word32#
cnt# #) ->
case Addr# -> Int# -> State# s -> (# State# s, Word8# #)
forall d. Addr# -> Int# -> State# d -> (# State# d, Word8# #)
readWord8OffAddr# (Addr#
a# Addr# -> Int# -> Addr#
`plusAddr#` Int#
32#) Int#
0# State# s
s7 of
(# State# s
s8, Word8#
ly# #) ->
(# State# s
s8
, Float
-> Float
-> Float
-> Float
-> Int
-> Word32
-> Word32
-> Layer
-> DrawCmd
DrawCmd
(Float# -> Float
F# Float#
x#)
(Float# -> Float
F# Float#
y#)
(Float# -> Float
F# Float#
w#)
(Float# -> Float
F# Float#
h#)
(Int# -> Int
I# Int#
tex#)
(Word32# -> Word32
W32# Word32#
off#)
(Word32# -> Word32
W32# Word32#
cnt#)
(Word8 -> Layer
layerFromWord8 (Word8# -> Word8
W8# Word8#
ly#))
#)
writeOffAddr# :: forall s. Addr# -> Int# -> DrawCmd -> State# s -> State# s
writeOffAddr# Addr#
addr# Int#
i# DrawCmd
cmd State# s
s0 =
case DrawCmd
cmd of
DrawCmd (F# Float#
x#) (F# Float#
y#) (F# Float#
w#) (F# Float#
h#) (I# Int#
tex#) (W32# Word32#
off#) (W32# Word32#
cnt#) Layer
ly ->
let a# :: Addr#
a# = Addr#
addr# Addr# -> Int# -> Addr#
`plusAddr#` (Int#
i# Int# -> Int# -> Int#
*# Int#
40#)
!(W8# Word8#
ly#) = Layer -> Word8
layerToWord8 Layer
ly
in Addr# -> Int# -> Word8# -> State# s -> State# s
forall d. Addr# -> Int# -> Word8# -> State# d -> State# d
writeWord8OffAddr# (Addr#
a# Addr# -> Int# -> Addr#
`plusAddr#` Int#
32#) Int#
0# Word8#
ly# (State# s -> State# s) -> State# s -> State# s
forall a b. (a -> b) -> a -> b
$
Addr# -> Int# -> Word32# -> State# s -> State# s
forall d. Addr# -> Int# -> Word32# -> State# d -> State# d
writeWord32OffAddr# (Addr#
a# Addr# -> Int# -> Addr#
`plusAddr#` Int#
28#) Int#
0# Word32#
cnt# (State# s -> State# s) -> State# s -> State# s
forall a b. (a -> b) -> a -> b
$
Addr# -> Int# -> Word32# -> State# s -> State# s
forall d. Addr# -> Int# -> Word32# -> State# d -> State# d
writeWord32OffAddr# (Addr#
a# Addr# -> Int# -> Addr#
`plusAddr#` Int#
24#) Int#
0# Word32#
off# (State# s -> State# s) -> State# s -> State# s
forall a b. (a -> b) -> a -> b
$
Addr# -> Int# -> Int# -> State# s -> State# s
forall d. Addr# -> Int# -> Int# -> State# d -> State# d
writeIntOffAddr# (Addr#
a# Addr# -> Int# -> Addr#
`plusAddr#` Int#
16#) Int#
0# Int#
tex# (State# s -> State# s) -> State# s -> State# s
forall a b. (a -> b) -> a -> b
$
Addr# -> Int# -> Float# -> State# s -> State# s
forall d. Addr# -> Int# -> Float# -> State# d -> State# d
writeFloatOffAddr# (Addr#
a# Addr# -> Int# -> Addr#
`plusAddr#` Int#
12#) Int#
0# Float#
h# (State# s -> State# s) -> State# s -> State# s
forall a b. (a -> b) -> a -> b
$
Addr# -> Int# -> Float# -> State# s -> State# s
forall d. Addr# -> Int# -> Float# -> State# d -> State# d
writeFloatOffAddr# (Addr#
a# Addr# -> Int# -> Addr#
`plusAddr#` Int#
8#) Int#
0# Float#
w# (State# s -> State# s) -> State# s -> State# s
forall a b. (a -> b) -> a -> b
$
Addr# -> Int# -> Float# -> State# s -> State# s
forall d. Addr# -> Int# -> Float# -> State# d -> State# d
writeFloatOffAddr# (Addr#
a# Addr# -> Int# -> Addr#
`plusAddr#` Int#
4#) Int#
0# Float#
y# (State# s -> State# s) -> State# s -> State# s
forall a b. (a -> b) -> a -> b
$
Addr# -> Int# -> Float# -> State# s -> State# s
forall d. Addr# -> Int# -> Float# -> State# d -> State# d
writeFloatOffAddr# Addr#
a# Int#
0# Float#
x# State# s
s0
setOffAddr# :: forall s. Addr# -> Int# -> Int# -> DrawCmd -> State# s -> State# s
setOffAddr# = Addr# -> Int# -> Int# -> DrawCmd -> State# s -> State# s
forall a s.
Prim a =>
Addr# -> Int# -> Int# -> a -> State# s -> State# s
defaultSetOffAddr#
data DrawData = DrawData
{ DrawData -> ForeignPtr Word8
drawVertices :: ForeignPtr Word8
, DrawData -> Int
drawVertexCount :: {-# UNPACK #-} !Int
, DrawData -> ForeignPtr Word8
drawIndices :: ForeignPtr Word8
, DrawData -> Int
drawIndexCount :: {-# UNPACK #-} !Int
, DrawData -> PrimArray DrawCmd
drawCommands :: !(PrimArray DrawCmd)
, DrawData -> PrimArray LayerSlice
drawLayerSlices :: !(PrimArray LayerSlice)
}
{-# INLINE drawCmdCount #-}
drawCmdCount :: DrawData -> Int
drawCmdCount :: DrawData -> Int
drawCmdCount DrawData
dd = PrimArray DrawCmd -> Int
forall a. Prim a => PrimArray a -> Int
sizeofPrimArray (DrawData -> PrimArray DrawCmd
drawCommands DrawData
dd)
{-# INLINE drawCmdNull #-}
drawCmdNull :: DrawData -> Bool
drawCmdNull :: DrawData -> Bool
drawCmdNull DrawData
dd = DrawData -> Int
drawCmdCount DrawData
dd Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== Int
0
{-# INLINE forDrawCmdsInLayer_ #-}
forDrawCmdsInLayer_ :: Layer -> DrawData -> (DrawCmd -> IO ()) -> IO ()
forDrawCmdsInLayer_ :: Layer -> DrawData -> (DrawCmd -> IO ()) -> IO ()
forDrawCmdsInLayer_ Layer
ly DrawData
dd DrawCmd -> IO ()
f =
let LayerSlice Int
off Int
cnt = PrimArray LayerSlice -> Int -> LayerSlice
forall a. Prim a => PrimArray a -> Int -> a
indexPrimArray (DrawData -> PrimArray LayerSlice
drawLayerSlices DrawData
dd) (Layer -> Int
forall a. Enum a => a -> Int
fromEnum Layer
ly)
cmds :: PrimArray DrawCmd
cmds = DrawData -> PrimArray DrawCmd
drawCommands DrawData
dd
go :: Int -> IO ()
go !Int
i
| Int
i Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
>= Int
cnt = () -> IO ()
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure ()
| Bool
otherwise = DrawCmd -> IO ()
f (PrimArray DrawCmd -> Int -> DrawCmd
forall a. Prim a => PrimArray a -> Int -> a
indexPrimArray PrimArray DrawCmd
cmds (Int
off Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
i)) IO () -> IO () -> IO ()
forall a b. IO a -> IO b -> IO b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Int -> IO ()
go (Int
i Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
1)
in Int -> IO ()
go Int
0
drawCmdElems :: DrawData -> [DrawCmd]
drawCmdElems :: DrawData -> [DrawCmd]
drawCmdElems DrawData
dd =
let cmds :: PrimArray DrawCmd
cmds = DrawData -> PrimArray DrawCmd
drawCommands DrawData
dd
in [PrimArray DrawCmd -> Int -> DrawCmd
forall a. Prim a => PrimArray a -> Int -> a
indexPrimArray PrimArray DrawCmd
cmds Int
i | Int
i <- [Int
0 .. PrimArray DrawCmd -> Int
forall a. Prim a => PrimArray a -> Int
sizeofPrimArray PrimArray DrawCmd
cmds Int -> Int -> Int
forall a. Num a => a -> a -> a
- Int
1]]
type BufferPool = IORef [(ForeignPtr Word8, Int)]
data DrawArena = DrawArena
{ DrawArena -> IORef (ForeignPtr Word8)
daVertexFPtr :: !(IORef (ForeignPtr Word8))
, DrawArena -> IORef (Ptr Word8)
daVertexPtr :: !(IORef (Ptr Word8))
, DrawArena -> IORef Int
daVertexCap :: !(IORef Int)
, DrawArena -> IORef Int
daVertexCount :: !(IORef Int)
, DrawArena -> BufferPool
daVertexPool :: !BufferPool
, DrawArena -> IORef (ForeignPtr Word8)
daIndexFPtr :: !(IORef (ForeignPtr Word8))
, DrawArena -> IORef (Ptr Word8)
daIndexPtr :: !(IORef (Ptr Word8))
, DrawArena -> IORef Int
daIndexCap :: !(IORef Int)
, DrawArena -> IORef Int
daIndexCount :: !(IORef Int)
, DrawArena -> BufferPool
daIndexPool :: !BufferPool
, DrawArena -> IORef (MutablePrimArray RealWorld DrawCmd)
daCmdStore :: !(IORef (MutablePrimArray RealWorld DrawCmd))
, DrawArena -> IORef Int
daCmdCount :: !(IORef Int)
, DrawArena -> IORef Int
daCmdCapacity :: !(IORef Int)
, DrawArena -> IORef Layer
daCurrentLayer :: !(IORef Layer)
, DrawArena -> MutablePrimArray RealWorld Float
daCurrentClip :: !(MutablePrimArray RealWorld Float)
, DrawArena -> IORef Int
daCurrentTexture :: !(IORef Int)
, DrawArena -> IORef Int
daCmdStartIndex :: !(IORef Int)
, DrawArena -> IORef Float
daSnapScale :: !(IORef Float)
, DrawArena -> IORef Bool
daSquareGeometry :: !(IORef Bool)
, DrawArena -> IORef Bool
daExternalText :: !(IORef Bool)
}
vertexSize :: Int
vertexSize :: Int
vertexSize = Int
32
indexSize :: Int
indexSize :: Int
indexSize = Int
4
backdropDimTextureId :: Int
backdropDimTextureId :: Int
backdropDimTextureId = Int
0x7ffffffe
glyphAtlasTextureId :: Int
glyphAtlasTextureId :: Int
glyphAtlasTextureId = Int
0x7ffffffd