aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/xeen/screen.cpp15
-rw-r--r--engines/xeen/screen.h2
-rw-r--r--engines/xeen/xsurface.cpp46
-rw-r--r--engines/xeen/xsurface.h31
4 files changed, 27 insertions, 67 deletions
diff --git a/engines/xeen/screen.cpp b/engines/xeen/screen.cpp
index a013b9706b..e1e7b50a56 100644
--- a/engines/xeen/screen.cpp
+++ b/engines/xeen/screen.cpp
@@ -33,12 +33,21 @@ Window::Window() : _vm(nullptr), _enabled(false), _a(0), _border(0),
_xLo(0), _xHi(0), _ycL(0), _ycH(0) {
}
+Window::Window(const Window &src) : _vm(src._vm), _enabled(src._enabled),
+ _a(src._a), _border(src._border), _xLo(src._xLo), _ycL(src._ycL),
+ _xHi(src._xHi), _ycH(src._ycH) {
+ if (src._vm) {
+ setBounds(src._bounds);
+ create(*_vm->_screen, Common::Rect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT));
+ }
+}
+
Window::Window(XeenEngine *vm, const Common::Rect &bounds, int a, int border,
int xLo, int ycL, int xHi, int ycH):
_vm(vm), _enabled(false), _a(a), _border(border),
_xLo(xLo), _ycL(ycL), _xHi(xHi), _ycH(ycH) {
setBounds(bounds);
- create(_vm->_screen, Common::Rect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT));
+ create(*_vm->_screen, Common::Rect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT));
}
void Window::setBounds(const Common::Rect &r) {
@@ -346,7 +355,7 @@ void Screen::loadPage(int pageNum) {
_pages[1].create(SCREEN_WIDTH, SCREEN_HEIGHT);
}
- blitTo(_pages[pageNum]);
+ _pages[pageNum].blitFrom(*this);
}
void Screen::freePages() {
@@ -447,7 +456,7 @@ void Screen::saveBackground(int slot) {
void Screen::restoreBackground(int slot) {
assert(slot > 0 && slot < 10);
- _savedScreens[slot - 1].blitTo(*this);
+ blitFrom(_savedScreens[slot - 1]);
}
void Screen::frameWindow(uint bgType) {
diff --git a/engines/xeen/screen.h b/engines/xeen/screen.h
index 4ab76d529d..854a05a7cf 100644
--- a/engines/xeen/screen.h
+++ b/engines/xeen/screen.h
@@ -74,7 +74,7 @@ public:
virtual void addDirtyRect(const Common::Rect &r);
public:
Window();
-
+ Window(const Window &src);
Window(XeenEngine *vm, const Common::Rect &bounds, int a, int border,
int xLo, int ycL, int xHi, int ycH);
diff --git a/engines/xeen/xsurface.cpp b/engines/xeen/xsurface.cpp
index 1793d76129..5f10a83dc6 100644
--- a/engines/xeen/xsurface.cpp
+++ b/engines/xeen/xsurface.cpp
@@ -28,50 +28,4 @@
namespace Xeen {
-XSurface::XSurface() : Graphics::Surface(), _freeFlag(false) {
-}
-
-XSurface::XSurface(int width, int height) : Graphics::Surface(),
- _freeFlag(false) {
- create(w, h);
-}
-
-XSurface::~XSurface() {
- if (_freeFlag)
- free();
-}
-
-void XSurface::create(uint16 width, uint16 height) {
- Graphics::Surface::create(width, height, Graphics::PixelFormat::createFormatCLUT8());
- _freeFlag = true;
-}
-
-void XSurface::create(XSurface *s, const Common::Rect &bounds) {
- pixels = (byte *)s->getBasePtr(bounds.left, bounds.top);
- format = Graphics::PixelFormat::createFormatCLUT8();
- pitch = s->pitch;
- w = bounds.width();
- h = bounds.height();
-
- _freeFlag = false;
-}
-
-void XSurface::blitTo(XSurface &dest) const {
- blitTo(dest, Common::Point());
-}
-
-void XSurface::blitTo(XSurface &dest, const Common::Point &destPos) const {
- if (dest.getPixels() == nullptr)
- dest.create(w, h);
-
- for (int yp = 0; yp < h; ++yp) {
- const byte *srcP = (const byte *)getBasePtr(0, yp);
- byte *destP = (byte *)dest.getBasePtr(destPos.x, destPos.y + yp);
-
- Common::copy(srcP, srcP + w, destP);
- }
-
- dest.addDirtyRect(Common::Rect(destPos.x, destPos.y, destPos.x + w, destPos.y + h));
-}
-
} // End of namespace Xeen
diff --git a/engines/xeen/xsurface.h b/engines/xeen/xsurface.h
index f562112e5c..40d4611419 100644
--- a/engines/xeen/xsurface.h
+++ b/engines/xeen/xsurface.h
@@ -26,29 +26,26 @@
#include "common/scummsys.h"
#include "common/system.h"
#include "common/rect.h"
-#include "graphics/surface.h"
+#include "graphics/managed_surface.h"
namespace Xeen {
-class XSurface: public Graphics::Surface {
-private:
- bool _freeFlag;
+class BaseSurface: public Graphics::ManagedSurface {
public:
- virtual void addDirtyRect(const Common::Rect &r) {}
+ virtual void addDirtyRect(const Common::Rect &r) {
+ Graphics::ManagedSurface::addDirtyRect(r);
+ }
public:
- XSurface();
- XSurface(int width, int height);
- virtual ~XSurface();
-
- void create(uint16 width, uint16 height);
-
- void create(XSurface *s, const Common::Rect &bounds);
-
- void blitTo(XSurface &dest, const Common::Point &destPos) const;
-
- void blitTo(XSurface &dest) const;
+ BaseSurface() : Graphics::ManagedSurface() {}
+ BaseSurface(int width, int height) : Graphics::ManagedSurface(width, height) {}
+ virtual ~BaseSurface() {}
+};
- bool empty() const { return getPixels() == nullptr; }
+class XSurface : public BaseSurface {
+public:
+ XSurface() : BaseSurface() {}
+ XSurface(int width, int height) : BaseSurface(width, height) {}
+ virtual ~XSurface() {}
};
} // End of namespace Xeen