[Scummvm-git-logs] scummvm master -> 1558f7a7841b8cebf37e3421f8b39f37175d85a5

ccawley2011 noreply at scummvm.org
Fri Feb 3 00:37:24 UTC 2023


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

Summary:
aa5076fb58 STARK: Move the Color struct into a separate header
1558f7a784 STARK: Add a method for drawing filled rectangles


Commit: aa5076fb582b3a1e89e9c8e2c573fffe0b2e3c0a
    https://github.com/scummvm/scummvm/commit/aa5076fb582b3a1e89e9c8e2c573fffe0b2e3c0a
Author: Cameron Cawley (ccawley2011 at gmail.com)
Date: 2023-02-03T00:37:20Z

Commit Message:
STARK: Move the Color struct into a separate header

Changed paths:
  A engines/stark/gfx/color.h
    engines/stark/resources/image.cpp
    engines/stark/resources/image.h
    engines/stark/ui/cursor.cpp
    engines/stark/ui/dialogbox.h
    engines/stark/ui/menu/dialogmenu.cpp
    engines/stark/ui/menu/dialogmenu.h
    engines/stark/ui/menu/diaryindex.cpp
    engines/stark/ui/menu/diaryindex.h
    engines/stark/ui/menu/fmvmenu.h
    engines/stark/ui/menu/locationscreen.cpp
    engines/stark/ui/menu/locationscreen.h
    engines/stark/ui/menu/saveloadmenu.cpp
    engines/stark/ui/menu/saveloadmenu.h
    engines/stark/ui/menu/settingsmenu.h
    engines/stark/ui/world/actionmenu.cpp
    engines/stark/ui/world/button.cpp
    engines/stark/ui/world/clicktext.cpp
    engines/stark/ui/world/clicktext.h
    engines/stark/ui/world/dialogpanel.cpp
    engines/stark/ui/world/dialogpanel.h
    engines/stark/visual/text.cpp
    engines/stark/visual/text.h


diff --git a/engines/stark/gfx/color.h b/engines/stark/gfx/color.h
new file mode 100644
index 00000000000..52746ab7c7b
--- /dev/null
+++ b/engines/stark/gfx/color.h
@@ -0,0 +1,50 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifndef STARK_GFX_COLOR_H
+#define STARK_GFX_COLOR_H
+
+#include "common/scummsys.h"
+
+namespace Stark {
+namespace Gfx {
+
+struct Color {
+	uint8 r;
+	uint8 g;
+	uint8 b;
+	uint8 a;
+
+	Color(uint8 red, uint8 green, uint8 blue, uint8 alpha = 0xFF) :
+			r(red), g(green), b(blue), a(alpha) {}
+
+	bool operator==(const Color &color) const {
+		return r == color.r &&
+		       g == color.g &&
+		       b == color.b &&
+		       a == color.a;
+	}
+};
+
+} // End of namespace Gfx
+} // End of namespace Stark
+
+#endif // STARK_GFX_COLOR_H
diff --git a/engines/stark/resources/image.cpp b/engines/stark/resources/image.cpp
index 94eca914fde..d63c54bf7d0 100644
--- a/engines/stark/resources/image.cpp
+++ b/engines/stark/resources/image.cpp
@@ -262,7 +262,7 @@ void ImageStill::printData() {
 
 ImageText::ImageText(Object *parent, byte subType, uint16 index, const Common::String &name) :
 		Image(parent, subType, index, name),
-		_color(Color(0, 0, 0)),
+		_color(Gfx::Color(0, 0, 0)),
 		_font(0) {
 }
 
diff --git a/engines/stark/resources/image.h b/engines/stark/resources/image.h
index 49ded6ad307..e2c5bd1e53d 100644
--- a/engines/stark/resources/image.h
+++ b/engines/stark/resources/image.h
@@ -26,12 +26,13 @@
 #include "common/str.h"
 
 #include "engines/stark/resources/object.h"
-#include "engines/stark/visual/text.h"
+#include "engines/stark/gfx/color.h"
 
 namespace Stark {
 
 class Visual;
 class VisualImageXMG;
+class VisualText;
 namespace Formats {
 class XRCReadStream;
 }
@@ -140,7 +141,7 @@ protected:
 
 	Common::Point _size;
 	Common::String _text;
-	Color _color;
+	Gfx::Color _color;
 	uint32 _font;
 };
 
diff --git a/engines/stark/ui/cursor.cpp b/engines/stark/ui/cursor.cpp
index 9b575372db0..eb24f39a64e 100644
--- a/engines/stark/ui/cursor.cpp
+++ b/engines/stark/ui/cursor.cpp
@@ -165,8 +165,8 @@ void Cursor::setMouseHint(const Common::String &hint) {
 		if (!hint.empty()) {
 			_mouseText = new VisualText(_gfx);
 			_mouseText->setText(hint);
-			_mouseText->setColor(Color(0xFF, 0xFF, 0xFF));
-			_mouseText->setBackgroundColor(Color(0x00, 0x00, 0x00, 0x80));
+			_mouseText->setColor(Gfx::Color(0xFF, 0xFF, 0xFF));
+			_mouseText->setBackgroundColor(Gfx::Color(0x00, 0x00, 0x00, 0x80));
 			_mouseText->setFont(FontProvider::kSmallFont);
 			_mouseText->setTargetWidth(96);
 		} else {
diff --git a/engines/stark/ui/dialogbox.h b/engines/stark/ui/dialogbox.h
index 09da5f506f2..0516ee6deb0 100644
--- a/engines/stark/ui/dialogbox.h
+++ b/engines/stark/ui/dialogbox.h
@@ -24,7 +24,7 @@
 
 #include "engines/stark/stark.h"
 #include "engines/stark/ui/window.h"
-#include "engines/stark/visual/text.h"
+#include "engines/stark/gfx/color.h"
 
 #include "common/keyboard.h"
 #include "common/scummsys.h"
@@ -90,7 +90,7 @@ private:
 	Common::Rect _cancelButtonRect;
 	Common::Rect _messageRect;
 
-	const Color _textColor = Color(0xFF, 0xFF, 0xFF);
+	const Gfx::Color _textColor = Gfx::Color(0xFF, 0xFF, 0xFF);
 
 	ConfirmCallback *_confirmCallback;
 };
diff --git a/engines/stark/ui/menu/dialogmenu.cpp b/engines/stark/ui/menu/dialogmenu.cpp
index 289fc1025b1..e11e0298852 100644
--- a/engines/stark/ui/menu/dialogmenu.cpp
+++ b/engines/stark/ui/menu/dialogmenu.cpp
@@ -328,7 +328,7 @@ DialogLineText::DialogLineText(Gfx::Driver *gfx, uint logIndex, uint lineIndex,
 	Common::String name = StarkGlobal->getCharacterName(logLine.characterId);
 	name.toUppercase();
 
-	Color color = logLine.characterId == StarkGlobal->getApril()->getCharacterIndex() ? _textColorApril : _textColorNormal;
+	Gfx::Color color = logLine.characterId == StarkGlobal->getApril()->getCharacterIndex() ? _textColorApril : _textColorNormal;
 
 	_nameText.setText(name);
 	_nameText.setColor(color);
diff --git a/engines/stark/ui/menu/dialogmenu.h b/engines/stark/ui/menu/dialogmenu.h
index a68ffc182f9..03a7478dfc3 100644
--- a/engines/stark/ui/menu/dialogmenu.h
+++ b/engines/stark/ui/menu/dialogmenu.h
@@ -99,7 +99,7 @@ public:
 	void onScreenChanged() { _text.reset(); }
 
 private:
-	const Color _color = Color(0x68, 0x05, 0x04);
+	const Gfx::Color _color = Gfx::Color(0x68, 0x05, 0x04);
 
 	Common::Point _pos;
 	VisualText _text;
@@ -127,8 +127,8 @@ public:
 	}
 
 private:
-	const Color _textColorApril = Color(0x68, 0x05, 0x04);
-	const Color _textColorNormal = Color(0x1E, 0x1E, 0x96);
+	const Gfx::Color _textColorApril = Gfx::Color(0x68, 0x05, 0x04);
+	const Gfx::Color _textColorNormal = Gfx::Color(0x1E, 0x1E, 0x96);
 
 	Common::Point _namePos, _linePos;
 	VisualText _nameText, _lineText;
@@ -158,8 +158,8 @@ public:
 	void onScreenChanged() override;
 
 private:
-	const Color _textColorHovered = Color(0x1E, 0x1E, 0x96);
-	const Color _textColorDefault = Color(0x00, 0x00, 0x00);
+	const Gfx::Color _textColorHovered = Gfx::Color(0x1E, 0x1E, 0x96);
+	const Gfx::Color _textColorDefault = Gfx::Color(0x00, 0x00, 0x00);
 
 	uint _logIndex, _chapter;
 	int _width, _height;
diff --git a/engines/stark/ui/menu/diaryindex.cpp b/engines/stark/ui/menu/diaryindex.cpp
index 68594db109b..6c842ee23b0 100644
--- a/engines/stark/ui/menu/diaryindex.cpp
+++ b/engines/stark/ui/menu/diaryindex.cpp
@@ -104,7 +104,7 @@ void DiaryIndexScreen::open() {
 
 void DiaryIndexScreen::widgetTextColorHandler(StaticLocationWidget &widget, const Common::Point &mousePos) {
 	if (widget.isVisible()) {
-		Color textColor = widget.isMouseInside(mousePos) ? _textColorHovered : _textColorDefault;
+		Gfx::Color textColor = widget.isMouseInside(mousePos) ? _textColorHovered : _textColorDefault;
 		widget.setTextColor(textColor);
 	}
 }
diff --git a/engines/stark/ui/menu/diaryindex.h b/engines/stark/ui/menu/diaryindex.h
index a43e50ad7a3..30078873017 100644
--- a/engines/stark/ui/menu/diaryindex.h
+++ b/engines/stark/ui/menu/diaryindex.h
@@ -48,8 +48,8 @@ private:
 	void dialogHandler();
 	void quitHandler();
 
-	const Color _textColorHovered = Color(0x1E, 0x1E, 0x96);
-	const Color _textColorDefault = Color(0x00, 0x00, 0x00);
+	const Gfx::Color _textColorHovered = Gfx::Color(0x1E, 0x1E, 0x96);
+	const Gfx::Color _textColorDefault = Gfx::Color(0x00, 0x00, 0x00);
 };
 
 } // End of namespace Stark
diff --git a/engines/stark/ui/menu/fmvmenu.h b/engines/stark/ui/menu/fmvmenu.h
index beab6003620..f7a503944fe 100644
--- a/engines/stark/ui/menu/fmvmenu.h
+++ b/engines/stark/ui/menu/fmvmenu.h
@@ -90,13 +90,13 @@ public:
 
 	void onClick();
 
-	void setTextColor(const Color &color) { _title.setColor(color); }
+	void setTextColor(const Gfx::Color &color) { _title.setColor(color); }
 
 	void onScreenChanged() { _title.reset(); }
 
 private:
-	const Color _textColorHovered = Color(0x1E, 0x1E, 0x96);
-	const Color _textColorDefault = Color(0x00, 0x00, 0x00);
+	const Gfx::Color _textColorHovered = Gfx::Color(0x1E, 0x1E, 0x96);
+	const Gfx::Color _textColorDefault = Gfx::Color(0x00, 0x00, 0x00);
 
 	Common::Point _formatRectPos;
 	int _fontHeight;
diff --git a/engines/stark/ui/menu/locationscreen.cpp b/engines/stark/ui/menu/locationscreen.cpp
index 0ac5632ee9f..61bbac8c959 100644
--- a/engines/stark/ui/menu/locationscreen.cpp
+++ b/engines/stark/ui/menu/locationscreen.cpp
@@ -228,7 +228,7 @@ void StaticLocationWidget::setupSounds(int16 enterSound, int16 clickSound) {
 	}
 }
 
