[Scummvm-git-logs] scummvm master -> 9fe70f20cf9710054c30b2ae8b7547564183b2bc

sev- sev at scummvm.org
Thu Jan 30 23:10:41 UTC 2020


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

Summary:
2ec72ea3dd GRAPHICS: MACGUI: Add helper method for color searching
a1cce6dfee PINK: Fix warning
cdd2d9336b GRAPHICS: MACGUI: Simplified color matching
69343b2db8 GRAPHICS: MACGUI: Actually store palette when it is passed
9fe70f20cf DIRECTOR: Follow the requested textcast color


Commit: 2ec72ea3dd7c6ce5b9fee99a0b1419cbf6b04329
    https://github.com/scummvm/scummvm/commit/2ec72ea3dd7c6ce5b9fee99a0b1419cbf6b04329
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2020-01-31T00:10:18+01:00

Commit Message:
GRAPHICS: MACGUI: Add helper method for color searching

Changed paths:
    graphics/macgui/macwindowmanager.cpp
    graphics/macgui/macwindowmanager.h


diff --git a/graphics/macgui/macwindowmanager.cpp b/graphics/macgui/macwindowmanager.cpp
index 1944805..ebaa803 100644
--- a/graphics/macgui/macwindowmanager.cpp
+++ b/graphics/macgui/macwindowmanager.cpp
@@ -170,6 +170,9 @@ MacWindowManager::MacWindowManager(uint32 mode) {
 
 	_fullRefresh = true;
 
+	_palette = nullptr;
+	_paletteSize = 0;
+
 	for (int i = 0; i < ARRAYSIZE(fillPatterns); i++)
 		_patterns.push_back(fillPatterns[i]);
 
@@ -496,6 +499,12 @@ void MacWindowManager::popCursor() {
 void MacWindowManager::passPalette(const byte *pal, uint size) {
 	const byte *p = pal;
 
+	if (_palette)
+		free(_palette);
+
+	_palette = (byte *)malloc(size * 3);
+	_paletteSize = size;
+
 	_colorWhite = -1;
 	_colorBlack = -1;
 
@@ -539,6 +548,30 @@ void MacWindowManager::passPalette(const byte *pal, uint size) {
 	_colorBlack = di;
 }
 
+#define BLUE(rgb) ((rgb) & 0xFF)
+#define GREEN(rgb) (((rgb) >> 8) & 0xFF)
+#define RED(rgb) (((rgb) >> 16) & 0xFF)
+
+uint MacWindowManager::findBestColor(uint32 rgb) {
+	uint bestColor = 0;
+	double min = 0xFFFFFFFF;
+
+	for (uint i = 0; i < _paletteSize; ++i) {
+		int rmean = (*(_palette + 3 * i + 0) + RED(rgb)) / 2;
+		int r = *(_palette + 3 * i + 0) - RED(rgb);
+		int g = *(_palette + 3 * i + 1) - GREEN(rgb);
+		int b = *(_palette + 3 * i + 2) - BLUE(rgb);
+
+		double dist = sqrt((((512 + rmean) * r * r) >> 8) + 4 * g * g + (((767 - rmean) * b * b) >> 8));
+		if (min > dist) {
+			bestColor = i;
+			min = dist;
+		}
+	}
+
+	return bestColor;
+}
+
 void MacWindowManager::pauseEngine(bool pause) {
 	if (_engineP && _pauseEngineCallback) {
 		_pauseEngineCallback(_engineP, pause);
diff --git a/graphics/macgui/macwindowmanager.h b/graphics/macgui/macwindowmanager.h
index 5846bcb..a518378 100644
--- a/graphics/macgui/macwindowmanager.h
+++ b/graphics/macgui/macwindowmanager.h
@@ -221,6 +221,7 @@ public:
 	void setEngineRedrawCallback(void *engine, void (*redrawCallback)(void *engine));
 
 	void passPalette(const byte *palette, uint size);
+	uint findBestColor(uint32 rgb);
 
 public:
 	MacFontManager *_fontMan;
@@ -257,6 +258,8 @@ private:
 	bool _fullRefresh;
 
 	MacPatterns _patterns;
+	byte *_palette;
+	int _paletteSize;
 
 	MacMenu *_menu;
 	uint32 _menuDelay;


Commit: a1cce6dfeea1308b0cafd359a08d5dd9673ffd90
    https://github.com/scummvm/scummvm/commit/a1cce6dfeea1308b0cafd359a08d5dd9673ffd90
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2020-01-31T00:10:18+01:00

Commit Message:
PINK: Fix warning

Changed paths:
    engines/pink/pink.h


diff --git a/engines/pink/pink.h b/engines/pink/pink.h
index ce48a90..42e8f5e 100644
--- a/engines/pink/pink.h
+++ b/engines/pink/pink.h
@@ -66,7 +66,7 @@ namespace Common {
 
 namespace Graphics {
 class MacMenu;
-class WinCursorGroup;
+struct WinCursorGroup;
 }
 
 namespace Pink {


Commit: cdd2d9336b64530fba7ab1b672c7b00fd51ee6d9
    https://github.com/scummvm/scummvm/commit/cdd2d9336b64530fba7ab1b672c7b00fd51ee6d9
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2020-01-31T00:10:18+01:00

Commit Message:
GRAPHICS: MACGUI: Simplified color matching

Changed paths:
    graphics/macgui/macwindowmanager.cpp
    graphics/macgui/macwindowmanager.h


diff --git a/graphics/macgui/macwindowmanager.cpp b/graphics/macgui/macwindowmanager.cpp
index ebaa803..ab401f4 100644
--- a/graphics/macgui/macwindowmanager.cpp
+++ b/graphics/macgui/macwindowmanager.cpp
@@ -548,19 +548,15 @@ void MacWindowManager::passPalette(const byte *pal, uint size) {
 	_colorBlack = di;
 }
 
-#define BLUE(rgb) ((rgb) & 0xFF)
-#define GREEN(rgb) (((rgb) >> 8) & 0xFF)
-#define RED(rgb) (((rgb) >> 16) & 0xFF)
-
-uint MacWindowManager::findBestColor(uint32 rgb) {
+uint MacWindowManager::findBestColor(byte cr, byte cg, byte cb) {
 	uint bestColor = 0;
 	double min = 0xFFFFFFFF;
 
 	for (uint i = 0; i < _paletteSize; ++i) {
-		int rmean = (*(_palette + 3 * i + 0) + RED(rgb)) / 2;
-		int r = *(_palette + 3 * i + 0) - RED(rgb);
-		int g = *(_palette + 3 * i + 1) - GREEN(rgb);
-		int b = *(_palette + 3 * i + 2) - BLUE(rgb);
+		int rmean = (*(_palette + 3 * i + 0) + cr) / 2;
+		int r = *(_palette + 3 * i + 0) - cr;
+		int g = *(_palette + 3 * i + 1) - cg;
+		int b = *(_palette + 3 * i + 2) - cb;
 
 		double dist = sqrt((((512 + rmean) * r * r) >> 8) + 4 * g * g + (((767 - rmean) * b * b) >> 8));
 		if (min > dist) {
diff --git a/graphics/macgui/macwindowmanager.h b/graphics/macgui/macwindowmanager.h
index a518378..a91e009 100644
--- a/graphics/macgui/macwindowmanager.h
+++ b/graphics/macgui/macwindowmanager.h
@@ -221,7 +221,7 @@ public:
 	void setEngineRedrawCallback(void *engine, void (*redrawCallback)(void *engine));
 
 	void passPalette(const byte *palette, uint size);
-	uint findBestColor(uint32 rgb);
+	uint findBestColor(byte cr, byte cg, byte cb);
 
 public:
 	MacFontManager *_fontMan;


Commit: 69343b2db87aaa14fc89d05c00a610d82c6c78e1
    https://github.com/scummvm/scummvm/commit/69343b2db87aaa14fc89d05c00a610d82c6c78e1
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2020-01-31T00:10:18+01:00

Commit Message:
GRAPHICS: MACGUI: Actually store palette when it is passed

Changed paths:
    graphics/macgui/macwindowmanager.cpp


diff --git a/graphics/macgui/macwindowmanager.cpp b/graphics/macgui/macwindowmanager.cpp
index ab401f4..b3b87b4 100644
--- a/graphics/macgui/macwindowmanager.cpp
+++ b/graphics/macgui/macwindowmanager.cpp
@@ -517,7 +517,9 @@ void MacWindowManager::passPalette(const byte *pal, uint size) {
 		if (_colorBlack == -1 && p[0] == 0x00 && p[1] == 0x00 && p[2] == 0x00)
 			_colorBlack = i;
 
-		p += 3;
+		_palette[i * 3 + 0] = *p++;
+		_palette[i * 3 + 1] = *p++;
+		_palette[i * 3 + 2] = *p++;
 	}
 
 	if (_colorWhite != -1 && _colorBlack != -1)


Commit: 9fe70f20cf9710054c30b2ae8b7547564183b2bc
    https://github.com/scummvm/scummvm/commit/9fe70f20cf9710054c30b2ae8b7547564183b2bc
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2020-01-31T00:10:18+01:00

Commit Message:
DIRECTOR: Follow the requested textcast color

Changed paths:
    engines/director/cachedmactext.cpp


diff --git a/engines/director/cachedmactext.cpp b/engines/director/cachedmactext.cpp
index d3557c6..39a4745 100644
--- a/engines/director/cachedmactext.cpp
+++ b/engines/director/cachedmactext.cpp
@@ -21,6 +21,7 @@
  */
 
 #include "graphics/macgui/macfontmanager.h"
+#include "graphics/macgui/macwindowmanager.h"
 #include "graphics/macgui/mactext.h"
 
 #include "director/director.h"
@@ -49,7 +50,9 @@ void CachedMacText::makeMacText() {
 		_textCast->_fontId, _textCast->_fontSize, _textCast->_textSlant, macFont->getName().c_str(),
 		Common::toPrintable(_textCast->_ftext).c_str());
 
-	_macText = new Graphics::MacText(_textCast->_ftext, _wm, macFont, 0x00, 0xff, _width, _align, 1);
+	uint color = _wm->findBestColor(_textCast->_palinfo1 & 0xff, _textCast->_palinfo2 & 0xff, _textCast->_palinfo3 & 0xff);
+
+	_macText = new Graphics::MacText(_textCast->_ftext, _wm, macFont, color, 0xff, _width, _align, 1);
 	// TODO destroy me
 }
 




More information about the Scummvm-git-logs mailing list