[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
Re: [pygame] Pygame alpha blits and self blitting
Hi Brian,
Brian Fisher wrote:
Haha - it's funny you bring this up Lenard. I was one of the advocates
of raising an exception, and the reason I felt that way was because it
was crashing in windows but not other platforms, and I felt that in
the interest of being a good cross-platform library pygame should
restrict users from doing operations that won't work on one of the
platforms on the other platforms.
I reviewed the entire thread on Bug 19 before posting. I used your
suggestion as one of the options.
...but then after some detective work, you figured out the cause of
the crash was actually the gcc compiler on i386 architectures had
changed behavior to not clear the direction flag for inline assembly.
The fix for that is in SVN SDL, and now you build your prebuilts off
of SVN SDL to include that fix, right?
Well, I chased it down to a direction flag not being cleared. Others
worked out why SDL broke. And the prebuilt SDL incorporates the bug fix.
I would like to note that, though the crashes mentioned in Bugzilla Bug
19 were almost certainly due to the flag problem, the submitted Python
code snippet shows a colorkey blit, a Pygame operation. That was never
examined as a possible cause, well by me anyway.
My point is, the reason why I advocated raising an exception are gone
(i.e. the windows crashing is fixed), so I personally think that
should be off the table.
True enough. This is in the domain of Pygame, so we can actually do
something about it.
I'd say making the blit work as expected with a special case would be
great.
It will be more than just the colorkey blit that need special casing. I
recently added ten new blit loops to handle blend blits to 24 bit
surfaces. None of them are special cased. I am hoping the solution is as
simple as adjusting some pointers and stride values. Having a duplicate
of every blit routine in alphablit.c would be too cumbersome in my opinion.
However I also am in favor of an explicit scroll routine (on the
surface probably?) - largely because blitting a surface to itself with
colorkey (or alpha for that matter) would definitely be the wrong way
to scroll the surface and an explicit scroll would not be succeptible
to accidentally having such features on, not to mention being more
readable.
Certainly scrolling is a separate operation that can be optimized.
I have added both self-blits and the scroll method to the Pygame todo list.
Lenard
On Fri, Feb 13, 2009 at 1:14 PM, Lenard Lindstrom <len-l@xxxxxxxxx
<mailto:len-l@xxxxxxxxx>> wrote:
Hi everyone,
While checking out Mozilla bug 19 (*) I found that blitting a
surface with colorkey to itself causes repetition of the source
image. I have attached an example. This is a known problem with
copy algorithms. SDL blits have special code to handle it.
Pygame's blits do not. The concerns over self blits were discussed
in the bug 19 related thread (**), but I could find no conclusion
as to whether to support it or raise an exception and provide
explicit scroll routines instead. Pygame has many special case
blit loops to be considered.
Lenard
(*) http://pygame.motherhamster.org/bugzilla/show_bug.cgi?id=19
(**)
http://thread.gmane.org/gmane.comp.python.pygame/15390/focus=15407
--
Lenard Lindstrom
<len-l@xxxxxxxxx>