[Scummvm-cvs-logs] SF.net SVN: scummvm:[51859] scummvm/trunk

drmccoy at users.sourceforge.net drmccoy at users.sourceforge.net
Sun Aug 8 02:39:04 CEST 2010


Revision: 51859
          http://scummvm.svn.sourceforge.net/scummvm/?rev=51859&view=rev
Author:   drmccoy
Date:     2010-08-08 00:39:03 +0000 (Sun, 08 Aug 2010)

Log Message:
-----------
VIDEO/GOB: Add CoktelDecoder::getDirtyRects()

This allows for the client code to only update the parts of the
video frames that actually changed.

Modified Paths:
--------------
    scummvm/trunk/engines/gob/demos/demoplayer.cpp
    scummvm/trunk/engines/gob/videoplayer.cpp
    scummvm/trunk/graphics/video/coktel_decoder.cpp
    scummvm/trunk/graphics/video/coktel_decoder.h

Modified: scummvm/trunk/engines/gob/demos/demoplayer.cpp
===================================================================
--- scummvm/trunk/engines/gob/demos/demoplayer.cpp	2010-08-08 00:38:26 UTC (rev 51858)
+++ scummvm/trunk/engines/gob/demos/demoplayer.cpp	2010-08-08 00:39:03 UTC (rev 51859)
@@ -226,6 +226,7 @@
 		for (uint i = 0; i < _vm->_vidPlayer->getFrameCount(); i++) {
 			// _vm->_vidPlayer->playFrame(i);
 
+			/*
 			Graphics::CoktelDecoder::State state;// = _vm->_vidPlayer->getState();
 
 			int16 w = state.right - state.left + 1;
@@ -237,6 +238,7 @@
 					state.left, state.top, state.right, state.bottom, state.left, state.top, 0);
 			_vm->_draw->dirtiedRect(_vm->_draw->_frontSurface,
 					state.left * 2, state.top * 2, wD, hD);
+			*/
 			_vm->_video->retrace();
 
 			_vm->_util->processInput();

Modified: scummvm/trunk/engines/gob/videoplayer.cpp
===================================================================
--- scummvm/trunk/engines/gob/videoplayer.cpp	2010-08-08 00:38:26 UTC (rev 51858)
+++ scummvm/trunk/engines/gob/videoplayer.cpp	2010-08-08 00:39:03 UTC (rev 51859)
@@ -307,23 +307,23 @@
 		}
 		*/
 
+		const Common::List<Common::Rect> &dirtyRects = video->decoder->getDirtyRects();
+
 		if (modifiedPal && (properties.palCmd == 8) && (properties.sprite == Draw::kBackSurface))
 			_vm->_video->setFullPalette(_vm->_global->_pPaletteDesc);
 
 		if (properties.sprite == Draw::kBackSurface) {
 
-			_vm->_draw->invalidateRect(properties.x, properties.y,
-					properties.x + video->decoder->getWidth(),
-					properties.y + video->decoder->getHeight());
+			for (Common::List<Common::Rect>::const_iterator rect = dirtyRects.begin(); rect != dirtyRects.end(); ++rect)
+				_vm->_draw->invalidateRect(rect->left, rect->top, rect->right - 1, rect->bottom - 1);
 			_vm->_draw->blitInvalidated();
 
 			// if (!noRetrace)
 				_vm->_video->retrace();
 
 		} else if (properties.sprite == Draw::kFrontSurface) {
-			_vm->_video->dirtyRectsAdd(properties.x, properties.y,
-					properties.x + video->decoder->getWidth(),
-					properties.y + video->decoder->getHeight());
+			for (Common::List<Common::Rect>::const_iterator rect = dirtyRects.begin(); rect != dirtyRects.end(); ++rect)
+				_vm->_video->dirtyRectsAdd(rect->left, rect->top, rect->right - 1, rect->bottom - 1);
 
 			// if (!noRetrace)
 				_vm->_video->retrace();

Modified: scummvm/trunk/graphics/video/coktel_decoder.cpp
===================================================================
--- scummvm/trunk/graphics/video/coktel_decoder.cpp	2010-08-08 00:38:26 UTC (rev 51858)
+++ scummvm/trunk/graphics/video/coktel_decoder.cpp	2010-08-08 00:39:03 UTC (rev 51859)
@@ -29,7 +29,7 @@
 
 namespace Graphics {
 
-CoktelDecoder::State::State() : left(0), top(0), right(0), bottom(0), flags(0), speechId(0) {
+CoktelDecoder::State::State() : flags(0), speechId(0) {
 }
 
 
@@ -97,6 +97,10 @@
 	_y = y;
 }
 
+const Common::List<Common::Rect> &CoktelDecoder::getDirtyRects() const {
+	return _dirtyRects;
+}
+
 void CoktelDecoder::close() {
 	freeSurface();
 
@@ -299,6 +303,8 @@
 }
 
 void PreIMDDecoder::renderFrame() {
+	_dirtyRects.clear();
+
 	uint16 w = CLIP<int32>(_surface.w - _x, 0, _width);
 	uint16 h = CLIP<int32>(_surface.h - _y, 0, _height);
 
@@ -317,6 +323,8 @@
 
 		frameDataSize -= n;
 	}
+
+	_dirtyRects.push_back(Common::Rect(_x, _y, _x + _width, _y + _height));
 }
 
 PixelFormat PreIMDDecoder::getPixelFormat() const {

Modified: scummvm/trunk/graphics/video/coktel_decoder.h
===================================================================
--- scummvm/trunk/graphics/video/coktel_decoder.h	2010-08-08 00:38:26 UTC (rev 51858)
+++ scummvm/trunk/graphics/video/coktel_decoder.h	2010-08-08 00:39:03 UTC (rev 51859)
@@ -33,6 +33,9 @@
 #ifndef GRAPHICS_VIDEO_COKTELDECODER_H
 #define GRAPHICS_VIDEO_COKTELDECODER_H
 
+#include "common/list.h"
+#include "common/rect.h"
+
 #include "graphics/video/video_decoder.h"
 
 #include "sound/mixer.h"
@@ -42,14 +45,6 @@
 class CoktelDecoder : public FixedRateVideoDecoder {
 public:
 	struct State {
-		/** Left-most value of the updated rectangle. */
-		int16 left;
-		/** Top-most value of the updated rectangle. */
-		int16 top;
-		/** Right-most value of the updated rectangle. */
-		int16 right;
-		/** Bottom-most value of the updated rectangle. */
-		int16 bottom;
 		/** Set accordingly to what was done. */
 		uint32 flags;
 		/** The id of the spoken words. */
@@ -72,6 +67,9 @@
 	/** Draw the video starting at this position within the video memory. */
 	void setXY(uint16 x, uint16 y);
 
+	/** Return a list of rectangles that changed in the last frame. */
+	const Common::List<Common::Rect> &getDirtyRects() const;
+
 	// VideoDecoder interface
 
 	void close();
@@ -102,6 +100,8 @@
 	bool    _ownSurface;
 	Surface _surface;
 
+	Common::List<Common::Rect> _dirtyRects;
+
 	Common::Rational _frameRate;
 
 	bool hasSurface();


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list