diff --git a/modules/rostests/apitests/gdi32/CMakeLists.txt b/modules/rostests/apitests/gdi32/CMakeLists.txt index 486a112c319..33d431ebc65 100644 --- a/modules/rostests/apitests/gdi32/CMakeLists.txt +++ b/modules/rostests/apitests/gdi32/CMakeLists.txt @@ -1,5 +1,5 @@ -include_directories(${REACTOS_SOURCE_DIR}/win32ss) +include_directories(${REACTOS_SOURCE_DIR}/win32ss ../gditools) list(APPEND SOURCE AddFontMemResourceEx.c @@ -76,8 +76,7 @@ list(APPEND SOURCE SetWindowExtEx.c SetWorldTransform.c StretchBlt.c - TextTransform.c - init.c) + TextTransform.c) list(APPEND PCH_SKIP_SOURCE testlist.c) @@ -87,7 +86,7 @@ add_executable(gdi32_apitest ${PCH_SKIP_SOURCE} resource.rc) -target_link_libraries(gdi32_apitest ${PSEH_LIB} win32ksys) +target_link_libraries(gdi32_apitest ${PSEH_LIB} gditools win32ksys) set_module_type(gdi32_apitest win32cui) add_importlibs(gdi32_apitest gdi32 user32 msvcrt kernel32 ntdll) add_pch(gdi32_apitest precomp.h "${PCH_SKIP_SOURCE}") diff --git a/modules/rostests/apitests/gdi32/CreateDIBPatternBrush.c b/modules/rostests/apitests/gdi32/CreateDIBPatternBrush.c index bc58c3a3e7a..490a5789a33 100644 --- a/modules/rostests/apitests/gdi32/CreateDIBPatternBrush.c +++ b/modules/rostests/apitests/gdi32/CreateDIBPatternBrush.c @@ -7,7 +7,7 @@ #include "precomp.h" -#include "init.h" +#include /* New color use parameter. See https://www.betaarchive.com/wiki/index.php?title=Microsoft_KB_Archive/108497 */ #define DIB_PAL_INDICES 2 @@ -180,10 +180,9 @@ void Test_CreateDIBPatternBrushPt_RLE8() START_TEST(CreateDIBPatternBrush) { - InitStuff(); + GdiToolsInit(); Test_CreateDIBPatternBrush(); Test_CreateDIBPatternBrushPt(); //Test_CreateDIBPatternBrushPt_RLE8(); broken } - diff --git a/modules/rostests/apitests/gdi32/CreateDIBitmap.c b/modules/rostests/apitests/gdi32/CreateDIBitmap.c index cc11cab28c5..62ac6265f62 100644 --- a/modules/rostests/apitests/gdi32/CreateDIBitmap.c +++ b/modules/rostests/apitests/gdi32/CreateDIBitmap.c @@ -7,7 +7,7 @@ #include "precomp.h" -#include "init.h" +#include "gditools.h" #include @@ -534,11 +534,10 @@ Test_CreateDIBitmap_CBM_CREATDIB(void) START_TEST(CreateDIBitmap) { - InitStuff(); + GdiToolsInit(); Test_CreateDIBitmap_Params(); Test_CreateDIBitmap1(); Test_CreateDIBitmap_DIB_PAL_COLORS(); Test_CreateDIBitmap_RLE8(); Test_CreateDIBitmap_CBM_CREATDIB(); } - diff --git a/modules/rostests/apitests/gdi32/FrameRgn.c b/modules/rostests/apitests/gdi32/FrameRgn.c index 547d4947e62..3d40f68d609 100644 --- a/modules/rostests/apitests/gdi32/FrameRgn.c +++ b/modules/rostests/apitests/gdi32/FrameRgn.c @@ -7,7 +7,7 @@ #include "precomp.h" -#include "init.h" +#include #if 0 BOOL @@ -135,11 +135,8 @@ void Test_FrameRgn() } - - START_TEST(FrameRgn) { - InitStuff(); + GdiToolsInit(); Test_FrameRgn(); } - diff --git a/modules/rostests/apitests/gdi32/GetDIBits.c b/modules/rostests/apitests/gdi32/GetDIBits.c index f06b11fe2d7..439cb4a19d3 100644 --- a/modules/rostests/apitests/gdi32/GetDIBits.c +++ b/modules/rostests/apitests/gdi32/GetDIBits.c @@ -7,7 +7,7 @@ #include "precomp.h" -#include "init.h" +#include void Test_GetDIBits_xBpp( @@ -473,7 +473,7 @@ void Test_GetDIBits_BI_BITFIELDS() START_TEST(GetDIBits) { //getchar(); - InitStuff(); + GdiToolsInit(); Test_GetDIBits_xBpp(1); Test_GetDIBits_xBpp(4); Test_GetDIBits_xBpp(8); @@ -482,4 +482,3 @@ START_TEST(GetDIBits) Test_GetDIBits_xBpp(32); Test_GetDIBits(); } - diff --git a/modules/rostests/apitests/gdi32/MaskBlt.c b/modules/rostests/apitests/gdi32/MaskBlt.c index 9bc8048c03e..fb75b125b24 100644 --- a/modules/rostests/apitests/gdi32/MaskBlt.c +++ b/modules/rostests/apitests/gdi32/MaskBlt.c @@ -7,7 +7,7 @@ #include "precomp.h" -#include "init.h" +#include void Test_MaskBlt_1bpp() { @@ -293,7 +293,7 @@ void Test_MaskBlt_Brush() START_TEST(MaskBlt) { - InitStuff(); + GdiToolsInit(); Test_MaskBlt_1bpp(); Test_MaskBlt_16bpp(); Test_MaskBlt_32bpp(); diff --git a/modules/rostests/apitests/gdi32/PaintRgn.c b/modules/rostests/apitests/gdi32/PaintRgn.c index 083dcfd457b..4c89ddf0646 100644 --- a/modules/rostests/apitests/gdi32/PaintRgn.c +++ b/modules/rostests/apitests/gdi32/PaintRgn.c @@ -7,7 +7,7 @@ #include "precomp.h" -#include "init.h" +#include void Test_PaintRgn() { @@ -55,7 +55,6 @@ void Test_PaintRgn() START_TEST(PaintRgn) { - InitStuff(); + GdiToolsInit(); Test_PaintRgn(); } - diff --git a/modules/rostests/apitests/gdi32/RealizePalette.c b/modules/rostests/apitests/gdi32/RealizePalette.c index d97dc5430f9..7b3eab5cd20 100644 --- a/modules/rostests/apitests/gdi32/RealizePalette.c +++ b/modules/rostests/apitests/gdi32/RealizePalette.c @@ -7,11 +7,11 @@ #include "precomp.h" -#include "init.h" +#include START_TEST(RealizePalette) { - InitStuff(); + GdiToolsInit(); ok_int(RealizePalette(NULL), GDI_ERROR); ok_int(RealizePalette((HDC)UlongToHandle(0xdeadc0de)), GDI_ERROR); ok_int(RealizePalette((HDC)UlongToHandle(0x00010001)), 0); diff --git a/modules/rostests/apitests/gdi32/SetDIBitsToDevice.c b/modules/rostests/apitests/gdi32/SetDIBitsToDevice.c index 1df511d51d1..23c0e230196 100644 --- a/modules/rostests/apitests/gdi32/SetDIBitsToDevice.c +++ b/modules/rostests/apitests/gdi32/SetDIBitsToDevice.c @@ -7,7 +7,7 @@ #include "precomp.h" -#include "init.h" +#include static void Test_SetDIBitsToDevice_Params() @@ -687,10 +687,8 @@ Test_SetDIBitsToDevice() START_TEST(SetDIBitsToDevice) { - InitStuff(); + GdiToolsInit(); Test_SetDIBitsToDevice_Params(); Test_SetDIBitsToDevice(); - - } diff --git a/modules/rostests/apitests/gdi32/init.c b/modules/rostests/apitests/gdi32/init.c deleted file mode 100644 index dd4b83c0572..00000000000 --- a/modules/rostests/apitests/gdi32/init.c +++ /dev/null @@ -1,120 +0,0 @@ - -#include "precomp.h" - -#include "init.h" - -HBITMAP ghbmp1, ghbmp4, ghbmp8, ghbmp16, ghbmp24, ghbmp32; -HBITMAP ghbmpDIB1, ghbmpDIB4, ghbmpDIB8, ghbmpDIB16, ghbmpDIB24, ghbmpDIB32; -HDC ghdcDIB1, ghdcDIB4, ghdcDIB8, ghdcDIB16, ghdcDIB24, ghdcDIB32; -PVOID gpvDIB1, gpvDIB4, gpvDIB8, gpvDIB16, gpvDIB24, gpvDIB32; -ULONG (*gpDIB32)[8][8]; -HPALETTE ghpal; - -MYPAL gpal = -{ - 0x300, 8, - { - { 0x10, 0x20, 0x30, PC_NOCOLLAPSE }, - { 0x20, 0x30, 0x40, PC_NOCOLLAPSE }, - { 0x30, 0x40, 0x50, PC_NOCOLLAPSE }, - { 0x40, 0x50, 0x60, PC_NOCOLLAPSE }, - { 0x50, 0x60, 0x70, PC_NOCOLLAPSE }, - { 0x60, 0x70, 0x80, PC_NOCOLLAPSE }, - { 0x70, 0x80, 0x90, PC_NOCOLLAPSE }, - { 0x80, 0x90, 0xA0, PC_NOCOLLAPSE }, - } -}; - -BOOL -InitPerBitDepth( - _In_ ULONG cBitsPerPixel, - _In_ ULONG cx, - _In_ ULONG cy, - _Out_ HBITMAP *phbmp, - _Out_ HDC *phdcDIB, - _Out_ HBITMAP *phbmpDIB, - _Out_ PVOID *ppvBits) -{ - struct - { - BITMAPINFOHEADER bmiHeader; - ULONG bmiColors[256]; - } bmiBuffer; - LPBITMAPINFO pbmi = (LPBITMAPINFO)&bmiBuffer; - - /* Create a bitmap */ - *phbmp = CreateBitmap(cx, cy, 1, cBitsPerPixel, NULL); - if (*phbmp == NULL) - { - printf("CreateBitmap failed %lu\n", cBitsPerPixel); - return FALSE; - } - - /* Setup bitmap info */ - memset(&bmiBuffer, 0, sizeof(bmiBuffer)); - pbmi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER); - pbmi->bmiHeader.biWidth = cx; - pbmi->bmiHeader.biHeight = -(LONG)cy; - pbmi->bmiHeader.biPlanes = 1; - pbmi->bmiHeader.biBitCount = cBitsPerPixel; - pbmi->bmiHeader.biCompression = BI_RGB; - pbmi->bmiHeader.biSizeImage = 0; - pbmi->bmiHeader.biXPelsPerMeter = 0; - pbmi->bmiHeader.biYPelsPerMeter = 0; - pbmi->bmiHeader.biClrUsed = 0; - pbmi->bmiHeader.biClrImportant = 0; - - if (cBitsPerPixel == 1) - { - bmiBuffer.bmiColors[0] = 0; - bmiBuffer.bmiColors[1] = 0xFFFFFF; - pbmi->bmiHeader.biClrUsed = 2; - } - - /* Create a compatible DC for the DIB */ - *phdcDIB = CreateCompatibleDC(0); - if (*phdcDIB == NULL) - { - printf("CreateCompatibleDC failed %lu\n", cBitsPerPixel); - return FALSE; - } - - /* Create the DIB section with the same values */ - *phbmpDIB = CreateDIBSection(*phdcDIB, pbmi, DIB_RGB_COLORS, ppvBits, 0, 0 ); - if (*phbmpDIB == NULL) - { - printf("CreateDIBSection failed. %lu\n", cBitsPerPixel); - return FALSE; - } - - SelectObject(*phdcDIB, *phbmpDIB); - - return TRUE; -} - -BOOL InitStuff(void) -{ - - /* Initialize a logical palette */ - ghpal = CreatePalette((LOGPALETTE*)&gpal); - if (!ghpal) - { - printf("failed to create a palette\n"); - return FALSE; - } - - if (!InitPerBitDepth(1, 9, 9, &ghbmp1, &ghdcDIB1, &ghbmpDIB1, &gpvDIB1) || - !InitPerBitDepth(4, 5, 5, &ghbmp4, &ghdcDIB4, &ghbmpDIB4, &gpvDIB4) || - !InitPerBitDepth(8, 5, 5, &ghbmp8, &ghdcDIB8, &ghbmpDIB8, &gpvDIB8) || - !InitPerBitDepth(16, 8, 8, &ghbmp16, &ghdcDIB16, &ghbmpDIB16, &gpvDIB16) || - !InitPerBitDepth(24, 8, 8, &ghbmp24, &ghdcDIB24, &ghbmpDIB24, &gpvDIB24) || - !InitPerBitDepth(32, 8, 8, &ghbmp32, &ghdcDIB32, &ghbmpDIB32, &gpvDIB32)) - { - printf("failed to create objects\n"); - return FALSE; - } - - gpDIB32 = gpvDIB32; - - return TRUE; -} diff --git a/modules/rostests/apitests/gdi32/init.h b/modules/rostests/apitests/gdi32/init.h deleted file mode 100644 index a57e860a05f..00000000000 --- a/modules/rostests/apitests/gdi32/init.h +++ /dev/null @@ -1,24 +0,0 @@ -#pragma once - -extern HBITMAP ghbmp1, ghbmp4, ghbmp8, ghbmp16, ghbmp24, ghbmp32; -extern HBITMAP ghbmpDIB1, ghbmpDIB4, ghbmpDIB8, ghbmpDIB16, ghbmpDIB24, ghbmpDIB32; -extern HDC ghdcDIB1, ghdcDIB4, ghdcDIB8, ghdcDIB16, ghdcDIB24, ghdcDIB32; -extern PVOID gpvDIB1, gpvDIB4, gpvDIB8, gpvDIB16, gpvDIB24, gpvDIB32; - -extern HBITMAP ghbmpDIB32; -//extern PULONG pulDIB32Bits; -extern PULONG pulDIB4Bits; -extern HPALETTE ghpal; -typedef struct -{ - WORD palVersion; - WORD palNumEntries; - PALETTEENTRY logpalettedata[8]; -} MYPAL; - -extern ULONG (*gpDIB32)[8][8]; - -extern MYPAL gpal; - -BOOL InitStuff(void); - diff --git a/modules/rostests/apitests/gditools/gditools.c b/modules/rostests/apitests/gditools/gditools.c index 8fb953faab9..cd73c52b879 100644 --- a/modules/rostests/apitests/gditools/gditools.c +++ b/modules/rostests/apitests/gditools/gditools.c @@ -16,6 +16,30 @@ #include #include +#include "gditools.h" + +HBITMAP ghbmp1, ghbmp4, ghbmp8, ghbmp16, ghbmp24, ghbmp32; +HBITMAP ghbmpDIB1, ghbmpDIB4, ghbmpDIB8, ghbmpDIB16, ghbmpDIB24, ghbmpDIB32; +HDC ghdcDIB1, ghdcDIB4, ghdcDIB8, ghdcDIB16, ghdcDIB24, ghdcDIB32; +PVOID gpvDIB1, gpvDIB4, gpvDIB8, gpvDIB16, gpvDIB24, gpvDIB32; +ULONG (*gpDIB32)[8][8]; +HPALETTE ghpal; + +MYPAL gpal = +{ + 0x300, 8, + { + { 0x10, 0x20, 0x30, PC_NOCOLLAPSE }, + { 0x20, 0x30, 0x40, PC_NOCOLLAPSE }, + { 0x30, 0x40, 0x50, PC_NOCOLLAPSE }, + { 0x40, 0x50, 0x60, PC_NOCOLLAPSE }, + { 0x50, 0x60, 0x70, PC_NOCOLLAPSE }, + { 0x60, 0x70, 0x80, PC_NOCOLLAPSE }, + { 0x70, 0x80, 0x90, PC_NOCOLLAPSE }, + { 0x80, 0x90, 0xA0, PC_NOCOLLAPSE }, + } +}; + PENTRY GdiQueryTable( VOID) @@ -80,3 +104,96 @@ GdiGetHandleUserData( return pentry->pUser; } +BOOL +InitPerBitDepth( + _In_ ULONG cBitsPerPixel, + _In_ ULONG cx, + _In_ ULONG cy, + _Out_ HBITMAP *phbmp, + _Out_ HDC *phdcDIB, + _Out_ HBITMAP *phbmpDIB, + _Out_ PVOID *ppvBits) +{ + struct + { + BITMAPINFOHEADER bmiHeader; + ULONG bmiColors[256]; + } bmiBuffer; + LPBITMAPINFO pbmi = (LPBITMAPINFO)&bmiBuffer; + + /* Create a bitmap */ + *phbmp = CreateBitmap(cx, cy, 1, cBitsPerPixel, NULL); + if (*phbmp == NULL) + { + printf("CreateBitmap failed %lu\n", cBitsPerPixel); + return FALSE; + } + + /* Setup bitmap info */ + memset(&bmiBuffer, 0, sizeof(bmiBuffer)); + pbmi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER); + pbmi->bmiHeader.biWidth = cx; + pbmi->bmiHeader.biHeight = -(LONG)cy; + pbmi->bmiHeader.biPlanes = 1; + pbmi->bmiHeader.biBitCount = cBitsPerPixel; + pbmi->bmiHeader.biCompression = BI_RGB; + pbmi->bmiHeader.biSizeImage = 0; + pbmi->bmiHeader.biXPelsPerMeter = 0; + pbmi->bmiHeader.biYPelsPerMeter = 0; + pbmi->bmiHeader.biClrUsed = 0; + pbmi->bmiHeader.biClrImportant = 0; + + if (cBitsPerPixel == 1) + { + bmiBuffer.bmiColors[0] = 0; + bmiBuffer.bmiColors[1] = 0xFFFFFF; + pbmi->bmiHeader.biClrUsed = 2; + } + + /* Create a compatible DC for the DIB */ + *phdcDIB = CreateCompatibleDC(0); + if (*phdcDIB == NULL) + { + printf("CreateCompatibleDC failed %lu\n", cBitsPerPixel); + return FALSE; + } + + /* Create the DIB section with the same values */ + *phbmpDIB = CreateDIBSection(*phdcDIB, pbmi, DIB_RGB_COLORS, ppvBits, 0, 0 ); + if (*phbmpDIB == NULL) + { + printf("CreateDIBSection failed. %lu\n", cBitsPerPixel); + return FALSE; + } + + SelectObject(*phdcDIB, *phbmpDIB); + + return TRUE; +} + +BOOL GdiToolsInit(void) +{ + + /* Initialize a logical palette */ + ghpal = CreatePalette((LOGPALETTE*)&gpal); + if (!ghpal) + { + printf("failed to create a palette\n"); + return FALSE; + } + + if (!InitPerBitDepth(1, 9, 9, &ghbmp1, &ghdcDIB1, &ghbmpDIB1, &gpvDIB1) || + !InitPerBitDepth(4, 5, 5, &ghbmp4, &ghdcDIB4, &ghbmpDIB4, &gpvDIB4) || + !InitPerBitDepth(8, 5, 5, &ghbmp8, &ghdcDIB8, &ghbmpDIB8, &gpvDIB8) || + !InitPerBitDepth(16, 8, 8, &ghbmp16, &ghdcDIB16, &ghbmpDIB16, &gpvDIB16) || + !InitPerBitDepth(24, 8, 8, &ghbmp24, &ghdcDIB24, &ghbmpDIB24, &gpvDIB24) || + !InitPerBitDepth(32, 8, 8, &ghbmp32, &ghdcDIB32, &ghbmpDIB32, &gpvDIB32)) + { + printf("failed to create objects\n"); + return FALSE; + } + + gpDIB32 = gpvDIB32; + + return TRUE; +} diff --git a/modules/rostests/apitests/gditools/gditools.h b/modules/rostests/apitests/gditools/gditools.h index 7d7dffd7e8e..3082eb1a80d 100644 --- a/modules/rostests/apitests/gditools/gditools.h +++ b/modules/rostests/apitests/gditools/gditools.h @@ -1,6 +1,28 @@ #pragma once +extern HBITMAP ghbmp1, ghbmp4, ghbmp8, ghbmp16, ghbmp24, ghbmp32; +extern HBITMAP ghbmpDIB1, ghbmpDIB4, ghbmpDIB8, ghbmpDIB16, ghbmpDIB24, ghbmpDIB32; +extern HDC ghdcDIB1, ghdcDIB4, ghdcDIB8, ghdcDIB16, ghdcDIB24, ghdcDIB32; +extern PVOID gpvDIB1, gpvDIB4, gpvDIB8, gpvDIB16, gpvDIB24, gpvDIB32; + +extern HBITMAP ghbmpDIB32; +//extern PULONG pulDIB32Bits; +extern PULONG pulDIB4Bits; +extern HPALETTE ghpal; +typedef struct +{ + WORD palVersion; + WORD palNumEntries; + PALETTEENTRY logpalettedata[8]; +} MYPAL; + +extern ULONG (*gpDIB32)[8][8]; + +extern MYPAL gpal; + +BOOL GdiToolsInit(void); + PENTRY GdiQueryTable( VOID);