5668{
5669 D3DKMT_DESTROYDCFROMMEMORY destroy_desc;
5670 D3DKMT_CREATEDCFROMMEMORY create_desc;
5672 unsigned int i,
x,
y,
z;
5683
5684 static const struct
5685 {
5688 unsigned int bit_count;
5689 DWORD mask_r, mask_g, mask_b;
5691 }
5693 {
5694 {
"R8G8B8", D3DDDIFMT_R8G8B8, 24, 0x00000000, 0x00000000, 0x00000000,
STATUS_SUCCESS },
5695 {
"A8R8G8B8", D3DDDIFMT_A8R8G8B8, 32, 0x00000000, 0x00000000, 0x00000000,
STATUS_SUCCESS },
5696 {
"X8R8G8B8", D3DDDIFMT_X8R8G8B8, 32, 0x00000000, 0x00000000, 0x00000000,
STATUS_SUCCESS },
5697 {
"R5G6B5", D3DDDIFMT_R5G6B5, 16, 0x0000f800, 0x000007e0, 0x0000001f,
STATUS_SUCCESS },
5698 {
"X1R5G5B5", D3DDDIFMT_X1R5G5B5, 16, 0x00007c00, 0x000003e0, 0x0000001f,
STATUS_SUCCESS },
5699 {
"A1R5G5B5", D3DDDIFMT_A1R5G5B5, 16, 0x00007c00, 0x000003e0, 0x0000001f,
STATUS_SUCCESS },
5705 {
"P8", D3DDDIFMT_P8, 8, 0x00000000, 0x00000000, 0x00000000,
STATUS_SUCCESS },
5715 };
5716
5717 if (!pD3DKMTCreateDCFromMemory)
5718 {
5719 win_skip(
"D3DKMTCreateDCFromMemory() is not implemented.\n");
5720 return;
5721 }
5722
5725
5727 {
5729
5730 create_desc.pMemory =
data;
5732 create_desc.Width = 9;
5733 create_desc.Height = 7;
5734 create_desc.Pitch = sizeof(*data);
5735 create_desc.hDeviceDc =
NULL;
5736 create_desc.pColorTable =
NULL;
5737 create_desc.hDc = (void *)0x010baade;
5738 create_desc.hBitmap = (void *)0x020baade;
5739
5740 status = pD3DKMTCreateDCFromMemory( &create_desc );
5743
5745 create_desc.pMemory =
NULL;
5746 status = pD3DKMTCreateDCFromMemory( &create_desc );
5749
5750 create_desc.pMemory =
data;
5751 create_desc.Height = 0;
5752 status = pD3DKMTCreateDCFromMemory( &create_desc );
5755 ok(create_desc.hDc == (
void *)0x010baade,
"%s: Got unexpected dc %p.\n",
5757 ok(create_desc.hBitmap == (
void *)0x020baade,
"%s: Got unexpected bitmap %p.\n",
5759
5760 create_desc.Height = 7;
5761 create_desc.Width = 0;
5762 status = pD3DKMTCreateDCFromMemory( &create_desc );
5766 {
5767 destroy_desc.hDc = create_desc.hDc;
5768 destroy_desc.hBitmap = create_desc.hBitmap;
5769 status = pD3DKMTDestroyDCFromMemory( &destroy_desc );
5771 create_desc.hDc = (void *)0x010baade;
5772 create_desc.hBitmap = (void *)0x020baade;
5773 }
5774
5775 create_desc.Pitch = 0;
5776 status = pD3DKMTCreateDCFromMemory( &create_desc );
5779 ok(create_desc.hDc == (
void *)0x010baade,
"%s: Got unexpected dc %p.\n",
5781 ok(create_desc.hBitmap == (
void *)0x020baade,
"%s: Got unexpected bitmap %p.\n",
5783
5784 create_desc.Width = 9;
5785 create_desc.Pitch = sizeof(*data);
5786 status = pD3DKMTCreateDCFromMemory( &create_desc );
5790 {
5791 ok(!!create_desc.hDc,
"%s: Got unexpected dc %p.\n",
5793 ok(!!create_desc.hBitmap,
"%s: Got unexpected bitmap %p.\n",
5795 }
5796 else
5797 {
5798 ok(create_desc.hDc == (
void *)0x010baade,
"%s: Got unexpected dc %p.\n",
5800 ok(create_desc.hBitmap == (
void *)0x020baade,
"%s: Got unexpected bitmap %p.\n",
5802 continue;
5803 }
5804
5810 ok(
bitmap == create_desc.hBitmap,
"%s: Got unexpected bitmap %p, expected %p.\n",
5812
5815 ok(!
dib.dsBm.bmType,
"%s: Got unexpected type %#x.\n",
5817 ok(
dib.dsBm.bmWidth == create_desc.Width,
"%s: Got unexpected width %d.\n",
5819 ok(
dib.dsBm.bmHeight == create_desc.Height,
"%s: Got unexpected height %d.\n",
5822 ok(
dib.dsBm.bmWidthBytes ==
width_bytes,
"%s: Got unexpected width bytes %d.\n",
5824 ok(
dib.dsBm.bmPlanes == 1,
"%s: Got unexpected plane count %d.\n",
5826 ok(
dib.dsBm.bmBitsPixel ==
test_data[
i].bit_count,
"%s: Got unexpected bit count %d.\n",
5828 ok(
dib.dsBm.bmBits == create_desc.pMemory,
"%s: Got unexpected bits %p, expected %p.\n",
5830
5831 ok(
dib.dsBmih.biSize ==
sizeof(
dib.dsBmih),
"%s: Got unexpected size %u.\n",
5833 ok(
dib.dsBmih.biWidth == create_desc.Width,
"%s: Got unexpected width %d.\n",
5835 ok(
dib.dsBmih.biHeight == create_desc.Height,
"%s: Got unexpected height %d.\n",
5837 ok(
dib.dsBmih.biPlanes == 1,
"%s: Got unexpected plane count %u.\n",
5839 ok(
dib.dsBmih.biBitCount ==
test_data[
i].bit_count,
"%s: Got unexpected bit count %u.\n",
5842 "%s: Got unexpected compression %#x.\n",
5844 ok(!
dib.dsBmih.biSizeImage,
"%s: Got unexpected image size %u.\n",
5846 ok(!
dib.dsBmih.biXPelsPerMeter,
"%s: Got unexpected horizontal resolution %d.\n",
5848 ok(!
dib.dsBmih.biYPelsPerMeter,
"%s: Got unexpected vertical resolution %d.\n",
5851 {
5852 ok(
dib.dsBmih.biClrUsed == 256,
"%s: Got unexpected used colour count %u.\n",
5854 ok(
dib.dsBmih.biClrImportant == 256,
"%s: Got unexpected important colour count %u.\n",
5856 }
5857 else
5858 {
5859 ok(!
dib.dsBmih.biClrUsed,
"%s: Got unexpected used colour count %u.\n",
5861 ok(!
dib.dsBmih.biClrImportant,
"%s: Got unexpected important colour count %u.\n",
5863 }
5864
5867 "%s: Got unexpected colour masks 0x%08x 0x%08x 0x%08x.\n",
5869 ok(!
dib.dshSection,
"%s: Got unexpected section %p.\n",
test_data[
i].name,
dib.dshSection);
5870 ok(!
dib.dsOffset,
"%s: Got unexpected offset %u.\n",
test_data[
i].name,
dib.dsOffset);
5871
5873 ok(
ret,
"Failed to blit.\n");
5875 ok(
ret,
"Failed to blit.\n");
5876
5877
5879 ok(bmp_dc !=
NULL,
"failed to create DC\n");
5881 ok(
bmp !=
NULL,
"failed to create bmp\n");
5883 ret =
BitBlt( bmp_dc, 0, 0, create_desc.Width, create_desc.Height, create_desc.hDc, 0, 0,
SRCCOPY );
5884 ok(
ret,
"Failed to blit.\n");
5885
5886 destroy_desc.hDc = create_desc.hDc;
5887 destroy_desc.hBitmap = create_desc.hBitmap;
5888
5891 status = pD3DKMTDestroyDCFromMemory( &destroy_desc );
5893 status = pD3DKMTDestroyDCFromMemory( &destroy_desc );
5895
5897 ok(
ret,
"Failed to delete dc.\n");
5898
5899 for (
y = 0, fail =
FALSE;
y < 12 && !fail; ++
y)
5900 {
5901 for (
x = 0;
x <
sizeof(*data) / (
test_data[
i].bit_count / 8) && !fail; ++
x)
5902 {
5903 for (
z = 0, colour = 0;
z <
test_data[
i].bit_count / 8; ++
z)
5904 {
5906 }
5907
5908 if ((
x == 1 ||
x == 2) && (
y == 1 ||
y == 2))
5910 else if (
x < 4 &&
y < 7)
5912 else
5914 ok(colour ==
expected,
"%s: Got unexpected colour 0x%08x at %u, %u, expected 0x%08x.\n",
5918
5919
5921 {
5923 if ((
x == 1 ||
x == 2) && (
y == 1 ||
y == 2))
5925 else if (
x < create_desc.Width &&
y < create_desc.Height)
5927 else
5931 }
5932 }
5933 }
5934
5937 }
5938}
static POBJECT_TYPE GetObjectType(IN PCWSTR TypeName)
GLint GLint GLint GLint GLint x
GLuint GLuint GLsizei GLenum type
GLint GLint GLint GLint GLint GLint y
#define STATUS_INVALID_PARAMETER
int WINAPI GetObjectA(_In_ HANDLE h, _In_ int c, _Out_writes_bytes_opt_(c) LPVOID pv)