[Scummvm-cvs-logs] scummvm master -> ac8adb07c835885584517674b9b03bab14e8a772

dreammaster dreammaster at scummvm.org
Fri May 27 03:21:18 CEST 2016


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
ac8adb07c8 ACCESS: Refactor ASurface and Screen to not use virtual inheritance


Commit: ac8adb07c835885584517674b9b03bab14e8a772
    https://github.com/scummvm/scummvm/commit/ac8adb07c835885584517674b9b03bab14e8a772
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2016-05-26T21:21:03-04:00

Commit Message:
ACCESS: Refactor ASurface and Screen to not use virtual inheritance

Changed paths:
    engines/access/access.cpp
    engines/access/access.h
    engines/access/amazon/amazon_game.cpp
    engines/access/asurface.cpp
    engines/access/asurface.h
    engines/access/bubble_box.cpp
    engines/access/font.cpp
    engines/access/font.h
    engines/access/screen.cpp
    engines/access/screen.h
    engines/access/video.cpp
    engines/access/video.h



diff --git a/engines/access/access.cpp b/engines/access/access.cpp
index c12761a..6f91bd7 100644
--- a/engines/access/access.cpp
+++ b/engines/access/access.cpp
@@ -244,7 +244,7 @@ void AccessEngine::freeCells() {
 	}
 }
 
