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:
parent
d51cfa1b14
commit
4a83a15d78
@ -17,6 +17,9 @@ namespace
|
|||||||
HANDLE g_ddUnlockEndEvent = nullptr;
|
HANDLE g_ddUnlockEndEvent = nullptr;
|
||||||
bool g_isDelayedUnlockPending = false;
|
bool g_isDelayedUnlockPending = false;
|
||||||
|
|
||||||
|
bool g_isPaletteUsed = false;
|
||||||
|
PALETTEENTRY g_usedPaletteEntries[256] = {};
|
||||||
|
|
||||||
FARPROC getProcAddress(HMODULE module, const char* procName)
|
FARPROC getProcAddress(HMODULE module, const char* procName)
|
||||||
{
|
{
|
||||||
if (!module || !procName)
|
if (!module || !procName)
|
||||||
@ -142,6 +145,14 @@ namespace CompatGdi
|
|||||||
++g_ddLockThreadRenderingRefCount;
|
++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;
|
++g_renderingRefCount;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -235,5 +246,19 @@ namespace CompatGdi
|
|||||||
{
|
{
|
||||||
GdiScopedThreadLock gdiLock;
|
GdiScopedThreadLock gdiLock;
|
||||||
CompatGdiDcCache::clear();
|
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();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,6 +14,7 @@ namespace
|
|||||||
|
|
||||||
std::vector<CachedDc> g_cache;
|
std::vector<CachedDc> g_cache;
|
||||||
DWORD g_cacheSize = 0;
|
DWORD g_cacheSize = 0;
|
||||||
|
DWORD g_cacheId = 0;
|
||||||
DWORD g_maxUsedCacheSize = 0;
|
DWORD g_maxUsedCacheSize = 0;
|
||||||
DWORD g_ddLockThreadId = 0;
|
DWORD g_ddLockThreadId = 0;
|
||||||
|
|
||||||
@ -67,6 +68,7 @@ namespace
|
|||||||
|
|
||||||
cachedDc.surface = surface;
|
cachedDc.surface = surface;
|
||||||
cachedDc.dc = dc;
|
cachedDc.dc = dc;
|
||||||
|
cachedDc.cacheId = g_cacheId;
|
||||||
return cachedDc;
|
return cachedDc;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -150,6 +152,7 @@ namespace CompatGdiDcCache
|
|||||||
}
|
}
|
||||||
g_cache.clear();
|
g_cache.clear();
|
||||||
g_cacheSize = 0;
|
g_cacheSize = 0;
|
||||||
|
++g_cacheId;
|
||||||
}
|
}
|
||||||
|
|
||||||
CachedDc getDc()
|
CachedDc getDc()
|
||||||
@ -189,7 +192,14 @@ namespace CompatGdiDcCache
|
|||||||
|
|
||||||
void releaseDc(const CachedDc& cachedDc)
|
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)
|
void setDdLockThreadId(DWORD ddLockThreadId)
|
||||||
|
@ -12,6 +12,7 @@ namespace CompatGdiDcCache
|
|||||||
{
|
{
|
||||||
IDirectDrawSurface7* surface;
|
IDirectDrawSurface7* surface;
|
||||||
HDC dc;
|
HDC dc;
|
||||||
|
DWORD cacheId;
|
||||||
};
|
};
|
||||||
|
|
||||||
void clear();
|
void clear();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user