aboutsummaryrefslogtreecommitdiff
path: root/gui
diff options
context:
space:
mode:
authorTorbjörn Andersson2005-07-13 14:38:26 +0000
committerTorbjörn Andersson2005-07-13 14:38:26 +0000
commit983643bc5a87ef30d522613cc0a479392292d3a6 (patch)
tree11d71096041c2b03c3d4950b2837e9c7a21e1c05 /gui
parentf65586dd0f8eaae8ae8625caa599e156e87e0cc2 (diff)
downloadscummvm-rg350-983643bc5a87ef30d522613cc0a479392292d3a6.tar.gz
scummvm-rg350-983643bc5a87ef30d522613cc0a479392292d3a6.tar.bz2
scummvm-rg350-983643bc5a87ef30d522613cc0a479392292d3a6.zip
Cache the blended background in a surface, so that the blending only needs
to be made once, instead of whenever the console is redrawn. (This is the same trick as the About dialog uses.) It should speed up the drawing quite a bit, though it's not particularly noticeable on the computer I'm using at the moment, so I can't say for sure. svn-id: r18540
Diffstat (limited to 'gui')
-rw-r--r--gui/console.cpp29
-rw-r--r--gui/console.h3
2 files changed, 30 insertions, 2 deletions
diff --git a/gui/console.cpp b/gui/console.cpp
index eb0a812eae..5ad73f4993 100644
--- a/gui/console.cpp
+++ b/gui/console.cpp
@@ -117,10 +117,16 @@ void ConsoleDialog::slideUpAndClose() {
}
void ConsoleDialog::open() {
+ // This dialog will be redrawn a lot, so we store a copy of the blended
+ // background in a separate "canvas", just like in the About dialog.
+ _canvas.pixels = NULL;
+
+
// Initiate sliding the console down. We do a very simple trick to achieve
// this effect: we simply move the console dialog just above (outside) the
// visible screen area, then shift it down in handleTickle() over a
// certain period of time.
+
_y = -_h;
_slideTime = g_system->getMillis();
_slideMode = kDownSlideMode;
@@ -132,9 +138,19 @@ void ConsoleDialog::open() {
}
}
+void ConsoleDialog::close() {
+ free(_canvas.pixels);
+ Dialog::close();
+}
+
void ConsoleDialog::drawDialog() {
- // Blend over the background
- g_gui.blendRect(_x, _y, _w, _h, g_gui._bgcolor, 2);
+ if (!_canvas.pixels) {
+ // Blend over the background
+ g_gui.blendRect(0, 0, _w, _h, g_gui._bgcolor, 2);
+ g_gui.copyToSurface(&_canvas, 0, 0, _w, _h);
+ }
+
+ g_gui.drawSurface(_canvas, 0, 0);
// Draw a border
g_gui.hLine(_x, _y + _h - 1, _x + _w - 1, g_gui._color);
@@ -165,7 +181,16 @@ void ConsoleDialog::drawDialog() {
g_gui.addDirtyRect(_x, _y, _w, _h);
}
+void ConsoleDialog::handleScreenChanged() {
+ free(_canvas.pixels);
+ _canvas.pixels = NULL;
+ draw();
+}
+
void ConsoleDialog::handleTickle() {
+ if (!_canvas.pixels)
+ return;
+
uint32 time = g_system->getMillis();
if (_caretTime < time) {
_caretTime = time + kCaretBlinkTime;
diff --git a/gui/console.h b/gui/console.h
index ac75e413d8..69b3f88d6a 100644
--- a/gui/console.h
+++ b/gui/console.h
@@ -43,6 +43,7 @@ public:
typedef bool (*CompletionCallbackProc)(ConsoleDialog* console, const char *input, char*& completion, void *refCon);
protected:
+ Graphics::Surface _canvas;
char _buffer[kBufferSize];
int _linesInBuffer;
@@ -92,9 +93,11 @@ public:
ConsoleDialog(float widthPercent, float heightPercent);
void open();
+ void close();
void drawDialog();
void handleTickle();
+ void handleScreenChanged();
void handleMouseWheel(int x, int y, int direction);
void handleKeyDown(uint16 ascii, int keycode, int modifiers);
void handleCommand(CommandSender *sender, uint32 cmd, uint32 data);