[Scummvm-git-logs] scummvm master -> 3b62b557d4c8526709658c7835f3a89ff01b60ec

lephilousophe noreply at scummvm.org
Fri Jan 24 11:11:27 UTC 2025


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

Summary:
58ade5240e GRAPHICS: Add missing drawing primitives
2a37e2b808 GRAPHICS: MACGUI: Implement drawing primitives
6b1b96efd8 CINE: Don't use deprecated primitives
c0171b0c98 DGDS: Don't use deprecated primitives
45768dbef6 GOB: Don't use deprecated primitives
6b24643bed PARALLACTION: Don't use deprecated primitives
3761db3830 PRINCE: Don't use deprecated primitives
378d903649 SCI: Don't use deprecated primitives
d77cf892c6 SCUMM: Don't use deprecated primitives
e7f1bfc999 SWORD2: Don't use deprecated primitives
7a626614ec TITANIC: Don't use deprecated primitives
09b5ed6d92 TOUCHE: Don't use deprecated primitives
9b89dd6fa7 WAGE: Don't use deprecated primitives
3b62b557d4 GRAPHICS: Remove obsolete and unused primitives


Commit: 58ade5240e306cc8ffea14e1a1bc30d37ec41064
    https://github.com/scummvm/scummvm/commit/58ade5240e306cc8ffea14e1a1bc30d37ec41064
Author: Le Philousophe (lephilousophe at users.noreply.github.com)
Date: 2025-01-24T12:11:17+01:00

Commit Message:
GRAPHICS: Add missing drawing primitives

This allows to draw polygon and ellipses directly on the surfaces.

Changed paths:
    graphics/managed_surface.h
    graphics/surface.cpp
    graphics/surface.h


diff --git a/graphics/managed_surface.h b/graphics/managed_surface.h
index 66525dfb597..1fe2af069a3 100644
--- a/graphics/managed_surface.h
+++ b/graphics/managed_surface.h
@@ -725,6 +725,22 @@ public:
 		addDirtyRect(rect);
 	}
 
+	/**
+	 * Draw a filled polygon.
+	 */
+	void drawPolygonScan(const int *polyX, const int *polyY, int npoints, const Common::Rect &bbox, uint32 color) {
+		_innerSurface.drawPolygonScan(polyX, polyY, npoints, bbox, color);
+		addDirtyRect(bbox);
+	}
+
+	/**
+	 * Draw an ellipse.
+	 */
+	void drawEllipse(int x0, int y0, int x1, int y1, uint32 color, bool filled) {
+		_innerSurface.drawEllipse(x0, y0, x1, y1, color, filled);
+		addDirtyRect(Common::Rect(MIN(x0, x1), MIN(y0, y1), MAX(x0, x1 + 1), MAX(y0, y1 + 1)));
+	}
+
 	/**
 	 * Draw a horizontal line.
 	 */
diff --git a/graphics/surface.cpp b/graphics/surface.cpp
index ce4e01ad22f..0be37c8ffcf 100644
--- a/graphics/surface.cpp
+++ b/graphics/surface.cpp
@@ -109,6 +109,34 @@ void Surface::drawRoundRect(const Common::Rect &rect, int arc, uint32 color, boo
 		error("Surface::drawRoundRect: bytesPerPixel must be 1, 2, or 4, got %d", format.bytesPerPixel);
 }
 
