[Scummvm-git-logs] scummvm master -> 7665bb150f088f46794b07944e522f7170674bf8

OMGPizzaGuy noreply at scummvm.org
Sat Dec 17 01:34:43 UTC 2022


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

Summary:
7665bb150f ULTIMA8: Eliminate static pixel format in render surface


Commit: 7665bb150f088f46794b07944e522f7170674bf8
    https://github.com/scummvm/scummvm/commit/7665bb150f088f46794b07944e522f7170674bf8
Author: Matthew Jimenez (matthew.jimenez at outlook.com)
Date: 2022-12-16T19:32:54-06:00

Commit Message:
ULTIMA8: Eliminate static pixel format in render surface

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


diff --git a/engines/ultima/ultima8/graphics/render_surface.cpp b/engines/ultima/ultima8/graphics/render_surface.cpp
index 3cfa8ebe569..e5877dbdecf 100644
--- a/engines/ultima/ultima8/graphics/render_surface.cpp
+++ b/engines/ultima/ultima8/graphics/render_surface.cpp
@@ -31,8 +31,6 @@
 namespace Ultima {
 namespace Ultima8 {
 
-Graphics::PixelFormat *RenderSurface::_format = nullptr;
-
 uint8 RenderSurface::_gamma10toGamma22[256];
 uint8 RenderSurface::_gamma22toGamma10[256];
 
@@ -44,19 +42,6 @@ RenderSurface::RenderSurface(Graphics::ManagedSurface *s) : _pixels(nullptr), _p
 	_clipWindow.setHeight(_height = _surface->h);
 	_pitch = _surface->pitch;
 
-	// TODO: Slight hack - set the global surface format only once.
-	if (!RenderSurface::_format->bytesPerPixel) {
-		RenderSurface::_format->bytesPerPixel = _surface->format.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->rShift = _surface->format.rShift;
-		RenderSurface::_format->gShift = _surface->format.gShift;
-		RenderSurface::_format->bShift = _surface->format.bShift;
-		RenderSurface::_format->aShift = _surface->format.aShift;
-	}
-
 	SetPixelsPointer();
 }
 
@@ -153,15 +138,16 @@ bool RenderSurface::EndPainting() {
 // Desc: Create a palette of colours native to the surface
 //
 void RenderSurface::CreateNativePalette(Palette *palette, int maxindex) {
+	const Graphics::PixelFormat &format = _surface->format;
 	if (maxindex == 0)
 		maxindex = 256;
 	for (int i = 0; i < maxindex; i++) {
 		int32 r, g, b;
 
 		// Normal palette
-		palette->_native_untransformed[i] = _format->RGBToColor(palette->_palette[i * 3 + 0],
-																palette->_palette[i * 3 + 1],
-																palette->_palette[i * 3 + 2]);
+		palette->_native_untransformed[i] = format.RGBToColor(palette->_palette[i * 3 + 0],
+															  palette->_palette[i * 3 + 1],
+															  palette->_palette[i * 3 + 2]);
 
 		r = palette->_matrix[0] * palette->_palette[i * 3 + 0] +
 			palette->_matrix[1] * palette->_palette[i * 3 + 1] +
@@ -192,9 +178,9 @@ void RenderSurface::CreateNativePalette(Palette *palette, int maxindex) {
 
 		// Transformed normal palette
 		// FIXME - Wont work on non SDL SRS Implementations
-		palette->_native[i] = _format->RGBToColor(static_cast<uint8>(r >> 11),
-												  static_cast<uint8>(g >> 11),
-												  static_cast<uint8>(b >> 11));
+		palette->_native[i] = format.RGBToColor(static_cast<uint8>(r >> 11),
+												static_cast<uint8>(g >> 11),
+												static_cast<uint8>(b >> 11));
 
 		// Transformed XFORM palette (Uses the TEX32 format)
 		if (TEX32_A(palette->_xform_untransformed[i])) {
@@ -340,8 +326,6 @@ bool RenderSurface::IsFlipped() const {
 //
 
 RenderSurface *RenderSurface::SetVideoMode(uint32 width, uint32 height, int bpp) {
-	_format = &Ultima8Engine::get_instance()->_renderFormat;
-
 	// Set up the pixel format to use
 	Graphics::PixelFormat pixelFormat;
 
@@ -376,13 +360,17 @@ RenderSurface *RenderSurface::SetVideoMode(uint32 width, uint32 height, int bpp)
 
 // Create a SecondaryRenderSurface with an associated Texture object
 RenderSurface *RenderSurface::CreateSecondaryRenderSurface(uint32 width, uint32 height) {
+	const Graphics::PixelFormat &format = Ultima8Engine::get_instance()->getScreen()->format;
+
 	// Now create the SoftRenderSurface
 	RenderSurface *surf;
 
 	// TODO: Change this
-	Graphics::ManagedSurface *managedSurface = new Graphics::ManagedSurface(width, height, *_format);
-	if (_format->bytesPerPixel == 4) surf = new SoftRenderSurface<uint32>(managedSurface);
-	else surf = new SoftRenderSurface<uint16>(managedSurface);
+	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 c26f823962b..29a7d52e4f0 100644
--- a/engines/ultima/ultima8/graphics/render_surface.h
+++ b/engines/ultima/ultima8/graphics/render_surface.h
@@ -70,8 +70,6 @@ protected:
 	void SetPixelsPointer();
 
 public:
-	static Graphics::PixelFormat *_format;
-
 	static uint8 _gamma10toGamma22[256];
 	static uint8 _gamma22toGamma10[256];
 
diff --git a/engines/ultima/ultima8/graphics/soft_render_surface.cpp b/engines/ultima/ultima8/graphics/soft_render_surface.cpp
index a9ba6316276..70481277a10 100644
--- a/engines/ultima/ultima8/graphics/soft_render_surface.cpp
+++ b/engines/ultima/ultima8/graphics/soft_render_surface.cpp
@@ -55,7 +55,7 @@ template<class uintX> SoftRenderSurface<uintX>::SoftRenderSurface(Graphics::Mana
 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);
-	rgb = _format->RGBToColor((rgb >> 16) & 0xFF , (rgb >> 8) & 0xFF , rgb & 0xFF);
+	rgb = _surface->format.RGBToColor((rgb >> 16) & 0xFF , (rgb >> 8) & 0xFF , rgb & 0xFF);
 	_surface->fillRect(Common::Rect(rect.left + _ox, rect.top + _oy, rect.right + _ox, rect.bottom + _oy), rgb);
 }
 
@@ -68,7 +68,8 @@ template<class uintX> void SoftRenderSurface<uintX>::Fill32(uint32 rgb, int32 sx
 //#define CHECK_ALPHA_FILLS
 
 template<class uintX> void SoftRenderSurface<uintX>::FillAlpha(uint8 alpha, int32 sx, int32 sy, int32 w, int32 h) {
-	uint32 aMask = _format->aMax() << _format->aShift;
+	const Graphics::PixelFormat &format = _surface->format;
+	uint32 aMask = format.aMax() << format.aShift;
 	Rect rect(sx, sy, sx + w, sy + h);
 	rect.clip(_clipWindow);
 	sx = rect.left;
@@ -91,17 +92,17 @@ template<class uintX> void SoftRenderSurface<uintX>::FillAlpha(uint8 alpha, int3
 	uint8 *line_end = pixel + w * sizeof(uintX);
 	int diff = _pitch - w * sizeof(uintX);
 
-	uintX a = (((uintX)alpha) << RenderSurface::_format->aShift) & aMask;
+	uintX a = (((uintX)alpha) << format.aShift) & aMask;
 
 #ifdef CHECK_ALPHA_FILLS
 	uintX c;
 	uintX m;
 	if (a == 0) {
-		c = (RenderSurface::_format->bMask >> 1)&RenderSurface::_format->bMask;
-		m = RenderSurface::_format->bMask;
+		c = (format.bMask >> 1)&format.bMask;
+		m = format.bMask;
 	} else {
-		c = (RenderSurface::_format->rMask >> 1)&RenderSurface::_format->rMask;
-		m = RenderSurface::_format->rMask;
+		c = (format.rMask >> 1)&format.rMask;
+		m = format.rMask;
 	}
 #endif
 
@@ -149,7 +150,8 @@ template<class uintX> void SoftRenderSurface<uintX>::FillBlended(uint32 rgba, in
 	uint8 *line_end = pixel + w * sizeof(uintX);
 	int diff = _pitch - w * sizeof(uintX);
 
-	uint32 aMask = _format->aMax() << _format->aShift;
+	const Graphics::PixelFormat &format = _surface->format;
+	uint32 aMask = format.aMax() << format.aShift;
 	int alpha = TEX32_A(rgba) + 1;
 	rgba = TEX32_PACK_RGBA16(TEX32_R(rgba) * alpha, TEX32_G(rgba) * alpha, TEX32_B(rgba) * alpha, 255 * alpha);
 
@@ -157,7 +159,7 @@ template<class uintX> void SoftRenderSurface<uintX>::FillBlended(uint32 rgba, in
 		while (pixel != line_end) {
 			uintX *dest = reinterpret_cast<uintX *>(pixel);
 			uintX d = *dest;
-			*dest = (d & aMask) | BlendPreModFast(rgba, d);
+			*dest = (d & aMask) | BlendPreModFast(rgba, d, format);
 			pixel += sizeof(uintX);
 		}
 
@@ -295,6 +297,7 @@ template<class uintX> void SoftRenderSurface<uintX>::FadedBlit(const Graphics::M
 	uint32 g = (TEX32_G(col32) * a);
 	uint32 b = (TEX32_B(col32) * a);
 
+	const Graphics::PixelFormat &format = _surface->format;
 	const Graphics::PixelFormat &texformat = src.rawSurface().format;
 
 	if (texformat.bpp() == 32) {
@@ -305,7 +308,7 @@ template<class uintX> void SoftRenderSurface<uintX>::FadedBlit(const Graphics::M
 			if (!alpha_blend) while (pixel != line_end) {
 					if (*texel & TEX32_A_MASK) {
 						*(reinterpret_cast<uintX *>(pixel)) = static_cast<uintX>(
-							_format->RGBToColor(
+							format.RGBToColor(
 								(TEX32_R(*texel) * ia + r) >> 8,
 								(TEX32_G(*texel) * ia + g) >> 8,
 								(TEX32_B(*texel) * ia + b) >> 8));
@@ -317,7 +320,7 @@ template<class uintX> void SoftRenderSurface<uintX>::FadedBlit(const Graphics::M
 					uint32 alpha = *texel & TEX32_A_MASK;
 					if (alpha == 0xFF) {
 						*(reinterpret_cast<uintX *>(pixel)) = static_cast<uintX>(
-							_format->RGBToColor(
+							format.RGBToColor(
 								(TEX32_R(*texel) * ia + r) >> 8,
 								(TEX32_G(*texel) * ia + g) >> 8,
 								(TEX32_B(*texel) * ia + b) >> 8));
@@ -326,7 +329,7 @@ template<class uintX> void SoftRenderSurface<uintX>::FadedBlit(const Graphics::M
 
 						uint32 Tsrc = *texel;
 						uint8 r2, g2, b2;
-						_format->colorToRGB(*dest, r2, g2, b2);
+						format.colorToRGB(*dest, r2, g2, b2);
 
 						uint32 dr = r2 * (256 - TEX32_A(Tsrc));
 						uint32 dg = g2 * (256 - TEX32_A(Tsrc));
@@ -335,7 +338,7 @@ template<class uintX> void SoftRenderSurface<uintX>::FadedBlit(const Graphics::M
 						dg += TEX32_G(Tsrc) * ia + ((g * TEX32_A(Tsrc)) >> 8);
 						db += TEX32_B(Tsrc) * ia + ((b * TEX32_A(Tsrc)) >> 8);
 
-						*dest = _format->RGBToColor(dr >> 8, dg >> 8, db >> 8);
+						*dest = format.RGBToColor(dr >> 8, dg >> 8, db >> 8);
 					}
 					pixel += sizeof(uintX);
 					texel++;
@@ -345,7 +348,7 @@ template<class uintX> void SoftRenderSurface<uintX>::FadedBlit(const Graphics::M
 			pixel += diff;
 			texel += tex_diff;
 		}
-	} else if (texformat == *_format) {
+	} else if (texformat == format) {
 		const uintX *texel = reinterpret_cast<const uintX *>(src.getBasePtr(sx, sy));
 		int tex_diff = src.w - w;
 
@@ -354,7 +357,7 @@ template<class uintX> void SoftRenderSurface<uintX>::FadedBlit(const Graphics::M
 				// Uh, not supported right now
 				//if (*texel & RenderSurface::a_mask)
 				{
-					*(reinterpret_cast<uintX *>(pixel)) = BlendHighlight(*texel, r, g, b, 1, ia);
+					*(reinterpret_cast<uintX *>(pixel)) = BlendHighlight(*texel, r, g, b, 1, ia, format);
 				}
 				pixel += sizeof(uintX);
 				texel++;
@@ -365,7 +368,7 @@ template<class uintX> void SoftRenderSurface<uintX>::FadedBlit(const Graphics::M
 			texel += tex_diff;
 		}
 	} else {
-		error("FadedBlit not supported from %d bpp to %d bpp", texformat.bpp(), _format->bpp());
+		error("FadedBlit not supported from %d bpp to %d bpp", texformat.bpp(), format.bpp());
 	}
 }
 
@@ -419,7 +422,8 @@ template<class uintX> void SoftRenderSurface<uintX>::MaskedBlit(const Graphics::
 	uint32 g = (TEX32_G(col32) * a);
 	uint32 b = (TEX32_B(col32) * a);
 
-	uint32 aMask = _format->aMax() << _format->aShift;
+	const Graphics::PixelFormat &format = _surface->format;
+	uint32 aMask = format.aMax() << format.aShift;
 	int texbpp = src.rawSurface().format.bpp();
 
 	if (texbpp == 32) {
@@ -434,7 +438,7 @@ template<class uintX> void SoftRenderSurface<uintX>::MaskedBlit(const Graphics::
 					if (*texel & TEX32_A_MASK) {
 						if (!aMask || (*dest & aMask)) {
 							*dest = static_cast<uintX>(
-								_format->RGBToColor(
+								format.RGBToColor(
 									(TEX32_R(*texel) * ia + r) >> 8,
 									(TEX32_G(*texel) * ia + g) >> 8,
 									(TEX32_B(*texel) * ia + b) >> 8));
@@ -451,14 +455,14 @@ template<class uintX> void SoftRenderSurface<uintX>::MaskedBlit(const Graphics::
 						uint32 alpha = *texel & TEX32_A_MASK;
 						if (alpha == 0xFF) {
 							*dest = static_cast<uintX>(
-								_format->RGBToColor(
+								format.RGBToColor(
 									(TEX32_R(*texel) * ia + r) >> 8,
 									(TEX32_G(*texel) * ia + g) >> 8,
 									(TEX32_B(*texel) * ia + b) >> 8));
 						} else if (alpha) {
 							uint32 Tsrc = *texel;
 							uint8 r2, g2, b2;
-							_format->colorToRGB(*dest, r2, g2, b2);
+							format.colorToRGB(*dest, r2, g2, b2);
 
 							uint32 dr = r2 * (256 - TEX32_A(Tsrc));
 							uint32 dg = g2 * (256 - TEX32_A(Tsrc));
@@ -467,7 +471,7 @@ template<class uintX> void SoftRenderSurface<uintX>::MaskedBlit(const Graphics::
 							dg += TEX32_G(Tsrc) * ia + ((g * TEX32_A(Tsrc)) >> 8);
 							db += TEX32_B(Tsrc) * ia + ((b * TEX32_A(Tsrc)) >> 8);
 
-							*dest = _format->RGBToColor(dr >> 8, dg >> 8, db >> 8);
+							*dest = format.RGBToColor(dr >> 8, dg >> 8, db >> 8);
 						}
 					}
 					pixel += sizeof(uintX);
@@ -479,7 +483,7 @@ template<class uintX> void SoftRenderSurface<uintX>::MaskedBlit(const Graphics::
 			pixel += diff;
 			texel += tex_diff;
 		}
-	} else if (texbpp == _format->bpp()) {
+	} else if (texbpp == format.bpp()) {
 		const uintX *texel = reinterpret_cast<const uintX *>(src.getBasePtr(sx, sy));
 		int tex_diff = src.w - w;
 
@@ -488,9 +492,9 @@ template<class uintX> void SoftRenderSurface<uintX>::MaskedBlit(const Graphics::
 				uintX *dest = reinterpret_cast<uintX *>(pixel);
 
 				// Uh, not completely supported right now
-				//if ((*texel & RenderSurface::_format->a_mask) && (*dest & RenderSurface::_format->a_mask))
+				//if ((*texel & format.a_mask) && (*dest & format.a_mask))
 				if (*dest & aMask) {
-					*dest = BlendHighlight(*texel, r, g, b, 1, ia);
+					*dest = BlendHighlight(*texel, r, g, b, 1, ia, format);
 				}
 				pixel += sizeof(uintX);
 				texel++;
@@ -569,7 +573,7 @@ template<class uintX> void SoftRenderSurface<uintX>::PaintInvisible(const Shape
 #define FLIP_CONDITIONAL mirrored
 #define XFORM_SHAPES
 #define XFORM_CONDITIONAL trans
-#define BLEND_SHAPES(src,dst) BlendInvisible(src,dst)
+#define BLEND_SHAPES(src, dst) BlendInvisible(src, dst, format)
 
 #include "ultima/ultima8/graphics/soft_render_surface.inl"
 
@@ -592,7 +596,7 @@ template<class uintX> void SoftRenderSurface<uintX>::PaintHighlight(const Shape
 #define FLIP_CONDITIONAL mirrored
 #define XFORM_SHAPES
 #define XFORM_CONDITIONAL trans
-#define BLEND_SHAPES(src,dst) BlendHighlight(src,cr,cg,cb,ca,255-ca)
+#define BLEND_SHAPES(src, dst) BlendHighlight(src, cr, cg, cb, ca, 255 - ca, format)
 
 	uint32 ca = TEX32_A(col32);
 	uint32 cr = TEX32_R(col32);
@@ -619,7 +623,7 @@ template<class uintX> void SoftRenderSurface<uintX>::PaintHighlightInvis(const S
 #define FLIP_CONDITIONAL mirrored
 #define XFORM_SHAPES
 #define XFORM_CONDITIONAL trans
-#define BLEND_SHAPES(src,dst) BlendHighlightInvis(src,dst,cr,cg,cb,ca,255-ca)
+#define BLEND_SHAPES(src, dst) BlendHighlightInvis(src, dst, cr, cg, cb, ca, 255 - ca, format)
 
 	uint32 ca = TEX32_A(col32);
 	uint32 cr = TEX32_R(col32);
diff --git a/engines/ultima/ultima8/graphics/soft_render_surface.inl b/engines/ultima/ultima8/graphics/soft_render_surface.inl
index 064283693e4..472806a6cbd 100644
--- a/engines/ultima/ultima8/graphics/soft_render_surface.inl
+++ b/engines/ultima/ultima8/graphics/soft_render_surface.inl
@@ -170,6 +170,7 @@ const int32 neg = (FLIP_CONDITIONAL)?-1:0;
 	if (s->getPalette() == 0)
 		return;
 
+	const Graphics::PixelFormat &format = _surface->format;
 	const ShapeFrame *frame			= s->getFrame(framenum);
 	if (!frame)
 		return;
@@ -210,7 +211,7 @@ const int32 neg = (FLIP_CONDITIONAL)?-1:0;
 					const uint8 *srcpix = srcline + xpos;
 					#ifdef XFORM_SHAPES
 					if (USE_XFORM_FUNC) {
-						*dstpix = CUSTOM_BLEND(BlendPreModulated(xform_pal[*srcpix], *dstpix));
+						*dstpix = CUSTOM_BLEND(BlendPreModulated(xform_pal[*srcpix], *dstpix, format));
 					}
 					else
 					#endif
diff --git a/engines/ultima/ultima8/graphics/xform_blend.h b/engines/ultima/ultima8/graphics/xform_blend.h
index 72fd89f1b9b..5db34c391bf 100644
--- a/engines/ultima/ultima8/graphics/xform_blend.h
+++ b/engines/ultima/ultima8/graphics/xform_blend.h
@@ -41,9 +41,9 @@ namespace Ultima8 {
 extern const uint8 U8XFormPal[1024];
 extern const uint8 CruXFormPal[1024];
 
-inline uint32 P_FASTCALL BlendPreModulated(uint32 src, uint32 dst) {
+inline uint32 P_FASTCALL BlendPreModulated(uint32 src, uint32 dst, const Graphics::PixelFormat &format) {
 	uint8 sr, sg, sb;
-	RenderSurface::_format->colorToRGB(dst, sr, sg, sb);
+	format.colorToRGB(dst, sr, sg, sb);
 
 	uint32 r = sr * (256 - TEX32_A(src));
 	uint32 g = sg * (256 - TEX32_A(src));
@@ -54,12 +54,12 @@ inline uint32 P_FASTCALL BlendPreModulated(uint32 src, uint32 dst) {
 	r >>= 8;
 	g >>= 8;
 	b >>= 8;
-	return RenderSurface::_format->RGBToColor(r > 0xFF ? 0xFF : r, g > 0xFF ? 0xFF : g, b > 0xFF ? 0xFF : b);
+	return format.RGBToColor(r > 0xFF ? 0xFF : r, g > 0xFF ? 0xFF : g, b > 0xFF ? 0xFF : b);
 }
 
-inline uint32 P_FASTCALL BlendPreModFast(uint32 src, uint32 dst) {
+inline uint32 P_FASTCALL BlendPreModFast(uint32 src, uint32 dst, const Graphics::PixelFormat &format) {
 	uint8 sr, sg, sb;
-	RenderSurface::_format->colorToRGB(dst, sr, sg, sb);
+	format.colorToRGB(dst, sr, sg, sb);
 
 	uint32 r = sr * (256 - TEX32_A(src));
 	uint32 g = sg * (256 - TEX32_A(src));
@@ -67,38 +67,38 @@ inline uint32 P_FASTCALL BlendPreModFast(uint32 src, uint32 dst) {
 	r += 256 * TEX32_R(src);
 	g += 256 * TEX32_G(src);
 	b += 256 * TEX32_B(src);
-	return RenderSurface::_format->RGBToColor(r >> 8, g >> 8, b >> 8);
+	return format.RGBToColor(r >> 8, g >> 8, b >> 8);
 }
 
 // This does the red highlight blending.
-inline uint32 P_FASTCALL BlendHighlight(uint32 src, uint32 cr, uint32 cg, uint32 cb, uint32 ca, uint32 ica) {
+inline uint32 P_FASTCALL BlendHighlight(uint32 src, uint32 cr, uint32 cg, uint32 cb, uint32 ca, uint32 ica, const Graphics::PixelFormat &format) {
 	uint8 sr, sg, sb;
-	RenderSurface::_format->colorToRGB(src, sr, sg, sb);
-	return RenderSurface::_format->RGBToColor((sr * ica + cr * ca) >> 8,
-											  (sg * ica + cg * ca) >> 8,
-											  (sb * ica + cb * ca) >> 8);
+	format.colorToRGB(src, sr, sg, sb);
+	return format.RGBToColor((sr * ica + cr * ca) >> 8,
+							 (sg * ica + cg * ca) >> 8,
+							 (sb * ica + cb * ca) >> 8);
 }
 
 // This does the invisible blending. I've set it to about 40%
-inline uint32 P_FASTCALL BlendInvisible(uint32 src, uint32 dst) {
+inline uint32 P_FASTCALL BlendInvisible(uint32 src, uint32 dst, const Graphics::PixelFormat &format) {
 	uint8 sr, sg, sb;
 	uint8 dr, dg, db;
-	RenderSurface::_format->colorToRGB(src, sr, sg, sb);
-	RenderSurface::_format->colorToRGB(dst, dr, dg, db);
-	return RenderSurface::_format->RGBToColor((sr * 100 + dr * 156) >> 8,
-											  (sg * 100 + dg * 156) >> 8,
-											  (sb * 100 + db * 156) >> 8);
+	format.colorToRGB(src, sr, sg, sb);
+	format.colorToRGB(dst, dr, dg, db);
+	return format.RGBToColor((sr * 100 + dr * 156) >> 8,
+							 (sg * 100 + dg * 156) >> 8,
+							 (sb * 100 + db * 156) >> 8);
 }
 
 // This does the translucent highlight blending. (50%)
-inline uint32 P_FASTCALL BlendHighlightInvis(uint32 src, uint32 dst, uint32 cr, uint32 cg, uint32 cb, uint32 ca, uint32 ica) {
+inline uint32 P_FASTCALL BlendHighlightInvis(uint32 src, uint32 dst, uint32 cr, uint32 cg, uint32 cb, uint32 ca, uint32 ica, const Graphics::PixelFormat &format) {
 	uint8 sr, sg, sb;
 	uint8 dr, dg, db;
-	RenderSurface::_format->colorToRGB(src, sr, sg, sb);
-	RenderSurface::_format->colorToRGB(dst, dr, dg, db);
-	return RenderSurface::_format->RGBToColor((((sr * ica + cr * ca) >> 1) + (dr << 7)) >> 8,
-											  (((sg * ica + cg * ca) >> 1) + (dg << 7)) >> 8,
-											  (((sb * ica + cb * ca) >> 1) + (db << 7)) >> 8);
+	format.colorToRGB(src, sr, sg, sb);
+	format.colorToRGB(dst, dr, dg, db);
+	return format.RGBToColor((((sr * ica + cr * ca) >> 1) + (dr << 7)) >> 8,
+							 (((sg * ica + cg * ca) >> 1) + (dg << 7)) >> 8,
+							 (((sb * ica + cb * ca) >> 1) + (db << 7)) >> 8);
 }
 
 } // End of namespace Ultima8
diff --git a/engines/ultima/ultima8/ultima8.cpp b/engines/ultima/ultima8/ultima8.cpp
index 777bd1bf9b9..9aba5ad0cc2 100644
--- a/engines/ultima/ultima8/ultima8.cpp
+++ b/engines/ultima/ultima8/ultima8.cpp
@@ -668,7 +668,7 @@ void Ultima8Engine::GraphicSysInit() {
 		_screen->GetSurfaceDims(old_dims);
 		if (width == old_dims.width() && height == old_dims.height())
 			return;
-		bpp = RenderSurface::_format->bpp();
+		bpp = _screen->getRawSurface()->format.bpp();
 
 		delete _screen;
 	}
diff --git a/engines/ultima/ultima8/ultima8.h b/engines/ultima/ultima8/ultima8.h
index 0fe4f435c64..f69477eb398 100644
--- a/engines/ultima/ultima8/ultima8.h
+++ b/engines/ultima/ultima8/ultima8.h
@@ -374,8 +374,6 @@ public:
 	bool isInterpolationEnabled() const {
 		return _interpolate;
 	}
-public:
-	Graphics::PixelFormat _renderFormat;
 };
 
 } // End of namespace Ultima8




More information about the Scummvm-git-logs mailing list