mirror of
https://github.com/libretro/scummvm.git
synced 2024-12-03 15:41:41 +00:00
GRAPHICS: MACGUI: add cache for inverted color.
This commit is contained in:
parent
50bfc4e521
commit
4133592992
@ -100,7 +100,6 @@ void Window::invertChannel(Channel *channel, const Common::Rect &destRect) {
|
||||
byte *src = (byte *)_composeSurface->getBasePtr(srcRect.left, srcRect.top + i);
|
||||
const byte *msk = mask ? (const byte *)mask->getBasePtr(xoff, yoff + i) : nullptr;
|
||||
|
||||
// if this will cause efficiency problem, then we shall cache the inverted color in wm
|
||||
for (int j = 0; j < srcRect.width(); j++, src++)
|
||||
if (!mask || (msk && !(*msk++)))
|
||||
*src = _wm->inverter(*src);
|
||||
|
@ -1295,6 +1295,7 @@ void MacWindowManager::passPalette(const byte *pal, uint size) {
|
||||
_paletteSize = size;
|
||||
|
||||
_colorHash.clear();
|
||||
_invertColorHash.clear();
|
||||
|
||||
LOOKUPCOLOR(White);
|
||||
LOOKUPCOLOR(Gray80);
|
||||
@ -1355,17 +1356,21 @@ void MacWindowManager::decomposeColor(uint32 color, byte &r, byte &g, byte &b) {
|
||||
}
|
||||
|
||||
uint MacWindowManager::inverter(uint src) {
|
||||
if (_invertColorHash.contains(src))
|
||||
return _invertColorHash[src];
|
||||
|
||||
if (_pixelformat.bytesPerPixel == 1) {
|
||||
byte r, g, b;
|
||||
decomposeColor(src, r, g, b);
|
||||
r = ~r;
|
||||
g = ~g;
|
||||
b = ~b;
|
||||
return findBestColor(r, g, b);
|
||||
_invertColorHash[src] = findBestColor(r, g, b);
|
||||
} else {
|
||||
uint32 alpha = _pixelformat.ARGBToColor(255, 0, 0, 0);
|
||||
return ~(src & ~alpha) | alpha;
|
||||
_invertColorHash[src] = ~(src & ~alpha) | alpha;
|
||||
}
|
||||
return _invertColorHash[src];
|
||||
}
|
||||
|
||||
PauseToken MacWindowManager::pauseEngine() {
|
||||
|
@ -432,7 +432,8 @@ private:
|
||||
PauseToken *_screenCopyPauseToken;
|
||||
|
||||
Common::Array<ZoomBox *> _zoomBoxes;
|
||||
Common::HashMap<uint32, uint> _colorHash;
|
||||
Common::HashMap<uint, uint> _colorHash;
|
||||
Common::HashMap<uint, uint> _invertColorHash;
|
||||
|
||||
Common::Archive *_dataBundle;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user