DXGL r663 - Code Review

Jump to navigation Jump to search
Repository:DXGL
Revision:r662‎ | r663 | r664 >
Date:00:34, 9 June 2016
Author:admin
Status:new
Tags:
Comment:
Fix colorspace color keys.
Fix crash setting palette or stencil texture to NULL;
Modified paths:
  • /ddraw/glDirectDrawSurface.cpp (modified) (history)
  • /ddraw/glRenderer.cpp (modified) (history)
  • /ddraw/glTexture.cpp (modified) (history)

Diff [purge]

Index: ddraw/glDirectDrawSurface.cpp
@@ -1320,21 +1320,29 @@
13211321 {
13221322 ddsd.dwFlags |= DDSD_CKSRCBLT;
13231323 colorkey[0] = key;
 1324+ ddsd.ddckCKSrcBlt = *lpDDColorKey;
 1325+ if (!key.colorspace) ddsd.ddckCKSrcBlt.dwColorSpaceHighValue = lpDDColorKey->dwColorSpaceLowValue;
13241326 }
13251327 if(dwFlags & DDCKEY_DESTBLT)
13261328 {
13271329 ddsd.dwFlags |= DDSD_CKDESTBLT;
13281330 colorkey[1] = key;
 1331+ ddsd.ddckCKDestBlt = *lpDDColorKey;
 1332+ if (!key.colorspace) ddsd.ddckCKDestBlt.dwColorSpaceHighValue = lpDDColorKey->dwColorSpaceLowValue;
13291333 }
13301334 if(dwFlags & DDCKEY_SRCOVERLAY)
13311335 {
13321336 ddsd.dwFlags |= DDSD_CKSRCOVERLAY;
13331337 colorkey[2] = key;
 1338+ ddsd.ddckCKSrcOverlay = *lpDDColorKey;
 1339+ if (!key.colorspace) ddsd.ddckCKSrcOverlay.dwColorSpaceHighValue = lpDDColorKey->dwColorSpaceLowValue;
13341340 }
13351341 if(dwFlags & DDCKEY_DESTOVERLAY)
13361342 {
13371343 ddsd.dwFlags |= DDSD_CKDESTOVERLAY;
13381344 colorkey[3] = key;
 1345+ ddsd.ddckCKDestOverlay = *lpDDColorKey;
 1346+ if (!key.colorspace) ddsd.ddckCKDestOverlay.dwColorSpaceHighValue = lpDDColorKey->dwColorSpaceLowValue;
13391347 }
13401348 glRenderer_SetTextureColorKey(this->ddInterface->renderer, this->texture, dwFlags, lpDDColorKey, this->miplevel);
13411349 TRACE_EXIT(23,DD_OK);
Index: ddraw/glRenderer.cpp
@@ -2928,29 +2928,29 @@
29292929 {
29302930 texture->levels[level].ddsd.dwFlags |= DDSD_CKSRCBLT;
29312931 texture->levels[level].ddsd.ddckCKSrcBlt.dwColorSpaceLowValue = lpDDColorKey->dwColorSpaceLowValue;
2932 - if (DDCKEY_COLORSPACE) texture->levels[level].ddsd.ddckCKSrcBlt.dwColorSpaceHighValue = lpDDColorKey->dwColorSpaceLowValue;
2933 - else texture->levels[level].ddsd.ddckCKSrcBlt.dwColorSpaceHighValue = lpDDColorKey->dwColorSpaceHighValue;
 2932+ if (DDCKEY_COLORSPACE) texture->levels[level].ddsd.ddckCKSrcBlt.dwColorSpaceHighValue = lpDDColorKey->dwColorSpaceHighValue;
 2933+ else texture->levels[level].ddsd.ddckCKSrcBlt.dwColorSpaceHighValue = lpDDColorKey->dwColorSpaceLowValue;
29342934 }
29352935 if (dwFlags & DDCKEY_DESTBLT)
29362936 {
29372937 texture->levels[level].ddsd.dwFlags |= DDSD_CKDESTBLT;
29382938 texture->levels[level].ddsd.ddckCKDestBlt.dwColorSpaceLowValue = lpDDColorKey->dwColorSpaceLowValue;
2939 - if (DDCKEY_COLORSPACE) texture->levels[level].ddsd.ddckCKDestBlt.dwColorSpaceHighValue = lpDDColorKey->dwColorSpaceLowValue;
2940 - else texture->levels[level].ddsd.ddckCKDestBlt.dwColorSpaceHighValue = lpDDColorKey->dwColorSpaceHighValue;
 2939+ if (DDCKEY_COLORSPACE) texture->levels[level].ddsd.ddckCKDestBlt.dwColorSpaceHighValue = lpDDColorKey->dwColorSpaceHighValue;
 2940+ else texture->levels[level].ddsd.ddckCKDestBlt.dwColorSpaceHighValue = lpDDColorKey->dwColorSpaceLowValue;
29412941 }
29422942 if (dwFlags & DDCKEY_SRCOVERLAY)
29432943 {
29442944 texture->levels[level].ddsd.dwFlags |= DDSD_CKSRCOVERLAY;
29452945 texture->levels[level].ddsd.ddckCKSrcOverlay.dwColorSpaceLowValue = lpDDColorKey->dwColorSpaceLowValue;
2946 - if (DDCKEY_COLORSPACE) texture->levels[level].ddsd.ddckCKSrcOverlay.dwColorSpaceHighValue = lpDDColorKey->dwColorSpaceLowValue;
2947 - else texture->levels[level].ddsd.ddckCKSrcOverlay.dwColorSpaceHighValue = lpDDColorKey->dwColorSpaceHighValue;
 2946+ if (DDCKEY_COLORSPACE) texture->levels[level].ddsd.ddckCKSrcOverlay.dwColorSpaceHighValue = lpDDColorKey->dwColorSpaceHighValue;
 2947+ else texture->levels[level].ddsd.ddckCKSrcOverlay.dwColorSpaceHighValue = lpDDColorKey->dwColorSpaceLowValue;
29482948 }
29492949 if (dwFlags & DDCKEY_DESTOVERLAY)
29502950 {
29512951 texture->levels[level].ddsd.dwFlags |= DDSD_CKDESTOVERLAY;
29522952 texture->levels[level].ddsd.ddckCKDestOverlay.dwColorSpaceLowValue = lpDDColorKey->dwColorSpaceLowValue;
2953 - if (DDCKEY_COLORSPACE) texture->levels[level].ddsd.ddckCKDestOverlay.dwColorSpaceHighValue = lpDDColorKey->dwColorSpaceLowValue;
2954 - else texture->levels[level].ddsd.ddckCKDestOverlay.dwColorSpaceHighValue = lpDDColorKey->dwColorSpaceHighValue;
 2953+ if (DDCKEY_COLORSPACE) texture->levels[level].ddsd.ddckCKDestOverlay.dwColorSpaceHighValue = lpDDColorKey->dwColorSpaceHighValue;
 2954+ else texture->levels[level].ddsd.ddckCKDestOverlay.dwColorSpaceHighValue = lpDDColorKey->dwColorSpaceLowValue;
29552955 }
29562956 SetEvent(This->busy);
29572957 }
Index: ddraw/glTexture.cpp
@@ -371,13 +371,13 @@
372372 {
373373 if (This->palette) glTexture_Release(This->palette, backend);
374374 This->palette = palette;
375 - glTexture_AddRef(palette);
 375+ if (palette) glTexture_AddRef(palette);
376376 }
377377 void glTexture_SetStencil(glTexture *This, glTexture *stencil, BOOL backend)
378378 {
379379 if (This->stencil) glTexture_Release(This->stencil, backend);
380380 This->stencil = stencil;
381 - glTexture_AddRef(stencil);
 381+ if (stencil) glTexture_AddRef(stencil);
382382 }
383383 void glTexture_CreateDummyColor(glTexture *This, BOOL backend)
384384 {