only drawing on available surface area

This commit is contained in:
nek0 2017-02-24 17:11:10 +01:00
parent ea8fdf37ee
commit 130d941779

View file

@ -12,6 +12,8 @@ module Affection.Draw
import Affection.Types import Affection.Types
import Data.Maybe (maybe)
import Foreign import Foreign
import Foreign.C.Types import Foreign.C.Types
@ -75,18 +77,23 @@ handleDrawRequest
handleDrawRequest pixels stride cpp dr@DrawRequest{..} = do handleDrawRequest pixels stride cpp dr@DrawRequest{..} = do
ad <- get ad <- get
let surf = drawSurface ad let surf = drawSurface ad
liftIO $ SDL.lockSurface surf mrealRect <- liftIO $ G.gegl_rectangle_intersect
liftIO $ G.gegl_buffer_get requestArea
requestBuffer (G.GeglRectangle 0 0 (fst $ drawDimensions ad) (snd $ drawDimensions ad))
(Just requestArea) maybe (return()) (\realRect -> do
1 liftIO $ SDL.lockSurface surf
(Just $ drawFormat ad) liftIO $ G.gegl_buffer_get
(pixels `plusPtr` requestBuffer
(rectangleX requestArea * cpp + rectangleY requestArea * stride)) (Just realRect)
stride 1
G.GeglAbyssNone (Just $ drawFormat ad)
liftIO $ SDL.unlockSurface surf (pixels `plusPtr`
-- liftIO $ SDL.updateWindowSurface $ drawWindow ad (rectangleX realRect * cpp + rectangleY realRect * stride))
stride
G.GeglAbyssNone
liftIO $ SDL.unlockSurface surf
-- liftIO $ SDL.updateWindowSurface $ drawWindow ad
) mrealRect
case requestPersist of case requestPersist of
Yes -> Yes ->
return Nothing return Nothing
@ -103,19 +110,24 @@ invalidateDrawRequest
-> Affection us () -> Affection us ()
invalidateDrawRequest pixels stride cpp dr@DrawRequest{..} = do invalidateDrawRequest pixels stride cpp dr@DrawRequest{..} = do
ad <- get ad <- get
let surf = drawSurface ad mrealRect <- liftIO $ G.gegl_rectangle_intersect
liftIO $ clearArea requestBuffer requestArea requestArea
liftIO $ SDL.lockSurface surf (G.GeglRectangle 0 0 (fst $ drawDimensions ad) (snd $ drawDimensions ad))
liftIO $ G.gegl_buffer_get maybe (return()) (\realRect -> do
requestBuffer let surf = drawSurface ad
(Just requestArea) liftIO $ clearArea requestBuffer realRect
1 liftIO $ SDL.lockSurface surf
(Just $ drawFormat ad) liftIO $ G.gegl_buffer_get
(pixels `plusPtr` requestBuffer
(rectangleX requestArea * cpp + rectangleY requestArea * stride)) (Just realRect)
stride 1
G.GeglAbyssNone (Just $ drawFormat ad)
liftIO $ SDL.unlockSurface surf (pixels `plusPtr`
(rectangleX realRect * cpp + rectangleY realRect * stride))
stride
G.GeglAbyssNone
liftIO $ SDL.unlockSurface surf
) mrealRect
case requestPersist of case requestPersist of
Kill (Just victim) -> Kill (Just victim) ->
liftIO $ G.gegl_node_drop victim liftIO $ G.gegl_node_drop victim