-void StaticLocationWidget::setTextColor(const Color &textColor) {
+void StaticLocationWidget::setTextColor(const Gfx::Color &textColor) {
 	if (!_renderEntry) return;
 
 	VisualText *text = _renderEntry->getText();
diff --git a/engines/stark/ui/menu/locationscreen.h b/engines/stark/ui/menu/locationscreen.h
index f376241b24d..8b443548e9d 100644
--- a/engines/stark/ui/menu/locationscreen.h
+++ b/engines/stark/ui/menu/locationscreen.h
@@ -24,7 +24,7 @@
 
 #include "engines/stark/ui/screen.h"
 #include "engines/stark/ui/window.h"
-#include "engines/stark/visual/text.h"
+#include "engines/stark/gfx/color.h"
 
 namespace Stark {
 
@@ -121,7 +121,7 @@ public:
 	 *
 	 * Only applies for widget referring to a RenderEntry for a text visual
 	 */
-	void setTextColor(const Color &textColor);
+	void setTextColor(const Gfx::Color &textColor);
 
 	/** Widgets must be visible to be rendered and interactive */
 	bool isVisible() const;
diff --git a/engines/stark/ui/menu/saveloadmenu.cpp b/engines/stark/ui/menu/saveloadmenu.cpp
index 1776e82bbfb..06f3927c00c 100644
--- a/engines/stark/ui/menu/saveloadmenu.cpp
+++ b/engines/stark/ui/menu/saveloadmenu.cpp
@@ -93,7 +93,7 @@ void SaveLoadMenuScreen::open() {
 			CLICK_HANDLER(SaveLoadMenuScreen, prevPageHandler),
 			nullptr));
 	_widgets.back()->setupSounds(0, 1);
-	_widgets.back()->setTextColor(Color(0, 0, 0));
+	_widgets.back()->setTextColor(Gfx::Color(0, 0, 0));
 	_widgets.back()->setVisible(_page > 0);
 
 	_widgets.push_back(new StaticLocationWidget(
@@ -101,7 +101,7 @@ void SaveLoadMenuScreen::open() {
 			CLICK_HANDLER(SaveLoadMenuScreen, nextPageHandler),
 			nullptr));
 	_widgets.back()->setupSounds(0, 1);
-	_widgets.back()->setTextColor(Color(0, 0, 0));
+	_widgets.back()->setTextColor(Gfx::Color(0, 0, 0));
 	_widgets.back()->setVisible(_page < _maxPage);
 
 	loadSaveData(_page);
diff --git a/engines/stark/ui/menu/saveloadmenu.h b/engines/stark/ui/menu/saveloadmenu.h
index cbeb57355d6..64d79b3b59a 100644
--- a/engines/stark/ui/menu/saveloadmenu.h
+++ b/engines/stark/ui/menu/saveloadmenu.h
@@ -156,8 +156,8 @@ public:
 	bool hasSave() { return _hasSave; }
 
 private:
-	const Color _outlineColor = Color(0x1E, 0x1E, 0x96);
-	const Color _textColor = Color(0x5C, 0x48, 0x3D);
+	const Gfx::Color _outlineColor = Gfx::Color(0x1E, 0x1E, 0x96);
+	const Gfx::Color _textColor = Gfx::Color(0x5C, 0x48, 0x3D);
 
 	int _slot;
 	SaveLoadMenuScreen *_screen;
diff --git a/engines/stark/ui/menu/settingsmenu.h b/engines/stark/ui/menu/settingsmenu.h
index 9f2f2a2ee8b..39bb6c51560 100644
--- a/engines/stark/ui/menu/settingsmenu.h
+++ b/engines/stark/ui/menu/settingsmenu.h
@@ -105,8 +105,8 @@ private:
 	void backHandler();
 
 private:
-	const Color _textColorHovered = Color(0x1E, 0x1E, 0x96);
-	const Color _textColorDefault = Color(0x00, 0x00, 0x00);
+	const Gfx::Color _textColorHovered = Gfx::Color(0x1E, 0x1E, 0x96);
+	const Gfx::Color _textColorDefault = Gfx::Color(0x00, 0x00, 0x00);
 
 	TestSoundManager _soundManager;
 };
@@ -155,7 +155,7 @@ public:
 	void onMouseUp() override;
 
 private:
-	const Color _textColorBgHovered = Color(0xFF, 0xFF, 0xFF);
+	const Gfx::Color _textColorBgHovered = Gfx::Color(0xFF, 0xFF, 0xFF);
 	static const int _maxVolume = 256;
 
 	VisualImageXMG *_sliderImage;
diff --git a/engines/stark/ui/world/actionmenu.cpp b/engines/stark/ui/world/actionmenu.cpp
index bb5d49af90f..66c8fbd0877 100644
--- a/engines/stark/ui/world/actionmenu.cpp
+++ b/engines/stark/ui/world/actionmenu.cpp
@@ -57,8 +57,8 @@ ActionMenu::ActionMenu(Gfx::Driver *gfx, Cursor *cursor) :
 	_background = StarkStaticProvider->getUIElement(StaticProvider::kActionMenuBg);
 
 	_itemDescription = new VisualText(gfx);
-	_itemDescription->setColor(Color(0xFF, 0xFF, 0xFF));
-	_itemDescription->setBackgroundColor(Color(0x00, 0x00, 0x00, 0x80));
+	_itemDescription->setColor(Gfx::Color(0xFF, 0xFF, 0xFF));
+	_itemDescription->setBackgroundColor(Gfx::Color(0x00, 0x00, 0x00, 0x80));
 	_itemDescription->setFont(FontProvider::kSmallFont);
 	_itemDescription->setTargetWidth(96);
 
diff --git a/engines/stark/ui/world/button.cpp b/engines/stark/ui/world/button.cpp
index a5f1cfbf7b2..69edcad66c7 100644
--- a/engines/stark/ui/world/button.cpp
+++ b/engines/stark/ui/world/button.cpp
@@ -84,7 +84,7 @@ void Button::showButtonHint() {
 	if (!_mouseText) {
 		_mouseText = new VisualText(StarkGfx);
 		_mouseText->setText(_text);
-		_mouseText->setColor(Color(0xFF, 0xFF, 0xFF));
+		_mouseText->setColor(Gfx::Color(0xFF, 0xFF, 0xFF));
 		_mouseText->setFont(FontProvider::kSmallFont);
 		_mouseText->setTargetWidth(96);
 	}
diff --git a/engines/stark/ui/world/clicktext.cpp b/engines/stark/ui/world/clicktext.cpp
index 672572517bf..f74fac46ceb 100644
--- a/engines/stark/ui/world/clicktext.cpp
+++ b/engines/stark/ui/world/clicktext.cpp
@@ -25,7 +25,7 @@
 
 namespace Stark {
 
-ClickText::ClickText(const Common::String &text, const Color &color) :
+ClickText::ClickText(const Common::String &text, const Gfx::Color &color) :
 		_text(text),
 		_color(color) {
 	_visualPassive = new VisualText(StarkGfx);
@@ -36,7 +36,7 @@ ClickText::ClickText(const Common::String &text, const Color &color) :
 
 	_visualActive = new VisualText(StarkGfx);
 	_visualActive->setText(_text);
-	_visualActive->setColor(Color(0x00, 0x00, 0x00));
+	_visualActive->setColor(Gfx::Color(0x00, 0x00, 0x00));
 	_visualActive->setBackgroundColor(_color);
 	_visualActive->setFont(FontProvider::kBigFont);
 	_visualActive->setTargetWidth(600);
diff --git a/engines/stark/ui/world/clicktext.h b/engines/stark/ui/world/clicktext.h
index 36e89570ac8..685cb5412e5 100644
--- a/engines/stark/ui/world/clicktext.h
+++ b/engines/stark/ui/world/clicktext.h
@@ -22,7 +22,7 @@
 #ifndef STARK_UI_CLICK_TEXT_H
 #define STARK_UI_CLICK_TEXT_H
 
-#include "engines/stark/visual/text.h"
+#include "engines/stark/gfx/color.h"
 
 #include "common/scummsys.h"
 #include "common/rect.h"
@@ -34,7 +34,7 @@ class VisualText;
 
 class ClickText {
 public:
-	ClickText(const Common::String &text, const Color &color);
+	ClickText(const Common::String &text, const Gfx::Color &color);
 	~ClickText();
 
 	void setPosition(const Common::Point &pos) { _position = pos; }
@@ -52,7 +52,7 @@ private:
 	Common::Point _position;
 	Common::String _text;
 	Common::Rect _bbox;
-	Color _color;
+	Gfx::Color _color;
 };
 
 } // End of namespace Stark
diff --git a/engines/stark/ui/world/dialogpanel.cpp b/engines/stark/ui/world/dialogpanel.cpp
index 67320ba95a7..bdb804502a8 100644
--- a/engines/stark/ui/world/dialogpanel.cpp
+++ b/engines/stark/ui/world/dialogpanel.cpp
@@ -159,7 +159,7 @@ void DialogPanel::onRender() {
 void DialogPanel::updateSubtitleVisual() {
 	clearSubtitleVisual();
 
-	Color color = _otherColor;
+	Gfx::Color color = _otherColor;
 	if (_currentSpeech->characterIsApril())
 		color = _aprilColor;
 
diff --git a/engines/stark/ui/world/dialogpanel.h b/engines/stark/ui/world/dialogpanel.h
index 641de8d59c7..cc7a701e034 100644
--- a/engines/stark/ui/world/dialogpanel.h
+++ b/engines/stark/ui/world/dialogpanel.h
@@ -23,7 +23,7 @@
 #define STARK_UI_DIALOG_PANEL_H
 
 #include "engines/stark/ui/window.h"
-#include "engines/stark/visual/text.h"
+#include "engines/stark/gfx/color.h"
 
 #include "common/scummsys.h"
 #include "common/str.h"
@@ -34,6 +34,7 @@
 namespace Stark {
 
 class VisualImageXMG;
+class VisualText;
 class ClickText;
 
 namespace Resources {
@@ -103,8 +104,8 @@ private:
 	Common::Array<ClickText*> _options;
 	bool _acceptIdleMousePos;
 
-	Color _aprilColor = Color(0xFF, 0xC0, 0x00);
-	Color _otherColor = Color(0xFF, 0x40, 0x40);
+	const Gfx::Color _aprilColor = Gfx::Color(0xFF, 0xC0, 0x00);
+	const Gfx::Color _otherColor = Gfx::Color(0xFF, 0x40, 0x40);
 	static const uint32 _optionsTop = 4;
 	static const uint32 _optionsLeft = 30;
 	static const uint32 _optionsHeight = 80;
diff --git a/engines/stark/visual/text.cpp b/engines/stark/visual/text.cpp
index 5e3aab83b9e..dff4a740d2e 100644
--- a/engines/stark/visual/text.cpp
+++ b/engines/stark/visual/text.cpp
@@ -41,9 +41,8 @@ VisualText::VisualText(Gfx::Driver *gfx) :
 		Visual(TYPE),
 		_gfx(gfx),
 		_bitmap(nullptr),
-		_bgBitmap(nullptr),
-		_color(Color(0, 0, 0)),
-		_backgroundColor(Color(0, 0, 0, 0)),
+		_color(Gfx::Color(0, 0, 0)),
+		_backgroundColor(Gfx::Color(0, 0, 0, 0)),
 		_align(Graphics::kTextAlignLeft),
 		_targetWidth(600),
 		_targetHeight(600),
@@ -73,7 +72,7 @@ void VisualText::setText(const Common::String &text) {
 	}
 }
 
-void VisualText::setColor(const Color &color) {
+void VisualText::setColor(const Gfx::Color &color) {
 	if (_color == color) {
 		return;
 	}
@@ -82,7 +81,7 @@ void VisualText::setColor(const Color &color) {
 	_color = color;
 }
 
-void VisualText::setBackgroundColor(const Color &color) {
+void VisualText::setBackgroundColor(const Gfx::Color &color) {
 	if (color == _backgroundColor) {
 		return;
 	}
@@ -198,7 +197,7 @@ static void multiplyColorWithAlpha(Graphics::Surface *source) {
  *
  * Color space aware version.
  */
-static void blendWithColor(Graphics::Surface *source, const Color &color) {
+static void blendWithColor(Graphics::Surface *source, const Gfx::Color &color) {
 	assert(source->format == Gfx::Driver::getRGBAPixelFormat());
 
 	float sRL = srgbToLinear(color.r / 255.f);
diff --git a/engines/stark/visual/text.h b/engines/stark/visual/text.h
index e2631730c4e..710f0859d24 100644
--- a/engines/stark/visual/text.h
+++ b/engines/stark/visual/text.h
@@ -25,6 +25,7 @@
 #include "engines/stark/visual/visual.h"
 
 #include "engines/stark/services/fontprovider.h"
+#include "engines/stark/gfx/color.h"
 
 #include "common/rect.h"
 #include "graphics/font.h"
@@ -37,23 +38,6 @@ class SurfaceRenderer;
 class Bitmap;
 }
 
-struct Color {
-	uint8 r;
-	uint8 g;
-	uint8 b;
-	uint8 a;
-
-	Color(uint8 red, uint8 green, uint8 blue, uint8 alpha = 0xFF) :
-			r(red), g(green), b(blue), a(alpha) {}
-
-	bool operator==(const Color &color) const {
-		return r == color.r &&
-		       g == color.g &&
-		       b == color.b &&
-		       a == color.a;
-	}
-};
-
 /**
  * Text renderer
  */
@@ -67,8 +51,8 @@ public:
 	Common::Rect getRect();
 
 	void setText(const Common::String &text);
-	void setColor(const Color &color);
-	void setBackgroundColor(const Color &color);
+	void setColor(const Gfx::Color &color);
+	void setBackgroundColor(const Gfx::Color &color);
 	void setAlign(Graphics::TextAlign align);
 	void setTargetWidth(uint32 width);
 	void setTargetHeight(uint32 height);
@@ -93,8 +77,8 @@ private:
 	Gfx::Bitmap *_bgBitmap;
 
 	Common::String _text;
-	Color _color;
-	Color _backgroundColor;
+	Gfx::Color _color;
+	Gfx::Color _backgroundColor;
 	Graphics::TextAlign _align;
 	uint32 _targetWidth;
 	uint32 _targetHeight;


Commit: 1558f7a7841b8cebf37e3421f8b39f37175d85a5
    https://github.com/scummvm/scummvm/commit/1558f7a7841b8cebf37e3421f8b39f37175d85a5
Author: Cameron Cawley (ccawley2011 at gmail.com)
Date: 2023-02-03T00:37:20Z

Commit Message:
STARK: Add a method for drawing filled rectangles

Changed paths:
  A engines/stark/shaders/stark_surface_fill.fragment
  A engines/stark/shaders/stark_surface_fill.vertex
    devtools/create_project/xcode.cpp
    dists/scummvm.rc
    engines/stark/gfx/opengls.cpp
    engines/stark/gfx/opengls.h
    engines/stark/gfx/openglssurface.cpp
    engines/stark/gfx/openglssurface.h
    engines/stark/gfx/openglsurface.cpp
    engines/stark/gfx/openglsurface.h
    engines/stark/gfx/surfacerenderer.h
    engines/stark/gfx/tinyglbitmap.cpp
    engines/stark/gfx/tinyglbitmap.h
    engines/stark/gfx/tinyglsurface.cpp
    engines/stark/gfx/tinyglsurface.h
    engines/stark/ui/dialogbox.cpp
    engines/stark/ui/dialogbox.h
    engines/stark/visual/text.cpp
    engines/stark/visual/text.h


diff --git a/devtools/create_project/xcode.cpp b/devtools/create_project/xcode.cpp
index 048f2d4ecd6..3f21708a59e 100644
--- a/devtools/create_project/xcode.cpp
+++ b/devtools/create_project/xcode.cpp
@@ -1041,6 +1041,8 @@ XcodeProvider::ValueList& XcodeProvider::getResourceFiles(const BuildSetup &setu
 			files.push_back("engines/stark/shaders/stark_prop.vertex");
 			files.push_back("engines/stark/shaders/stark_surface.fragment");
 			files.push_back("engines/stark/shaders/stark_surface.vertex");
+			files.push_back("engines/stark/shaders/stark_surface_fill.fragment");
+			files.push_back("engines/stark/shaders/stark_surface_fill.vertex");
 			files.push_back("engines/stark/shaders/stark_fade.fragment");
 			files.push_back("engines/stark/shaders/stark_fade.vertex");
 			files.push_back("engines/stark/shaders/stark_shadow.fragment");
diff --git a/dists/scummvm.rc b/dists/scummvm.rc
index 550cd9403d3..dc6165d9dcf 100644
--- a/dists/scummvm.rc
+++ b/dists/scummvm.rc
@@ -164,6 +164,8 @@ shaders/stark_prop.fragment          FILE    "engines/stark/shaders/stark_prop.f
 shaders/stark_prop.vertex            FILE    "engines/stark/shaders/stark_prop.vertex"
 shaders/stark_surface.fragment       FILE    "engines/stark/shaders/stark_surface.fragment"
 shaders/stark_surface.vertex         FILE    "engines/stark/shaders/stark_surface.vertex"
+shaders/stark_surface_fill.fragment  FILE    "engines/stark/shaders/stark_surface_fill.fragment"
+shaders/stark_surface_fill.vertex    FILE    "engines/stark/shaders/stark_surface_fill.vertex"
 shaders/stark_fade.fragment          FILE    "engines/stark/shaders/stark_fade.fragment"
 shaders/stark_fade.vertex            FILE    "engines/stark/shaders/stark_fade.vertex"
 shaders/stark_shadow.fragment        FILE    "engines/stark/shaders/stark_shadow.fragment"
diff --git a/engines/stark/gfx/opengls.cpp b/engines/stark/gfx/opengls.cpp
index 05b0d1d524b..86068d15b43 100644
--- a/engines/stark/gfx/opengls.cpp
+++ b/engines/stark/gfx/opengls.cpp
@@ -58,6 +58,7 @@ static const GLfloat fadeVertices[] = {
 
 OpenGLSDriver::OpenGLSDriver() :
 	_surfaceShader(nullptr),
+	_surfaceFillShader(nullptr),
 	_actorShader(nullptr),
 	_fadeShader(nullptr),
 	_shadowShader(nullptr),
@@ -68,6 +69,7 @@ OpenGLSDriver::OpenGLSDriver() :
 OpenGLSDriver::~OpenGLSDriver() {
 	OpenGL::Shader::freeBuffer(_surfaceVBO);
 	OpenGL::Shader::freeBuffer(_fadeVBO);
+	delete _surfaceFillShader;
 	delete _surfaceShader;
 	delete _actorShader;
 	delete _fadeShader;
@@ -83,6 +85,10 @@ void OpenGLSDriver::init() {
 	_surfaceShader->enableVertexAttribute("position", _surfaceVBO, 2, GL_FLOAT, GL_TRUE, 2 * sizeof(float), 0);
 	_surfaceShader->enableVertexAttribute("texcoord", _surfaceVBO, 2, GL_FLOAT, GL_TRUE, 2 * sizeof(float), 0);
 
+	static const char* fillAttributes[] = { "position", nullptr };
+	_surfaceFillShader = OpenGL::Shader::fromFiles("stark_surface_fill", fillAttributes);
+	_surfaceFillShader->enableVertexAttribute("position", _surfaceVBO, 2, GL_FLOAT, GL_TRUE, 2 * sizeof(float), 0);
+
 	static const char* actorAttributes[] = { "position1", "position2", "bone1", "bone2", "boneWeight", "normal", "texcoord", nullptr };
 	_actorShader = OpenGL::Shader::fromFiles("stark_actor", actorAttributes);
 
@@ -214,6 +220,10 @@ OpenGL::Shader *OpenGLSDriver::createSurfaceShaderInstance() {
 	return _surfaceShader->clone();
 }
 
+OpenGL::Shader *OpenGLSDriver::createSurfaceFillShaderInstance() {
+	return _surfaceFillShader->clone();
+}
+
 OpenGL::Shader *OpenGLSDriver::createFadeShaderInstance() {
 	return _fadeShader->clone();
 }
diff --git a/engines/stark/gfx/opengls.h b/engines/stark/gfx/opengls.h
index 7cd6163fc27..b19f8eddb82 100644
--- a/engines/stark/gfx/opengls.h
+++ b/engines/stark/gfx/opengls.h
@@ -59,6 +59,7 @@ public:
 
 	OpenGL::Shader *createActorShaderInstance();
 	OpenGL::Shader *createSurfaceShaderInstance();
+	OpenGL::Shader *createSurfaceFillShaderInstance();
 	OpenGL::Shader *createFadeShaderInstance();
 	OpenGL::Shader *createShadowShaderInstance();
 
@@ -77,6 +78,7 @@ private:
 	Common::Rect _unscaledViewport;
 
 	OpenGL::Shader *_surfaceShader;
+	OpenGL::Shader *_surfaceFillShader;
 	OpenGL::Shader *_actorShader;
 	OpenGL::Shader *_fadeShader;
 	OpenGL::Shader *_shadowShader;
diff --git a/engines/stark/gfx/openglssurface.cpp b/engines/stark/gfx/openglssurface.cpp
index baa4285ee0a..fff9615e342 100644
--- a/engines/stark/gfx/openglssurface.cpp
+++ b/engines/stark/gfx/openglssurface.cpp
@@ -23,6 +23,7 @@
 
 #include "engines/stark/gfx/opengls.h"
 #include "engines/stark/gfx/bitmap.h"
+#include "engines/stark/gfx/color.h"
 
 #if defined(USE_OPENGL_SHADERS)
 
@@ -35,9 +36,11 @@ OpenGLSSurfaceRenderer::OpenGLSSurfaceRenderer(OpenGLSDriver *gfx) :
 		SurfaceRenderer(),
 		_gfx(gfx) {
 	_shader = _gfx->createSurfaceShaderInstance();
+	_shaderFill = _gfx->createSurfaceFillShaderInstance();
 }
 
 OpenGLSSurfaceRenderer::~OpenGLSSurfaceRenderer() {
+	delete _shaderFill;
 	delete _shader;
 }
 
@@ -69,6 +72,31 @@ void OpenGLSSurfaceRenderer::render(const Bitmap *bitmap, const Common::Point &d
 	_gfx->end2DMode();
 }
 
+void OpenGLSSurfaceRenderer::fill(const Color &color, const Common::Point &dest, uint width, uint height) {
+	// Destination rectangle with given width and height
+	_gfx->start2DMode();
+
+	_shaderFill->use();
+	_shaderFill->setUniform1f("fadeLevel", _fadeLevel);
+	_shaderFill->setUniform1f("snapToGrid", _snapToGrid);
+	_shaderFill->setUniform("verOffsetXY", normalizeOriginalCoordinates(dest.x, dest.y));
+	if (_noScalingOverride) {
+		_shaderFill->setUniform("verSizeWH", normalizeCurrentCoordinates(width, height));
+	} else {
+		_shaderFill->setUniform("verSizeWH", normalizeOriginalCoordinates(width, height));
+	}
+
+	Common::Rect nativeViewport = _gfx->getViewport();
+	_shaderFill->setUniform("viewport", Math::Vector2d(nativeViewport.width(), nativeViewport.height()));
+
+	_shaderFill->setUniform("color", Math::Vector4d(color.r / 255.0f, color.g / 255.0f, color.b / 255.0f, color.a / 255.0f));
+
+	glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
+
+	_shaderFill->unbind();
+	_gfx->end2DMode();
+}
+
 Math::Vector2d OpenGLSSurfaceRenderer::normalizeOriginalCoordinates(int x, int y) const {
 	Common::Rect viewport = _gfx->getUnscaledViewport();
 	return Math::Vector2d(x / (float)viewport.width(), y / (float)viewport.height());
diff --git a/engines/stark/gfx/openglssurface.h b/engines/stark/gfx/openglssurface.h
index 0f96c9c2f62..765ea5e10b4 100644
--- a/engines/stark/gfx/openglssurface.h
+++ b/engines/stark/gfx/openglssurface.h
@@ -49,6 +49,7 @@ public:
 	// SurfaceRenderer API
 	void render(const Bitmap *bitmap, const Common::Point &dest) override;
 	void render(const Bitmap *bitmap, const Common::Point &dest, uint width, uint height) override;
+	void fill(const Color &color, const Common::Point &dest, uint width, uint height) override;
 
 private:
 	Math::Vector2d normalizeOriginalCoordinates(int x, int y) const;
@@ -56,6 +57,7 @@ private:
 
 	OpenGLSDriver *_gfx;
 	OpenGL::Shader *_shader;
+	OpenGL::Shader *_shaderFill;
 };
 
 } // End of namespace Gfx
diff --git a/engines/stark/gfx/openglsurface.cpp b/engines/stark/gfx/openglsurface.cpp
index af373ef044e..46b83400b96 100644
--- a/engines/stark/gfx/openglsurface.cpp
+++ b/engines/stark/gfx/openglsurface.cpp
@@ -21,6 +21,7 @@
 
 #include "engines/stark/gfx/openglsurface.h"
 #include "engines/stark/gfx/bitmap.h"
+#include "engines/stark/gfx/color.h"
 
 #if defined(USE_OPENGL_GAME)
 
@@ -51,39 +52,8 @@ void OpenGLSurfaceRenderer::render(const Bitmap *bitmap, const Common::Point &de
 	// Destination rectangle with given width and height
 	_gfx->start2DMode();
 
-	const Math::Vector2d surfaceVertices[] = {
-		// X   Y
-		{ 0.0f, 0.0f },
-		{ 1.0f, 0.0f },
-		{ 0.0f, 1.0f },
-		{ 1.0f, 1.0f },
-	};
-
-	Math::Vector2d verSizeWH;
-	if (_noScalingOverride) {
-		verSizeWH = normalizeCurrentCoordinates(width, height);
-	} else {
-		verSizeWH = normalizeOriginalCoordinates(width, height);
-	}
-	auto verOffsetXY = normalizeOriginalCoordinates(dest.x, dest.y);
-	auto nativeViewport = _gfx->getViewport();
-	auto viewport = Math::Vector2d(nativeViewport.width(), nativeViewport.height());
-
 	SurfaceVertex vertices[4] = {};
-	for (int32 v = 0; v < 4; v++) {
-		Math::Vector2d pos = verOffsetXY + (surfaceVertices[v] * verSizeWH);
-
-		if (_snapToGrid) {
-			// Align vertex coordinates to the native pixel grid
-			// This ensures text does not get garbled by nearest neighbors scaling
-			pos.setX(floor(pos.getX() * viewport.getX() + 0.5) / viewport.getX());
-			pos.setY(floor(pos.getY() * viewport.getY() + 0.5) / viewport.getY());
-		}
-
-		// position coords
-		vertices[v].x = pos.getX() * 2.0 - 1.0;
-		vertices[v].y = -1.0 * (pos.getY() * 2.0 - 1.0);
-	}
+	convertToVertices(vertices, dest, width, height);
 
 	glMatrixMode(GL_PROJECTION);
 	glPushMatrix();
@@ -119,6 +89,75 @@ void OpenGLSurfaceRenderer::render(const Bitmap *bitmap, const Common::Point &de
 	_gfx->end2DMode();
 }
 
+void OpenGLSurfaceRenderer::fill(const Color &color, const Common::Point &dest, uint width, uint height) {
+	_gfx->start2DMode();
+
+	SurfaceVertex vertices[4] = {};
+	convertToVertices(vertices, dest, width, height);
+
+	glMatrixMode(GL_PROJECTION);
+	glPushMatrix();
+	glLoadIdentity();
+
+	glMatrixMode(GL_MODELVIEW);
+	glPushMatrix();
+	glLoadIdentity();
+
+	glDisable(GL_TEXTURE_2D);
+
+	glEnableClientState(GL_VERTEX_ARRAY);
+
+	glVertexPointer(2, GL_FLOAT, sizeof(SurfaceVertex), &vertices[0].x);
+	glColor4f((color.r / 255.0f) - _fadeLevel, (color.g / 255.0f) - _fadeLevel, (color.b / 255.0f) - _fadeLevel, color.a / 255.0f);
+
+	glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
+
+	glDisableClientState(GL_VERTEX_ARRAY);
+
+	glMatrixMode(GL_MODELVIEW);
+	glPopMatrix();
+
+	glMatrixMode(GL_PROJECTION);
+	glPopMatrix();
+
+	_gfx->end2DMode();
+}
+
+void OpenGLSurfaceRenderer::convertToVertices(SurfaceVertex *vertices, const Common::Point &dest, uint width, uint height) const {
+	const Math::Vector2d surfaceVertices[] = {
+		// X   Y
+		{ 0.0f, 0.0f },
+		{ 1.0f, 0.0f },
+		{ 0.0f, 1.0f },
+		{ 1.0f, 1.0f },
+	};
+
+	Math::Vector2d verSizeWH;
+	if (_noScalingOverride) {
+		verSizeWH = normalizeCurrentCoordinates(width, height);
+	} else {
+		verSizeWH = normalizeOriginalCoordinates(width, height);
+	}
+	auto verOffsetXY = normalizeOriginalCoordinates(dest.x, dest.y);
+	auto nativeViewport = _gfx->getViewport();
+	auto viewport = Math::Vector2d(nativeViewport.width(), nativeViewport.height());
+
+	for (int32 v = 0; v < 4; v++) {
+		Math::Vector2d pos = verOffsetXY + (surfaceVertices[v] * verSizeWH);
+
+		if (_snapToGrid) {
+			// Align vertex coordinates to the native pixel grid
+			// This ensures text does not get garbled by nearest neighbors scaling
+			pos.setX(floor(pos.getX() * viewport.getX() + 0.5) / viewport.getX());
+			pos.setY(floor(pos.getY() * viewport.getY() + 0.5) / viewport.getY());
+		}
+
+		// position coords
+		vertices[v].x = pos.getX() * 2.0 - 1.0;
+		vertices[v].y = -1.0 * (pos.getY() * 2.0 - 1.0);
+	}
+}
+
 Math::Vector2d OpenGLSurfaceRenderer::normalizeOriginalCoordinates(int x, int y) const {
 	Common::Rect viewport = _gfx->getUnscaledViewport();
 	return Math::Vector2d(x / (float)viewport.width(), y / (float)viewport.height());
diff --git a/engines/stark/gfx/openglsurface.h b/engines/stark/gfx/openglsurface.h
index 6a76305cb32..ee6c339f926 100644
--- a/engines/stark/gfx/openglsurface.h
+++ b/engines/stark/gfx/openglsurface.h
@@ -35,12 +35,6 @@ namespace Gfx {
 class OpenGLDriver;
 class Bitmap;
 
-struct _SurfaceVertex {
-	float x;
-	float y;
-};
-typedef _SurfaceVertex SurfaceVertex;
-
 /**
  * An programmable pipeline OpenGL surface renderer
  */
@@ -52,10 +46,17 @@ public:
 	// SurfaceRenderer API
 	void render(const Bitmap *bitmap, const Common::Point &dest) override;
 	void render(const Bitmap *bitmap, const Common::Point &dest, uint width, uint height) override;
+	void fill(const Color &color, const Common::Point &dest, uint width, uint height) override;
 
 private:
+	struct SurfaceVertex {
+		float x;
+		float y;
+	};
+
 	Math::Vector2d normalizeOriginalCoordinates(int x, int y) const;
 	Math::Vector2d normalizeCurrentCoordinates(int x, int y) const;
+	void convertToVertices(SurfaceVertex *vertices, const Common::Point &dest, uint width, uint height) const;
 
 	OpenGLDriver *_gfx;
 };
diff --git a/engines/stark/gfx/surfacerenderer.h b/engines/stark/gfx/surfacerenderer.h
index dcfe8c7fbea..377f194fdd4 100644
--- a/engines/stark/gfx/surfacerenderer.h
+++ b/engines/stark/gfx/surfacerenderer.h
@@ -28,6 +28,7 @@ namespace Stark {
 namespace Gfx {
 
 class Bitmap;
+struct Color;
 
 /**
  * A renderer to draw textures as two dimensional surfaces to the current viewport
@@ -47,6 +48,11 @@ public:
 	 */
 	virtual void render(const Bitmap *bitmap, const Common::Point &dest, uint width, uint height) = 0;
 
+	/**
+	 * Draw a filled 2D rectangle using the specified color
+	 */
+	virtual void fill(const Color &color, const Common::Point &dest, uint width, uint height) = 0;
+
 	/**
 	 * When this is set to true, the texture size is expected to be in current
 	 * coordinates, and is to be drawn without scaling.
diff --git a/engines/stark/gfx/tinyglbitmap.cpp b/engines/stark/gfx/tinyglbitmap.cpp
index 9301ed754b8..61ae32743a6 100644
--- a/engines/stark/gfx/tinyglbitmap.cpp
+++ b/engines/stark/gfx/tinyglbitmap.cpp
@@ -28,8 +28,7 @@ namespace Stark {
 namespace Gfx {
 
 TinyGlBitmap::TinyGlBitmap() :
-		Bitmap(),
-		 _1x1Color(0) {
+		Bitmap() {
 	_blitImage = tglGenBlitImage();
 }
 
@@ -51,11 +50,6 @@ void TinyGlBitmap::update(const Graphics::Surface *surface, const byte *palette)
 		convertedSurface->free();
 		delete convertedSurface;
 	} else {
-		// W/A for 1x1 size bitmap
-		// store pixel color used later fo creating scalled bitmap
-		if (_width == 1 && _height == 1) {
-			_1x1Color = surface->getPixel(0, 0);
-		}
 		tglUploadBlitImage(_blitImage, *surface, 0, false);
 	}
 }
diff --git a/engines/stark/gfx/tinyglbitmap.h b/engines/stark/gfx/tinyglbitmap.h
index a64fe9b61af..f3e125ca319 100644
--- a/engines/stark/gfx/tinyglbitmap.h
+++ b/engines/stark/gfx/tinyglbitmap.h
@@ -42,11 +42,9 @@ public:
 	TinyGL::BlitImage *getBlitImage() const;
 	void update(const Graphics::Surface *surface, const byte *palette = nullptr) override;
 	void setSamplingFilter(SamplingFilter filter) override;
-	uint32 get1x1Color() { return _1x1Color; }
 
 protected:
 	TinyGL::BlitImage *_blitImage;
-	uint32 _1x1Color;
 };
 
 } // End of namespace Gfx
diff --git a/engines/stark/gfx/tinyglsurface.cpp b/engines/stark/gfx/tinyglsurface.cpp
index 4ae87c3c454..cee8027940f 100644
--- a/engines/stark/gfx/tinyglsurface.cpp
+++ b/engines/stark/gfx/tinyglsurface.cpp
@@ -21,6 +21,7 @@
 
 #include "engines/stark/gfx/tinyglsurface.h"
 #include "engines/stark/gfx/tinyglbitmap.h"
+#include "engines/stark/gfx/color.h"
 
 #include "graphics/tinygl/tinygl.h"
 
@@ -67,24 +68,81 @@ void TinyGLSurfaceRenderer::render(const Bitmap *bitmap, const Common::Point &de
 	}
 
 	transform.sourceRectangle(0, 0, blitImageWidth, blitImageHeight);
-
-	// W/A for 1x1 dimension bitmap
-	// it needs new filled and scaled bitmap based on one pixel color
-	if (blitImageWidth == 1 && blitImageHeight == 1) {
-		auto pixelColor = ((TinyGlBitmap *)const_cast<Bitmap *>(bitmap))->get1x1Color();
-		Graphics::Surface surface;
-		surface.create(width, height, Driver::getRGBAPixelFormat());
-		surface.fillRect(Common::Rect(0, 0, width, height), pixelColor);
-		tglUploadBlitImage(blitImage, surface, 0, false);
-		surface.free();
-	}
-
 	transform.tint(1.0, 1.0 - _fadeLevel, 1.0 - _fadeLevel, 1.0 - _fadeLevel);
 	tglBlit(blitImage, transform);
 
 	_gfx->end2DMode();
 }
 
+void TinyGLSurfaceRenderer::fill(const Color &color, const Common::Point &dest, uint width, uint height) {
+	_gfx->start2DMode();
+
+	SurfaceVertex vertices[4] = {};
+	convertToVertices(vertices, dest, width, height);
+
+	tglMatrixMode(TGL_PROJECTION);
+	tglPushMatrix();
+	tglLoadIdentity();
+
+	tglMatrixMode(TGL_MODELVIEW);
+	tglPushMatrix();
+	tglLoadIdentity();
+
+	tglDisable(TGL_TEXTURE_2D);
+
+	tglEnableClientState(TGL_VERTEX_ARRAY);
+
+	tglVertexPointer(2, TGL_FLOAT, sizeof(SurfaceVertex), &vertices[0].x);
+	tglColor4f((color.r / 255.0f) - _fadeLevel, (color.g / 255.0f) - _fadeLevel, (color.b / 255.0f) - _fadeLevel, color.a / 255.0f);
+
+	tglDrawArrays(TGL_TRIANGLE_STRIP, 0, 4);
+
+	tglDisableClientState(TGL_VERTEX_ARRAY);
+
+	tglMatrixMode(TGL_MODELVIEW);
+	tglPopMatrix();
+
+	tglMatrixMode(TGL_PROJECTION);
+	tglPopMatrix();
+
+	_gfx->end2DMode();
+}
+
+void TinyGLSurfaceRenderer::convertToVertices(SurfaceVertex *vertices, const Common::Point &dest, uint width, uint height) const {
+	const Math::Vector2d surfaceVertices[] = {
+		// X   Y
+		{ 0.0f, 0.0f },
+		{ 1.0f, 0.0f },
+		{ 0.0f, 1.0f },
+		{ 1.0f, 1.0f },
+	};
+
+	Math::Vector2d verSizeWH;
+	if (_noScalingOverride) {
+		verSizeWH = normalizeCurrentCoordinates(width, height);
+	} else {
+		verSizeWH = normalizeOriginalCoordinates(width, height);
+	}
+	auto verOffsetXY = normalizeOriginalCoordinates(dest.x, dest.y);
+	auto nativeViewport = _gfx->getViewport();
+	auto viewport = Math::Vector2d(nativeViewport.width(), nativeViewport.height());
+
+	for (int32 v = 0; v < 4; v++) {
+		Math::Vector2d pos = verOffsetXY + (surfaceVertices[v] * verSizeWH);
+
+		if (_snapToGrid) {
+			// Align vertex coordinates to the native pixel grid
+			// This ensures text does not get garbled by nearest neighbors scaling
+			pos.setX(floor(pos.getX() * viewport.getX() + 0.5) / viewport.getX());
+			pos.setY(floor(pos.getY() * viewport.getY() + 0.5) / viewport.getY());
+		}
+
+		// position coords
+		vertices[v].x = pos.getX() * 2.0 - 1.0;
+		vertices[v].y = -1.0 * (pos.getY() * 2.0 - 1.0);
+	}
+}
+
 Math::Vector2d TinyGLSurfaceRenderer::normalizeOriginalCoordinates(int x, int y) const {
 	Common::Rect viewport = _gfx->getUnscaledViewport();
 	return Math::Vector2d(x / (float)viewport.width(), y / (float)viewport.height());
diff --git a/engines/stark/gfx/tinyglsurface.h b/engines/stark/gfx/tinyglsurface.h
index 64d1a061f97..eddf5f55e77 100644
--- a/engines/stark/gfx/tinyglsurface.h
+++ b/engines/stark/gfx/tinyglsurface.h
@@ -46,10 +46,17 @@ public:
 	// SurfaceRenderer API
 	void render(const Bitmap *bitmap, const Common::Point &dest) override;
 	void render(const Bitmap *bitmap, const Common::Point &dest, uint width, uint height) override;
+	void fill(const Color &color, const Common::Point &dest, uint width, uint height) override;
 
 private:
+	struct SurfaceVertex {
+		float x;
+		float y;
+	};
+
 	Math::Vector2d normalizeOriginalCoordinates(int x, int y) const;
 	Math::Vector2d normalizeCurrentCoordinates(int x, int y) const;
+	void convertToVertices(SurfaceVertex *vertices, const Common::Point &dest, uint width, uint height) const;
 
 	TinyGLDriver *_gfx;
 };
diff --git a/engines/stark/shaders/stark_surface_fill.fragment b/engines/stark/shaders/stark_surface_fill.fragment
new file mode 100644
index 00000000000..d605a50b2bf
--- /dev/null
+++ b/engines/stark/shaders/stark_surface_fill.fragment
@@ -0,0 +1,9 @@
+
+OUTPUT
+
+uniform float fadeLevel;
+uniform vec4 color;
+
+void main() {
+	outColor = color + vec4(fadeLevel, fadeLevel, fadeLevel, 0) * color.a;
+}
diff --git a/engines/stark/shaders/stark_surface_fill.vertex b/engines/stark/shaders/stark_surface_fill.vertex
new file mode 100644
index 00000000000..a46ca3385cd
--- /dev/null
+++ b/engines/stark/shaders/stark_surface_fill.vertex
@@ -0,0 +1,23 @@
+in vec2 position;
+
+uniform vec2 verOffsetXY;
+uniform vec2 verSizeWH;
+uniform vec2 viewport;
+uniform UBOOL snapToGrid;
+
+void main() {
+	// Coordinates are [0.0; 1.0], transform to [-1.0; 1.0]
+	vec2 pos = verOffsetXY + position * verSizeWH;
+
+	if (UBOOL_TEST(snapToGrid)) {
+		// Align vertex coordinates to the native pixel grid
+		// This ensures text does not get garbled by nearest neighbors scaling
+		pos.x = floor(pos.x * viewport.x + 0.5) / viewport.x;
+		pos.y = floor(pos.y * viewport.y + 0.5) / viewport.y;
+	}
+
+	pos.x = pos.x * 2.0 - 1.0;
+	pos.y = -1.0 * (pos.y * 2.0 - 1.0);
+
+	gl_Position = vec4(pos, 0.0, 1.0);
+}
diff --git a/engines/stark/ui/dialogbox.cpp b/engines/stark/ui/dialogbox.cpp
index 266c8e4a6ce..2f922f1fa1b 100644
--- a/engines/stark/ui/dialogbox.cpp
+++ b/engines/stark/ui/dialogbox.cpp
@@ -46,25 +46,16 @@ static const uint buttonVerticalMargin   = 5;
 
 DialogBox::DialogBox(StarkEngine *vm, Gfx::Driver *gfx, Cursor *cursor) :
 		Window(gfx, cursor),
+		_background(nullptr),
 		_foreground(nullptr),
 		_confirmCallback(nullptr) {
 	_vm = vm;
 	_surfaceRenderer = gfx->createSurfaceRenderer();
 
-	Graphics::Surface *background = loadBackground();
-	if (!background) {
-		// If we were not able to load the background, fallback to dark blue
-		background = new Graphics::Surface();
-		background->create(256, 256, Gfx::Driver::getRGBAPixelFormat());
-
-		uint32 blue = background->format.RGBToColor(26, 28, 57);
-		background->fillRect(Common::Rect(256, 256), blue);
+	_background = loadBackground(gfx);
+	if (_background) {
+		_background->setSamplingFilter(Gfx::Bitmap::kLinear);
 	}
-	_background = gfx->createBitmap(background);
-	_background->setSamplingFilter(Gfx::Bitmap::kLinear);
-
-	background->free();
-	delete background;
 
 	_messageVisual = new VisualText(gfx);
 	_messageVisual->setColor(_textColor);
@@ -214,7 +205,7 @@ void DialogBox::onKeyPress(const Common::KeyState &keyState) {
 	}
 }
 
-Graphics::Surface *DialogBox::loadBackground() {
+Gfx::Bitmap *DialogBox::loadBackground(Gfx::Driver *gfx) {
 	Common::PEResources *executable = new Common::PEResources();
 	if (!executable->loadFromEXE("game.exe") && !executable->loadFromEXE("game.dll")) {
 		warning("Unable to load 'game.exe' to read the modal dialog background image");
@@ -263,13 +254,17 @@ Graphics::Surface *DialogBox::loadBackground() {
 
 	delete[] bitmapWithHeader;
 
-	return decoder.getSurface()->convertTo(Gfx::Driver::getRGBAPixelFormat(), decoder.getPalette());
+	return gfx->createBitmap(decoder.getSurface(), decoder.getPalette());
 }
 
 void DialogBox::onRender() {
-	uint32 backgroundRepeatX = ceil(_foreground->width() / (float)_background->width());
-	for (uint i = 0; i < backgroundRepeatX; i++) {
-		_surfaceRenderer->render(_background, Common::Point(i * _background->width(), 0));
+	if (_background) {
+		uint32 backgroundRepeatX = ceil(_foreground->width() / (float)_background->width());
+		for (uint i = 0; i < backgroundRepeatX; i++) {
+			_surfaceRenderer->render(_background, Common::Point(i * _background->width(), 0));
+		}
+	} else {
+		_surfaceRenderer->fill(_backgroundColor, Common::Point(0, 0), _foreground->width(), _foreground->height());
 	}
 
 	_surfaceRenderer->render(_foreground, Common::Point(0, 0));
diff --git a/engines/stark/ui/dialogbox.h b/engines/stark/ui/dialogbox.h
index 0516ee6deb0..df102e2942c 100644
--- a/engines/stark/ui/dialogbox.h
+++ b/engines/stark/ui/dialogbox.h
@@ -69,7 +69,7 @@ protected:
 	void onClick(const Common::Point &pos) override;
 
 private:
-	Graphics::Surface *loadBackground();
+	Gfx::Bitmap *loadBackground(Gfx::Driver *gfx);
 	static void drawBevel(Graphics::Surface *surface, const Common::Rect &rect);
 	static Common::Rect centerRect(const Common::Rect &container, const Common::Rect &size);
 
@@ -91,6 +91,7 @@ private:
 	Common::Rect _messageRect;
 
 	const Gfx::Color _textColor = Gfx::Color(0xFF, 0xFF, 0xFF);
+	const Gfx::Color _backgroundColor = Gfx::Color(26, 28, 57);
 
 	ConfirmCallback *_confirmCallback;
 };
diff --git a/engines/stark/visual/text.cpp b/engines/stark/visual/text.cpp
index dff4a740d2e..54dd2498884 100644
--- a/engines/stark/visual/text.cpp
+++ b/engines/stark/visual/text.cpp
@@ -296,29 +296,11 @@ void VisualText::createBitmap() {
 	_bitmap->setSamplingFilter(Gfx::Bitmap::kNearest);
 
 	surface.free();
-
-	// If we have a background color, generate a 1x1px bitmap of that color
-	if (_backgroundColor.a != 0) {
-		surface.create(1, 1, Gfx::Driver::getRGBAPixelFormat());
-
-		uint32 bgColor = surface.format.ARGBToColor(
-		            _backgroundColor.a, _backgroundColor.r, _backgroundColor.g, _backgroundColor.b
-		            );
-
-		surface.fillRect(Common::Rect(surface.w, surface.h), bgColor);
-		multiplyColorWithAlpha(&surface);
-
-		_bgBitmap = _gfx->createBitmap(&surface);
-
-		surface.free();
-	}
 }
 
 void VisualText::freeBitmap() {
 	delete _bitmap;
 	_bitmap = nullptr;
-	delete _bgBitmap;
-	_bgBitmap = nullptr;
 }
 
 void VisualText::render(const Common::Point &position) {
@@ -326,8 +308,8 @@ void VisualText::render(const Common::Point &position) {
 		createBitmap();
 	}
 
-	if (_bgBitmap) {
-		_surfaceRenderer->render(_bgBitmap, position, _bitmap->width(), _bitmap->height());
+	if (_backgroundColor.a != 0) {
+		_surfaceRenderer->fill(_backgroundColor, position, _bitmap->width(), _bitmap->height());
 	}
 
 	_surfaceRenderer->render(_bitmap, position);
diff --git a/engines/stark/visual/text.h b/engines/stark/visual/text.h
index 710f0859d24..e350271d06c 100644
--- a/engines/stark/visual/text.h
+++ b/engines/stark/visual/text.h
@@ -74,7 +74,6 @@ private:
 	Gfx::Driver *_gfx;
 	Gfx::SurfaceRenderer *_surfaceRenderer;
 	Gfx::Bitmap *_bitmap;
-	Gfx::Bitmap *_bgBitmap;
 
 	Common::String _text;
 	Gfx::Color _color;




More information about the Scummvm-git-logs mailing list