[Scummvm-devel] New GUI thoughts in the Wiki

Marcus Comstedt marcus at mc.pp.se
Sat Nov 19 14:20:04 CET 2005


Max Horn <max at quendi.de> writes:

[...]
> So at first, this all sounds like a very good plan. And I like it.
> However, it's not quite as simple as it sounds here... because not
> all DLEs are covering their full area. Transparency effects etc.
> partially break this approach. This is most obvious for a "text DLE",
> but also for bitmaps, which usually would employ transparency at the
> corners (think rounded rectangles, as seen in the concept drafts of
> the GUI design).

That's why the optimization is only allowed to break the traversal of
the DL if the DLE which contains all of the removed element is non-
transparent.  This is enough to handle text on buttons and so on,
but if you want to use transparency for rounded corners on buttons,
you'll lose the performance again, yes.


> One possible solution would be to not allow transparency. If we
> restrict ourselves to single colored backgrounds, we can achieve this
> by adding a "background_color" attribute to every DLE, and when
> redrawing it (or portions of it), the corresponding area is first
> filled with the background color. Or for bitmaps, we could simply not
> allow transparency for them.

For a bitmap, it's better to use transparency + background_color.  The
reason is, that the pixmap might have reduced colour depth compared to
a solid rectangle, which means that the colour of the background, and
a pixel in the bitmap which is nominally of the same colour, might not
match exactly.  Not noticable on a standard TV set, but definitely on
a VGA monitor.


> As long as we only allow 1 bit transparency, we could also rely on
> the client code to take care of proper usage itself. E.g. for
> buttons, the pressed / non-pressed versions would precisely cover
> each other anyway, so no harm would be done if we ignored any
> transparency issues for them. The story is a bit different when full
> 8 bit alpha blending is used, of course, because we don't want to
> alpha blend a button with an older version of itself.

If you know the background in advance, you can preblend and use 1 bit
transparency.  For the pre-blended pixels, the colour mismatch problem
mentioned above is not an issue, since you have modified the colour
anyway.  But this only works if all the instances of the same
graphical element will have the same background.  (For stuff like
anti-aliased corners you can allow some mismatch, but it will look
wrong if you switch a light background for a dark one etc.)


  // Marcus






More information about the Scummvm-devel mailing list