[Scummvm-git-logs] scummvm master -> 919e48d964fed6302a29ed800aef563f635ee9c2

dreammaster noreply at scummvm.org
Sat Sep 6 22:07:51 UTC 2025


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

Summary:
919e48d964 BAGEL: MFC: Remove pointer references from GDI object classes


Commit: 919e48d964fed6302a29ed800aef563f635ee9c2
    https://github.com/scummvm/scummvm/commit/919e48d964fed6302a29ed800aef563f635ee9c2
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-09-06T15:07:45-07:00

Commit Message:
BAGEL: MFC: Remove pointer references from GDI object classes

Changed paths:
    engines/bagel/hodjnpodj/artparts/artparts.cpp
    engines/bagel/mfc/afxwin.h
    engines/bagel/mfc/brush.cpp
    engines/bagel/mfc/dc.cpp
    engines/bagel/mfc/palette.cpp
    engines/bagel/mfc/pen.cpp
    engines/bagel/mfc/win_app.cpp


diff --git a/engines/bagel/hodjnpodj/artparts/artparts.cpp b/engines/bagel/hodjnpodj/artparts/artparts.cpp
index beab6169cda..f67744bc460 100644
--- a/engines/bagel/hodjnpodj/artparts/artparts.cpp
+++ b/engines/bagel/hodjnpodj/artparts/artparts.cpp
@@ -1263,8 +1263,8 @@ BOOL CMainWindow::CopyPaletteContents(CPalette *pSource, CPalette *pDest) {
 		return FALSE;
 
 	// Use C++-isms to copy palette contents from src to dest
-	Graphics::Palette *src = pSource->_palette;
-	Graphics::Palette *dest = pDest->_palette;
+	Graphics::Palette *src = pSource->palette();
+	Graphics::Palette *dest = pDest->palette();
 	*dest = *src;
 
 	return TRUE;
diff --git a/engines/bagel/mfc/afxwin.h b/engines/bagel/mfc/afxwin.h
index 74de7a45266..66902d9278b 100644
--- a/engines/bagel/mfc/afxwin.h
+++ b/engines/bagel/mfc/afxwin.h
@@ -516,7 +516,9 @@ public:
 		}
 	};
 
-	Impl *&_pen = *(Impl **)&m_hObject;
+	Impl *pen() const {
+		return (Impl *)m_hObject;
+	}
 
 public:
 	CPen() {}
@@ -541,7 +543,9 @@ public:
 		byte getColor() const;
 	};
 
-	Impl *&_brush = *(Impl **)&m_hObject;
+	Impl *brush() const {
+		return (Impl *)m_hObject;
+	}
 
 public:
 	static CBrush *FromHandle(HGDIOBJ h) {
@@ -574,7 +578,9 @@ public:
 		}
 	};
 
-	Impl *&_font = *(Impl **)&m_hObject;
+	Impl *font() const {
+		return (Impl *)m_hObject;
+	}
 
 public:
 	static CFont *FromHandle(HGDIOBJ h) {
@@ -599,7 +605,9 @@ public:
 		~Impl() override {}
 	};
 
-	Impl *&_bitmap = *(Impl **)&m_hObject;
+	Impl *bitmap() const {
+		return (Impl *)m_hObject;
+	}
 
 public:
 	static CBitmap *FromHandle(HGDIOBJ h) {
@@ -630,7 +638,9 @@ public:
 		~Impl() override {}
 	};
 
-	Impl *&_palette = *(Impl **)&m_hObject;
+	Impl *palette() const {
+		return (Impl *)m_hObject;
+	}
 
 public:
 	static CPalette *FromHandle(HGDIOBJ h) {
@@ -653,7 +663,7 @@ public:
 	                    const PALETTEENTRY *lpPaletteColors);
 	UINT GetNearestPaletteIndex(COLORREF crColor);
 	bool isEmpty() const {
-		return !_palette || _palette->empty();
+		return !palette() || palette()->empty();
 	}
 };
 
