[Scummvm-git-logs] scummvm master -> 3451b2fb5204bb6f5b617ae8d5f3c632f7383735

OMGPizzaGuy noreply at scummvm.org
Sat Dec 17 18:06:31 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:
3451b2fb52 ULTIMA8: Move methods to render surface


Commit: 3451b2fb5204bb6f5b617ae8d5f3c632f7383735
    https://github.com/scummvm/scummvm/commit/3451b2fb5204bb6f5b617ae8d5f3c632f7383735
Author: Matthew Jimenez (matthew.jimenez at outlook.com)
Date: 2022-12-17T12:03:45-06:00

Commit Message:
ULTIMA8: Move methods to 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.h


diff --git a/engines/ultima/ultima8/graphics/render_surface.cpp b/engines/ultima/ultima8/graphics/render_surface.cpp
index f7fcb5c8829..4b0d861f9be 100644
--- a/engines/ultima/ultima8/graphics/render_surface.cpp
+++ b/engines/ultima/ultima8/graphics/render_surface.cpp
@@ -318,6 +318,96 @@ bool RenderSurface::IsFlipped() const {
 	return _flipped;
 }
 
+//
+// RenderSurface::Fill32(uint32 rgb, int32 sx, int32 sy, int32 w, int32 h)
+//
+// Desc: Fill buffer (using a RGB colour)
+//
+void RenderSurface::Fill32(uint32 rgb, int32 sx, int32 sy, int32 w, int32 h) {
+	Rect rect(sx, sy, sx + w, sy + h);
+	rect.clip(_clipWindow);
+	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);
+}
+
+//
+// RenderSurface::DrawLine32(uint32 rgb, int32 sx, int32 sy, int32 ex, int32 ey);
+//
+// Desc: Draw a (non-antialiased) line from (sx,sy) to (ex,ey) with color rgb
+//
+void RenderSurface::DrawLine32(uint32 rgb, int32 sx, int32 sy, int32 ex, int32 ey) {
+	if (sy == ey) {
+		int w;
+		if (sx < ex) {
+			w = ex - sx + 1;
+		} else {
+			w = sx - ex + 1;
+			sx = ex;
+		}
+		Fill32(rgb, sx, sy, w, 1);
+	} else if (sx == ex) {
+		int h;
+		if (sy < ey) {
+			h = ey - sy + 1;
+		} else {
+			h = sy - ey + 1;
+			sy = ey;
+		}
+		Fill32(rgb, sx, sy, 1, h);
+	} else {
+		int32 t;
+		bool steep = ABS(ey - sy) > ABS(ex - sx);
+		if (steep) {
+			t = sx;
+			sx = sy;
+			sy = t;
+			t = ex;
+			ex = ey;
+			ey = t;
+		}
+		if (sx > ex) {
+			t = sx;
+			sx = ex;
+			ex = t;
+			t = sy;
+			sy = ey;
+			ey = t;
+		}
+		int deltax = ex - sx;
+		int deltay = ABS(ey - sy);
+		int error = -deltax / 2;
+		int y = sy;
+		int ystep = (sy < ey) ? 1 : -1;
+		for (int x = sx; x <= ex; ++x) {
+			// TODO: don't use Fill32 here; it's too slow
+			if (steep) {
+				Fill32(rgb, y, x, 1, 1);
+			} else {
+				Fill32(rgb, x, y, 1, 1);
+			}
+			error += deltay;
+			if (error > 0) {
+				y += ystep;
+				error -= deltax;
+			}
+		}
+	}
+}
+
+//
+// RenderSurface::Blit(Graphics::ManagedSurface &src, const Common::Rect &srcRect, int32 dx, int32 dy, bool alpha_blend)
+//
+// Desc: Blit a region from a Texture (Alpha == 0 -> skipped)
+//
+void RenderSurface::Blit(const Graphics::ManagedSurface &src, const Common::Rect &srcRect, int32 dx, int32 dy, bool alpha_blend) {
+	Common::Point dpoint = Common::Point(_ox + dx, _oy + dy);
+	if (alpha_blend) {
+		_surface->transBlitFrom(src, srcRect, dpoint);
+	} else {
+		_surface->blitFrom(src, srcRect, dpoint);
+	}
+}
+
 //
 // RenderSurface::SetVideoMode()
 //
diff --git a/engines/ultima/ultima8/graphics/render_surface.h b/engines/ultima/ultima8/graphics/render_surface.h
index 5aa06898ab8..95d042e1138 100644
--- a/engines/ultima/ultima8/graphics/render_surface.h
+++ b/engines/ultima/ultima8/graphics/render_surface.h
@@ -149,7 +149,7 @@ public:
 	//
 
 	//! Fill buffer (using a RGB colour)
-	virtual void Fill32(uint32 rgb, int32 sx, int32 sy, int32 w, int32 h) = 0;
+	virtual void Fill32(uint32 rgb, int32 sx, int32 sy, int32 w, int32 h);
 
 	//! Fill alpha channel
 	virtual void FillAlpha(uint8 alpha, int32 sx, int32 sy, int32 w, int32 h) = 0;
@@ -195,7 +195,7 @@ public:
 	//
 
 	// Draw a RGB Line
-	virtual void DrawLine32(uint32 rgb, int32 sx, int32 sy, int32 ex, int32 ey) = 0;
+	virtual void DrawLine32(uint32 rgb, int32 sx, int32 sy, int32 ex, int32 ey);
 
 
 	//
@@ -203,7 +203,7 @@ public:
 	//
 
 	//! Blit a region from a Texture (Alpha == 0 -> skipped)
