[Scummvm-git-logs] scummvm master -> 28bb304812316dcb816e747102931202d55e40d6

mduggan mgithub at guarana.org
Mon Jan 4 00:08:40 UTC 2021


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

Summary:
40021819a9 ULTIMA8: Remove unused rendering code and use common fill function
ec53ee1760 ULTIMA8: Make Shapes more const now rendering is more const
28bb304812 ULTIMA8: Graphics refactor, use more common code


Commit: 40021819a9b9167574d6867130785bb82802518c
    https://github.com/scummvm/scummvm/commit/40021819a9b9167574d6867130785bb82802518c
Author: Matthew Duggan (mgithub at guarana.org)
Date: 2021-01-04T09:01:43+09:00

Commit Message:
ULTIMA8: Remove unused rendering code and use common fill function

Changed paths:
    engines/ultima/ultima8/graphics/render_surface.h
    engines/ultima/ultima8/graphics/soft_render_surface.cpp
    engines/ultima/ultima8/graphics/soft_render_surface.h
    engines/ultima/ultima8/graphics/soft_render_surface.inl


diff --git a/engines/ultima/ultima8/graphics/render_surface.h b/engines/ultima/ultima8/graphics/render_surface.h
index 1b77be1f5e..79a21dcd64 100644
--- a/engines/ultima/ultima8/graphics/render_surface.h
+++ b/engines/ultima/ultima8/graphics/render_surface.h
@@ -154,9 +154,6 @@ public:
 	// Surface Filling
 	//
 
-	//! Fill buffer (using a palette index)
-	virtual void Fill8(uint8 index, int32 sx, int32 sy, int32 w, int32 h) = 0;
-
 	//! Fill buffer (using a RGB colour)
 	virtual void Fill32(uint32 rgb, int32 sx, int32 sy, int32 w, int32 h) = 0;
 
@@ -179,54 +176,34 @@ public:
 	//
 
 	//! Paint a Shape
-	// TODO: virtual void Paint(CachedShape* s, uint32 frame, int32 x, int32 y) = 0;
 	virtual void Paint(const Shape *s, uint32 frame, int32 x, int32 y, bool untformed_pal = false) = 0;
 
 	//! Paint a Shape without clipping
-	// TODO: virtual void PaintNoClip(CachedShape*s, uint32 frame, int32 x, int32 y) = 0;
 	virtual void PaintNoClip(const Shape *s, uint32 frame, int32 x, int32 y, bool untformed_pal = false) = 0;
 
 	//! Paint a Translucent Shape.
-	// TODO: virtual void PaintTranslucent(CachedShape* s, uint32 frame, int32 x, int32 y) = 0;
 	virtual void PaintTranslucent(const Shape *s, uint32 frame, int32 x, int32 y, bool untformed_pal = false) = 0;
 
 	//! Paint a Mirrored Shape
-	// TODO: virtual void PaintMirrored(CachedShape* s, uint32 frame, int32 x, int32 y, bool trans = false) = 0;
 	virtual void PaintMirrored(const Shape *s, uint32 frame, int32 x, int32 y, bool trans = false, bool untformed_pal = false) = 0;
 
 	//! Paint an Invisible Shape
-	// TODO: virtual void PaintInvisible(CachedShape* s, uint32 frame, int32 x, int32 y, bool trans, bool mirrored) = 0;
 	virtual void PaintInvisible(const Shape *s, uint32 frame, int32 x, int32 y, bool trans, bool mirrored, bool untformed_pal = false) = 0;
 
 	//! Paint a Highlighted Shape of using the 32 Bit Colour col32 (0xAARRGGBB Alpha is blend level)
-	// TODO: virtual void PaintHighlight(CachedShape* s, uint32 frame, int32 x, int32 y, bool trans, bool mirrored, uint32 col32);
 	virtual void PaintHighlight(const Shape *s, uint32 frame, int32 x, int32 y, bool trans, bool mirrored, uint32 col32, bool untformed_pal = false) = 0;
 
 	//! Paint a Invisible Highlighted Shape of using the 32 Bit Colour col32 (0xAARRGGBB Alpha is blend level)
-	// TODO: virtual void PaintHighlightInvis(CachedShape* s, uint32 frame, int32 x, int32 y, bool trans, bool mirrored, uint32 col32);
 	virtual void PaintHighlightInvis(const Shape *s, uint32 frame, int32 x, int32 y, bool trans, bool mirrored, uint32 col32, bool untformed_pal = false) = 0;
 
 	//
 	// Basic Line Drawing
 	//
 
-	// Draw a Line (using a palette index)
-	// TODO: virtual void DrawLine8(uint8 index, int32 sx, int32 sy, int32 ex, int32 ey) = 0;
-
 	// Draw a RGB Line
 	virtual void DrawLine32(uint32 rgb, int32 sx, int32 sy, int32 ex, int32 ey) = 0;
 
 
-	//
-	// Basic Font Drawing
-	//
-	//! Draw FixedWidthFont
-	virtual void PrintTextFixed(const FixedWidthFont *, const char *text, int x, int y) = 0;
-
-	//! Draw a fixed width character from a FixedWidthFont
-	virtual void PrintCharFixed(const FixedWidthFont *, int character, int x, int y) = 0;
-
-
 	//
 	// Basic Texture Blitting
 	//
diff --git a/engines/ultima/ultima8/graphics/soft_render_surface.cpp b/engines/ultima/ultima8/graphics/soft_render_surface.cpp
index 39de776740..888a160747 100644
--- a/engines/ultima/ultima8/graphics/soft_render_surface.cpp
+++ b/engines/ultima/ultima8/graphics/soft_render_surface.cpp
@@ -82,113 +82,18 @@ template<class uintX> SoftRenderSurface<uintX>::SoftRenderSurface(int w, int h)
 }
 
 
-//
-// SoftRenderSurface::Fill8(uint8 index, int32 sx, int32 sy, int32 w, int32 h)
-//
-// Desc: Fill buffer (using a palette index) - Remove????
-//
-template<class uintX> void SoftRenderSurface<uintX>::Fill8(uint8 /*index*/, int32 /*sx*/, int32 /*sy*/, int32 /*w*/, int32 /*h*/) {
-}
-
-
 //
 // SoftRenderSurface::Fill32(uint32 rgb, int32 sx, int32 sy, int32 w, int32 h)
 //
 // Desc: Fill buffer (using a RGB colour)
 //
-
 template<class uintX> void SoftRenderSurface<uintX>::Fill32(uint32 rgb, int32 sx, int32 sy, int32 w, int32 h) {
 	Rect rect(sx, sy, sx + w, sy + h);
 	rect.clip(_clipWindow);
-	sx = rect.left;
-	sy = rect.top;
-	w = rect.width();
-	h = rect.height();
-
-	if (!w || !h) return;
-
-	// An optimization.
-	if ((w * sizeof(uintX)) == _pitch) {
-		w *= h;
-		h = 1;
-	}
-
-	uint8 *pixel = _pixels + sy * _pitch + sx * sizeof(uintX);
-	uint8 *end = pixel + h * _pitch;
-
 	rgb = PACK_RGB8((rgb >> 16) & 0xFF , (rgb >> 8) & 0xFF , rgb & 0xFF);
-
-	uint8 *line_end = pixel + w * sizeof(uintX);
-	int diff = _pitch - w * sizeof(uintX);
-
-	while (pixel != end) {
-		while (pixel != line_end) {
-			*(reinterpret_cast<uintX *>(pixel)) = rgb;
-			pixel += sizeof(uintX);
-		}
-
-		line_end += _pitch;
-		pixel += diff;
-	}
+	_surface->fillRect(Common::Rect(rect.left + _ox, rect.top + _oy, rect.right + _ox, rect.bottom + _oy), rgb);
 }
 
-// 16 bit version
-template<> void SoftRenderSurface<uint16>::Fill32(uint32 rgb, int32 sx, int32 sy, int32 w, int32 h) {
-	Rect rect(sx, sy, sx + w, sy + h);
-	rect.clip(_clipWindow);
-	sx = rect.left;
-	sy = rect.top;
-	w = rect.width();
-	h = rect.height();
-
-	if (!w || !h) return;
-
-	// An optimization.
-	if (2 * w == _pitch) {
-		w *= h;
-		h = 1;
-	}
-
-	uint8 *pixel = _pixels + sy * _pitch + sx * sizeof(uint16);
-	uint8 *end = pixel + h * _pitch;
-
-	rgb = PACK_RGB8((rgb >> 16) & 0xFF , (rgb >> 8) & 0xFF , rgb & 0xFF);
-
-	while (pixel != end) {
-		memset_16(pixel, rgb, w);
-		pixel += _pitch;
-	}
-}
-
-// 32 bit version
-template<> void SoftRenderSurface<uint32>::Fill32(uint32 rgb, int32 sx, int32 sy, int32 w, int32 h) {
-	Rect rect(sx, sy, sx + w, sy + h);
-	rect.clip(_clipWindow);
-	sx = rect.left;
-	sy = rect.top;
-	w = rect.width();
-	h = rect.height();
-
-	if (!w || !h) return;
-
-	// An optimization.
-	if (4 * w == _pitch) {
-		w *= h;
-		h = 1;
-	}
-
-	uint8 *pixel = _pixels + sy * _pitch + sx * sizeof(uint32);
-	uint8 *end = pixel + h * _pitch;
-
-	rgb = PACK_RGB8((rgb >> 16) & 0xFF , (rgb >> 8) & 0xFF , rgb & 0xFF);
-
-	while (pixel != end) {
-		memset_32(pixel, rgb, w);
-		pixel += _pitch;
-	}
-}
-
-
 //
 // SoftRenderSurface::FillAlpha(uint8 alpha, int32 sx, int32 sy, int32 w, int32 h)
 //
@@ -738,61 +643,6 @@ template<class uintX> bool SoftRenderSurface<uintX>::ScalerBlit(const Texture *t
 	return scaler->Scale(texture, sx, sy, sw, sh, pixel, dw, dh, _pitch, clampedges);
 }
 
-//
-// SoftRenderSurface::PrintCharFixed(FixedWidthFont *, char character, int x, int y)
-//
-// Desc: Draw a fixed width character from a Texture buffer
-//
-template<class uintX> void SoftRenderSurface<uintX>::PrintCharFixed(const FixedWidthFont *font, int character, int x, int y) {
-	if (character == ' ') return;   // Don't paint spaces
-
-	int align_x = font->_alignX;
-	int align_y = font->_alignY;
-	int char_width = font->_width;
-	int char_height = font->_height;
-	Texture *texture = font->_tex;
-
-	if (align_x == 16 && align_y == 16) {
-		SoftRenderSurface::Blit(texture, (character & 0x0F) << 4, character & 0xF0, char_width, char_height, x, y);
-	} else if (align_x == 8 && align_y == 8) {
-		SoftRenderSurface::Blit(texture, (character & 0x0F) << 3, (character >> 1) & 0x78, char_width, char_height, x, y);
-	} else {
-		SoftRenderSurface::Blit(texture, (character & 0x0F) * align_x, (character & 0xF0 >> 4) * align_y, char_width, char_height, x, y);
-	}
-}
-
-
-//
-// SoftRenderSurface::PrintTextFixed(FixedWidthFont *, const char *text, int x, int y)
-//
-// Desc: Draw fixed width from a Texture buffer (16x16 characters fixed width and height)
-//
-template<class uintX> void SoftRenderSurface<uintX>::PrintTextFixed(const FixedWidthFont *font, const char *text, int x, int y) {
-	int align_x = font->_alignX;
-	int align_y = font->_alignY;
-	int char_width = font->_width;
-	int char_height = font->_height;
-	Texture *texture = font->_tex;
-
-	int character;
-	if (align_x == 16 && align_y == 16) while (0 != (character = *text)) {
-			SoftRenderSurface::Blit(texture, (character & 0x0F) << 4, character & 0xF0, char_width, char_height, x, y);
-			++text;
-			x += char_width;
-		}
-	else if (align_x == 8 && align_y == 8) while (0 != (character = *text)) {
-			SoftRenderSurface::Blit(texture, (character & 0x0F) << 3, (character >> 1) & 0x78, char_width, char_height, x, y);
-			++text;
-			x += char_width;
-		}
-	else while (0 != (character = *text)) {
-			SoftRenderSurface::Blit(texture, (character & 0x0F) * align_x, (character & 0xF0 >> 4) * align_y, char_width, char_height, x, y);
-			++text;
-			x += char_width;
-		}
-}
-
-
 //
 // void SoftRenderSurface::Paint(Shape*s, uint32 framenum, int32 x, int32 y)
 //
diff --git a/engines/ultima/ultima8/graphics/soft_render_surface.h b/engines/ultima/ultima8/graphics/soft_render_surface.h
index 15e05a4f39..38a583e72e 100644
--- a/engines/ultima/ultima8/graphics/soft_render_surface.h
+++ b/engines/ultima/ultima8/graphics/soft_render_surface.h
@@ -54,9 +54,6 @@ public:
 	// Surface Filling
 	//
 
-	// Fill buffer (using a palette index)
-	void Fill8(uint8 index, int32 sx, int32 sy, int32 w, int32 h) override;
-
 	// Fill buffer (using a RGB colour)
 	void Fill32(uint32 rgb, int32 sx, int32 sy, int32 w, int32 h) override;
 
@@ -79,54 +76,34 @@ public:
 	//
 
 	// Paint a Shape
-	// TODO: virtual void Paint(CachedShape* s, uint32 frame, int32 x, int32 y);
 	void Paint(const Shape *s, uint32 frame, int32 x, int32 y, bool untformed_pal = false) override;
 
 	// Paint an Shape without clipping
-	// TODO: virtual void PaintNoClip(CachedShape*s, uint32 frame, int32 x, int32 y);
 	void PaintNoClip(const Shape *s, uint32 frame, int32 x, int32 y, bool untformed_pal = false) override;
 
 	// Paint a Translucent Shape.
-	// TODO: virtual void PaintTranslucent(CachedShape* s, uint32 frame, int32 x, int32 y);
 	void PaintTranslucent(const Shape *s, uint32 frame, int32 x, int32 y, bool untformed_pal = false) override;
 
 	// Paint a Mirrored Shape
-	// TODO: virtual void PaintMirrored(CachedShape* s, uint32 frame, int32 x, int32 y, bool trans = false);
 	void PaintMirrored(const Shape *s, uint32 frame, int32 x, int32 y, bool trans = false, bool untformed_pal = false) override;
 
 	// Paint a Invisible Shape
-	// TODO: virtual void PaintInvisible(CachedShape* s, uint32 frame, int32 x, int32 y, bool trans, bool mirrored);
 	void PaintInvisible(const Shape *s, uint32 frame, int32 x, int32 y, bool trans, bool mirrored, bool untformed_pal = false) override;
 
 	// Paint a Highlighted Shape of using the 32 Bit Colour col32 (0xAARRGGBB Alpha is blend level)
-	// TODO: virtual void PaintHighlight(CachedShape* s, uint32 frame, int32 x, int32 y, bool trans, bool mirrored, uint32 col32);
 	void PaintHighlight(const Shape *s, uint32 frame, int32 x, int32 y, bool trans, bool mirrored, uint32 col32, bool untformed_pal = false) override;
 
 	// Paint a Invisible Highlighted Shape of using the 32 Bit Colour col32 (0xAARRGGBB Alpha is blend level)
-	// TODO: virtual void PaintHighlightInvis(CachedShape* s, uint32 frame, int32 x, int32 y, bool trans, bool mirrored, uint32 col32);
 	void PaintHighlightInvis(const Shape *s, uint32 frame, int32 x, int32 y, bool trans, bool mirrored, uint32 col32, bool untformed_pal = false) override;
 
 	//
 	// Basic Line Drawing
 	//
 
-	// Draw a Line (using a palette index)
-	// TODO: virtual void DrawLine8(uint8 index, int32 sx, int32 sy, int32 ex, int32 ey);
-
 	// Draw a RGB Line
 	void DrawLine32(uint32 rgb, int32 sx, int32 sy, int32 ex, int32 ey) override;
 
 
-	//
-	// Basic Font Drawing
-	//
-	// Draw FixedWidthFont
-	void PrintTextFixed(const FixedWidthFont *, const char *text, int x, int y) override;
-
-	// Draw a fixed width character from a FixedWidthFont
-	void PrintCharFixed(const FixedWidthFont *, int character, int x, int y) override;
-
-
 	//
 	// Basic Texture Blitting
 	//
diff --git a/engines/ultima/ultima8/graphics/soft_render_surface.inl b/engines/ultima/ultima8/graphics/soft_render_surface.inl
index 703f441e0a..93cc0725d6 100644
--- a/engines/ultima/ultima8/graphics/soft_render_surface.inl
+++ b/engines/ultima/ultima8/graphics/soft_render_surface.inl
@@ -176,14 +176,14 @@ const int32 neg = (FLIP_CONDITIONAL)?-1:0;
 		return;
 	const uint8		*srcpixels		= frame->_pixels;
 	const uint8		*srcmask		= frame->_mask;
-	const uint32	*pal			= untformed_pal?
-										&(s->getPalette()->_native_untransformed[0]):
-										&(s->getPalette()->_native[0]);
+	const uint32	*pal			= untformed_pal ?
+										s->getPalette()->_native_untransformed:
+										s->getPalette()->_native;
 
 #ifdef XFORM_SHAPES
-	const uint32	*xform_pal		= untformed_pal?
-										&(s->getPalette()->_xform_untransformed[0]):
-										&(s->getPalette()->_xform[0]);
+	const uint32	*xform_pal		= untformed_pal ?
+										s->getPalette()->_xform_untransformed:
+										s->getPalette()->_xform;
 #endif
 
 	const int32 width_ = frame->_width;


Commit: ec53ee176087ab2ee575b3c4e7327774d8598ec7
    https://github.com/scummvm/scummvm/commit/ec53ee176087ab2ee575b3c4e7327774d8598ec7
Author: Matthew Duggan (mgithub at guarana.org)
Date: 2021-01-04T09:01:43+09:00

Commit Message:
ULTIMA8: Make Shapes more const now rendering is more const

Changed paths:
    engines/ultima/ultima8/gumps/container_gump.cpp
    engines/ultima/ultima8/gumps/container_gump.h
    engines/ultima/ultima8/gumps/gump.h
    engines/ultima/ultima8/gumps/paperdoll_gump.cpp
    engines/ultima/ultima8/gumps/paperdoll_gump.h
    engines/ultima/ultima8/gumps/quit_gump.cpp
    engines/ultima/ultima8/gumps/readable_gump.cpp
    engines/ultima/ultima8/gumps/scroll_gump.cpp
    engines/ultima/ultima8/gumps/shape_viewer_gump.cpp
    engines/ultima/ultima8/gumps/slider_gump.cpp
    engines/ultima/ultima8/gumps/weasel_gump.cpp
    engines/ultima/ultima8/gumps/widgets/sliding_widget.cpp
    engines/ultima/ultima8/gumps/widgets/sliding_widget.h
    engines/ultima/ultima8/world/item.cpp
    engines/ultima/ultima8/world/item.h
    engines/ultima/ultima8/world/item_sorter.cpp


diff --git a/engines/ultima/ultima8/gumps/container_gump.cpp b/engines/ultima/ultima8/gumps/container_gump.cpp
index aa79cbef9e..6e70dc0b30 100644
--- a/engines/ultima/ultima8/gumps/container_gump.cpp
+++ b/engines/ultima/ultima8/gumps/container_gump.cpp
@@ -52,7 +52,7 @@ ContainerGump::ContainerGump()
 
 }
 
