[SDL] Help to increase performance in SDL_ttf marquee program.

Ricardo Leite ricleitepessoal at gmail.com
Wed Mar 31 11:43:50 PDT 2010


Ok, thanks.
I will test this.

2010/3/31 David Olofson <david at olofson.net>

> On Wednesday 31 March 2010, at 19.37.06, Ricardo Leite
> <ricleitepessoal at gmail.com> wrote:
> > Friends,
> > My program that displays text messages is very slow and inefficient.
> > Please, help me with tips and tricks.
>
> First of all, what hardware, operating system and video subsystem are you
> using? The "correct" setup and methods for maximum performance depends a
> lot
> on that.
>
> For example, certain X servers (like XFree86 and X.org) have a fixed pixel
> format for the desktop, and that applies to all windows - often even in
> fullscreen mode. (XFree86 and X.org don't really have fullscreen modes, but
> rather zoom in on a "locked" window on the standard desktop.) So, if you
> have
> a 16 or 32 bpp desktop, asking SDL for an 8 bpp display will result in you
> getting a software surface that is converted from 8 bpp to the desktop
> format
> *on the fly*. Not very efficient...
>
> What you should probably do here is just ask for "0 bpp", that is, whatever
> the default is. Then you should use SDL_DisplayFormat() and
> SDL_DisplayFormatAlpha() to convert your source surfaces ('text' in your
> case)
> to formats suitable for fast blitting to whatever display surface you have
> at
> hand. That is, you don't really have to care about the pixel format as long
> as
> you're not doing pixel level software rendering.
>
> Also, very few video subsystems support windows with hardware surfaces
> (that
> requires specific hardware support to be practically useful in a desktop
> environment), and some don't even support it in fullscreen mode. Nothing
> you
> have to worry about most of the time, but keep in mind that SDL_Flip() may
> actually be a full-screen shadow-to-display copy, rather than the classic
> (very low cost) flip of DMA pointers. This may be of great importance if
> your
> application usually only changes a small area of the screen at a time.
>
> One thing that may be an absolute performance killer is alpha blending.
> It's
> really rather expensive in software - and even more so if your surface is
> "straight" as opposed to RLE accelerated! (See SDL_SetAlpha() and
> SDL_SetColorKey().)
>
> Try to use opaque surfaces first, then colorkeyed RLE accelerated, and if
> you
> really need to, RLE accelerated RGBA surfaces. (You may increase the
> "contrast" on the alpha channel to eliminate pixels that are nearly opaque
> or
> nearly transparent. It's the pixels that are actually blended that are
> expensive when you're using RLE! The opaque ones are just copied whereas
> the
> transparent ones are skipped entirely.)
>
> Finally, SDL_FillRect() may not be all that much faster than
> SDL_BlitSurface(), so don't rely on it being fast just because it seems
> trivial... Unless you actually have a background image or something, it may
> be
> better to make the 'text' surface opaque, so you don't have to clear the
> screen before blitting.
>
>
> --
> //David Olofson - Developer, Artist, Open Source Advocate
>
> .--- Games, examples, libraries, scripting, sound, music, graphics ---.
> |  http://olofson.net   http://kobodeluxe.com   http://audiality.org  |
> |  http://eel.olofson.net  http://zeespace.net   http://reologica.se  |
> '---------------------------------------------------------------------'
> _______________________________________________
> SDL mailing list
> SDL at lists.libsdl.org
> http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20100331/3a7829da/attachment.htm>


More information about the SDL mailing list