We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 4188

Summary: Software renderer SDL_RenderCopyEx blits corrupt image under certain cases
Product: SDL Reporter: duckgrease
Component: renderAssignee: Sam Lantinga <slouken>
Status: RESOLVED FIXED QA Contact: Sam Lantinga <slouken>
Severity: normal    
Priority: P2 CC: sezeroz, sylvain.becker
Version: 2.0.8   
Hardware: x86_64   
OS: All   
Attachments: corrupt SDL_RenderCopyEx example code
patch
patch v2

Description duckgrease 2018-06-07 01:30:11 UTC
Created attachment 3255 [details]
corrupt SDL_RenderCopyEx example code

SDL_RenderCopyEx blits wrong image (in some cases it's bunch of alternating horizontal lines, some cases it's image from the wrong coordinate, and in some cases it's just a bunch of garbled pixels), when the following conditions are met:
- Use software renderer.
- Enable either horizontal or vertical flip.
- source and destination rectangles must have same width and height, and must be smaller than the size of the texture.
- source rectangle's X and Y coordinates must be 0.

I was able to reproduce this problem on both Windows 10 and Linux 64 bit, from version 2.0.3 to latest 2.0.8.

Attached an example (modified from the 2D software rendering example code). Go to line 62 and disable flip and you'll see non-corrupt image.
Comment 1 Sylvain 2018-10-09 09:46:12 UTC
Created attachment 3355 [details]
patch

You're right. This has never worked perfectly. 
Last commit was almost fine https://hg.libsdl.org/SDL/rev/1e1ce9f6d215 bug #3029

This patch fixes rotations 0/90/180/270 with/out flip (0, Vertical,Horizontal,Both).
Comment 2 Sam Lantinga 2018-10-10 00:41:58 UTC
Patch added, thanks!
https://hg.libsdl.org/SDL/rev/b19b09eb9e6d
Comment 3 Sylvain 2018-10-17 19:32:12 UTC
Created attachment 3381 [details]
patch v2

Re-opening this issue.

It fixes the test-case, but it introduces a regression with another bug (bug #4313).

So here's a new patch that activate cropping of the source surface to solve the issue.
It also reverts the wrong changeset.
It prevents unneeded colorkey error message.
Comment 4 Sylvain 2018-10-17 20:15:29 UTC
marked as reopened
Comment 5 Ozkan Sezer 2018-10-30 12:07:28 UTC
Sam:  Do we need this for 2.0.9 ?
Comment 6 Sylvain 2018-10-30 12:40:19 UTC
Oops, I forgot to activate you. Yep you really want this. It fixes my regression and the bug.
Comment 7 Sam Lantinga 2018-10-30 14:00:26 UTC
Patch added, thanks!
https://hg.libsdl.org/SDL/rev/bced4041fcc0