[Scummvm-git-logs] scummvm master -> 0654be0322c84f26bb77c3b248da6e50fcd47ce1

sev- sev at scummvm.org
Fri Jul 17 12:19:46 UTC 2020


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

Summary:
0654be0322 GRAPHICS: MACGUI: Implement hashing to findBestColor()


Commit: 0654be0322c84f26bb77c3b248da6e50fcd47ce1
    https://github.com/scummvm/scummvm/commit/0654be0322c84f26bb77c3b248da6e50fcd47ce1
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2020-07-17T14:19:22+02:00

Commit Message:
GRAPHICS: MACGUI: Implement hashing to findBestColor()

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


diff --git a/graphics/macgui/macwindowmanager.cpp b/graphics/macgui/macwindowmanager.cpp
index 1bb2cc5f17..67dcce9de2 100644
--- a/graphics/macgui/macwindowmanager.cpp
+++ b/graphics/macgui/macwindowmanager.cpp
@@ -679,6 +679,8 @@ void MacWindowManager::passPalette(const byte *pal, uint size) {
 	_palette = (byte *)malloc(size * 3);
 	_paletteSize = size;
 
+	_colorHash.clear();
+
 	_colorWhite = -1;
 	_colorBlack = -1;
 
@@ -728,6 +730,11 @@ uint MacWindowManager::findBestColor(byte cr, byte cg, byte cb) {
 	uint bestColor = 0;
 	double min = 0xFFFFFFFF;
 
+	uint32 color = cr << 16 | cg << 8 | cb;
+
+	if (_colorHash.contains(color))
+		return _colorHash[color];
+
 	for (uint i = 0; i < _paletteSize; ++i) {
 		int rmean = (*(_palette + 3 * i + 0) + cr) / 2;
 		int r = *(_palette + 3 * i + 0) - cr;
@@ -741,6 +748,8 @@ uint MacWindowManager::findBestColor(byte cr, byte cg, byte cb) {
 		}
 	}
 
+	_colorHash[color] = bestColor;
+
 	return bestColor;
 }
 
diff --git a/graphics/macgui/macwindowmanager.h b/graphics/macgui/macwindowmanager.h
index c425fef35e..8846b019d9 100644
--- a/graphics/macgui/macwindowmanager.h
+++ b/graphics/macgui/macwindowmanager.h
@@ -324,6 +324,7 @@ private:
 	PauseToken _screenCopyPauseToken;
 
 	Common::Array<ZoomBox *> _zoomBoxes;
+	Common::HashMap<uint32, uint> _colorHash;
 };
 
 } // End of namespace Graphics




More information about the Scummvm-git-logs mailing list