@@ -2039,8 +2049,8 @@ public:
 	}
 	HFONT getFont(const char *lpszFacename, int nHeight);
 	HFONT getDefaultFont() {
-		assert(_defaultFont._font);
-		return (HFONT)_defaultFont._font;
+		assert(_defaultFont.m_hObject);
+		return (HFONT)_defaultFont.m_hObject;
 	}
 	HPEN getDefaultPen() const {
 		assert(_defaultPen.m_hObject);
@@ -2051,8 +2061,8 @@ public:
 		return (HBRUSH)_defaultBrush.m_hObject;
 	}
 	HPALETTE getSystemPalette() {
-		assert(_systemPalette._palette);
-		return _systemPalette._palette;
+		assert(_systemPalette.m_hObject);
+		return (HPALETTE)_systemPalette.m_hObject;
 	}
 
 	LPCSTR AfxRegisterWndClass(UINT nClassStyle,
diff --git a/engines/bagel/mfc/brush.cpp b/engines/bagel/mfc/brush.cpp
index 4efec803c61..5e65ec2c681 100644
--- a/engines/bagel/mfc/brush.cpp
+++ b/engines/bagel/mfc/brush.cpp
@@ -29,7 +29,7 @@ CBrush::CBrush() {
 }
 
 CBrush::CBrush(CBitmap *pBitmap) {
-	_brush = new Impl(pBitmap);
+	m_hObject = new Impl(pBitmap);
 }
 
 CBrush::CBrush(COLORREF crColor) {
@@ -37,12 +37,12 @@ CBrush::CBrush(COLORREF crColor) {
 }
 
 CBrush::CBrush(int nIndex, COLORREF crColor) {
-	_brush = new Impl(nIndex, crColor);
+	m_hObject = new Impl(nIndex, crColor);
 }
 
 BOOL CBrush::CreateSolidBrush(COLORREF crColor) {
 	DeleteObject();
-	_brush = new Impl(crColor);
+	m_hObject = new Impl(crColor);
 
 	AfxHookObject();
 	return true;
@@ -50,7 +50,7 @@ BOOL CBrush::CreateSolidBrush(COLORREF crColor) {
 
 BOOL CBrush::CreateBrushIndirect(const LOGBRUSH *lpLogBrush) {
 	DeleteObject();
-	_brush = new Impl(lpLogBrush->lbStyle,
+	m_hObject = new Impl(lpLogBrush->lbStyle,
 	    lpLogBrush->lbColor);
 
 	AfxHookObject();
diff --git a/engines/bagel/mfc/dc.cpp b/engines/bagel/mfc/dc.cpp
index bc0688cd39a..a7a53ef1ee1 100644
--- a/engines/bagel/mfc/dc.cpp
+++ b/engines/bagel/mfc/dc.cpp
@@ -657,7 +657,7 @@ CDC::Impl::Impl(CWnd *wndOwner) : m_pWnd(wndOwner), _drawMode(R2_COPYPEN) {
 	// By default the _bitmap will point to
 	// this dummy 1x1 bitmap
 	_defaultBitmap.CreateBitmap(1, 1, 1, 8, nullptr);
-	_bitmap = _defaultBitmap._bitmap;
+	_bitmap = _defaultBitmap.bitmap();
 
 	// Defaults
 	CWinApp *app = AfxGetApp();
@@ -673,7 +673,7 @@ CDC::Impl::Impl(HDC srcDc) {
 	// By default the _bitmap will point to
 	// this dummy 1x1 bitmap
 	_defaultBitmap.CreateBitmap(1, 1, 1, 8, nullptr);
-	_bitmap = _defaultBitmap._bitmap;
+	_bitmap = _defaultBitmap.bitmap();
 
 	if (src) {
 		_font = src->_font;
@@ -736,14 +736,14 @@ const Graphics::PixelFormat &CDC::Impl::getFormat() const {
 }
 
 void CDC::Impl::setFormat(const Graphics::PixelFormat &format) {
-	_defaultBitmap._bitmap->create(1, 1, format);
-	_bitmap = _defaultBitmap._bitmap;
+	_defaultBitmap.bitmap()->create(1, 1, format);
+	_bitmap = _defaultBitmap.bitmap();
 }
 
 void CDC::Impl::setScreenRect() {
 	Graphics::Screen *scr = AfxGetApp()->getScreen();
-	_defaultBitmap._bitmap->create(*scr, Common::Rect(0, 0, scr->w, scr->h));
-	_bitmap = _defaultBitmap._bitmap;
+	_defaultBitmap.bitmap()->create(*scr, Common::Rect(0, 0, scr->w, scr->h));
+	_bitmap = _defaultBitmap.bitmap();
 }
 
 void CDC::Impl::setScreenRect(const Common::Rect &r) {
@@ -751,8 +751,8 @@ void CDC::Impl::setScreenRect(const Common::Rect &r) {
 	assert(r.left >= 0 && r.top >= 0 &&
 		r.right <= scr->w && r.bottom <= scr->h);
 
-	_defaultBitmap._bitmap->create(*scr, r);
-	_bitmap = _defaultBitmap._bitmap;
+	_defaultBitmap.bitmap()->create(*scr, r);
+	_bitmap = _defaultBitmap.bitmap();
 }
 
 HPALETTE CDC::Impl::selectPalette(HPALETTE pal, BOOL bForceBackground) {
@@ -827,11 +827,11 @@ void CDC::Impl::fillRect(const Common::Rect &r, COLORREF crColor) {
 void CDC::Impl::drawRect(const Common::Rect &r, CBrush *brush) {
 	CBitmap::Impl *bitmap = (CBitmap::Impl *)_bitmap;
 	CPen::Impl *pen = (CPen::Impl *)_pen;
-	byte brushColor = brush->_brush->getColor();
+	byte brushColor = brush->brush()->getColor();
 	uint penColor = getPenColor();
 
 	if (pen->_penStyle == PS_INSIDEFRAME &&
-			brush->_brush->_type != BS_HOLLOW) {
+			brush->brush()->_type != BS_HOLLOW) {
 		Common::Rect rInner(r.left + 1, r.top + 1,
 			r.right - 1, r.bottom - 1);
 		bitmap->fillRect(rInner, brushColor);
@@ -842,7 +842,7 @@ void CDC::Impl::drawRect(const Common::Rect &r, CBrush *brush) {
 
 void CDC::Impl::frameRect(const Common::Rect &r, CBrush *brush) {
 	CBitmap::Impl *bitmap = (CBitmap::Impl *)_bitmap;
-	byte brushColor = brush->_brush->getColor();
+	byte brushColor = brush->brush()->getColor();
 
 	bitmap->frameRect(r, brushColor);
 }
diff --git a/engines/bagel/mfc/palette.cpp b/engines/bagel/mfc/palette.cpp
index b2e2b538cde..3f911ea90d6 100644
--- a/engines/bagel/mfc/palette.cpp
+++ b/engines/bagel/mfc/palette.cpp
@@ -27,7 +27,7 @@ namespace MFC {
 
 BOOL CPalette::CreatePalette(LPLOGPALETTE lpLogPalette) {
 	DeleteObject();
-	_palette = new Impl(lpLogPalette);
+	m_hObject = new Impl(lpLogPalette);
 
 	// This is where it becomes permanent
 	AfxHookObject();
@@ -111,7 +111,7 @@ BOOL CPalette::AnimatePalette(UINT nStartIndex, UINT nNumEntries,
 }
 
 UINT CPalette::GetNearestPaletteIndex(COLORREF crColor) {
-	return _palette->findBestColor(
+	return palette()->findBestColor(
 		GetRValue(crColor),
 		GetGValue(crColor),
 		GetBValue(crColor)
diff --git a/engines/bagel/mfc/pen.cpp b/engines/bagel/mfc/pen.cpp
index 53809ec8079..e2977b5f7c3 100644
--- a/engines/bagel/mfc/pen.cpp
+++ b/engines/bagel/mfc/pen.cpp
@@ -30,7 +30,7 @@ CPen::CPen(int nPenStyle, int nWidth, COLORREF crColor) {
 }
 
 BOOL CPen::CreatePen(int nPenStyle, int nWidth, COLORREF crColor) {
-	_pen = new Impl(nPenStyle, nWidth, crColor);
+	m_hObject = new Impl(nPenStyle, nWidth, crColor);
 	AfxHookObject();
 	return true;
 }
diff --git a/engines/bagel/mfc/win_app.cpp b/engines/bagel/mfc/win_app.cpp
index 59009484195..aaedfb9991a 100644
--- a/engines/bagel/mfc/win_app.cpp
+++ b/engines/bagel/mfc/win_app.cpp
@@ -153,7 +153,7 @@ BOOL CWinApp::SaveAllModified() {
 
 int CWinApp::Run() {
 	// Ensure app has been initialized
-	assert(_defaultFont._font);
+	assert(_defaultFont.font());
 
 	SetCursor(LoadCursor(IDC_ARROW));
 
@@ -303,7 +303,7 @@ byte CWinApp::getColor(COLORREF color) const {
 	if (color <= 0xff || (color >> 24) == 1)
 		return (byte)(color & 0xff);
 
-	return _currentPalette._palette->findBestColor(
+	return _currentPalette.palette()->findBestColor(
 		GetRValue(color),
 		GetGValue(color),
 		GetBValue(color)




More information about the Scummvm-git-logs mailing list