Ticket #8419: credits.diff

File credits.diff, 5.6 KB (added by eriktorbjorn, 16 years ago)

Patch against an April 15 CVS snapshot

  • TODO

    diff -ur --exclude=CVS --exclude=Makefile ScummVM/TODO ScummVM+hack/TODO
    old new  
    196196* Maybe add the ScummVM logo (+typeface?) to the about dialog
    197197* Unify DirBrowserDialog and FileBrowserDialog.
    198198* MacOS X version of FileBrowserDialog, since there is one of DirBrowserDialog.
    199 * The credits scroll is too CPU intensive. This is because for each time the
    200   text is redrawn it has to do a full redraw, which causes blendRect() to be
    201   called twice. Perhaps AboutDialog could keep a private copy of the blended
    202   background so that it wouldn't have to be re-generated each time? Of course
    203   we'd probably have to take screen changes into account, but there already is
    204   a mechanism for that, I believe.
    205199
    206200Launcher
    207201========
  • gui/about.cpp

    diff -ur --exclude=CVS --exclude=Makefile ScummVM/gui/about.cpp ScummVM+hack/gui/about.cpp
    old new  
    120120        _scrollPos = 0;
    121121        _modifiers = 0;
    122122        _willClose = false;
     123        _canvas.pixels = NULL;
    123124
    124125        Dialog::open();
    125126}
    126127
     128void AboutDialog::close() {
     129        free(_canvas.pixels);
     130        Dialog::close();
     131}
     132
    127133void AboutDialog::drawDialog() {
    128         // Blend over the background
    129         g_gui.blendRect(_x, _y, _w, _h, g_gui._bgcolor);
     134        if (!_canvas.pixels) {
     135                // Blend over the background. Since we can't afford to do that
     136                // every time the text is updated (it's horribly CPU intensive)
     137                // we do it just once and then use a copy of the result as our
     138                // static background for the remainder of the credits.
     139                g_gui.blendRect(_x, _y, _w, _h, g_gui._bgcolor);
     140                g_gui.getRect(&_canvas, _x, _y, _w, _h);
     141        }
     142
     143        g_gui.putRect(&_canvas, _x, _y);
    130144
    131145        // Draw text
    132146        // TODO: Add a "fade" effect for the top/bottom text lines
     
    212226                } else if ((uint32)_scrollPos > _lines.size() * _lineHeight) {
    213227                        _scrollPos = 0;
    214228                        _scrollTime += kScrollStartDelay;
    215                 } else {
    216                         g_gui.addDirtyRect(_x, _y, _w, _h);
    217229                }
    218                 draw(); // Issue a full redraw
     230                drawDialog();
    219231        }
    220232}
    221233
     234void AboutDialog::handleScreenChanged() {
     235        // The screen has changed. Do a full redraw to ensure that the canvas
     236        // we draw the text on will still have the correct background image.
     237        free(_canvas.pixels);
     238        _canvas.pixels = NULL;
     239        draw();
     240}
     241
    222242void AboutDialog::handleMouseUp(int x, int y, int button, int clickCount) {
    223243        // Close upon any mouse click
    224244        close();
  • gui/about.h

    diff -ur --exclude=CVS --exclude=Makefile ScummVM/gui/about.h ScummVM+hack/gui/about.h
    old new  
    2323
    2424#include "gui/dialog.h"
    2525#include "common/str.h"
     26#include "graphics/surface.h"
    2627
    2728namespace GUI {
    2829
     
    3536        uint32          _lineHeight;
    3637        byte            _modifiers;
    3738        bool            _willClose;
     39        Graphics::Surface       _canvas;
    3840
    3941public:
    4042        AboutDialog();
    4143
    4244        void open();
     45        void close();
    4346        void drawDialog();
    4447        void handleTickle();
     48        void handleScreenChanged();
    4549        void handleMouseUp(int x, int y, int button, int clickCount);
    4650        void handleKeyDown(uint16 ascii, int keycode, int modifiers);
    4751        void handleKeyUp(uint16 ascii, int keycode, int modifiers);
  • gui/newgui.cpp

    diff -ur --exclude=CVS --exclude=Makefile ScummVM/gui/newgui.cpp ScummVM+hack/gui/newgui.cpp
    old new  
    301301        _screen.vLine(x * _scaleFactor, y * _scaleFactor, y2 * _scaleFactor, color);
    302302}
    303303
     304void NewGui::getRect(Graphics::Surface *s, int x, int y, int w, int h) {
     305        Common::Rect rect(x * _scaleFactor, y * _scaleFactor, (x + w) * _scaleFactor, (y + h) * _scaleFactor);
     306        rect.clip(_screen.w, _screen.h);
     307
     308        if (!rect.isValidRect())
     309                return;
     310
     311        s->w = rect.width();
     312        s->h = rect.height();
     313        s->bytesPerPixel = sizeof(OverlayColor);
     314        s->pitch = s->w * s->bytesPerPixel;
     315        s->pixels = (OverlayColor *)malloc(s->pitch * s->h);
     316
     317        w = s->w;
     318        h = s->h;
     319
     320        OverlayColor *dst = (OverlayColor *)s->pixels;
     321        OverlayColor *src = getBasePtr(rect.left, rect.top);
     322
     323        while (h--) {
     324                memcpy(dst, src, s->pitch);
     325                src += _screenPitch;
     326                dst += s->w;
     327        }
     328}
     329
     330void NewGui::putRect(Graphics::Surface *s, int x, int y) {
     331        Common::Rect rect(x * _scaleFactor, y * _scaleFactor, x * _scaleFactor + s->w, y * _scaleFactor + s->h);
     332        rect.clip(_screen.w, _screen.h);
     333
     334        if (!rect.isValidRect())
     335                return;
     336
     337        OverlayColor *src = (OverlayColor *)s->pixels;
     338        OverlayColor *dst = getBasePtr(rect.left, rect.top);
     339
     340        int w = rect.width();
     341        int h = rect.height();
     342
     343        while (h--) {
     344                memcpy(dst, src, s->pitch);
     345                src += w;
     346                dst += _screenPitch;
     347        }
     348}
     349
    304350void NewGui::blendRect(int x, int y, int w, int h, OverlayColor color, int level) {
    305351#ifdef NEWGUI_256
    306352        fillRect(x, y, w, h, color);
  • gui/newgui.h

    diff -ur --exclude=CVS --exclude=Makefile ScummVM/gui/newgui.h ScummVM+hack/gui/newgui.h
    old new  
    134134        void box(int x, int y, int width, int height, OverlayColor colorA, OverlayColor colorB);
    135135        void hLine(int x, int y, int x2, OverlayColor color);
    136136        void vLine(int x, int y, int y2, OverlayColor color);
     137        void getRect(Graphics::Surface *s, int x, int y, int w, int h);
     138        void putRect(Graphics::Surface *s, int x, int y);
    137139        void blendRect(int x, int y, int w, int h, OverlayColor color, int level = 3);
    138140        void fillRect(int x, int y, int w, int h, OverlayColor color);
    139141        void frameRect(int x, int y, int w, int h, OverlayColor color);