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
9628db25
Commit
9628db25
authored
Feb 05, 2016
by
Henri Verbeet
Committed by
Alexandre Julliard
Feb 06, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ddraw/tests: Rewrite rectangle_settings().
Signed-off-by:
Henri Verbeet
<
hverbeet@codeweavers.com
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
03ef393a
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
376 additions
and
166 deletions
+376
-166
Makefile.in
dlls/ddraw/tests/Makefile.in
+0
-1
ddraw1.c
dlls/ddraw/tests/ddraw1.c
+94
-0
ddraw2.c
dlls/ddraw/tests/ddraw2.c
+94
-0
ddraw4.c
dlls/ddraw/tests/ddraw4.c
+94
-0
ddraw7.c
dlls/ddraw/tests/ddraw7.c
+94
-0
overlay.c
dlls/ddraw/tests/overlay.c
+0
-165
No files found.
dlls/ddraw/tests/Makefile.in
View file @
9628db25
...
...
@@ -9,6 +9,5 @@ C_SRCS = \
ddraw7.c
\
ddrawmodes.c
\
dsurface.c
\
overlay.c
\
refcount.c
\
visual.c
dlls/ddraw/tests/ddraw1.c
View file @
9628db25
...
...
@@ -8410,6 +8410,99 @@ done:
DestroyWindow
(
window
);
}
static
void
test_overlay_rect
(
void
)
{
IDirectDrawSurface
*
overlay
,
*
primary
;
DDSURFACEDESC
surface_desc
;
RECT
rect
=
{
0
,
0
,
64
,
64
};
IDirectDraw
*
ddraw
;
LONG
pos_x
,
pos_y
;
HRESULT
hr
,
hr2
;
HWND
window
;
HDC
dc
;
window
=
CreateWindowA
(
"static"
,
"ddraw_test"
,
WS_OVERLAPPEDWINDOW
,
0
,
0
,
640
,
480
,
0
,
0
,
0
,
0
);
ddraw
=
create_ddraw
();
ok
(
!!
ddraw
,
"Failed to create a ddraw object.
\n
"
);
hr
=
IDirectDraw_SetCooperativeLevel
(
ddraw
,
window
,
DDSCL_NORMAL
);
ok
(
SUCCEEDED
(
hr
),
"Failed to set cooperative level, hr %#x.
\n
"
,
hr
);
if
(
!
(
overlay
=
create_overlay
(
ddraw
,
64
,
64
,
MAKEFOURCC
(
'U'
,
'Y'
,
'V'
,
'Y'
))))
{
skip
(
"Failed to create a UYVY overlay, skipping test.
\n
"
);
goto
done
;
}
memset
(
&
surface_desc
,
0
,
sizeof
(
surface_desc
));
surface_desc
.
dwSize
=
sizeof
(
surface_desc
);
surface_desc
.
dwFlags
=
DDSD_CAPS
;
surface_desc
.
ddsCaps
.
dwCaps
=
DDSCAPS_PRIMARYSURFACE
;
hr
=
IDirectDraw_CreateSurface
(
ddraw
,
&
surface_desc
,
&
primary
,
NULL
);
ok
(
SUCCEEDED
(
hr
),
"Failed to create surface, hr %#x.
\n
"
,
hr
);
/* On Windows 7, and probably Vista, UpdateOverlay() will return
* DDERR_OUTOFCAPS if the dwm is active. Calling GetDC() on the primary
* surface prevents this by disabling the dwm. */
hr
=
IDirectDrawSurface_GetDC
(
primary
,
&
dc
);
ok
(
SUCCEEDED
(
hr
),
"Failed to get DC, hr %#x.
\n
"
,
hr
);
hr
=
IDirectDrawSurface_ReleaseDC
(
primary
,
dc
);
ok
(
SUCCEEDED
(
hr
),
"Failed to release DC, hr %#x.
\n
"
,
hr
);
/* The dx sdk sort of implies that rect must be set when DDOVER_SHOW is
* used. This is not true in Windows Vista and earlier, but changed in
* Windows 7. */
hr
=
IDirectDrawSurface_UpdateOverlay
(
overlay
,
NULL
,
primary
,
&
rect
,
DDOVER_SHOW
,
NULL
);
ok
(
SUCCEEDED
(
hr
),
"Failed to update overlay, hr %#x.
\n
"
,
hr
);
hr
=
IDirectDrawSurface_UpdateOverlay
(
overlay
,
NULL
,
primary
,
NULL
,
DDOVER_HIDE
,
NULL
);
ok
(
SUCCEEDED
(
hr
),
"Failed to update overlay, hr %#x.
\n
"
,
hr
);
hr
=
IDirectDrawSurface_UpdateOverlay
(
overlay
,
NULL
,
primary
,
NULL
,
DDOVER_SHOW
,
NULL
);
ok
(
hr
==
DD_OK
||
hr
==
DDERR_INVALIDPARAMS
,
"Got unexpected hr %#x.
\n
"
,
hr
);
/* Show that the overlay position is the (top, left) coordinate of the
* destination rectangle. */
OffsetRect
(
&
rect
,
32
,
16
);
hr
=
IDirectDrawSurface_UpdateOverlay
(
overlay
,
NULL
,
primary
,
&
rect
,
DDOVER_SHOW
,
NULL
);
ok
(
SUCCEEDED
(
hr
),
"Failed to update overlay, hr %#x.
\n
"
,
hr
);
pos_x
=
-
1
;
pos_y
=
-
1
;
hr
=
IDirectDrawSurface_GetOverlayPosition
(
overlay
,
&
pos_x
,
&
pos_y
);
ok
(
SUCCEEDED
(
hr
),
"Failed to get overlay position, hr %#x.
\n
"
,
hr
);
ok
(
pos_x
==
rect
.
left
,
"Got unexpected pos_x %d, expected %d.
\n
"
,
pos_x
,
rect
.
left
);
ok
(
pos_y
==
rect
.
top
,
"Got unexpected pos_y %d, expected %d.
\n
"
,
pos_y
,
rect
.
top
);
/* Passing a NULL dest rect sets the position to 0/0. Visually it can be
* seen that the overlay overlays the whole primary(==screen). */
hr2
=
IDirectDrawSurface_UpdateOverlay
(
overlay
,
NULL
,
primary
,
NULL
,
0
,
NULL
);
ok
(
hr2
==
DD_OK
||
hr2
==
DDERR_INVALIDPARAMS
||
hr2
==
DDERR_OUTOFCAPS
,
"Got unexpected hr %#x.
\n
"
,
hr2
);
hr
=
IDirectDrawSurface_GetOverlayPosition
(
overlay
,
&
pos_x
,
&
pos_y
);
ok
(
SUCCEEDED
(
hr
),
"Failed to get overlay position, hr %#x.
\n
"
,
hr
);
if
(
SUCCEEDED
(
hr2
))
{
ok
(
!
pos_x
,
"Got unexpected pos_x %d.
\n
"
,
pos_x
);
ok
(
!
pos_y
,
"Got unexpected pos_y %d.
\n
"
,
pos_y
);
}
else
{
ok
(
pos_x
==
32
,
"Got unexpected pos_x %d.
\n
"
,
pos_x
);
ok
(
pos_y
==
16
,
"Got unexpected pos_y %d.
\n
"
,
pos_y
);
}
/* The position cannot be retrieved when the overlay is not shown. */
hr
=
IDirectDrawSurface_UpdateOverlay
(
overlay
,
NULL
,
primary
,
&
rect
,
DDOVER_HIDE
,
NULL
);
ok
(
SUCCEEDED
(
hr
),
"Failed to update overlay, hr %#x.
\n
"
,
hr
);
pos_x
=
-
1
;
pos_y
=
-
1
;
hr
=
IDirectDrawSurface_GetOverlayPosition
(
overlay
,
&
pos_x
,
&
pos_y
);
ok
(
hr
==
DDERR_OVERLAYNOTVISIBLE
,
"Got unexpected hr %#x.
\n
"
,
hr
);
ok
(
!
pos_x
,
"Got unexpected pos_x %d.
\n
"
,
pos_x
);
ok
(
!
pos_y
,
"Got unexpected pos_y %d.
\n
"
,
pos_y
);
IDirectDrawSurface_Release
(
primary
);
IDirectDrawSurface_Release
(
overlay
);
done:
IDirectDraw_Release
(
ddraw
);
DestroyWindow
(
window
);
}
START_TEST
(
ddraw1
)
{
IDirectDraw
*
ddraw
;
...
...
@@ -8485,4 +8578,5 @@ START_TEST(ddraw1)
test_lockrect_invalid
();
test_yv12_overlay
();
test_offscreen_overlay
();
test_overlay_rect
();
}
dlls/ddraw/tests/ddraw2.c
View file @
9628db25
...
...
@@ -9517,6 +9517,99 @@ done:
DestroyWindow
(
window
);
}
static
void
test_overlay_rect
(
void
)
{
IDirectDrawSurface
*
overlay
,
*
primary
;
DDSURFACEDESC
surface_desc
;
RECT
rect
=
{
0
,
0
,
64
,
64
};
IDirectDraw2
*
ddraw
;
LONG
pos_x
,
pos_y
;
HRESULT
hr
,
hr2
;
HWND
window
;
HDC
dc
;
window
=
CreateWindowA
(
"static"
,
"ddraw_test"
,
WS_OVERLAPPEDWINDOW
,
0
,
0
,
640
,
480
,
0
,
0
,
0
,
0
);
ddraw
=
create_ddraw
();
ok
(
!!
ddraw
,
"Failed to create a ddraw object.
\n
"
);
hr
=
IDirectDraw2_SetCooperativeLevel
(
ddraw
,
window
,
DDSCL_NORMAL
);
ok
(
SUCCEEDED
(
hr
),
"Failed to set cooperative level, hr %#x.
\n
"
,
hr
);
if
(
!
(
overlay
=
create_overlay
(
ddraw
,
64
,
64
,
MAKEFOURCC
(
'U'
,
'Y'
,
'V'
,
'Y'
))))
{
skip
(
"Failed to create a UYVY overlay, skipping test.
\n
"
);
goto
done
;
}
memset
(
&
surface_desc
,
0
,
sizeof
(
surface_desc
));
surface_desc
.
dwSize
=
sizeof
(
surface_desc
);
surface_desc
.
dwFlags
=
DDSD_CAPS
;
surface_desc
.
ddsCaps
.
dwCaps
=
DDSCAPS_PRIMARYSURFACE
;
hr
=
IDirectDraw2_CreateSurface
(
ddraw
,
&
surface_desc
,
&
primary
,
NULL
);
ok
(
SUCCEEDED
(
hr
),
"Failed to create surface, hr %#x.
\n
"
,
hr
);
/* On Windows 7, and probably Vista, UpdateOverlay() will return
* DDERR_OUTOFCAPS if the dwm is active. Calling GetDC() on the primary
* surface prevents this by disabling the dwm. */
hr
=
IDirectDrawSurface_GetDC
(
primary
,
&
dc
);
ok
(
SUCCEEDED
(
hr
),
"Failed to get DC, hr %#x.
\n
"
,
hr
);
hr
=
IDirectDrawSurface_ReleaseDC
(
primary
,
dc
);
ok
(
SUCCEEDED
(
hr
),
"Failed to release DC, hr %#x.
\n
"
,
hr
);
/* The dx sdk sort of implies that rect must be set when DDOVER_SHOW is
* used. This is not true in Windows Vista and earlier, but changed in
* Windows 7. */
hr
=
IDirectDrawSurface_UpdateOverlay
(
overlay
,
NULL
,
primary
,
&
rect
,
DDOVER_SHOW
,
NULL
);
ok
(
SUCCEEDED
(
hr
),
"Failed to update overlay, hr %#x.
\n
"
,
hr
);
hr
=
IDirectDrawSurface_UpdateOverlay
(
overlay
,
NULL
,
primary
,
NULL
,
DDOVER_HIDE
,
NULL
);
ok
(
SUCCEEDED
(
hr
),
"Failed to update overlay, hr %#x.
\n
"
,
hr
);
hr
=
IDirectDrawSurface_UpdateOverlay
(
overlay
,
NULL
,
primary
,
NULL
,
DDOVER_SHOW
,
NULL
);
ok
(
hr
==
DD_OK
||
hr
==
DDERR_INVALIDPARAMS
,
"Got unexpected hr %#x.
\n
"
,
hr
);
/* Show that the overlay position is the (top, left) coordinate of the
* destination rectangle. */
OffsetRect
(
&
rect
,
32
,
16
);
hr
=
IDirectDrawSurface_UpdateOverlay
(
overlay
,
NULL
,
primary
,
&
rect
,
DDOVER_SHOW
,
NULL
);
ok
(
SUCCEEDED
(
hr
),
"Failed to update overlay, hr %#x.
\n
"
,
hr
);
pos_x
=
-
1
;
pos_y
=
-
1
;
hr
=
IDirectDrawSurface_GetOverlayPosition
(
overlay
,
&
pos_x
,
&
pos_y
);
ok
(
SUCCEEDED
(
hr
),
"Failed to get overlay position, hr %#x.
\n
"
,
hr
);
ok
(
pos_x
==
rect
.
left
,
"Got unexpected pos_x %d, expected %d.
\n
"
,
pos_x
,
rect
.
left
);
ok
(
pos_y
==
rect
.
top
,
"Got unexpected pos_y %d, expected %d.
\n
"
,
pos_y
,
rect
.
top
);
/* Passing a NULL dest rect sets the position to 0/0. Visually it can be
* seen that the overlay overlays the whole primary(==screen). */
hr2
=
IDirectDrawSurface_UpdateOverlay
(
overlay
,
NULL
,
primary
,
NULL
,
0
,
NULL
);
ok
(
hr2
==
DD_OK
||
hr2
==
DDERR_INVALIDPARAMS
||
hr2
==
DDERR_OUTOFCAPS
,
"Got unexpected hr %#x.
\n
"
,
hr2
);
hr
=
IDirectDrawSurface_GetOverlayPosition
(
overlay
,
&
pos_x
,
&
pos_y
);
ok
(
SUCCEEDED
(
hr
),
"Failed to get overlay position, hr %#x.
\n
"
,
hr
);
if
(
SUCCEEDED
(
hr2
))
{
ok
(
!
pos_x
,
"Got unexpected pos_x %d.
\n
"
,
pos_x
);
ok
(
!
pos_y
,
"Got unexpected pos_y %d.
\n
"
,
pos_y
);
}
else
{
ok
(
pos_x
==
32
,
"Got unexpected pos_x %d.
\n
"
,
pos_x
);
ok
(
pos_y
==
16
,
"Got unexpected pos_y %d.
\n
"
,
pos_y
);
}
/* The position cannot be retrieved when the overlay is not shown. */
hr
=
IDirectDrawSurface_UpdateOverlay
(
overlay
,
NULL
,
primary
,
&
rect
,
DDOVER_HIDE
,
NULL
);
ok
(
SUCCEEDED
(
hr
),
"Failed to update overlay, hr %#x.
\n
"
,
hr
);
pos_x
=
-
1
;
pos_y
=
-
1
;
hr
=
IDirectDrawSurface_GetOverlayPosition
(
overlay
,
&
pos_x
,
&
pos_y
);
ok
(
hr
==
DDERR_OVERLAYNOTVISIBLE
,
"Got unexpected hr %#x.
\n
"
,
hr
);
ok
(
!
pos_x
,
"Got unexpected pos_x %d.
\n
"
,
pos_x
);
ok
(
!
pos_y
,
"Got unexpected pos_y %d.
\n
"
,
pos_y
);
IDirectDrawSurface_Release
(
primary
);
IDirectDrawSurface_Release
(
overlay
);
done:
IDirectDraw2_Release
(
ddraw
);
DestroyWindow
(
window
);
}
START_TEST
(
ddraw2
)
{
IDirectDraw2
*
ddraw
;
...
...
@@ -9599,4 +9692,5 @@ START_TEST(ddraw2)
test_lockrect_invalid
();
test_yv12_overlay
();
test_offscreen_overlay
();
test_overlay_rect
();
}
dlls/ddraw/tests/ddraw4.c
View file @
9628db25
...
...
@@ -10692,6 +10692,99 @@ done:
DestroyWindow
(
window
);
}
static
void
test_overlay_rect
(
void
)
{
IDirectDrawSurface4
*
overlay
,
*
primary
;
DDSURFACEDESC2
surface_desc
;
RECT
rect
=
{
0
,
0
,
64
,
64
};
IDirectDraw4
*
ddraw
;
LONG
pos_x
,
pos_y
;
HRESULT
hr
,
hr2
;
HWND
window
;
HDC
dc
;
window
=
CreateWindowA
(
"static"
,
"ddraw_test"
,
WS_OVERLAPPEDWINDOW
,
0
,
0
,
640
,
480
,
0
,
0
,
0
,
0
);
ddraw
=
create_ddraw
();
ok
(
!!
ddraw
,
"Failed to create a ddraw object.
\n
"
);
hr
=
IDirectDraw4_SetCooperativeLevel
(
ddraw
,
window
,
DDSCL_NORMAL
);
ok
(
SUCCEEDED
(
hr
),
"Failed to set cooperative level, hr %#x.
\n
"
,
hr
);
if
(
!
(
overlay
=
create_overlay
(
ddraw
,
64
,
64
,
MAKEFOURCC
(
'U'
,
'Y'
,
'V'
,
'Y'
))))
{
skip
(
"Failed to create a UYVY overlay, skipping test.
\n
"
);
goto
done
;
}
memset
(
&
surface_desc
,
0
,
sizeof
(
surface_desc
));
surface_desc
.
dwSize
=
sizeof
(
surface_desc
);
surface_desc
.
dwFlags
=
DDSD_CAPS
;
surface_desc
.
ddsCaps
.
dwCaps
=
DDSCAPS_PRIMARYSURFACE
;
hr
=
IDirectDraw4_CreateSurface
(
ddraw
,
&
surface_desc
,
&
primary
,
NULL
);
ok
(
SUCCEEDED
(
hr
),
"Failed to create surface, hr %#x.
\n
"
,
hr
);
/* On Windows 7, and probably Vista, UpdateOverlay() will return
* DDERR_OUTOFCAPS if the dwm is active. Calling GetDC() on the primary
* surface prevents this by disabling the dwm. */
hr
=
IDirectDrawSurface4_GetDC
(
primary
,
&
dc
);
ok
(
SUCCEEDED
(
hr
),
"Failed to get DC, hr %#x.
\n
"
,
hr
);
hr
=
IDirectDrawSurface4_ReleaseDC
(
primary
,
dc
);
ok
(
SUCCEEDED
(
hr
),
"Failed to release DC, hr %#x.
\n
"
,
hr
);
/* The dx sdk sort of implies that rect must be set when DDOVER_SHOW is
* used. This is not true in Windows Vista and earlier, but changed in
* Windows 7. */
hr
=
IDirectDrawSurface4_UpdateOverlay
(
overlay
,
NULL
,
primary
,
&
rect
,
DDOVER_SHOW
,
NULL
);
ok
(
SUCCEEDED
(
hr
),
"Failed to update overlay, hr %#x.
\n
"
,
hr
);
hr
=
IDirectDrawSurface4_UpdateOverlay
(
overlay
,
NULL
,
primary
,
NULL
,
DDOVER_HIDE
,
NULL
);
ok
(
SUCCEEDED
(
hr
),
"Failed to update overlay, hr %#x.
\n
"
,
hr
);
hr
=
IDirectDrawSurface4_UpdateOverlay
(
overlay
,
NULL
,
primary
,
NULL
,
DDOVER_SHOW
,
NULL
);
ok
(
hr
==
DD_OK
||
hr
==
DDERR_INVALIDPARAMS
,
"Got unexpected hr %#x.
\n
"
,
hr
);
/* Show that the overlay position is the (top, left) coordinate of the
* destination rectangle. */
OffsetRect
(
&
rect
,
32
,
16
);
hr
=
IDirectDrawSurface4_UpdateOverlay
(
overlay
,
NULL
,
primary
,
&
rect
,
DDOVER_SHOW
,
NULL
);
ok
(
SUCCEEDED
(
hr
),
"Failed to update overlay, hr %#x.
\n
"
,
hr
);
pos_x
=
-
1
;
pos_y
=
-
1
;
hr
=
IDirectDrawSurface4_GetOverlayPosition
(
overlay
,
&
pos_x
,
&
pos_y
);
ok
(
SUCCEEDED
(
hr
),
"Failed to get overlay position, hr %#x.
\n
"
,
hr
);
ok
(
pos_x
==
rect
.
left
,
"Got unexpected pos_x %d, expected %d.
\n
"
,
pos_x
,
rect
.
left
);
ok
(
pos_y
==
rect
.
top
,
"Got unexpected pos_y %d, expected %d.
\n
"
,
pos_y
,
rect
.
top
);
/* Passing a NULL dest rect sets the position to 0/0. Visually it can be
* seen that the overlay overlays the whole primary(==screen). */
hr2
=
IDirectDrawSurface4_UpdateOverlay
(
overlay
,
NULL
,
primary
,
NULL
,
0
,
NULL
);
ok
(
hr2
==
DD_OK
||
hr2
==
DDERR_INVALIDPARAMS
||
hr2
==
DDERR_OUTOFCAPS
,
"Got unexpected hr %#x.
\n
"
,
hr2
);
hr
=
IDirectDrawSurface4_GetOverlayPosition
(
overlay
,
&
pos_x
,
&
pos_y
);
ok
(
SUCCEEDED
(
hr
),
"Failed to get overlay position, hr %#x.
\n
"
,
hr
);
if
(
SUCCEEDED
(
hr2
))
{
ok
(
!
pos_x
,
"Got unexpected pos_x %d.
\n
"
,
pos_x
);
ok
(
!
pos_y
,
"Got unexpected pos_y %d.
\n
"
,
pos_y
);
}
else
{
ok
(
pos_x
==
32
,
"Got unexpected pos_x %d.
\n
"
,
pos_x
);
ok
(
pos_y
==
16
,
"Got unexpected pos_y %d.
\n
"
,
pos_y
);
}
/* The position cannot be retrieved when the overlay is not shown. */
hr
=
IDirectDrawSurface4_UpdateOverlay
(
overlay
,
NULL
,
primary
,
&
rect
,
DDOVER_HIDE
,
NULL
);
ok
(
SUCCEEDED
(
hr
),
"Failed to update overlay, hr %#x.
\n
"
,
hr
);
pos_x
=
-
1
;
pos_y
=
-
1
;
hr
=
IDirectDrawSurface4_GetOverlayPosition
(
overlay
,
&
pos_x
,
&
pos_y
);
ok
(
hr
==
DDERR_OVERLAYNOTVISIBLE
,
"Got unexpected hr %#x.
\n
"
,
hr
);
ok
(
!
pos_x
,
"Got unexpected pos_x %d.
\n
"
,
pos_x
);
ok
(
!
pos_y
,
"Got unexpected pos_y %d.
\n
"
,
pos_y
);
IDirectDrawSurface4_Release
(
primary
);
IDirectDrawSurface4_Release
(
overlay
);
done:
IDirectDraw4_Release
(
ddraw
);
DestroyWindow
(
window
);
}
START_TEST
(
ddraw4
)
{
IDirectDraw4
*
ddraw
;
...
...
@@ -10781,4 +10874,5 @@ START_TEST(ddraw4)
test_lockrect_invalid
();
test_yv12_overlay
();
test_offscreen_overlay
();
test_overlay_rect
();
}
dlls/ddraw/tests/ddraw7.c
View file @
9628db25
...
...
@@ -10971,6 +10971,99 @@ done:
DestroyWindow
(
window
);
}
static
void
test_overlay_rect
(
void
)
{
IDirectDrawSurface7
*
overlay
,
*
primary
;
DDSURFACEDESC2
surface_desc
;
RECT
rect
=
{
0
,
0
,
64
,
64
};
IDirectDraw7
*
ddraw
;
LONG
pos_x
,
pos_y
;
HRESULT
hr
,
hr2
;
HWND
window
;
HDC
dc
;
window
=
CreateWindowA
(
"static"
,
"ddraw_test"
,
WS_OVERLAPPEDWINDOW
,
0
,
0
,
640
,
480
,
0
,
0
,
0
,
0
);
ddraw
=
create_ddraw
();
ok
(
!!
ddraw
,
"Failed to create a ddraw object.
\n
"
);
hr
=
IDirectDraw7_SetCooperativeLevel
(
ddraw
,
window
,
DDSCL_NORMAL
);
ok
(
SUCCEEDED
(
hr
),
"Failed to set cooperative level, hr %#x.
\n
"
,
hr
);
if
(
!
(
overlay
=
create_overlay
(
ddraw
,
64
,
64
,
MAKEFOURCC
(
'U'
,
'Y'
,
'V'
,
'Y'
))))
{
skip
(
"Failed to create a UYVY overlay, skipping test.
\n
"
);
goto
done
;
}
memset
(
&
surface_desc
,
0
,
sizeof
(
surface_desc
));
surface_desc
.
dwSize
=
sizeof
(
surface_desc
);
surface_desc
.
dwFlags
=
DDSD_CAPS
;
surface_desc
.
ddsCaps
.
dwCaps
=
DDSCAPS_PRIMARYSURFACE
;
hr
=
IDirectDraw7_CreateSurface
(
ddraw
,
&
surface_desc
,
&
primary
,
NULL
);
ok
(
SUCCEEDED
(
hr
),
"Failed to create surface, hr %#x.
\n
"
,
hr
);
/* On Windows 7, and probably Vista, UpdateOverlay() will return
* DDERR_OUTOFCAPS if the dwm is active. Calling GetDC() on the primary
* surface prevents this by disabling the dwm. */
hr
=
IDirectDrawSurface7_GetDC
(
primary
,
&
dc
);
ok
(
SUCCEEDED
(
hr
),
"Failed to get DC, hr %#x.
\n
"
,
hr
);
hr
=
IDirectDrawSurface7_ReleaseDC
(
primary
,
dc
);
ok
(
SUCCEEDED
(
hr
),
"Failed to release DC, hr %#x.
\n
"
,
hr
);
/* The dx sdk sort of implies that rect must be set when DDOVER_SHOW is
* used. This is not true in Windows Vista and earlier, but changed in
* Windows 7. */
hr
=
IDirectDrawSurface7_UpdateOverlay
(
overlay
,
NULL
,
primary
,
&
rect
,
DDOVER_SHOW
,
NULL
);
ok
(
SUCCEEDED
(
hr
),
"Failed to update overlay, hr %#x.
\n
"
,
hr
);
hr
=
IDirectDrawSurface7_UpdateOverlay
(
overlay
,
NULL
,
primary
,
NULL
,
DDOVER_HIDE
,
NULL
);
ok
(
SUCCEEDED
(
hr
),
"Failed to update overlay, hr %#x.
\n
"
,
hr
);
hr
=
IDirectDrawSurface7_UpdateOverlay
(
overlay
,
NULL
,
primary
,
NULL
,
DDOVER_SHOW
,
NULL
);
ok
(
hr
==
DD_OK
||
hr
==
DDERR_INVALIDPARAMS
,
"Got unexpected hr %#x.
\n
"
,
hr
);
/* Show that the overlay position is the (top, left) coordinate of the
* destination rectangle. */
OffsetRect
(
&
rect
,
32
,
16
);
hr
=
IDirectDrawSurface7_UpdateOverlay
(
overlay
,
NULL
,
primary
,
&
rect
,
DDOVER_SHOW
,
NULL
);
ok
(
SUCCEEDED
(
hr
),
"Failed to update overlay, hr %#x.
\n
"
,
hr
);
pos_x
=
-
1
;
pos_y
=
-
1
;
hr
=
IDirectDrawSurface7_GetOverlayPosition
(
overlay
,
&
pos_x
,
&
pos_y
);
ok
(
SUCCEEDED
(
hr
),
"Failed to get overlay position, hr %#x.
\n
"
,
hr
);
ok
(
pos_x
==
rect
.
left
,
"Got unexpected pos_x %d, expected %d.
\n
"
,
pos_x
,
rect
.
left
);
ok
(
pos_y
==
rect
.
top
,
"Got unexpected pos_y %d, expected %d.
\n
"
,
pos_y
,
rect
.
top
);
/* Passing a NULL dest rect sets the position to 0/0. Visually it can be
* seen that the overlay overlays the whole primary(==screen). */
hr2
=
IDirectDrawSurface7_UpdateOverlay
(
overlay
,
NULL
,
primary
,
NULL
,
0
,
NULL
);
ok
(
hr2
==
DD_OK
||
hr2
==
DDERR_INVALIDPARAMS
||
hr2
==
DDERR_OUTOFCAPS
,
"Got unexpected hr %#x.
\n
"
,
hr2
);
hr
=
IDirectDrawSurface7_GetOverlayPosition
(
overlay
,
&
pos_x
,
&
pos_y
);
ok
(
SUCCEEDED
(
hr
),
"Failed to get overlay position, hr %#x.
\n
"
,
hr
);
if
(
SUCCEEDED
(
hr2
))
{
ok
(
!
pos_x
,
"Got unexpected pos_x %d.
\n
"
,
pos_x
);
ok
(
!
pos_y
,
"Got unexpected pos_y %d.
\n
"
,
pos_y
);
}
else
{
ok
(
pos_x
==
32
,
"Got unexpected pos_x %d.
\n
"
,
pos_x
);
ok
(
pos_y
==
16
,
"Got unexpected pos_y %d.
\n
"
,
pos_y
);
}
/* The position cannot be retrieved when the overlay is not shown. */
hr
=
IDirectDrawSurface7_UpdateOverlay
(
overlay
,
NULL
,
primary
,
&
rect
,
DDOVER_HIDE
,
NULL
);
ok
(
SUCCEEDED
(
hr
),
"Failed to update overlay, hr %#x.
\n
"
,
hr
);
pos_x
=
-
1
;
pos_y
=
-
1
;
hr
=
IDirectDrawSurface7_GetOverlayPosition
(
overlay
,
&
pos_x
,
&
pos_y
);
ok
(
hr
==
DDERR_OVERLAYNOTVISIBLE
,
"Got unexpected hr %#x.
\n
"
,
hr
);
ok
(
!
pos_x
,
"Got unexpected pos_x %d.
\n
"
,
pos_x
);
ok
(
!
pos_y
,
"Got unexpected pos_y %d.
\n
"
,
pos_y
);
IDirectDrawSurface7_Release
(
primary
);
IDirectDrawSurface7_Release
(
overlay
);
done:
IDirectDraw7_Release
(
ddraw
);
DestroyWindow
(
window
);
}
START_TEST
(
ddraw7
)
{
HMODULE
module
=
GetModuleHandleA
(
"ddraw.dll"
);
...
...
@@ -11071,4 +11164,5 @@ START_TEST(ddraw7)
test_lockrect_invalid
();
test_yv12_overlay
();
test_offscreen_overlay
();
test_overlay_rect
();
}
dlls/ddraw/tests/overlay.c
deleted
100644 → 0
View file @
03ef393a
/*
* Unit tests for DirectDraw overlay functions
*
* Copyright (C) 2008,2011 Stefan Dösinger for CodeWeavers
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#define COBJMACROS
#include "wine/test.h"
#include "ddraw.h"
#include "unknwn.h"
static
HRESULT
(
WINAPI
*
pDirectDrawCreateEx
)(
GUID
*
driver_guid
,
void
**
ddraw
,
REFIID
interface_iid
,
IUnknown
*
outer
);
static
IDirectDraw7
*
ddraw
=
NULL
;
static
IDirectDrawSurface7
*
primary
=
NULL
;
static
IDirectDrawSurface7
*
create_overlay
(
DWORD
width
,
DWORD
height
,
DWORD
format
)
{
DDSURFACEDESC2
ddsd
;
HRESULT
hr
;
IDirectDrawSurface7
*
ret
;
memset
(
&
ddsd
,
0
,
sizeof
(
ddsd
));
ddsd
.
dwSize
=
sizeof
(
ddsd
);
ddsd
.
dwFlags
=
DDSD_CAPS
|
DDSD_HEIGHT
|
DDSD_WIDTH
|
DDSD_PIXELFORMAT
;
ddsd
.
dwWidth
=
width
;
ddsd
.
dwHeight
=
height
;
ddsd
.
ddsCaps
.
dwCaps
=
DDSCAPS_OVERLAY
;
U4
(
ddsd
).
ddpfPixelFormat
.
dwSize
=
sizeof
(
U4
(
ddsd
).
ddpfPixelFormat
);
U4
(
ddsd
).
ddpfPixelFormat
.
dwFlags
=
DDPF_FOURCC
;
U4
(
ddsd
).
ddpfPixelFormat
.
dwFourCC
=
format
;
hr
=
IDirectDraw7_CreateSurface
(
ddraw
,
&
ddsd
,
&
ret
,
NULL
);
if
(
FAILED
(
hr
))
return
NULL
;
else
return
ret
;
}
static
BOOL
CreateDirectDraw
(
void
)
{
HRESULT
hr
;
DDSURFACEDESC2
ddsd
;
IDirectDrawSurface7
*
overlay
=
NULL
;
HMODULE
hmod
=
GetModuleHandleA
(
"ddraw.dll"
);
pDirectDrawCreateEx
=
(
void
*
)
GetProcAddress
(
hmod
,
"DirectDrawCreateEx"
);
if
(
!
pDirectDrawCreateEx
)
{
win_skip
(
"DirectDrawCreateEx is not available
\n
"
);
return
FALSE
;
}
hr
=
pDirectDrawCreateEx
(
NULL
,
(
void
**
)
&
ddraw
,
&
IID_IDirectDraw7
,
NULL
);
ok
(
hr
==
DD_OK
||
hr
==
DDERR_NODIRECTDRAWSUPPORT
,
"DirectDrawCreateEx returned: %x
\n
"
,
hr
);
if
(
!
ddraw
)
{
trace
(
"DirectDrawCreateEx() failed with an error %x
\n
"
,
hr
);
return
FALSE
;
}
hr
=
IDirectDraw_SetCooperativeLevel
(
ddraw
,
NULL
,
DDSCL_NORMAL
);
ok
(
hr
==
DD_OK
,
"SetCooperativeLevel returned: %x
\n
"
,
hr
);
memset
(
&
ddsd
,
0
,
sizeof
(
ddsd
));
ddsd
.
dwSize
=
sizeof
(
ddsd
);
ddsd
.
dwFlags
=
DDSD_CAPS
;
ddsd
.
ddsCaps
.
dwCaps
=
DDSCAPS_PRIMARYSURFACE
;
hr
=
IDirectDraw7_CreateSurface
(
ddraw
,
&
ddsd
,
&
primary
,
NULL
);
if
(
FAILED
(
hr
))
{
IDirectDraw7_Release
(
ddraw
);
trace
(
"IDirectDraw7_CreateSurface() failed with an error %x
\n
"
,
hr
);
return
FALSE
;
}
overlay
=
create_overlay
(
64
,
64
,
MAKEFOURCC
(
'U'
,
'Y'
,
'V'
,
'Y'
));
if
(
!
overlay
)
{
IDirectDrawSurface7_Release
(
primary
);
IDirectDraw7_Release
(
ddraw
);
skip
(
"Failed to create an overlay - assuming not supported
\n
"
);
return
FALSE
;
}
IDirectDraw7_Release
(
overlay
);
return
TRUE
;
}
static
void
rectangle_settings
(
void
)
{
IDirectDrawSurface7
*
overlay
=
create_overlay
(
64
,
64
,
MAKEFOURCC
(
'U'
,
'Y'
,
'V'
,
'Y'
));
HRESULT
hr
,
hr2
;
RECT
rect
=
{
0
,
0
,
64
,
64
};
LONG
posx
,
posy
;
/* The dx sdk sort of implies that rect must be set when DDOVER_SHOW is used. This is not true
* in Windows Vista and earlier, but changed in Win7 */
hr
=
IDirectDrawSurface7_UpdateOverlay
(
overlay
,
NULL
,
primary
,
&
rect
,
DDOVER_SHOW
,
NULL
);
ok
(
hr
==
DD_OK
,
"IDirectDrawSurface7_UpdateOverlay failed with hr=0x%08x
\n
"
,
hr
);
hr
=
IDirectDrawSurface7_UpdateOverlay
(
overlay
,
NULL
,
primary
,
NULL
,
DDOVER_HIDE
,
NULL
);
ok
(
hr
==
DD_OK
,
"IDirectDrawSurface7_UpdateOverlay failed with hr=0x%08x
\n
"
,
hr
);
hr
=
IDirectDrawSurface7_UpdateOverlay
(
overlay
,
NULL
,
primary
,
NULL
,
DDOVER_SHOW
,
NULL
);
ok
(
hr
==
DD_OK
||
hr
==
DDERR_INVALIDPARAMS
,
"IDirectDrawSurface7_UpdateOverlay failed with hr=0x%08x
\n
"
,
hr
);
/* Show that the overlay position is the (top, left) coordinate of the dest rectangle */
rect
.
top
+=
16
;
rect
.
left
+=
32
;
rect
.
bottom
+=
16
;
rect
.
right
+=
32
;
hr
=
IDirectDrawSurface7_UpdateOverlay
(
overlay
,
NULL
,
primary
,
&
rect
,
DDOVER_SHOW
,
NULL
);
ok
(
hr
==
DD_OK
,
"IDirectDrawSurface7_UpdateOverlay failed with hr=0x%08x
\n
"
,
hr
);
posx
=
-
1
;
posy
=
-
1
;
hr
=
IDirectDrawSurface7_GetOverlayPosition
(
overlay
,
&
posx
,
&
posy
);
ok
(
hr
==
DD_OK
,
"IDirectDrawSurface7_GetOverlayPosition failed with hr=0x%08x
\n
"
,
hr
);
ok
(
posx
==
rect
.
left
&&
posy
==
rect
.
top
,
"Overlay position is (%d, %d), expected (%d, %d)
\n
"
,
posx
,
posy
,
rect
.
left
,
rect
.
top
);
/* Passing a NULL dest rect sets the position to 0/0 . Visually it can be seen that the overlay overlays the whole primary(==screen)*/
hr2
=
IDirectDrawSurface7_UpdateOverlay
(
overlay
,
NULL
,
primary
,
NULL
,
0
,
NULL
);
ok
(
hr2
==
DD_OK
||
hr2
==
DDERR_INVALIDPARAMS
||
hr2
==
DDERR_OUTOFCAPS
,
"IDirectDrawSurface7_UpdateOverlay failed with hr=0x%08x
\n
"
,
hr2
);
hr
=
IDirectDrawSurface7_GetOverlayPosition
(
overlay
,
&
posx
,
&
posy
);
ok
(
hr
==
DD_OK
,
"IDirectDrawSurface7_GetOverlayPosition failed with hr=0x%08x
\n
"
,
hr
);
if
(
SUCCEEDED
(
hr2
))
{
ok
(
posx
==
0
&&
posy
==
0
,
"Overlay position is (%d, %d), expected (%d, %d)
\n
"
,
posx
,
posy
,
0
,
0
);
}
else
{
/* Otherwise the position remains untouched */
ok
(
posx
==
32
&&
posy
==
16
,
"Overlay position is (%d, %d), expected (%d, %d)
\n
"
,
posx
,
posy
,
32
,
16
);
}
/* The position cannot be retrieved when the overlay is not shown */
hr
=
IDirectDrawSurface7_UpdateOverlay
(
overlay
,
NULL
,
primary
,
&
rect
,
DDOVER_HIDE
,
NULL
);
ok
(
hr
==
DD_OK
,
"IDirectDrawSurface7_UpdateOverlay failed with hr=0x%08x
\n
"
,
hr
);
posx
=
-
1
;
posy
=
-
1
;
hr
=
IDirectDrawSurface7_GetOverlayPosition
(
overlay
,
&
posx
,
&
posy
);
ok
(
hr
==
DDERR_OVERLAYNOTVISIBLE
,
"IDirectDrawSurface7_GetOverlayPosition failed with hr=0x%08x
\n
"
,
hr
);
ok
(
posx
==
0
&&
posy
==
0
,
"Overlay position is (%d, %d), expected (%d, %d)
\n
"
,
posx
,
posy
,
0
,
0
);
IDirectDrawSurface7_Release
(
overlay
);
}
START_TEST
(
overlay
)
{
if
(
CreateDirectDraw
()
==
FALSE
)
{
skip
(
"Failed to initialize ddraw
\n
"
);
return
;
}
rectangle_settings
();
if
(
primary
)
IDirectDrawSurface7_Release
(
primary
);
if
(
ddraw
)
IDirectDraw7_Release
(
ddraw
);
}
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