-void AccessEngine::speakText(ASurface *s, const Common::String &msg) {
+void AccessEngine::speakText(BaseSurface *s, const Common::String &msg) {
 	Common::String lines = msg;
 	Common::String line;
 	int curPage = 0;
@@ -325,7 +325,7 @@ void AccessEngine::speakText(ASurface *s, const Common::String &msg) {
 	}
 }
 
-void AccessEngine::printText(ASurface *s, const Common::String &msg) {
+void AccessEngine::printText(BaseSurface *s, const Common::String &msg) {
 	Common::String lines = msg;
 	Common::String line;
 	int width = 0;
diff --git a/engines/access/access.h b/engines/access/access.h
index 2ca4a34..972dd4c 100644
--- a/engines/access/access.h
+++ b/engines/access/access.h
@@ -156,8 +156,8 @@ public:
 	MusicManager *_midi;
 	VideoPlayer *_video;
 
-	ASurface *_destIn;
-	ASurface *_current;
+	BaseSurface *_destIn;
+	BaseSurface *_current;
 	ASurface _buffer1;
 	ASurface _buffer2;
 	ASurface _vidBuf;
@@ -280,8 +280,8 @@ public:
 	/**
 	 * Draw a string on a given surface and update text positioning
 	 */
-	void printText(ASurface *s, const Common::String &msg);
-	void speakText(ASurface *s, const Common::String &msg);
+	void printText(BaseSurface *s, const Common::String &msg);
+	void speakText(BaseSurface *s, const Common::String &msg);
 
 	/**
 	 * Load a savegame
diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp
index 0a671d2..8467d8b 100644
--- a/engines/access/amazon/amazon_game.cpp
+++ b/engines/access/amazon/amazon_game.cpp
@@ -496,7 +496,7 @@ void AmazonEngine::drawHelp(const Common::String str) {
 
 	_files->loadScreen(95, 2);
 	if (_moreHelp == 1) {
-		ASurface *oldDest = _destIn;
+		BaseSurface *oldDest = _destIn;
 		_destIn = _screen;
 		int oldClip = _screen->_clipHeight;
 		_screen->_clipHeight = 200;
diff --git a/engines/access/asurface.cpp b/engines/access/asurface.cpp
index 2518ff6..e92869b 100644
--- a/engines/access/asurface.cpp
+++ b/engines/access/asurface.cpp
@@ -107,10 +107,10 @@ void ImageEntryList::addToList(ImageEntry &ie) {
 
 /*------------------------------------------------------------------------*/
 
-int ASurface::_clipWidth;
-int ASurface::_clipHeight;
+int BaseSurface::_clipWidth;
+int BaseSurface::_clipHeight;
 
-ASurface::ASurface(): Graphics::ManagedSurface() {
+BaseSurface::BaseSurface(): Graphics::Screen() {
 	_leftSkip = _rightSkip = 0;
 	_topSkip = _bottomSkip = 0;
 	_lastBoundsX = _lastBoundsY = 0;
@@ -121,16 +121,16 @@ ASurface::ASurface(): Graphics::ManagedSurface() {
 	_maxChars = 0;
 }
 
-ASurface::~ASurface() {
+BaseSurface::~BaseSurface() {
 	_savedBlock.free();
 }
 
-void ASurface::clearBuffer() {
+void BaseSurface::clearBuffer() {
 	byte *pSrc = (byte *)getPixels();
 	Common::fill(pSrc, pSrc + w * h, 0);
 }
 
-void ASurface::plotImage(SpriteResource *sprite, int frameNum, const Common::Point &pt) {
+void BaseSurface::plotImage(SpriteResource *sprite, int frameNum, const Common::Point &pt) {
 	SpriteFrame *frame = sprite->getFrame(frameNum);
 	Common::Rect r(pt.x, pt.y, pt.x + frame->w, pt.y + frame->h);
 
@@ -144,38 +144,38 @@ void ASurface::plotImage(SpriteResource *sprite, int frameNum, const Common::Poi
 	}
 }
 
-void ASurface::copyBuffer(Graphics::ManagedSurface *src) {
+void BaseSurface::copyBuffer(Graphics::ManagedSurface *src) {
 	blitFrom(*src);
 }
 
-void ASurface::plotF(SpriteFrame *frame, const Common::Point &pt) {
+void BaseSurface::plotF(SpriteFrame *frame, const Common::Point &pt) {
 	sPlotF(frame, Common::Rect(pt.x, pt.y, pt.x + frame->w, pt.y + frame->h));
 }
 
-void ASurface::plotB(SpriteFrame *frame, const Common::Point &pt) {
+void BaseSurface::plotB(SpriteFrame *frame, const Common::Point &pt) {
 	sPlotB(frame, Common::Rect(pt.x, pt.y, pt.x + frame->w, pt.y + frame->h));
 }
 
-void ASurface::sPlotF(SpriteFrame *frame, const Common::Rect &bounds) {
+void BaseSurface::sPlotF(SpriteFrame *frame, const Common::Rect &bounds) {
 	transBlitFrom(*frame, Common::Rect(0, 0, frame->w, frame->h), bounds, TRANSPARENCY, false);
 }
 
-void ASurface::sPlotB(SpriteFrame *frame, const Common::Rect &bounds) {
+void BaseSurface::sPlotB(SpriteFrame *frame, const Common::Rect &bounds) {
 	transBlitFrom(*frame, Common::Rect(0, 0, frame->w, frame->h), bounds, TRANSPARENCY, true);
 }
 
-void ASurface::copyBlock(ASurface *src, const Common::Rect &bounds) {
+void BaseSurface::copyBlock(BaseSurface *src, const Common::Rect &bounds) {
 	copyRectToSurface(*src, bounds.left, bounds.top, bounds);
 }
 
-void ASurface::copyTo(ASurface *dest) { 
+void BaseSurface::copyTo(BaseSurface *dest) {
 	if (dest->empty())
 		dest->create(this->w, this->h);
 
 	dest->blitFrom(*this); 
 }
 
-void ASurface::saveBlock(const Common::Rect &bounds) {
+void BaseSurface::saveBlock(const Common::Rect &bounds) {
 	_savedBounds = bounds;
 	_savedBounds.clip(Common::Rect(0, 0, this->w, this->h));
 
@@ -185,7 +185,7 @@ void ASurface::saveBlock(const Common::Rect &bounds) {
 	_savedBlock.copyRectToSurface(*this, 0, 0, _savedBounds);
 }
 
-void ASurface::restoreBlock() {
+void BaseSurface::restoreBlock() {
 	if (!_savedBounds.isEmpty()) {
 		copyRectToSurface(_savedBlock, _savedBounds.left, _savedBounds.top,
 			Common::Rect(0, 0, _savedBlock.w, _savedBlock.h));
@@ -195,26 +195,26 @@ void ASurface::restoreBlock() {
 	}
 }
 
-void ASurface::drawRect() {
+void BaseSurface::drawRect() {
 	Graphics::ManagedSurface::fillRect(Common::Rect(_orgX1, _orgY1, _orgX2, _orgY2), _lColor);
 }
 
-void ASurface::drawLine(int x1, int y1, int x2, int y2, int col) {
+void BaseSurface::drawLine(int x1, int y1, int x2, int y2, int col) {
 	Graphics::ManagedSurface::drawLine(x1, y1, x2, y2, col);
 }
 
-void ASurface::drawLine() {
+void BaseSurface::drawLine() {
 	Graphics::ManagedSurface::drawLine(_orgX1, _orgY1, _orgX2, _orgY1, _lColor);
 }
 
-void ASurface::drawBox() {
+void BaseSurface::drawBox() {
 	Graphics::ManagedSurface::drawLine(_orgX1, _orgY1, _orgX2, _orgY1, _lColor);
 	Graphics::ManagedSurface::drawLine(_orgX1, _orgY2, _orgX2, _orgY2, _lColor);
 	Graphics::ManagedSurface::drawLine(_orgX2, _orgY1, _orgX2, _orgY1, _lColor);
 	Graphics::ManagedSurface::drawLine(_orgX2, _orgY2, _orgX2, _orgY2, _lColor);
 }
 
-void ASurface::flipHorizontal(ASurface &dest) {
+void BaseSurface::flipHorizontal(BaseSurface &dest) {
 	dest.create(this->w, this->h);
 	for (int y = 0; y < h; ++y) {
 		const byte *pSrc = (const byte *)getBasePtr(this->w - 1, y);
@@ -225,27 +225,27 @@ void ASurface::flipHorizontal(ASurface &dest) {
 	}
 }
 
-void ASurface::moveBufferLeft() {
+void BaseSurface::moveBufferLeft() {
 	byte *p = (byte *)getPixels();
 	Common::copy(p + TILE_WIDTH, p + (w * h), p);
 }
 
-void ASurface::moveBufferRight() {
+void BaseSurface::moveBufferRight() {
 	byte *p = (byte *)getPixels();
 	Common::copy_backward(p, p + (pitch * h) - TILE_WIDTH, p + (pitch * h));
 }
 
-void ASurface::moveBufferUp() {
+void BaseSurface::moveBufferUp() {
 	byte *p = (byte *)getPixels();
 	Common::copy(p + (pitch * TILE_HEIGHT), p + (pitch * h), p);
 }
 
-void ASurface::moveBufferDown() {
+void BaseSurface::moveBufferDown() {
 	byte *p = (byte *)getPixels();
 	Common::copy_backward(p, p + (pitch * (h - TILE_HEIGHT)), p + (pitch * h));
 }
 
-bool ASurface::clip(Common::Rect &r) {
+bool BaseSurface::clip(Common::Rect &r) {
 	int skip;
 	_leftSkip = _rightSkip = 0;
 	_topSkip = _bottomSkip = 0;
diff --git a/engines/access/asurface.h b/engines/access/asurface.h
index ec18ec0..64ddf3d 100644
--- a/engines/access/asurface.h
+++ b/engines/access/asurface.h
@@ -27,7 +27,7 @@
 #include "common/array.h"
 #include "common/memstream.h"
 #include "common/rect.h"
-#include "graphics/managed_surface.h"
+#include "graphics/screen.h"
 #include "access/data.h"
 
 namespace Access {
@@ -35,11 +35,16 @@ namespace Access {
 class SpriteResource;
 class SpriteFrame;
 
-class ASurface : virtual public Graphics::ManagedSurface {
+/**
+ * Base Access surface class. This derivces from Graphics::Screen
+ * because it has logic we'll need for our own Screen class that
+ * derives from this one
+ */
+class BaseSurface : virtual public Graphics::Screen {
 private:
 	Graphics::Surface _savedBlock;
 
-	void flipHorizontal(ASurface &dest);
+	void flipHorizontal(BaseSurface &dest);
 protected:
 	Common::Rect _savedBounds;
 public:
@@ -57,9 +62,9 @@ public:
 public:
 	static int _clipWidth, _clipHeight;
 public:
-	ASurface();
+	BaseSurface();
 
-	virtual ~ASurface();
+	virtual ~BaseSurface();
 
 	void clearBuffer();
 
@@ -85,7 +90,7 @@ public:
 	 */
 	void plotB(SpriteFrame *frame, const Common::Point &pt);
 
-	virtual void copyBlock(ASurface *src, const Common::Rect &bounds);
+	virtual void copyBlock(BaseSurface *src, const Common::Rect &bounds);
 
 	virtual void restoreBlock();
 
@@ -99,7 +104,7 @@ public:
 
 	virtual void copyBuffer(Graphics::ManagedSurface *src);
 
-	void copyTo(ASurface *dest);
+	void copyTo(BaseSurface *dest);
 
 	void saveBlock(const Common::Rect &bounds);
 
@@ -114,6 +119,17 @@ public:
 	bool clip(Common::Rect &r);
 };
 
+class ASurface : public BaseSurface {
+protected:
+	/**
+	 * Override the addDirtyRect from Graphics::Screen, since for standard
+	 * surfaces we don't need dirty rects to be tracked
+	 */
+	virtual void addDirtyRect(const Common::Rect &r) {}
+public:
+	ASurface() : BaseSurface() {}
+};
+
 class SpriteFrame : public ASurface {
 public:
 	SpriteFrame(AccessEngine *vm, Common::SeekableReadStream *stream, int frameSize);
diff --git a/engines/access/bubble_box.cpp b/engines/access/bubble_box.cpp
index e557019..29b58a3 100644
--- a/engines/access/bubble_box.cpp
+++ b/engines/access/bubble_box.cpp
@@ -228,7 +228,7 @@ void BubbleBox::drawBubble(int index) {
 
 void BubbleBox::doBox(int item, int box) {
 	FontManager &fonts = _vm->_fonts;
-	ASurface &screen = *_vm->_screen;
+	Screen &screen = *_vm->_screen;
 
 	_startItem = item;
 	_startBox = box;
diff --git a/engines/access/font.cpp b/engines/access/font.cpp
index 6ae65e4..8e02f80 100644
--- a/engines/access/font.cpp
+++ b/engines/access/font.cpp
@@ -139,7 +139,7 @@ bool Font::getLine(Common::String &s, int maxWidth, Common::String &line, int &w
 	return true;
 }
 
-void Font::drawString(ASurface *s, const Common::String &msg, const Common::Point &pt) {
+void Font::drawString(BaseSurface *s, const Common::String &msg, const Common::Point &pt) {
 	Common::Point currPt = pt;
 	const char *msgP = msg.c_str();
 
@@ -149,7 +149,7 @@ void Font::drawString(ASurface *s, const Common::String &msg, const Common::Poin
 	}
 }
 
-int Font::drawChar(ASurface *s, char c, Common::Point &pt) {
+int Font::drawChar(BaseSurface *s, char c, Common::Point &pt) {
 	Graphics::Surface &ch = _chars[c - ' '];
 	Graphics::Surface dest = s->getSubArea(Common::Rect(pt.x, pt.y, pt.x + ch.w, pt.y + ch.h));
 
diff --git a/engines/access/font.h b/engines/access/font.h
index 6a81205..9234078 100644
--- a/engines/access/font.h
+++ b/engines/access/font.h
@@ -78,12 +78,12 @@ public:
 	/**
 	 * Draw a string on a given surface
 	 */
-	void drawString(ASurface *s, const Common::String &msg, const Common::Point &pt);
+	void drawString(BaseSurface *s, const Common::String &msg, const Common::Point &pt);
 
 	/**
 	 * Draw a character on a given surface
 	 */
-	int drawChar(ASurface *s, char c, Common::Point &pt);
+	int drawChar(BaseSurface *s, char c, Common::Point &pt);
 
 };
 
diff --git a/engines/access/screen.cpp b/engines/access/screen.cpp
index 9700640..e62af9f 100644
--- a/engines/access/screen.cpp
+++ b/engines/access/screen.cpp
@@ -264,22 +264,22 @@ void Screen::copyBlock(ASurface *src, const Common::Rect &bounds) {
 void Screen::restoreBlock() {
 	if (!_savedBounds.isEmpty())
 		addDirtyRect(_savedBounds);
-	ASurface::restoreBlock();
+	BaseSurface::restoreBlock();
 }
 
 void Screen::drawRect() {
 	addDirtyRect(Common::Rect(_orgX1, _orgY1, _orgX2, _orgY2));
-	ASurface::drawRect();
+	BaseSurface::drawRect();
 }
 
 void Screen::drawBox() {
 	addDirtyRect(Common::Rect(_orgX1, _orgY1, _orgX2, _orgY2));
-	ASurface::drawBox();
+	BaseSurface::drawBox();
 }
 
 void Screen::copyBuffer(Graphics::ManagedSurface *src) {
 	addDirtyRect(Common::Rect(0, 0, src->w, src->h));
-	ASurface::copyBuffer(src);
+	BaseSurface::copyBuffer(src);
 }
 
 void Screen::setPaletteCycle(int startCycle, int endCycle, int timer) {
diff --git a/engines/access/screen.h b/engines/access/screen.h
index a022741..9330054 100644
--- a/engines/access/screen.h
+++ b/engines/access/screen.h
@@ -45,7 +45,7 @@ struct ScreenSave {
 	int _screenYOff;
 };
 
-class Screen : public virtual ASurface, public virtual Graphics::Screen {
+class Screen : public BaseSurface {
 private:
 	AccessEngine *_vm;
 	byte _tempPalette[PALETTE_SIZE];
diff --git a/engines/access/video.cpp b/engines/access/video.cpp
index e3ff457..22842a5 100644
--- a/engines/access/video.cpp
+++ b/engines/access/video.cpp
@@ -48,7 +48,7 @@ VideoPlayer::~VideoPlayer() {
 	closeVideo();
 }
 
-void VideoPlayer::setVideo(ASurface *vidSurface, const Common::Point &pt, int rate) {
+void VideoPlayer::setVideo(BaseSurface *vidSurface, const Common::Point &pt, int rate) {
 	_vidSurface = vidSurface;
 	vidSurface->_orgX1 = pt.x;
 	vidSurface->_orgY1 = pt.y;
@@ -87,14 +87,14 @@ void VideoPlayer::setVideo(ASurface *vidSurface, const Common::Point &pt, int ra
 	_videoEnd = false;
 }
 
-void VideoPlayer::setVideo(ASurface *vidSurface, const Common::Point &pt, const Common::String filename, int rate) {
+void VideoPlayer::setVideo(BaseSurface *vidSurface, const Common::Point &pt, const Common::String filename, int rate) {
 	// Open up video stream
 	_videoData = _vm->_files->loadFile(filename);
 
 	setVideo(vidSurface, pt, rate);
 }
 
-void VideoPlayer::setVideo(ASurface *vidSurface, const Common::Point &pt, const FileIdent &videoFile, int rate) {
+void VideoPlayer::setVideo(BaseSurface *vidSurface, const Common::Point &pt, const FileIdent &videoFile, int rate) {
 	// Open up video stream
 	_videoData = _vm->_files->loadFile(videoFile);
 	
diff --git a/engines/access/video.h b/engines/access/video.h
index 83c8995..65dff3e 100644
--- a/engines/access/video.h
+++ b/engines/access/video.h
@@ -40,7 +40,7 @@ class VideoPlayer : public Manager {
 		VideoFlags _flags;
 	};
 private:
-	ASurface *_vidSurface;
+	BaseSurface *_vidSurface;
 	Resource *_videoData;
 	VideoHeader _header;
 	byte *_startCoord;
@@ -51,7 +51,7 @@ private:
 	Common::Rect _videoBounds;
 
 	void getFrame();
-	void setVideo(ASurface *vidSurface, const Common::Point &pt, int rate);
+	void setVideo(BaseSurface *vidSurface, const Common::Point &pt, int rate);
 public:
 	int _videoFrame;
 	bool _soundFlag;
@@ -64,8 +64,8 @@ public:
 	/**
 	 * Start up a video
 	 */
-	void setVideo(ASurface *vidSurface, const Common::Point &pt, const FileIdent &videoFile, int rate);
-	void setVideo(ASurface *vidSurface, const Common::Point &pt, const Common::String filename, int rate);
+	void setVideo(BaseSurface *vidSurface, const Common::Point &pt, const FileIdent &videoFile, int rate);
+	void setVideo(BaseSurface *vidSurface, const Common::Point &pt, const Common::String filename, int rate);
 
 	/**
 	 * Decodes a frame of the video






More information about the Scummvm-git-logs mailing list