Skip to content

Commit 0de9061

Browse files
tngafwlehmannpolarina
authored andcommitted
surfaceBlit returns the clipped dest rect
1 parent a3d6d1c commit 0de9061

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

ChangeLog.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
* `getMouseLocation` in `SDL.Input.Mouse`
1313
* Merge `isScreenSaverEnabled, `enableScreenSaver`, and `disableScreenSaver`
1414
into a `screenSaverEnabled` StateVar.
15+
* Make function `surfaceBlit` in `SDL.Video.Renderer` return final blit
16+
rectangle post-clipping.
1517
* Fix issue with `setWindowMode` transitions not working properly between
1618
fullscreen and windowed modes.
1719

src/SDL/Video/Renderer.hs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -155,12 +155,13 @@ surfaceBlit :: MonadIO m
155155
-> Maybe (Rectangle CInt) -- ^ The rectangle to be copied, or 'Nothing' to copy the entire surface
156156
-> Surface -- ^ The 'Surface' that is the blit target
157157
-> Maybe (Point V2 CInt) -- ^ The position to blit to
158-
-> m ()
158+
-> m (Maybe (Rectangle CInt))
159159
surfaceBlit (Surface src _) srcRect (Surface dst _) dstLoc = liftIO $
160-
throwIfNeg_ "SDL.Video.blitSurface" "SDL_BlitSurface" $
161160
maybeWith with srcRect $ \srcPtr ->
162-
maybeWith with (fmap (flip Rectangle 0) dstLoc) $ \dstPtr ->
163-
Raw.blitSurface src (castPtr srcPtr) dst (castPtr dstPtr)
161+
maybeWith with (fmap (flip Rectangle 0) dstLoc) $ \dstPtr -> do
162+
throwIfNeg "SDL.Video.blitSurface" "SDL_BlitSurface" $
163+
Raw.blitSurface src (castPtr srcPtr) dst (castPtr dstPtr)
164+
maybe (pure Nothing) (\_ -> Just <$> peek dstPtr) dstLoc
164165

165166
-- | Create a texture for a rendering context.
166167
--

0 commit comments

Comments
 (0)