[Scummvm-git-logs] scummvm master -> c0a219af447d66399525d1ef0ff64b98513ae018
dreammaster
noreply at scummvm.org
Wed Oct 29 10:42:59 UTC 2025
This automated email contains information about 3 new commits which have been
pushed to the 'scummvm' repo located at https://api.github.com/repos/scummvm/scummvm .
Summary:
a57f1b7df3 BAGEL: MFC: Implement RealizePalette palette mapping
2b2a0c5bed BAGEL: MFC: Move creating palette map to it's own function
c0a219af44 BAGEL: MFC: Implementing window palette functions
Commit: a57f1b7df3a406e988d895c67e505f577be62464
https://github.com/scummvm/scummvm/commit/a57f1b7df3a406e988d895c67e505f577be62464
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-10-28T22:28:59-07:00
Commit Message:
BAGEL: MFC: Implement RealizePalette palette mapping
Changed paths:
engines/bagel/mfc/afxwin.h
engines/bagel/mfc/dc.cpp
engines/bagel/mfc/gfx/blitter.cpp
engines/bagel/mfc/gfx/blitter.h
engines/bagel/mfc/wingdi.cpp
diff --git a/engines/bagel/mfc/afxwin.h b/engines/bagel/mfc/afxwin.h
index 0726c039387..42187da8a28 100644
--- a/engines/bagel/mfc/afxwin.h
+++ b/engines/bagel/mfc/afxwin.h
@@ -744,7 +744,8 @@ public:
int _bkMode = TRANSPARENT;
COLORREF _textColor = 0;
uint _textAlign = TA_LEFT;
- int _drawMode;
+ int _drawMode = 0;
+ bool _paletteRealized = false;
uint getPenColor() const;
uint getBrushColor() const;
diff --git a/engines/bagel/mfc/dc.cpp b/engines/bagel/mfc/dc.cpp
index 89455e10bee..351e3319afa 100644
--- a/engines/bagel/mfc/dc.cpp
+++ b/engines/bagel/mfc/dc.cpp
@@ -790,9 +790,10 @@ unsigned int CDC::Impl::realizePalette() {
// This window is active - update the system palette
AfxGetApp()->setPalette(*pal);
return 1; // number of entries changed - simplified
+ } else {
+ _paletteRealized = true;
}
- // Not active - do not change system palette
return 0;
}
@@ -1013,28 +1014,53 @@ void CDC::Impl::bitBlt(int x, int y, int nWidth, int nHeight, CDC *pSrcDC,
Gfx::Surface dummySrc;
Gfx::Surface *src = &dummySrc;
+ uint32 *paletteMap = nullptr;
if (pSrcDC) {
- src = pSrcDC->impl()->getSurface();
- //CPoint srcOrg = src->getViewportOrg();
+ auto *srcImpl = pSrcDC->impl();
+ src = srcImpl->getSurface();
+
+ // If the source DC has a realized palette, we need to set up a palette map
+ // so that palette indexes can be mapped to our own destination palette
+ if (_paletteRealized) {
+ const Graphics::Palette *srcPal = dynamic_cast<Graphics::Palette *>(srcImpl->_palette);
+ const Graphics::Palette *destPal = dynamic_cast<Graphics::Palette *>(_palette);
+ assert(srcPal && destPal);
+ Graphics::PaletteLookup palLookup(srcPal->data(), srcPal->size());
+ paletteMap = palLookup.createMap(destPal->data(), destPal->size());
+ }
}
Gfx::Surface *dest = getSurface();
const Common::Point destPos(x, y);
uint bgColor = getBkPixel();
- Gfx::blit(src, dest, srcRect, destPos, bgColor, dwRop);
+ Gfx::blit(src, dest, srcRect, destPos, bgColor, dwRop, paletteMap);
+
+ delete[] paletteMap;
}
void CDC::Impl::stretchBlt(int x, int y, int nWidth, int nHeight, CDC *pSrcDC,
int xSrc, int ySrc, int nSrcWidth, int nSrcHeight, uint32 dwRop) {
- Gfx::Surface *src = pSrcDC->impl()->getSurface();
+ auto *srcImpl = pSrcDC->impl();
+ Gfx::Surface *src = srcImpl->getSurface();
Gfx::Surface *dest = getSurface();
const Common::Rect srcRect(xSrc, ySrc, xSrc + nSrcWidth, ySrc + nSrcHeight);
const Common::Rect destRect(x, y, x + nWidth, y + nHeight);
uint bgColor = getBkPixel();
+ uint32 *paletteMap = nullptr;
+
+ if (pSrcDC && _paletteRealized) {
+ const Graphics::Palette *srcPal = dynamic_cast<Graphics::Palette *>(srcImpl->_palette);
+ const Graphics::Palette *destPal = dynamic_cast<Graphics::Palette *>(_palette);
+ assert(srcPal && destPal);
+ Graphics::PaletteLookup palLookup(srcPal->data(), srcPal->size());
+ paletteMap = palLookup.createMap(destPal->data(), destPal->size());
+ }
+
+ Gfx::stretchBlit(src, dest, srcRect, destRect, bgColor, dwRop, nullptr);
- Gfx::stretchBlit(src, dest, srcRect, destRect, bgColor, dwRop);
+ delete[] paletteMap;
}
void CDC::Impl::moveTo(int x, int y) {
diff --git a/engines/bagel/mfc/gfx/blitter.cpp b/engines/bagel/mfc/gfx/blitter.cpp
index c586da516ec..a197c102920 100644
--- a/engines/bagel/mfc/gfx/blitter.cpp
+++ b/engines/bagel/mfc/gfx/blitter.cpp
@@ -28,27 +28,31 @@ namespace MFC {
namespace Gfx {
static inline void copyPixel(const byte *srcP, byte *destP, int mode, const byte &WHITE,
- bool isDestMonochrome, uint bgColor) {
+ bool isDestMonochrome, uint bgColor, const uint32 *paletteMap) {
+ byte src = *srcP;
+ if (paletteMap)
+ src = paletteMap[src];
+
switch (mode) {
case SRCCOPY:
- *destP = *srcP;
+ *destP = src;
break;
case SRCAND:
- *destP &= *srcP;
+ *destP &= src;
break;
case SRCINVERT:
- *destP ^= *srcP;
+ *destP ^= src;
break;
case SRCPAINT:
- *destP |= *srcP;
+ *destP |= src;
break;
case NOTSRCCOPY:
if (isDestMonochrome) {
- *destP = *srcP == bgColor ? 0 : 0xff;
+ *destP = src == bgColor ? 0 : 0xff;
return;
}
- *destP = ~*srcP;
+ *destP = ~src;
break;
case DSTINVERT:
*destP = ~*destP;
@@ -71,7 +75,7 @@ static inline void copyPixel(const byte *srcP, byte *destP, int mode, const byte
static void blitInner(Gfx::Surface *srcSurface,
Gfx::Surface *destSurface,
const Common::Rect &srcRect, const Common::Point &destPos,
- uint bgColor, int mode) {
+ uint bgColor, int mode, const uint32 *paletteMap) {
const bool isDestMonochrome = destSurface->format.bytesPerPixel == 1 &&
destSurface->format.aLoss == 255;
const byte WHITE = 255;
@@ -91,7 +95,7 @@ static void blitInner(Gfx::Surface *srcSurface,
if (!destP)
destP = &dummy;
- copyPixel(srcP, destP, mode, WHITE, isDestMonochrome, bgColor);
+ copyPixel(srcP, destP, mode, WHITE, isDestMonochrome, bgColor, paletteMap);
}
}
}
@@ -99,7 +103,7 @@ static void blitInner(Gfx::Surface *srcSurface,
static void stretchBlitInner(Gfx::Surface *srcSurface,
Gfx::Surface *destSurface,
const Common::Rect &srcRect, const Common::Rect &dstRect,
- uint bgColor, int mode) {
+ uint bgColor, int mode, const uint32 *paletteMap) {
const bool isDestMonochrome = destSurface->format.bytesPerPixel == 1 &&
destSurface->format.aLoss == 255;
const byte WHITE = 255;
@@ -140,14 +144,14 @@ static void stretchBlitInner(Gfx::Surface *srcSurface,
yDest = dstY;
byte *destP = xDest;
- copyPixel(srcP, destP, mode, WHITE, isDestMonochrome, bgColor);
+ copyPixel(srcP, destP, mode, WHITE, isDestMonochrome, bgColor, paletteMap);
}
}
}
void blit(Gfx::Surface *src, Gfx::Surface *dest,
const Common::Rect &srcRect, const Common::Point &destPos,
- uint bgColor, int mode) {
+ uint bgColor, int mode, const uint32 *paletteMap) {
// For normal copying modes, the formats must match.
// Other modes like DSTINVERT don't need a source,
// so in that case the source can remain uninitialized
@@ -156,7 +160,7 @@ void blit(Gfx::Surface *src, Gfx::Surface *dest,
assert(dest->format.bytesPerPixel == dest->format.bytesPerPixel ||
dest->format.bytesPerPixel == 0);
- blitInner(src, dest, srcRect, destPos, bgColor, mode);
+ blitInner(src, dest, srcRect, destPos, bgColor, mode, paletteMap);
Common::Rect dirtyRect(destPos.x, destPos.y,
destPos.x + srcRect.width(), destPos.y + srcRect.height());
@@ -165,13 +169,13 @@ void blit(Gfx::Surface *src, Gfx::Surface *dest,
void stretchBlit(Gfx::Surface *src, Gfx::Surface *dest,
const Common::Rect &srcRect, const Common::Rect &destRect,
- uint bgColor, int mode) {
+ uint bgColor, int mode, const uint32 *paletteMap) {
assert(src->format.bytesPerPixel == dest->format.bytesPerPixel ||
src->format.bytesPerPixel == 0);
assert(dest->format.bytesPerPixel == dest->format.bytesPerPixel ||
dest->format.bytesPerPixel == 0);
- stretchBlitInner(src, dest, srcRect, destRect, bgColor, mode);
+ stretchBlitInner(src, dest, srcRect, destRect, bgColor, mode, paletteMap);
}
static inline void rasterPixel(byte *pixel, byte) {
diff --git a/engines/bagel/mfc/gfx/blitter.h b/engines/bagel/mfc/gfx/blitter.h
index e3503659d9e..3cf326544c8 100644
--- a/engines/bagel/mfc/gfx/blitter.h
+++ b/engines/bagel/mfc/gfx/blitter.h
@@ -30,12 +30,11 @@ namespace Gfx {
extern void blit(Gfx::Surface *src, Gfx::Surface *dest,
const Common::Rect &srcRect, const Common::Point &destPos,
- uint bgColor, int mode);
+ uint bgColor, int mode, const uint32 *paletteMap);
extern void stretchBlit(Gfx::Surface *src, Gfx::Surface *dest,
- const Common::Rect &srcRect,
- const Common::Rect &destRect,
- uint bgColor, int mode);
+ const Common::Rect &srcRect, const Common::Rect &destRect,
+ uint bgColor, int mode, const uint32 *paletteMap);
extern void frameRect(Gfx::Surface *dest,
const Common::Rect &r, byte color, int drawMode);
diff --git a/engines/bagel/mfc/wingdi.cpp b/engines/bagel/mfc/wingdi.cpp
index 0a2f7240c9b..6511c05d9d9 100644
--- a/engines/bagel/mfc/wingdi.cpp
+++ b/engines/bagel/mfc/wingdi.cpp
@@ -250,7 +250,7 @@ bool BitBlt(HDC hdc, int xDest, int yDest, int width, int height,
Gfx::blit(src, dest,
Common::Rect(xSrc, ySrc, xSrc + width, ySrc + height),
Common::Point(xDest, yDest),
- bgColor, rop);
+ bgColor, rop, nullptr);
return true;
}
Commit: 2b2a0c5bede21380a2bfd6b35293f3633ec9584c
https://github.com/scummvm/scummvm/commit/2b2a0c5bede21380a2bfd6b35293f3633ec9584c
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-10-29T02:40:42-07:00
Commit Message:
BAGEL: MFC: Move creating palette map to it's own function
Changed paths:
engines/bagel/mfc/afxwin.h
engines/bagel/mfc/dc.cpp
diff --git a/engines/bagel/mfc/afxwin.h b/engines/bagel/mfc/afxwin.h
index 42187da8a28..42419367d64 100644
--- a/engines/bagel/mfc/afxwin.h
+++ b/engines/bagel/mfc/afxwin.h
@@ -749,6 +749,7 @@ public:
uint getPenColor() const;
uint getBrushColor() const;
+ uint32 *getPaletteMap(const Graphics::Palette *srcPal, const Graphics::Palette *destPal);
public:
HBITMAP _bitmap;
diff --git a/engines/bagel/mfc/dc.cpp b/engines/bagel/mfc/dc.cpp
index 351e3319afa..5f42524df49 100644
--- a/engines/bagel/mfc/dc.cpp
+++ b/engines/bagel/mfc/dc.cpp
@@ -1025,9 +1025,7 @@ void CDC::Impl::bitBlt(int x, int y, int nWidth, int nHeight, CDC *pSrcDC,
if (_paletteRealized) {
const Graphics::Palette *srcPal = dynamic_cast<Graphics::Palette *>(srcImpl->_palette);
const Graphics::Palette *destPal = dynamic_cast<Graphics::Palette *>(_palette);
- assert(srcPal && destPal);
- Graphics::PaletteLookup palLookup(srcPal->data(), srcPal->size());
- paletteMap = palLookup.createMap(destPal->data(), destPal->size());
+ paletteMap = getPaletteMap(srcPal, destPal);
}
}
@@ -1053,9 +1051,7 @@ void CDC::Impl::stretchBlt(int x, int y, int nWidth, int nHeight, CDC *pSrcDC,
if (pSrcDC && _paletteRealized) {
const Graphics::Palette *srcPal = dynamic_cast<Graphics::Palette *>(srcImpl->_palette);
const Graphics::Palette *destPal = dynamic_cast<Graphics::Palette *>(_palette);
- assert(srcPal && destPal);
- Graphics::PaletteLookup palLookup(srcPal->data(), srcPal->size());
- paletteMap = palLookup.createMap(destPal->data(), destPal->size());
+ paletteMap = getPaletteMap(srcPal, destPal);
}
Gfx::stretchBlit(src, dest, srcRect, destRect, bgColor, dwRop, nullptr);
@@ -1063,6 +1059,12 @@ void CDC::Impl::stretchBlt(int x, int y, int nWidth, int nHeight, CDC *pSrcDC,
delete[] paletteMap;
}
+uint32 *CDC::Impl::getPaletteMap(const Graphics::Palette *srcPal, const Graphics::Palette *destPal) {
+ assert(srcPal && destPal && srcPal->size() == destPal->size());
+ Graphics::PaletteLookup palLookup(srcPal->data(), srcPal->size());
+ return palLookup.createMap(destPal->data(), destPal->size());
+}
+
void CDC::Impl::moveTo(int x, int y) {
_linePos.x = x;
_linePos.y = y;
Commit: c0a219af447d66399525d1ef0ff64b98513ae018
https://github.com/scummvm/scummvm/commit/c0a219af447d66399525d1ef0ff64b98513ae018
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-10-29T02:48:28-07:00
Commit Message:
BAGEL: MFC: Implementing window palette functions
Changed paths:
engines/bagel/mfc/afxmsg.h
engines/bagel/mfc/afxwin.h
engines/bagel/mfc/libs/event_loop.cpp
engines/bagel/mfc/wnd.cpp
diff --git a/engines/bagel/mfc/afxmsg.h b/engines/bagel/mfc/afxmsg.h
index b31056397d9..cad317d7e13 100644
--- a/engines/bagel/mfc/afxmsg.h
+++ b/engines/bagel/mfc/afxmsg.h
@@ -189,6 +189,10 @@ namespace MFC {
#define WM_EXITMENULOOP 0x0212
#define WM_MOUSELEAVE 0x02A3
#define UNICODE_NOCHAR 0xFFFF
+
+#define WM_QUERYNEWPALETTE 0x030f
+#define WM_PALETTEISCHANGING 0x0310
+#define WM_PALETTECHANGED 0x0311
#define WM_INITIALUPDATE 0x0364 // (params unused) - sent to children
#define MM_JOY1MOVE 0x3A0
diff --git a/engines/bagel/mfc/afxwin.h b/engines/bagel/mfc/afxwin.h
index 42419367d64..55655e53e3e 100644
--- a/engines/bagel/mfc/afxwin.h
+++ b/engines/bagel/mfc/afxwin.h
@@ -444,6 +444,7 @@ union MessageMapFunctions {
void (AFX_MSG_CALL CWnd:: *pfn_vOWNER)(int, uint16 *); // force return true
int (AFX_MSG_CALL CWnd:: *pfn_iis)(int, uint16 *);
unsigned int(AFX_MSG_CALL CWnd:: *pfn_wp)(CPoint);
+ bool(AFX_MSG_CALL CWnd:: *pfn_bv)();
unsigned int(AFX_MSG_CALL CWnd:: *pfn_wv)();
void (AFX_MSG_CALL CWnd:: *pfn_vPOS)(WINDOWPOS *);
void (AFX_MSG_CALL CWnd:: *pfn_vCALC)(bool, NCCALCSIZE_PARAMS *);
@@ -1211,9 +1212,6 @@ protected:
afx_msg bool OnQueryEndSession() {
return false;
}
- afx_msg bool OnQueryNewPalette() {
- return false;
- }
afx_msg bool OnQueryOpen() {
return false;
}
@@ -1228,6 +1226,7 @@ protected:
afx_msg unsigned int OnQueryUIState() {
return 0;
}
+ afx_msg bool OnQueryNewPalette();
// Nonclient-Area message handler member functions
afx_msg bool OnNcActivate(bool bActive) {
diff --git a/engines/bagel/mfc/libs/event_loop.cpp b/engines/bagel/mfc/libs/event_loop.cpp
index 8a082afd2b6..94a47087c88 100644
--- a/engines/bagel/mfc/libs/event_loop.cpp
+++ b/engines/bagel/mfc/libs/event_loop.cpp
@@ -63,11 +63,15 @@ void EventLoop::SetActiveWindow(CWnd *wnd) {
// open windows at the same time. Each new window
// is effectively a dialog on top of previous ones
- if (!_activeWindows.empty())
- _activeWindows.top()->SendMessage(WM_ACTIVATE, MAKEWPARAM(WA_INACTIVE, 0), 0);
+ if (!_activeWindows.empty()) {
+ auto *win = _activeWindows.top();
+ win->SendMessage(WM_ACTIVATE, MAKEWPARAM(WA_INACTIVE, 0), 0);
+ win->SendMessage(WM_PALETTECHANGED, (WPARAM)wnd);
+ }
_activeWindows.push(wnd);
wnd->SendMessage(WM_ACTIVATE, MAKEWPARAM(WA_ACTIVE, 0), 0);
+ wnd->SendMessage(WM_QUERYNEWPALETTE, 0, 0);
}
void EventLoop::PopActiveWindow() {
diff --git a/engines/bagel/mfc/wnd.cpp b/engines/bagel/mfc/wnd.cpp
index fb82b6d6391..7ecc8a70c70 100644
--- a/engines/bagel/mfc/wnd.cpp
+++ b/engines/bagel/mfc/wnd.cpp
@@ -40,6 +40,7 @@ BEGIN_MESSAGE_MAP(CWnd, CCmdTarget)
ON_WM_SETFONT()
ON_WM_SETCURSOR()
ON_WM_SHOWWINDOW()
+ ON_WM_QUERYNEWPALETTE()
END_MESSAGE_MAP()
CWnd *CWnd::FromHandlePermanent(HWND hWnd) {
@@ -747,7 +748,11 @@ bool CWnd::OnWndMsg(unsigned int message, WPARAM wParam, LPARAM lParam, LRESULT
}
break;
- case AfxSig_wv: // AfxSig_bv, AfxSig_wv
+ case AfxSig_bv:
+ lResult = (this->*mmf.pfn_bv)() ? 1 : 0;
+ break;
+
+ case AfxSig_wv:
lResult = (this->*mmf.pfn_wv)();
break;
@@ -1251,5 +1256,11 @@ HWND CWnd::Detach() {
return hWnd;
}
+bool CWnd::OnQueryNewPalette() {
+ Invalidate();
+ UpdateWindow();
+ return true;
+}
+
} // namespace MFC
} // namespace Bagel
More information about the Scummvm-git-logs
mailing list