DXGL r740 - Code Review

Jump to navigation Jump to search
Repository:DXGL
Revision:r739‎ | r740 | r741 >
Date:06:13, 3 September 2017
Author:admin
Status:new
Tags:
Comment:
Add Destination Color Key Override Test.
Modified paths:
  • /ddraw/glDirectDrawSurface.cpp (modified) (history)
  • /dxgltest/Tests2D.cpp (modified) (history)
  • /dxgltest/dxgltest.cpp (modified) (history)

Diff [purge]

Index: ddraw/glDirectDrawSurface.cpp
@@ -696,6 +696,16 @@
697697 cmd.patternlevel = pattern->miplevel;
698698 }
699699 }
 700+ if (dwFlags & DDBLT_KEYSRCOVERRIDE)
 701+ {
 702+ if(!lpDDBltFx) TRACE_RET(HRESULT, 23, DDERR_INVALIDPARAMS);
 703+ if(dwFlags) TRACE_RET(HRESULT, 23, DDERR_INVALIDPARAMS);
 704+ }
 705+ if (dwFlags & DDBLT_KEYDESTOVERRIDE)
 706+ {
 707+ if (!lpDDBltFx) TRACE_RET(HRESULT, 23, DDERR_INVALIDPARAMS);
 708+ if (dwFlags) TRACE_RET(HRESULT, 23, DDERR_INVALIDPARAMS);
 709+ }
