mirror of
https://github.com/reactos/reactos.git
synced 2026-05-31 08:17:09 +08:00
[GDITOOLS][GDI32_APITEST] Move resources to gditools lib
This allows to share them in win32knt_apitest.
This commit is contained in:
@@ -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}")
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
#include "precomp.h"
|
||||
|
||||
#include "init.h"
|
||||
#include <gditools.h>
|
||||
|
||||
/* 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
|
||||
}
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
#include "precomp.h"
|
||||
|
||||
#include "init.h"
|
||||
#include "gditools.h"
|
||||
|
||||
#include <pseh/pseh2.h>
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
#include "precomp.h"
|
||||
|
||||
#include "init.h"
|
||||
#include <gditools.h>
|
||||
|
||||
#if 0
|
||||
BOOL
|
||||
@@ -135,11 +135,8 @@ void Test_FrameRgn()
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
START_TEST(FrameRgn)
|
||||
{
|
||||
InitStuff();
|
||||
GdiToolsInit();
|
||||
Test_FrameRgn();
|
||||
}
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
#include "precomp.h"
|
||||
|
||||
#include "init.h"
|
||||
#include <gditools.h>
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
#include "precomp.h"
|
||||
|
||||
#include "init.h"
|
||||
#include <gditools.h>
|
||||
|
||||
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();
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
#include "precomp.h"
|
||||
|
||||
#include "init.h"
|
||||
#include <gditools.h>
|
||||
|
||||
void Test_PaintRgn()
|
||||
{
|
||||
@@ -55,7 +55,6 @@ void Test_PaintRgn()
|
||||
|
||||
START_TEST(PaintRgn)
|
||||
{
|
||||
InitStuff();
|
||||
GdiToolsInit();
|
||||
Test_PaintRgn();
|
||||
}
|
||||
|
||||
|
||||
@@ -7,11 +7,11 @@
|
||||
|
||||
#include "precomp.h"
|
||||
|
||||
#include "init.h"
|
||||
#include <gditools.h>
|
||||
|
||||
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);
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
#include "precomp.h"
|
||||
|
||||
#include "init.h"
|
||||
#include <gditools.h>
|
||||
|
||||
static void
|
||||
Test_SetDIBitsToDevice_Params()
|
||||
@@ -687,10 +687,8 @@ Test_SetDIBitsToDevice()
|
||||
|
||||
START_TEST(SetDIBitsToDevice)
|
||||
{
|
||||
InitStuff();
|
||||
GdiToolsInit();
|
||||
|
||||
Test_SetDIBitsToDevice_Params();
|
||||
Test_SetDIBitsToDevice();
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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);
|
||||
|
||||
@@ -16,6 +16,30 @@
|
||||
#include <ntgdi.h>
|
||||
#include <ntgdihdl.h>
|
||||
|
||||
#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;
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user