mirror of
https://github.com/FunkyFr3sh/cnc-ddraw.git
synced 2025-03-14 22:03:27 +01:00
make sure we don't update the palette twice
This commit is contained in:
parent
bbe8c4f857
commit
39b2e69540
@ -7,6 +7,8 @@
|
||||
#include "IDirectDrawPalette.h"
|
||||
#include "dd.h"
|
||||
|
||||
#define DDPCAPS_REFRESH_CHANGED_ONLY (1 << 31)
|
||||
|
||||
HRESULT ddp_GetEntries(IDirectDrawPaletteImpl* This, DWORD dwFlags, DWORD dwBase, DWORD dwNumEntries, LPPALETTEENTRY lpEntries);
|
||||
HRESULT ddp_SetEntries(IDirectDrawPaletteImpl* This, DWORD dwFlags, DWORD dwStartingEntry, DWORD dwCount, LPPALETTEENTRY lpEntries);
|
||||
HRESULT dd_CreatePalette(DWORD dwFlags, LPPALETTEENTRY lpDDColorArray, IDirectDrawPaletteImpl** lpDDPalette, IUnknown FAR* unkOuter);
|
||||
|
@ -5,6 +5,7 @@
|
||||
#include "ddsurface.h"
|
||||
#include "IDirectDrawPalette.h"
|
||||
#include "debug.h"
|
||||
#include "crc32.h"
|
||||
|
||||
|
||||
HRESULT ddp_GetEntries(
|
||||
@ -38,6 +39,13 @@ HRESULT ddp_SetEntries(
|
||||
if (!lpEntries)
|
||||
return DDERR_INVALIDPARAMS;
|
||||
|
||||
unsigned long crc32 = 0;
|
||||
|
||||
if ((dwFlags & DDPCAPS_REFRESH_CHANGED_ONLY))
|
||||
{
|
||||
crc32 = Crc32_ComputeBuf(0, This->data_rgb, sizeof(This->data_rgb));
|
||||
}
|
||||
|
||||
for (int i = dwStartingEntry, x = 0; i < dwStartingEntry + dwCount && i < 256; i++, x++)
|
||||
{
|
||||
This->data_bgr[i] = (lpEntries[x].peBlue << 16) | (lpEntries[x].peGreen << 8) | lpEntries[x].peRed;
|
||||
@ -64,6 +72,12 @@ HRESULT ddp_SetEntries(
|
||||
This->data_rgb[255].rgbReserved = 0;
|
||||
}
|
||||
|
||||
if (crc32 && crc32 == Crc32_ComputeBuf(0, This->data_rgb, sizeof(This->data_rgb)))
|
||||
{
|
||||
// do not set palette_updated BOOL if nothing changed
|
||||
return DD_OK;
|
||||
}
|
||||
|
||||
if (g_ddraw.ref && g_ddraw.primary && g_ddraw.primary->palette == This && g_ddraw.render.run)
|
||||
{
|
||||
InterlockedExchange(&g_ddraw.render.palette_updated, TRUE);
|
||||
|
@ -1460,7 +1460,7 @@ UINT WINAPI fake_RealizePalette(HDC hdc)
|
||||
|
||||
ddp_SetEntries(
|
||||
g_ddraw.primary->palette,
|
||||
0,
|
||||
DDPCAPS_REFRESH_CHANGED_ONLY,
|
||||
0,
|
||||
g_ddraw.primary->selected_pal_count,
|
||||
g_ddraw.primary->selected_pal);
|
||||
|
Loading…
x
Reference in New Issue
Block a user