700710 if (dwFlags & DDBLT_KEYSRC)
701711 {
702712 if (!lpDDSrcSurface) TRACE_RET(HRESULT, 23, DDERR_INVALIDPARAMS);
@@ -704,6 +714,7 @@
705715 if (((glDirectDrawSurface7*)lpDDSrcSurface)->ddsd.ddckCKSrcBlt.dwColorSpaceHighValue !=
706716 ((glDirectDrawSurface7*)lpDDSrcSurface)->ddsd.ddckCKSrcBlt.dwColorSpaceLowValue)
707717 cmd.flags |= 0x20000000;
 718+ if(dwFlags & DDBLT_KEYSRCOVERRIDE) cmd.flags |= 0x20000000;
708719 }
709720 if (dwFlags & DDBLT_KEYDEST)
710721 {
@@ -710,6 +721,7 @@
711722 if (!(this->ddsd.dwFlags & DDSD_CKDESTBLT)) TRACE_RET(HRESULT, 23, DDERR_INVALIDPARAMS);
712723 if (this->ddsd.ddckCKDestBlt.dwColorSpaceHighValue != this->ddsd.ddckCKDestBlt.dwColorSpaceLowValue)
713724 cmd.flags |= 0x40000000;
 725+ if(dwFlags & DDBLT_KEYDESTOVERRIDE) cmd.flags |= 0x40000000;
714726 }
715727 glDirectDrawSurface7 *src = (glDirectDrawSurface7 *)lpDDSrcSurface;
716728 if (clipper)
Index: dxgltest/Tests2D.cpp
@@ -127,7 +127,7 @@
128128 RunTestMouse2D(testnum,Msg,wParam,lParam);
129129 if(!fullscreen)
130130 {
131 - if ((testnum != 4) && (testnum != 10))
 131+ if ((testnum != 4) && (testnum != 10) && (testnum != 11))
132132 {
133133 p.x = 0;
134134 p.y = 0;
@@ -698,6 +698,7 @@
699699 counter = 0;
700700 break;
701701 case 10:
 702+ case 11:
702703 ddsrender->GetSurfaceDesc(&ddsd);
703704 sprites[0].ddsd.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH;
704705 sprites[0].ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
@@ -802,6 +803,7 @@
803804 }
804805 break;
805806 case 10: // Source Key Override test
 807+ case 11: // Destination Key Override Test
806808 if (backbuffers) ddsrender->GetAttachedSurface(&ddscaps, &temp1);
807809 else temp1 = ddsrender;
808810
@@ -810,7 +812,8 @@
811813 switch (bpp)
812814 {
813815 case 8:
814 - bltfx.ddckSrcColorkey.dwColorSpaceHighValue = bltfx.ddckSrcColorkey.dwColorSpaceLowValue = counter;
 816+ bltfx.ddckSrcColorkey.dwColorSpaceHighValue = bltfx.ddckSrcColorkey.dwColorSpaceLowValue =
 817+ bltfx.ddckDestColorkey.dwColorSpaceHighValue = bltfx.ddckDestColorkey.dwColorSpaceLowValue = counter;
815818 counter++;
816819 if (counter > 255) counter = 0;
817820 r1.left = r1.top = 0;
@@ -821,31 +824,38 @@
822825 {
823826 case 0:
824827 bltfx.ddckSrcColorkey.dwColorSpaceHighValue = bltfx.ddckSrcColorkey.dwColorSpaceLowValue =
 828+ bltfx.ddckDestColorkey.dwColorSpaceHighValue = bltfx.ddckDestColorkey.dwColorSpaceLowValue =
825829 (counter & 31) << 10;
826830 break;
827831 case 1:
828832 bltfx.ddckSrcColorkey.dwColorSpaceHighValue = bltfx.ddckSrcColorkey.dwColorSpaceLowValue =
 833+ bltfx.ddckDestColorkey.dwColorSpaceHighValue = bltfx.ddckDestColorkey.dwColorSpaceLowValue =
829834 (counter & 31) << 5;
830835 break;
831836 case 2:
832837 bltfx.ddckSrcColorkey.dwColorSpaceHighValue = bltfx.ddckSrcColorkey.dwColorSpaceLowValue =
 838+ bltfx.ddckDestColorkey.dwColorSpaceHighValue = bltfx.ddckDestColorkey.dwColorSpaceLowValue =
833839 (counter & 31);
834840 break;
835841 case 3:
836842 bltfx.ddckSrcColorkey.dwColorSpaceHighValue = bltfx.ddckSrcColorkey.dwColorSpaceLowValue =
 843+ bltfx.ddckDestColorkey.dwColorSpaceHighValue = bltfx.ddckDestColorkey.dwColorSpaceLowValue =
837844 (counter & 31) + ((counter & 31) << 5);
838845 break;
839846 case 4:
840847 bltfx.ddckSrcColorkey.dwColorSpaceHighValue = bltfx.ddckSrcColorkey.dwColorSpaceLowValue =
 848+ bltfx.ddckDestColorkey.dwColorSpaceHighValue = bltfx.ddckDestColorkey.dwColorSpaceLowValue =
841849 (counter & 31) + ((counter & 31) << 10);
842850 break;
843851 case 5:
844852 bltfx.ddckSrcColorkey.dwColorSpaceHighValue = bltfx.ddckSrcColorkey.dwColorSpaceLowValue =
 853+ bltfx.ddckDestColorkey.dwColorSpaceHighValue = bltfx.ddckDestColorkey.dwColorSpaceLowValue =
845854 ((counter & 31) << 5) + ((counter & 31) << 10);
846855 break;
847856 case 6:
848857 default:
849858 bltfx.ddckSrcColorkey.dwColorSpaceHighValue = bltfx.ddckSrcColorkey.dwColorSpaceLowValue =
 859+ bltfx.ddckDestColorkey.dwColorSpaceHighValue = bltfx.ddckDestColorkey.dwColorSpaceLowValue =
850860 (counter & 31) + ((counter & 31) << 5) + ((counter & 31) << 10);
851861 break;
852862 }
@@ -860,31 +870,38 @@
861871 {
862872 case 0:
863873 bltfx.ddckSrcColorkey.dwColorSpaceHighValue = bltfx.ddckSrcColorkey.dwColorSpaceLowValue =
 874+ bltfx.ddckDestColorkey.dwColorSpaceHighValue = bltfx.ddckDestColorkey.dwColorSpaceLowValue =
864875 ((counter & 63) >> 1) << 11;
865876 break;
866877 case 1:
867878 bltfx.ddckSrcColorkey.dwColorSpaceHighValue = bltfx.ddckSrcColorkey.dwColorSpaceLowValue =
 879+ bltfx.ddckDestColorkey.dwColorSpaceHighValue = bltfx.ddckDestColorkey.dwColorSpaceLowValue =
868880 (counter & 63) << 5;
869881 break;
870882 case 2:
871883 bltfx.ddckSrcColorkey.dwColorSpaceHighValue = bltfx.ddckSrcColorkey.dwColorSpaceLowValue =
 884+ bltfx.ddckDestColorkey.dwColorSpaceHighValue = bltfx.ddckDestColorkey.dwColorSpaceLowValue =
872885 (counter & 63) >> 1;
873886 break;
874887 case 3:
875888 bltfx.ddckSrcColorkey.dwColorSpaceHighValue = bltfx.ddckSrcColorkey.dwColorSpaceLowValue =
 889+ bltfx.ddckDestColorkey.dwColorSpaceHighValue = bltfx.ddckDestColorkey.dwColorSpaceLowValue =
876890 ((counter & 63) >> 1) + ((counter & 63) << 5);
877891 break;
878892 case 4:
879893 bltfx.ddckSrcColorkey.dwColorSpaceHighValue = bltfx.ddckSrcColorkey.dwColorSpaceLowValue =
 894+ bltfx.ddckDestColorkey.dwColorSpaceHighValue = bltfx.ddckDestColorkey.dwColorSpaceLowValue =
880895 ((counter & 63) >> 1) + (((counter & 63) >> 1) << 11);
881896 break;
882897 case 5:
883898 bltfx.ddckSrcColorkey.dwColorSpaceHighValue = bltfx.ddckSrcColorkey.dwColorSpaceLowValue =
 899+ bltfx.ddckDestColorkey.dwColorSpaceHighValue = bltfx.ddckDestColorkey.dwColorSpaceLowValue =
884900 ((counter & 63) << 5) + (((counter & 63) >> 1) << 11);
885901 break;
886902 case 6:
887903 default:
888904 bltfx.ddckSrcColorkey.dwColorSpaceHighValue = bltfx.ddckSrcColorkey.dwColorSpaceLowValue =
 905+ bltfx.ddckDestColorkey.dwColorSpaceHighValue = bltfx.ddckDestColorkey.dwColorSpaceLowValue =
889906 ((counter & 63) >> 1) + ((counter & 63) << 5) + (((counter & 63) >> 1) << 11);
890907 break;
891908 }
@@ -901,31 +918,38 @@
902919 {
903920 case 0:
904921 bltfx.ddckSrcColorkey.dwColorSpaceHighValue = bltfx.ddckSrcColorkey.dwColorSpaceLowValue =
 922+ bltfx.ddckDestColorkey.dwColorSpaceHighValue = bltfx.ddckDestColorkey.dwColorSpaceLowValue =
905923 (counter & 255) << 16;
906924 break;
907925 case 1:
908926 bltfx.ddckSrcColorkey.dwColorSpaceHighValue = bltfx.ddckSrcColorkey.dwColorSpaceLowValue =
 927+ bltfx.ddckDestColorkey.dwColorSpaceHighValue = bltfx.ddckDestColorkey.dwColorSpaceLowValue =
909928 (counter & 255) << 8;
910929 break;
911930 case 2:
912931 bltfx.ddckSrcColorkey.dwColorSpaceHighValue = bltfx.ddckSrcColorkey.dwColorSpaceLowValue =
 932+ bltfx.ddckDestColorkey.dwColorSpaceHighValue = bltfx.ddckDestColorkey.dwColorSpaceLowValue =
913933 counter & 255;
914934 break;
915935 case 3:
916936 bltfx.ddckSrcColorkey.dwColorSpaceHighValue = bltfx.ddckSrcColorkey.dwColorSpaceLowValue =
 937+ bltfx.ddckDestColorkey.dwColorSpaceHighValue = bltfx.ddckDestColorkey.dwColorSpaceLowValue =
917938 (counter & 255) + ((counter & 255) << 8);
918939 break;
919940 case 4:
920941 bltfx.ddckSrcColorkey.dwColorSpaceHighValue = bltfx.ddckSrcColorkey.dwColorSpaceLowValue =
 942+ bltfx.ddckDestColorkey.dwColorSpaceHighValue = bltfx.ddckDestColorkey.dwColorSpaceLowValue =
921943 (counter & 255) + ((counter & 255) << 16);
922944 break;
923945 case 5:
924946 bltfx.ddckSrcColorkey.dwColorSpaceHighValue = bltfx.ddckSrcColorkey.dwColorSpaceLowValue =
 947+ bltfx.ddckDestColorkey.dwColorSpaceHighValue = bltfx.ddckDestColorkey.dwColorSpaceLowValue =
925948 ((counter & 255) << 8) + ((counter & 255) << 16);
926949 break;
927950 case 6:
928951 default:
929952 bltfx.ddckSrcColorkey.dwColorSpaceHighValue = bltfx.ddckSrcColorkey.dwColorSpaceLowValue =
 953+ bltfx.ddckDestColorkey.dwColorSpaceHighValue = bltfx.ddckDestColorkey.dwColorSpaceLowValue =
930954 (counter & 255) + ((counter & 255) << 8) + ((counter & 255) << 16);
931955 break;
932956 }
@@ -936,7 +960,10 @@
937961 r1.bottom = 7;
938962 break;
939963 }
940 - sprites[0].surface->Blt(NULL, sprites[2].surface, NULL, DDBLT_WAIT|DDBLT_KEYSRCOVERRIDE, &bltfx);
 964+ if (test == 10)
 965+ sprites[0].surface->Blt(NULL, sprites[2].surface, NULL, DDBLT_WAIT | DDBLT_KEYSRCOVERRIDE, &bltfx);
 966+ else
 967+ sprites[0].surface->Blt(NULL, sprites[2].surface, NULL, DDBLT_WAIT | DDBLT_KEYDESTOVERRIDE, &bltfx);
941968 temp1->GetDC(&hDCdest);
942969 sprites[0].surface->GetDC(&hDCsrc);
943970 if (ddver > 3) ddsd.dwSize = sizeof(DDSURFACEDESC2);
@@ -947,7 +974,10 @@
948975 sprites[0].surface->ReleaseDC(hDCsrc);
949976 SetBkColor(hDCdest, RGB(0, 0, 255));
950977 SetTextColor(hDCdest, RGB(255, 255, 255));
951 - _tcscpy(message, _T("Source Color Key Override Test"));
 978+ if(test == 10)
 979+ _tcscpy(message, _T("Source Color Key Override Test"));
 980+ else
 981+ _tcscpy(message, _T("Destination Color Key Override Test"));
952982 TextOut(hDCdest, 0, 0, message, _tcslen(message));
953983 _stprintf(message, _T("Color: 0x%08X "), bltfx.ddckSrcColorkey.dwColorSpaceHighValue);
954984 TextOut(hDCdest, 0, 16, message, _tcslen(message));
Index: dxgltest/dxgltest.cpp
@@ -231,7 +231,8 @@
232232 {1, 7, 1, 1, true, 1.0, false, false, _T("Raster Operation Blt() test")},
233233 {1, 7, 0, 0, false, 0.0, false, false, _T("Mirrored and Rotated Blt() test")},
234234 {1, 7, 0, 1, false, 0.0, false, false, _T("Large batch color fill Blt() operations")},
235 - {1, 7, 0, 1, true, 60.0, false, false, _T("Source Color Key Override test")}
 235+ {1, 7, 0, 1, true, 60.0, false, false, _T("Source Color Key Override test")},
 236+ {1, 7, 0, 1, true, 60.0, false, false, _T("Destination Color Key Override test")}
236237 };
237238 const int END_2D = __LINE__ - 4;
238239 const int numtests2d = END_2D - START_2D;