@@ -35,6 +35,9 @@ namespace Pegasus {
35
35
GraphicsManager::GraphicsManager (PegasusEngine *vm) : _vm(vm) {
36
36
initGraphics (640 , 480 , true , NULL );
37
37
38
+ if (_vm->_system ->getScreenFormat ().bytesPerPixel == 1 )
39
+ error (" No true color mode available" );
40
+
38
41
// Old
39
42
_pictDecoder = new Graphics::PictDecoder (_vm->_system ->getScreenFormat ());
40
43
@@ -45,6 +48,7 @@ GraphicsManager::GraphicsManager(PegasusEngine *vm) : _vm(vm) {
45
48
_backLayer = kMinAvailableOrder ;
46
49
_frontLayer = kMaxAvailableOrder ;
47
50
_firstDisplayElement = _lastDisplayElement = 0 ;
51
+ _workArea.create (640 , 480 , _vm->_system ->getScreenFormat ());
48
52
}
49
53
50
54
GraphicsManager::~GraphicsManager () {
@@ -57,6 +61,9 @@ GraphicsManager::~GraphicsManager() {
57
61
delete _cache[i].surface ;
58
62
}
59
63
}
64
+
65
+ // New
66
+ _workArea.free ();
60
67
}
61
68
62
69
Graphics::Surface *GraphicsManager::decodeImage (const Common::String &filename) {
@@ -272,5 +279,35 @@ void GraphicsManager::removeDisplayElement(DisplayElement *oldElement) {
272
279
oldElement->_nextElement = 0 ;
273
280
oldElement->_elementIsDisplaying = false ;
274
281
}
282
+
283
+ void GraphicsManager::updateDisplay () {
284
+ // TODO: Check for cursor move/change
285
+
286
+ bool screenDirty = false ;
287
+
288
+ if (!_dirtyRect.isEmpty ()) {
289
+ for (DisplayElement *runner = _firstDisplayElement; runner != 0 ; runner = runner->_nextElement ) {
290
+ Common::Rect bounds;
291
+ runner->getBounds (bounds);
292
+
293
+ // TODO: Better logic; it does a bit more work than it probably needs to
294
+ // but it should work fine for now.
295
+ if (bounds.intersects (_dirtyRect) && runner->validToDraw (_backLayer, _frontLayer))
296
+ runner->draw (bounds);
297
+ }
298
+
299
+ // Copy only the dirty rect to the screen
300
+ g_system->copyRectToScreen ((byte *)_workArea.pixels , _workArea.pitch , _dirtyRect.left , _dirtyRect.top , _dirtyRect.width (), _dirtyRect.height ());
301
+
302
+ // Mark the screen as dirty
303
+ screenDirty = true ;
304
+
305
+ // Clear the dirty rect
306
+ _dirtyRect = Common::Rect ();
307
+ }
308
+
309
+ if (screenDirty)
310
+ g_system->updateScreen ();
311
+ }
275
312
276
313
} // End of namespace Pegasus
0 commit comments