Use unsigned ints for width and height, like SDL does.
We're using the SDL typedefs there after all.
Include argument names in header when type name does tell everything.
Use whitespace in argument lists.
A bug in SDL_ConvertSurface() leaves the per-surface alpha undefined when
converting from RGBA to RGBA. This can cause problems if the surface is
later converted to a format without an alpha channel, such as the display
format.
Instead of having the copy constructor convert to display format, the new
copy constructor preserves the pixel format and a separate method was
introduced to convert surfaces to display format.
The code was made more robust as well: it should no longer crash if the
wallpaper cannot be loaded.
If loading fails, the factory method returns NULL, while previously the
constructor would create a Surface object with a NULL "raw" field.
However, since most of the methods dereference "raw" without checking,
such a Surface would likely crash the application when used.
Use real double buffering instead.
I checked the SDL code and if the hardware cannot provide double buffering
it will use a shadow surface to ensure that a frame is not displayed until
it has been fully painted.
Also disable mouse cursor before opening the output surface. The reason it
was disabled after the surface was opened is that SDL on GP2X has a bug.
However, this means the cursor is visible for a short time during startup
which looks ugly.
Before this commit loadPNG() could return any surface format and the caller
was responsible for converting it to the desired format. However, in practice
all callers want a surface with an alpha channel and SDL only supports that
with 32bpp surfaces, so RGBA or a permutation thereof. So I changed the
contract for loadPNG() so it is required to return an RGBA surface, and
removed the conversion code in the callers.
The next step is to replace IMG_Load() by a function that calls libpng
directly and loads a fixed 32bpp pixel format. That way, we can drop the
SDL_image dependency and avoid unnecessary pixel format conversions.
Removed all methods that are never called.
Made methods that are only called by Surface itself private.
One ugly thing remaining is outside access to the "raw" field.