[Scummvm-cvs-logs] CVS: scummvm/gui newgui.cpp,1.33,1.34
Max Horn
fingolfin at users.sourceforge.net
Fri Dec 13 08:17:03 CET 2002
Update of /cvsroot/scummvm/scummvm/gui
In directory sc8-pr-cvs1:/tmp/cvs-serv22013/gui
Modified Files:
newgui.cpp
Log Message:
changed OSystem to allow RBG<->16bit color conversion to be done in the backend; after all, the backend 'knows' best what format the overlay uses. Default implementations of RBGToColor and colorToRBG assume 565 mode, backends other than SDL may want to provide alternate implementations (SDL backend already does the right thing for non-565 modes)
Index: newgui.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gui/newgui.cpp,v
retrieving revision 1.33
retrieving revision 1.34
diff -u -d -r1.33 -r1.34
--- newgui.cpp 12 Dec 2002 23:22:47 -0000 1.33
+++ newgui.cpp 13 Dec 2002 16:15:58 -0000 1.34
@@ -84,14 +84,6 @@
NewGui::NewGui(OSystem *system) : _system(system), _screen(0), _needRedraw(false),
_stateIsSaved(false), _cursorAnimateCounter(0), _cursorAnimateTimer(0)
{
- // Setup some default GUI colors.
- // TODO - either use nicer values, or maybe make this configurable?
- _bgcolor = RGB_TO_16(0, 0, 0);
- _color = RGB_TO_16(96, 96, 96);
- _shadowcolor = RGB_TO_16(64, 64, 64);
- _textcolor = RGB_TO_16(32, 160, 32);
- _textcolorhi = RGB_TO_16(0, 255, 0);
-
// Clear the cursor
memset(_cursor, 0xFF, sizeof(_cursor));
@@ -107,6 +99,18 @@
if (activeDialog == 0)
return;
+ // Setup some default GUI colors. This has to be done here to ensure the
+ // overlay has been created already. Even then, one can get wrong colors, namely
+ // if the GUI is up and then the user toggles to full screen mode - on some system
+ // different color modes (555 vs 565) might be used depending on the resolution
+ // (e.g. that's the case on my system), so we still end up with wrong colors in those
+ // sitauations. At least now the user can fix it by closing and reopening the GUI.
+ _bgcolor = _system->RBGToColor(0, 0, 0);
+ _color = _system->RBGToColor(96, 96, 96);
+ _shadowcolor = _system->RBGToColor(64, 64, 64);
+ _textcolor = _system->RBGToColor(32, 160, 32);
+ _textcolorhi = _system->RBGToColor(0, 255, 0);
+
if (!_stateIsSaved) {
saveState();
didSaveState = true;
@@ -313,16 +317,18 @@
void NewGui::blendRect(int x, int y, int w, int h, int16 color)
{
- int r = RED_FROM_16(color) * 3;
- int g = GREEN_FROM_16(color) * 3;
- int b = BLUE_FROM_16(color) * 3;
+ uint8 r, g, b;
+ uint8 ar, ag, ab;
+ _system->colorToRBG(color, r, g, b);
+ r *= 3;
+ g *= 3;
+ b *= 3;
int16 *ptr = getBasePtr(x, y);
while (h--) {
for (int i = 0; i < w; i++) {
- ptr[i] = RGB_TO_16((RED_FROM_16(ptr[i])+r)/4,
- (GREEN_FROM_16(ptr[i])+g)/4,
- (BLUE_FROM_16(ptr[i])+b)/4);
+ _system->colorToRBG(ptr[i], ar, ag, ab);
+ ptr[i] = _system->RBGToColor((ar+r)/4, (ag+g)/4, (ab+b)/4);
}
ptr += _screenPitch;
}
More information about the Scummvm-git-logs
mailing list