only drawing on available surface area
This commit is contained in:
parent
ea8fdf37ee
commit
130d941779
1 changed files with 37 additions and 25 deletions
|
@ -12,6 +12,8 @@ module Affection.Draw
|
|||
|
||||
import Affection.Types
|
||||
|
||||
import Data.Maybe (maybe)
|
||||
|
||||
import Foreign
|
||||
import Foreign.C.Types
|
||||
|
||||
|
@ -75,18 +77,23 @@ handleDrawRequest
|
|||
handleDrawRequest pixels stride cpp dr@DrawRequest{..} = do
|
||||
ad <- get
|
||||
let surf = drawSurface ad
|
||||
liftIO $ SDL.lockSurface surf
|
||||
liftIO $ G.gegl_buffer_get
|
||||
requestBuffer
|
||||
(Just requestArea)
|
||||
1
|
||||
(Just $ drawFormat ad)
|
||||
(pixels `plusPtr`
|
||||
(rectangleX requestArea * cpp + rectangleY requestArea * stride))
|
||||
stride
|
||||
G.GeglAbyssNone
|
||||
liftIO $ SDL.unlockSurface surf
|
||||
-- liftIO $ SDL.updateWindowSurface $ drawWindow ad
|
||||
mrealRect <- liftIO $ G.gegl_rectangle_intersect
|
||||
requestArea
|
||||
(G.GeglRectangle 0 0 (fst $ drawDimensions ad) (snd $ drawDimensions ad))
|
||||
maybe (return()) (\realRect -> do
|
||||
liftIO $ SDL.lockSurface surf
|
||||
liftIO $ G.gegl_buffer_get
|
||||
requestBuffer
|
||||
(Just realRect)
|
||||
1
|
||||
(Just $ drawFormat ad)
|
||||
(pixels `plusPtr`
|
||||
(rectangleX realRect * cpp + rectangleY realRect * stride))
|
||||
stride
|
||||
G.GeglAbyssNone
|
||||
liftIO $ SDL.unlockSurface surf
|
||||
-- liftIO $ SDL.updateWindowSurface $ drawWindow ad
|
||||
) mrealRect
|
||||
case requestPersist of
|
||||
Yes ->
|
||||
return Nothing
|
||||
|
@ -103,19 +110,24 @@ invalidateDrawRequest
|
|||
-> Affection us ()
|
||||
invalidateDrawRequest pixels stride cpp dr@DrawRequest{..} = do
|
||||
ad <- get
|
||||
let surf = drawSurface ad
|
||||
liftIO $ clearArea requestBuffer requestArea
|
||||
liftIO $ SDL.lockSurface surf
|
||||
liftIO $ G.gegl_buffer_get
|
||||
requestBuffer
|
||||
(Just requestArea)
|
||||
1
|
||||
(Just $ drawFormat ad)
|
||||
(pixels `plusPtr`
|
||||
(rectangleX requestArea * cpp + rectangleY requestArea * stride))
|
||||
stride
|
||||
G.GeglAbyssNone
|
||||
liftIO $ SDL.unlockSurface surf
|
||||
mrealRect <- liftIO $ G.gegl_rectangle_intersect
|
||||
requestArea
|
||||
(G.GeglRectangle 0 0 (fst $ drawDimensions ad) (snd $ drawDimensions ad))
|
||||
maybe (return()) (\realRect -> do
|
||||
let surf = drawSurface ad
|
||||
liftIO $ clearArea requestBuffer realRect
|
||||
liftIO $ SDL.lockSurface surf
|
||||
liftIO $ G.gegl_buffer_get
|
||||
requestBuffer
|
||||
(Just realRect)
|
||||
1
|
||||
(Just $ drawFormat ad)
|
||||
(pixels `plusPtr`
|
||||
(rectangleX realRect * cpp + rectangleY realRect * stride))
|
||||
stride
|
||||
G.GeglAbyssNone
|
||||
liftIO $ SDL.unlockSurface surf
|
||||
) mrealRect
|
||||
case requestPersist of
|
||||
Kill (Just victim) ->
|
||||
liftIO $ G.gegl_node_drop victim
|
||||
|
|
Loading…
Reference in a new issue