+void Surface::drawPolygonScan(const int *polyX, const int *polyY, int npoints, const Common::Rect &bbox, uint32 color) {
+	if (format.bytesPerPixel == 1) {
+		SurfacePrimitives<byte> primitives;
+		primitives.drawPolygonScan(polyX, polyY, npoints, bbox, color, this);
+	} else if (format.bytesPerPixel == 2) {
+		SurfacePrimitives<uint16> primitives;
+		primitives.drawPolygonScan(polyX, polyY, npoints, bbox, color, this);
+	} else if (format.bytesPerPixel == 4) {
+		SurfacePrimitives<uint32> primitives;
+		primitives.drawPolygonScan(polyX, polyY, npoints, bbox, color, this);
+	} else
+		error("Surface::drawPolygonScan: bytesPerPixel must be 1, 2, or 4, got %d", format.bytesPerPixel);
+}
+
+void Surface::drawEllipse(int x0, int y0, int x1, int y1, uint32 color, bool filled) {
+	if (format.bytesPerPixel == 1) {
+		SurfacePrimitives<byte> primitives;
+		primitives.drawEllipse(x0, y0, x1, y1, color, filled, this);
+	} else if (format.bytesPerPixel == 2) {
+		SurfacePrimitives<uint16> primitives;
+		primitives.drawEllipse(x0, y0, x1, y1, color, filled, this);
+	} else if (format.bytesPerPixel == 4) {
+		SurfacePrimitives<uint32> primitives;
+		primitives.drawEllipse(x0, y0, x1, y1, color, filled, this);
+	} else
+		error("Surface::drawEllipse: bytesPerPixel must be 1, 2, or 4, got %d", format.bytesPerPixel);
+}
+
 // see graphics/blit/blit-atari.cpp
 #ifndef ATARI
 void Surface::create(int16 width, int16 height, const PixelFormat &f) {
diff --git a/graphics/surface.h b/graphics/surface.h
index 8ceae6d84a3..87c8886253f 100644
--- a/graphics/surface.h
+++ b/graphics/surface.h
@@ -438,6 +438,33 @@ public:
 	 */
 	void drawRoundRect(const Common::Rect &rect, int arc, uint32 color, bool filled);
 
+	/**
+	 * Draw a filled polygon.
+	 *
+	 * @param polyX   The X coordinates of the points.
+	 * @param polyY   The Y coordinates of the points.
+	 * @param npoints The number of points in the polygon.
+	 * @param bbox    The bounding box of the polygon.
+	 * @param color   Color of the polygon.
+	 *
+	 * @note This is just a wrapper around Graphics::Primitives.
+	 */
+	void drawPolygonScan(const int *polyX, const int *polyY, int npoints, const Common::Rect &bbox, uint32 color);
+
+	/**
+	 * Draw an ellipse.
+	 *
+	 * @param x0     The x coordinate of the start corner.
+	 * @param y0     The y coordinate of the start corner.
+	 * @param x1     The x coordinate of the end corner.
+	 * @param y1     The y coordinate of the end corner.
+	 * @param color  Color of the ellipse.
+	 * @param filled Whether the ellipse should be filled in.
+	 *
+	 * @note This is just a wrapper around Graphics::Primitives.
+	 */
+	void drawEllipse(int x0, int y0, int x1, int y1, uint32 color, bool filled);
+
 	/**
 	 * Draw a horizontal line.
 	 *


Commit: 2a37e2b8084eb04e17a3e0eafd9fed3960ce57f4
    https://github.com/scummvm/scummvm/commit/2a37e2b8084eb04e17a3e0eafd9fed3960ce57f4
Author: Le Philousophe (lephilousophe at users.noreply.github.com)
Date: 2025-01-24T12:11:17+01:00

Commit Message:
GRAPHICS: MACGUI: Implement drawing primitives

This makes the code comply with the latest API changes.
The drawing calls now need to be optimized for the complex shapes.

Changed paths:
    engines/director/graphics.cpp
    engines/director/sprite.cpp
    graphics/macgui/macbutton.cpp
    graphics/macgui/macdialog.cpp
    graphics/macgui/macwindowborder.cpp
    graphics/macgui/macwindowmanager.cpp
    graphics/macgui/macwindowmanager.h


diff --git a/engines/director/graphics.cpp b/engines/director/graphics.cpp
index 017e1412451..6238303565f 100644
--- a/engines/director/graphics.cpp
+++ b/engines/director/graphics.cpp
@@ -314,7 +314,7 @@ void InkPrimitives<T>::drawPoint(int x, int y, uint32 src, void *data) {
 			// Get the pixel that macDrawPixel will give us, but store it to apply the
 			// ink later
 			tmpDst = *dst;
-			(wm->getDrawPixel())(x, y, src, p->ms->pd);
+			wm->getDrawPrimitives().drawPoint(x, y, src, p->ms->pd);
 			src = *dst;
 
 			*dst = tmpDst;
diff --git a/engines/director/sprite.cpp b/engines/director/sprite.cpp
index 793ea05cbe3..44ea7f72ed5 100644
--- a/engines/director/sprite.cpp
+++ b/engines/director/sprite.cpp
@@ -157,19 +157,21 @@ void Sprite::createQDMatte() {
 	Common::Rect fillAreaRect((int)srcRect.width(), (int)srcRect.height());
 	Graphics::MacPlotData plotFill(&tmp, nullptr, &g_director->getPatterns(), getPattern(), 0, 0, 1, g_director->_wm->_colorBlack);
 
+	Graphics::Primitives &primitives = g_director->_wm->getDrawPrimitives();
+
 	// it's the same for filled and outlined qd shape when we are using floodfill, so we use filled rect directly since it won't be affected by line size.
 	switch (_spriteType) {
 	case kOutlinedRectangleSprite:
 	case kRectangleSprite:
-		Graphics::drawFilledRect1(fillAreaRect, g_director->_wm->_colorBlack, g_director->_wm->getDrawPixel(), &plotFill);
+		primitives.drawFilledRect1(fillAreaRect, g_director->_wm->_colorBlack, &plotFill);
 		break;
 	case kOutlinedRoundedRectangleSprite:
 	case kRoundedRectangleSprite:
-		Graphics::drawRoundRect1(fillAreaRect, 12, g_director->_wm->_colorBlack, true, g_director->_wm->getDrawPixel(), &plotFill);
+		primitives.drawRoundRect1(fillAreaRect, 12, g_director->_wm->_colorBlack, true, &plotFill);
 		break;
 	case kOutlinedOvalSprite:
 	case kOvalSprite:
-		Graphics::drawEllipse(fillAreaRect.left, fillAreaRect.top, fillAreaRect.right, fillAreaRect.bottom, g_director->_wm->_colorBlack, true, g_director->_wm->getDrawPixel(), &plotFill);
+		primitives.drawEllipse(fillAreaRect.left, fillAreaRect.top, fillAreaRect.right, fillAreaRect.bottom, g_director->_wm->_colorBlack, true, &plotFill);
 		break;
 	case kLineBottomTopSprite:
 	case kLineTopBottomSprite:
diff --git a/graphics/macgui/macbutton.cpp b/graphics/macgui/macbutton.cpp
index ff68154e73c..0e985d9f6f0 100644
--- a/graphics/macgui/macbutton.cpp
+++ b/graphics/macgui/macbutton.cpp
@@ -70,21 +70,23 @@ void MacButton::setActive(bool active) {
 		_contentIsDirty = true;
 }
 
-// whether to use getDrawPixel or getDrawInvertPixel to draw invert pixel, maybe depends on the pattle we are using
+// whether to use getDrawPrimitives or getDrawInvertPrimitives to draw invert pixel, maybe depends on the pattle we are using
 void MacButton::invertOuter() {
 	Common::Rect r(_dims.width() - 1, _dims.height() - 1);
 
+	Primitives &primitives = _wm->getDrawPrimitives();
+
 	switch (_buttonType) {
 	case kCheckBox: {
 		Common::Rect c = Common::Rect(r.left + 1, r.top + 3, r.left + 9, r.top + 11);
-		Graphics::drawRect1(c, 0, _wm->getDrawPixel(), &_pd);
+		primitives.drawRect1(c, 0, &_pd);
 	}
 		break;
 	case kRound:
-		Graphics::drawRoundRect1(r, 4, 0, true, _wm->getDrawPixel(), &_pd);
+		primitives.drawRoundRect1(r, 4, 0, true, &_pd);
 		break;
 	case kRadio:
-		Graphics::drawEllipse(r.left + 1, r.top + 3, r.left + 10, r.top + 12, 0, false, _wm->getDrawPixel(), &_pd);
+		primitives.drawEllipse(r.left + 1, r.top + 3, r.left + 10, r.top + 12, 0, false, &_pd);
 		break;
 	}
 }
@@ -100,28 +102,30 @@ void MacButton::invertInner() {
 	Common::Rect r(_dims.width() - 1, _dims.height() - 1);
 	Common::Rect checkbox;
 
+	Primitives &primitives = _wm->getDrawPrimitives();
+
 	switch (_buttonType) {
 	case kCheckBox:
 		switch (_checkBoxType) {
 		case kCBNormal:
-			Graphics::drawLine(r.left + 1, r.top + 3, r.left + 9, r.top + 11, 0, _wm->getDrawPixel(), &_pd);
-			Graphics::drawLine(r.left + 1, r.top + 11, r.left + 9, r.top + 3, 0, _wm->getDrawPixel(), &_pd);
-			(_wm->getDrawInvertPixel())(5, 7, 0, &_pd);
+			primitives.drawLine(r.left + 1, r.top + 3, r.left + 9, r.top + 11, 0, &_pd);
+			primitives.drawLine(r.left + 1, r.top + 11, r.left + 9, r.top + 3, 0, &_pd);
+			(_wm->getDrawInvertPrimitives()).drawPoint(5, 7, 0, &_pd);
 			break;
 		case kCBInsetBlack:
 			checkbox = Common::Rect(r.left + 2, r.top + 4, r.left + 2 + 6, r.top + 4 + 6);
-			Graphics::drawFilledRect1(checkbox, 0, _wm->getDrawPixel(), &_pd);
+			primitives.drawFilledRect1(checkbox, 0, &_pd);
 			break;
 		case kCBFilledBlack:
 			checkbox = Common::Rect(r.left + 1, r.top + 3, r.left + 1 + 8, r.top + 3 + 8);
-			Graphics::drawFilledRect1(checkbox, 0, _wm->getDrawPixel(), &_pd);
+			primitives.drawFilledRect1(checkbox, 0, &_pd);
 			break;
 		}
 		break;
 	case kRound:
 		break;
 	case kRadio:
-		Graphics::drawEllipse(r.left + 3, r.top + 5, r.left + 8, r.top + 10, 0, true, _wm->getDrawPixel(), &_pd);
+		primitives.drawEllipse(r.left + 3, r.top + 5, r.left + 8, r.top + 10, 0, true, &_pd);
 		break;
 	}
 }
@@ -142,17 +146,19 @@ bool MacButton::draw(bool forceRedraw) {
 	Common::Rect r(_dims.width() - 1, _dims.height() - 1);
 	Graphics::MacPlotData pd(_composeSurface, nullptr, &_wm->getPatterns(), 1, 0, 0, 1, 0);
 
+	Primitives &primitives = _wm->getDrawPrimitives();
+
 	switch (_buttonType) {
 	case kCheckBox: {
 		Common::Rect c = Common::Rect(r.left, r.top + 2, r.left + 10, r.top + 2 + 10);
-		Graphics::drawRect1(c, 0xff, _wm->getDrawPixel(), &pd);
+		primitives.drawRect1(c, 0xff, &pd);
 		break;
 	}
 	case kRound:
-		Graphics::drawRoundRect1(r, 4, 0xff, false, _wm->getDrawPixel(), &pd);
+		primitives.drawRoundRect1(r, 4, 0xff, false, &pd);
 		break;
 	case kRadio:
-		Graphics::drawEllipse(r.left, r.top + 2, r.left + 11, r.top + 13, 0xff, false, _wm->getDrawPixel(), &pd);
+		primitives.drawEllipse(r.left, r.top + 2, r.left + 11, r.top + 13, 0xff, false, &pd);
 		break;
 	}
 
diff --git a/graphics/macgui/macdialog.cpp b/graphics/macgui/macdialog.cpp
index fd55735429a..0f7885f749a 100644
--- a/graphics/macgui/macdialog.cpp
+++ b/graphics/macgui/macdialog.cpp
@@ -99,8 +99,10 @@ const Graphics::Font *MacDialog::getDialogFont() {
 }
 
 void MacDialog::paint() {
+	Primitives &primitives = _wm->getDrawPrimitives();
+
 	MacPlotData pd(_screen, nullptr, &_wm->getPatterns(), 1, 0, 0, 1, _wm->_colorBlack, false);
-	drawFilledRect1(_bbox, kColorWhite, _wm->getDrawPixel(), &pd);
+	primitives.drawFilledRect1(_bbox, kColorWhite, &pd);
 	_mactext->drawToPoint(_screen, Common::Point(_bbox.left + (_bbox.width() - _maxTextWidth)/2, _bbox.top + 16));
 	static int boxOutline[] = {1, 0, 0, 1, 1};
 	drawOutline(_bbox, boxOutline, ARRAYSIZE(boxOutline));
@@ -121,7 +123,7 @@ void MacDialog::paint() {
 			Common::Rect bb(button->bounds.left + 5, button->bounds.top + 5,
 							button->bounds.right - 5, button->bounds.bottom - 5);
 
-			drawFilledRect1(bb, kColorBlack, _wm->getDrawPixel(), &pd);
+			primitives.drawFilledRect1(bb, kColorBlack, &pd);
 
 			color = kColorWhite;
 		}
@@ -141,11 +143,13 @@ void MacDialog::paint() {
 }
 
 void MacDialog::drawOutline(Common::Rect &bounds, int *spec, int speclen) {
+	Primitives &primitives = _wm->getDrawPrimitives();
+
 	MacPlotData pd(_screen, nullptr, &_wm->getPatterns(), 1, 0, 0, 1, _wm->_colorBlack, false);	
 	for (int i = 0; i < speclen; i++)
 		if (spec[i] != 0) {
 			Common::Rect r(bounds.left + i, bounds.top + i, bounds.right - i, bounds.bottom - i);
-			drawRect1(r, kColorBlack, _wm->getDrawPixel(), &pd);
+			primitives.drawRect1(r, kColorBlack, &pd);
 		}
 }
 
diff --git a/graphics/macgui/macwindowborder.cpp b/graphics/macgui/macwindowborder.cpp
index 7bdbadd08e0..0b2e23cdb85 100644
--- a/graphics/macgui/macwindowborder.cpp
+++ b/graphics/macgui/macwindowborder.cpp
@@ -176,7 +176,8 @@ void MacWindowBorder::drawScrollBar(ManagedSurface *g, MacWindowManager *wm) {
 	Common::Rect rr(rx1, ry1, rx2, ry2);
 
 	MacPlotData pd(g, nullptr,  &wm->getPatterns(), 1, 0, 0, 1, wm->_colorWhite, true);
-	Graphics::drawFilledRect1(rr, wm->_colorWhite, wm->getDrawInvertPixel(), &pd);
+	Primitives &primitives = wm->getDrawInvertPrimitives();
+	primitives.drawFilledRect1(rr, wm->_colorWhite, &pd);
 
 	// after drawing, we set the _scrollSize negative, to indicate no more drawing is needed
 	// if win95 mode is enabled, then we keep on drawing the scrollbar
diff --git a/graphics/macgui/macwindowmanager.cpp b/graphics/macgui/macwindowmanager.cpp
index e7fc13536d2..c896d4e34ed 100644
--- a/graphics/macgui/macwindowmanager.cpp
+++ b/graphics/macgui/macwindowmanager.cpp
@@ -152,6 +152,18 @@ static const byte macCursorCrossBar[] = {
 	3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
 };
 
+template<typename T>
+class MacDrawPrimitives : public Primitives {
+public:
+	void drawPoint(int x, int y, uint32 color, void *data) override;
+};
+
+template<typename T>
+class MacDrawInvertPrimitives : public MacDrawPrimitives<T> {
+public:
+	void drawPoint(int x, int y, uint32 color, void *data) override;
+};
+
 MacWindowManager::MacWindowManager(uint32 mode, MacPatterns *patterns, Common::Language language) {
 	_screen = nullptr;
 	_screenCopy = nullptr;
@@ -194,10 +206,16 @@ MacWindowManager::MacWindowManager(uint32 mode, MacPatterns *patterns, Common::L
 
 	_hilitingWidget = false;
 
-	if (mode & kWMMode32bpp)
+	if (mode & kWMMode32bpp) {
 		_pixelformat = Graphics::PixelFormat(4, 8, 8, 8, 8, 24, 16, 8, 0);
-	else
+		_macDrawPrimitives = new MacDrawPrimitives<uint32>();
+		// No implementation yet
+		_macDrawInvertPrimitives = nullptr;
+	} else {
 		_pixelformat = PixelFormat::createFormatCLUT8();
+		_macDrawPrimitives = new MacDrawPrimitives<byte>();
+		_macDrawInvertPrimitives = new MacDrawInvertPrimitives<byte>();
+	}
 
 	if (patterns) {
 		_patterns = *patterns;
@@ -255,6 +273,9 @@ MacWindowManager::~MacWindowManager() {
 
 	delete _desktop;
 
+	delete _macDrawPrimitives;
+	delete _macDrawInvertPrimitives;
+
 	cleanupDesktopBmp();
 	cleanupDataBundle();
 }
@@ -765,7 +786,7 @@ void MacWindowManager::removeWindow(MacWindow *target) {
 }
 
 template<typename T>
-void macDrawPixel(int x, int y, int color, void *data) {
+void MacDrawPrimitives<T>::drawPoint(int x, int y, uint32 color, void *data) {
 	MacPlotData *p = (MacPlotData *)data;
 
 	if (p->fillType > p->patterns->size() || !p->fillType)
@@ -778,11 +799,11 @@ void macDrawPixel(int x, int y, int color, void *data) {
 			uint xu = (uint)x; // for letting compiler optimize it
 			uint yu = (uint)y;
 
-			*((T)p->surface->getBasePtr(xu, yu)) = p->invert ? ~(*((T)p->surface->getBasePtr(xu, yu))) :
+			*((T *)p->surface->getBasePtr(xu, yu)) = p->invert ? ~(*((T *)p->surface->getBasePtr(xu, yu))) :
 				(pat[(yu + p->fillOriginY) % 8] & (1 << (7 - (xu + p->fillOriginX) % 8))) ? color : p->bgColor;
 
 			if (p->mask)
-				*((T)p->mask->getBasePtr(xu, yu)) = 0xff;
+				*((T *)p->mask->getBasePtr(xu, yu)) = 0xff;
 		}
 	} else {
 		int x1 = x;
@@ -795,16 +816,19 @@ void macDrawPixel(int x, int y, int color, void *data) {
 				if (x >= 0 && x < p->surface->w && y >= 0 && y < p->surface->h) {
 					uint xu = (uint)x; // for letting compiler optimize it
 					uint yu = (uint)y;
-					*((T)p->surface->getBasePtr(xu, yu)) = p->invert ? ~(*((T)p->surface->getBasePtr(xu, yu))) :
+					*((T *)p->surface->getBasePtr(xu, yu)) = p->invert ? ~(*((T *)p->surface->getBasePtr(xu, yu))) :
 						(pat[(yu + p->fillOriginY) % 8] & (1 << (7 + (xu - p->fillOriginX) % 8))) ? color : p->bgColor;
 
 					if (p->mask)
-						*((T)p->mask->getBasePtr(xu, yu)) = 0xff;
+						*((T *)p->mask->getBasePtr(xu, yu)) = 0xff;
 				}
 	}
 }
 
-void macDrawInvertPixel(int x, int y, int color, void *data) {
+// TODO: implement for other bpp
+
+template<>
+void MacDrawInvertPrimitives<byte>::drawPoint(int x, int y, uint32 color, void *data) {
 	MacPlotData *p = (MacPlotData *)data;
 
 	if (p->fillType > p->patterns->size() || !p->fillType)
@@ -828,19 +852,11 @@ void macDrawInvertPixel(int x, int y, int color, void *data) {
 	}
 }
 
-MacDrawPixPtr MacWindowManager::getDrawPixel() {
-	if (_pixelformat.bytesPerPixel == 1)
-		return &macDrawPixel<byte *>;
-	else
-		return &macDrawPixel<uint32 *>;
-}
-
 // get the function of drawing invert pixel for default palette
-MacDrawPixPtr MacWindowManager::getDrawInvertPixel() {
-	if (_pixelformat.bytesPerPixel == 1)
-		return &macDrawInvertPixel;
-	warning("function of drawing invert pixel for default palette has not implemented yet");
-	return nullptr;
+Primitives &MacWindowManager::getDrawInvertPrimitives() const {
+	if (!_macDrawInvertPrimitives)
+		warning("function of drawing invert pixel for default palette has not implemented yet");
+	return *_macDrawInvertPrimitives;
 }
 
 void MacWindowManager::loadDesktop() {
@@ -889,7 +905,7 @@ void MacWindowManager::drawDesktop() {
 
 		MacPlotData pd(_desktop, nullptr, &_patterns, kPatternCheckers, 0, 0, 1, _colorWhite);
 
-		Graphics::drawRoundRect(r, kDesktopArc, _colorBlack, true, getDrawPixel(), &pd);
+		getDrawPrimitives().drawRoundRect(r, kDesktopArc, _colorBlack, true, &pd);
 	}
 }
 
@@ -1230,10 +1246,11 @@ void MacWindowManager::renderZoomBox(bool redraw) {
 }
 
 void MacWindowManager::zoomBoxInner(Common::Rect &r, Graphics::MacPlotData &pd) {
-	Graphics::drawLine(r.left,  r.top,    r.right, r.top,    0xff, getDrawPixel(), &pd);
-	Graphics::drawLine(r.right, r.top,    r.right, r.bottom, 0xff, getDrawPixel(), &pd);
-	Graphics::drawLine(r.left,  r.bottom, r.right, r.bottom, 0xff, getDrawPixel(), &pd);
-	Graphics::drawLine(r.left,  r.top,    r.left,  r.bottom, 0xff, getDrawPixel(), &pd);
+	Primitives &primitives = getDrawPrimitives();
+	primitives.drawHLine(r.left, r.right, r.top, 0xff, &pd);
+	primitives.drawVLine(r.right, r.top, r.bottom, 0xff, &pd);
+	primitives.drawHLine(r.left, r.right, r.bottom, 0xff, &pd);
+	primitives.drawVLine(r.left, r.top, r.bottom, 0xff, &pd);
 }
 
 /////////////////
diff --git a/graphics/macgui/macwindowmanager.h b/graphics/macgui/macwindowmanager.h
index a00646c7dcf..5a81733b2c3 100644
--- a/graphics/macgui/macwindowmanager.h
+++ b/graphics/macgui/macwindowmanager.h
@@ -140,8 +140,6 @@ struct ZoomBox {
 	uint32 nextTime;
 };
 
-typedef void (* MacDrawPixPtr)(int, int, int, void *);
-
 /**
  * A manager class to handle window creation, destruction,
  * drawing, moving and event handling.
@@ -151,8 +149,8 @@ public:
 	MacWindowManager(uint32 mode = 0, MacPatterns *patterns = nullptr, Common::Language language = Common::UNK_LANG);
 	~MacWindowManager();
 
-	MacDrawPixPtr getDrawPixel();
-	MacDrawPixPtr getDrawInvertPixel();
+	Primitives &getDrawPrimitives() const { return *_macDrawPrimitives; }
+	Primitives &getDrawInvertPrimitives() const;
 
 	/**
 	 * Mutator to indicate the surface onto which the desktop will be drawn.
@@ -452,6 +450,9 @@ private:
 
 	bool _inEditableArea;
 
+	Primitives *_macDrawPrimitives;
+	Primitives *_macDrawInvertPrimitives;
+
 	MacPatterns _patterns;
 	MacPatterns _builtinPatterns;
 	byte *_palette;


Commit: 6b1b96efd879f9c0e58a779d928449b3f4d008cb
    https://github.com/scummvm/scummvm/commit/6b1b96efd879f9c0e58a779d928449b3f4d008cb
Author: Le Philousophe (lephilousophe at users.noreply.github.com)
Date: 2025-01-24T12:11:17+01:00

Commit Message:
CINE: Don't use deprecated primitives

Changed paths:
    engines/cine/gfx.cpp


diff --git a/engines/cine/gfx.cpp b/engines/cine/gfx.cpp
index 9b824ceccde..794b109a753 100644
--- a/engines/cine/gfx.cpp
+++ b/engines/cine/gfx.cpp
@@ -108,12 +108,14 @@ static const byte cursorPalette[] = {
 	0xff, 0xff, 0xff, 0xff
 };
 
-void plotPoint(int x, int y, int color, void *data) {
-	byte *output = (byte *)data;
-	if (x >= 0 && x < 320 && y >= 0 && y < 200) {
-		output[y * 320 + x] = (byte)color;
+class FWPrimitives : public Graphics::Primitives {
+	void drawPoint(int x, int y, uint32 color, void *data) override {
+		byte *output = (byte *)data;
+		if (x >= 0 && x < 320 && y >= 0 && y < 200) {
+			output[y * 320 + x] = (byte)color;
+		}
 	}
-}
+};
 
 /**
  * Initialize renderer
@@ -1650,7 +1652,7 @@ void OSRenderer::renderOverlay(const Common::List<overlay>::iterator &it) {
 		width = obj->frame;
 		height = obj->costume;
 		// Using Bresenham's algorithm, looks good enough for visual purposes in Operation Stealth
-		Graphics::drawLine(obj->x, obj->y, width, height, color, plotPoint, _backBuffer);
+		FWPrimitives().drawLine(obj->x, obj->y, width, height, color, _backBuffer);
 		break;
 
 	// something else


Commit: c0171b0c988c230c20f27796da1dbac1f6634a40
    https://github.com/scummvm/scummvm/commit/c0171b0c988c230c20f27796da1dbac1f6634a40
Author: Le Philousophe (lephilousophe at users.noreply.github.com)
Date: 2025-01-24T12:11:17+01:00

Commit Message:
DGDS: Don't use deprecated primitives

Changed paths:
    engines/dgds/dialog.cpp
    engines/dgds/drawing.cpp
    engines/dgds/drawing.h
    engines/dgds/ttm.cpp


diff --git a/engines/dgds/dialog.cpp b/engines/dgds/dialog.cpp
index ef28d8efdef..e5c2251c79e 100644
--- a/engines/dgds/dialog.cpp
+++ b/engines/dgds/dialog.cpp
@@ -27,7 +27,6 @@
 #include "common/system.h"
 
 #include "graphics/surface.h"
-#include "graphics/primitives.h"
 
 #include "dgds/dgds.h"
 #include "dgds/includes.h"
@@ -353,8 +352,8 @@ void Dialog::drawType4(Graphics::ManagedSurface *dst, DialogDrawStage stage) {
 		// This is not exactly the same as the original - might need some work to get pixel-perfect
 		if (DgdsEngine::getInstance()->getGameId() != GID_HOC) {
 			Common::Rect drawRect(x, y, x + w, y + h);
-			Graphics::drawRoundRect(drawRect, midy, fillbgcolor, true, Drawing::drawPixel, dst);
-			Graphics::drawRoundRect(drawRect, midy, fillcolor, false, Drawing::drawPixel, dst);
+			dst->drawRoundRect(drawRect, midy, fillbgcolor, true);
+			dst->drawRoundRect(drawRect, midy, fillcolor, false);
 		}
 	} else if (stage == kDlgDrawFindSelectionPointXY) {
 		drawFindSelectionXY();
diff --git a/engines/dgds/drawing.cpp b/engines/dgds/drawing.cpp
index 17760764d7f..a861970e19e 100644
--- a/engines/dgds/drawing.cpp
+++ b/engines/dgds/drawing.cpp
@@ -19,7 +19,6 @@
  *
  */
 
-#include "graphics/primitives.h"
 #include "graphics/managed_surface.h"
 #include "dgds/drawing.h"
 
@@ -27,20 +26,13 @@ namespace Dgds {
 
 namespace Drawing {
 
-void drawPixel(int x, int y, int color, void *data) {
-	Graphics::ManagedSurface *surface = (Graphics::ManagedSurface *)data;
-
-	if (x >= 0 && x < surface->w && y >= 0 && y < surface->h)
-		*((byte *)surface->getBasePtr(x, y)) = (byte)color;
-}
-
 void filledCircle(int x, int y, int xr, int yr, Graphics::ManagedSurface *dst, byte fgcol, byte bgcol) {
-	Graphics::drawEllipse(x - xr, y - yr, x + xr, y + yr, bgcol, true, drawPixel, dst);
-	Graphics::drawEllipse(x - xr, y - yr, x + xr, y + yr, fgcol, false, drawPixel, dst);
+	dst->drawEllipse(x - xr, y - yr, x + xr, y + yr, bgcol, true);
+	dst->drawEllipse(x - xr, y - yr, x + xr, y + yr, fgcol, false);
 }
 
 void emptyCircle(int x, int y, int xr, int yr, Graphics::ManagedSurface *dst, byte fgcol) {
-	Graphics::drawEllipse(x - xr, y - yr, x + xr, y + yr, fgcol, false, drawPixel, dst);
+	dst->drawEllipse(x - xr, y - yr, x + xr, y + yr, fgcol, false);
 }
 
 void rectClipped(const Common::Rect &r, const Common::Rect &clip, Graphics::ManagedSurface *dst, byte color) {
diff --git a/engines/dgds/drawing.h b/engines/dgds/drawing.h
index e62405fbd67..fb129838155 100644
--- a/engines/dgds/drawing.h
+++ b/engines/dgds/drawing.h
@@ -30,9 +30,6 @@ namespace Dgds {
 
 namespace Drawing {
 
-	// A function that can be used as the callback for Graphics::Primitives functions.
-	void drawPixel(int x, int y, int color, void *data);
-
 	void filledCircle(int x, int y, int xr, int yr, Graphics::ManagedSurface *dst, byte fgcol, byte bgcol);
 	void emptyCircle(int x, int y, int xr, int yr, Graphics::ManagedSurface *dst, byte fgcol);
 
diff --git a/engines/dgds/ttm.cpp b/engines/dgds/ttm.cpp
index 0145480c5b8..5d87acad335 100644
--- a/engines/dgds/ttm.cpp
+++ b/engines/dgds/ttm.cpp
@@ -23,7 +23,6 @@
 #include "common/serializer.h"
 
 #include "graphics/managed_surface.h"
-#include "graphics/primitives.h"
 
 #include "dgds/ttm.h"
 #include "dgds/ads.h"
@@ -263,22 +262,6 @@ const char *TTMInterpreter::ttmOpName(uint16 op) {
 	}
 }
 
-class ClipSurface {
-public:
-	ClipSurface(const Common::Rect &clipWin, Graphics::Surface *surf)
-		: _surf(surf), _clipWin(clipWin) { }
-	Graphics::Surface *_surf;
-	Common::Rect _clipWin;
-};
-
-static void plotClippedPoint(int x, int y, int color, void *data) {
-	ClipSurface *cs = (ClipSurface *)data;
-	if (cs->_clipWin.contains(x, y)) {
-		byte *ptr = (byte *)cs->_surf->getBasePtr(x, y);
-		*ptr = (byte)color;
-	}
-}
-
 static void _copyRectToScreen(const Graphics::ManagedSurface &src, const Common::Rect &r) {
 	if (r.isEmpty())
 		return;
@@ -934,8 +917,12 @@ void TTMInterpreter::handleOperation(TTMEnviro &env, TTMSeq &seq, uint16 op, byt
 		doWipeOp(op, env, seq, Common::Rect(Common::Point(ivals[0], ivals[1]), ivals[2], ivals[3]));
 		break;
 	case 0xa0a0: { // DRAW LINE  x1,y1,x2,y2:int
-		ClipSurface clipSurf(seq._drawWin, _vm->_compositionBuffer.surfacePtr());
-		Graphics::drawLine(ivals[0], ivals[1], ivals[2], ivals[3], seq._drawColFG, plotClippedPoint, &clipSurf);
+		Graphics::Surface clipSurf(_vm->_compositionBuffer.getSubArea(seq._drawWin));
+		clipSurf.drawLine(
+			ivals[0] - seq._drawWin.left,
+			ivals[1] - seq._drawWin.top,
+			ivals[2] - seq._drawWin.left,
+			ivals[3] - seq._drawWin.top, seq._drawColFG);
 		break;
 	}
 	case 0xa100: { // DRAW FILLED RECT x,y,w,h:int	[0..320,0..200]
@@ -1034,27 +1021,36 @@ void TTMInterpreter::handleOperation(TTMEnviro &env, TTMSeq &seq, uint16 op, byt
 		break;
 	}
 	case 0xaf10: { // DRAW EMPTY POLY [pts]
-		ClipSurface clipSurf(seq._drawWin, _vm->_compositionBuffer.surfacePtr());
+		Graphics::Surface clipSurf(_vm->_compositionBuffer.getSubArea(seq._drawWin));
 		for (uint i = 1; i < pts.size(); i++) {
 			const Common::Point &p1 = pts[i - 1];
 			const Common::Point &p2 = pts[i];
-			Graphics::drawLine(p1.x, p1.y, p2.x, p2.y, seq._drawColFG, plotClippedPoint, &clipSurf);
+			clipSurf.drawLine(
+				p1.x - seq._drawWin.left,
+				p1.y - seq._drawWin.top,
+				p2.x - seq._drawWin.left,
+				p2.y - seq._drawWin.top, seq._drawColFG);
 		}
 		if (pts.size() > 2)
-			Graphics::drawLine(pts.back().x, pts.back().y, pts[0].x, pts[0].y, seq._drawColFG,
-				plotClippedPoint, &clipSurf);
+			clipSurf.drawLine(
+				pts.back().x - seq._drawWin.left,
+				pts.back().y - seq._drawWin.top,
+				pts[0].x - seq._drawWin.left,
+				pts[0].y - seq._drawWin.top, seq._drawColFG);
 		break;
 	}
 	case 0xaf20: { // DRAW FILLED POLY [pts]
-		ClipSurface clipSurf(seq._drawWin, _vm->_compositionBuffer.surfacePtr());
+		Graphics::Surface clipSurf(_vm->_compositionBuffer.getSubArea(seq._drawWin));
 		Common::Array<int> xvals(pts.size());
 		Common::Array<int> yvals(pts.size());
 		for (uint i = 0; i < pts.size(); i++) {
-			xvals[i] = pts[i].x;
-			yvals[i] = pts[i].y;
+			xvals[i] = pts[i].x - seq._drawWin.left;
+			yvals[i] = pts[i].y - seq._drawWin.top;
 		}
-		Graphics::drawPolygonScan(xvals.data(), yvals.data(), pts.size(), seq._drawWin,
-					seq._drawColFG, plotClippedPoint, &clipSurf);
+		Common::Rect bbox(seq._drawWin);
+		bbox.moveTo(0, 0);
+		clipSurf.drawPolygonScan(xvals.data(), yvals.data(), pts.size(), bbox,
+					seq._drawColFG);
 		break;
 	}
 	case 0xb000: // INIT CREDITS SCRLL


Commit: 45768dbef6f6e95807117c134271363be9098295
    https://github.com/scummvm/scummvm/commit/45768dbef6f6e95807117c134271363be9098295
Author: Le Philousophe (lephilousophe at users.noreply.github.com)
Date: 2025-01-24T12:11:17+01:00

Commit Message:
GOB: Don't use deprecated primitives

Changed paths:
    engines/gob/surface.cpp


diff --git a/engines/gob/surface.cpp b/engines/gob/surface.cpp
index af040e187fd..7f2d1e99844 100644
--- a/engines/gob/surface.cpp
+++ b/engines/gob/surface.cpp
@@ -42,12 +42,33 @@
 
 namespace Gob {
 
-static void plotPixel(int x, int y, int color, void *data) {
-	Surface *dest = (Surface *)data;
+class SurfacePrimitives final : public Graphics::Primitives {
+public:
+        void drawPoint(int x, int y, uint32 color, void *data) override {
+		Surface *s = (Surface *)data;
+		s->putPixel(x, y, color);
+	}
 
-	dest->putPixel(x, y, color);
-}
+        void drawHLine(int x1, int x2, int y, uint32 color, void *data) override {
+		Surface *s = (Surface *)data;
+		s->fillRect(x1, y, x2, y, color);
+	}
+
+        void drawVLine(int x, int y1, int y2, uint32 color, void *data) override {
+		Surface *s = (Surface *)data;
+		s->fillRect(x, y1, x, y2, color);
+	}
+
+	void drawFilledRect(const Common::Rect &rect, uint32 color, void *data) override {
+		Surface *s = (Surface *)data;
+		s->fillRect(rect.left, rect.top, rect.right - 1, rect.bottom - 1, color);
+	}
 
+	void drawFilledRect1(const Common::Rect &rect, uint32 color, void *data) override {
+		Surface *s = (Surface *)data;
+		s->fillRect(rect.left, rect.top, rect.right, rect.bottom, color);
+	}
+};
 
 Pixel::Pixel(byte *vidMem, uint8 bpp, byte *min, byte *max) :
 	_vidMem(vidMem), _bpp(bpp), _min(min), _max(max) {
@@ -696,7 +717,7 @@ void Surface::putPixel(uint16 x, uint16 y, uint32 color) {
 }
 
 void Surface::drawLine(uint16 x0, uint16 y0, uint16 x1, uint16 y1, uint32 color) {
-	Graphics::drawLine(x0, y0, x1, y1, color, &plotPixel, this);
+	SurfacePrimitives().drawLine(x0, y0, x1, y1, color, this);
 }
 
 void Surface::drawRect(uint16 left, uint16 top, uint16 right, uint16 bottom, uint32 color) {


Commit: 6b24643bed989fb8fe0467d2abe5c91dae000f73
    https://github.com/scummvm/scummvm/commit/6b24643bed989fb8fe0467d2abe5c91dae000f73
Author: Le Philousophe (lephilousophe at users.noreply.github.com)
Date: 2025-01-24T12:11:17+01:00

Commit Message:
PARALLACTION: Don't use deprecated primitives

Changed paths:
    engines/parallaction/callables_ns.cpp
    engines/parallaction/graphics.cpp


diff --git a/engines/parallaction/callables_ns.cpp b/engines/parallaction/callables_ns.cpp
index a6bbc6ad614..effa08616f5 100644
--- a/engines/parallaction/callables_ns.cpp
+++ b/engines/parallaction/callables_ns.cpp
@@ -488,12 +488,14 @@ void Parallaction_ns::_c_moveSheet(void *parm) {
 	return;
 }
 
-void zeroMask(int x, int y, int color, void *data) {
-	BackgroundInfo *info = (BackgroundInfo *)data;
+class ZeroMaskPrimitives : public Graphics::Primitives {
+	void drawPoint(int x, int y, uint32 color, void *data) override {
+		BackgroundInfo *info = (BackgroundInfo *)data;
 
-	uint16 _ax = x + y * info->_mask->w;
-	info->_mask->data[_ax >> 2] &= ~(3 << ((_ax & 3) << 1));
-}
+		uint16 _ax = x + y * info->_mask->w;
+		info->_mask->data[_ax >> 2] &= ~(3 << ((_ax & 3) << 1));
+	}
+};
 
 void Parallaction_ns::_c_sketch(void *parm) {
 
@@ -519,7 +521,7 @@ void Parallaction_ns::_c_sketch(void *parm) {
 	}
 
 	if (_gfx->_backgroundInfo->hasMask()) {
-		Graphics::drawLine(oldx, oldy, newx, newy, 0, zeroMask, _gfx->_backgroundInfo);
+		ZeroMaskPrimitives().drawLine(oldx, oldy, newx, newy, 0, _gfx->_backgroundInfo);
 	}
 
 	_rightHandAnim->setX(newx);
diff --git a/engines/parallaction/graphics.cpp b/engines/parallaction/graphics.cpp
index 317e31dc291..78013419d9a 100644
--- a/engines/parallaction/graphics.cpp
+++ b/engines/parallaction/graphics.cpp
@@ -41,41 +41,42 @@ namespace Parallaction {
 
 #define	LABEL_TRANSPARENT_COLOR 0xFF
 
-void halfbritePixel(int x, int y, int color, void *data) {
-	Graphics::Surface *surf = (Graphics::Surface *)data;
-	byte *pixel = (byte *)surf->getBasePtr(x, y);
-	*pixel &= ~0x20;
-}
-
-void drawCircleLine(int xCenter, int yCenter, int x, int y, int color, void (*plotProc)(int, int, int, void *), void *data){
-	Graphics::drawLine(xCenter + x, yCenter + y, xCenter - x, yCenter + y, color, plotProc, data);
-	Graphics::drawLine(xCenter + x, yCenter - y, xCenter - x, yCenter - y, color, plotProc, data);
-	Graphics::drawLine(xCenter + y, yCenter + x, xCenter - y, yCenter + x, color, plotProc, data);
-	Graphics::drawLine(xCenter + y, yCenter - x, xCenter - y, yCenter - x, color, plotProc, data);
-}
-
-void drawCircle(int xCenter, int yCenter, int radius, int color, void (*plotProc)(int, int, int, void *), void *data) {
-	int x = 0;
-	int y = radius;
-	int p = 1 - radius;
-
-	/* Plot first set of points */
-	drawCircleLine(xCenter, yCenter, x, y, color, plotProc, data);
-
-	while (x < y) {
-		x++;
-		if (p < 0)
-			p += 2*x + 1;
-		else {
-			y--;
-			p += 2 * (x-y) + 1;
-		}
-		drawCircleLine(xCenter, yCenter, x, y, color, plotProc, data);
+class HalfbritePrimitives : public Graphics::Primitives {
+public:
+	void drawPoint(int x, int y, uint32 color, void *data) override {
+		Graphics::Surface *surf = (Graphics::Surface *)data;
+		byte *pixel = (byte *)surf->getBasePtr(x, y);
+		*pixel &= ~0x20;
 	}
-}
 
+	void drawCircleLine(int xCenter, int yCenter, int x, int y, int color, void *data) {
+		drawLine(xCenter + x, yCenter + y, xCenter - x, yCenter + y, color, data);
+		drawLine(xCenter + x, yCenter - y, xCenter - x, yCenter - y, color, data);
+		drawLine(xCenter + y, yCenter + x, xCenter - y, yCenter + x, color, data);
+		drawLine(xCenter + y, yCenter - x, xCenter - y, yCenter - x, color, data);
+	}
 
+	void drawCircle(int xCenter, int yCenter, int radius, int color, void *data) {
+		int x = 0;
+		int y = radius;
+		int p = 1 - radius;
+
+		/* Plot first set of points */
+		drawCircleLine(xCenter, yCenter, x, y, color, data);
+
+		while (x < y) {
+			x++;
+			if (p < 0)
+				p += 2*x + 1;
+			else {
+				y--;
+				p += 2 * (x-y) + 1;
+			}
+			drawCircleLine(xCenter, yCenter, x, y, color, data);
+		}
+	}
 
+};
 
 Palette::Palette() {
 
@@ -463,7 +464,7 @@ void Gfx::applyHalfbriteEffect_NS(Graphics::Surface &surf) {
 		}
 	}
 	if (_hbCircleRadius > 0) {
-		drawCircle(_hbCirclePos.x, _hbCirclePos.y, _hbCircleRadius, 0, &halfbritePixel, &surf);
+		HalfbritePrimitives().drawCircle(_hbCirclePos.x, _hbCirclePos.y, _hbCircleRadius, 0, &surf);
 	}
 }
 


Commit: 3761db383092940586a990e1d04cf5de1c3f4e2c
    https://github.com/scummvm/scummvm/commit/3761db383092940586a990e1d04cf5de1c3f4e2c
Author: Le Philousophe (lephilousophe at users.noreply.github.com)
Date: 2025-01-24T12:11:17+01:00

Commit Message:
PRINCE: Don't use deprecated primitives

Changed paths:
    engines/prince/hero.cpp
    engines/prince/prince.cpp
    engines/prince/prince.h


diff --git a/engines/prince/hero.cpp b/engines/prince/hero.cpp
index e702bcbb9f9..cd91d1aeaa5 100644
--- a/engines/prince/hero.cpp
+++ b/engines/prince/hero.cpp
@@ -33,6 +33,15 @@
 
 namespace Prince {
 
+class ShadowLinePlotter : public Graphics::Primitives {
+	void drawPoint(int x, int y, uint32 color, void *data) override {
+		PrinceEngine *vm = (PrinceEngine *)data;
+		WRITE_LE_UINT16(&vm->_shadowLine[vm->_shadLineLen * 4], x);
+		WRITE_LE_UINT16(&vm->_shadowLine[vm->_shadLineLen * 4 + 2], y);
+		vm->_shadLineLen++;
+	}
+};
+
 Hero::Hero(PrinceEngine *vm, GraphicsMan *graph) : _vm(vm), _graph(graph),
 	_number(0), _visible(false), _state(kHeroStateStay), _middleX(0), _middleY(0),
 	_boreNum(1), _currHeight(0), _moveDelay(0), _shadMinus(0), _moveSetType(0), _zoomedHeroSurface(nullptr),
@@ -231,7 +240,7 @@ void Hero::showHeroShadow(Graphics::Surface *screen, DrawNode *drawNode) {
 		}
 
 		vm->_shadLineLen = 0;
-		Graphics::drawLine(vm->_lightX, vm->_lightY, drawNode->posX, drawNode->posY, 0, &vm->plotShadowLinePoint, vm);
+		ShadowLinePlotter().drawLine(vm->_lightX, vm->_lightY, drawNode->posX, drawNode->posY, 0, vm);
 
 		byte *sprShadow = vm->_graph->_shadowTable70;
 
diff --git a/engines/prince/prince.cpp b/engines/prince/prince.cpp
index a573a054906..f838faf0bd2 100644
--- a/engines/prince/prince.cpp
+++ b/engines/prince/prince.cpp
@@ -465,13 +465,6 @@ void PrinceEngine::setShadowScale(int32 shadowScale) {
 	}
 }
 
-void PrinceEngine::plotShadowLinePoint(int x, int y, int color, void *data) {
-	PrinceEngine *vm = (PrinceEngine *)data;
-	WRITE_LE_UINT16(&vm->_shadowLine[vm->_shadLineLen * 4], x);
-	WRITE_LE_UINT16(&vm->_shadowLine[vm->_shadLineLen * 4 + 2], y);
-	vm->_shadLineLen++;
-}
-
 bool PrinceEngine::playNextFLCFrame() {
 	if (!_flicPlayer.isVideoLoaded())
 		return false;
diff --git a/engines/prince/prince.h b/engines/prince/prince.h
index 1aa9d6fe4e3..2f29d4e1fd2 100644
--- a/engines/prince/prince.h
+++ b/engines/prince/prince.h
@@ -380,7 +380,6 @@ public:
 	int32 _shadLineLen;
 	byte *_shadowLine;
 	void setShadowScale(int32 shadowScale);
-	static void plotShadowLinePoint(int x, int y, int color, void *data);
 
 	static const int16 kFPS = 15;
 	static const int32 kIntMax = 2147483647;


Commit: 378d9036499ad976149185fb71ac2791b89003d4
    https://github.com/scummvm/scummvm/commit/378d9036499ad976149185fb71ac2791b89003d4
Author: Le Philousophe (lephilousophe at users.noreply.github.com)
Date: 2025-01-24T12:11:17+01:00

Commit Message:
SCI: Don't use deprecated primitives

Changed paths:
    engines/sci/graphics/paint32.cpp
    engines/sci/graphics/paint32.h


diff --git a/engines/sci/graphics/paint32.cpp b/engines/sci/graphics/paint32.cpp
index 79d9baed271..f563a00dd3b 100644
--- a/engines/sci/graphics/paint32.cpp
+++ b/engines/sci/graphics/paint32.cpp
@@ -83,7 +83,7 @@ void GfxPaint32::kernelDeleteLine(const reg_t screenItemObject, const reg_t plan
 	g_sci->_gfxFrameout->deleteScreenItem(*screenItem, *plane);
 }
 
-void GfxPaint32::plotter(int x, int y, int color, void *data) {
+void GfxPaint32::Primitives::drawPoint(int x, int y, uint32 color, void *data) {
 	LineProperties &properties = *static_cast<LineProperties *>(data);
 	byte *pixels = properties.bitmap->getPixels();
 
@@ -178,10 +178,11 @@ reg_t GfxPaint32::makeLineBitmap(const Common::Point &startPoint, const Common::
 		properties.lastAddress = properties.horizontal ? x1 : y1;
 	}
 
+	Primitives primitives;
 	if (thickness <= 1) {
-		Graphics::drawLine(x1, y1, x2, y2, color, plotter, &properties);
+		primitives.drawLine(x1, y1, x2, y2, color, &properties);
 	} else {
-		Graphics::drawThickLine2(x1, y1, x2, y2, thickness, color, plotter, &properties);
+		primitives.drawThickLine2(x1, y1, x2, y2, thickness, color, &properties);
 	}
 
 	return bitmapId;
diff --git a/engines/sci/graphics/paint32.h b/engines/sci/graphics/paint32.h
index 4bbbff0fc67..1f60e2a39a9 100644
--- a/engines/sci/graphics/paint32.h
+++ b/engines/sci/graphics/paint32.h
@@ -22,6 +22,8 @@
 #ifndef SCI_GRAPHICS_PAINT32_H
 #define SCI_GRAPHICS_PAINT32_H
 
+#include "graphics/primitives.h"
+
 namespace Sci {
 class Plane;
 class SciBitmap;
@@ -61,7 +63,9 @@ private:
 		int lastAddress;
 	} LineProperties;
 
-	static void plotter(int x, int y, int color, void *data);
+	class Primitives : public Graphics::Primitives {
+		void drawPoint(int x, int y, uint32 color, void *data) override;
+	};
 
 	reg_t makeLineBitmap(const Common::Point &startPoint, const Common::Point &endPoint, const int16 priority, const uint8 color, const LineStyle style, const uint16 pattern, const uint8 thickness, Common::Rect &outRect);
 };


Commit: d77cf892c6a1910313288d27a91c3486a382eb7f
    https://github.com/scummvm/scummvm/commit/d77cf892c6a1910313288d27a91c3486a382eb7f
Author: Le Philousophe (lephilousophe at users.noreply.github.com)
Date: 2025-01-24T12:11:17+01:00

Commit Message:
SCUMM: Don't use deprecated primitives

Changed paths:
    engines/scumm/macgui/macgui_dialogwindow.cpp
    engines/scumm/macgui/macgui_impl.h
    engines/scumm/macgui/macgui_loom.cpp


diff --git a/engines/scumm/macgui/macgui_dialogwindow.cpp b/engines/scumm/macgui/macgui_dialogwindow.cpp
index fe5c53360c8..6ac4d3e8753 100644
--- a/engines/scumm/macgui/macgui_dialogwindow.cpp
+++ b/engines/scumm/macgui/macgui_dialogwindow.cpp
@@ -858,49 +858,51 @@ void MacGuiImpl::MacDialogWindow::drawSprite(const Graphics::Surface *sprite, in
 	}
 }
 
-void MacGuiImpl::MacDialogWindow::plotPixel(int x, int y, int color, void *data) {
-	MacGuiImpl::MacDialogWindow *window = (MacGuiImpl::MacDialogWindow *)data;
-	Graphics::Surface *s = window->innerSurface();
-	s->setPixel(x, y, color);
-}
-
 // I don't know if the original actually used two different plot functions, one
 // to fill and one to darken (used to draw over the text screens). It's such a
 // subtle effect that I suspect it was just doing some different magic, maybe
 // with XOR, but I couldn't get that to work by eye only.
 
-void MacGuiImpl::MacDialogWindow::plotPattern(int x, int y, int pattern, void *data) {
-	const uint16 patterns[] = {
-		0x0000, 0x2828, 0xA5A5, 0xD7D7,
-		0xFFFF,	0xD7D7, 0xA5A5, 0x2828
-	};
-
-	MacGuiImpl::MacDialogWindow *window = (MacGuiImpl::MacDialogWindow *)data;
-	Graphics::Surface *s = window->innerSurface();
-	int bit = 0x8000 >> (4 * (y % 4) + (x % 4));
-	if (patterns[pattern] & bit)
-		s->setPixel(x, y, window->_gui->getBlack());
-	else
-		s->setPixel(x, y, window->_gui->getWhite());
-}
-
-void MacGuiImpl::MacDialogWindow::plotPatternDarkenOnly(int x, int y, int pattern, void *data) {
-	const uint16 patterns[] = {
-		0x0000, 0x2828, 0xA5A5, 0xD7D7, 0xFFFF
-	};
-
-	MacGuiImpl::MacDialogWindow *window = (MacGuiImpl::MacDialogWindow *)data;
-	Graphics::Surface *s = window->innerSurface();
-	int bit = 0x8000 >> (4 * (y % 4) + (x % 4));
-	if (patterns[pattern] & bit)
-		s->setPixel(x, y, window->_gui->getBlack());
-}
+class PatternPrimitives : public Graphics::Primitives {
+	void drawPoint(int x, int y, uint32 pattern, void *data) override {
+		const uint16 patterns[] = {
+			0x0000, 0x2828, 0xA5A5, 0xD7D7,
+			0xFFFF,	0xD7D7, 0xA5A5, 0x2828
+		};
+
+		MacGuiImpl::MacDialogWindow *window = (MacGuiImpl::MacDialogWindow *)data;
+		Graphics::Surface *s = window->innerSurface();
+		int bit = 0x8000 >> (4 * (y % 4) + (x % 4));
+		if (patterns[pattern] & bit)
+			s->setPixel(x, y, window->_gui->getBlack());
+		else
+			s->setPixel(x, y, window->_gui->getWhite());
+	}
+};
+
+class PatternDarkenOnlyPrimitives : public Graphics::Primitives {
+	void drawPoint(int x, int y, uint32 pattern, void *data) override {
+		const uint16 patterns[] = {
+			0x0000, 0x2828, 0xA5A5, 0xD7D7, 0xFFFF
+		};
+
+		MacGuiImpl::MacDialogWindow *window = (MacGuiImpl::MacDialogWindow *)data;
+		Graphics::Surface *s = window->innerSurface();
+		int bit = 0x8000 >> (4 * (y % 4) + (x % 4));
+		if (patterns[pattern] & bit)
+			s->setPixel(x, y, window->_gui->getBlack());
+	}
+};
 
-void MacGuiImpl::MacDialogWindow::drawRoundRect(const Common::Rect &rect, int arc, uint32 color, bool filled, void (*plotProc)(int, int, int, void *)) {
+void MacGuiImpl::MacDialogWindow::drawPatternRoundRect(const Common::Rect &rect, int arc, uint32 color, bool filled, bool darkenOnly) {
 	// FIXME: This is a deprecated method, but we should replace it with
 	// something that matches QuickDraw's rounded rects instead.
 
-	Graphics::drawRoundRect(rect, arc, color, filled, plotProc, this);
+	if (darkenOnly) {
+		PatternDarkenOnlyPrimitives().drawRoundRect(rect, arc, color, filled, this);
+	} else {
+		PatternPrimitives().drawRoundRect(rect, arc, color, filled, this);
+	}
 }
 
 void MacGuiImpl::MacDialogWindow::drawTexts(Common::Rect r, const TextLine *lines, bool inverse) {
@@ -998,8 +1000,8 @@ void MacGuiImpl::MacDialogWindow::drawTextBox(Common::Rect r, const TextLine *li
 		bg = _white;
 	}
 
-	drawRoundRect(r, arc, bg, true, plotPixel);
-	drawRoundRect(r, arc, fg, false, plotPixel);
+	innerSurface()->drawRoundRect(r, arc, bg, true);
+	innerSurface()->drawRoundRect(r, arc, fg, false);
 	markRectAsDirty(r);
 
 	drawTexts(r, lines, inverse);
diff --git a/engines/scumm/macgui/macgui_impl.h b/engines/scumm/macgui/macgui_impl.h
index cc94f21c76d..1bfb22ef391 100644
--- a/engines/scumm/macgui/macgui_impl.h
+++ b/engines/scumm/macgui/macgui_impl.h
@@ -762,11 +762,7 @@ public:
 		void markRectAsDirty(Common::Rect r);
 		void update(bool fullRedraw = false);
 
-		static void plotPixel(int x, int y, int color, void *data);
-		static void plotPattern(int x, int y, int pattern, void *data);
-		static void plotPatternDarkenOnly(int x, int y, int pattern, void *data);
-
-		void drawRoundRect(const Common::Rect &rect, int arc, uint32 color, bool filled, void (*plotProc)(int, int, int, void *));
+		void drawPatternRoundRect(const Common::Rect &rect, int arc, uint32 color, bool filled, bool darkenOnly);
 
 		void drawDottedHLine(int x0, int y, int x1);
 		void fillPattern(Common::Rect r, uint16 pattern, bool fillBlack = true, bool fillWhite = true);
diff --git a/engines/scumm/macgui/macgui_loom.cpp b/engines/scumm/macgui/macgui_loom.cpp
index 78a83d5d446..29f078e620d 100644
--- a/engines/scumm/macgui/macgui_loom.cpp
+++ b/engines/scumm/macgui/macgui_loom.cpp
@@ -328,7 +328,7 @@ void MacLoomGui::runAboutDialog() {
 			if (pattern > 4)
 				darkenOnly = false;
 
-			window->drawRoundRect(r, 7, pattern, true, darkenOnly ? MacDialogWindow::plotPatternDarkenOnly : MacDialogWindow::plotPattern);
+			window->drawPatternRoundRect(r, 7, pattern, true, darkenOnly);
 
 			if (!fastForward)
 				window->markRectAsDirty(r);


Commit: e7f1bfc99960ad55ddd5518d72f5d1b0abeeee28
    https://github.com/scummvm/scummvm/commit/e7f1bfc99960ad55ddd5518d72f5d1b0abeeee28
Author: Le Philousophe (lephilousophe at users.noreply.github.com)
Date: 2025-01-24T12:11:17+01:00

Commit Message:
SWORD2: Don't use deprecated primitives

Changed paths:
    engines/sword2/render.cpp


diff --git a/engines/sword2/render.cpp b/engines/sword2/render.cpp
index d999023bf25..582aadd667a 100644
--- a/engines/sword2/render.cpp
+++ b/engines/sword2/render.cpp
@@ -245,10 +245,12 @@ void Screen::plotPoint(int x, int y, uint8 color) {
 	}
 }
 
-static void plot(int x, int y, int color, void *data) {
-	Screen *screen = (Screen *)data;
-	screen->plotPoint(x, y, (uint8) color);
-}
+class ScreenPrimitives : public Graphics::Primitives {
+	void drawPoint(int x, int y, uint32 color, void *data) override {
+		Screen *screen = (Screen *)data;
+		screen->plotPoint(x, y, (uint8) color);
+	}
+};
 
 /**
  * Draws a line from one point to another. This is only used for debugging.
@@ -260,7 +262,7 @@ static void plot(int x, int y, int color, void *data) {
  */
 
 void Screen::drawLine(int x0, int y0, int x1, int y1, uint8 color) {
-	Graphics::drawLine(x0, y0, x1, y1, color, &plot, this);
+	ScreenPrimitives().drawLine(x0, y0, x1, y1, color, this);
 }
 
 /**


Commit: 7a626614ecb5504dd34ff592584a62a1db89c9e9
    https://github.com/scummvm/scummvm/commit/7a626614ecb5504dd34ff592584a62a1db89c9e9
Author: Le Philousophe (lephilousophe at users.noreply.github.com)
Date: 2025-01-24T12:11:17+01:00

Commit Message:
TITANIC: Don't use deprecated primitives

Changed paths:
    engines/titanic/star_control/surface_area.cpp
    engines/titanic/star_control/surface_area.h


diff --git a/engines/titanic/star_control/surface_area.cpp b/engines/titanic/star_control/surface_area.cpp
index cd56ed21ea8..1c026aba6a7 100644
--- a/engines/titanic/star_control/surface_area.cpp
+++ b/engines/titanic/star_control/surface_area.cpp
@@ -121,6 +121,17 @@ void CSurfaceArea::pixelToRGB(uint pixel, uint *rgb) {
 	}
 }
 
+template<typename T>
+class CSurfacePrimitives : public Graphics::Primitives {
+	void drawPoint(int x, int y, uint32 color, void *data) override {
+		CSurfaceArea *sa = (CSurfaceArea *)data;
+		if (x >= 0 && x < sa->_width && y >= 0 && y < sa->_height) {
+			T *ptr = (T *)sa->_surface->getBasePtr(x, y);
+			*ptr = (*ptr & sa->_colorMask) ^ sa->_color;
+		}
+	}
+};
+
 double CSurfaceArea::drawLine(const FPoint &pt1, const FPoint &pt2) {
 	if (pt1 == pt2)
 		return pt1._y;
@@ -194,20 +205,20 @@ double CSurfaceArea::drawLine(const FPoint &pt1, const FPoint &pt2) {
 	switch (_bpp) {
 	case 0:
 		if (_mode != SA_SOLID) {
-			Graphics::drawLine(srcPos.x, srcPos.y, destPos.x, destPos.y, 0, plotPoint<byte>, this);
+			CSurfacePrimitives<byte>().drawLine(srcPos.x, srcPos.y, destPos.x, destPos.y, 0, this);
 			return p1._y;
 		}
 		break;
 	case 1:
 	case 2:
 		if (_mode != SA_SOLID) {
-			Graphics::drawLine(srcPos.x, srcPos.y, destPos.x, destPos.y, 0, plotPoint<uint16>, this);
+			CSurfacePrimitives<uint16>().drawLine(srcPos.x, srcPos.y, destPos.x, destPos.y, 0, this);
 			return p1._y;
 		}
 		break;
 	case 4:
 		if (_mode != SA_SOLID) {
-			Graphics::drawLine(srcPos.x, srcPos.y, destPos.x, destPos.y, 0, plotPoint<uint32>, this);
+			CSurfacePrimitives<uint32>().drawLine(srcPos.x, srcPos.y, destPos.x, destPos.y, 0, this);
 			return p1._y;
 		}
 		break;
diff --git a/engines/titanic/star_control/surface_area.h b/engines/titanic/star_control/surface_area.h
index dd6e2058032..a8378037a7e 100644
--- a/engines/titanic/star_control/surface_area.h
+++ b/engines/titanic/star_control/surface_area.h
@@ -34,14 +34,6 @@ enum SurfaceAreaMode {
 };
 
 class CSurfaceArea {
-	template<typename T>
-	static void plotPoint(int x, int y, int color, void *data) {
-		CSurfaceArea *sa = (CSurfaceArea *)data;
-		if (x >= 0 && x < sa->_width && y >= 0 && y < sa->_height) {
-			T *ptr = (T *)sa->_surface->getBasePtr(x, y);
-			*ptr = (*ptr & sa->_colorMask) ^ sa->_color;
-		}
-	}
 private:
 	/**
 	 * Initialize data for the class


Commit: 09b5ed6d925d03c4b7f567f6da74a15ed7df2cf4
    https://github.com/scummvm/scummvm/commit/09b5ed6d925d03c4b7f567f6da74a15ed7df2cf4
Author: Le Philousophe (lephilousophe at users.noreply.github.com)
Date: 2025-01-24T12:11:17+01:00

Commit Message:
TOUCHE: Don't use deprecated primitives

Changed paths:
    engines/touche/graphics.cpp


diff --git a/engines/touche/graphics.cpp b/engines/touche/graphics.cpp
index 384e8f58501..5a6652ef826 100644
--- a/engines/touche/graphics.cpp
+++ b/engines/touche/graphics.cpp
@@ -20,7 +20,7 @@
  */
 
 #include "common/endian.h"
-#include "graphics/primitives.h"
+#include "graphics/surface.h"
 
 #include "touche/graphics.h"
 
@@ -129,34 +129,25 @@ void Graphics::fillRect(uint8 *dst, int dstPitch, int x, int y, int w, int h, ui
 }
 
 void Graphics::drawRect(uint8 *dst, int dstPitch, int x, int y, int w, int h, uint8 color1, uint8 color2) {
+	::Graphics::Surface s;
+	s.init(x+w, y+h, dstPitch, dst, ::Graphics::PixelFormat::createFormatCLUT8());
 	const int x1 = x;
 	const int y1 = y;
 	const int x2 = x + w - 1;
 	const int y2 = y + h - 1;
-	drawLine(dst, dstPitch, x1, y1, x2, y1, color1);
-	drawLine(dst, dstPitch, x1, y1, x1, y2, color1);
-	drawLine(dst, dstPitch, x2, y1 + 1, x2, y2, color2);
-	drawLine(dst, dstPitch, x1 + 1, y2, x2, y2, color2);
-}
-
-struct drawLineHelperData {
-	uint8 *dst;
-	int width;
-};
-
-static void drawLineHelper(int x, int y, int c, void *data) {
-	drawLineHelperData *param = (drawLineHelperData *)data;
-	*(param->dst + y * param->width + x) = c;
+	s.hLine(x1, y1, x2, color1);
+	s.vLine(x1, y1, y2, color1);
+	s.vLine(x2, y1 + 1, y2, color2);
+	s.hLine(x1 + 1, y2, x2, color2);
 }
 
 void Graphics::drawLine(uint8 *dst, int dstPitch, int x1, int y1, int x2, int y2, uint8 color) {
 	assert(x1 >= 0 && y1 >= 0 && x2 >= 0 && y2 >= 0);
 
-	drawLineHelperData d;
-	d.dst = dst;
-	d.width = dstPitch;
+	::Graphics::Surface s;
+	s.init(MAX(x1, x2) + 1, MAX(y1, y2) + 1, dstPitch, dst, ::Graphics::PixelFormat::createFormatCLUT8());
 
-	::Graphics::drawLine(x1, y1, x2, y2, color, drawLineHelper, &d);
+	s.drawLine(x1, y1, x2, y2, color);
 }
 
 void Graphics::copyRect(uint8 *dst, int dstPitch, int dstX, int dstY, const uint8 *src, int srcPitch, int srcX, int srcY, int w, int h, int flags) {


Commit: 9b89dd6fa72aca530b1e7978c04f3eed63347b55
    https://github.com/scummvm/scummvm/commit/9b89dd6fa72aca530b1e7978c04f3eed63347b55
Author: Le Philousophe (lephilousophe at users.noreply.github.com)
Date: 2025-01-24T12:11:17+01:00

Commit Message:
WAGE: Don't use deprecated primitives

Changed paths:
    engines/wage/design.cpp
    engines/wage/design.h


diff --git a/engines/wage/design.cpp b/engines/wage/design.cpp
index 0b3a657390a..3810f69e0ae 100644
--- a/engines/wage/design.cpp
+++ b/engines/wage/design.cpp
@@ -63,7 +63,6 @@ struct PlotData {
 		surface(s), patterns(p), fillType(f), thickness(t), design(d) {}
 };
 
-void drawPixel(int x, int y, int color, void *data);
 void drawPixelPlain(int x, int y, int color, void *data);
 
 Design::Design(Common::SeekableReadStream *data) {
@@ -205,107 +204,114 @@ void Design::adjustBounds(int16 x, int16 y) {
 	_bounds->bottom = MAX(y, _bounds->bottom);
 }
 
-void drawPixel(int x, int y, int color, void *data) {
-	PlotData *p = (PlotData *)data;
+class PlotDataPrimitives : public Graphics::Primitives {
+	void drawPoint(int x, int y, uint32 color, void *data) override {
+		PlotData *p = (PlotData *)data;
 
-	if (p->fillType > p->patterns->size())
-		return;
+		if (p->fillType > p->patterns->size())
+			return;
+
+		if (p->design && p->design->isBoundsCalculation()) {
+			if (x < 0 || y < 0)
+				return;
+			if (p->thickness == 1) {
+				p->design->adjustBounds(x, y);
+			} else {
+				int x1 = x;
+				int x2 = x1 + p->thickness;
+				int y1 = y;
+				int y2 = y1 + p->thickness;
+
+				for (y = y1; y < y2; y++)
+					for (x = x1; x < x2; x++)
+						p->design->adjustBounds(x, y);
+			}
 
-	if (p->design && p->design->isBoundsCalculation()) {
-		if (x < 0 || y < 0)
 			return;
+		}
+
+		const byte *pat = p->patterns->operator[](p->fillType - 1);
+
 		if (p->thickness == 1) {
-			p->design->adjustBounds(x, y);
+			if (x >= 0 && x < p->surface->w && y >= 0 && y < p->surface->h) {
+				uint xu = (uint)x; // for letting compiler optimize it
+				uint yu = (uint)y;
+
+				*((byte *)p->surface->getBasePtr(xu, yu)) =
+					(pat[yu % 8] & (1 << (7 - xu % 8))) ?
+						color : kColorWhite;
+			}
 		} else {
-			int x1 = x;
+			int x1 = x - p->thickness / 2;
 			int x2 = x1 + p->thickness;
-			int y1 = y;
+			int y1 = y - p->thickness / 2;
 			int y2 = y1 + p->thickness;
 
 			for (y = y1; y < y2; y++)
 				for (x = x1; x < x2; x++)
-					p->design->adjustBounds(x, y);
+					if (x >= 0 && x < p->surface->w && y >= 0 && y < p->surface->h) {
+						uint xu = (uint)x; // for letting compiler optimize it
+						uint yu = (uint)y;
+						*((byte *)p->surface->getBasePtr(xu, yu)) =
+							(pat[yu % 8] & (1 << (7 - xu % 8))) ?
+								color : kColorWhite;
+					}
 		}
-
-		return;
 	}
+};
 
-	const byte *pat = p->patterns->operator[](p->fillType - 1);
+class PlotDataCirclePrimitives : public Graphics::Primitives {
+	void drawPoint(int x, int y, uint32 color, void *data) override {
+		PlotData *p = (PlotData *)data;
 
-	if (p->thickness == 1) {
-		if (x >= 0 && x < p->surface->w && y >= 0 && y < p->surface->h) {
-			uint xu = (uint)x; // for letting compiler optimize it
-			uint yu = (uint)y;
+		if (p->fillType > p->patterns->size())
+			return;
 
-			*((byte *)p->surface->getBasePtr(xu, yu)) =
-				(pat[yu % 8] & (1 << (7 - xu % 8))) ?
-					color : kColorWhite;
-		}
-	} else {
-		int x1 = x - p->thickness / 2;
-		int x2 = x1 + p->thickness;
-		int y1 = y - p->thickness / 2;
-		int y2 = y1 + p->thickness;
-
-		for (y = y1; y < y2; y++)
-			for (x = x1; x < x2; x++)
-				if (x >= 0 && x < p->surface->w && y >= 0 && y < p->surface->h) {
-					uint xu = (uint)x; // for letting compiler optimize it
-					uint yu = (uint)y;
-					*((byte *)p->surface->getBasePtr(xu, yu)) =
-						(pat[yu % 8] & (1 << (7 - xu % 8))) ?
-							color : kColorWhite;
-				}
-	}
-}
+		if (p->design && p->design->isBoundsCalculation()) {
+			if (x < 0 || y < 0)
+				return;
+			if (p->thickness == 1) {
+				p->design->adjustBounds(x, y);
+			} else {
+				int x1 = x;
+				int x2 = x1 + p->thickness;
+				int y1 = y;
+				int y2 = y1 + p->thickness;
+
+				for (y = y1; y < y2; y++)
+					for (x = x1; x < x2; x++)
+						p->design->adjustBounds(x, y);
+			}
 
-void drawPixelCircle(int x, int y, int color, void *data) {
-	PlotData *p = (PlotData *)data;
+			return;
+		}
 
-	if (p->fillType > p->patterns->size())
-		return;
+		const byte *pat = p->patterns->operator[](p->fillType - 1);
 
-	if (p->design && p->design->isBoundsCalculation()) {
-		if (x < 0 || y < 0)
-			return;
+		// Draw circle when thickness is > 1, put a pixel otherwise
 		if (p->thickness == 1) {
-			p->design->adjustBounds(x, y);
+			if (x >= 0 && x < p->surface->w && y >= 0 && y < p->surface->h) {
+				uint xu = (uint)x; // for letting compiler optimize it
+				uint yu = (uint)y;
+
+				*((byte *)p->surface->getBasePtr(xu, yu)) =
+					(pat[yu % 8] & (1 << (7 - xu % 8))) ? color : kColorWhite;
+			}
 		} else {
-			int x1 = x;
+			int x1 = x - p->thickness / 2;
 			int x2 = x1 + p->thickness;
-			int y1 = y;
+			int y1 = y - p->thickness / 2;
 			int y2 = y1 + p->thickness;
 
-			for (y = y1; y < y2; y++)
-				for (x = x1; x < x2; x++)
-					p->design->adjustBounds(x, y);
-		}
-
-		return;
-	}
-
-	const byte *pat = p->patterns->operator[](p->fillType - 1);
-
-	// Draw circle when thickness is > 1, put a pixel otherwise
-	if (p->thickness == 1) {
-		if (x >= 0 && x < p->surface->w && y >= 0 && y < p->surface->h) {
-			uint xu = (uint)x; // for letting compiler optimize it
-			uint yu = (uint)y;
+			PlotData pd(p->surface, p->patterns, p->fillType, 1, p->design);
 
-			*((byte *)p->surface->getBasePtr(xu, yu)) =
-				(pat[yu % 8] & (1 << (7 - xu % 8))) ? color : kColorWhite;
+			subprimitives.drawEllipse(x1, y1, x2 - 1, y2 - 1, kColorBlack, true, &pd);
 		}
-	} else {
-		int x1 = x - p->thickness / 2;
-		int x2 = x1 + p->thickness;
-		int y1 = y - p->thickness / 2;
-		int y2 = y1 + p->thickness;
-
-		PlotData pd(p->surface, p->patterns, p->fillType, 1, p->design);
-
-		Graphics::drawEllipse(x1, y1, x2 - 1, y2 - 1, kColorBlack, true, drawPixel, &pd);
 	}
-}
+
+private:
+	PlotDataPrimitives subprimitives;
+};
 
 void drawPixelPlain(int x, int y, int color, void *data) {
 	PlotData *p = (PlotData *)data;
@@ -348,9 +354,10 @@ void Design::drawRect(Graphics::ManagedSurface *surface, Common::ReadStream &in,
 
 	Common::Rect r(x1, y1, x2, y2);
 	PlotData pd(surface, &patterns, fillType, 1, this);
+	PlotDataPrimitives primitives;
 
 	if (fillType <= patterns.size())
-		Graphics::drawFilledRect1(r, kColorBlack, drawPixel, &pd);
+		primitives.drawFilledRect1(r, kColorBlack, &pd);
 
 	pd.fillType = borderFillType;
 	pd.thickness = borderThickness;
@@ -363,10 +370,10 @@ void Design::drawRect(Graphics::ManagedSurface *surface, Common::ReadStream &in,
 	}
 
 	if (borderThickness > 0 && borderFillType <= patterns.size()) {
-		Graphics::drawLine(x1, y1, x2, y1, kColorBlack, drawPixel, &pd);
-		Graphics::drawLine(x2, y1, x2, y2, kColorBlack, drawPixel, &pd);
-		Graphics::drawLine(x2, y2, x1, y2, kColorBlack, drawPixel, &pd);
-		Graphics::drawLine(x1, y2, x1, y1, kColorBlack, drawPixel, &pd);
+		primitives.drawLine(x1, y1, x2, y1, kColorBlack, &pd);
+		primitives.drawLine(x2, y1, x2, y2, kColorBlack, &pd);
+		primitives.drawLine(x2, y2, x1, y2, kColorBlack, &pd);
+		primitives.drawLine(x1, y2, x1, y1, kColorBlack, &pd);
 	}
 }
 
@@ -400,15 +407,16 @@ void Design::drawRoundRect(Graphics::ManagedSurface *surface, Common::ReadStream
 
 	Common::Rect r(x1, y1, x2, y2);
 	PlotData pd(surface, &patterns, fillType, 1, this);
+	PlotDataPrimitives primitives;
 
 	if (fillType <= patterns.size())
-		Graphics::drawRoundRect1(r, arc / 2, kColorBlack, true, drawPixel, &pd);
+		primitives.drawRoundRect1(r, arc / 2, kColorBlack, true, &pd);
 
 	pd.fillType = borderFillType;
 	pd.thickness = borderThickness;
 
 	if (borderThickness > 0 && borderFillType <= patterns.size())
-		Graphics::drawRoundRect1(r, arc / 2 - 1, kColorBlack, false, drawPixel, &pd);
+		primitives.drawRoundRect1(r, arc / 2 - 1, kColorBlack, false, &pd);
 }
 
 void Design::drawPolygon(Graphics::ManagedSurface *surface, Common::ReadStream &in,
@@ -487,16 +495,17 @@ void Design::drawPolygon(Graphics::ManagedSurface *surface, Common::ReadStream &
 	}
 
 	PlotData pd(surface, &patterns, fillType, 1, this);
+	PlotDataPrimitives primitives;
 
 	if (fillType <= patterns.size()) {
-		Graphics::drawPolygonScan(xpoints, ypoints, npoints, bbox, kColorBlack, drawPixel, &pd);
+		primitives.drawPolygonScan(xpoints, ypoints, npoints, bbox, kColorBlack, &pd);
 	}
 
 	pd.fillType = borderFillType;
 	pd.thickness = borderThickness;
 	if (borderThickness > 0 && borderFillType <= patterns.size()) {
 		for (int i = 1; i < npoints; i++)
-			Graphics::drawLine(xpoints[i-1], ypoints[i-1], xpoints[i], ypoints[i], kColorBlack, drawPixel, &pd);
+			primitives.drawLine(xpoints[i-1], ypoints[i-1], xpoints[i], ypoints[i], kColorBlack, &pd);
 	}
 
 	free(xpoints);
@@ -510,6 +519,7 @@ void Design::drawOval(Graphics::ManagedSurface *surface, Common::ReadStream &in,
 	int16 y2 = in.readSint16BE();
 	int16 x2 = in.readSint16BE();
 	PlotData pd(surface, &patterns, fillType, 1, this);
+	PlotDataPrimitives primitives;
 
 	if (_surface) {
 		if (!_maskImage) {
@@ -520,7 +530,7 @@ void Design::drawOval(Graphics::ManagedSurface *surface, Common::ReadStream &in,
 	}
 
 	if (fillType <= patterns.size())
-		Graphics::drawEllipse(x1, y1, x2-1, y2-1, kColorBlack, true, drawPixel, &pd);
+		PlotDataPrimitives().drawEllipse(x1, y1, x2-1, y2-1, kColorBlack, true, &pd);
 
 	pd.fillType = borderFillType;
 	pd.thickness = borderThickness;
@@ -533,7 +543,7 @@ void Design::drawOval(Graphics::ManagedSurface *surface, Common::ReadStream &in,
 	}
 
 	if (borderThickness > 0 && borderFillType <= patterns.size())
-		Graphics::drawEllipse(x1, y1, x2 - 1, y2 - 1, kColorBlack, false, drawPixelCircle, &pd);
+		PlotDataCirclePrimitives().drawEllipse(x1, y1, x2 - 1, y2 - 1, kColorBlack, false, &pd);
 }
 
 void Design::drawBitmap(Graphics::ManagedSurface *surface, Common::SeekableReadStream &in) {
@@ -640,43 +650,35 @@ void Design::drawBitmap(Graphics::ManagedSurface *surface, Common::SeekableReadS
 	tmp.free();
 }
 
-void Design::drawRect(Graphics::ManagedSurface *surface, Common::Rect &rect, int thickness, int color, Graphics::MacPatterns &patterns, byte fillType) {
-	drawRect(surface, rect.left, rect.top, rect.right, rect.bottom, thickness, color, patterns, fillType);
+void Design::drawRect(Graphics::ManagedSurface *surface, const Common::Rect &rect, int thickness, int color, Graphics::MacPatterns &patterns, byte fillType) {
+	PlotData pd(surface, &patterns, fillType, thickness, nullptr);
+	PlotDataPrimitives().drawRect1(rect, kColorBlack, &pd);
 }
 
 void Design::drawRect(Graphics::ManagedSurface *surface, int x1, int y1, int x2, int y2, int thickness, int color, Graphics::MacPatterns &patterns, byte fillType) {
-	PlotData pd(surface, &patterns, fillType, thickness, nullptr);
-
-	Graphics::drawLine(x1, y1, x2, y1, kColorBlack, drawPixel, &pd);
-	Graphics::drawLine(x2, y1, x2, y2, kColorBlack, drawPixel, &pd);
-	Graphics::drawLine(x2, y2, x1, y2, kColorBlack, drawPixel, &pd);
-	Graphics::drawLine(x1, y2, x1, y1, kColorBlack, drawPixel, &pd);
+	drawRect(surface, Common::Rect(MIN(x1, x2), MIN(y1, y2), MAX(x1, x2), MAX(y1, y2)),
+			thickness, color, patterns, fillType);
 }
 
 
 void Design::drawFilledRect(Graphics::ManagedSurface *surface, Common::Rect &rect, int color, Graphics::MacPatterns &patterns, byte fillType) {
 	PlotData pd(surface, &patterns, fillType, 1, nullptr);
-
-	for (int y = rect.top; y <= rect.bottom; y++)
-		Graphics::drawHLine(rect.left, rect.right, y, color, drawPixel, &pd);
+	PlotDataPrimitives().drawFilledRect1(rect, color, &pd);
 }
 
 void Design::drawFilledRoundRect(Graphics::ManagedSurface *surface, Common::Rect &rect, int arc, int color, Graphics::MacPatterns &patterns, byte fillType) {
 	PlotData pd(surface, &patterns, fillType, 1, nullptr);
-
-	Graphics::drawRoundRect1(rect, arc, color, true, drawPixel, &pd);
+	PlotDataPrimitives().drawRoundRect1(rect, arc, color, true, &pd);
 }
 
 void Design::drawHLine(Graphics::ManagedSurface *surface, int x1, int x2, int y, int thickness, int color, Graphics::MacPatterns &patterns, byte fillType) {
 	PlotData pd(surface, &patterns, fillType, thickness, nullptr);
-
-	Graphics::drawHLine(x1, x2, y, color, drawPixel, &pd);
+	PlotDataPrimitives().drawHLine(x1, x2, y, color, &pd);
 }
 
 void Design::drawVLine(Graphics::ManagedSurface *surface, int x, int y1, int y2, int thickness, int color, Graphics::MacPatterns &patterns, byte fillType) {
 	PlotData pd(surface, &patterns, fillType, thickness, nullptr);
-
-	Graphics::drawVLine(x, y1, y2, color, drawPixel, &pd);
+	PlotDataPrimitives().drawVLine(x, y1, y2, color, &pd);
 }
 
 } // End of namespace Wage
diff --git a/engines/wage/design.h b/engines/wage/design.h
index c2d38e8eea7..36ec9903bd1 100644
--- a/engines/wage/design.h
+++ b/engines/wage/design.h
@@ -72,7 +72,7 @@ public:
 
 	void paint(Graphics::ManagedSurface *canvas, Graphics::MacPatterns &patterns, int x, int y);
 	bool isInBounds(int x, int y);
-	static void drawRect(Graphics::ManagedSurface *surface, Common::Rect &rect, int thickness, int color, Graphics::MacPatterns &patterns, byte fillType);
+	static void drawRect(Graphics::ManagedSurface *surface, const Common::Rect &rect, int thickness, int color, Graphics::MacPatterns &patterns, byte fillType);
 	static void drawRect(Graphics::ManagedSurface *surface, int x1, int y1, int x2, int y2, int thickness, int color, Graphics::MacPatterns &patterns, byte fillType);
 	static void drawFilledRect(Graphics::ManagedSurface *surface, Common::Rect &rect, int color, Graphics::MacPatterns &patterns, byte fillType);
 	static void drawFilledRoundRect(Graphics::ManagedSurface *surface, Common::Rect &rect, int arc, int color, Graphics::MacPatterns &patterns, byte fillType);


Commit: 3b62b557d4c8526709658c7835f3a89ff01b60ec
    https://github.com/scummvm/scummvm/commit/3b62b557d4c8526709658c7835f3a89ff01b60ec
Author: Le Philousophe (lephilousophe at users.noreply.github.com)
Date: 2025-01-24T12:11:17+01:00

Commit Message:
GRAPHICS: Remove obsolete and unused primitives

Changed paths:
    graphics/primitives.cpp
    graphics/primitives.h


diff --git a/graphics/primitives.cpp b/graphics/primitives.cpp
index fa71bb4d061..5cebe128d19 100644
--- a/graphics/primitives.cpp
+++ b/graphics/primitives.cpp
@@ -451,83 +451,4 @@ void Primitives::drawEllipse(int x0, int y0, int x1, int y1, uint32 color, bool
 	}
 }
 
-class DeprecatedPrimitives final : public Primitives {
-public:
-	constexpr DeprecatedPrimitives(void (*plotProc)(int, int, int, void *)) : _plotProc(plotProc) {}
-
-	void drawPoint(int x, int y, uint32 color, void *data) override {
-		_plotProc(x, y, color, data);
-	}
-
-private:
-	void (*_plotProc)(int, int, int, void *);
-};
-
-void drawLine(int x0, int y0, int x1, int y1, uint32 color, void (*plotProc)(int, int, int, void *), void *data) {
-	DeprecatedPrimitives primitives(plotProc);
-	primitives.drawLine(x0, y0, x1, y1, color, data);
-}
-
-void drawHLine(int x1, int x2, int y, uint32 color, void (*plotProc)(int, int, int, void *), void *data) {
-	DeprecatedPrimitives primitives(plotProc);
-	primitives.drawHLine(x1, x2, y, color, data);
-}
-
-void drawVLine(int x, int y1, int y2, uint32 color, void (*plotProc)(int, int, int, void *), void *data) {
-	DeprecatedPrimitives primitives(plotProc);
-	primitives.drawVLine(x, y1, y2, color, data);
-}
-
-void drawThickLine(int x0, int y0, int x1, int y1, int penX, int penY, uint32 color, void (*plotProc)(int, int, int, void *), void *data) {
-	DeprecatedPrimitives primitives(plotProc);
-	primitives.drawThickLine(x0, y0, x1, y1, penX, penY, color, data);
-}
-
-void drawThickLine2(int x1, int y1, int x2, int y2, int thick, uint32 color,
-								void (*plotProc)(int, int, int, void *), void *data) {
-	DeprecatedPrimitives primitives(plotProc);
-	primitives.drawThickLine2(x1, y1, x2, y2, thick, color, data);
-}
-
-void drawFilledRect(const Common::Rect &rect, uint32 color, void (*plotProc)(int, int, int, void *), void *data) {
-	DeprecatedPrimitives primitives(plotProc);
-	primitives.drawFilledRect(rect, color, data);
-}
-
-void drawFilledRect1(const Common::Rect &rect, uint32 color, void (*plotProc)(int, int, int, void *), void *data) {
-	DeprecatedPrimitives primitives(plotProc);
-	primitives.drawFilledRect1(rect, color, data);
-}
-
-void drawRect(const Common::Rect &rect, uint32 color, void (*plotProc)(int, int, int, void *), void *data) {
-	DeprecatedPrimitives primitives(plotProc);
-	primitives.drawRect(rect, color, data);
-}
-
-void drawRect1(const Common::Rect &rect, uint32 color, void (*plotProc)(int, int, int, void *), void *data) {
-	DeprecatedPrimitives primitives(plotProc);
-	primitives.drawRect1(rect, color, data);
-}
-
-void drawRoundRect(const Common::Rect &rect, int arc, uint32 color, bool filled, void (*plotProc)(int, int, int, void *), void *data) {
-	DeprecatedPrimitives primitives(plotProc);
-	primitives.drawRoundRect(rect, arc, color, filled, data);
-}
-
-void drawRoundRect1(const Common::Rect &rect, int arc, uint32 color, bool filled, void (*plotProc)(int, int, int, void *), void *data) {
-	DeprecatedPrimitives primitives(plotProc);
-	primitives.drawRoundRect1(rect, arc, color, filled, data);
-}
-
-void drawPolygonScan(const int *polyX, const int *polyY, int npoints, const Common::Rect &bbox, uint32 color,
-								void (*plotProc)(int, int, int, void *), void *data) {
-	DeprecatedPrimitives primitives(plotProc);
-	primitives.drawPolygonScan(polyX, polyY, npoints, bbox, color, data);
-}
-
-void drawEllipse(int x0, int y0, int x1, int y1, uint32 color, bool filled, void (*plotProc)(int, int, int, void *), void *data) {
-	DeprecatedPrimitives primitives(plotProc);
-	primitives.drawEllipse(x0, y0, x1, y1, color, filled, data);
-}
-
 } // End of namespace Graphics
diff --git a/graphics/primitives.h b/graphics/primitives.h
index 95b86a01766..536c5c55432 100644
--- a/graphics/primitives.h
+++ b/graphics/primitives.h
@@ -47,35 +47,6 @@ public:
 	virtual void drawEllipse(int x0, int y0, int x1, int y1, uint32 color, bool filled, void *data);
 };
 
-WARN_DEPRECATED("Use a subclass of Graphics::Primitives")
-void drawLine(int x0, int y0, int x1, int y1, uint32 color, void (*plotProc)(int, int, int, void *), void *data);
-WARN_DEPRECATED("Use a subclass of Graphics::Primitives")
-void drawHLine(int x1, int x2, int y, uint32 color, void (*plotProc)(int, int, int, void *), void *data);
-WARN_DEPRECATED("Use a subclass of Graphics::Primitives")
-void drawVLine(int x, int y1, int y2, uint32 color, void (*plotProc)(int, int, int, void *), void *data);
-WARN_DEPRECATED("Use a subclass of Graphics::Primitives")
-void drawThickLine(int x0, int y0, int x1, int y1, int penX, int penY, uint32 color, void (*plotProc)(int, int, int, void *), void *data);
-WARN_DEPRECATED("Use a subclass of Graphics::Primitives")
-void drawThickLine2(int x1, int y1, int x2, int y2, int thick, uint32 color,
-								void (*plotProc)(int, int, int, void *), void *data);
-WARN_DEPRECATED("Use a subclass of Graphics::Primitives")
-void drawFilledRect(const Common::Rect &rect, uint32 color, void (*plotProc)(int, int, int, void *), void *data);
-WARN_DEPRECATED("Use a subclass of Graphics::Primitives")
-void drawFilledRect1(const Common::Rect &rect, uint32 color, void (*plotProc)(int, int, int, void *), void *data);
-WARN_DEPRECATED("Use a subclass of Graphics::Primitives")
-void drawRect(const Common::Rect &rect, uint32 color, void (*plotProc)(int, int, int, void *), void *data);
-WARN_DEPRECATED("Use a subclass of Graphics::Primitives")
-void drawRect1(const Common::Rect &rect, uint32 color, void (*plotProc)(int, int, int, void *), void *data);
-WARN_DEPRECATED("Use a subclass of Graphics::Primitives")
-void drawRoundRect(const Common::Rect &rect, int arc, uint32 color, bool filled, void (*plotProc)(int, int, int, void *), void *data);
-WARN_DEPRECATED("Use a subclass of Graphics::Primitives")
-void drawRoundRect1(const Common::Rect &rect, int arc, uint32 color, bool filled, void (*plotProc)(int, int, int, void *), void *data);
-WARN_DEPRECATED("Use a subclass of Graphics::Primitives")
-void drawPolygonScan(const int *polyX, const int *polyY, int npoints, const Common::Rect &bbox, uint32 color,
-								void (*plotProc)(int, int, int, void *), void *data);
-WARN_DEPRECATED("Use a subclass of Graphics::Primitives")
-void drawEllipse(int x0, int y0, int x1, int y1, uint32 color, bool filled, void (*plotProc)(int, int, int, void *), void *data);
-
 } // End of namespace Graphics
 
 #endif




More information about the Scummvm-git-logs mailing list