diff options
author | Denis Kasak | 2009-06-19 00:13:05 +0000 |
---|---|---|
committer | Denis Kasak | 2009-06-19 00:13:05 +0000 |
commit | adef44e4519c1f553062b1f213028e8e1afe0512 (patch) | |
tree | 484ff19095c078c89fa538c56dc8f1eda3106eb1 /engines | |
parent | 9d0b940af312efe50008ea2ac3f9e28bb3ea7daf (diff) | |
download | scummvm-rg350-adef44e4519c1f553062b1f213028e8e1afe0512.tar.gz scummvm-rg350-adef44e4519c1f553062b1f213028e8e1afe0512.tar.bz2 scummvm-rg350-adef44e4519c1f553062b1f213028e8e1afe0512.zip |
* Made the Screen class use the new Surface class.
* Added Screen::drawRect() method.
* Added support for updating dirty rectangles.
svn-id: r41657
Diffstat (limited to 'engines')
-rw-r--r-- | engines/draci/screen.cpp | 68 | ||||
-rw-r--r-- | engines/draci/screen.h | 14 |
2 files changed, 51 insertions, 31 deletions
diff --git a/engines/draci/screen.cpp b/engines/draci/screen.cpp index a1ac27211e..9011fa235c 100644 --- a/engines/draci/screen.cpp +++ b/engines/draci/screen.cpp @@ -31,16 +31,14 @@ namespace Draci { Screen::Screen(DraciEngine *vm) : _vm(vm) { - _surface = new Graphics::Surface(); - _surface->create(kScreenWidth, kScreenHeight, 1); - this->clearScreen(); + _surface = new Surface(kScreenWidth, kScreenHeight); _palette = new byte[4 * kNumColours]; setPaletteEmpty(); + this->clearScreen(); } Screen::~Screen() { - _surface->free(); - delete[] _surface; + delete _surface; delete[] _palette; } @@ -50,7 +48,7 @@ void Screen::setPaletteEmpty(unsigned int numEntries) { } _vm->_system->setPalette(_palette, 0, numEntries); - _vm->_system->updateScreen(); + copyToScreen(); } void Screen::setPalette(byte *data, uint16 start, uint16 num) { @@ -73,49 +71,71 @@ void Screen::setPalette(byte *data, uint16 start, uint16 num) { } _vm->_system->setPalette(_palette, start, num); - _vm->_system->updateScreen(); + copyToScreen(); } void Screen::copyToScreen() const { - byte *ptr = (byte *)_surface->getBasePtr(0, 0); + Common::List<Common::Rect> *dirtyRects = _surface->getDirtyRects(); + Common::List<Common::Rect>::iterator it; + + if (_surface->needsFullUpdate()) { + byte *ptr = (byte *)_surface->getBasePtr(0, 0); - _vm->_system->copyRectToScreen(ptr, kScreenWidth, 0, 0, - kScreenWidth, kScreenHeight); + _vm->_system->copyRectToScreen(ptr, kScreenWidth, + 0, 0, kScreenWidth, kScreenHeight); + } else { + for (it = dirtyRects->begin(); it != dirtyRects->end(); ++it) { + byte *ptr = (byte *)_surface->getBasePtr(it->left, it->top); + _vm->_system->copyRectToScreen(ptr, kScreenWidth, + it->left, it->top, it->width(), it->height()); + } + } + _vm->_system->updateScreen(); + _surface->markClean(); } void Screen::clearScreen() const { byte *ptr = (byte *)_surface->getBasePtr(0, 0); + _surface->markDirty(); + memset(ptr, 0, kScreenWidth * kScreenHeight); } -void Screen::drawSprite(const Sprite &s) const { - byte *dst = (byte *)_surface->getBasePtr(s._x, s._y); - byte *src = s._data; +void Screen::fillScreen(uint16 colour) const { + byte *ptr = (byte *)_surface->getBasePtr(0, 0); + + _surface->markDirty(); + + memset(ptr, colour, kScreenWidth * kScreenHeight); +} + +void Screen::drawRect(Common::Rect &r, uint8 colour) { + + r.clip(_surface->w, _surface->h); + + if (r.isEmpty()) + return; - for (unsigned int i = 0; i < s._height; ++i) { - for(unsigned int j = 0; j < s._width; ++j) { - dst[j] = *src++; + byte *ptr = (byte *)_surface->getBasePtr(r.left, r.top); + + for (uint16 i = 0; i < r.width(); ++i) { + for (uint16 j = 0; j < r.height(); ++j) { + ptr[j * kScreenWidth + i] = colour; } - - dst += _surface->pitch; } -} -void Screen::fillScreen(uint16 colour) const { - byte *ptr = (byte *)_surface->getBasePtr(0, 0); - - memset(ptr, colour, kScreenWidth * kScreenHeight); + _surface->markDirtyRect(r); } byte *Screen::getPalette() const { return _palette; } -Graphics::Surface *Screen::getSurface() { +Draci::Surface *Screen::getSurface() { return _surface; } diff --git a/engines/draci/screen.h b/engines/draci/screen.h index 95b73b92ac..20fa3553f1 100644 --- a/engines/draci/screen.h +++ b/engines/draci/screen.h @@ -26,8 +26,7 @@ #ifndef DRACI_SCREEN_H #define DRACI_SCREEN_H -#include "graphics/surface.h" - +#include "draci/surface.h" #include "draci/sprite.h" namespace Draci { @@ -35,8 +34,8 @@ namespace Draci { enum ScreenParameters { kScreenWidth = 320, kScreenHeight = 200, - - kNumColours = 256 + kNumColours = 256, + kDefaultTransparent = 255 }; class DraciEngine; @@ -54,10 +53,11 @@ public: void clearScreen() const; void drawSprite(const Sprite &s) const; void fillScreen(uint16 colour) const; - Graphics::Surface *getSurface(); - + Surface *getSurface(); + void drawRect(Common::Rect &r, uint8 colour); + private: - Graphics::Surface *_surface; + Surface *_surface; byte *_palette; DraciEngine *_vm; }; |