More dirty rectangle related changes (dirty rectangle handling is still broken)

svn-id: r35281
This commit is contained in:
Filippos Karapetis 2008-12-07 18:49:35 +00:00
parent c2424b04a5
commit 78fd335a42
8 changed files with 51 additions and 12 deletions

View File

@ -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));
}

View File

@ -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

View File

@ -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 };

View File

@ -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) {

View File

@ -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

View File

@ -94,6 +94,7 @@ public:
}
void drawDirtyRects();
void restoreChangedRects();
private:
#ifdef SAGA_DEBUG

View File

@ -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

View File

@ -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) {