[Scummvm-git-logs] scummvm master -> fd6ddff1238650a244617bf41f02eceec76cee52

sev- noreply at scummvm.org
Fri Feb 20 00:11:21 UTC 2026


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:
fd6ddff123 GRAPHICS: MACGUI: Added two masks to MacText


Commit: fd6ddff1238650a244617bf41f02eceec76cee52
    https://github.com/scummvm/scummvm/commit/fd6ddff1238650a244617bf41f02eceec76cee52
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-02-20T01:10:55+01:00

Commit Message:
GRAPHICS: MACGUI: Added two masks to MacText

One mask is for characters-only, and another one for individual
string bboxes

Changed paths:
    graphics/macgui/mactext-canvas.cpp
    graphics/macgui/mactext-canvas.h
    graphics/macgui/mactext.cpp
    graphics/macgui/mactext.h


diff --git a/graphics/macgui/mactext-canvas.cpp b/graphics/macgui/mactext-canvas.cpp
index b090cee6c1b..de4784292cf 100644
--- a/graphics/macgui/mactext-canvas.cpp
+++ b/graphics/macgui/mactext-canvas.cpp
@@ -40,6 +40,8 @@ namespace Graphics {
 MacTextCanvas::~MacTextCanvas() {
 	delete _surface;
 	delete _shadowSurface;
+	delete _glyphsMask;
+	delete _charBoxMask;
 
 	for (auto &t : _text) {
 		delete t.table;
@@ -642,6 +644,11 @@ void MacTextCanvas::reallocSurface() {
 
 	if (!_surface) {
 		_surface = new ManagedSurface(_maxWidth, _textMaxHeight, _wm->_pixelformat);
+		_charBoxMask = new ManagedSurface(_maxWidth, _textMaxHeight, Graphics::PixelFormat::createFormatCLUT8());
+		_glyphsMask = new ManagedSurface(_maxWidth, _textMaxHeight, Graphics::PixelFormat::createFormatCLUT8());
+
+		_charBoxMask->clear(0);
+		_glyphsMask->clear(0);
 
 		if (_textShadow)
 			_shadowSurface = new ManagedSurface(_maxWidth, _textMaxHeight, _wm->_pixelformat);
@@ -670,9 +677,9 @@ void MacTextCanvas::reallocSurface() {
 	}
 }
 
-void MacTextCanvas::render(int from, int to, int shadow) {
+void MacTextCanvas::render(int from, int to, ManagedSurface *target, uint32 fillColor, bool bboxesOnly) {
 	int w = MIN(_maxWidth, _textMaxWidth);
-	ManagedSurface *surface = shadow ? _shadowSurface : _surface;
+	ManagedSurface *surface = target ? target : _surface;
 
 	int myFrom = from, myTo = to + 1, delta = 1;
 
@@ -736,17 +743,29 @@ void MacTextCanvas::render(int from, int to, int shadow) {
 				yOffset = maxAscentForRow - _text[i].chunks[j].font->getFontAscent();
 			}
 
+			int x1 = xOffset;
+
 			if (_text[i].chunks[j].plainByteMode()) {
 				Common::String str = _text[i].chunks[j].getEncodedText();
-				_text[i].chunks[j].getFont()->drawString(surface, str, xOffset, _text[i].y + yOffset, w, shadow ? _wm->_colorBlack : _text[i].chunks[j].fgcolor, kTextAlignLeft, 0, true);
+
+				if (!bboxesOnly)
+					_text[i].chunks[j].getFont()->drawString(surface, str, xOffset, _text[i].y + yOffset, w, target ? fillColor : _text[i].chunks[j].fgcolor, kTextAlignLeft, 0, true);
+
 				xOffset += _text[i].chunks[j].getFont()->getStringWidth(str);
 			} else {
-				if (_wm->_language == Common::HE_ISR)
-					_text[i].chunks[j].getFont()->drawString(surface, convertBiDiU32String(_text[i].chunks[j].text, Common::BIDI_PAR_RTL), xOffset, _text[i].y + yOffset, w, shadow ? _wm->_colorBlack : _text[i].chunks[j].fgcolor, kTextAlignLeft, 0, true);
-				else
-					_text[i].chunks[j].getFont()->drawString(surface, convertBiDiU32String(_text[i].chunks[j].text), xOffset, _text[i].y + yOffset, w, shadow ? _wm->_colorBlack : _text[i].chunks[j].fgcolor, kTextAlignLeft, 0, true);
+				if (!bboxesOnly) {
+					if (_wm->_language == Common::HE_ISR)
+						_text[i].chunks[j].getFont()->drawString(surface, convertBiDiU32String(_text[i].chunks[j].text, Common::BIDI_PAR_RTL), xOffset, _text[i].y + yOffset, w, target ? fillColor : _text[i].chunks[j].fgcolor, kTextAlignLeft, 0, true);
+					else
+						_text[i].chunks[j].getFont()->drawString(surface, convertBiDiU32String(_text[i].chunks[j].text), xOffset, _text[i].y + yOffset, w, target ? fillColor : _text[i].chunks[j].fgcolor, kTextAlignLeft, 0, true);
+				}
 				xOffset += _text[i].chunks[j].getFont()->getStringWidth(_text[i].chunks[j].text);
 			}
+
+			if (bboxesOnly) {
+				Common::Rect bbox(x1, _text[i].y + yOffset, xOffset, _text[i].y + yOffset + _text[i].chunks[j].font->getFontHeight());
+				surface->fillRect(bbox, 0xff);
+			}
 		}
 	}
 }
@@ -765,9 +784,11 @@ void MacTextCanvas::render(int from, int to) {
 
 	// render the shadow surface;
 	if (_textShadow)
-		render(from, to, _textShadow);
+		render(from, to, _shadowSurface, _wm->_colorBlack);
 
-	render(from, to, 0);
+	render(from, to, _glyphsMask, 0xff);
+	render(from, to, _charBoxMask, 0xff, true);
+	render(from, to, nullptr);
 
 	debugPrint("MacTextCanvas::render");
 }
diff --git a/graphics/macgui/mactext-canvas.h b/graphics/macgui/mactext-canvas.h
index 7e53a3b6cd3..fdcaa7817f6 100644
--- a/graphics/macgui/mactext-canvas.h
+++ b/graphics/macgui/mactext-canvas.h
@@ -111,6 +111,7 @@ class MacTextCanvas {
 public:
 	Common::Array<MacTextLine> _text;
 	ManagedSurface *_surface = nullptr, *_shadowSurface = nullptr;
+	ManagedSurface *_glyphsMask = nullptr, *_charBoxMask = nullptr;
 	int _maxWidth = 0;
 	int _textMaxWidth = 0;
 	int _textMaxHeight = 0;
@@ -131,7 +132,7 @@ public:
 	void recalcDims();
 	void reallocSurface();
 	void render(int from, int to);
-	void render(int from, int to, int shadow);
+	void render(int from, int to, ManagedSurface *targeet, uint32 fillColor = 0, bool bboxesOnly = false);
 	int getAlignOffset(int row);
 
 	/**
diff --git a/graphics/macgui/mactext.cpp b/graphics/macgui/mactext.cpp
index a1ca34ffb87..3d5e08dc2f0 100644
--- a/graphics/macgui/mactext.cpp
+++ b/graphics/macgui/mactext.cpp
@@ -633,6 +633,8 @@ void MacText::setDefaultFormatting(uint16 fontId, byte textSlant, uint16 fontSiz
 void MacText::render() {
 	if (_fullRefresh) {
 		_canvas._surface->clear(_canvas._tbgcolor);
+		_canvas._glyphsMask->clear(0);
+		_canvas._charBoxMask->clear(0);
 		if (_canvas._textShadow)
 			_canvas._shadowSurface->clear(_canvas._tbgcolor);
 
@@ -830,7 +832,7 @@ void MacText::appendText_(const Common::U32String &strWithFont, uint oldLen) {
 
 	Common::U32String finalText = strWithFont;
 
-    if (_addInputPadding && _editable && strWithFont.lastChar() != '\n') 
+    if (_addInputPadding && _editable && strWithFont.lastChar() != '\n')
 		finalText += '\n';
 
 	_canvas.splitString(finalText, -1, _defaultFormatting);
diff --git a/graphics/macgui/mactext.h b/graphics/macgui/mactext.h
index cc4e97be07f..f375bc6f418 100644
--- a/graphics/macgui/mactext.h
+++ b/graphics/macgui/mactext.h
@@ -75,6 +75,9 @@ public:
 	void drawToPoint(ManagedSurface *g, Common::Point dstPoint);
 
 	ManagedSurface *getSurface() { return _canvas._surface; }
+	ManagedSurface *getGlyphMask() { return _canvas._glyphsMask; }
+	ManagedSurface *getCharBoxMask() { return _canvas._charBoxMask; }
+
 	int getInterLinear() { return _canvas._interLinear; }
 	void setInterLinear(int interLinear);
 	void setMaxWidth(int maxWidth);
@@ -87,7 +90,7 @@ public:
 	virtual Common::Point calculateOffset();
 	void setActive(bool active) override;
 	void setEditable(bool editable);
-	void setInputPadding(bool enable){ _addInputPadding = enable; }	
+	void setInputPadding(bool enable){ _addInputPadding = enable; }
 
 	void setColors(uint32 fg, uint32 bg) override;
 	// set fgcolor for line x




More information about the Scummvm-git-logs mailing list