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 1822 - Inconsistent renderer behaviour on rotation
Summary: Inconsistent renderer behaviour on rotation
Status: RESOLVED FIXED
Alias: None
Product: SDL
Classification: Unclassified
Component: video (show other bugs)
Version: HG 2.0
Hardware: x86_64 Linux
: P2 minor
Assignee: Sam Lantinga
QA Contact: Sam Lantinga
URL:
Keywords: target-2.0.0
Depends on:
Blocks:
 
Reported: 2013-04-25 05:25 UTC by Sebastian
Modified: 2017-10-24 19:33 UTC (History)
2 users (show)

See Also:


Attachments
self contained testcase (needs sdl2 and sdl2_image) (7.95 KB, text/x-csrc)
2013-04-25 05:25 UTC, Sebastian
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Sebastian 2013-04-25 05:25:37 UTC
Created attachment 1124 [details]
self contained testcase (needs sdl2 and sdl2_image)

The different renderers behave differently when using RenderCopyEx with rotation on images with even width and height.

When rendering a 64x64 tile with 90.0 degrees rotation and a NULL center the resulting image is moved one pixel further to the right when using software or direct3d renderer than it would be when using the opengl renderer.

This is not really a problem when you force a renderer, but I guess it would be more consistent if all renderers behaved the same. 

I tested this on win and linux (each 64 bit).

You'll find a self contained testcase attached. To test the different renderers just uncomment the appropriate string at the top.
Comment 1 Ryan C. Gordon 2013-07-12 22:15:33 UTC
(Sorry if you get a lot of copies of this email, we're touching dozens of bug reports right now.)

Tagging a bunch of bugs as target-2.0.0, Priority 2.

This means we're in the final stretch for an official SDL 2.0.0 release! These are the bugs we really want to fix before shipping if humanly possible.

That being said, we don't promise to fix them because of this tag, we just want to make sure we don't forget to deal with them before we bless a final 2.0.0 release, and generally be organized about what we're aiming to ship.

Hopefully you'll hear more about this bug soon. If you have more information (including "this got fixed at some point, nevermind"), we would love to have you come add more information to the bug report when you have a moment.

Thanks!
--ryan.
Comment 2 Sylvain 2016-11-07 08:49:34 UTC
I believe the position is fixed from #2421


but there is still a weird behaviour with the renderer software:
when rotated +90 or -90, some transparent lines appears, though there is no Alpha or ColorKey.

if you set a dummy colorkey, it will remove the line ...
if you set a some alpha mod, the +90/-90 get transparent but not the 0/180  ...









   SDL_Surface *surf = IMG_Load_RW(SDL_RWFromMem((void*)street_vert_jpg, sizeof(street_vert_jpg)), 0); 
   SDL_PixelFormat  *pixel_format = SDL_AllocFormat(SDL_PIXELFORMAT_RGB888);
   SDL_Surface *surf2 = SDL_ConvertSurface(surf, pixel_format, 0); 
   SDL_SetColorKey(surf2, SDL_FALSE, 0); 
//   SDL_SetColorKey(surf2, SDL_TRUE, 999);// a colorkey would remove the lines ...
   SDL_SetSurfaceBlendMode(surf2, SDL_BLENDMODE_NONE);
//   SDL_SetSurfaceAlphaMod(surf2, 0); // setting alpha mod, make +90&-90 transparent
   SDL_Texture *tex = SDL_CreateTextureFromSurface(renderer, surf2);
Comment 3 Sylvain 2016-11-07 14:43:56 UTC
Plain black (0/0/0) was interpreted as a ColorKey, because SDL gfx rotate function uses former SDL-1.2 style to interpret SDL_Surface flags.

Some patch ...

--- a/src/render/software/SDL_rotate.c	Sun Nov 06 20:26:48 2016 -0800
+++ b/src/render/software/SDL_rotate.c	Mon Nov 07 15:40:47 2016 +0100
@@ -428,7 +428,7 @@
     if (src == NULL)
         return (NULL);
 
-    if (src->flags & SDL_TRUE/* SDL_SRCCOLORKEY */)
+    if (SDL_GetColorKey(src, &colorkey) == 0)
     {
         colorkey = _colorkey(src);
         SDL_GetRGB(colorkey, src->format, &r, &g, &b);
Comment 4 Sylvain 2016-11-07 14:54:47 UTC
oops wrong patch, the error was a little after: background surface had always the ColorKey set.



--- a/src/render/software/SDL_rotate.c	Sun Nov 06 20:26:48 2016 -0800
+++ b/src/render/software/SDL_rotate.c	Mon Nov 07 15:52:03 2016 +0100
@@ -526,7 +526,6 @@
         * Turn on source-alpha support
         */
         /* SDL_SetAlpha(rz_dst, SDL_SRCALPHA, 255); */
-        SDL_SetColorKey(rz_dst, /* SDL_SRCCOLORKEY */ SDL_TRUE | SDL_RLEACCEL, _colorkey(rz_src));
     } else {
         /*
         * Copy palette and colorkey info
@@ -543,7 +542,12 @@
         } else {
             transformSurfaceY(rz_src, rz_dst, centerx, centery, (int)(sangleinv), (int)(cangleinv), flipx, flipy);
         }
-        SDL_SetColorKey(rz_dst, /* SDL_SRCCOLORKEY */ SDL_TRUE | SDL_RLEACCEL, _colorkey(rz_src));
+    }
+
+    if (colorKeyAvailable == 1) {
+       SDL_SetColorKey(rz_dst, /* SDL_SRCCOLORKEY */ SDL_TRUE | SDL_RLEACCEL, _colorkey(rz_src));
+    } else {
+       SDL_SetColorKey(rz_dst, SDL_FALSE, 0);
     }
 
     /* copy alpha mod, color mod, and blend mode */
Comment 5 Sylvain 2017-10-24 19:33:43 UTC
that was fixed
https://hg.libsdl.org/SDL/rev/c7209688838b