-ContainerGump::ContainerGump(Shape *shape, uint32 frameNum, uint16 owner,
+ContainerGump::ContainerGump(const Shape *shape, uint32 frameNum, uint16 owner,
                              uint32 flags, int32 layer)
 	: ItemRelativeGump(0, 0, 5, 5, owner, flags, layer),
 	  _displayDragging(false), _draggingShape(0), _draggingFrame(0),
@@ -132,7 +132,7 @@ void ContainerGump::PaintThis(RenderSurface *surf, int32 lerp_factor, bool scale
 
 		int32 itemx, itemy;
 		getItemCoords(item, itemx, itemy);
-		Shape *s = item->getShapeObject();
+		const Shape *s = item->getShapeObject();
 		assert(s);
 		surf->Paint(s, item->getFrame(), itemx, itemy);
 	}
diff --git a/engines/ultima/ultima8/gumps/container_gump.h b/engines/ultima/ultima8/gumps/container_gump.h
index d26f0a4328..a17a54c13e 100644
--- a/engines/ultima/ultima8/gumps/container_gump.h
+++ b/engines/ultima/ultima8/gumps/container_gump.h
@@ -40,7 +40,7 @@ public:
 	ENABLE_RUNTIME_CLASSTYPE()
 
 	ContainerGump();
-	ContainerGump(Shape *shape, uint32 frameNum, uint16 owner,
+	ContainerGump(const Shape *shape, uint32 frameNum, uint16 owner,
 	              uint32 flags = FLAG_DRAGGABLE, int32 layer = LAYER_NORMAL);
 	~ContainerGump() override;
 
diff --git a/engines/ultima/ultima8/gumps/gump.h b/engines/ultima/ultima8/gumps/gump.h
index 4e48e5ea02..e54265c86a 100644
--- a/engines/ultima/ultima8/gumps/gump.h
+++ b/engines/ultima/ultima8/gumps/gump.h
@@ -58,7 +58,7 @@ protected:
 
 	int32 _index;         // 'Index'
 
-	Shape *_shape;        // The gumps shape (always painted at 0,0)
+	const Shape *_shape;  // The gumps shape (always painted at 0,0)
 	uint32 _frameNum;
 
 	//! The Gump list for this gump. This will contain all child gumps,
@@ -89,7 +89,7 @@ public:
 	}
 
 	//! Set the Gump's shape/frame
-	inline void SetShape(Shape *shape, uint32 frameNum) {
+	inline void SetShape(const Shape *shape, uint32 frameNum) {
 		_shape = shape;
 		_frameNum = frameNum;
 	}
diff --git a/engines/ultima/ultima8/gumps/paperdoll_gump.cpp b/engines/ultima/ultima8/gumps/paperdoll_gump.cpp
index 3bd3bb53a4..9f51f3ebfb 100644
--- a/engines/ultima/ultima8/gumps/paperdoll_gump.cpp
+++ b/engines/ultima/ultima8/gumps/paperdoll_gump.cpp
@@ -87,7 +87,7 @@ PaperdollGump::PaperdollGump() : ContainerGump(), _statButtonId(0),
 	Common::fill(_cachedVal, _cachedVal + 7, 0);
 }
 
-PaperdollGump::PaperdollGump(Shape *shape, uint32 frameNum, uint16 owner,
+PaperdollGump::PaperdollGump(const Shape *shape, uint32 frameNum, uint16 owner,
 		uint32 Flags, int32 layer)
 		: ContainerGump(shape, frameNum, owner, Flags, layer),
 		_statButtonId(0), _backpackRect(49, 25, 59, 50) {
@@ -203,7 +203,7 @@ void PaperdollGump::PaintThis(RenderSurface *surf, int32 lerp_factor, bool scale
 		itemy = equipcoords[i].y;
 		itemx += _itemArea.left;
 		itemy += _itemArea.top;
-		Shape *s = item->getShapeObject();
+		const Shape *s = item->getShapeObject();
 		assert(s);
 		surf->Paint(s, frame, itemx, itemy);
 	}
diff --git a/engines/ultima/ultima8/gumps/paperdoll_gump.h b/engines/ultima/ultima8/gumps/paperdoll_gump.h
index 58bc042fc5..1af10f90e5 100644
--- a/engines/ultima/ultima8/gumps/paperdoll_gump.h
+++ b/engines/ultima/ultima8/gumps/paperdoll_gump.h
@@ -39,7 +39,7 @@ public:
 	ENABLE_RUNTIME_CLASSTYPE()
 
 	PaperdollGump();
-	PaperdollGump(Shape *shape, uint32 frameNum, uint16 owner,
+	PaperdollGump(const Shape *shape, uint32 frameNum, uint16 owner,
 	              uint32 flags = FLAG_DRAGGABLE, int32 layer = LAYER_NORMAL);
 	~PaperdollGump() override;
 
diff --git a/engines/ultima/ultima8/gumps/quit_gump.cpp b/engines/ultima/ultima8/gumps/quit_gump.cpp
index 6316243fea..f9a24b550d 100644
--- a/engines/ultima/ultima8/gumps/quit_gump.cpp
+++ b/engines/ultima/ultima8/gumps/quit_gump.cpp
@@ -110,7 +110,7 @@ void QuitGump::InitGump(Gump *newparent, bool take_focus) {
 			widget->InitGump(this, false);
 			widget->setRelativePosition(TOP_CENTER, 0, 13);
 		} else {
-			Shape *askShape = GameData::get_instance()->getShape(askshape);
+			const Shape *askShape = GameData::get_instance()->getShape(askshape);
 			const ShapeFrame *sf = askShape->getFrame(askshape._frameNum);
 			assert(sf);
 
diff --git a/engines/ultima/ultima8/gumps/readable_gump.cpp b/engines/ultima/ultima8/gumps/readable_gump.cpp
index 351cae6e12..425d179abf 100644
--- a/engines/ultima/ultima8/gumps/readable_gump.cpp
+++ b/engines/ultima/ultima8/gumps/readable_gump.cpp
@@ -57,7 +57,7 @@ ReadableGump::~ReadableGump(void) {
 void ReadableGump::InitGump(Gump *newparent, bool take_focus) {
 	ModalGump::InitGump(newparent, take_focus);
 
-	Shape *shape = GameData::get_instance()->getGumps()->getShape(_shapeNum);
+	const Shape *shape = GameData::get_instance()->getGumps()->getShape(_shapeNum);
 
 	SetShape(shape, 0);
 
diff --git a/engines/ultima/ultima8/gumps/scroll_gump.cpp b/engines/ultima/ultima8/gumps/scroll_gump.cpp
index f25f7d3b19..de75adff4c 100644
--- a/engines/ultima/ultima8/gumps/scroll_gump.cpp
+++ b/engines/ultima/ultima8/gumps/scroll_gump.cpp
@@ -61,7 +61,7 @@ void ScrollGump::InitGump(Gump *newparent, bool take_focus) {
 
 	_text.clear(); // no longer need this
 
-	Shape *shape = GameData::get_instance()->getGumps()->getShape(19);
+	const Shape *shape = GameData::get_instance()->getGumps()->getShape(19);
 
 	SetShape(shape, 0);
 	UpdateDimsFromShape();
diff --git a/engines/ultima/ultima8/gumps/shape_viewer_gump.cpp b/engines/ultima/ultima8/gumps/shape_viewer_gump.cpp
index de651840e4..a7bd5f2df9 100644
--- a/engines/ultima/ultima8/gumps/shape_viewer_gump.cpp
+++ b/engines/ultima/ultima8/gumps/shape_viewer_gump.cpp
@@ -95,7 +95,7 @@ void ShapeViewerGump::PaintThis(RenderSurface *surf, int32 lerp_factor, bool /*s
 	int32 posx = (_dims.width() - _shapeW) / 2 + _shapeX;
 	int32 posy = (_dims.height() - _shapeH) / 2 + _shapeY - 25;
 
-	Shape *shape = _flex->getShape(_curShape);
+	const Shape *shape = _flex->getShape(_curShape);
 	if (shape && _curFrame < shape->frameCount())
 		surf->Paint(shape, _curFrame, posx, posy);
 	
diff --git a/engines/ultima/ultima8/gumps/slider_gump.cpp b/engines/ultima/ultima8/gumps/slider_gump.cpp
index c249dc0da1..edc0c4ecd2 100644
--- a/engines/ultima/ultima8/gumps/slider_gump.cpp
+++ b/engines/ultima/ultima8/gumps/slider_gump.cpp
@@ -126,7 +126,7 @@ void SliderGump::InitGump(Gump *newparent, bool take_focus) {
 	_shape = GameData::get_instance()->getGumps()->getShape(gumpshape);
 	UpdateDimsFromShape();
 
-	Shape *childshape = GameData::get_instance()->
+	const Shape *childshape = GameData::get_instance()->
 	                    getGumps()->getShape(slidershape);
 
 	// Create the SlidingWidget
diff --git a/engines/ultima/ultima8/gumps/weasel_gump.cpp b/engines/ultima/ultima8/gumps/weasel_gump.cpp
index 4ebacd525b..39d684ebbb 100644
--- a/engines/ultima/ultima8/gumps/weasel_gump.cpp
+++ b/engines/ultima/ultima8/gumps/weasel_gump.cpp
@@ -130,10 +130,10 @@ void WeaselGump::InitGump(Gump *newparent, bool take_focus) {
 
 	GumpShapeArchive *shapeArchive = GameData::get_instance()->getGumps();
 
-	Shape *top = shapeArchive->getShape(WEASEL_SHAPE_TOP);
-	Shape *midhi = shapeArchive->getShape(WEASEL_SHAPE_TOP + 1);
-	Shape *midlo = shapeArchive->getShape(WEASEL_SHAPE_TOP + 2);
-	Shape *bot = shapeArchive->getShape(WEASEL_SHAPE_TOP + 3);
+	const Shape *top = shapeArchive->getShape(WEASEL_SHAPE_TOP);
+	const Shape *midhi = shapeArchive->getShape(WEASEL_SHAPE_TOP + 1);
+	const Shape *midlo = shapeArchive->getShape(WEASEL_SHAPE_TOP + 2);
+	const Shape *bot = shapeArchive->getShape(WEASEL_SHAPE_TOP + 3);
 
 	if (!top || !midhi || !midlo || !bot) {
 		error("Couldn't load shapes for weasel");
@@ -170,7 +170,7 @@ void WeaselGump::InitGump(Gump *newparent, bool take_focus) {
 
 	for (int i = 0; i < ARRAYSIZE(WEASEL_BTN_X); i++) {
 		uint32 buttonShapeNum = WEASEL_BTN_SHAPES[i];
-		Shape *buttonShape = shapeArchive->getShape(buttonShapeNum);
+		const Shape *buttonShape = shapeArchive->getShape(buttonShapeNum);
 		if (!buttonShape) {
 			error("Couldn't load shape for weasel button %d", i);
 			return;
@@ -507,7 +507,7 @@ void WeaselGump::updateItemDisplay() {
 	if (!shapeinfo || !shapeinfo->_weaponInfo) {
 		warning("Weasel: no info for shape %d", _curItemShape);
 	}
-	Shape *shape = GameData::get_instance()->getGumps()->getShape(shapeinfo->_weaponInfo->_displayGumpShape);
+	const Shape *shape = GameData::get_instance()->getGumps()->getShape(shapeinfo->_weaponInfo->_displayGumpShape);
 
 	_closeIfExists(_ui->FindGump(&FindByIndex<kTxtCredits>));
 	_closeIfExists(_ui->FindGump(&FindByIndex<kTxtItemName>));
diff --git a/engines/ultima/ultima8/gumps/widgets/sliding_widget.cpp b/engines/ultima/ultima8/gumps/widgets/sliding_widget.cpp
index 5eff23c5cd..d47bd465c8 100644
--- a/engines/ultima/ultima8/gumps/widgets/sliding_widget.cpp
+++ b/engines/ultima/ultima8/gumps/widgets/sliding_widget.cpp
@@ -34,7 +34,7 @@ SlidingWidget::SlidingWidget()
 	: Gump() {
 }
 
-SlidingWidget::SlidingWidget(int x, int y, Shape *shape, uint32 frameNum)
+SlidingWidget::SlidingWidget(int x, int y, const Shape *shape, uint32 frameNum)
 	: Gump(x, y, 5, 5, 0, FLAG_DRAGGABLE) {
 	_shape = shape;
 	_frameNum = frameNum;
diff --git a/engines/ultima/ultima8/gumps/widgets/sliding_widget.h b/engines/ultima/ultima8/gumps/widgets/sliding_widget.h
index 6cec9384b0..09c32579f1 100644
--- a/engines/ultima/ultima8/gumps/widgets/sliding_widget.h
+++ b/engines/ultima/ultima8/gumps/widgets/sliding_widget.h
@@ -34,7 +34,7 @@ public:
 	ENABLE_RUNTIME_CLASSTYPE()
 
 	SlidingWidget();
-	SlidingWidget(int x, int y, Shape *shape, uint32 frameNum);
+	SlidingWidget(int x, int y, const Shape *shape, uint32 frameNum);
 	~SlidingWidget() override;
 
 	void InitGump(Gump *newparent, bool take_focus = true) override;
diff --git a/engines/ultima/ultima8/world/item.cpp b/engines/ultima/ultima8/world/item.cpp
index 2b49f3baf1..5241c909eb 100644
--- a/engines/ultima/ultima8/world/item.cpp
+++ b/engines/ultima/ultima8/world/item.cpp
@@ -719,7 +719,7 @@ const ShapeInfo *Item::getShapeInfoFromGameInstance() const {
 	return GameData::get_instance()->getMainShapes()->getShapeInfo(_shape);
 }
 
-Shape *Item::getShapeObject() const {
+const Shape *Item::getShapeObject() const {
 	if (!_cachedShape) _cachedShape = GameData::get_instance()->getMainShapes()->getShape(_shape);
 	return _cachedShape;
 }
@@ -1845,7 +1845,7 @@ void Item::leaveFastArea() {
 uint16 Item::openGump(uint32 gumpshape) {
 	if (_flags & FLG_GUMP_OPEN) return 0;
 	assert(_gump == 0);
-	Shape *shapeP = GameData::get_instance()->getGumps()->getShape(gumpshape);
+	const Shape *shapeP = GameData::get_instance()->getGumps()->getShape(gumpshape);
 
 	ContainerGump *cgump;
 
diff --git a/engines/ultima/ultima8/world/item.h b/engines/ultima/ultima8/world/item.h
index 2b7c74a4b8..7119a1af1d 100644
--- a/engines/ultima/ultima8/world/item.h
+++ b/engines/ultima/ultima8/world/item.h
@@ -247,7 +247,7 @@ public:
 	const ShapeInfo *getShapeInfoFromGameInstance() const;
 
 	//! Get the Shape object for this Item. (The pointer will be cached.)
-	Shape *getShapeObject() const;
+	const Shape *getShapeObject() const;
 
 	//! Get the family of the shape number of this Item. (This is a
 	//! member of the ShapeInfo object.)
@@ -614,7 +614,7 @@ protected:
 
 	ObjId _parent; // objid container this item is in (or 0 for top-level items)
 
-	mutable Shape *_cachedShape;
+	mutable const Shape *_cachedShape;
 	mutable const ShapeInfo *_cachedShapeInfo;
 
 	// This is stuff that is used for displaying and interpolation
diff --git a/engines/ultima/ultima8/world/item_sorter.cpp b/engines/ultima/ultima8/world/item_sorter.cpp
index beaa2d84a9..9fb79fc969 100644
--- a/engines/ultima/ultima8/world/item_sorter.cpp
+++ b/engines/ultima/ultima8/world/item_sorter.cpp
@@ -57,7 +57,7 @@ struct SortItem {
 
 	uint16                  _itemNum;   // Owner item number
 
-	Shape                   *_shape;
+	const Shape             *_shape;
 	uint32                  _shapeNum;
 	uint32                  _frame;
 	uint32                  _flags;     // Item flags
@@ -871,7 +871,7 @@ bool ItemSorter::PaintSortItem(SortItem *si) {
 		uint32 wo_shapenum;
 		av->getWeaponOverlay(wo_frame, wo_shapenum);
 		if (wo_frame) {
-			Shape *wo_shape = GameData::get_instance()->getMainShapes()->getShape(wo_shapenum);
+			const Shape *wo_shape = GameData::get_instance()->getMainShapes()->getShape(wo_shapenum);
 			_surf->Paint(wo_shape, wo_frame->_frame,
 			            si->_sxBot + wo_frame->_xOff,
 			            si->_syBot + wo_frame->_yOff);


Commit: 28bb304812316dcb816e747102931202d55e40d6
    https://github.com/scummvm/scummvm/commit/28bb304812316dcb816e747102931202d55e40d6
Author: Matthew Duggan (mgithub at guarana.org)
Date: 2021-01-04T09:08:20+09:00

Commit Message:
ULTIMA8: Graphics refactor, use more common code

Try to use more of the built-in ScummVM rendering pipeline and remove redundant
types where possible.  Unfortunately this is a bit of a mega-commit because all
the pieces were tied together, but the main changes are:

* Remove the Texture types, as they add little over ManagedSurface
* Remove the ScalerGump as we no longer use it - we should be using the
  built-in ScummVM scalers
* Remove the Scaler types - the only remaining user after removing ScalerGump
  was in hte AVI player.  There we manually add the Crusader style interlaced
  scaling, which was an outstanding TODO anyway.
* Remove now-unused functions from the RenderSurface family
* Remove the "default" mouse cursor as we never use it in ScummVM
* Remove the memset_n header which duplicates Common::Fill functions (fixes
  #11969)
* Remove the fixed-width bitmap fonts which were used for the Pentagram
  console.

I've tested the following things that this had the potential to break:

* U8 game, credits, movies, minimap, and ttf rendering
* Crusader game and movies
* Debug tools (shape viewer, touch-highlight)

Changed paths:
  R devtools/create_ultima/files/ultima8/fixedfont.ini
  R devtools/create_ultima/files/ultima8/fixedfont.tga
  R devtools/create_ultima/files/ultima8/fixedfont12.ini
  R devtools/create_ultima/files/ultima8/fixedfont12.tga
  R engines/ultima/ultima8/graphics/fonts/fixed_width_font.cpp
  R engines/ultima/ultima8/graphics/fonts/fixed_width_font.h
  R engines/ultima/ultima8/graphics/point_scaler.cpp
  R engines/ultima/ultima8/graphics/point_scaler.h
  R engines/ultima/ultima8/graphics/scaler.h
  R engines/ultima/ultima8/graphics/texture.cpp
  R engines/ultima/ultima8/graphics/texture_bitmap.cpp
  R engines/ultima/ultima8/graphics/texture_bitmap.h
  R engines/ultima/ultima8/graphics/texture_png.cpp
  R engines/ultima/ultima8/graphics/texture_png.h
  R engines/ultima/ultima8/graphics/texture_targa.cpp
  R engines/ultima/ultima8/graphics/texture_targa.h
  R engines/ultima/ultima8/gumps/scaler_gump.cpp
  R engines/ultima/ultima8/gumps/scaler_gump.h
  R engines/ultima/ultima8/misc/memset_n.h
  R test/engines/ultima/ultima8/misc/memset_n.h
    engines/ultima/module.mk
    engines/ultima/ultima8/games/game_data.h
    engines/ultima/ultima8/graphics/avi_player.cpp
    engines/ultima/ultima8/graphics/avi_player.h
    engines/ultima/ultima8/graphics/base_soft_render_surface.cpp
    engines/ultima/ultima8/graphics/base_soft_render_surface.h
    engines/ultima/ultima8/graphics/fonts/shape_rendered_text.cpp
    engines/ultima/ultima8/graphics/fonts/tt_font.cpp
    engines/ultima/ultima8/graphics/fonts/tt_font.h
    engines/ultima/ultima8/graphics/fonts/ttf_rendered_text.cpp
    engines/ultima/ultima8/graphics/fonts/ttf_rendered_text.h
    engines/ultima/ultima8/graphics/render_surface.cpp
    engines/ultima/ultima8/graphics/render_surface.h
    engines/ultima/ultima8/graphics/skf_player.cpp
    engines/ultima/ultima8/graphics/skf_player.h
    engines/ultima/ultima8/graphics/soft_render_surface.cpp
    engines/ultima/ultima8/graphics/soft_render_surface.h
    engines/ultima/ultima8/graphics/soft_render_surface.inl
    engines/ultima/ultima8/graphics/texture.h
    engines/ultima/ultima8/gumps/credits_gump.cpp
    engines/ultima/ultima8/gumps/gump.cpp
    engines/ultima/ultima8/gumps/inverter_gump.cpp
    engines/ultima/ultima8/gumps/item_relative_gump.cpp
    engines/ultima/ultima8/gumps/minimap_gump.cpp
    engines/ultima/ultima8/gumps/minimap_gump.h
    engines/ultima/ultima8/kernel/mouse.cpp
    engines/ultima/ultima8/kernel/mouse.h
    engines/ultima/ultima8/misc/debugger.cpp
    engines/ultima/ultima8/ultima8.cpp
    engines/ultima/ultima8/ultima8.h


diff --git a/devtools/create_ultima/files/ultima8/fixedfont.ini b/devtools/create_ultima/files/ultima8/fixedfont.ini
deleted file mode 100644
index 5c6f1f3ac8..0000000000
--- a/devtools/create_ultima/files/ultima8/fixedfont.ini
+++ /dev/null
@@ -1,4 +0,0 @@
-[font]
-path=@data/fixedfont.tga
-height=8
-width=8
diff --git a/devtools/create_ultima/files/ultima8/fixedfont.tga b/devtools/create_ultima/files/ultima8/fixedfont.tga
deleted file mode 100644
index 7030512d2e..0000000000
Binary files a/devtools/create_ultima/files/ultima8/fixedfont.tga and /dev/null differ
diff --git a/devtools/create_ultima/files/ultima8/fixedfont12.ini b/devtools/create_ultima/files/ultima8/fixedfont12.ini
deleted file mode 100644
index 4b6de1e4cb..0000000000
--- a/devtools/create_ultima/files/ultima8/fixedfont12.ini
+++ /dev/null
@@ -1,6 +0,0 @@
-[font]
-path=@data/fixedfont12.tga
-height=12
-width=11
-align_x=16
-align_y=16
diff --git a/devtools/create_ultima/files/ultima8/fixedfont12.tga b/devtools/create_ultima/files/ultima8/fixedfont12.tga
deleted file mode 100644
index 56a5f69a84..0000000000
Binary files a/devtools/create_ultima/files/ultima8/fixedfont12.tga and /dev/null differ
diff --git a/engines/ultima/module.mk b/engines/ultima/module.mk
index d50dcd90e4..60937cb437 100644
--- a/engines/ultima/module.mk
+++ b/engines/ultima/module.mk
@@ -427,7 +427,6 @@ MODULE_OBJS := \
 	ultima8/graphics/palette.o \
 	ultima8/graphics/palette_fader_process.o \
 	ultima8/graphics/palette_manager.o \
-	ultima8/graphics/point_scaler.o \
 	ultima8/graphics/raw_shape_frame.o \
 	ultima8/graphics/render_surface.o \
 	ultima8/graphics/shape.o \
@@ -436,14 +435,9 @@ MODULE_OBJS := \
 	ultima8/graphics/shape_info.o \
 	ultima8/graphics/skf_player.o \
 	ultima8/graphics/soft_render_surface.o \
-	ultima8/graphics/texture.o \
-	ultima8/graphics/texture_bitmap.o \
-	ultima8/graphics/texture_png.o \
 	ultima8/graphics/type_flags.o \
 	ultima8/graphics/wpn_ovlay_dat.o \
 	ultima8/graphics/xform_blend.o \
-	ultima8/graphics/texture_targa.o \
-	ultima8/graphics/fonts/fixed_width_font.o \
 	ultima8/graphics/fonts/font.o \
 	ultima8/graphics/fonts/font_manager.o \
 	ultima8/graphics/fonts/font_shape_archive.o \
@@ -490,7 +484,6 @@ MODULE_OBJS := \
 	ultima8/gumps/readable_gump.o \
 	ultima8/gumps/remorse_menu_gump.o \
 	ultima8/gumps/resizable_gump.o \
-	ultima8/gumps/scaler_gump.o \
 	ultima8/gumps/scroll_gump.o \
 	ultima8/gumps/shape_viewer_gump.o \
 	ultima8/gumps/slider_gump.o \
diff --git a/engines/ultima/ultima8/games/game_data.h b/engines/ultima/ultima8/games/game_data.h
index f53866bdc5..2d16051a46 100644
--- a/engines/ultima/ultima8/games/game_data.h
+++ b/engines/ultima/ultima8/games/game_data.h
@@ -77,7 +77,7 @@ public:
 	GumpShapeArchive *getGumps() const {
 		return _gumps;
 	}
-	Shape *getMouse() const {
+	const Shape *getMouse() const {
 		return _mouse;
 	}
 	MusicFlex *getMusic() const {
diff --git a/engines/ultima/ultima8/graphics/avi_player.cpp b/engines/ultima/ultima8/graphics/avi_player.cpp
index 80596ec8e8..21ae45ba22 100644
--- a/engines/ultima/ultima8/graphics/avi_player.cpp
+++ b/engines/ultima/ultima8/graphics/avi_player.cpp
@@ -48,6 +48,8 @@ AVIPlayer::AVIPlayer(Common::SeekableReadStream *rs, int width, int height, cons
 	}
 	_xoff = _width / 2 - (vidWidth / 2);
 	_yoff = _height / 2 - (vidHeight / 2);
+	_currentFrame.create(vidWidth, vidHeight, _decoder->getPixelFormat());
+	_currentFrame.fillRect(Common::Rect(0, 0, vidWidth, vidHeight), 0);
 }
 
 AVIPlayer::~AVIPlayer() {
@@ -96,24 +98,26 @@ void AVIPlayer::paint(RenderSurface *surf, int /*lerp*/) {
 			else
 				pal = _decoder->getPalette();
 
-			_currentFrame.loadSurface8Bit(frame, pal);
+			_currentFrame.setPalette(pal, 0, 256);
+		}
+		if (_doubleSize) {
+			assert(_currentFrame.w == frame->w * 2 && _currentFrame.h == frame->h * 2);
+			for (int y = 0; y < frame->h; y++) {
+				const uint8 *srcPixel = static_cast<const uint8 *>(frame->getPixels()) + frame->pitch * y;
+				uint8 *dstPixels = static_cast<uint8 *>(_currentFrame.getPixels()) + _currentFrame.pitch * y * 2;
+				for (int x = 0; x < frame->w; x++) {
+					dstPixels[x * 2] = *srcPixel;
+					dstPixels[x * 2 + 1] = *srcPixel;
+					srcPixel++;
+				}
+			}
 		} else {
-			_currentFrame.loadSurface(frame);
+			_currentFrame.blitFrom(*frame);
 		}
 	}
 
-	// TODO: Crusader has a CRT-like scaling which it uses in some
-	// movies too (eg, T02 for the intro).  For now just point-scale.
-	if (_doubleSize) {
-		const Scaler *pointScaler = &Ultima8Engine::get_instance()->point_scaler;
-		bool ok = surf->ScalerBlit(&_currentFrame, 0, 0, _currentFrame.w, _currentFrame.h,
-								   _xoff, _yoff, _currentFrame.w * 2, _currentFrame.h * 2,
-								   pointScaler, false);
-		assert(ok);
-	} else {
-		surf->Blit(&_currentFrame, 0, 0, _currentFrame.w, _currentFrame.h,
-				   _xoff, _yoff);
-	}
+	surf->Blit(&_currentFrame, 0, 0, _currentFrame.w, _currentFrame.h,
+			_xoff, _yoff);
 }
 
 void AVIPlayer::run() {
diff --git a/engines/ultima/ultima8/graphics/avi_player.h b/engines/ultima/ultima8/graphics/avi_player.h
index 6a090b90ae..eea972def6 100644
--- a/engines/ultima/ultima8/graphics/avi_player.h
+++ b/engines/ultima/ultima8/graphics/avi_player.h
@@ -52,7 +52,7 @@ private:
 
 	bool _playing;
 	Video::AVIDecoder *_decoder;
-	Texture _currentFrame;
+	Graphics::ManagedSurface _currentFrame;
 	// Width and height of the area we've been given to play back in
 	uint32 _width;
 	uint32 _height;
diff --git a/engines/ultima/ultima8/graphics/base_soft_render_surface.cpp b/engines/ultima/ultima8/graphics/base_soft_render_surface.cpp
index 9c8ad628da..e0fec96de0 100644
--- a/engines/ultima/ultima8/graphics/base_soft_render_surface.cpp
+++ b/engines/ultima/ultima8/graphics/base_soft_render_surface.cpp
@@ -41,34 +41,36 @@ namespace Ultima8 {
 // Desc: Constructor for BaseSoftRenderSurface from a managed surface
 //
 BaseSoftRenderSurface::BaseSoftRenderSurface(Graphics::ManagedSurface *s) :
-	_pixels(nullptr), _pixels00(nullptr), _zBuffer(nullptr),
-	_zBuffer00(nullptr), _bytesPerPixel(0), _bitsPerPixel(0), _formatType(0),
-	_ox(0), _oy(0), _width(0), _height(0), _pitch(0), _zPitch(0),
+	_pixels(nullptr), _pixels00(nullptr), _bytesPerPixel(0), _bitsPerPixel(0), _formatType(0),
+	_ox(0), _oy(0), _width(0), _height(0), _pitch(0),
 	_flipped(false), _clipWindow(0, 0, 0, 0), _lockCount(0),
-	_surface(s), _rttTex(nullptr) {
+	_surface(s) {
 	_clipWindow.setWidth(_width = _surface->w);
 	_clipWindow.setHeight(_height = _surface->h);
 	_pitch = _surface->pitch;
 	_bitsPerPixel = _surface->format.bpp();
 	_bytesPerPixel = _surface->format.bytesPerPixel;
 
-	RenderSurface::_format.bytesPerPixel = _bytesPerPixel;
-	RenderSurface::_format.rLoss = _surface->format.rLoss;
-	RenderSurface::_format.gLoss = _surface->format.gLoss;
-	RenderSurface::_format.bLoss = _surface->format.bLoss;
-	RenderSurface::_format.aLoss = _surface->format.aLoss;
-	RenderSurface::_format.rLoss16 = _format.rLoss + 8;
-	RenderSurface::_format.gLoss16 = _format.gLoss + 8;
-	RenderSurface::_format.bLoss16 = _format.bLoss + 8;
-	RenderSurface::_format.aLoss16 = _format.aLoss + 8;
-	RenderSurface::_format.rShift = _surface->format.rShift;
-	RenderSurface::_format.gShift = _surface->format.gShift;
-	RenderSurface::_format.bShift = _surface->format.bShift;
-	RenderSurface::_format.aShift = _surface->format.aShift;
-	RenderSurface::_format.rMask = _surface->format.rMax() << _surface->format.rShift;
-	RenderSurface::_format.gMask = _surface->format.gMax() << _surface->format.gShift;
-	RenderSurface::_format.bMask = _surface->format.bMax() << _surface->format.bShift;
-	RenderSurface::_format.aMask = _surface->format.aMax() << _surface->format.aShift;
+	// TODO: Slight hack - set the global surface format only once.
+	if (!RenderSurface::_format.bytesPerPixel) {
+		RenderSurface::_format.bytesPerPixel = _bytesPerPixel;
+		RenderSurface::_format.rLoss = _surface->format.rLoss;
+		RenderSurface::_format.gLoss = _surface->format.gLoss;
+		RenderSurface::_format.bLoss = _surface->format.bLoss;
+		RenderSurface::_format.aLoss = _surface->format.aLoss;
+		RenderSurface::_format.rLoss16 = _format.rLoss + 8;
+		RenderSurface::_format.gLoss16 = _format.gLoss + 8;
+		RenderSurface::_format.bLoss16 = _format.bLoss + 8;
+		RenderSurface::_format.aLoss16 = _format.aLoss + 8;
+		RenderSurface::_format.rShift = _surface->format.rShift;
+		RenderSurface::_format.gShift = _surface->format.gShift;
+		RenderSurface::_format.bShift = _surface->format.bShift;
+		RenderSurface::_format.aShift = _surface->format.aShift;
+		RenderSurface::_format.rMask = _surface->format.rMax() << _surface->format.rShift;
+		RenderSurface::_format.gMask = _surface->format.gMax() << _surface->format.gShift;
+		RenderSurface::_format.bMask = _surface->format.bMax() << _surface->format.bShift;
+		RenderSurface::_format.aMask = _surface->format.aMax() << _surface->format.aShift;
+	}
 
 	SetPixelsPointer();
 
@@ -111,127 +113,6 @@ BaseSoftRenderSurface::BaseSoftRenderSurface(Graphics::ManagedSurface *s) :
 }
 
 
-//
-// BaseSoftRenderSurface::BaseSoftRenderSurface(int w, int h, int bpp, int rsft, int gsft, int bsft)
-//
-// Desc: Constructor for Generic BaseSoftRenderSurface
-//
-BaseSoftRenderSurface::BaseSoftRenderSurface(int w, int h, int bpp,
-        int rsft, int gsft, int bsft, int asft) :
-	_pixels(nullptr), _pixels00(nullptr), _zBuffer(nullptr),
-	_zBuffer00(nullptr), _bytesPerPixel(0), _bitsPerPixel(0), _formatType(0),
-	_ox(0), _oy(0), _width(0), _height(0), _pitch(0), _zPitch(0),
-	_flipped(false), _clipWindow(0, 0, 0, 0), _lockCount(0), _surface(nullptr),
-	_rttTex(nullptr) {
-	_clipWindow.setWidth(_width = w);
-	_clipWindow.setHeight(_height = h);
-
-	switch (bpp) {
-	case 15:
-		_format.rLoss = 3;
-		_format.gLoss = 3;
-		_format.bLoss = 3;
-		_format.aLoss = 7;
-		bpp = 16;
-		break;
-
-	case 16:
-		_format.rLoss = 3;
-		_format.gLoss = 2;
-		_format.bLoss = 3;
-		_format.aLoss = 0;
-		break;
-
-	case 32:
-		_format.rLoss = 0;
-		_format.gLoss = 0;
-		_format.bLoss = 0;
-		_format.aLoss = 0;
-		break;
-
-	default:
-		break;
-	}
-
-	_pitch = w * bpp / 8;
-	_bitsPerPixel = bpp;
-	_bytesPerPixel = bpp / 8;
-
-	RenderSurface::_format.bytesPerPixel = _bytesPerPixel;
-	RenderSurface::_format.rLoss16 = _format.rLoss + 8;
-	RenderSurface::_format.gLoss16 = _format.gLoss + 8;
-	RenderSurface::_format.bLoss16 = _format.bLoss + 8;
-	RenderSurface::_format.aLoss16 = _format.aLoss + 8;
-	RenderSurface::_format.rShift = rsft;
-	RenderSurface::_format.gShift = gsft;
-	RenderSurface::_format.bShift = bsft;
-	RenderSurface::_format.aShift = asft;
-	RenderSurface::_format.rMask = (0xFF >> _format.rLoss) << rsft;
-	RenderSurface::_format.gMask = (0xFF >> _format.gLoss) << gsft;
-	RenderSurface::_format.bMask = (0xFF >> _format.bLoss) << bsft;
-	RenderSurface::_format.aMask = (0xFF >> _format.aLoss) << asft;
-
-	SetPixelsPointer();
-}
-
-
-//
-// BaseSoftRenderSurface::BaseSoftRenderSurface(int w, int h, uint8 *buf)
-//
-// Desc: Constructor for Generic BaseSoftRenderSurface which matches screen params
-//
-BaseSoftRenderSurface::BaseSoftRenderSurface(int w, int h, uint8 *buf) :
-	_pixels(nullptr), _pixels00(nullptr), _zBuffer(nullptr),
-	_zBuffer00(nullptr), _bytesPerPixel(0), _bitsPerPixel(0), _formatType(0),
-	_ox(0), _oy(0), _width(0), _height(0), _pitch(0), _zPitch(0),
-	_flipped(false), _clipWindow(0, 0, 0, 0), _lockCount(0),
-	_surface(nullptr), _rttTex(nullptr) {
-	_clipWindow.setWidth(_width = w);
-	_clipWindow.setHeight(_height = h);
-
-	int bpp = RenderSurface::_format.bpp();
-
-	_pitch = w * bpp / 8;
-	_bitsPerPixel = bpp;
-	_bytesPerPixel = bpp / 8;
-	_pixels00 = buf;
-
-	SetPixelsPointer();
-}
-
-//
-// BaseSoftRenderSurface::BaseSoftRenderSurface(int w, int h, uint8 *buf)
-//
-// Desc: Constructor for Generic BaseSoftRenderSurface which matches screen params
-//
-BaseSoftRenderSurface::BaseSoftRenderSurface(int w, int h) :
-	_pixels(nullptr), _pixels00(nullptr), _zBuffer(nullptr), _zBuffer00(nullptr),
-	_bytesPerPixel(0), _bitsPerPixel(0), _formatType(0),
-	_ox(0), _oy(0), _width(0), _height(0), _pitch(0), _zPitch(0),
-	_flipped(false), _clipWindow(0, 0, 0, 0), _lockCount(0), _surface(nullptr),
-	_rttTex(nullptr) {
-	_clipWindow.setWidth(_width = w);
-	_clipWindow.setHeight(_height = h);
-
-	int bpp = RenderSurface::_format.bpp();
-
-	_pitch = w * bpp / 8;
-	_bitsPerPixel = bpp;
-	_bytesPerPixel = bpp / 8;
-	_pixels00 = new uint8[_pitch * _height];
-
-	_rttTex = new Texture;
-	_rttTex->setPixels(_pixels00);
-	_rttTex->w = _width;
-	_rttTex->h = _height;
-	_rttTex->_format = TEX_FMT_NATIVE;
-	_rttTex->format = RenderSurface::getPixelFormat();
-	_rttTex->pitch = _pitch;
-	_rttTex->CalcLOG2s();
-
-	SetPixelsPointer();
-}
-
 
 //
 // BaseSoftRenderSurface::~BaseSoftRenderSurface()
@@ -239,11 +120,6 @@ BaseSoftRenderSurface::BaseSoftRenderSurface(int w, int h) :
 // Desc: Destructor
 //
 BaseSoftRenderSurface::~BaseSoftRenderSurface() {
-	if (_rttTex) {
-		delete _rttTex;
-		delete [] _pixels00;
-		delete [] _zBuffer00;
-	}
 }
 
 
@@ -263,10 +139,8 @@ bool BaseSoftRenderSurface::BeginPainting() {
 
 			_pitch = _surface->pitch;
 			if (_flipped) _pitch = -_pitch;
-		} else  {
-			if (!GenericLock())
-				return false;
 		}
+		// else, nothing to lock.
 	}
 
 	_lockCount++;
@@ -305,34 +179,19 @@ bool BaseSoftRenderSurface::EndPainting() {
 			// Clear pointers
 			_pixels = _pixels00 = 0;
 
-			// Render the screen
+			// Render the screen if this is it (slight hack..)
 			Graphics::Screen *screen = dynamic_cast<Graphics::Screen *>(_surface);
-			assert(screen);
-			screen->update();
+			if (screen)
+				screen->update();
 
-		} else {
-			if (!GenericUnlock())
-				return false;
 		}
+		// else, nothing to unlock.
 	}
 
 	// No error
 	return true;
 }
 
-//
-// Texture *BaseSoftRenderSurface::GetSurfaceAsTexture()
-//
-// Desc: Get the surface as a Texture. Only valid for SecondaryRenderSurfaces
-//
-Texture *BaseSoftRenderSurface::GetSurfaceAsTexture() {
-	if (!_rttTex) {
-		perr << "Error: GetSurfaceAsTexture(): Surface doesn't render-to-texture" << Std::endl;
-	}
-
-	return _rttTex;
-}
-
 //
 // void BaseSoftRenderSurface::CreateNativePalette(Palette* palette)
 //
@@ -511,7 +370,6 @@ void BaseSoftRenderSurface::SetFlipped(bool wantFlipped) {
 	_oy += _clipWindow.top;
 
 	_pitch = -_pitch;
-	_zPitch = -_zPitch;
 
 	SetPixelsPointer();
 
diff --git a/engines/ultima/ultima8/graphics/base_soft_render_surface.h b/engines/ultima/ultima8/graphics/base_soft_render_surface.h
index d29e7e91fb..a4f7b1da8e 100644
--- a/engines/ultima/ultima8/graphics/base_soft_render_surface.h
+++ b/engines/ultima/ultima8/graphics/base_soft_render_surface.h
@@ -41,10 +41,6 @@ protected:
 	uint8           *_pixels;                // Pointer to logical pixel 0,0
 	uint8           *_pixels00;              // Pointer to physical pixel 0,0
 
-	// Depth Buffer
-	uint16          *_zBuffer;               // Pointer to logical pixel 0,0
-	uint8           *_zBuffer00;             // Pointer to physical pixel 0,0
-
 	// Pixel Format (also see 'Colour shifting values' later)
 	int             _bytesPerPixel;          // 2 or 4
 	int             _bitsPerPixel;           // 16 or 32
@@ -54,7 +50,6 @@ protected:
 	int32           _ox, _oy;                // Physical Pixel for Logical Origin
 	int32           _width, _height;         // Width and height
 	int32           _pitch;                  // Frame buffer pitch (bytes) (could be negated)
-	int32           _zPitch;                 // Z Buffer pitch (bytes) (could be negated)
 	bool            _flipped;
 
 	// Clipping Rectangle
@@ -65,37 +60,18 @@ protected:
 
 	Graphics::ManagedSurface *_surface;
 
-	// Renderint to a texture
-	Texture         *_rttTex;
-
 	// Create from a managed surface
 	BaseSoftRenderSurface(Graphics::ManagedSurface *);
 
-	// Create with Texture
-	BaseSoftRenderSurface(int w, int h);
-
-	// Create Generic
-	BaseSoftRenderSurface(int w, int h, int bpp, int rsft, int gsft, int bsft, int asft);
-	BaseSoftRenderSurface(int w, int h, uint8 *buf);
-	virtual bool GenericLock()  {
-		return true;
-	}
-	virtual bool GenericUnlock()  {
-		return true;
-	}
-
 	// Update the Pixels Pointer
 	void    SetPixelsPointer() {
 		uint8 *pix00 = _pixels00;
-		uint8 *zbuf00 = _zBuffer00;
 
 		if (_flipped) {
 			pix00 += -_pitch * (_height - 1);
-			zbuf00 += -_zPitch * (_height - 1);
 		}
 
 		_pixels = pix00 + _ox * _bytesPerPixel + _oy * _pitch;
-		_zBuffer = reinterpret_cast<uint16 *>(zbuf00 + _ox + _oy * _zPitch);
 	}
 
 public:
@@ -116,10 +92,6 @@ public:
 	// Returns Error Code on error. Check return code.....
 	bool EndPainting() override;
 
-	// Get the surface as a Texture. Only valid for SecondaryRenderSurfaces
-	Texture *GetSurfaceAsTexture() override;
-
-
 	//
 	// Surface Properties
 	//
diff --git a/engines/ultima/ultima8/graphics/fonts/fixed_width_font.cpp b/engines/ultima/ultima8/graphics/fonts/fixed_width_font.cpp
deleted file mode 100644
index 45aa48f9de..0000000000
--- a/engines/ultima/ultima8/graphics/fonts/fixed_width_font.cpp
+++ /dev/null
@@ -1,94 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
-
-#include "ultima/ultima8/misc/pent_include.h"
-#include "ultima/ultima8/graphics/fonts/fixed_width_font.h"
-#include "ultima/ultima8/graphics/texture.h"
-#include "ultima/ultima8/filesys/idata_source.h"
-#include "ultima/ultima8/conf/config_file_manager.h"
-#include "ultima/ultima8/filesys/file_system.h"
-
-namespace Ultima {
-namespace Ultima8 {
-
-FixedWidthFont *FixedWidthFont::Create(const Std::string &iniroot) {
-	ConfigFileManager *config = ConfigFileManager::get_instance();
-	FileSystem *filesys = FileSystem::get_instance();
-
-	Std::string filename;
-	if (!config->get(iniroot + "/font/path", filename)) {
-		perr << "Error: 'path' key not found in font ini" << Std::endl;
-		return nullptr;
-	}
-
-	Common::SeekableReadStream *rs = filesys->ReadFile(filename);
-
-	if (!rs) {
-		perr << "Error: Unable to open file " << filename << Std::endl;
-		return nullptr;
-	}
-
-	Texture *fonttex = Texture::Create(rs, filename.c_str());
-
-	if (!fonttex) {
-		perr << "Error: Unable to read texture " << filename << Std::endl;
-		// FIXME: This leaks rs
-		return nullptr;
-	}
-
-	delete rs;
-
-	FixedWidthFont *fwf = new FixedWidthFont;
-
-	fwf->_tex = fonttex;
-
-	if (!config->get(iniroot + "/font/width", fwf->_width)) {
-		fwf->_width = fwf->_tex->w / 16;
-	}
-
-	if (!config->get(iniroot + "/font/height", fwf->_height)) {
-		fwf->_height = fwf->_tex->h / 16;
-	}
-
-	if (!config->get(iniroot + "/font/align_x", fwf->_alignX)) {
-		for (int i = 0; i < 32; i++) {
-			if (fwf->_width <= (1 << i)) {
-				fwf->_alignX = 1 << i;
-				break;
-			}
-		}
-	}
-
-	if (!config->get(iniroot + "/font/align_y", fwf->_alignY)) {
-		for (int i = 0; i < 32; i++) {
-			if (fwf->_height <= (1 << i)) {
-				fwf->_alignY = 1 << i;
-				break;
-			}
-		}
-	}
-
-	return fwf;
-}
-
-} // End of namespace Ultima8
-} // End of namespace Ultima
diff --git a/engines/ultima/ultima8/graphics/fonts/fixed_width_font.h b/engines/ultima/ultima8/graphics/fonts/fixed_width_font.h
deleted file mode 100644
index 053ae9232d..0000000000
--- a/engines/ultima/ultima8/graphics/fonts/fixed_width_font.h
+++ /dev/null
@@ -1,49 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
-
-#ifndef ULTIMA8_GRAPHICS_FONTS_FIXEDWIDTHFONT_H
-#define ULTIMA8_GRAPHICS_FONTS_FIXEDWIDTHFONT_H
-
-#include "ultima/shared/std/string.h"
-
-namespace Ultima {
-namespace Ultima8 {
-
-class Texture;
-
-struct FixedWidthFont {
-	int     _width;
-	int     _height;
-	int     _alignX;
-	int     _alignY;
-
-	Texture *_tex;
-
-	~FixedWidthFont();
-
-	static FixedWidthFont *Create(const Std::string &iniroot);
-};
-
-} // End of namespace Ultima8
-} // End of namespace Ultima
-
-#endif
diff --git a/engines/ultima/ultima8/graphics/fonts/shape_rendered_text.cpp b/engines/ultima/ultima8/graphics/fonts/shape_rendered_text.cpp
index fa22ece209..7f418fcfdc 100644
--- a/engines/ultima/ultima8/graphics/fonts/shape_rendered_text.cpp
+++ b/engines/ultima/ultima8/graphics/fonts/shape_rendered_text.cpp
@@ -46,6 +46,8 @@ void ShapeRenderedText::draw(RenderSurface *surface, int x, int y, bool /*destma
 
 	Std::list<PositionedText>::const_iterator iter;
 
+	surface->BeginPainting();
+
 	for (iter = _lines.begin(); iter != _lines.end(); ++iter) {
 		int line_x = x + iter->_dims.left;
 		int line_y = y + iter->_dims.top;
@@ -69,6 +71,8 @@ void ShapeRenderedText::draw(RenderSurface *surface, int x, int y, bool /*destma
 			                1, iter->_dims.height());
 		}
 	}
+
+	surface->EndPainting();
 }
 
 void ShapeRenderedText::drawBlended(RenderSurface *surface, int x, int y,
diff --git a/engines/ultima/ultima8/graphics/fonts/tt_font.cpp b/engines/ultima/ultima8/graphics/fonts/tt_font.cpp
index 0780fe16a4..965fb7e9fb 100644
--- a/engines/ultima/ultima8/graphics/fonts/tt_font.cpp
+++ b/engines/ultima/ultima8/graphics/fonts/tt_font.cpp
@@ -40,12 +40,12 @@ namespace Ultima8 {
 // various unicode characters which look like small black circles
 static const uint16 BULLETS[] = { 0x2022, 0x30FB, 0x25CF, 0 };
 
+static const Graphics::PixelFormat PF_RGBA(4, 8, 8, 8, 8, 24, 16, 8, 0);
 
 TTFont::TTFont(Graphics::Font *font, uint32 rgb, int borderSize,
 		bool antiAliased, bool SJIS) :
-		_borderSize(borderSize), _ttfFont(font), _antiAliased(antiAliased), _SJIS(SJIS),
-		_pixelFormat(Texture::getPixelFormat()) {
-	_color = _pixelFormat.RGBToColor((rgb >> 16) & 0xFF, (rgb >> 8) & 0xff, rgb & 0xff);
+		_borderSize(borderSize), _ttfFont(font), _antiAliased(antiAliased), _SJIS(SJIS) {
+	_color = PF_RGBA.RGBToColor((rgb >> 16) & 0xFF, (rgb >> 8) & 0xff, rgb & 0xff);
 
 	_bullet = 0;
 	// scan for a character to use as a conversation option _bullet
@@ -139,8 +139,7 @@ RenderedText *TTFont::renderText(const Std::string &text, unsigned int &remainin
 			resultWidth, resultHeight, cursor);
 	lineHeight = _ttfFont->getFontHeight();
 
-	Texture *texture = new Texture();
-	texture->create(resultWidth, resultHeight, TEX_FMT_STANDARD);
+	Graphics::ManagedSurface *texture = new Graphics::ManagedSurface(resultWidth, resultHeight, PF_RGBA);
 	uint32 *texBuf = (uint32 *)texture->getPixels();
 
 	Std::list<PositionedText>::const_iterator iter;
@@ -162,13 +161,13 @@ RenderedText *TTFont::renderText(const Std::string &text, unsigned int &remainin
 			_ttfFont->drawString(&textSurf, unicodeText, 0, 0, resultWidth, 1);
 		} else {
 			// Use a high color surface with the specified _color color for text
-			textSurf.create(resultWidth, lineHeight, _pixelFormat);
+			textSurf.create(resultWidth, lineHeight, PF_RGBA);
 			_ttfFont->drawString(&textSurf, unicodeText, 0, 0, resultWidth, _color);
 		};
 
 		// render the text surface into our texture buffer
 		for (int y = 0; y < textSurf.h; y++) {
-			byte *surfrow = (byte *)textSurf.getBasePtr(0, y);
+			const byte *surfrow = (const byte *)textSurf.getBasePtr(0, y);
 
 			// CHECKME: _borderSize!
 			uint32 *bufrow = texBuf + (iter->_dims.top + y + _borderSize) * resultWidth;
diff --git a/engines/ultima/ultima8/graphics/fonts/tt_font.h b/engines/ultima/ultima8/graphics/fonts/tt_font.h
index f90f16c3d0..765580bf7b 100644
--- a/engines/ultima/ultima8/graphics/fonts/tt_font.h
+++ b/engines/ultima/ultima8/graphics/fonts/tt_font.h
@@ -32,8 +32,6 @@ namespace Ultima {
 namespace Ultima8 {
 
 class TTFont : public Font {
-private:
-	Graphics::PixelFormat _pixelFormat;
 public:
 	TTFont(Graphics::Font *font, uint32 rgb, int bordersize,
 	       bool antiAliased, bool SJIS);
diff --git a/engines/ultima/ultima8/graphics/fonts/ttf_rendered_text.cpp b/engines/ultima/ultima8/graphics/fonts/ttf_rendered_text.cpp
index e4b5e304a6..a6d19ee2af 100644
--- a/engines/ultima/ultima8/graphics/fonts/ttf_rendered_text.cpp
+++ b/engines/ultima/ultima8/graphics/fonts/ttf_rendered_text.cpp
@@ -29,7 +29,7 @@
 namespace Ultima {
 namespace Ultima8 {
 
-TTFRenderedText::TTFRenderedText(Texture *texture, int width, int height,
+TTFRenderedText::TTFRenderedText(Graphics::ManagedSurface *texture, int width, int height,
 		int vLead, TTFont *font) : _texture(texture), _font(font) {
 	_width = width;
 	_height = height;
diff --git a/engines/ultima/ultima8/graphics/fonts/ttf_rendered_text.h b/engines/ultima/ultima8/graphics/fonts/ttf_rendered_text.h
index 287213dec6..3110e10e31 100644
--- a/engines/ultima/ultima8/graphics/fonts/ttf_rendered_text.h
+++ b/engines/ultima/ultima8/graphics/fonts/ttf_rendered_text.h
@@ -26,6 +26,7 @@
 #include "ultima/ultima8/graphics/fonts/rendered_text.h"
 #include "ultima/ultima8/graphics/fonts/font.h"
 #include "ultima/ultima8/misc/p_dynamic_cast.h"
+#include "graphics/managed_surface.h"
 
 namespace Ultima {
 namespace Ultima8 {
@@ -35,7 +36,7 @@ class Texture;
 
 class TTFRenderedText : public RenderedText {
 public:
-	TTFRenderedText(Texture *texture, int width, int height, int vlead,
+	TTFRenderedText(Graphics::ManagedSurface *texture, int width, int height, int vlead,
 	                TTFont *font);
 	~TTFRenderedText() override;
 
@@ -45,7 +46,7 @@ public:
 	                         bool destmasked = false) override;
 
 protected:
-	Texture *_texture;
+	Graphics::ManagedSurface *_texture;
 	TTFont *_font;
 };
 
diff --git a/engines/ultima/ultima8/graphics/point_scaler.cpp b/engines/ultima/ultima8/graphics/point_scaler.cpp
deleted file mode 100644
index 99e3fb4c44..0000000000
--- a/engines/ultima/ultima8/graphics/point_scaler.cpp
+++ /dev/null
@@ -1,305 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
-
-#include "ultima/ultima8/misc/pent_include.h"
-#include "ultima/ultima8/graphics/point_scaler.h"
-#include "ultima/ultima8/graphics/manips.h"
-
-namespace Ultima {
-namespace Ultima8 {
-
-// Very very simple point scaler
-template<class uintX, class Manip, class uintS = uintX> class PointScalerInternal {
-public:
-	static bool Scale(const Texture *tex  , int32 sx, int32 sy, int32 sw, int32 sh,
-	                  uint8 *pixel, int32 dw, int32 dh, int32 pitch, bool clamp_src) {
-		// Source buffer pointers
-		const uintS *texel = reinterpret_cast<const uintS *>(tex->getPixels()) + (sy * tex->w + sx);
-		int tpitch = tex->w;
-		const uintS *tline_end = texel + sw;
-		const uintS *tex_end = texel + sh * tex->w;
-		int tex_diff = tex->w - sw;
-
-
-		// First detect integer up scalings, since they are 'easy'
-		bool x_intscale = ((dw / sw) * sw) == dw;
-		bool y_intscale = ((dh / sh) * sh) == dh;
-
-		//
-		// 2x
-		//
-		if ((sw * 2 == dw) && (sh * 2 == dh)) {
-			uint8 *pixel2 = pixel + pitch;
-			int p_diff    = (pitch * 2) - (dw * sizeof(uintX));
-
-			// Src Loop Y
-			do {
-				// Src Loop X
-				do {
-					uintX p = Manip::copy(*texel);
-
-					*(reinterpret_cast<uintX *>(pixel + 0)) = p;
-					*(reinterpret_cast<uintX *>(pixel + sizeof(uintX))) = p;
-					*(reinterpret_cast<uintX *>(pixel2 + 0)) = p;
-					*(reinterpret_cast<uintX *>(pixel2 + sizeof(uintX))) = p;
-					pixel  += sizeof(uintX) * 2;
-					pixel2 += sizeof(uintX) * 2;
-					texel++;
-				} while (texel != tline_end);
-
-				pixel  += p_diff;
-				pixel2 += p_diff;
-
-				texel += tex_diff;
-				tline_end += tpitch;
-			} while (texel != tex_end);
-
-		}
-		//
-		// Integer scaling, x and y
-		//
-		else if (x_intscale && y_intscale) {
-			int xf = dw / sw;
-			int yf = dh / sh;
-
-			uint8 *px_end = pixel + xf * sizeof(uintX);
-			uint8 *py_end = pixel + yf * pitch;
-
-			int block_w = xf * sizeof(uintX);
-			int block_h = pitch * yf;
-			int block_xdiff = pitch - block_w;
-			int p_diff = block_h - dw * sizeof(uintX);
-
-			// Src Loop Y
-			do {
-				// Src Loop X
-				do {
-					uintX p = Manip::copy(*texel);
-
-					//
-					// Inner loops
-					//
-
-					// Dest Loop Y
-					do {
-						// Dest Loop X
-						do {
-							*(reinterpret_cast<uintX *>(pixel)) = p;
-							pixel += sizeof(uintX);
-						} while (pixel != px_end);
-
-						pixel += block_xdiff;
-						px_end += pitch;
-					} while (pixel != py_end);
-
-					pixel  += block_w - block_h;
-					px_end += block_w - block_h;
-					py_end += block_w;
-					texel++;
-				} while (texel != tline_end);
-
-				pixel += p_diff;
-				py_end += p_diff;
-				px_end += p_diff;
-
-				texel += tex_diff;
-				tline_end += tpitch;
-			} while (texel != tex_end);
-
-		}
-		//
-		// 2x X and Arbitrary Upscaled Y
-		// Specifically to handle 320x200 -> 640x480
-		//
-		else if ((sw * 2 == dw) && (dh >= sh)) {
-			uint32 pos_y;
-			uint32 end_y = dh;
-			uint32 dst_y = 0;
-			uint8 *next_block = nullptr;
-
-			// Src Loop Y
-			do {
-				next_block = pixel;
-
-				// Src Loop X
-				do {
-					pos_y = dst_y;
-
-					uintX p = Manip::copy(*texel);
-
-					//
-					// Inner loops
-					//
-					pixel = next_block;
-					next_block = next_block + sizeof(uintX) * 2;
-
-					// Dest Loop Y
-					do {
-						*(reinterpret_cast<uintX *>(pixel + 0)) = p;
-						*(reinterpret_cast<uintX *>(pixel + sizeof(uintX))) = p;
-						pixel += pitch;
-						pos_y += sh;
-					} while (pos_y < end_y);
-
-					texel++;
-				} while (texel != tline_end);
-
-				pixel -= sizeof(uintX) * (dw - 2);
-				dst_y = pos_y;
-				end_y += dh;
-
-				texel += tex_diff;
-				tline_end += tpitch;
-			} while (texel != tex_end);
-		}
-		//
-		// 1x X and Arbitrary Upscaled Y
-		// Specifically to handle 640x400 -> 640x480
-		//
-		else if ((sw == dw) && (dh >= sh)) {
-			uint32 pos_y;
-			uint32 end_y = dh;
-			uint32 dst_y = 0;
-			uint8 *next_block = nullptr;
-
-			// Src Loop Y
-			do {
-				next_block = pixel;
-
-				// Src Loop X
-				do {
-					pos_y = dst_y;
-
-					uintX p = Manip::copy(*texel);
-
-					//
-					// Inner loops
-					//
-					pixel = next_block;
-					next_block = next_block + sizeof(uintX);
-
-					// Dest Loop Y
-					do {
-						*(reinterpret_cast<uintX *>(pixel)) = p;
-						pixel += pitch;
-						pos_y += sh;
-					} while (pos_y < end_y);
-
-					texel++;
-				} while (texel != tline_end);
-
-				pixel -= sizeof(uintX) * (dw - 1);
-				dst_y = pos_y;
-				end_y += dh;
-
-				texel += tex_diff;
-				tline_end += tpitch;
-			} while (texel != tex_end);
-		}
-		//
-		// Arbitrary scaling X and Y (optimized for upscaling)
-		//
-		else {
-			uint32 pos_y = 0, pos_x = 0;
-			uint32 end_y = dh;
-			uint32 dst_y = 0;
-			uint8 *blockline_start = nullptr;
-			uint8 *next_block = nullptr;
-
-			// Src Loop Y
-			do {
-				uint32 end_x = dw;
-				uint32 dst_x = 0;
-
-				next_block = pixel;
-
-				// Src Loop X
-				do {
-					pos_y = dst_y;
-
-					const uintX p = Manip::copy(*texel);
-
-					//
-					// Inner loops
-					//
-					blockline_start = next_block;
-					next_block = nullptr;
-
-					// Dest Loop Y
-					while (pos_y < end_y) {
-						pos_x = dst_x;
-						pixel = blockline_start;
-
-						// Dest Loop X
-						while (pos_x < end_x) {
-							*(reinterpret_cast<uintX *>(pixel)) = p;
-
-							pixel += sizeof(uintX);
-							pos_x += sw;
-						}
-						if (!next_block) next_block = pixel;
-
-						blockline_start += pitch;
-
-						pos_y += sh;
-					}
-
-					dst_x = pos_x;
-					end_x += dw;
-					texel++;
-				} while (texel != tline_end);
-
-				pixel += pitch - sizeof(uintX) * (dw);
-
-				dst_y = pos_y;
-				end_y += dh;
-
-				texel += tex_diff;
-				tline_end += tpitch;
-			} while (texel != tex_end);
-		}
-
-		return true;
-	}
-
-};
-
-
-PointScaler::PointScaler() : Scaler() {
-	Scale16Nat = PointScalerInternal<uint16, Manip_Nat2Nat_16, uint16>::Scale;
-	Scale16Sta = PointScalerInternal<uint16, Manip_Sta2Nat_16, uint32>::Scale;
-
-	Scale32Nat = PointScalerInternal<uint32, Manip_Nat2Nat_32, uint32>::Scale;
-	Scale32Sta = PointScalerInternal<uint32, Manip_Sta2Nat_32, uint32>::Scale;
-	Scale32_A888 = PointScalerInternal<uint32, Manip_32_A888, uint32>::Scale;
-	Scale32_888A = PointScalerInternal<uint32, Manip_32_888A, uint32>::Scale;
-}
-
-uint32 PointScaler::ScaleBits() const {
-	return 0xFFFFFFFF;
-}
-bool PointScaler::ScaleArbitrary() const {
-	return true;
-}
-
-} // End of namespace Ultima8
-} // End of namespace Ultima
diff --git a/engines/ultima/ultima8/graphics/point_scaler.h b/engines/ultima/ultima8/graphics/point_scaler.h
deleted file mode 100644
index 0e935ced6f..0000000000
--- a/engines/ultima/ultima8/graphics/point_scaler.h
+++ /dev/null
@@ -1,42 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
-
-#ifndef ULTIMA8_GRAPHICS_SCALERS_POINTSCALER_H
-#define ULTIMA8_GRAPHICS_SCALERS_POINTSCALER_H
-
-#include "ultima/ultima8/graphics/scaler.h"
-
-namespace Ultima {
-namespace Ultima8 {
-
-class PointScaler : public Scaler {
-public:
-	PointScaler();
-
-	uint32    ScaleBits() const override;          //< bits for supported integer scaling
-	bool      ScaleArbitrary() const override;     //< supports arbitrary scaling of any degree
-};
-
-} // End of namespace Ultima8
-} // End of namespace Ultima
-
-#endif
diff --git a/engines/ultima/ultima8/graphics/render_surface.cpp b/engines/ultima/ultima8/graphics/render_surface.cpp
index 0598d55d8f..8f0f7d44a2 100644
--- a/engines/ultima/ultima8/graphics/render_surface.cpp
+++ b/engines/ultima/ultima8/graphics/render_surface.cpp
@@ -81,8 +81,9 @@ RenderSurface *RenderSurface::CreateSecondaryRenderSurface(uint32 width, uint32
 	RenderSurface *surf;
 
 	// TODO: Change this
-	if (_format.bytesPerPixel == 4) surf = new SoftRenderSurface<uint32>(width, height);
-	else surf = new SoftRenderSurface<uint16>(width, height);
+	Graphics::ManagedSurface *managedSurface = new Graphics::ManagedSurface(width, height, _format);
+	if (_format.bytesPerPixel == 4) surf = new SoftRenderSurface<uint32>(managedSurface);
+	else surf = new SoftRenderSurface<uint16>(managedSurface);
 	return surf;
 }
 
diff --git a/engines/ultima/ultima8/graphics/render_surface.h b/engines/ultima/ultima8/graphics/render_surface.h
index 79a21dcd64..2695f5d5cc 100644
--- a/engines/ultima/ultima8/graphics/render_surface.h
+++ b/engines/ultima/ultima8/graphics/render_surface.h
@@ -95,12 +95,6 @@ public:
 	// \return true on success, false on failure
 	virtual bool EndPainting() = 0;
 
-	//! Get the surface as a Texture. Only valid for SecondaryRenderSurfaces
-	// \note Do not delete the texture.
-	// \note Do not assume anything about the contents of the Texture object.
-	// \note It should only be used with Painting and Blitting methods.
-	virtual Texture *GetSurfaceAsTexture() = 0;
-
 	//
 	// Surface Properties
 	//
@@ -209,19 +203,13 @@ public:
 	//
 
 	//! Blit a region from a Texture (Alpha == 0 -> skipped)
-	virtual void Blit(const Texture *, int32 sx, int32 sy, int32 w, int32 h, int32 dx, int32 dy, bool alpha_blend = false) = 0;
+	virtual void Blit(const Graphics::ManagedSurface *, int32 sx, int32 sy, int32 w, int32 h, int32 dx, int32 dy, bool alpha_blend = false) = 0;
 
 	//! Blit a region from a Texture with a Colour blend (AlphaTex == 0 -> skipped. AlphaCol32 -> Blend Factors)
-	virtual void FadedBlit(const Texture *, int32 sx, int32 sy, int32 w, int32 h, int32 dx, int32 dy, uint32 col32, bool alpha_blend = false) = 0;
+	virtual void FadedBlit(const Graphics::ManagedSurface *, int32 sx, int32 sy, int32 w, int32 h, int32 dx, int32 dy, uint32 col32, bool alpha_blend = false) = 0;
 
 	//! Blit a region from a Texture with a Colour blend masked based on DestAlpha (AlphaTex == 0 || AlphaDest == 0 -> skipped. AlphaCol32 -> Blend Factors)
-	virtual void MaskedBlit(const Texture *, int32 sx, int32 sy, int32 w, int32 h, int32 dx, int32 dy, uint32 col32, bool alpha_blend = false) = 0;
-
-	//! Blit a stretched region from a Texture (Alpha == 0 -> skipped???)
-	virtual void StretchBlit(const Texture *, int32 sx, int32 sy, int32 sw, int32 sh, int32 dx, int32 dy, int32 dw, int32 dh, bool clampedges = false) = 0;
-
-	//! Blit a region from a Texture using a scaler
-	virtual bool ScalerBlit(const Texture *, int32 sx, int32 sy, int32 sw, int32 sh, int32 dx, int32 dy, int32 dw, int32 dh, const Scaler *, bool clampedges = false) = 0;
+	virtual void MaskedBlit(const Graphics::ManagedSurface *, int32 sx, int32 sy, int32 w, int32 h, int32 dx, int32 dy, uint32 col32, bool alpha_blend = false) = 0;
 
 };
 
diff --git a/engines/ultima/ultima8/graphics/scaler.h b/engines/ultima/ultima8/graphics/scaler.h
deleted file mode 100644
index f76f819f00..0000000000
--- a/engines/ultima/ultima8/graphics/scaler.h
+++ /dev/null
@@ -1,122 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
-
-#ifndef ULTIMA8_GRAPHICS_SCALER_H
-#define ULTIMA8_GRAPHICS_SCALER_H
-
-#include "ultima/ultima8/graphics/texture.h"
-#include "ultima/ultima8/graphics/render_surface.h"
-
-namespace Ultima {
-namespace Ultima8 {
-
-/// Base Scaler class
-class Scaler {
-	friend class hqScaler;
-protected:
-	// Basic scaler function template
-	typedef bool (*ScalerFunc)(const Texture *tex, int32 sx, int32 sy, int32 sw, int32 sh,
-	                           uint8 *pixel, int32 dw, int32 dh, int32 pitch, bool clamp_src);
-
-	//
-	// Basic scaler functions (filled in by the scalers constructor)
-	//
-	ScalerFunc  Scale16Nat;
-	ScalerFunc  Scale16Sta;
-
-	ScalerFunc  Scale32Nat;
-	ScalerFunc  Scale32Sta;
-	ScalerFunc  Scale32_A888;
-	ScalerFunc  Scale32_888A;
-
-	Scaler() : Scale16Nat(0), Scale16Sta(0), Scale32Nat(0), Scale32Sta(0),
-		Scale32_A888(0), Scale32_888A(0) {}
-public:
-	//
-	// Scaler Capabilites
-	//
-
-	virtual uint32    ScaleBits() const = 0;          //< bits for supported integer scaling
-	virtual bool      ScaleArbitrary() const = 0;     //< supports arbitrary scaling of any degree
-
-	//
-	// Maybe one day... for now we just grab everything from RenderSurface
-	// virtual bool SetDisplayFormat(const RenderSurface::Format &format);
-
-	// Call this to scale a section of the screen
-	inline bool Scale(const Texture *texture, int32 sx, int32 sy, int32 sw, int32 sh,
-	                  uint8 *pixel, int32 dw, int32 dh, int32 pitch, bool clamp_src) const {
-		// Check to see if we are doing valid integer scalings
-		if (!ScaleArbitrary()) {
-			uint32 scale_bits = ScaleBits();
-			int x_factor = dw / sw;
-			int y_factor = dh / sh;
-
-			// Not integer
-			if ((x_factor * sw) != dw || (y_factor * sh) != dh) return false;
-
-			// Don't support this
-			if (!(scale_bits & (1 << x_factor))) return false;
-
-			// Don't support this
-			if (!(scale_bits & (1 << y_factor))) return false;
-		}
-
-		if (RenderSurface::_format.bytesPerPixel == 4) {
-			if (texture->_format == TEX_FMT_NATIVE || (texture->_format == TEX_FMT_STANDARD &&
-			        RenderSurface::_format.aMask == TEX32_A_MASK && RenderSurface::_format.rMask == TEX32_R_MASK &&
-			        RenderSurface::_format.gMask == TEX32_G_MASK && RenderSurface::_format.bMask == TEX32_B_MASK)) {
-				if (RenderSurface::_format.aMask == 0xFF000000) {
-					if (!Scale32_A888) return false;
-					return Scale32_A888(texture, sx, sy, sw, sh, pixel, dw, dh, pitch, clamp_src);
-				} else if (RenderSurface::_format.aMask == 0x000000FF) {
-					if (!Scale32_888A) return false;
-					return Scale32_888A(texture, sx, sy, sw, sh, pixel, dw, dh, pitch, clamp_src);
-				} else {
-					if (!Scale32Nat) return false;
-					return Scale32Nat(texture, sx, sy, sw, sh, pixel, dw, dh, pitch, clamp_src);
-				}
-			} else if (texture->_format == TEX_FMT_STANDARD) {
-				if (!Scale32Sta) return false;
-				return Scale32Sta(texture, sx, sy, sw, sh, pixel, dw, dh, pitch, clamp_src);
-			}
-		}
-		if (RenderSurface::_format.bytesPerPixel == 2) {
-			if (texture->_format == TEX_FMT_NATIVE) {
-				if (!Scale16Nat) return false;
-				return Scale16Nat(texture, sx, sy, sw, sh, pixel, dw, dh, pitch, clamp_src);
-			} else if (texture->_format == TEX_FMT_STANDARD) {
-				if (!Scale16Sta) return false;
-				return Scale16Sta(texture, sx, sy, sw, sh, pixel, dw, dh, pitch, clamp_src);
-			}
-		}
-
-		return false;
-	}
-
-	virtual ~Scaler() { }
-};
-
-} // End of namespace Ultima8
-} // End of namespace Ultima
-
-#endif
diff --git a/engines/ultima/ultima8/graphics/skf_player.cpp b/engines/ultima/ultima8/graphics/skf_player.cpp
index 424d762a3b..c946f74e2a 100644
--- a/engines/ultima/ultima8/graphics/skf_player.cpp
+++ b/engines/ultima/ultima8/graphics/skf_player.cpp
@@ -80,7 +80,11 @@ SKFPlayer::SKFPlayer(Common::SeekableReadStream *rs, int width, int height, bool
 	parseEventList(eventlist);
 	delete eventlist;
 
-	_buffer = RenderSurface::CreateSecondaryRenderSurface(_width, _height);
+	// TODO: Slight hack.. clean me up.
+	if (RenderSurface::getPixelFormat().bpp() == 16)
+		_buffer = new SoftRenderSurface<uint16>(new Graphics::ManagedSurface(_width, _height, RenderSurface::getPixelFormat()));
+	else
+		_buffer = new SoftRenderSurface<uint32>(new Graphics::ManagedSurface(_width, _height, RenderSurface::getPixelFormat()));
 }
 
 SKFPlayer::~SKFPlayer() {
@@ -106,9 +110,7 @@ void SKFPlayer::parseEventList(Common::ReadStream *eventlist) {
 }
 
 void SKFPlayer::start() {
-	_buffer->BeginPainting();
 	_buffer->Fill32(0, 0, 0, _width, _height);
-	_buffer->EndPainting();
 	MusicProcess *musicproc = MusicProcess::get_instance();
 	if (musicproc) musicproc->playMusic(0);
 	_playing = true;
@@ -124,16 +126,14 @@ void SKFPlayer::stop() {
 void SKFPlayer::paint(RenderSurface *surf, int /*lerp*/) {
 	if (!_buffer) return;
 
-	Texture *tex = _buffer->GetSurfaceAsTexture();
-
 	if (!_fadeLevel) {
-		surf->Blit(tex, 0, 0, _width, _height, 0, 0);
+		surf->Blit(_buffer->getRawSurface(), 0, 0, _width, _height, 0, 0);
 		if (_subs)
 			_subs->draw(surf, 60, _subtitleY);
 	} else {
 		uint32 fade = TEX32_PACK_RGBA(_fadeColour, _fadeColour, _fadeColour,
 		                              (_fadeLevel * 255) / FADESTEPS);
-		surf->FadedBlit(tex, 0, 0, _width, _height, 0, 0, fade);
+		surf->FadedBlit(_buffer->getRawSurface(), 0, 0, _width, _height, 0, 0, fade);
 		if (_subs)
 			_subs->drawBlended(surf, 60, _subtitleY, fade);
 	}
diff --git a/engines/ultima/ultima8/graphics/skf_player.h b/engines/ultima/ultima8/graphics/skf_player.h
index f7e42925b5..50f410d8fd 100644
--- a/engines/ultima/ultima8/graphics/skf_player.h
+++ b/engines/ultima/ultima8/graphics/skf_player.h
@@ -25,13 +25,13 @@
 
 #include "ultima/shared/std/containers.h"
 #include "ultima/ultima8/graphics/movie_player.h"
+#include "ultima/ultima8/graphics/base_soft_render_surface.h"
 
 namespace Ultima {
 namespace Ultima8 {
 
 struct SKFEvent;
 class RawArchive;
-class RenderSurface;
 class RenderedText;
 struct Palette;
 
@@ -64,7 +64,7 @@ private:
 	unsigned int _timer;
 	unsigned int _frameRate;
 	uint8 _fadeColour, _fadeLevel;
-	RenderSurface *_buffer;
+	BaseSoftRenderSurface *_buffer;
 	RenderedText *_subs;
 	int _subtitleY;
 	bool _introMusicHack;
diff --git a/engines/ultima/ultima8/graphics/soft_render_surface.cpp b/engines/ultima/ultima8/graphics/soft_render_surface.cpp
index 888a160747..179c552061 100644
--- a/engines/ultima/ultima8/graphics/soft_render_surface.cpp
+++ b/engines/ultima/ultima8/graphics/soft_render_surface.cpp
@@ -26,10 +26,7 @@
 #include "ultima/ultima8/graphics/shape.h"
 #include "ultima/ultima8/graphics/shape_frame.h"
 #include "ultima/ultima8/graphics/palette.h"
-#include "ultima/ultima8/graphics/fonts/fixed_width_font.h"
-#include "ultima/ultima8/misc/memset_n.h"
 #include "ultima/ultima8/graphics/xform_blend.h"
-#include "ultima/ultima8/graphics/point_scaler.h"
 #include "ultima/ultima8/ultima8.h"
 
 namespace Ultima {
@@ -52,36 +49,6 @@ template<class uintX> SoftRenderSurface<uintX>::SoftRenderSurface(Graphics::Mana
 }
 
 
-//
-// SoftRenderSurface::SoftRenderSurface(int w, int h, int bpp, int rsft, int gsft, int bsft)
-//
-// Desc: Create a Generic SoftRenderSurface
-//
-template<class uintX> SoftRenderSurface<uintX>::SoftRenderSurface(int w, int h, int bpp, int rsft, int gsft, int bsft, int asft)
-	: BaseSoftRenderSurface(w, h, bpp, rsft, gsft, bsft, asft) {
-}
-
-
-//
-// SoftRenderSurface::SoftRenderSurface(int w, int h)
-//
-// Desc: Create a Generic surface that matches current screen parameters
-//
-template<class uintX> SoftRenderSurface<uintX>::SoftRenderSurface(int w, int h, uint8 *buf)
-	: BaseSoftRenderSurface(w, h, buf) {
-}
-
-
-//
-// SoftRenderSurface::SoftRenderSurface(int w, int h)
-//
-// Desc: Create a Render to texture surface
-//
-template<class uintX> SoftRenderSurface<uintX>::SoftRenderSurface(int w, int h)
-	: BaseSoftRenderSurface(w, h) {
-}
-
-
 //
 // SoftRenderSurface::Fill32(uint32 rgb, int32 sx, int32 sy, int32 w, int32 h)
 //
@@ -265,106 +232,30 @@ template<class uintX> void SoftRenderSurface<uintX>::DrawLine32(uint32 rgb, int3
 
 
 //
-// SoftRenderSurface::Blit(Texture *, int32 sx, int32 sy, int32 w, int32 h, int32 dx, int32 dy, bool alpha_blend)
+// SoftRenderSurface::Blit(Graphics::ManagedSurface *, int32 sx, int32 sy, int32 w, int32 h, int32 dx, int32 dy, bool alpha_blend)
 //
 // Desc: Blit a region from a Texture (Alpha == 0 -> skipped)
 //
-template<class uintX> void SoftRenderSurface<uintX>::Blit(const Texture *_tex, int32 sx, int32 sy, int32 w, int32 h, int32 dx, int32 dy, bool alpha_blend) {
-	// Clamp or wrap or return?
-	if (sx + w > static_cast<int32>(_tex->w))
-		return;
-
-	// Clamp or wrap or return?
-	if (sy + h > static_cast<int32>(_tex->h))
-		return;
-
-	if (sx < 0 || sy < 0)
-		return;
-
-	// Clip to window
-	int px = dx, py = dy;
-	Rect rect(dx, dy, dx + w, dy + h);
-	rect.clip(_clipWindow);
-	dx = rect.left;
-	dy = rect.top;
-	w = rect.width();
-	h = rect.height();
-
-	if (!w || !h) return;
-
-	// Adjust source x and y
-	if (px != dx) sx += dx - px;
-	if (py != dy) sy += dy - py;
-
-	uint8 *pixel = _pixels + dy * _pitch + dx * sizeof(uintX);
-	uint8 *line_end = pixel + w * sizeof(uintX);
-	uint8 *end = pixel + h * _pitch;
-	int diff = _pitch - w * sizeof(uintX);
-
-	if (_tex->_format == TEX_FMT_STANDARD) {
-		uint32 *texel = (uint32 *)_tex->getBasePtr(sx, sy);
-		int tex_diff = _tex->w - w;
-
-		while (pixel != end) {
-			if (!alpha_blend) while (pixel != line_end) {
-					if (*texel & TEX32_A_MASK) {
-						*(reinterpret_cast<uintX *>(pixel)) = static_cast<uintX>(PACK_RGB8(TEX32_R(*texel), TEX32_G(*texel), TEX32_B(*texel)));
-					}
-					pixel += sizeof(uintX);
-					texel++;
-				}
-			else while (pixel != line_end) {
-					uint32 alpha = *texel & TEX32_A_MASK;
-					if (alpha == 0xFF) {
-						*(reinterpret_cast<uintX *>(pixel)) = static_cast<uintX>(PACK_RGB8(TEX32_R(*texel), TEX32_G(*texel), TEX32_B(*texel)));
-					} else if (alpha) {
-						uintX *dest = reinterpret_cast<uintX *>(pixel);
-						*dest = static_cast<uintX>(BlendPreModFast(*texel, *dest));
-					}
-					pixel += sizeof(uintX);
-					texel++;
-				}
-
-			line_end += _pitch;
-			pixel += diff;
-			texel += tex_diff;
-		}
-	} else if (_tex->_format == TEX_FMT_NATIVE) {
-		const uintX *texel = reinterpret_cast<const uintX *>(_tex->getBasePtr(sx, sy));
-		int tex_diff = _tex->w - w;
-
-		while (pixel != end) {
-			while (pixel != line_end) {
-				// Uh, not supported right now
-				//if (*texel & RenderSurface::a_mask)
-				{
-					*(reinterpret_cast<uintX *>(pixel)) = *texel;
-				}
-				pixel += sizeof(uintX);
-				texel++;
-			}
-
-			line_end += _pitch;
-			pixel += diff;
-			texel += tex_diff;
-		}
-	}
-
+template<class uintX> void SoftRenderSurface<uintX>::Blit(const Graphics::ManagedSurface *tex, int32 sx, int32 sy, int32 w, int32 h, int32 dx, int32 dy, bool alpha_blend) {
+	Common::Rect srect = Common::Rect(sx, sy, sx + w, sy + h);
+	Common::Point dpoint = Common::Point(_ox + dx, _oy + dy);
+	_surface->blitFrom(*tex, srect, dpoint);
 }
 
 
 //
-// void SoftRenderSurface::FadedBlit(Texture *, int32 sx, int32 sy, int32 w, int32 h, int32 dx, int32 dy, uint32 col32)
+// void SoftRenderSurface::FadedBlit(Graphics::ManagedSurface *, int32 sx, int32 sy, int32 w, int32 h, int32 dx, int32 dy, uint32 col32)
 //
 // Desc: Blit a region from a Texture (Alpha == 0 -> skipped)
 //
-template<class uintX> void SoftRenderSurface<uintX>::FadedBlit(const Texture *_tex, int32 sx, int32 sy, int32 w, int32 h, int32 dx, int32 dy, uint32 col32, bool alpha_blend) {
+template<class uintX> void SoftRenderSurface<uintX>::FadedBlit(const Graphics::ManagedSurface *tex, int32 sx, int32 sy, int32 w, int32 h, int32 dx, int32 dy, uint32 col32, bool alpha_blend) {
+
 	// Clamp or wrap or return?
-	if (w > static_cast<int32>(_tex->w))
+	if (w > static_cast<int32>(tex->w))
 		return;
 
 	// Clamp or wrap or return?
-	if (h > static_cast<int32>(_tex->h))
+	if (h > static_cast<int32>(tex->h))
 		return;
 
 	// Clip to window
@@ -394,9 +285,11 @@ template<class uintX> void SoftRenderSurface<uintX>::FadedBlit(const Texture *_t
 	uint32 g = (TEX32_G(col32) * a);
 	uint32 b = (TEX32_B(col32) * a);
 
-	if (_tex->_format == TEX_FMT_STANDARD) {
-		uint32 *texel = (uint32 *)_tex->getBasePtr(sx, sy);
-		int tex_diff = _tex->w - w;
+	const Graphics::PixelFormat &texformat = tex->rawSurface().format;
+
+	if (texformat.bpp() == 32) {
+		const uint32 *texel = static_cast<const uint32 *>(tex->getBasePtr(sx, sy));
+		int tex_diff = tex->w - w;
 
 		while (pixel != end) {
 			if (!alpha_blend) while (pixel != line_end) {
@@ -411,7 +304,7 @@ template<class uintX> void SoftRenderSurface<uintX>::FadedBlit(const Texture *_t
 					}
 					pixel += sizeof(uintX);
 					texel++;
-				}
+			}
 			else while (pixel != line_end) {
 					uint32 alpha = *texel & TEX32_A_MASK;
 					if (alpha == 0xFF) {
@@ -446,9 +339,9 @@ template<class uintX> void SoftRenderSurface<uintX>::FadedBlit(const Texture *_t
 			pixel += diff;
 			texel += tex_diff;
 		}
-	} else if (_tex->_format == TEX_FMT_NATIVE) {
-		const uintX *texel = reinterpret_cast<const uintX *>(_tex->getBasePtr(sx, sy));
-		int tex_diff = _tex->w - w;
+	} else if (texformat == _format) {
+		const uintX *texel = reinterpret_cast<const uintX *>(tex->getBasePtr(sx, sy));
+		int tex_diff = tex->w - w;
 
 		while (pixel != end) {
 			while (pixel != line_end) {
@@ -465,23 +358,25 @@ template<class uintX> void SoftRenderSurface<uintX>::FadedBlit(const Texture *_t
 			pixel += diff;
 			texel += tex_diff;
 		}
+	} else {
+		error("FadedBlit not supported from %d bpp to %d bpp", texformat.bpp(), _format.bpp());
 	}
 }
 
 
 //
-// void SoftRenderSurface::MaskedBlit(Texture *, int32 sx, int32 sy, int32 w, int32 h, int32 dx, int32 dy, uint32 col32, bool alpha_blend=false)
+// void SoftRenderSurface::MaskedBlit(Graphics::ManagedSurface *, int32 sx, int32 sy, int32 w, int32 h, int32 dx, int32 dy, uint32 col32, bool alpha_blend=false)
 //
 // Desc Blit a region from a Texture with a Colour blend masked based on DestAlpha (AlphaTex == 0 || AlphaDest == 0 -> skipped. AlphaCol32 -> Blend Factors)
 //
 //
-template<class uintX> void SoftRenderSurface<uintX>::MaskedBlit(const Texture *_tex, int32 sx, int32 sy, int32 w, int32 h, int32 dx, int32 dy, uint32 col32, bool alpha_blend) {
+template<class uintX> void SoftRenderSurface<uintX>::MaskedBlit(const Graphics::ManagedSurface *tex, int32 sx, int32 sy, int32 w, int32 h, int32 dx, int32 dy, uint32 col32, bool alpha_blend) {
 	// Clamp or wrap or return?
-	if (w > static_cast<int32>(_tex->w))
+	if (w > static_cast<int32>(tex->w))
 		return;
 
 	// Clamp or wrap or return?
-	if (h > static_cast<int32>(_tex->h))
+	if (h > static_cast<int32>(tex->h))
 		return;
 
 	// Clip to window
@@ -512,9 +407,11 @@ template<class uintX> void SoftRenderSurface<uintX>::MaskedBlit(const Texture *_
 	uint32 g = (TEX32_G(col32) * a);
 	uint32 b = (TEX32_B(col32) * a);
 
-	if (_tex->_format == TEX_FMT_STANDARD) {
-		uint32 *texel = (uint32 *)_tex->getBasePtr(sx, sy);
-		int tex_diff = _tex->w - w;
+	int texbpp = tex->rawSurface().format.bpp();
+
+	if (texbpp == 32) {
+		const uint32 *texel = static_cast<const uint32 *>(tex->getBasePtr(sx, sy));
+		int tex_diff = tex->w - w;
 
 		while (pixel != end) {
 			if (!alpha_blend) {
@@ -573,9 +470,9 @@ template<class uintX> void SoftRenderSurface<uintX>::MaskedBlit(const Texture *_
 			pixel += diff;
 			texel += tex_diff;
 		}
-	} else if (_tex->_format == TEX_FMT_NATIVE) {
-		const uintX *texel = reinterpret_cast<const uintX *>(_tex->getBasePtr(sx, sy));
-		int tex_diff = _tex->w - w;
+	} else if (texbpp == _format.bpp()) {
+		const uintX *texel = reinterpret_cast<const uintX *>(tex->getBasePtr(sx, sy));
+		int tex_diff = tex->w - w;
 
 		while (pixel != end) {
 			while (pixel != line_end) {
@@ -594,55 +491,12 @@ template<class uintX> void SoftRenderSurface<uintX>::MaskedBlit(const Texture *_
 			pixel += diff;
 			texel += tex_diff;
 		}
+	} else {
+		error("unsupported texture format %d bpp", texbpp);
 	}
 }
 
 
-
-//
-// void SoftRenderSurface::StretchBlit(Texture *, int32 sx, int32 sy, int32 sw, int32 sh, int32 dx, int32 dy, int32 dw, int32 dh, bool clampedges)
-//
-// Desc: Blit a region from a Texture, and arbitrarily stretch it to fit the dest region
-//
-//
-template<class uintX> void SoftRenderSurface<uintX>::StretchBlit(const Texture *texture,
-        int32 sx, int32 sy, int32 sw, int32 sh,
-        int32 dx, int32 dy, int32 dw, int32 dh,
-        bool clampedges) {
-	// Nothing we can do
-	if ((sh <= 0) || (dh <= 0) || (sw <= 0) || (dw <= 0)) return;
-
-	// 1x No scaling needed
-	if (dw == sw && sh == dh) {
-		Blit(texture, sw, sy, sw, sh, dx, dy);
-		return;
-	}
-
-	uint8 *pixel = _pixels + dy * _pitch + dx * sizeof(uintX);
-	Ultima8Engine::get_instance()->point_scaler.Scale(texture, sx, sy, sw, sh, pixel, dw, dh, _pitch, clampedges);
-}
-
-//
-// bool SoftRenderSurface::ScalerBlit(Texture *texure, int32 sx, int32 sy, int32 sw, int32 sh, int32 dx, int32 dy, int32 dw, int32 dh, const Scaler *scaler, bool clampedges)
-//
-// Desc: Blit a region from a Texture using a scaler
-//
-//
-template<class uintX> bool SoftRenderSurface<uintX>::ScalerBlit(const Texture *texture, int32 sx, int32 sy, int32 sw, int32 sh, int32 dx, int32 dy, int32 dw, int32 dh, const Scaler *scaler, bool clampedges) {
-	// Nothing we can do
-	if ((sh <= 0) || (dh <= 0) || (sw <= 0) || (dw <= 0)) return false;
-
-	// 1x No scaling needed (but still do it anyway, could be a filter????)
-	if (dw == sw && sh == dh) {
-		Blit(texture, sw, sy, sw, sh, dx, dy);
-		return true;
-	}
-
-	uint8 *pixel = _pixels + dy * _pitch + dx * sizeof(uintX);
-
-	return scaler->Scale(texture, sx, sy, sw, sh, pixel, dw, dh, _pitch, clampedges);
-}
-
 //
 // void SoftRenderSurface::Paint(Shape*s, uint32 framenum, int32 x, int32 y)
 //
diff --git a/engines/ultima/ultima8/graphics/soft_render_surface.h b/engines/ultima/ultima8/graphics/soft_render_surface.h
index 38a583e72e..42428b179d 100644
--- a/engines/ultima/ultima8/graphics/soft_render_surface.h
+++ b/engines/ultima/ultima8/graphics/soft_render_surface.h
@@ -35,20 +35,10 @@ namespace Ultima8 {
 // Desc: The class for software rendering in Pentagram
 //
 template<class uintX> class SoftRenderSurface : public BaseSoftRenderSurface {
-protected:
-	// Create Generic surface
-	SoftRenderSurface(int w, int h, int bpp, int rsft, int gsft, int bsft, int asft);
-
 public:
 
 	// Create from a managed surface
-	SoftRenderSurface(Graphics::ManagedSurface *);
-
-	// Create a Generic surface that matches current screen parameters
-	SoftRenderSurface(int w, int h, uint8 *buf);
-
-	// Create a Render to texture surface
-	SoftRenderSurface(int w, int h);
+	SoftRenderSurface(Graphics::ManagedSurface *managed);
 
 	//
 	// Surface Filling
@@ -109,19 +99,13 @@ public:
 	//
 
 	// Blit a region from a Texture (Alpha == 0 -> skipped)
-	void Blit(const Texture *, int32 sx, int32 sy, int32 w, int32 h, int32 dx, int32 dy, bool alpha_blend = false) override;
+	void Blit(const Graphics::ManagedSurface *, int32 sx, int32 sy, int32 w, int32 h, int32 dx, int32 dy, bool alpha_blend = false) override;
 
 	// Blit a region from a Texture with a Colour blend (AlphaTex == 0 -> skipped. AlphaCol32 -> Blend Factors)
-	void FadedBlit(const Texture *, int32 sx, int32 sy, int32 w, int32 h, int32 dx, int32 dy, uint32 col32, bool alpha_blend = false) override;
+	void FadedBlit(const Graphics::ManagedSurface *, int32 sx, int32 sy, int32 w, int32 h, int32 dx, int32 dy, uint32 col32, bool alpha_blend = false) override;
 
 	// Blit a region from a Texture with a Colour blend masked based on DestAlpha (AlphaTex == 0 || AlphaDest == 0 -> skipped. AlphaCol32 -> Blend Factors)
-	void MaskedBlit(const Texture *, int32 sx, int32 sy, int32 w, int32 h, int32 dx, int32 dy, uint32 col32, bool alpha_blend = false) override;
-
-	// Blit a stretched region from a Texture (Alpha == 0 -> skipped)
-	void StretchBlit(const Texture *, int32 sx, int32 sy, int32 sw, int32 sh, int32 dx, int32 dy, int32 dw, int32 dh, bool clampedges = false) override;
-
-	// Blit a region from a Texture using a scaler
-	bool ScalerBlit(const Texture *, int32 sx, int32 sy, int32 sw, int32 sh, int32 dx, int32 dy, int32 dw, int32 dh, const Scaler *, bool clampedges = false) override;
+	void MaskedBlit(const Graphics::ManagedSurface *, int32 sx, int32 sy, int32 w, int32 h, int32 dx, int32 dy, uint32 col32, bool alpha_blend = false) override;
 };
 
 } // End of namespace Ultima8
diff --git a/engines/ultima/ultima8/graphics/soft_render_surface.inl b/engines/ultima/ultima8/graphics/soft_render_surface.inl
index 93cc0725d6..1e345837bb 100644
--- a/engines/ultima/ultima8/graphics/soft_render_surface.inl
+++ b/engines/ultima/ultima8/graphics/soft_render_surface.inl
@@ -191,6 +191,8 @@ const int32 neg = (FLIP_CONDITIONAL)?-1:0;
 	x -= XNEG(frame->_xoff);
 	y -= frame->_yoff;
 
+	assert(_pixels && srcpixels && srcmask);
+
 	for (int i = 0; i < height_; i++)  {
 		int line = y + i;
 
diff --git a/engines/ultima/ultima8/graphics/texture.cpp b/engines/ultima/ultima8/graphics/texture.cpp
deleted file mode 100644
index e36810ee26..0000000000
--- a/engines/ultima/ultima8/graphics/texture.cpp
+++ /dev/null
@@ -1,152 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
-
-#include "ultima/ultima8/misc/pent_include.h"
-#include "ultima/ultima8/graphics/texture.h"
-#include "ultima/ultima8/graphics/texture_bitmap.h"
-#include "ultima/ultima8/graphics/texture_targa.h"
-#include "ultima/ultima8/graphics/texture_png.h"
-#include "ultima/ultima8/graphics/render_surface.h"
-
-namespace Ultima {
-namespace Ultima8 {
-
-
-Texture::Texture() : _format(TEX_FMT_STANDARD), _glTex(0),
-	_next(nullptr), _wlog2(-1), _hlog2(-1) {
-}
-
-//
-// Destructor
-//
-Texture::~Texture() {
-}
-
-//
-// Helper Macro for texture type detection
-//
-#define TRY_TYPE(TextureType)               \
-	tex = new TextureType();                    \
-	/* If read failed, delete the texture. */   \
-	if (!tex->Read(rs)) {                       \
-		delete tex;                             \
-		tex = nullptr;                          \
-	}                                           \
-	else {                                      \
-		/* Worked so return it */               \
-		return tex;                             \
-	}
-
-void Texture::create(uint16 width, uint16 height, TextureFormat textureFormat) {
-	_format = textureFormat;
-	create(width, height, (_format == TEX_FMT_NATIVE) ? RenderSurface::getPixelFormat() :
-		Texture::getPixelFormat());
-}
-
-//
-// Create a texture from a Data Source
-// (filename is used to help detection of type)
-//
-Texture *Texture::Create(Common::SeekableReadStream *rs, const char *filename) {
-	Texture *tex;
-
-	if (filename) {
-		// Looks like it's a PNG
-		if (Std::strstr(filename, ".png")) {
-			TRY_TYPE(TexturePNG);
-		}
-		// Looks like it's a BMP
-		if (Std::strstr(filename, ".bmp")) {
-			TRY_TYPE(TextureBitmap);
-		}
-		// Looks like it's a TGA
-		if (Std::strstr(filename, ".tga")) {
-			TRY_TYPE(TextureTarga);
-		}
-	}
-
-	// Now go through each type 1 by 1
-	TRY_TYPE(TexturePNG);
-	TRY_TYPE(TextureBitmap);
-	TRY_TYPE(TextureTarga);
-
-	// Couldn't find it
-	return nullptr;
-}
-
-void Texture::loadSurface(const Graphics::Surface *surf) {
-	assert(surf->format.bytesPerPixel == 2 || surf->format.bytesPerPixel == 4);
-	create(surf->w, surf->h, Texture::getPixelFormat());
-	this->_format = TEX_FMT_STANDARD;
-	this->_wlog2 = -1;
-	this->_hlog2 = -1;
-
-	// Repack RGBA
-	uint32 *buffer = (uint32 *)getPixels();
-	uint32 pixel, i = 0;
-	byte r, g, b, a;
-	for (int y = 0; y < surf->h; ++y) {
-		const byte *srcP = (const byte *)surf->getBasePtr(0, y);
-
-		for (int x = 0; x < surf->w; ++x, srcP += surf->format.bytesPerPixel) {
-			pixel = (surf->format.bytesPerPixel == 2) ? *((const uint16 *)srcP) : *((const uint32 *)srcP);
-			surf->format.colorToARGB(pixel, a, r, g, b);
-
-			buffer[i++] = (r << TEX32_R_SHIFT)
-				| (g << TEX32_G_SHIFT)
-				| (b << TEX32_B_SHIFT)
-				| (a << TEX32_A_SHIFT);
-		}
-	}
-}
-
-void Texture::loadSurface8Bit(const Graphics::Surface *surf, const byte *pal) {
-	assert(surf->format.bytesPerPixel == 1 && pal);
-	create(surf->w, surf->h, Texture::getPixelFormat());
-	this->_format = TEX_FMT_STANDARD;
-	this->_wlog2 = -1;
-	this->_hlog2 = -1;
-
-	// Repack RGBA
-	uint32 *buffer = (uint32 *)getPixels();
-	uint32 i = 0;
-	const byte a = 0xff;
-	for (int y = 0; y < surf->h; ++y) {
-		const byte *srcP = (const byte *)surf->getBasePtr(0, y);
-
-		for (int x = 0; x < surf->w; ++x, srcP++) {
-			const byte p = *srcP;
-			const byte r = pal[p*3+0];
-			const byte g = pal[p*3+1];
-			const byte b = pal[p*3+2];
-
-			buffer[i++] = (r << TEX32_R_SHIFT)
-				| (g << TEX32_G_SHIFT)
-				| (b << TEX32_B_SHIFT)
-				| (a << TEX32_A_SHIFT);
-		}
-	}
-}
-
-
-} // End of namespace Ultima8
-} // End of namespace Ultima
diff --git a/engines/ultima/ultima8/graphics/texture.h b/engines/ultima/ultima8/graphics/texture.h
index 694b9c8c96..4492e29244 100644
--- a/engines/ultima/ultima8/graphics/texture.h
+++ b/engines/ultima/ultima8/graphics/texture.h
@@ -59,91 +59,6 @@ namespace Ultima8 {
                                      (((g)>>8)<<TEX32_G_SHIFT)|\
                                      (((b)>>8)<<TEX32_B_SHIFT))
 
-// 64 Bit Texture bit operations
-#define TEX64_A_SHIFT           16
-#define TEX64_A_MASK            0xFFFF0000
-#define TEX64_A_MASK_H          0xFF000000
-
-#define TEX64_G_SHIFT           0
-#define TEX64_G_MASK            0x0000FFFF
-#define TEX64_G_MASK_H          0x0000FF00
-
-#define TEX64_B_SHIFT           16
-#define TEX64_B_MASK            0xFFFF0000
-#define TEX64_B_MASK_H          0xFF000000
-
-#define TEX64_R_SHIFT           0
-#define TEX64_R_MASK            0x0000FFFF
-#define TEX64_R_MASK_H          0x0000FF00
-
-enum TextureFormat {
-	TEX_FMT_STANDARD        = 0,    // Standard texture format as defined using Macros above
-	TEX_FMT_NATIVE          = 1     // The native format of the RenderSurface
-};
-
-
-//
-// Basic 32 Bit Texture
-//
-class Texture : public Graphics::ManagedSurface {
-public:
-	uint32          _format;
-
-	// Use CalcLOG2s to calculate these (can be -1 which indicates not log2)
-	int32           _wlog2;
-	int32           _hlog2;
-
-	// For OpenGL
-	uint32          _glTex;
-	Texture         *_next;
-
-	static Graphics::PixelFormat getPixelFormat() {
-		return Graphics::PixelFormat(4, 8, 8, 8, 8, TEX32_R_SHIFT, TEX32_G_SHIFT, TEX32_B_SHIFT, TEX32_A_SHIFT);
-	}
-
-	Texture();
-
-	virtual ~Texture();
-
-	void create(uint16 width, uint16 height) override {
-		Graphics::ManagedSurface::create(width, height);
-	}
-	void create(uint16 width, uint16 height, const Graphics::PixelFormat &pixelFormat) override {
-		Graphics::ManagedSurface::create(width, height, pixelFormat);
-	}
-	void create(ManagedSurface &surf, const Common::Rect &bounds) override {
-		Graphics::ManagedSurface::create(surf, bounds);
-	}
-	void create(uint16 width, uint16 height, TextureFormat textureFormat);
-
-	// Calc texture log2's
-	void CalcLOG2s() {
-		_wlog2 = -1;
-		_hlog2 = -1;
-		for (int i = 0; i < 32; i++) {
-			if (this->w == (1 << i))
-				_wlog2 = i;
-
-			if (this->h == (1 << i))
-				_hlog2 = i;
-		}
-	}
-
-	// Create a texture from a Data Source (filename is use to help detection of type)
-	static Texture *Create(Common::SeekableReadStream *rs, const char *filename = NULL);
-
-	// Loads the data from the passed surfcae
-	void loadSurface(const Graphics::Surface *surf);
-
-	// Load data from a passed 8bit surface
-	void loadSurface8Bit(const Graphics::Surface *surf, const byte *pal);
-protected:
-
-	// Read from a File. No filetype supported by this class
-	virtual bool Read(Common::SeekableReadStream *rs) {
-		return false;
-	}
-};
 
 } // End of namespace Ultima8
 } // End of namespace Ultima
diff --git a/engines/ultima/ultima8/graphics/texture_bitmap.cpp b/engines/ultima/ultima8/graphics/texture_bitmap.cpp
deleted file mode 100644
index f93455ab6e..0000000000
--- a/engines/ultima/ultima8/graphics/texture_bitmap.cpp
+++ /dev/null
@@ -1,47 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
-
-#include "ultima/ultima8/misc/pent_include.h"
-#include "ultima/ultima8/graphics/texture_bitmap.h"
-#include "ultima/ultima8/filesys/idata_source.h"
-#include "image/bmp.h"
-
-namespace Ultima {
-namespace Ultima8 {
-
-//
-// Read from a Data Source
-//
-bool TextureBitmap::Read(Common::SeekableReadStream *rs) {
-	Image::BitmapDecoder decoder;
-
-	if (!decoder.loadStream(*rs))
-		return false;
-
-	const Graphics::Surface *s = decoder.getSurface();
-	loadSurface(s);
-
-	return true;
-}
-
-} // End of namespace Ultima8
-} // End of namespace Ultima
diff --git a/engines/ultima/ultima8/graphics/texture_bitmap.h b/engines/ultima/ultima8/graphics/texture_bitmap.h
deleted file mode 100644
index d26393c28c..0000000000
--- a/engines/ultima/ultima8/graphics/texture_bitmap.h
+++ /dev/null
@@ -1,42 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
-
-#ifndef ULTIMA8_GRAPHICS_TEXTUREBITMAP_H
-#define ULTIMA8_GRAPHICS_TEXTUREBITMAP_H
-
-#include "ultima/ultima8/graphics/texture.h"
-
-namespace Ultima {
-namespace Ultima8 {
-
-// container structure for bitmaps .BMP file
-struct TextureBitmap : public Texture {
-	TextureBitmap() : Texture() {}
-
-	// False on Error
-	bool Read(Common::SeekableReadStream *rs) override;
-};
-
-} // End of namespace Ultima8
-} // End of namespace Ultima
-
-#endif
diff --git a/engines/ultima/ultima8/graphics/texture_png.cpp b/engines/ultima/ultima8/graphics/texture_png.cpp
deleted file mode 100644
index a17145ee64..0000000000
--- a/engines/ultima/ultima8/graphics/texture_png.cpp
+++ /dev/null
@@ -1,45 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
-
-#include "ultima/ultima8/misc/pent_include.h"
-#include "ultima/ultima8/graphics/texture_png.h"
-#include "ultima/ultima8/filesys/idata_source.h"
-#include "image/png.h"
-#include "graphics/surface.h"
-
-namespace Ultima {
-namespace Ultima8 {
-
-bool TexturePNG::Read(Common::SeekableReadStream *rs) {
-	Image::PNGDecoder decoder;
-
-	if (!decoder.loadStream(*rs))
-		return false;
-
-	const Graphics::Surface *s = decoder.getSurface();
-	loadSurface(s);
-
-	return true;
-}
-
-} // End of namespace Ultima8
-} // End of namespace Ultima
diff --git a/engines/ultima/ultima8/graphics/texture_png.h b/engines/ultima/ultima8/graphics/texture_png.h
deleted file mode 100644
index cd9df3fdf4..0000000000
--- a/engines/ultima/ultima8/graphics/texture_png.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
-
-#ifndef ULTIMA8_GRAPHICS_TEXTUREPNG_H
-#define ULTIMA8_GRAPHICS_TEXTUREPNG_H
-
-#include "ultima/ultima8/graphics/texture.h"
-
-namespace Ultima {
-namespace Ultima8 {
-// container structure for graphics read from a PNG file
-struct TexturePNG : public Texture {
-	TexturePNG() : Texture() {}
-
-	// False on Error
-	bool Read(Common::SeekableReadStream *rs) override;
-};
-
-} // End of namespace Ultima8
-} // End of namespace Ultima
-
-#endif
diff --git a/engines/ultima/ultima8/graphics/texture_targa.cpp b/engines/ultima/ultima8/graphics/texture_targa.cpp
deleted file mode 100644
index d549d419ee..0000000000
--- a/engines/ultima/ultima8/graphics/texture_targa.cpp
+++ /dev/null
@@ -1,44 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
-
-#include "ultima/ultima8/misc/pent_include.h"
-#include "ultima/ultima8/graphics/texture_targa.h"
-#include "ultima/ultima8/filesys/idata_source.h"
-#include "image/tga.h"
-
-namespace Ultima {
-namespace Ultima8 {
-
-bool TextureTarga::Read(Common::SeekableReadStream *rs) {
-	Image::TGADecoder decoder;
-
-	if (!decoder.loadStream(*rs))
-		return false;
-
-	const Graphics::Surface *s = decoder.getSurface();
-	loadSurface(s);
-
-	return true;
-}
-
-} // End of namespace Ultima8
-} // End of namespace Ultima
diff --git a/engines/ultima/ultima8/graphics/texture_targa.h b/engines/ultima/ultima8/graphics/texture_targa.h
deleted file mode 100644
index 05f9d4ad1a..0000000000
--- a/engines/ultima/ultima8/graphics/texture_targa.h
+++ /dev/null
@@ -1,44 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
-
-#ifndef ULTIMA8_GRAPHICS_TEXTURETARGA_H
-#define ULTIMA8_GRAPHICS_TEXTURETARGA_H
-
-#include "ultima/ultima8/graphics/texture.h"
-
-namespace Ultima {
-namespace Ultima8 {
-
-struct TGA;
-
-// container structure for bitmaps .BMP file
-struct TextureTarga : public Texture {
-	TextureTarga() : Texture() {}
-
-	// False on Error
-	bool Read(Common::SeekableReadStream *rs) override;
-};
-
-} // End of namespace Ultima8
-} // End of namespace Ultima
-
-#endif
diff --git a/engines/ultima/ultima8/gumps/credits_gump.cpp b/engines/ultima/ultima8/gumps/credits_gump.cpp
index bd098daaf4..9648d704ed 100644
--- a/engines/ultima/ultima8/gumps/credits_gump.cpp
+++ b/engines/ultima/ultima8/gumps/credits_gump.cpp
@@ -172,7 +172,6 @@ void CreditsGump::run() {
 
 	if (_state == CS_PLAYING && available <= 160) {
 		// time to render next block
-
 		_scroll[nextblock]->Fill32(0xFF000000, 0, 0, 256, 200);
 		// _scroll[nextblock]->Fill32(0xFFFFFFFF,0,0,256,5); // block marker
 		_scrollHeight[nextblock] = 0;
@@ -352,22 +351,20 @@ void CreditsGump::PaintThis(RenderSurface *surf, int32 lerp_factor, bool scaled)
 	if (_title)
 		_title->draw(surf, 64, 34);
 
-	Texture *tex = _scroll[_currentSurface]->GetSurfaceAsTexture();
 	int h = _scrollHeight[_currentSurface] - _currentY;
 	if (h > 156) h = 156;
 	if (h > 0)
-		surf->Blit(tex, 0, _currentY, 256, h, 32, 44);
+		surf->Blit(_scroll[_currentSurface]->getRawSurface(), 0, _currentY, 256, h, 32, 44);
 
 	int y = h;
 	for (int i = 1; i < 4; i++) {
 		if (h == 156) break;
 
 		int s = (_currentSurface + i) % 4;
-		tex = _scroll[s]->GetSurfaceAsTexture();
 		h = _scrollHeight[s];
 		if (h > 156 - y) h = 156 - y;
 		if (h > 0)
-			surf->Blit(tex, 0, 0, 256, h, 32, 44 + y);
+			surf->Blit(_scroll[s]->getRawSurface(), 0, 0, 256, h, 32, 44 + y);
 		y += h;
 	}
 }
diff --git a/engines/ultima/ultima8/gumps/gump.cpp b/engines/ultima/ultima8/gumps/gump.cpp
index 93b08bb6e5..72f3b137a5 100644
--- a/engines/ultima/ultima8/gumps/gump.cpp
+++ b/engines/ultima/ultima8/gumps/gump.cpp
@@ -30,7 +30,6 @@
 #include "ultima/ultima8/gumps/gump_notify_process.h"
 #include "ultima/ultima8/kernel/kernel.h"
 #include "ultima/ultima8/kernel/object_manager.h"
-#include "ultima/ultima8/gumps/scaler_gump.h"
 #include "ultima/ultima8/ultima8.h"
 
 namespace Ultima {
diff --git a/engines/ultima/ultima8/gumps/inverter_gump.cpp b/engines/ultima/ultima8/gumps/inverter_gump.cpp
index c415dc14ed..10583bcca4 100644
--- a/engines/ultima/ultima8/gumps/inverter_gump.cpp
+++ b/engines/ultima/ultima8/gumps/inverter_gump.cpp
@@ -100,15 +100,13 @@ void InverterGump::PaintChildren(RenderSurface *surf, int32 lerp_factor, bool sc
 
 	DesktopGump::PaintChildren(_buffer, lerp_factor, scaled);
 
-	Texture *tex = _buffer->GetSurfaceAsTexture();
-
 	// now invert-blit _buffer to screen
 	int t = (state * height) / 0x10000;
 
 	for (int i = 0; i < height; ++i) {
 		int src = getLine(getIndex(i, height / 2) + t, height / 2);
 //		pout << src << " -> " << i << Std::endl;
-		surf->Blit(tex, 0, src, width, 1, 0, i);
+		surf->Blit(_buffer->getRawSurface(), 0, src, width, 1, 0, i);
 	}
 }
 
diff --git a/engines/ultima/ultima8/gumps/item_relative_gump.cpp b/engines/ultima/ultima8/gumps/item_relative_gump.cpp
index 44f66b05b3..4b9e32ae89 100644
--- a/engines/ultima/ultima8/gumps/item_relative_gump.cpp
+++ b/engines/ultima/ultima8/gumps/item_relative_gump.cpp
@@ -62,7 +62,7 @@ void ItemRelativeGump::MoveOnScreen() {
 	_x = 0;
 	_y = 0;
 
-	// get rectangle that gump occupies in scalerGump's coordinate space
+	// get rectangle that gump occupies in desktops's coordinate space
 	int32 left, right, top, bottom;
 	left = -_dims.left;
 	right = left + _dims.width();
diff --git a/engines/ultima/ultima8/gumps/minimap_gump.cpp b/engines/ultima/ultima8/gumps/minimap_gump.cpp
index 66f3efba16..0a743d9aa6 100644
--- a/engines/ultima/ultima8/gumps/minimap_gump.cpp
+++ b/engines/ultima/ultima8/gumps/minimap_gump.cpp
@@ -38,12 +38,14 @@ namespace Ultima8 {
 
 DEFINE_RUNTIME_CLASSTYPE_CODE(MiniMapGump)
 
+
+static const int MINMAPGUMP_SCALE = 8;
+
 MiniMapGump::MiniMapGump(int x, int y) :
 	Gump(x, y, MAP_NUM_CHUNKS * 2 + 2, MAP_NUM_CHUNKS * 2 + 2, 0,
 	     FLAG_DRAGGABLE, LAYER_NORMAL), _minimap(), _lastMapNum(0) {
-	_minimap._format = TEX_FMT_NATIVE;
-	_minimap.create((MAP_NUM_CHUNKS * MINMAPGUMP_SCALE), (MAP_NUM_CHUNKS * MINMAPGUMP_SCALE),
-		TEX_FMT_NATIVE);
+	_minimap = Graphics::ManagedSurface((MAP_NUM_CHUNKS * MINMAPGUMP_SCALE), (MAP_NUM_CHUNKS * MINMAPGUMP_SCALE),
+										RenderSurface::getPixelFormat());
 }
 
 MiniMapGump::MiniMapGump() : Gump() , _lastMapNum(0){
@@ -62,12 +64,12 @@ void MiniMapGump::setPixelAt(int x, int y, uint32 pixel) {
 	}
 }
 
-uint32 MiniMapGump::getPixelAt(int x, int y) {
+uint32 MiniMapGump::getPixelAt(int x, int y) const {
 	if (_minimap.format.bytesPerPixel == 2) {
-		uint16 *buf = (uint16 *)_minimap.getBasePtr(x, y);
+		const uint16 *buf = (const uint16 *)_minimap.getBasePtr(x, y);
 		return *buf;
 	} else {
-		uint32 *buf = (uint32 *)_minimap.getBasePtr(x, y);
+		const uint32 *buf = (const uint32 *)_minimap.getBasePtr(x, y);
 		return *buf;
 	}
 }
@@ -82,11 +84,13 @@ void MiniMapGump::PaintThis(RenderSurface *surf, int32 lerp_factor, bool scaled)
 		_lastMapNum = currentmap->getNum();
 	}
 
+	// Draw the yellow border
 	surf->Fill32(0xFFFFAF00, 0, 0, MAP_NUM_CHUNKS * 2 + 3, 1);
 	surf->Fill32(0xFFFFAF00, 0, 1, 1, MAP_NUM_CHUNKS * 2 + 1);
 	surf->Fill32(0xFFFFAF00, 1, MAP_NUM_CHUNKS * 2 + 1, MAP_NUM_CHUNKS * 2 + 1, 1);
 	surf->Fill32(0xFFFFAF00, MAP_NUM_CHUNKS * 2 + 1, 1, 1, MAP_NUM_CHUNKS * 2 + 1);
 
+	// Draw into the map surface
 	for (int yv = 0; yv < MAP_NUM_CHUNKS; yv++) {
 		for (int xv = 0; xv < MAP_NUM_CHUNKS; xv++) {
 			if (currentmap->isChunkFast(xv, yv)) {
@@ -204,7 +208,7 @@ bool MiniMapGump::loadData(Common::ReadStream *rs, uint32 version) {
 		return false;
 
 	_lastMapNum = 0;
-	_minimap.create(MAP_NUM_CHUNKS * MINMAPGUMP_SCALE, MAP_NUM_CHUNKS * MINMAPGUMP_SCALE, TEX_FMT_NATIVE);
+	_minimap.create(MAP_NUM_CHUNKS * MINMAPGUMP_SCALE, MAP_NUM_CHUNKS * MINMAPGUMP_SCALE, RenderSurface::getPixelFormat());
 
 	return true;
 }
diff --git a/engines/ultima/ultima8/gumps/minimap_gump.h b/engines/ultima/ultima8/gumps/minimap_gump.h
index 93efb93079..4cc5929225 100644
--- a/engines/ultima/ultima8/gumps/minimap_gump.h
+++ b/engines/ultima/ultima8/gumps/minimap_gump.h
@@ -31,14 +31,12 @@
 namespace Ultima {
 namespace Ultima8 {
 
-#define MINMAPGUMP_SCALE 8
-
 class MiniMapGump : public Gump {
 private:
-	Texture             _minimap;
+	Graphics::ManagedSurface _minimap;
 	unsigned int        _lastMapNum;
 
-	uint32 getPixelAt(int x, int y);
+	uint32 getPixelAt(int x, int y) const;
 	void setPixelAt(int x, int y, uint32 pixel);
 	uint32 sampleAtPoint(int x, int y, CurrentMap *map);
 public:
diff --git a/engines/ultima/ultima8/gumps/scaler_gump.cpp b/engines/ultima/ultima8/gumps/scaler_gump.cpp
deleted file mode 100644
index 40862dccbd..0000000000
--- a/engines/ultima/ultima8/gumps/scaler_gump.cpp
+++ /dev/null
@@ -1,249 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
-
-#include "ultima/ultima8/misc/pent_include.h"
-#include "ultima/ultima8/gumps/scaler_gump.h"
-
-#include "ultima/ultima8/graphics/render_surface.h"
-#include "ultima/ultima8/graphics/texture.h"
-#include "ultima/ultima8/graphics/scaler.h"
-#include "ultima/ultima8/conf/setting_manager.h"
-#include "ultima/ultima8/ultima8.h"
-
-namespace Ultima {
-namespace Ultima8 {
-
-DEFINE_RUNTIME_CLASSTYPE_CODE(ScalerGump)
-
-ScalerGump::ScalerGump(int32 x, int32 y, int32 width, int32 height) :
-		DesktopGump(x, y, width, height),
-		_swidth1(width), _sheight1(height),
-		_scaler1(nullptr), _buffer1(nullptr),
-		_swidth2(width), _sheight2(height),
-		_scaler2(nullptr), _buffer2(nullptr),
-		_width(width), _height(height) {
-
-	setupScaling();
-	if (_buffer1)
-		_buffer1->Fill32(0, 0, 0, _dims.width(), _dims.height());
-}
-
-ScalerGump::~ScalerGump() {
-	FORGET_OBJECT(_buffer1);
-	FORGET_OBJECT(_buffer2);
-}
-
-void ScalerGump::Paint(RenderSurface *surf, int32 lerp_factor, bool scaled) {
-	// Skip the clipping rect/origin setting, since they will already be set
-	// correctly by our parent.
-	// (Or maybe I'm just to lazy to figure out the correct coordinates
-	//  to use to compensate for the flipping... -wjp :-) )
-
-	// Don't paint if hidden
-	if (IsHidden()) return;
-
-	// No scaling or filtering
-	if (!_buffer1) {
-		PaintChildren(surf, lerp_factor, scaled);
-		return;
-	}
-
-	// Render to texture
-	_buffer1->BeginPainting();
-	PaintChildren(_buffer1, lerp_factor, true);
-	_buffer1->EndPainting();
-
-	if (!_buffer2) {
-		DoScalerBlit(_buffer1->GetSurfaceAsTexture(), _swidth1, _sheight1, surf, _width, _height, _scaler1);
-	} else {
-		_buffer2->BeginPainting();
-		DoScalerBlit(_buffer1->GetSurfaceAsTexture(), _swidth1, _sheight1, _buffer2, _swidth2, _sheight2, _scaler1);
-		_buffer2->EndPainting();
-
-		DoScalerBlit(_buffer2->GetSurfaceAsTexture(), _swidth2, _sheight2, surf, _width, _height, _scaler2);
-	}
-
-	int32 scalex = (_width << 16) / _swidth1;
-	int32 scaley = (_height << 16) / _sheight1;
-
-	// Iterate all children
-	Std::list<Gump *>::reverse_iterator it = _children.rbegin();
-	Std::list<Gump *>::reverse_iterator end = _children.rend();
-
-	while (it != end) {
-		Gump *g = *it;
-		// Paint if not closing
-		if (!g->IsClosing())
-			g->PaintCompositing(surf, lerp_factor, scalex, scaley);
-
-		++it;
-	}
-}
-
-void ScalerGump::DoScalerBlit(Texture *src, int swidth, int sheight, RenderSurface *dest, int dwidth, int dheight, const Scaler *scaler) {
-	bool ok = true;
-
-	// Cheap and nasty method to use a 2x scaler to do a 2.4x scale vertically
-	if (dwidth == 640 && swidth == 320 && dheight == 480 && sheight == 200 && !scaler->ScaleArbitrary()) {
-		ok = dest->ScalerBlit(src, 0, 0, swidth, 1, 0, 0, dwidth, 2, scaler);
-
-		int d = 1, s = 0;
-		while (d < 468 && ok) {
-			ok = dest->ScalerBlit(src, 0, s, swidth, 3, 0, d, dwidth, 6, scaler);
-			d += 5;
-			s += 2;
-
-			if (!ok) break;
-
-			ok = dest->ScalerBlit(src, 0, s, swidth, 4, 0, d, dwidth, 8, scaler);
-			d += 7;
-			s += 3;
-		}
-
-		while (d < 478 && ok) {
-			ok = dest->ScalerBlit(src, 0, s, swidth, 3, 0, d, dwidth, 6, scaler);
-			d += 5;
-			s += 2;
-		}
-	} else {
-		ok = dest->ScalerBlit(src, 0, 0, swidth, sheight, 0, 0, dwidth, dheight, scaler);
-	}
-
-	if (!ok) {
-		dest->StretchBlit(src, 0, 0, swidth, sheight, 0, 0, dwidth, dheight);
-	}
-}
-
-// Convert a parent relative point to a gump point
-void ScalerGump::ParentToGump(int32 &px, int32 &py, PointRoundDir r) {
-	px -= _x;
-	px *= _dims.width();
-	if (px < 0 && r == ROUND_TOPLEFT) px -= (_width - 1);
-	if (px > 0 && r == ROUND_BOTTOMRIGHT) px += (_width - 1);
-	px /= _width;
-
-	py -= _y;
-	py *= _dims.height();
-	if (py < 0 && r == ROUND_TOPLEFT) py -= (_height - 1);
-	if (py > 0 && r == ROUND_BOTTOMRIGHT) py += (_height - 1);
-	py /= _height;
-}
-
-// Convert a gump point to parent relative point
-void ScalerGump::GumpToParent(int32 &gx, int32 &gy, PointRoundDir r) {
-	gx *= _width;
-	if (gx < 0 && r == ROUND_TOPLEFT) gx -= (_dims.width() - 1);
-	if (gx > 0 && r == ROUND_BOTTOMRIGHT) gx += (_dims.width() - 1);
-	gx /= _dims.width();
-	gx += _x;
-
-	gy *= _height;
-	if (gy < 0 && r == ROUND_TOPLEFT) gy -= (_dims.height() - 1);
-	if (gy > 0 && r == ROUND_BOTTOMRIGHT) gy += (_dims.height() - 1);
-	gy /= _dims.height();
-	gy += _y;
-}
-
-void ScalerGump::RenderSurfaceChanged() {
-	// Resize the gump to match the RenderSurface
-	Rect new_dims;
-	_parent->GetDims(new_dims);
-
-	_width = new_dims.width();
-	_height = new_dims.height();
-
-	setupScaling();
-
-	Gump::RenderSurfaceChanged();
-}
-
-void ScalerGump::setupScaling() {
-	FORGET_OBJECT(_buffer1);
-	FORGET_OBJECT(_buffer2);
-
-	if (CoreApp::get_instance()->getGameInfo() && GAME_IS_U8) {
-		_swidth1 = Ultima8Engine::U8_DEFAULT_SCREEN_WIDTH;
-		_sheight1 = Ultima8Engine::U8_DEFAULT_SCREEN_HEIGHT;
-	} else {
-		_swidth1 = Ultima8Engine::CRUSADER_DEFAULT_SCREEN_WIDTH;
-		_sheight1 = Ultima8Engine::CRUSADER_DEFAULT_SCREEN_HEIGHT;
-	}
-	_swidth2 = 0;
-	_sheight2 = 0;
-	const Scaler *point = &Ultima8Engine::get_instance()->point_scaler;
-	_scaler1 = _scaler2 = point;
-
-	if (_swidth1 < 0) _swidth1 = -_swidth1;
-	else if (_swidth1 == 0) _swidth1 = _width;
-	else if (_swidth1 < 100) _swidth1 = _width / _swidth1;
-
-	if (_sheight1 < 0) _sheight1 = -_sheight1;
-	else if (_sheight1 == 0) _sheight1 = _height;
-	else if (_sheight1 < 100) _sheight1 = _height / _sheight1;
-
-	if (_swidth2 < 0) _swidth2 = -_swidth2;
-	else if (_swidth2 != 0 && _swidth2 < 100) _swidth2 = _width / _swidth2;
-
-	if (_sheight2 < 0) _sheight2 = -_sheight2;
-	else if (_sheight2 != 0 && _sheight2 < 100) _sheight2 = _height / _sheight2;
-
-	_dims.setWidth(_swidth1);
-	_dims.setHeight(_sheight1);
-
-	// We don't care, we are not going to support filters, at least not at the moment
-	if (_swidth1 == _width && _sheight1 == _height) return;
-
-	_buffer1 = RenderSurface::CreateSecondaryRenderSurface(_swidth1, _sheight1);
-
-	// _scaler2's factor isn't set so auto detect
-	if (_swidth2 == 0 || _sheight2 == 0) {
-		// scaler 1 is arbitrary so _scaler2 not required
-		if (_scaler1->ScaleArbitrary()) return;
-
-		_swidth2 = _swidth1 * 32;
-		_sheight2 = _sheight1 * 32;
-		for (int i = 31; i >= 0; i--) {
-			if (_scaler1->ScaleBits() & (1 << i)) {
-				if (_swidth2 > _width || _sheight2 > _height) {
-					_swidth2 = _swidth1 * i;
-					_sheight2 = _sheight1 * i;
-				}
-			}
-		}
-	}
-
-	// _scaler2 is required
-	if (_swidth2 != _width || _sheight2 != _height) {
-		// Well almost, in this situation we code in DoScalerBlit to do this for us
-		// _scaler2 not required
-		if (_width == 640 && _height == 480 &&
-		        _swidth2 == 640 && _sheight2 == 400 &&
-		        _swidth1 == 320 && _sheight1 == 200) {
-			return;
-		}
-
-		_buffer2 = RenderSurface::CreateSecondaryRenderSurface(_swidth2, _sheight2);
-	}
-}
-
-} // End of namespace Ultima8
-} // End of namespace Ultima
diff --git a/engines/ultima/ultima8/gumps/scaler_gump.h b/engines/ultima/ultima8/gumps/scaler_gump.h
deleted file mode 100644
index a35d971ab9..0000000000
--- a/engines/ultima/ultima8/gumps/scaler_gump.h
+++ /dev/null
@@ -1,91 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
-
-#ifndef ULTIMA8_GUMPS_SCALERGUMP_H
-#define ULTIMA8_GUMPS_SCALERGUMP_H
-
-#include "ultima/ultima8/gumps/desktop_gump.h"
-#include "ultima/shared/std/containers.h"
-#include "ultima/ultima8/misc/p_dynamic_cast.h"
-
-namespace Ultima {
-namespace Ultima8 {
-
-class RenderSurface;
-class Texture;
-class Scaler;
-
-/**
- * A virtual gump which scales the contents for display.  Mostly unused since import to scummvm.
- * TODO: Look into removing this entirely.
- */
-class ScalerGump : public DesktopGump {
-public:
-	ENABLE_RUNTIME_CLASSTYPE()
-
-	//! ScalerGump constructor
-	//! \param x x coordinate of our top-left corner in parent
-	//! \param y y coordinate
-	//! \param width width after scaling (usually screenwidth)
-	//! \param height height after scaling (usually screenheight)
-	//! \param swidth1 width before scaling (usually game-width)
-	//! \param sheight1 height before scaling (usually game-height)
-	//! \param scaler1 scaler to use
-	ScalerGump(int32 x, int32 y, int32 width, int32 height);
-	~ScalerGump() override;
-
-	void Paint(RenderSurface *surf, int32 lerp_factor, bool scaled) override;
-	void RenderSurfaceChanged() override;
-	void ParentToGump(int32 &px, int32 &py,
-	                          PointRoundDir r = ROUND_TOPLEFT) override;
-	void GumpToParent(int32 &gx, int32 &gy,
-	                          PointRoundDir r = ROUND_TOPLEFT) override;
-
-	void GetScaledSize(int32 &sw, int32 &sh) const {
-		sw = _swidth1;
-		sh = _sheight1;
-	}
-
-protected:
-	int _swidth1;
-	int _sheight1;
-	const Scaler *_scaler1;
-	RenderSurface *_buffer1;
-
-	int _swidth2;
-	int _sheight2;
-	const Scaler *_scaler2;
-	RenderSurface *_buffer2;
-
-	int32 _width;
-	int32 _height;
-
-private:
-	void setupScaling();
-
-	void DoScalerBlit(Texture *src, int swidth, int sheight, RenderSurface *dest, int dwidth, int dheight, const Scaler *scaler);
-};
-
-} // End of namespace Ultima8
-} // End of namespace Ultima
-
-#endif
diff --git a/engines/ultima/ultima8/kernel/mouse.cpp b/engines/ultima/ultima8/kernel/mouse.cpp
index eb9997592b..f1977d505e 100644
--- a/engines/ultima/ultima8/kernel/mouse.cpp
+++ b/engines/ultima/ultima8/kernel/mouse.cpp
@@ -40,7 +40,7 @@ namespace Ultima8 {
 
 Mouse *Mouse::_instance = nullptr;
 
-Mouse::Mouse() : _flashingCursorTime(0), _mouseOverGump(0), _defaultMouse(nullptr),
+Mouse::Mouse() : _flashingCursorTime(0), _mouseOverGump(0),
 		_dragging(DRAG_NOT), _dragging_objId(0), _draggingItem_startGump(0),
 		_draggingItem_lastGump(0) {
 	_instance = this;
@@ -51,14 +51,6 @@ Mouse::~Mouse() {
 }
 
 void Mouse::setup() {
-	FileSystem *filesys = FileSystem::get_instance();
-	Common::SeekableReadStream *dm = filesys->ReadFile("@data/mouse.tga");
-	_defaultMouse = dm ? Texture::Create(dm, "@data/mouse.tga") : 0;
-
-	if (!_defaultMouse)
-		error("Unable to load '@data/mouse.tga'");
-
-	delete dm;
 	pushMouseCursor();
 }
 
@@ -547,18 +539,15 @@ void Mouse::paint() {
 	RenderSurface *screen = Ultima8Engine::get_instance()->getRenderScreen();
 	GameData *gamedata = GameData::get_instance();
 
-	if (gamedata) {
-		Shape *mouse = gamedata->getMouse();
-		if (mouse) {
-			int frame = getMouseFrame();
-			if (frame >= 0) {
-				screen->Paint(mouse, frame, _mousePos.x, _mousePos.y, true);
-			} else if (frame == -2)
-				screen->Blit(_defaultMouse, 0, 0, _defaultMouse->w, _defaultMouse->h, _mousePos.x, _mousePos.y);
+	if (!gamedata)
+		return;
+
+	const Shape *mouse = gamedata->getMouse();
+	if (mouse) {
+		int frame = getMouseFrame();
+		if (frame >= 0) {
+			screen->Paint(mouse, frame, _mousePos.x, _mousePos.y, true);
 		}
-	} else {
-		if (getMouseFrame() != -1)
-			screen->Blit(_defaultMouse, 0, 0, _defaultMouse->w, _defaultMouse->h, _mousePos.x, _mousePos.y);
 	}
 }
 
diff --git a/engines/ultima/ultima8/kernel/mouse.h b/engines/ultima/ultima8/kernel/mouse.h
index 28d8427a9c..5331039b04 100644
--- a/engines/ultima/ultima8/kernel/mouse.h
+++ b/engines/ultima/ultima8/kernel/mouse.h
@@ -104,7 +104,6 @@ public:
 private:
 	static Mouse *_instance;
 	Common::Stack<MouseCursor> _cursors;
-	Texture *_defaultMouse;      //!< Default Pentagram mouse for when there is no GameData
 
 	/**
 	 * Time mouse started flashing, or 0
diff --git a/engines/ultima/ultima8/misc/debugger.cpp b/engines/ultima/ultima8/misc/debugger.cpp
index bf5480e7d0..a628a995b3 100644
--- a/engines/ultima/ultima8/misc/debugger.cpp
+++ b/engines/ultima/ultima8/misc/debugger.cpp
@@ -30,6 +30,7 @@
 #include "ultima/ultima8/filesys/file_system.h"
 #include "ultima/ultima8/filesys/raw_archive.h"
 #include "ultima/ultima8/graphics/inverter_process.h"
+#include "ultima/ultima8/graphics/render_surface.h"
 #include "ultima/ultima8/gumps/fast_area_vis_gump.h"
 #include "ultima/ultima8/gumps/game_map_gump.h"
 #include "ultima/ultima8/gumps/minimap_gump.h"
@@ -828,9 +829,6 @@ bool Debugger::cmdDumpMap(int argc, const char **argv) {
 	RenderSurface *s = RenderSurface::CreateSecondaryRenderSurface(bwidth,
 		bheight);
 
-	Texture *t = s->GetSurfaceAsTexture();
-	//t->clear();
-
 	debugPrintf("Rendering map...\n");
 
 	// Now render the map
@@ -878,9 +876,9 @@ bool Debugger::cmdDumpMap(int argc, const char **argv) {
 	bool result = dumpFile.open(filename);
 	if (result) {
 #ifdef USE_PNG
-		result = Image::writePNG(dumpFile, *t);
+		result = Image::writePNG(dumpFile, *(s->getRawSurface()));
 #else
-		result = Image::writeBMP(dumpFile, *t);
+		result = Image::writeBMP(dumpFile, *(s->getRawSurface()));
 #endif
 	}
 
diff --git a/engines/ultima/ultima8/misc/memset_n.h b/engines/ultima/ultima8/misc/memset_n.h
deleted file mode 100644
index 9e41ce3a5a..0000000000
--- a/engines/ultima/ultima8/misc/memset_n.h
+++ /dev/null
@@ -1,111 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
-
-//
-// memset_n is a set of optimized functions for filling buffers of
-// 16 and 32 bit integers
-//
-
-#ifndef ULTIMA8_MISC_MEMSET_N_H
-#define ULTIMA8_MISC_MEMSET_N_H
-
-namespace Ultima {
-namespace Ultima8 {
-
-//
-// Generic memset_32
-//
-// Can be used by all
-//
-inline void memset_32_aligned(void *buf, uint32 val, uint32 dwords) {
-	do {
-		*reinterpret_cast<uint32 *>(buf) = val;
-		buf = (reinterpret_cast<uint32 *>(buf)) + 1;
-	} while (--dwords);
-}
-
-//
-// memset_32
-//
-// Can be used by all
-//
-inline void memset_32(void *buf, uint32 val, uint32 dwords) {
-	// Fisrly we should dword Align it
-	int align = 0;
-	if (reinterpret_cast<uintptr>(buf) & 3) {
-		align = 4;
-		dwords--;
-
-		// Ok, shift along by 1 byte
-		if ((reinterpret_cast<uintptr>(buf) & 1)) {
-			*reinterpret_cast<uint8 *>(buf) = static_cast<uint8>(val & 0xFF);
-			buf = (reinterpret_cast<uint8 *>(buf)) + 1;
-			val = ((val & 0xFF) << 24) | ((val & 0xFFFFFF00) >> 8);
-			align --;
-		}
-
-		// Ok, shift along by 2 bytes
-		if ((reinterpret_cast<uintptr>(buf) & 2)) {
-			*reinterpret_cast<uint16 *>(buf) = static_cast<uint16>(val & 0xFFFF);
-			buf = (reinterpret_cast<uint16 *>(buf)) + 1;
-			val = ((val & 0xFFFF) << 16) | ((val & 0xFFFF0000) >> 16);
-			align -= 2;
-		}
-	}
-
-	// Fill Aligned
-	if (dwords) memset_32_aligned(buf, val, dwords);
-
-	// Do the unaligned data
-	if (align) {
-		buf = (reinterpret_cast<uint8 *>(buf)) + dwords * 4;
-		// Ok, shift along by 1 byte
-		if (align == 1) {
-			*reinterpret_cast<uint8 *>(buf) = static_cast<uint8>(val & 0xFF);
-		}
-		// Ok, shift along by 2 bytes
-		else {
-			*reinterpret_cast<uint16 *>(buf) = static_cast<uint16>(val & 0xFFFF);
-
-			// Ok, shift along by another byte
-			if (align & 1) *(reinterpret_cast<uint8 *>(buf) + 2) = static_cast<uint8>((val >> 16) & 0xFF);
-		}
-	}
-}
-
-//
-// memset_16
-//
-// Can be used by all
-//
-inline void memset_16(void *buf, int32 val, uint32 words) {
-	// Use memset_32
-	if (words > 1) memset_32(buf, val | val << 16, words>>1);
-
-	// Final word
-	if (words & 1) *(reinterpret_cast<uint16 *>(buf) + (words - 1)) = static_cast<uint16>(val & 0xFFFF);
-}
-
-} // End of namespace Ultima8
-} // End of namespace Ultima
-
-#endif
diff --git a/engines/ultima/ultima8/ultima8.cpp b/engines/ultima/ultima8/ultima8.cpp
index bc524eea30..63bdc4f200 100644
--- a/engines/ultima/ultima8/ultima8.cpp
+++ b/engines/ultima/ultima8/ultima8.cpp
@@ -42,7 +42,6 @@
 #include "ultima/ultima8/graphics/fonts/font_manager.h"
 #include "ultima/ultima8/graphics/render_surface.h"
 #include "ultima/ultima8/graphics/texture.h"
-#include "ultima/ultima8/graphics/fonts/fixed_width_font.h"
 #include "ultima/ultima8/graphics/palette_manager.h"
 #include "ultima/ultima8/graphics/palette.h"
 #include "ultima/ultima8/games/game_data.h"
@@ -56,7 +55,6 @@
 #include "ultima/ultima8/gumps/desktop_gump.h"
 #include "ultima/ultima8/gumps/game_map_gump.h"
 #include "ultima/ultima8/gumps/inverter_gump.h"
-#include "ultima/ultima8/gumps/scaler_gump.h"
 #include "ultima/ultima8/gumps/fast_area_vis_gump.h"
 #include "ultima/ultima8/gumps/minimap_gump.h"
 #include "ultima/ultima8/gumps/quit_gump.h"
@@ -157,9 +155,8 @@ Ultima8Engine::Ultima8Engine(OSystem *syst, const Ultima::UltimaGameDescription
 		_frameSkip(false), _frameLimit(true), _interpolate(true), _animationRate(100),
 		_avatarInStasis(false), _paintEditorItems(false), _inversion(0), _painting(false),
 		_showTouching(false), _timeOffset(0), _hasCheated(false), _cheatsEnabled(false),
-		_ttfOverrides(false), _audioMixer(0), _scalerGump(nullptr),
-		_inverterGump(nullptr), _lerpFactor(256), _inBetweenFrame(false),
-		_unkCrusaderFlag(false), _moveKeyFrame(0) {
+		_ttfOverrides(false), _audioMixer(0), _inverterGump(nullptr), _lerpFactor(256),
+		_inBetweenFrame(false), _unkCrusaderFlag(false), _moveKeyFrame(0) {
 	_application = this;
 }
 
@@ -439,7 +436,6 @@ void Ultima8Engine::shutdownGame(bool reloading) {
 
 	_desktopGump = nullptr;
 	_gameMapGump = nullptr;
-	_scalerGump = nullptr;
 	_inverterGump = nullptr;
 
 	_timeOffset = -(int32)Kernel::get_instance()->getFrameNum();
@@ -461,15 +457,8 @@ void Ultima8Engine::shutdownGame(bool reloading) {
 		_desktopGump->MakeFocus();
 
 		if (GAME_IS_U8) {
-			debugN(MM_INFO, "Creating _scalerGump...\n");
-			_scalerGump = new ScalerGump(0, 0, dims.width(), dims.height());
-			_scalerGump->InitGump(0);
-
-			Rect scaled_dims;
-			_scalerGump->GetDims(scaled_dims);
-
 			debugN(MM_INFO, "Creating Inverter...\n");
-			_inverterGump = new InverterGump(0, 0, scaled_dims.width(), scaled_dims.height());
+			_inverterGump = new InverterGump(0, 0, dims.width(), dims.height());
 			_inverterGump->InitGump(0);
 		}
 	}
@@ -690,33 +679,12 @@ void Ultima8Engine::GraphicSysInit() {
 	debugN(MM_INFO, "Loading Default Mouse Cursor...\n");
 	_mouse->setup();
 
-	Std::string alt_confont;
-	bool confont_loaded = false;
-
-	if (_settingMan->get("console_font", alt_confont)) {
-		debugN(MM_INFO, "Alternate console font found...\n");
-		confont_loaded = LoadConsoleFont(alt_confont);
-	}
-
-	if (!confont_loaded) {
-		debugN(MM_INFO, "Loading default console font...\n");
-		if (!LoadConsoleFont("@data/fixedfont.ini")) {
-			error("Failed to load console font. Exiting");
-		}
-	}
-
 	_desktopGump = new DesktopGump(0, 0, width, height);
 	_desktopGump->InitGump(0);
 	_desktopGump->MakeFocus();
 
 	if (GAME_IS_U8) {
-		_scalerGump = new ScalerGump(0, 0, width, height);
-		_scalerGump->InitGump(0);
-
-		Rect scaled_dims;
-		_scalerGump->GetDims(scaled_dims);
-
-		_inverterGump = new InverterGump(0, 0, scaled_dims.width(), scaled_dims.height());
+		_inverterGump = new InverterGump(0, 0, width, height);
 		_inverterGump->InitGump(0);
 	}
 
@@ -757,19 +725,6 @@ void Ultima8Engine::changeVideoMode(int width, int height) {
 	GraphicSysInit();
 }
 
-bool Ultima8Engine::LoadConsoleFont(Std::string confontini) {
-	// try to load the file
-	debugN(MM_INFO, "Loading console font config: %s... ", confontini.c_str());
-	if (_configFileMan->readConfigFile(confontini, "confont", true))
-		pout << "Ok" << Std::endl;
-	else {
-		pout << "Failed" << Std::endl;
-		return false;
-	}
-
-	return true;
-}
-
 void Ultima8Engine::enterTextMode(Gump *gump) {
 	if (!_textModes.empty()) {
 		_textModes.remove(gump->getObjId());
@@ -1075,7 +1030,6 @@ void Ultima8Engine::resetEngine() {
 	// Reset thet gumps
 	_desktopGump = nullptr;
 	_gameMapGump = nullptr;
-	_scalerGump = nullptr;
 	_inverterGump = nullptr;
 
 	_textModes.clear();
@@ -1104,34 +1058,22 @@ void Ultima8Engine::setupCoreGumps() {
 	_desktopGump->MakeFocus();
 
 	if (GAME_IS_U8) {
-		debugN(MM_INFO, "Creating ScalerGump...\n");
-		_scalerGump = new ScalerGump(0, 0, dims.width(), dims.height());
-		_scalerGump->InitGump(0);
-
-		Rect scaled_dims;
-		_scalerGump->GetDims(scaled_dims);
-
 		debugN(MM_INFO, "Creating Inverter...\n");
-		_inverterGump = new InverterGump(0, 0, scaled_dims.width(), scaled_dims.height());
+		_inverterGump = new InverterGump(0, 0, dims.width(), dims.height());
 		_inverterGump->InitGump(0);
-
-		debugN(MM_INFO, "Creating GameMapGump...\n");
-		_gameMapGump = new GameMapGump(0, 0, scaled_dims.width(), scaled_dims.height());
-		_gameMapGump->InitGump(0);
-	} else {
-		_gameMapGump = new GameMapGump(0, 0, dims.width(), dims.height());
-		_gameMapGump->InitGump(0);
 	}
+	debugN(MM_INFO, "Creating GameMapGump...\n");
+	_gameMapGump = new GameMapGump(0, 0, dims.width(), dims.height());
+	_gameMapGump->InitGump(0);
 
 	// TODO: clean this up
 	if (GAME_IS_U8) {
 		assert(_desktopGump->getObjId() == 256);
-		assert(_scalerGump->getObjId() == 257);
-		assert(_inverterGump->getObjId() == 258);
-		assert(_gameMapGump->getObjId() == 259);
+		assert(_inverterGump->getObjId() == 257);
+		assert(_gameMapGump->getObjId() == 258);
 	}
 
-	for (uint16 i = 261; i < 384; ++i)
+	for (uint16 i = 259; i < 384; ++i)
 		_objectManager->reserveObjId(i);
 }
 
@@ -1374,7 +1316,7 @@ void Ultima8Engine::addGump(Gump *gump) {
 	assert(_desktopGump);
 
 	if (dynamic_cast<ShapeViewerGump *>(gump) || dynamic_cast<MiniMapGump *>(gump) ||
-		dynamic_cast<ScalerGump *>(gump) || dynamic_cast<MessageBoxGump *>(gump)// ||
+		dynamic_cast<MessageBoxGump *>(gump)// ||
 		//(_ttfOverrides && (dynamic_cast<BarkGump *>(gump) ||
 		//                dynamic_cast<AskGump *>(gump)))
 		) {
@@ -1385,13 +1327,10 @@ void Ultima8Engine::addGump(Gump *gump) {
 		else
 			_desktopGump->AddChild(gump);
 	} else if (dynamic_cast<InverterGump *>(gump)) {
-		_scalerGump->AddChild(gump);
+		_desktopGump->AddChild(gump);
 	} else if (dynamic_cast<DesktopGump *>(gump)) {
 	} else {
-		if (GAME_IS_U8)
-			_scalerGump->AddChild(gump);
-		else
-			_desktopGump->AddChild(gump);
+		_desktopGump->AddChild(gump);
 	}
 }
 
diff --git a/engines/ultima/ultima8/ultima8.h b/engines/ultima/ultima8/ultima8.h
index 4cdd197249..c35bacb480 100644
--- a/engines/ultima/ultima8/ultima8.h
+++ b/engines/ultima/ultima8/ultima8.h
@@ -43,7 +43,6 @@
 #include "ultima/ultima8/kernel/core_app.h"
 #include "ultima/ultima8/kernel/mouse.h"
 #include "ultima/ultima8/misc/p_dynamic_cast.h"
-#include "ultima/ultima8/graphics/point_scaler.h"
 #include "common/events.h"
 
 namespace Ultima {
@@ -56,7 +55,6 @@ class Game;
 class Gump;
 class GameMapGump;
 class MenuGump;
-class ScalerGump;
 class InverterGump;
 class RenderSurface;
 class PaletteManager;
@@ -96,7 +94,6 @@ private:
 
 	Gump *_desktopGump;
 	GameMapGump *_gameMapGump;
-	ScalerGump *_scalerGump;
 	InverterGump *_inverterGump;
 	AvatarMoverProcess *_avatarMoverProcess;
 
@@ -155,7 +152,6 @@ private:
 
 	// called depending upon command line arguments
 	void GraphicSysInit(); // starts/restarts the graphics subsystem
-	bool LoadConsoleFont(Std::string confontini); // loads the console font
 
 	void handleDelayedEvents();
 protected:
@@ -168,8 +164,7 @@ protected:
 	 * Returns the data archive folder and version that's required
 	 */
 	bool isDataRequired(Common::String &folder, int &majorVersion, int &minorVersion) override;
-public:
-	PointScaler point_scaler;
+
 public:
 	Ultima8Engine(OSystem *syst, const Ultima::UltimaGameDescription *gameDesc);
 	~Ultima8Engine() override;
diff --git a/test/engines/ultima/ultima8/misc/memset_n.h b/test/engines/ultima/ultima8/misc/memset_n.h
deleted file mode 100644
index a633f100e2..0000000000
--- a/test/engines/ultima/ultima8/misc/memset_n.h
+++ /dev/null
@@ -1,95 +0,0 @@
-#include <cxxtest/TestSuite.h>
-#include "engines/ultima/ultima8/misc/memset_n.h"
-
-/**
- * Test suite for the functions in engines/ultima/ultima8/misc/memset_n.h
- */
-
-class U8MemsetTestSuite : public CxxTest::TestSuite {
-
-	static const uint32 VAL32 = 0xDEADBEEF;
-	static const uint32 VAL16 = 0xFEED;
-
-	uint8 buffer[256];
-
-	public:
-	U8MemsetTestSuite() {
-	}
-
-	static uint32 uint32val(const uint8 *p) {
-		return *reinterpret_cast<const uint32 *>(p);
-	}
-
-	static uint16 uint16val(const uint8 *p) {
-		return *reinterpret_cast<const uint16 *>(p);
-	}
-
-	void clear_buffer() {
-		memset(buffer, 0, 256);
-	}
-
-	void test_memset_32() {
-		// Pointer with some padding so we can make sure it does the right
-		// thing at start and end of memory block
-		uint8 *b = buffer + 16;
-
-		// Check a few alignments to make sure it does the right thing
-		// Starting alignment is not important as we cycle through them all
-		for (int i = 0; i < 10; i++) {
-			b++;
-			clear_buffer();
-			Ultima::Ultima8::memset_32(b, VAL32, 1);
-			TS_ASSERT_EQUALS(uint32val(b), VAL32);
-			TS_ASSERT_EQUALS(uint32val(b+4), 0);
-			TS_ASSERT_EQUALS(uint32val(b-4), 0);
-
-			clear_buffer();
-			Ultima::Ultima8::memset_32(b, VAL32, 2);
-			TS_ASSERT_EQUALS(uint32val(b), VAL32);
-			TS_ASSERT_EQUALS(uint32val(b+4), VAL32);
-			TS_ASSERT_EQUALS(uint32val(b+8), 0);
-			TS_ASSERT_EQUALS(uint32val(b-4), 0);
-		}
-	}
-
-	void test_memset_16() {
-		// Pointer with some padding so we can make sure it does the right
-		// thing at start and end of memory block
-		uint8 *b = buffer + 16;
-
-		// Check a few alignments to make sure it does the right thing
-		// Starting alignment is not important as we cycle through them all
-		for (int i = 0; i < 10; i++) {
-			b++;
-			clear_buffer();
-			Ultima::Ultima8::memset_16(b, VAL16, 1);
-			TS_ASSERT_EQUALS(uint16val(b), VAL16);
-			TS_ASSERT_EQUALS(uint16val(b+2), 0);
-			TS_ASSERT_EQUALS(uint16val(b-2), 0);
-
-			clear_buffer();
-			Ultima::Ultima8::memset_16(b, VAL16, 2);
-			TS_ASSERT_EQUALS(uint16val(b), VAL16);
-			TS_ASSERT_EQUALS(uint16val(b+2), VAL16);
-			TS_ASSERT_EQUALS(uint16val(b+4), 0);
-			TS_ASSERT_EQUALS(uint16val(b-2), 0);
-
-			clear_buffer();
-			Ultima::Ultima8::memset_16(b, VAL16, 3);
-			TS_ASSERT_EQUALS(uint16val(b), VAL16);
-			TS_ASSERT_EQUALS(uint16val(b+2), VAL16);
-			TS_ASSERT_EQUALS(uint16val(b+4), VAL16);
-			TS_ASSERT_EQUALS(uint16val(b+6), 0);
-			TS_ASSERT_EQUALS(uint16val(b-2), 0);
-
-			clear_buffer();
-			Ultima::Ultima8::memset_16(b, VAL16, 4);
-			TS_ASSERT_EQUALS(uint16val(b), VAL16);
-			TS_ASSERT_EQUALS(uint16val(b+2), VAL16);
-			TS_ASSERT_EQUALS(uint16val(b+4), VAL16);
-			TS_ASSERT_EQUALS(uint16val(b+6), VAL16);
-			TS_ASSERT_EQUALS(uint16val(b+8), 0);
-			TS_ASSERT_EQUALS(uint16val(b-2), 0);
-		 }
-	}
-};




More information about the Scummvm-git-logs mailing list