1
0
mirror of https://github.com/narzoul/DDrawCompat synced 2024-12-30 08:55:36 +01:00

Invalidate GDI content when palette changes

This commit is contained in:
narzoul 2016-02-14 17:11:34 +01:00
parent d51cfa1b14
commit 4a83a15d78
3 changed files with 37 additions and 1 deletions

View File

@ -17,6 +17,9 @@ namespace
HANDLE g_ddUnlockEndEvent = nullptr;
bool g_isDelayedUnlockPending = false;
bool g_isPaletteUsed = false;
PALETTEENTRY g_usedPaletteEntries[256] = {};
FARPROC getProcAddress(HMODULE module, const char* procName)
{
if (!module || !procName)
@ -142,6 +145,14 @@ namespace CompatGdi
++g_ddLockThreadRenderingRefCount;
}
if (!g_isPaletteUsed && CompatPrimarySurface::palette)
{
g_isPaletteUsed = true;
ZeroMemory(g_usedPaletteEntries, sizeof(g_usedPaletteEntries));
CompatPrimarySurface::palette->lpVtbl->GetEntries(
CompatPrimarySurface::palette, 0, 0, 256, g_usedPaletteEntries);
}
++g_renderingRefCount;
return true;
}
@ -235,5 +246,19 @@ namespace CompatGdi
{
GdiScopedThreadLock gdiLock;
CompatGdiDcCache::clear();
if (g_isPaletteUsed && CompatPrimarySurface::palette)
{
g_isPaletteUsed = false;
PALETTEENTRY usedPaletteEntries[256] = {};
CompatPrimarySurface::palette->lpVtbl->GetEntries(
CompatPrimarySurface::palette, 0, 0, 256, usedPaletteEntries);
if (0 != memcmp(usedPaletteEntries, g_usedPaletteEntries, sizeof(usedPaletteEntries)))
{
invalidate();
}
}
}
}

View File

@ -14,6 +14,7 @@ namespace
std::vector<CachedDc> g_cache;
DWORD g_cacheSize = 0;
DWORD g_cacheId = 0;
DWORD g_maxUsedCacheSize = 0;
DWORD g_ddLockThreadId = 0;
@ -67,6 +68,7 @@ namespace
cachedDc.surface = surface;
cachedDc.dc = dc;
cachedDc.cacheId = g_cacheId;
return cachedDc;
}
@ -150,6 +152,7 @@ namespace CompatGdiDcCache
}
g_cache.clear();
g_cacheSize = 0;
++g_cacheId;
}
CachedDc getDc()
@ -189,7 +192,14 @@ namespace CompatGdiDcCache
void releaseDc(const CachedDc& cachedDc)
{
g_cache.push_back(cachedDc);
if (cachedDc.cacheId == g_cacheId)
{
g_cache.push_back(cachedDc);
}
else
{
releaseCachedDc(cachedDc);
}
}
void setDdLockThreadId(DWORD ddLockThreadId)

View File

@ -12,6 +12,7 @@ namespace CompatGdiDcCache
{
IDirectDrawSurface7* surface;
HDC dc;
DWORD cacheId;
};
void clear();