aboutsummaryrefslogtreecommitdiff
path: root/engines/saga
diff options
context:
space:
mode:
authorFilippos Karapetis2008-12-07 18:49:35 +0000
committerFilippos Karapetis2008-12-07 18:49:35 +0000
commit78fd335a4260a16664083fbf3333b8fba52e75ea (patch)
tree49fbddacfc7a9a97eb984451da285d58b0ac5f97 /engines/saga
parentc2424b04a5964e4763a7d7c123317dec925c8214 (diff)
downloadscummvm-rg350-78fd335a4260a16664083fbf3333b8fba52e75ea.tar.gz
scummvm-rg350-78fd335a4260a16664083fbf3333b8fba52e75ea.tar.bz2
scummvm-rg350-78fd335a4260a16664083fbf3333b8fba52e75ea.zip
More dirty rectangle related changes (dirty rectangle handling is still broken)
svn-id: r35281
Diffstat (limited to 'engines/saga')
-rw-r--r--engines/saga/font.cpp11
-rw-r--r--engines/saga/gfx.cpp2
-rw-r--r--engines/saga/interface.cpp8
-rw-r--r--engines/saga/isomap.cpp7
-rw-r--r--engines/saga/render.cpp24
-rw-r--r--engines/saga/render.h1
-rw-r--r--engines/saga/scene.cpp4
-rw-r--r--engines/saga/sprite.cpp6
8 files changed, 51 insertions, 12 deletions
diff --git a/engines/saga/font.cpp b/engines/saga/font.cpp
index d9d8a4ab8a..58c37a9e74 100644
--- a/engines/saga/font.cpp
+++ b/engines/saga/font.cpp
@@ -30,6 +30,7 @@
#include "saga/rscfile.h"
#include "saga/font.h"
+#include "saga/render.h"
namespace Saga {
@@ -304,15 +305,15 @@ void Font::outFont(const FontStyle &drawFont, const char *text, size_t count, co
const byte *textPointer;
byte *c_dataPointer;
int c_code;
- int charRow;
+ int charRow = 0;
Point textPoint(point);
byte *outputPointer;
byte *outputPointer_min;
byte *outputPointer_max;
- int row;
- int rowLimit;
+ int row = 0;
+ int rowLimit = 0;
int c_byte_len;
int c_byte;
@@ -406,6 +407,10 @@ void Font::outFont(const FontStyle &drawFont, const char *text, size_t count, co
// Advance tracking position
textPoint.x += drawFont.fontCharEntry[c_code].tracking;
} // end per-character processing
+
+ rowLimit = (_vm->_gfx->getBackBufferHeight() < (textPoint.y + drawFont.header.charHeight)) ? _vm->_gfx->getBackBufferHeight() : textPoint.y + drawFont.header.charHeight;
+ // TODO: for now we add a dirty rect that ends at the right of the screen
+ _vm->_render->addDirtyRect(Common::Rect(textPoint.x, textPoint.y, _vm->_gfx->getBackBufferWidth(), rowLimit));
}
diff --git a/engines/saga/gfx.cpp b/engines/saga/gfx.cpp
index eac1d871ae..30b36e08ef 100644
--- a/engines/saga/gfx.cpp
+++ b/engines/saga/gfx.cpp
@@ -565,7 +565,7 @@ bool hitTestPoly(const Point *points, unsigned int npoints, const Point& test_po
// This method adds a dirty rectangle automatically
void Gfx::drawFrame(const Common::Point &p1, const Common::Point &p2, int color) {
_backBuffer.drawFrame(p1, p2, color);
- _vm->_render->addDirtyRect(Common::Rect(p1.x, p1.y, p2.x, p2.y));
+ _vm->_render->addDirtyRect(Common::Rect(p1.x, p1.y, p2.x + 1, p2.y + 1));
}
// This method adds a dirty rectangle automatically
diff --git a/engines/saga/interface.cpp b/engines/saga/interface.cpp
index e18e1654a0..30b5b5fcaa 100644
--- a/engines/saga/interface.cpp
+++ b/engines/saga/interface.cpp
@@ -2186,11 +2186,14 @@ void Interface::drawButtonBox(const Rect& rect, ButtonKind kind, bool down) {
int xe = rect.right - 1;
int ye = rect.bottom - 1;
- _vm->_gfx->drawRect(Common::Rect(x, y, x + w, y + h), frameColor);
_vm->_gfx->setPixelColor(x, y, cornerColor);
_vm->_gfx->setPixelColor(x, ye, cornerColor);
_vm->_gfx->setPixelColor(xe, y, cornerColor);
_vm->_gfx->setPixelColor(xe, ye, cornerColor);
+ _vm->_gfx->hLine(x + 1, y, x + w - 2, frameColor);
+ _vm->_gfx->hLine(x + 1, ye, x + w - 2, frameColor);
+ _vm->_gfx->vLine(x, y + 1, y + h - 2, frameColor);
+ _vm->_gfx->vLine(xe, y + 1, y + h - 2, frameColor);
x++;
y++;
@@ -2198,7 +2201,6 @@ void Interface::drawButtonBox(const Rect& rect, ButtonKind kind, bool down) {
ye--;
w -= 2;
h -= 2;
- // drawRect() above added a dirty rectangle automatically for these
_vm->_gfx->vLine(x, y, y + h - 1, odl);
_vm->_gfx->hLine(x, ye, x + w - 1, odl);
_vm->_gfx->vLine(xe, y, y + h - 2, our);
@@ -2210,7 +2212,6 @@ void Interface::drawButtonBox(const Rect& rect, ButtonKind kind, bool down) {
ye--;
w -= 2;
h -= 2;
- // drawRect() above added a dirty rectangle automatically for these
_vm->_gfx->setPixelColor(x, y, fillColor);
_vm->_gfx->setPixelColor(xe, ye, fillColor);
_vm->_gfx->vLine(x, y + 1, y + 1 + h - 2, idl);
@@ -2223,6 +2224,7 @@ void Interface::drawButtonBox(const Rect& rect, ButtonKind kind, bool down) {
Common::Rect fill(x, y, x + w, y + h);
_vm->_gfx->fillRect(fill, solidColor);
+ _vm->_render->addDirtyRect(rect);
}
static const int readingSpeeds[] = { kTextClick, kTextSlow, kTextMid, kTextFast };
diff --git a/engines/saga/isomap.cpp b/engines/saga/isomap.cpp
index 64348d869a..682ad83e89 100644
--- a/engines/saga/isomap.cpp
+++ b/engines/saga/isomap.cpp
@@ -29,6 +29,7 @@
#include "saga/gfx.h"
#include "saga/scene.h"
#include "saga/isomap.h"
+#include "saga/render.h"
namespace Saga {
@@ -877,6 +878,12 @@ void IsoMap::drawTile(uint16 tileIndex, const Point &point, const Location *loca
}
}
+ // Compute dirty rect
+ int rectX = MAX<int>(drawPoint.x, 0);
+ int rectY = MAX<int>(drawPoint.y, 0);
+ int rectX2 = MIN<int>(drawPoint.x + SAGA_ISOTILE_WIDTH, _tileClip.right);
+ int rectY2 = MIN<int>(drawPoint.y + height, _tileClip.bottom);
+ _vm->_render->addDirtyRect(Common::Rect(rectX, rectY, rectX2, rectY2));
}
bool IsoMap::checkDragonPoint(int16 u, int16 v, uint16 direction) {
diff --git a/engines/saga/render.cpp b/engines/saga/render.cpp
index 85448bc412..42c5120d80 100644
--- a/engines/saga/render.cpp
+++ b/engines/saga/render.cpp
@@ -92,6 +92,8 @@ void Render::drawScene() {
// Get mouse coordinates
mousePoint = _vm->mousePos();
+ restoreChangedRects();
+
if (!(_flags & (RF_DEMO_SUBST | RF_MAP) || curMode == kPanelPlacard)) {
// Do not redraw the whole scene and the actors if the scene is fading out or
// if an overlay is drawn above it (e.g. the options menu)
@@ -100,8 +102,10 @@ void Render::drawScene() {
curMode != kPanelLoad && curMode != kPanelSave &&
curMode != kPanelProtect)) {
// Display scene background
- if (!(_flags & RF_DISABLE_ACTORS) || _vm->getGameType() == GType_ITE)
- _vm->_scene->draw();
+ if (_fullRefresh) {
+ if (!(_flags & RF_DISABLE_ACTORS) || _vm->getGameType() == GType_ITE)
+ _vm->_scene->draw();
+ }
if (_vm->_puzzle->isActive()) {
_vm->_puzzle->movePiece(mousePoint);
@@ -202,6 +206,8 @@ void Render::drawScene() {
drawDirtyRects();
_system->updateScreen();
+
+ _fullRefresh = false;
}
void Render::addDirtyRect(Common::Rect rect) {
@@ -215,6 +221,16 @@ void Render::addDirtyRect(Common::Rect rect) {
_dirtyRects.push_back(rect);
}
+void Render::restoreChangedRects() {
+ if (!_fullRefresh) {
+ Common::List<Common::Rect>::const_iterator it;
+ for (it = _dirtyRects.begin(); it != _dirtyRects.end(); ++it) {
+ g_system->copyRectToScreen((byte *)_backGroundSurface.pixels, _backGroundSurface.w, it->left, it->top, it->width(), it->height());
+ }
+ }
+ _dirtyRects.clear();
+}
+
void Render::drawDirtyRects() {
if (_fullRefresh) {
_system->copyRectToScreen(_vm->_gfx->getBackBufferPixels(), _vm->_gfx->getBackBufferWidth(), 0, 0,
@@ -222,11 +238,9 @@ void Render::drawDirtyRects() {
} else {
Common::List<Common::Rect>::const_iterator it;
for (it = _dirtyRects.begin(); it != _dirtyRects.end(); ++it) {
- g_system->copyRectToScreen(_vm->_gfx->getBackBufferPixels(), it->width(), it->left, it->top, it->width(), it->height());
+ g_system->copyRectToScreen(_vm->_gfx->getBackBufferPixels(), _backGroundSurface.w, it->left, it->top, it->width(), it->height());
}
}
-
- _dirtyRects.clear();
}
#ifdef SAGA_DEBUG
diff --git a/engines/saga/render.h b/engines/saga/render.h
index 8fffed4cc1..8fc2eaa663 100644
--- a/engines/saga/render.h
+++ b/engines/saga/render.h
@@ -94,6 +94,7 @@ public:
}
void drawDirtyRects();
+ void restoreChangedRects();
private:
#ifdef SAGA_DEBUG
diff --git a/engines/saga/scene.cpp b/engines/saga/scene.cpp
index 7bef09b587..f53e6321c7 100644
--- a/engines/saga/scene.cpp
+++ b/engines/saga/scene.cpp
@@ -589,6 +589,9 @@ void Scene::loadScene(LoadSceneParams *loadSceneParams) {
Event *q_event;
static PalEntry current_pal[PAL_ENTRIES];
+ // Since we are loading a new scene, do a full refresh
+ _vm->_render->setFullRefresh(true);
+
if (loadSceneParams->transitionType == kTransitionFade)
_vm->_interface->setFadeMode(kFadeOut);
@@ -1185,6 +1188,7 @@ void Scene::endScene() {
} else {
_vm->_gfx->getBackBufferRect(rect);
_vm->_render->getBackGroundSurface()->blit(rect, (const byte *)_vm->_gfx->getBackBufferPixels());
+ _vm->_render->addDirtyRect(rect);
}
// Free scene background
diff --git a/engines/saga/sprite.cpp b/engines/saga/sprite.cpp
index 200b0af206..6507b6ebb3 100644
--- a/engines/saga/sprite.cpp
+++ b/engines/saga/sprite.cpp
@@ -33,6 +33,7 @@
#include "saga/font.h"
#include "saga/sprite.h"
+#include "saga/render.h"
namespace Saga {
@@ -251,6 +252,8 @@ void Sprite::drawClip(const Rect &clipRect, const Point &spritePointer, int widt
bufRowPointer += _vm->_gfx->getBackBufferPitch();
srcRowPointer += width;
}
+
+ _vm->_render->addDirtyRect(Common::Rect(spritePointer.x, spritePointer.y, spritePointer.x + clipWidth, spritePointer.y + clipHeight));
}
void Sprite::draw(const Rect &clipRect, SpriteList &spriteList, int32 spriteNumber, const Point &screenCoord, int scale) {
@@ -391,6 +394,9 @@ void Sprite::drawOccluded(const Rect &clipRect, SpriteList &spriteList, int spri
maskRowPointer += maskWidth;
sourceRowPointer += width;
}
+
+ _vm->_render->addDirtyRect(Common::Rect(clipData.destPoint.x, clipData.destPoint.y,
+ clipData.destPoint.x + clipData.drawWidth, clipData.destPoint.y + clipData.drawHeight));
}
void Sprite::decodeRLEBuffer(const byte *inputBuffer, size_t inLength, size_t outLength) {