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 563 - test/testalpha.c background of smiley face is visible
Summary: test/testalpha.c background of smiley face is visible
Status: RESOLVED FIXED
Alias: None
Product: SDL
Classification: Unclassified
Component: video (show other bugs)
Version: HG 2.0
Hardware: x86 Linux
: P2 normal
Assignee: Sam Lantinga
QA Contact: Sam Lantinga
URL:
Keywords:
: 580 (view as bug list)
Depends on:
Blocks:
 
Reported: 2008-02-29 09:39 UTC by Bob Pendleton
Modified: 2008-11-25 11:41 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Bob Pendleton 2008-02-29 09:39:10 UTC
Run testalpha and wait for a few seconds. The white background around the smiley face suddenly becomes visible. That is the part of the image that is supposed to be alpha blended away.
Comment 1 Bob Pendleton 2008-03-14 10:50:04 UTC
What is happening is something like this. The sprite is an RLE surface that is also being alpha blended. Everything works fine until the alpha level reaches 255. At that point the blit code decides to recompute the blit function to optimize for what is now an opaque alpha level. As part of that it calls  SDL_UnRLESurface which seems to lose the colorkey information which was used when the sprite was RLE compressed. 

I've added a printf to SDL_LowerBlit to trace the the address of the src & dst and their flags values after the call to SDL_MapSurface. I'll check it in with the line commented out. 

Here are the results of that line from the start of the program through showing the bug:

bob@voyager:~/sdl/sdl1.3/test$ testalpha 
src = 0x00661DC0 src->flags = 00000000 src->map->info.flags = 00000000
dst = 0x00661B30 dst->flags = 00000000 dst->map->info.flags = 00000000
src->map->blit = 0x76aaf570
src = 0x00661C60 src->flags = 00000000 src->map->info.flags = 00000000
dst = 0x00661CD0 dst->flags = 00000000 dst->map->info.flags = 00000000
src->map->blit = 0x76aaf570
Screen is at 32 bits per pixel
Screen is in system memory
Sprite is in system memory
src = 0x0065C6A0 src->flags = 00000000 src->map->info.flags = 00000000
dst = 0x00661CD0 dst->flags = 00000000 dst->map->info.flags = 00001000
src->map->blit = 0x76aaf570
src = 0x00661B30 src->flags = 00000001 src->map->info.flags = 00003122
dst = 0x0065C6A0 dst->flags = 00000001 dst->map->info.flags = 00000000
src->map->blit = 0x76aa94fb
Sprite blit dosn't uses hardware alpha acceleration
src = 0x00661CD0 src->flags = 00000001 src->map->info.flags = 00001000
dst = 0x0065C6A0 dst->flags = 00000001 dst->map->info.flags = 00000000
src->map->blit = 0x76aaf570
src = 0x00661B30 src->flags = 00000001 src->map->info.flags = 00002000
dst = 0x0065C6A0 dst->flags = 00000001 dst->map->info.flags = 00000000
src->map->blit = 0x76aaf570
src = 0x00661B30 src->flags = 00000001 src->map->info.flags = 00002022
dst = 0x0065C6A0 dst->flags = 00000001 dst->map->info.flags = 00000000
src->map->blit = 0x76aaf570
src = 0x00661B30 src->flags = 00000001 src->map->info.flags = 00002020
dst = 0x0065C6A0 dst->flags = 00000001 dst->map->info.flags = 00000000
src->map->blit = 0x76aaf570
src = 0x00661B30 src->flags = 00000001 src->map->info.flags = 00002022
dst = 0x0065C6A0 dst->flags = 00000001 dst->map->info.flags = 00000000
src->map->blit = 0x76aaf570

You can see how the info.flags changes from just SDL_COPY_RLE_COLORKEY to add in SDL_COPY_MODULATE_ALPHA and SDL_COPY_BLEND. Which seems to be related to the problem.

Hope this helps.
Comment 2 Sam Lantinga 2008-03-14 11:23:23 UTC
I actually have a fix for this in progress, but it's a slight rearchitecting of the 2D blitting system and is taking a while to finish.  I may have to revert your checkin of revision 3573 to avoid conflicts.
Comment 3 Sam Lantinga 2008-11-25 11:39:34 UTC
I checked in a better, non-invasive fix.  The basic problem was that the surface had both SDL_SRCALPHA and a colorkey set, which according to the spec, results in the colorkey being ignored.
Comment 4 Sam Lantinga 2008-11-25 11:41:02 UTC
*** Bug 580 has been marked as a duplicate of this bug. ***