aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorPaul Gilbert2012-01-01 16:12:07 +1100
committerPaul Gilbert2012-01-01 16:37:24 +1100
commita837bb409a0235e4b459bfbdfb66684c8b5d33e3 (patch)
treea75efbe399acec8743e6be1c4d442535861c8226 /engines
parentb59b703f721d4a52b1e73084294d44976419fead (diff)
downloadscummvm-rg350-a837bb409a0235e4b459bfbdfb66684c8b5d33e3.tar.gz
scummvm-rg350-a837bb409a0235e4b459bfbdfb66684c8b5d33e3.tar.bz2
scummvm-rg350-a837bb409a0235e4b459bfbdfb66684c8b5d33e3.zip
TSAGE: Revert buggy implementation of dirty rects
This reverts commit f69dfba21a5d4be8cc60a20a0dd0628717fa5373.
Diffstat (limited to 'engines')
-rw-r--r--engines/tsage/blue_force/blueforce_dialogs.cpp4
-rw-r--r--engines/tsage/converse.cpp2
-rw-r--r--engines/tsage/core.cpp4
-rw-r--r--engines/tsage/events.cpp6
-rw-r--r--engines/tsage/globals.cpp8
-rw-r--r--engines/tsage/graphics.cpp144
-rw-r--r--engines/tsage/graphics.h14
-rw-r--r--engines/tsage/ringworld/ringworld_dialogs.cpp4
-rw-r--r--engines/tsage/ringworld/ringworld_logic.cpp2
-rw-r--r--engines/tsage/ringworld/ringworld_scenes3.cpp6
-rw-r--r--engines/tsage/ringworld/ringworld_scenes5.cpp4
-rw-r--r--engines/tsage/ringworld2/ringworld2_dialogs.cpp2
-rw-r--r--engines/tsage/scenes.cpp2
13 files changed, 46 insertions, 156 deletions
diff --git a/engines/tsage/blue_force/blueforce_dialogs.cpp b/engines/tsage/blue_force/blueforce_dialogs.cpp
index 11c0358aca..0aaae2fc29 100644
--- a/engines/tsage/blue_force/blueforce_dialogs.cpp
+++ b/engines/tsage/blue_force/blueforce_dialogs.cpp
@@ -163,7 +163,7 @@ void RightClickDialog::execute() {
}
g_system->delayMillis(10);
- GLOBALS._screenSurface.copyToScreen();
+ g_system->updateScreen();
}
// Deactivate the graphics manager used for the dialog
@@ -244,7 +244,7 @@ void AmmoBeltDialog::execute() {
}
g_system->delayMillis(10);
- GLOBALS._screenSurface.copyToScreen();
+ g_system->updateScreen();
}
_gfxManager.deactivate();
diff --git a/engines/tsage/converse.cpp b/engines/tsage/converse.cpp
index 1542b0a8e3..a660c4b580 100644
--- a/engines/tsage/converse.cpp
+++ b/engines/tsage/converse.cpp
@@ -451,7 +451,7 @@ int ConversationChoiceDialog::execute(const Common::StringArray &choiceList) {
while (!g_globals->_events.getEvent(event, EVENT_KEYPRESS | EVENT_BUTTON_DOWN | EVENT_MOUSE_MOVE) &&
!g_vm->shouldQuit()) {
g_system->delayMillis(10);
- GLOBALS._screenSurface.copyToScreen();
+ g_system->updateScreen();
}
if (g_vm->shouldQuit())
break;
diff --git a/engines/tsage/core.cpp b/engines/tsage/core.cpp
index 33badf389b..73e7901fde 100644
--- a/engines/tsage/core.cpp
+++ b/engines/tsage/core.cpp
@@ -1416,7 +1416,7 @@ void ScenePalette::fade(const byte *adjustData, bool fullAdjust, int percent) {
// Set the altered pale4tte
g_system->getPaletteManager()->setPalette((const byte *)&tempPalette[0], 0, 256);
- GLOBALS._screenSurface.copyToScreen();
+ g_system->updateScreen();
}
PaletteRotation *ScenePalette::addRotation(int start, int end, int rotationMode, int duration, Action *action) {
@@ -1714,7 +1714,7 @@ void SceneItem::display(int resNum, int lineNum, ...) {
// Keep event on-screen until a mouse or keypress
while (!g_vm->shouldQuit() && !g_globals->_events.getEvent(event,
EVENT_BUTTON_DOWN | EVENT_KEYPRESS)) {
- GLOBALS._screenSurface.copyToScreen();
+ g_system->updateScreen();
g_system->delayMillis(10);
}
diff --git a/engines/tsage/events.cpp b/engines/tsage/events.cpp
index 21dc86b8ec..152570b187 100644
--- a/engines/tsage/events.cpp
+++ b/engines/tsage/events.cpp
@@ -49,8 +49,8 @@ bool EventsClass::pollEvent() {
_priorFrameTime = milli;
++_frameNumber;
- // Update the physical screen with any updates to the screen surface
- GLOBALS._screenSurface.copyToScreen();
+ // Update screen
+ g_system->updateScreen();
}
if (!g_system->getEventManager()->pollEvent(_event)) return false;
@@ -395,7 +395,7 @@ void EventsClass::delay(int numFrames) {
_priorFrameTime = g_system->getMillis();
}
- GLOBALS._screenSurface.copyToScreen();
+ g_system->updateScreen();
_prevDelayFrame = _frameNumber;
_priorFrameTime = g_system->getMillis();
}
diff --git a/engines/tsage/globals.cpp b/engines/tsage/globals.cpp
index 2869b3b60e..e18f3c12eb 100644
--- a/engines/tsage/globals.cpp
+++ b/engines/tsage/globals.cpp
@@ -108,15 +108,9 @@ Globals::Globals() : _dialogCenter(160, 140), _gfxManagerInstance(_screenSurface
_color2 = _gfxColors.foreground;
_color3 = _gfxColors.foreground;
}
-
- // Set up a buffer for the screen surface
- _screenSurface.create(SCREEN_WIDTH, SCREEN_HEIGHT);
- _screenSurface.trackDirtyRects();
-
- // Add the global graphics manager to the graphic manager list
+ _screenSurface.setScreenSurface();
_gfxManagers.push_back(&_gfxManagerInstance);
- // Set up the global scene objects list
_sceneObjects = &_sceneObjectsInstance;
_sceneObjects_queue.push_front(_sceneObjects);
diff --git a/engines/tsage/graphics.cpp b/engines/tsage/graphics.cpp
index bc4ce75c22..171167c2ea 100644
--- a/engines/tsage/graphics.cpp
+++ b/engines/tsage/graphics.cpp
@@ -220,10 +220,11 @@ void Rect::synchronize(Serializer &s) {
GfxSurface::GfxSurface() : _bounds(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT) {
_disableUpdates = false;
+ _screenSurface = false;
_lockSurfaceCtr = 0;
_customSurface = NULL;
+ _screenSurfaceP = NULL;
_transColor = -1;
- _trackDirtyRects = false;
}
GfxSurface::GfxSurface(const GfxSurface &s) {
@@ -240,41 +241,12 @@ GfxSurface::~GfxSurface() {
}
/**
- * Turns on dirty rectangle tracking for the surface
+ * Specifies that the surface will encapsulate the ScummVM screen surface
*/
-void GfxSurface::trackDirtyRects() {
- _trackDirtyRects = true;
-}
-
-void GfxSurface::addDirtyRect(const Rect &r) {
- if (_trackDirtyRects)
- _dirtyRects.push_back(Rect(r.left, r.top,
- MIN(r.right + 1, SCREEN_WIDTH), MIN(r.bottom + 1, SCREEN_HEIGHT)));
-}
-
-/**
- * Copies all areas specified by the dirty rect list to the screen
- */
-void GfxSurface::copyToScreen() {
- assert(_trackDirtyRects);
-
- // Merge any overlapping dirty rects
- mergeDirtyRects();
-
- // Loop through the dirty rect list to copy the affected areas to the sc
- for (Common::List<Rect>::iterator i = _dirtyRects.begin(); i != _dirtyRects.end(); ++i) {
- Rect r = *i;
-
- const byte *srcP = (const byte *)_customSurface->getBasePtr(r.left, r.top);
- g_system->copyRectToScreen(srcP, _customSurface->pitch, r.left, r.top,
- r.width(), r.height());
- }
-
- // Update the physical screen
- g_system->updateScreen();
-
- // Now that the dirty rects have been copied, clear the dirty rect list
- _dirtyRects.clear();
+void GfxSurface::setScreenSurface() {
+ _screenSurface = true;
+ _customSurface = NULL;
+ _lockSurfaceCtr = 0;
}
/**
@@ -282,13 +254,11 @@ void GfxSurface::copyToScreen() {
*/
void GfxSurface::create(int width, int height) {
assert((width >= 0) && (height >= 0));
-
- // Delete any prior internal surface that may have been previously created
+ _screenSurface = false;
if (_customSurface) {
_customSurface->free();
delete _customSurface;
}
-
_customSurface = new Graphics::Surface();
_customSurface->create(width, height, Graphics::PixelFormat::createFormatCLUT8());
Common::fill((byte *)_customSurface->pixels, (byte *)_customSurface->pixels + (width * height), 0);
@@ -301,7 +271,13 @@ void GfxSurface::create(int width, int height) {
Graphics::Surface GfxSurface::lockSurface() {
++_lockSurfaceCtr;
- Graphics::Surface *src = _customSurface;
+ Graphics::Surface *src;
+ if (_screenSurface) {
+ if (_lockSurfaceCtr == 1)
+ _screenSurfaceP = g_system->lockScreen();
+ src = _screenSurfaceP;
+ } else
+ src = _customSurface;
assert(src);
// Setup the returned surface either as one pointing to the same pixels as the source, or
@@ -322,10 +298,15 @@ Graphics::Surface GfxSurface::lockSurface() {
void GfxSurface::unlockSurface() {
assert(_lockSurfaceCtr > 0);
--_lockSurfaceCtr;
+
+ if ((_lockSurfaceCtr == 0) && _screenSurface) {
+ g_system->unlockScreen();
+ }
}
void GfxSurface::synchronize(Serializer &s) {
assert(!_lockSurfaceCtr);
+ assert(!_screenSurface);
s.syncAsByte(_disableUpdates);
_bounds.synchronize(s);
@@ -370,7 +351,6 @@ void GfxSurface::fillRect(const Rect &bounds, int color) {
Graphics::Surface surface = lockSurface();
surface.fillRect(bounds, color);
unlockSurface();
- addDirtyRect(bounds);
}
GfxSurface &GfxSurface::operator=(const GfxSurface &s) {
@@ -383,6 +363,7 @@ GfxSurface &GfxSurface::operator=(const GfxSurface &s) {
}
_customSurface = s._customSurface;
+ _screenSurface = s._screenSurface;
_disableUpdates = s._disableUpdates;
_bounds = s._bounds;
_centroid = s._centroid;
@@ -586,17 +567,10 @@ void GfxSurface::copyFrom(GfxSurface &src, Rect srcBounds, Rect destBounds, Regi
if (destBounds.bottom > destSurface.h)
destBounds.bottom = destSurface.h;
- if (destBounds.isValidRect() && (destBounds.left < SCREEN_WIDTH) && (destBounds.right >= 0) &&
- (destBounds.top < SCREEN_HEIGHT) && (destBounds.bottom >= 0)) {
- // Register the affected area as dirty
- addDirtyRect(Rect(destBounds.left + _bounds.left, destBounds.top + _bounds.top,
- destBounds.right + _bounds.left, destBounds.bottom + _bounds.top));
-
- // Get pointers to the source and destination surface areas
+ if (destBounds.isValidRect()) {
const byte *pSrc = (const byte *)srcSurface.getBasePtr(srcX, srcY);
byte *pDest = (byte *)destSurface.getBasePtr(destBounds.left, destBounds.top);
- // Loop through copying each row
for (int y = 0; y < destBounds.height(); ++y, pSrc += srcSurface.pitch, pDest += destSurface.pitch) {
if (!priorityRegion && (src._transColor == -1))
@@ -621,7 +595,6 @@ void GfxSurface::copyFrom(GfxSurface &src, Rect srcBounds, Rect destBounds, Regi
}
}
- // Unlock the surfaces
unlockSurface();
srcImage.unlockSurface();
}
@@ -640,68 +613,6 @@ void GfxSurface::draw(const Common::Point &pt, Rect *rect) {
}
}
-/**
- * Merges any clipping rectangles that overlap to try and reduce
- * the total number of clip rectangles.
- */
-void GfxSurface::mergeDirtyRects() {
- if (_dirtyRects.size() <= 1)
- return;
-
- Common::List<Rect>::iterator rOuter, rInner;
-
- for (rOuter = _dirtyRects.begin(); rOuter != _dirtyRects.end(); ++rOuter) {
- rInner = rOuter;
- while (++rInner != _dirtyRects.end()) {
-
- if (looseIntersectRectangle(*rOuter, *rInner)) {
- // these two rectangles overlap or
- // are next to each other - merge them
-
- unionRectangle(*rOuter, *rOuter, *rInner);
-
- // remove the inner rect from the list
- _dirtyRects.erase(rInner);
-
- // move back to beginning of list
- rInner = rOuter;
- }
- }
- }
-}
-
-/**
- * Check if the two rectangles are next to each other.
- * @param pSrc1 a source rectangle
- * @param pSrc2 a source rectangle
- */
-bool GfxSurface::looseIntersectRectangle(const Rect &src1, const Rect &src2) {
- Rect destRect;
-
- destRect.left = MAX(src1.left, src2.left);
- destRect.top = MAX(src1.top, src2.top);
- destRect.right = MIN(src1.right, src2.right);
- destRect.bottom = MIN(src1.bottom, src2.bottom);
-
- return destRect.isValidRect();
-}
-
-/**
- * Creates the union of two rectangles.
- * Returns True if there is a union.
- * @param pDest destination rectangle that is to receive the new union
- * @param pSrc1 a source rectangle
- * @param pSrc2 a source rectangle
- */
-bool GfxSurface::unionRectangle(Common::Rect &destRect, const Rect &src1, const Rect &src2) {
- destRect.left = MIN(src1.left, src2.left);
- destRect.top = MIN(src1.top, src2.top);
- destRect.right = MAX(src1.right, src2.right);
- destRect.bottom = MAX(src1.bottom, src2.bottom);
-
- return !destRect.isEmpty();
-}
-
/*--------------------------------------------------------------------------*/
GfxElement::GfxElement() {
@@ -728,9 +639,6 @@ void GfxElement::highlight() {
GfxManager &gfxManager = g_globals->gfxManager();
Graphics::Surface surface = gfxManager.lockSurface();
- // Mark the area is dirty
- gfxManager.addDirtyRect(_bounds);
-
// Scan through the contents of the element, switching any occurances of the foreground
// color with the background color and vice versa
Rect tempRect(_bounds);
@@ -826,7 +734,6 @@ void GfxElement::drawFrame() {
gfxManager.fillRect2(tempRect.right, tempRect.top + 2, 1, tempRect.height() - 3, 0);
gfxManager.unlockSurface();
- gfxManager.addDirtyRect(_bounds);
}
/**
@@ -1183,7 +1090,7 @@ GfxButton *GfxDialog::execute(GfxButton *defaultButton) {
}
g_system->delayMillis(10);
- GLOBALS._screenSurface.copyToScreen();
+ g_system->updateScreen();
}
_gfxManager.deactivate();
@@ -1267,11 +1174,6 @@ void GfxManager::fillArea(int xp, int yp, int color) {
_surface.fillRect(tempRect, color);
}
-void GfxManager::addDirtyRect(const Rect &r) {
- _surface.addDirtyRect(Rect(r.left + _bounds.left, r.top + _bounds.top,
- r.right + _bounds.left, r.bottom + _bounds.top));
-}
-
void GfxManager::fillRect(const Rect &bounds, int color) {
_surface.setBounds(_bounds);
_surface.fillRect(bounds, color);
diff --git a/engines/tsage/graphics.h b/engines/tsage/graphics.h
index e32994505c..dba3401700 100644
--- a/engines/tsage/graphics.h
+++ b/engines/tsage/graphics.h
@@ -74,16 +74,12 @@ public:
class GfxSurface {
private:
Graphics::Surface *_customSurface;
+ Graphics::Surface *_screenSurfaceP;
int _lockSurfaceCtr;
+ bool _screenSurface;
bool _disableUpdates;
Rect _bounds;
- bool _trackDirtyRects;
- Common::List<Rect> _dirtyRects;
-
- void mergeDirtyRects();
- bool looseIntersectRectangle(const Rect &src1, const Rect &src2);
- bool unionRectangle(Common::Rect &destRect, const Rect &src1, const Rect &src2);
public:
Common::Point _centroid;
int _transColor;
@@ -92,9 +88,7 @@ public:
GfxSurface(const GfxSurface &s);
~GfxSurface();
- void trackDirtyRects();
- void addDirtyRect(const Rect &r);
- void copyToScreen();
+ void setScreenSurface();
Graphics::Surface lockSurface();
void unlockSurface();
void synchronize(Serializer &s);
@@ -280,7 +274,6 @@ public:
return _surface.lockSurface();
}
void unlockSurface() { _surface.unlockSurface(); }
- void addDirtyRect(const Rect &r);
void fillArea(int xp, int yp, int color);
void fillRect(const Rect &bounds, int color);
void fillRect2(int xs, int ys, int width, int height, int color);
@@ -308,6 +301,7 @@ public:
void copyFrom(GfxSurface &src, int destX, int destY) {
_surface.setBounds(_bounds);
_surface.copyFrom(src, destX, destY);
+ g_system->updateScreen();
}
GfxSurface &getSurface() {
_surface.setBounds(_bounds);
diff --git a/engines/tsage/ringworld/ringworld_dialogs.cpp b/engines/tsage/ringworld/ringworld_dialogs.cpp
index 0561a27055..233cbe5c4c 100644
--- a/engines/tsage/ringworld/ringworld_dialogs.cpp
+++ b/engines/tsage/ringworld/ringworld_dialogs.cpp
@@ -183,7 +183,7 @@ void RightClickDialog::execute() {
}
g_system->delayMillis(10);
- GLOBALS._screenSurface.copyToScreen();
+ g_system->updateScreen();
}
_gfxManager.deactivate();
@@ -394,7 +394,7 @@ void InventoryDialog::execute() {
Event event;
while (!g_globals->_events.getEvent(event) && !g_vm->shouldQuit()) {
g_system->delayMillis(10);
- GLOBALS._screenSurface.copyToScreen();
+ g_system->updateScreen();
}
if (g_vm->shouldQuit())
break;
diff --git a/engines/tsage/ringworld/ringworld_logic.cpp b/engines/tsage/ringworld/ringworld_logic.cpp
index 2ee4f99267..e37eddf80c 100644
--- a/engines/tsage/ringworld/ringworld_logic.cpp
+++ b/engines/tsage/ringworld/ringworld_logic.cpp
@@ -315,7 +315,7 @@ void SceneArea::wait() {
// Wait until a mouse or keypress
Event event;
while (!g_vm->shouldQuit() && !g_globals->_events.getEvent(event)) {
- GLOBALS._screenSurface.copyToScreen();
+ g_system->updateScreen();
g_system->delayMillis(10);
}
diff --git a/engines/tsage/ringworld/ringworld_scenes3.cpp b/engines/tsage/ringworld/ringworld_scenes3.cpp
index 6f3d1ed93a..81190aea7b 100644
--- a/engines/tsage/ringworld/ringworld_scenes3.cpp
+++ b/engines/tsage/ringworld/ringworld_scenes3.cpp
@@ -532,7 +532,7 @@ void Scene2100::Action1::signal() {
// Wait for an event
Event event;
if (!g_globals->_events.getEvent(event)) {
- GLOBALS._screenSurface.copyToScreen();
+ g_system->updateScreen();
g_system->delayMillis(10);
continue;
}
@@ -2263,7 +2263,7 @@ void Scene2150::Action1::signal() {
// Wait for an event
Event event;
if (!g_globals->_events.getEvent(event)) {
- GLOBALS._screenSurface.copyToScreen();
+ g_system->updateScreen();
g_system->delayMillis(10);
continue;
}
@@ -5118,7 +5118,7 @@ void Scene2320::Action3::signal() {
// Wait for an event
Event event;
if (!g_globals->_events.getEvent(event)) {
- GLOBALS._screenSurface.copyToScreen();
+ g_system->updateScreen();
g_system->delayMillis(10);
continue;
}
diff --git a/engines/tsage/ringworld/ringworld_scenes5.cpp b/engines/tsage/ringworld/ringworld_scenes5.cpp
index 7c8da54fac..49726eba2e 100644
--- a/engines/tsage/ringworld/ringworld_scenes5.cpp
+++ b/engines/tsage/ringworld/ringworld_scenes5.cpp
@@ -2810,7 +2810,7 @@ void Scene4150::Action1::signal() {
case 4: {
for (int idx = 100; idx >= 0; idx -= 5) {
g_globals->_scenePalette.fade(adjustData, false, idx);
- GLOBALS._screenSurface.copyToScreen();
+ g_system->updateScreen();
g_system->delayMillis(10);
}
@@ -2838,7 +2838,7 @@ void Scene4150::Action1::signal() {
case 7:
for (int idx = 100; idx >= 0; idx -= 5) {
g_globals->_scenePalette.fade(adjustData, false, idx);
- GLOBALS._screenSurface.copyToScreen();
+ g_system->updateScreen();
g_system->delayMillis(10);
}
diff --git a/engines/tsage/ringworld2/ringworld2_dialogs.cpp b/engines/tsage/ringworld2/ringworld2_dialogs.cpp
index 6035b37e19..ddb4eae9c4 100644
--- a/engines/tsage/ringworld2/ringworld2_dialogs.cpp
+++ b/engines/tsage/ringworld2/ringworld2_dialogs.cpp
@@ -153,7 +153,7 @@ void RightClickDialog::execute() {
}
g_system->delayMillis(10);
- GLOBALS._screenSurface.copyToScreen();
+ g_system->updateScreen();
}
// Execute the specified action
diff --git a/engines/tsage/scenes.cpp b/engines/tsage/scenes.cpp
index 03c7d8d0ae..6362c63bc3 100644
--- a/engines/tsage/scenes.cpp
+++ b/engines/tsage/scenes.cpp
@@ -133,7 +133,7 @@ void SceneManager::fadeInIfNecessary() {
percent = 100;
g_globals->_scenePalette.fade((const byte *)&adjustData, false, percent);
- GLOBALS._screenSurface.copyToScreen();
+ g_system->updateScreen();
g_system->delayMillis(10);
}