Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
b9ab54a0
Commit
b9ab54a0
authored
Dec 13, 2013
by
Henri Verbeet
Committed by
Alexandre Julliard
Dec 13, 2013
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ddraw/tests: Add a test for palettes on primary surfaces.
parent
c5a8b933
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
398 additions
and
0 deletions
+398
-0
ddraw1.c
dlls/ddraw/tests/ddraw1.c
+98
-0
ddraw2.c
dlls/ddraw/tests/ddraw2.c
+98
-0
ddraw4.c
dlls/ddraw/tests/ddraw4.c
+98
-0
ddraw7.c
dlls/ddraw/tests/ddraw7.c
+104
-0
No files found.
dlls/ddraw/tests/ddraw1.c
View file @
b9ab54a0
...
...
@@ -3913,6 +3913,103 @@ static void test_sysmem_overlay(void)
DestroyWindow
(
window
);
}
static
void
test_primary_palette
(
void
)
{
DDSCAPS
surface_caps
=
{
DDSCAPS_FLIP
};
IDirectDrawSurface
*
primary
,
*
backbuffer
;
PALETTEENTRY
palette_entries
[
256
];
IDirectDrawPalette
*
palette
,
*
tmp
;
DDSURFACEDESC
surface_desc
;
IDirectDraw
*
ddraw
;
DWORD
palette_caps
;
ULONG
refcount
;
HWND
window
;
HRESULT
hr
;
if
(
!
(
ddraw
=
create_ddraw
()))
{
skip
(
"Failed to create a ddraw object, skipping test.
\n
"
);
return
;
}
window
=
CreateWindowA
(
"static"
,
"ddraw_test"
,
WS_OVERLAPPEDWINDOW
,
0
,
0
,
640
,
480
,
0
,
0
,
0
,
0
);
hr
=
IDirectDraw_SetDisplayMode
(
ddraw
,
640
,
480
,
8
);
ok
(
SUCCEEDED
(
hr
),
"Failed to set display mode, hr %#x.
\n
"
,
hr
);
hr
=
IDirectDraw_SetCooperativeLevel
(
ddraw
,
window
,
DDSCL_EXCLUSIVE
|
DDSCL_FULLSCREEN
);
ok
(
SUCCEEDED
(
hr
),
"Failed to set cooperative level, hr %#x.
\n
"
,
hr
);
memset
(
&
surface_desc
,
0
,
sizeof
(
surface_desc
));
surface_desc
.
dwSize
=
sizeof
(
surface_desc
);
surface_desc
.
dwFlags
=
DDSD_CAPS
|
DDSD_BACKBUFFERCOUNT
;
surface_desc
.
ddsCaps
.
dwCaps
=
DDSCAPS_PRIMARYSURFACE
|
DDSCAPS_COMPLEX
|
DDSCAPS_FLIP
;
surface_desc
.
dwBackBufferCount
=
1
;
hr
=
IDirectDraw_CreateSurface
(
ddraw
,
&
surface_desc
,
&
primary
,
NULL
);
ok
(
SUCCEEDED
(
hr
),
"Failed to create surface, hr %#x.
\n
"
,
hr
);
hr
=
IDirectDrawSurface_GetAttachedSurface
(
primary
,
&
surface_caps
,
&
backbuffer
);
ok
(
SUCCEEDED
(
hr
),
"Failed to get attached surface, hr %#x.
\n
"
,
hr
);
memset
(
palette_entries
,
0
,
sizeof
(
palette_entries
));
hr
=
IDirectDraw_CreatePalette
(
ddraw
,
DDPCAPS_8BIT
|
DDPCAPS_ALLOW256
,
palette_entries
,
&
palette
,
NULL
);
ok
(
SUCCEEDED
(
hr
),
"Failed to create palette, hr %#x.
\n
"
,
hr
);
refcount
=
get_refcount
((
IUnknown
*
)
palette
);
ok
(
refcount
==
1
,
"Got unexpected refcount %u.
\n
"
,
refcount
);
hr
=
IDirectDrawPalette_GetCaps
(
palette
,
&
palette_caps
);
ok
(
SUCCEEDED
(
hr
),
"Failed to get palette caps, hr %#x.
\n
"
,
hr
);
ok
(
palette_caps
==
(
DDPCAPS_8BIT
|
DDPCAPS_ALLOW256
),
"Got unexpected palette caps %#x.
\n
"
,
palette_caps
);
hr
=
IDirectDrawSurface_SetPalette
(
primary
,
palette
);
ok
(
SUCCEEDED
(
hr
),
"Failed to set palette, hr %#x.
\n
"
,
hr
);
refcount
=
get_refcount
((
IUnknown
*
)
palette
);
ok
(
refcount
==
2
,
"Got unexpected refcount %u.
\n
"
,
refcount
);
hr
=
IDirectDrawPalette_GetCaps
(
palette
,
&
palette_caps
);
ok
(
SUCCEEDED
(
hr
),
"Failed to get palette caps, hr %#x.
\n
"
,
hr
);
ok
(
palette_caps
==
(
DDPCAPS_8BIT
|
DDPCAPS_PRIMARYSURFACE
|
DDPCAPS_ALLOW256
),
"Got unexpected palette caps %#x.
\n
"
,
palette_caps
);
hr
=
IDirectDrawSurface_SetPalette
(
primary
,
NULL
);
ok
(
SUCCEEDED
(
hr
),
"Failed to set palette, hr %#x.
\n
"
,
hr
);
refcount
=
get_refcount
((
IUnknown
*
)
palette
);
ok
(
refcount
==
1
,
"Got unexpected refcount %u.
\n
"
,
refcount
);
hr
=
IDirectDrawPalette_GetCaps
(
palette
,
&
palette_caps
);
ok
(
SUCCEEDED
(
hr
),
"Failed to get palette caps, hr %#x.
\n
"
,
hr
);
ok
(
palette_caps
==
(
DDPCAPS_8BIT
|
DDPCAPS_ALLOW256
),
"Got unexpected palette caps %#x.
\n
"
,
palette_caps
);
hr
=
IDirectDrawSurface_SetPalette
(
primary
,
palette
);
ok
(
SUCCEEDED
(
hr
),
"Failed to set palette, hr %#x.
\n
"
,
hr
);
refcount
=
get_refcount
((
IUnknown
*
)
palette
);
ok
(
refcount
==
2
,
"Got unexpected refcount %u.
\n
"
,
refcount
);
hr
=
IDirectDrawSurface_GetPalette
(
primary
,
&
tmp
);
ok
(
SUCCEEDED
(
hr
),
"Failed to get palette, hr %#x.
\n
"
,
hr
);
ok
(
tmp
==
palette
,
"Got unexpected palette %p, expected %p.
\n
"
,
tmp
,
palette
);
IDirectDrawPalette_Release
(
tmp
);
hr
=
IDirectDrawSurface_GetPalette
(
backbuffer
,
&
tmp
);
ok
(
hr
==
DDERR_NOPALETTEATTACHED
,
"Got unexpected hr %#x.
\n
"
,
hr
);
refcount
=
IDirectDrawPalette_Release
(
palette
);
ok
(
refcount
==
1
,
"Got unexpected refcount %u.
\n
"
,
refcount
);
refcount
=
IDirectDrawPalette_Release
(
palette
);
ok
(
!
refcount
,
"Got unexpected refcount %u.
\n
"
,
refcount
);
/* Note that this only seems to work when the palette is attached to the
* primary surface. When attached to a regular surface, attempting to get
* the palette here will cause an access violation. */
hr
=
IDirectDrawSurface_GetPalette
(
primary
,
&
tmp
);
ok
(
hr
==
DDERR_NOPALETTEATTACHED
,
"Got unexpected hr %#x.
\n
"
,
hr
);
refcount
=
IDirectDrawSurface_Release
(
backbuffer
);
ok
(
refcount
==
1
,
"Got unexpected refcount %u.
\n
"
,
refcount
);
refcount
=
IDirectDrawSurface_Release
(
primary
);
ok
(
!
refcount
,
"Got unexpected refcount %u.
\n
"
,
refcount
);
refcount
=
IDirectDraw_Release
(
ddraw
);
ok
(
!
refcount
,
"Got unexpected refcount %u.
\n
"
,
refcount
);
DestroyWindow
(
window
);
}
START_TEST
(
ddraw1
)
{
test_coop_level_create_device_window
();
...
...
@@ -3943,4 +4040,5 @@ START_TEST(ddraw1)
test_surface_discard
();
test_flip
();
test_sysmem_overlay
();
test_primary_palette
();
}
dlls/ddraw/tests/ddraw2.c
View file @
b9ab54a0
...
...
@@ -4972,6 +4972,103 @@ static void test_sysmem_overlay(void)
DestroyWindow
(
window
);
}
static
void
test_primary_palette
(
void
)
{
DDSCAPS
surface_caps
=
{
DDSCAPS_FLIP
};
IDirectDrawSurface
*
primary
,
*
backbuffer
;
PALETTEENTRY
palette_entries
[
256
];
IDirectDrawPalette
*
palette
,
*
tmp
;
DDSURFACEDESC
surface_desc
;
IDirectDraw2
*
ddraw
;
DWORD
palette_caps
;
ULONG
refcount
;
HWND
window
;
HRESULT
hr
;
if
(
!
(
ddraw
=
create_ddraw
()))
{
skip
(
"Failed to create a ddraw object, skipping test.
\n
"
);
return
;
}
window
=
CreateWindowA
(
"static"
,
"ddraw_test"
,
WS_OVERLAPPEDWINDOW
,
0
,
0
,
640
,
480
,
0
,
0
,
0
,
0
);
hr
=
IDirectDraw2_SetDisplayMode
(
ddraw
,
640
,
480
,
8
,
0
,
0
);
ok
(
SUCCEEDED
(
hr
),
"Failed to set display mode, hr %#x.
\n
"
,
hr
);
hr
=
IDirectDraw2_SetCooperativeLevel
(
ddraw
,
window
,
DDSCL_EXCLUSIVE
|
DDSCL_FULLSCREEN
);
ok
(
SUCCEEDED
(
hr
),
"Failed to set cooperative level, hr %#x.
\n
"
,
hr
);
memset
(
&
surface_desc
,
0
,
sizeof
(
surface_desc
));
surface_desc
.
dwSize
=
sizeof
(
surface_desc
);
surface_desc
.
dwFlags
=
DDSD_CAPS
|
DDSD_BACKBUFFERCOUNT
;
surface_desc
.
ddsCaps
.
dwCaps
=
DDSCAPS_PRIMARYSURFACE
|
DDSCAPS_COMPLEX
|
DDSCAPS_FLIP
;
surface_desc
.
dwBackBufferCount
=
1
;
hr
=
IDirectDraw2_CreateSurface
(
ddraw
,
&
surface_desc
,
&
primary
,
NULL
);
ok
(
SUCCEEDED
(
hr
),
"Failed to create surface, hr %#x.
\n
"
,
hr
);
hr
=
IDirectDrawSurface_GetAttachedSurface
(
primary
,
&
surface_caps
,
&
backbuffer
);
ok
(
SUCCEEDED
(
hr
),
"Failed to get attached surface, hr %#x.
\n
"
,
hr
);
memset
(
palette_entries
,
0
,
sizeof
(
palette_entries
));
hr
=
IDirectDraw2_CreatePalette
(
ddraw
,
DDPCAPS_8BIT
|
DDPCAPS_ALLOW256
,
palette_entries
,
&
palette
,
NULL
);
ok
(
SUCCEEDED
(
hr
),
"Failed to create palette, hr %#x.
\n
"
,
hr
);
refcount
=
get_refcount
((
IUnknown
*
)
palette
);
ok
(
refcount
==
1
,
"Got unexpected refcount %u.
\n
"
,
refcount
);
hr
=
IDirectDrawPalette_GetCaps
(
palette
,
&
palette_caps
);
ok
(
SUCCEEDED
(
hr
),
"Failed to get palette caps, hr %#x.
\n
"
,
hr
);
ok
(
palette_caps
==
(
DDPCAPS_8BIT
|
DDPCAPS_ALLOW256
),
"Got unexpected palette caps %#x.
\n
"
,
palette_caps
);
hr
=
IDirectDrawSurface_SetPalette
(
primary
,
palette
);
ok
(
SUCCEEDED
(
hr
),
"Failed to set palette, hr %#x.
\n
"
,
hr
);
refcount
=
get_refcount
((
IUnknown
*
)
palette
);
ok
(
refcount
==
2
,
"Got unexpected refcount %u.
\n
"
,
refcount
);
hr
=
IDirectDrawPalette_GetCaps
(
palette
,
&
palette_caps
);
ok
(
SUCCEEDED
(
hr
),
"Failed to get palette caps, hr %#x.
\n
"
,
hr
);
ok
(
palette_caps
==
(
DDPCAPS_8BIT
|
DDPCAPS_PRIMARYSURFACE
|
DDPCAPS_ALLOW256
),
"Got unexpected palette caps %#x.
\n
"
,
palette_caps
);
hr
=
IDirectDrawSurface_SetPalette
(
primary
,
NULL
);
ok
(
SUCCEEDED
(
hr
),
"Failed to set palette, hr %#x.
\n
"
,
hr
);
refcount
=
get_refcount
((
IUnknown
*
)
palette
);
ok
(
refcount
==
1
,
"Got unexpected refcount %u.
\n
"
,
refcount
);
hr
=
IDirectDrawPalette_GetCaps
(
palette
,
&
palette_caps
);
ok
(
SUCCEEDED
(
hr
),
"Failed to get palette caps, hr %#x.
\n
"
,
hr
);
ok
(
palette_caps
==
(
DDPCAPS_8BIT
|
DDPCAPS_ALLOW256
),
"Got unexpected palette caps %#x.
\n
"
,
palette_caps
);
hr
=
IDirectDrawSurface_SetPalette
(
primary
,
palette
);
ok
(
SUCCEEDED
(
hr
),
"Failed to set palette, hr %#x.
\n
"
,
hr
);
refcount
=
get_refcount
((
IUnknown
*
)
palette
);
ok
(
refcount
==
2
,
"Got unexpected refcount %u.
\n
"
,
refcount
);
hr
=
IDirectDrawSurface_GetPalette
(
primary
,
&
tmp
);
ok
(
SUCCEEDED
(
hr
),
"Failed to get palette, hr %#x.
\n
"
,
hr
);
ok
(
tmp
==
palette
,
"Got unexpected palette %p, expected %p.
\n
"
,
tmp
,
palette
);
IDirectDrawPalette_Release
(
tmp
);
hr
=
IDirectDrawSurface_GetPalette
(
backbuffer
,
&
tmp
);
ok
(
hr
==
DDERR_NOPALETTEATTACHED
,
"Got unexpected hr %#x.
\n
"
,
hr
);
refcount
=
IDirectDrawPalette_Release
(
palette
);
ok
(
refcount
==
1
,
"Got unexpected refcount %u.
\n
"
,
refcount
);
refcount
=
IDirectDrawPalette_Release
(
palette
);
ok
(
!
refcount
,
"Got unexpected refcount %u.
\n
"
,
refcount
);
/* Note that this only seems to work when the palette is attached to the
* primary surface. When attached to a regular surface, attempting to get
* the palette here will cause an access violation. */
hr
=
IDirectDrawSurface_GetPalette
(
primary
,
&
tmp
);
ok
(
hr
==
DDERR_NOPALETTEATTACHED
,
"Got unexpected hr %#x.
\n
"
,
hr
);
refcount
=
IDirectDrawSurface_Release
(
backbuffer
);
ok
(
refcount
==
1
,
"Got unexpected refcount %u.
\n
"
,
refcount
);
refcount
=
IDirectDrawSurface_Release
(
primary
);
ok
(
!
refcount
,
"Got unexpected refcount %u.
\n
"
,
refcount
);
refcount
=
IDirectDraw2_Release
(
ddraw
);
ok
(
!
refcount
,
"Got unexpected refcount %u.
\n
"
,
refcount
);
DestroyWindow
(
window
);
}
START_TEST
(
ddraw2
)
{
test_coop_level_create_device_window
();
...
...
@@ -5008,4 +5105,5 @@ START_TEST(ddraw2)
test_set_surface_desc
();
test_user_memory_getdc
();
test_sysmem_overlay
();
test_primary_palette
();
}
dlls/ddraw/tests/ddraw4.c
View file @
b9ab54a0
...
...
@@ -5569,6 +5569,103 @@ static void test_sysmem_overlay(void)
DestroyWindow
(
window
);
}
static
void
test_primary_palette
(
void
)
{
DDSCAPS2
surface_caps
=
{
DDSCAPS_FLIP
,
0
,
0
,
0
};
IDirectDrawSurface4
*
primary
,
*
backbuffer
;
PALETTEENTRY
palette_entries
[
256
];
IDirectDrawPalette
*
palette
,
*
tmp
;
DDSURFACEDESC2
surface_desc
;
IDirectDraw4
*
ddraw
;
DWORD
palette_caps
;
ULONG
refcount
;
HWND
window
;
HRESULT
hr
;
if
(
!
(
ddraw
=
create_ddraw
()))
{
skip
(
"Failed to create a ddraw object, skipping test.
\n
"
);
return
;
}
window
=
CreateWindowA
(
"static"
,
"ddraw_test"
,
WS_OVERLAPPEDWINDOW
,
0
,
0
,
640
,
480
,
0
,
0
,
0
,
0
);
hr
=
IDirectDraw4_SetDisplayMode
(
ddraw
,
640
,
480
,
8
,
0
,
0
);
ok
(
SUCCEEDED
(
hr
),
"Failed to set display mode, hr %#x.
\n
"
,
hr
);
hr
=
IDirectDraw4_SetCooperativeLevel
(
ddraw
,
window
,
DDSCL_EXCLUSIVE
|
DDSCL_FULLSCREEN
);
ok
(
SUCCEEDED
(
hr
),
"Failed to set cooperative level, hr %#x.
\n
"
,
hr
);
memset
(
&
surface_desc
,
0
,
sizeof
(
surface_desc
));
surface_desc
.
dwSize
=
sizeof
(
surface_desc
);
surface_desc
.
dwFlags
=
DDSD_CAPS
|
DDSD_BACKBUFFERCOUNT
;
surface_desc
.
ddsCaps
.
dwCaps
=
DDSCAPS_PRIMARYSURFACE
|
DDSCAPS_COMPLEX
|
DDSCAPS_FLIP
;
surface_desc
.
dwBackBufferCount
=
1
;
hr
=
IDirectDraw4_CreateSurface
(
ddraw
,
&
surface_desc
,
&
primary
,
NULL
);
ok
(
SUCCEEDED
(
hr
),
"Failed to create surface, hr %#x.
\n
"
,
hr
);
hr
=
IDirectDrawSurface4_GetAttachedSurface
(
primary
,
&
surface_caps
,
&
backbuffer
);
ok
(
SUCCEEDED
(
hr
),
"Failed to get attached surface, hr %#x.
\n
"
,
hr
);
memset
(
palette_entries
,
0
,
sizeof
(
palette_entries
));
hr
=
IDirectDraw4_CreatePalette
(
ddraw
,
DDPCAPS_8BIT
|
DDPCAPS_ALLOW256
,
palette_entries
,
&
palette
,
NULL
);
ok
(
SUCCEEDED
(
hr
),
"Failed to create palette, hr %#x.
\n
"
,
hr
);
refcount
=
get_refcount
((
IUnknown
*
)
palette
);
ok
(
refcount
==
1
,
"Got unexpected refcount %u.
\n
"
,
refcount
);
hr
=
IDirectDrawPalette_GetCaps
(
palette
,
&
palette_caps
);
ok
(
SUCCEEDED
(
hr
),
"Failed to get palette caps, hr %#x.
\n
"
,
hr
);
ok
(
palette_caps
==
(
DDPCAPS_8BIT
|
DDPCAPS_ALLOW256
),
"Got unexpected palette caps %#x.
\n
"
,
palette_caps
);
hr
=
IDirectDrawSurface4_SetPalette
(
primary
,
palette
);
ok
(
SUCCEEDED
(
hr
),
"Failed to set palette, hr %#x.
\n
"
,
hr
);
refcount
=
get_refcount
((
IUnknown
*
)
palette
);
ok
(
refcount
==
2
,
"Got unexpected refcount %u.
\n
"
,
refcount
);
hr
=
IDirectDrawPalette_GetCaps
(
palette
,
&
palette_caps
);
ok
(
SUCCEEDED
(
hr
),
"Failed to get palette caps, hr %#x.
\n
"
,
hr
);
ok
(
palette_caps
==
(
DDPCAPS_8BIT
|
DDPCAPS_PRIMARYSURFACE
|
DDPCAPS_ALLOW256
),
"Got unexpected palette caps %#x.
\n
"
,
palette_caps
);
hr
=
IDirectDrawSurface4_SetPalette
(
primary
,
NULL
);
ok
(
SUCCEEDED
(
hr
),
"Failed to set palette, hr %#x.
\n
"
,
hr
);
refcount
=
get_refcount
((
IUnknown
*
)
palette
);
ok
(
refcount
==
1
,
"Got unexpected refcount %u.
\n
"
,
refcount
);
hr
=
IDirectDrawPalette_GetCaps
(
palette
,
&
palette_caps
);
ok
(
SUCCEEDED
(
hr
),
"Failed to get palette caps, hr %#x.
\n
"
,
hr
);
ok
(
palette_caps
==
(
DDPCAPS_8BIT
|
DDPCAPS_ALLOW256
),
"Got unexpected palette caps %#x.
\n
"
,
palette_caps
);
hr
=
IDirectDrawSurface4_SetPalette
(
primary
,
palette
);
ok
(
SUCCEEDED
(
hr
),
"Failed to set palette, hr %#x.
\n
"
,
hr
);
refcount
=
get_refcount
((
IUnknown
*
)
palette
);
ok
(
refcount
==
2
,
"Got unexpected refcount %u.
\n
"
,
refcount
);
hr
=
IDirectDrawSurface4_GetPalette
(
primary
,
&
tmp
);
ok
(
SUCCEEDED
(
hr
),
"Failed to get palette, hr %#x.
\n
"
,
hr
);
ok
(
tmp
==
palette
,
"Got unexpected palette %p, expected %p.
\n
"
,
tmp
,
palette
);
IDirectDrawPalette_Release
(
tmp
);
hr
=
IDirectDrawSurface4_GetPalette
(
backbuffer
,
&
tmp
);
ok
(
hr
==
DDERR_NOPALETTEATTACHED
,
"Got unexpected hr %#x.
\n
"
,
hr
);
refcount
=
IDirectDrawPalette_Release
(
palette
);
ok
(
refcount
==
1
,
"Got unexpected refcount %u.
\n
"
,
refcount
);
refcount
=
IDirectDrawPalette_Release
(
palette
);
ok
(
!
refcount
,
"Got unexpected refcount %u.
\n
"
,
refcount
);
/* Note that this only seems to work when the palette is attached to the
* primary surface. When attached to a regular surface, attempting to get
* the palette here will cause an access violation. */
hr
=
IDirectDrawSurface4_GetPalette
(
primary
,
&
tmp
);
ok
(
hr
==
DDERR_NOPALETTEATTACHED
,
"Got unexpected hr %#x.
\n
"
,
hr
);
refcount
=
IDirectDrawSurface4_Release
(
backbuffer
);
ok
(
refcount
==
1
,
"Got unexpected refcount %u.
\n
"
,
refcount
);
refcount
=
IDirectDrawSurface4_Release
(
primary
);
ok
(
!
refcount
,
"Got unexpected refcount %u.
\n
"
,
refcount
);
refcount
=
IDirectDraw4_Release
(
ddraw
);
ok
(
!
refcount
,
"Got unexpected refcount %u.
\n
"
,
refcount
);
DestroyWindow
(
window
);
}
START_TEST
(
ddraw4
)
{
test_process_vertices
();
...
...
@@ -5610,4 +5707,5 @@ START_TEST(ddraw4)
test_set_surface_desc
();
test_user_memory_getdc
();
test_sysmem_overlay
();
test_primary_palette
();
}
dlls/ddraw/tests/ddraw7.c
View file @
b9ab54a0
...
...
@@ -90,6 +90,12 @@ static BOOL compare_color(D3DCOLOR c1, D3DCOLOR c2, BYTE max_diff)
return
TRUE
;
}
static
ULONG
get_refcount
(
IUnknown
*
iface
)
{
IUnknown_AddRef
(
iface
);
return
IUnknown_Release
(
iface
);
}
static
DWORD
WINAPI
create_window_thread_proc
(
void
*
param
)
{
struct
create_window_thread_param
*
p
=
param
;
...
...
@@ -5457,6 +5463,103 @@ static void test_sysmem_overlay(void)
DestroyWindow
(
window
);
}
static
void
test_primary_palette
(
void
)
{
DDSCAPS2
surface_caps
=
{
DDSCAPS_FLIP
,
0
,
0
,
0
};
IDirectDrawSurface7
*
primary
,
*
backbuffer
;
PALETTEENTRY
palette_entries
[
256
];
IDirectDrawPalette
*
palette
,
*
tmp
;
DDSURFACEDESC2
surface_desc
;
IDirectDraw7
*
ddraw
;
DWORD
palette_caps
;
ULONG
refcount
;
HWND
window
;
HRESULT
hr
;
if
(
!
(
ddraw
=
create_ddraw
()))
{
skip
(
"Failed to create a ddraw object, skipping test.
\n
"
);
return
;
}
window
=
CreateWindowA
(
"static"
,
"ddraw_test"
,
WS_OVERLAPPEDWINDOW
,
0
,
0
,
640
,
480
,
0
,
0
,
0
,
0
);
hr
=
IDirectDraw7_SetDisplayMode
(
ddraw
,
640
,
480
,
8
,
0
,
0
);
ok
(
SUCCEEDED
(
hr
),
"Failed to set display mode, hr %#x.
\n
"
,
hr
);
hr
=
IDirectDraw7_SetCooperativeLevel
(
ddraw
,
window
,
DDSCL_EXCLUSIVE
|
DDSCL_FULLSCREEN
);
ok
(
SUCCEEDED
(
hr
),
"Failed to set cooperative level, hr %#x.
\n
"
,
hr
);
memset
(
&
surface_desc
,
0
,
sizeof
(
surface_desc
));
surface_desc
.
dwSize
=
sizeof
(
surface_desc
);
surface_desc
.
dwFlags
=
DDSD_CAPS
|
DDSD_BACKBUFFERCOUNT
;
surface_desc
.
ddsCaps
.
dwCaps
=
DDSCAPS_PRIMARYSURFACE
|
DDSCAPS_COMPLEX
|
DDSCAPS_FLIP
;
surface_desc
.
dwBackBufferCount
=
1
;
hr
=
IDirectDraw7_CreateSurface
(
ddraw
,
&
surface_desc
,
&
primary
,
NULL
);
ok
(
SUCCEEDED
(
hr
),
"Failed to create surface, hr %#x.
\n
"
,
hr
);
hr
=
IDirectDrawSurface7_GetAttachedSurface
(
primary
,
&
surface_caps
,
&
backbuffer
);
ok
(
SUCCEEDED
(
hr
),
"Failed to get attached surface, hr %#x.
\n
"
,
hr
);
memset
(
palette_entries
,
0
,
sizeof
(
palette_entries
));
hr
=
IDirectDraw7_CreatePalette
(
ddraw
,
DDPCAPS_8BIT
|
DDPCAPS_ALLOW256
,
palette_entries
,
&
palette
,
NULL
);
ok
(
SUCCEEDED
(
hr
),
"Failed to create palette, hr %#x.
\n
"
,
hr
);
refcount
=
get_refcount
((
IUnknown
*
)
palette
);
ok
(
refcount
==
1
,
"Got unexpected refcount %u.
\n
"
,
refcount
);
hr
=
IDirectDrawPalette_GetCaps
(
palette
,
&
palette_caps
);
ok
(
SUCCEEDED
(
hr
),
"Failed to get palette caps, hr %#x.
\n
"
,
hr
);
ok
(
palette_caps
==
(
DDPCAPS_8BIT
|
DDPCAPS_ALLOW256
),
"Got unexpected palette caps %#x.
\n
"
,
palette_caps
);
hr
=
IDirectDrawSurface7_SetPalette
(
primary
,
palette
);
ok
(
SUCCEEDED
(
hr
),
"Failed to set palette, hr %#x.
\n
"
,
hr
);
refcount
=
get_refcount
((
IUnknown
*
)
palette
);
ok
(
refcount
==
2
,
"Got unexpected refcount %u.
\n
"
,
refcount
);
hr
=
IDirectDrawPalette_GetCaps
(
palette
,
&
palette_caps
);
ok
(
SUCCEEDED
(
hr
),
"Failed to get palette caps, hr %#x.
\n
"
,
hr
);
ok
(
palette_caps
==
(
DDPCAPS_8BIT
|
DDPCAPS_PRIMARYSURFACE
|
DDPCAPS_ALLOW256
),
"Got unexpected palette caps %#x.
\n
"
,
palette_caps
);
hr
=
IDirectDrawSurface7_SetPalette
(
primary
,
NULL
);
ok
(
SUCCEEDED
(
hr
),
"Failed to set palette, hr %#x.
\n
"
,
hr
);
refcount
=
get_refcount
((
IUnknown
*
)
palette
);
ok
(
refcount
==
1
,
"Got unexpected refcount %u.
\n
"
,
refcount
);
hr
=
IDirectDrawPalette_GetCaps
(
palette
,
&
palette_caps
);
ok
(
SUCCEEDED
(
hr
),
"Failed to get palette caps, hr %#x.
\n
"
,
hr
);
ok
(
palette_caps
==
(
DDPCAPS_8BIT
|
DDPCAPS_ALLOW256
),
"Got unexpected palette caps %#x.
\n
"
,
palette_caps
);
hr
=
IDirectDrawSurface7_SetPalette
(
primary
,
palette
);
ok
(
SUCCEEDED
(
hr
),
"Failed to set palette, hr %#x.
\n
"
,
hr
);
refcount
=
get_refcount
((
IUnknown
*
)
palette
);
ok
(
refcount
==
2
,
"Got unexpected refcount %u.
\n
"
,
refcount
);
hr
=
IDirectDrawSurface7_GetPalette
(
primary
,
&
tmp
);
ok
(
SUCCEEDED
(
hr
),
"Failed to get palette, hr %#x.
\n
"
,
hr
);
ok
(
tmp
==
palette
,
"Got unexpected palette %p, expected %p.
\n
"
,
tmp
,
palette
);
IDirectDrawPalette_Release
(
tmp
);
hr
=
IDirectDrawSurface7_GetPalette
(
backbuffer
,
&
tmp
);
ok
(
hr
==
DDERR_NOPALETTEATTACHED
,
"Got unexpected hr %#x.
\n
"
,
hr
);
refcount
=
IDirectDrawPalette_Release
(
palette
);
ok
(
refcount
==
1
,
"Got unexpected refcount %u.
\n
"
,
refcount
);
refcount
=
IDirectDrawPalette_Release
(
palette
);
ok
(
!
refcount
,
"Got unexpected refcount %u.
\n
"
,
refcount
);
/* Note that this only seems to work when the palette is attached to the
* primary surface. When attached to a regular surface, attempting to get
* the palette here will cause an access violation. */
hr
=
IDirectDrawSurface7_GetPalette
(
primary
,
&
tmp
);
ok
(
hr
==
DDERR_NOPALETTEATTACHED
,
"Got unexpected hr %#x.
\n
"
,
hr
);
refcount
=
IDirectDrawSurface7_Release
(
backbuffer
);
ok
(
refcount
==
1
,
"Got unexpected refcount %u.
\n
"
,
refcount
);
refcount
=
IDirectDrawSurface7_Release
(
primary
);
ok
(
!
refcount
,
"Got unexpected refcount %u.
\n
"
,
refcount
);
refcount
=
IDirectDraw7_Release
(
ddraw
);
ok
(
!
refcount
,
"Got unexpected refcount %u.
\n
"
,
refcount
);
DestroyWindow
(
window
);
}
START_TEST
(
ddraw7
)
{
HMODULE
module
=
GetModuleHandleA
(
"ddraw.dll"
);
...
...
@@ -5506,4 +5609,5 @@ START_TEST(ddraw7)
test_set_surface_desc
();
test_user_memory_getdc
();
test_sysmem_overlay
();
test_primary_palette
();
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment