| Summary: | SDL_BlitScaled does not handle clipping correctly | ||
|---|---|---|---|
| Product: | SDL | Reporter: | Benoit Pierre <benoit.pierre> |
| Component: | video | Assignee: | Sam Lantinga <slouken> |
| Status: | RESOLVED FIXED | QA Contact: | Sam Lantinga <slouken> |
| Severity: | normal | ||
| Priority: | P2 | CC: | philipp.wiesemann, sylvain.becker |
| Version: | 2.0.3 | ||
| Hardware: | x86_64 | ||
| OS: | Linux | ||
| Attachments: |
patch to fix SDL_BlitScaled clipping
Python test script add SDL_round patch to fix SDL_BlitScaled clipping drop SDL_round.... |
||
|
Description
Benoit Pierre
2014-08-15 15:00:14 UTC
Created attachment 1823 [details]
Python test script
(In reply to Benoit Pierre from comment #0) > Created attachment 1820 [details] > patch to fix SDL_BlitScaled clipping The patch uses round() from math.h but SDL does not link with the C standard library on every supported platform. Therefore round() should either be introduced as SDL_round() in SDL_stdinc.h or be replaced with other functions already available there. (In reply to Philipp Wiesemann from comment #2) > (In reply to Benoit Pierre from comment #0) > > Created attachment 1820 [details] > > patch to fix SDL_BlitScaled clipping > > The patch uses round() from math.h but SDL does not link with the C standard > library on every supported platform. Therefore round() should either be > introduced as SDL_round() in SDL_stdinc.h or be replaced with other > functions already available there. OK, so here is a patch that add SDL_round, lifting the actual implementation from uClibc, and an updated SDL_BlitScaled patch that depends on it. It tested both the Autotools and the CMake builds on Linux, with and without libmath round (by manually undefining HAVE_ROUND in SDL_config.h). I updated the various SDL_config_PLATFORM.h headers, defining HAVE_ROUND when HAVE_MATH was already. (I noticed the SDL_config_pandora.h has HAVE_MATH defined but not HAVE_POW, normal?) Created attachment 1824 [details]
add SDL_round
Created attachment 1825 [details]
patch to fix SDL_BlitScaled clipping
Looks good, thanks! https://hg.libsdl.org/SDL/rev/257a6793aaf5 https://hg.libsdl.org/SDL/rev/5e713281410c Great, but I don't see src/libm/s_round.c, did you forget to add it? :P Also, how would one go about updating the documentation on https://wiki.libsdl.org, just request an account and edit away? I'd like to update SDL_BlitScaled documentation to mention the fact that dstrect will be updated. Unlike the other files in src/libm the s_round.c from the patch was released under the GNU LGPL license. This may cause a license problem for the platforms were SDL would be using it (because it is compiled into SDL and not just dynamically linked). Created attachment 1827 [details]
drop SDL_round....
Damn, sorry about that... The attached patch drop SDL_round and just manually round with SDL_trunc(x + 0.5). Do you have an implementation of SDL_trunc()? :) Wow, this is embarrassing... :( I thought SDL already provided SDL_trunc... SDL_floor can be used instead.
But the real question, is why does the CMake build not compiles everything with a least -Wall? I don't get any warning at all! It builds, it links... No complaints! Of course the resulting library is missing SDL_trunc:
> objdump -t libSDL2-2.0.so | grep trunc
0000000000000000 *UND* 0000000000000000 SDL_trunc
Updated, using SDL_floor() https://hg.libsdl.org/SDL/rev/2e4e71ec140f for the record, https://hg.libsdl.org/SDL/rev/7101c5a0d561 - better fix to clip after scaling computation is done - add back back SDL_round (added in bug #5404) |