| Summary: | software renderer cuts off edges when rotate-blitting with a multiple of 90 degrees | ||
|---|---|---|---|
| Product: | SDL | Reporter: | Adam M. <adam> |
| Component: | render | Assignee: | Sam Lantinga <slouken> |
| Status: | RESOLVED FIXED | QA Contact: | Sam Lantinga <slouken> |
| Severity: | normal | ||
| Priority: | P2 | CC: | sezeroz |
| Version: | 2.0.3 | ||
| Hardware: | x86_64 | ||
| OS: | Windows 7 | ||
| Attachments: |
proposed patch (v1)
proposed patch (v2) |
||
Additionally, rotations by a multiple of 90 degrees (which is probably a much more common case than arbitrary rotation) can be done significantly faster than the current rotozoomer method. Since fixing the rotozoomer is a bit tricky, I'd rather just implement a fast path for these rotations that fixes the edge-clipping at the same time. Created attachment 2197 [details]
proposed patch (v1)
I've proposed a patch to fix this problem.
Don't apply this yet. There is a problem in the case of a 270 degree rotation when the rotation point is not the center. Created attachment 2198 [details]
proposed patch (v2)
Darn typos. Fixed patch attached.
If you want to reproduce this for yourself, create a surface containing a hollow rectangle of the same size as the surface. Then, attempt to do a rotate-blit with a rotation of 90 degrees. If the software renderer takes the anti-aliased path in the rotation code, two edges of the rectangle will be cut off. Fixed, thanks! https://hg.libsdl.org/SDL/rev/1e1ce9f6d215 |
When doing a rotated texture copy with the software renderer, where the angle is a multiple of 90 degrees, one or two edges of the image get cut off. This is because of the following line in sw_rotate.c: if ((unsigned)dx < (unsigned)sw && (unsigned)dy < (unsigned)sh) { which is effectively saying: if (dx >= 0 && dx < src->w-1 && dy >= 0 && dy < src->h-1) { As a result, it doesn't process pixels in the right column or bottom row of the source image (except when they're accessed as part of the bilinear filtering for nearby pixels). This causes it to look like the edges are cut off, and it's especially obvious with an exact multiple of 90 degrees.