-	virtual void Blit(const Graphics::ManagedSurface &src, const Common::Rect &srcRect, int32 dx, int32 dy, bool alpha_blend = false) = 0;
+	virtual void Blit(const Graphics::ManagedSurface &src, const Common::Rect &srcRect, int32 dx, int32 dy, bool alpha_blend = false);
 
 	//! Blit a region from a Texture with a Colour blend (AlphaTex == 0 -> skipped. AlphaCol32 -> Blend Factors)
 	virtual void FadedBlit(const Graphics::ManagedSurface &src, const Common::Rect &srcRect, int32 dx, int32 dy, uint32 col32, bool alpha_blend = false) = 0;
diff --git a/engines/ultima/ultima8/graphics/soft_render_surface.cpp b/engines/ultima/ultima8/graphics/soft_render_surface.cpp
index 70481277a10..414c7492462 100644
--- a/engines/ultima/ultima8/graphics/soft_render_surface.cpp
+++ b/engines/ultima/ultima8/graphics/soft_render_surface.cpp
@@ -46,19 +46,6 @@ template<class uintX> SoftRenderSurface<uintX>::SoftRenderSurface(Graphics::Mana
 	: RenderSurface(s) {
 }
 
-
-//
-// 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);
-	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);
-}
-
 //
 // SoftRenderSurface::FillAlpha(uint8 alpha, int32 sx, int32 sy, int32 w, int32 h)
 //
@@ -168,88 +155,6 @@ template<class uintX> void SoftRenderSurface<uintX>::FillBlended(uint32 rgba, in
 	}
 }
 
-//
-// SoftRenderSurface::DrawLine32(uint32 rgb, int32 sx, int32 sy, int32 ex, int32 ey);
-//
-// Desc: Draw a (non-antialiased) line from (sx,sy) to (ex,ey) with color rgb
-//
-
-template<class uintX> void SoftRenderSurface<uintX>::DrawLine32(uint32 rgb, int32 sx, int32 sy, int32 ex, int32 ey) {
-	if (sy == ey) {
-		int w;
-		if (sx < ex) {
-			w = ex - sx + 1;
-		} else {
-			w = sx - ex + 1;
-			sx = ex;
-		}
-		Fill32(rgb, sx, sy, w, 1);
-	} else if (sx == ex) {
-		int h;
-		if (sy < ey) {
-			h = ey - sy + 1;
-		} else {
-			h = sy - ey + 1;
-			sy = ey;
-		}
-		Fill32(rgb, sx, sy, 1, h);
-	} else {
-		int32 t;
-		bool steep = ABS(ey - sy) > ABS(ex - sx);
-		if (steep) {
-			t = sx;
-			sx = sy;
-			sy = t;
-			t = ex;
-			ex = ey;
-			ey = t;
-		}
-		if (sx > ex) {
-			t = sx;
-			sx = ex;
-			ex = t;
-			t = sy;
-			sy = ey;
-			ey = t;
-		}
-		int deltax = ex - sx;
-		int deltay = ABS(ey - sy);
-		int error = -deltax / 2;
-		int y = sy;
-		int ystep = (sy < ey) ? 1 : -1;
-		for (int x = sx; x <= ex; ++x) {
-			// TODO: don't use Fill32 here; it's too slow
-			if (steep) {
-				Fill32(rgb, y, x, 1, 1);
-			} else {
-				Fill32(rgb, x, y, 1, 1);
-			}
-			error += deltay;
-			if (error > 0) {
-				y += ystep;
-				error -= deltax;
-			}
-		}
-	}
-}
-
-
-//
-// SoftRenderSurface::Blit(Graphics::ManagedSurface &src, const Common::Rect &srcRect, 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 Graphics::ManagedSurface &src, const Common::Rect &srcRect, int32 dx, int32 dy, bool alpha_blend) {
-	Common::Point dpoint = Common::Point(_ox + dx, _oy + dy);
-	if (alpha_blend) {
-		_surface->transBlitFrom(src, srcRect, dpoint);
-	}
-	else {
-		_surface->blitFrom(src, srcRect, dpoint);
-	}
-}
-
-
 //
 // void SoftRenderSurface::FadedBlit(Graphics::ManagedSurface &src, const Common::Rect &srcRect, int32 dx, int32 dy, uint32 col32)
 //
diff --git a/engines/ultima/ultima8/graphics/soft_render_surface.h b/engines/ultima/ultima8/graphics/soft_render_surface.h
index f7fe40d303e..21856bed641 100644
--- a/engines/ultima/ultima8/graphics/soft_render_surface.h
+++ b/engines/ultima/ultima8/graphics/soft_render_surface.h
@@ -43,9 +43,6 @@ public:
 	// Surface Filling
 	//
 
-	// Fill buffer (using a RGB colour)
-	void Fill32(uint32 rgb, int32 sx, int32 sy, int32 w, int32 h) override;
-
 	//! Fill alpha channel
 	void FillAlpha(uint8 alpha, int32 sx, int32 sy, int32 w, int32 h) override;
 
@@ -85,21 +82,6 @@ public:
 	// Paint a Invisible Highlighted Shape of using the 32 Bit Colour col32 (0xAARRGGBB Alpha is blend level)
 	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 RGB Line
-	void DrawLine32(uint32 rgb, int32 sx, int32 sy, int32 ex, int32 ey) override;
-
-
-	//
-	// Basic Texture Blitting
-	//
-
-	// Blit a region from a Texture (Alpha == 0 -> skipped)
-	void Blit(const Graphics::ManagedSurface &src, const Common::Rect &srcRect, 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 Graphics::ManagedSurface &src, const Common::Rect &srcRect, int32 dx, int32 dy, uint32 col32, bool alpha_blend = false) override;
 




More information about the Scummvm-git-logs mailing list