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
225f142c
Commit
225f142c
authored
Feb 16, 2004
by
Sami Aario
Committed by
Alexandre Julliard
Feb 16, 2004
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added surface tests.
parent
d6993619
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
110 additions
and
29 deletions
+110
-29
ddrawmodes.c
dlls/ddraw/tests/ddrawmodes.c
+110
-29
No files found.
dlls/ddraw/tests/ddrawmodes.c
View file @
225f142c
...
...
@@ -28,7 +28,9 @@
#define UNION_MEMBER(x, y) y
#endif
static
LPDIRECTDRAW
lpDD
;
static
LPDIRECTDRAW
lpDD
=
NULL
;
static
LPDIRECTDRAWSURFACE
lpDDSPrimary
=
NULL
;
static
LPDIRECTDRAWSURFACE
lpDDSBack
=
NULL
;
static
WNDCLASS
wc
;
static
HWND
hwnd
;
static
int
modes_cnt
;
...
...
@@ -57,8 +59,7 @@ static void createdirectdraw()
GetSystemMetrics
(
SM_CXSCREEN
),
GetSystemMetrics
(
SM_CYSCREEN
),
NULL
,
NULL
,
GetModuleHandleA
(
0
),
NULL
);
if
(
hwnd
==
NULL
)
assert
(
0
);
assert
(
hwnd
!=
NULL
);
ShowWindow
(
hwnd
,
SW_HIDE
);
UpdateWindow
(
hwnd
);
...
...
@@ -68,7 +69,17 @@ static void createdirectdraw()
ok
(
rc
==
DD_OK
,
"DirectDrawCreate returned: %lx
\n
"
,
rc
);
}
static
void
add_mode
(
LPDDSURFACEDESC
lpddsd
)
static
void
releasedirectdraw
()
{
if
(
lpDD
!=
NULL
)
{
IDirectDraw_Release
(
lpDD
);
lpDD
=
NULL
;
}
}
static
void
adddisplaymode
(
LPDDSURFACEDESC
lpddsd
)
{
if
(
!
modes
)
modes
=
malloc
((
modes_size
=
2
)
*
sizeof
(
DDSURFACEDESC
));
...
...
@@ -78,19 +89,19 @@ static void add_mode(LPDDSURFACEDESC lpddsd)
modes
[
modes_cnt
++
]
=
*
lpddsd
;
}
static
void
flush
_
modes
()
static
void
flush
display
modes
()
{
free
(
modes
);
modes
=
0
;
modes_cnt
=
modes_size
=
0
;
}
HRESULT
WINAPI
enummodes
_
callback
(
LPDDSURFACEDESC
lpddsd
,
LPVOID
lpContext
)
HRESULT
WINAPI
enummodescallback
(
LPDDSURFACEDESC
lpddsd
,
LPVOID
lpContext
)
{
trace
(
"Width = %l
x, Height = %lx, Refresh Rate = %lx
\r\n
"
,
trace
(
"Width = %l
i, Height = %li, Refresh Rate = %li
\r\n
"
,
lpddsd
->
dwWidth
,
lpddsd
->
dwHeight
,
lpddsd
->
UNION_MEMBER
(
2
,
dwRefreshRate
));
add
_
mode
(
lpddsd
);
add
display
mode
(
lpddsd
);
return
DDENUMRET_OK
;
}
...
...
@@ -106,39 +117,109 @@ void enumdisplaymodes()
ddsd
.
ddsCaps
.
dwCaps
=
DDSCAPS_PRIMARYSURFACE
;
rc
=
IDirectDraw_EnumDisplayModes
(
lpDD
,
DDEDM_STANDARDVGAMODES
,
&
ddsd
,
0
,
enummodes
_
callback
);
DDEDM_STANDARDVGAMODES
,
&
ddsd
,
0
,
enummodescallback
);
ok
(
rc
==
DD_OK
,
"EnumDisplayModes returned: %lx
\n
"
,
rc
);
}
static
void
setdisplaymode
_tests
(
)
static
void
setdisplaymode
(
int
i
)
{
HRESULT
rc
;
int
i
;
rc
=
IDirectDraw_SetCooperativeLevel
(
lpDD
,
hwnd
,
DDSCL_ALLOWMODEX
|
DDSCL_EXCLUSIVE
|
DDSCL_FULLSCREEN
);
ok
(
rc
==
DD_OK
,
"SetCooperativeLevel returned: %lx
\n
"
,
rc
);
if
(
modes
[
i
].
dwFlags
&
DDSD_PIXELFORMAT
)
{
if
(
modes
[
i
].
ddpfPixelFormat
.
dwFlags
&
DDPF_RGB
)
{
rc
=
IDirectDraw_SetDisplayMode
(
lpDD
,
modes
[
i
].
dwWidth
,
modes
[
i
].
dwHeight
,
modes
[
i
].
ddpfPixelFormat
.
UNION_MEMBER
(
1
,
dwRGBBitCount
));
ok
(
rc
==
DD_OK
,
"SetDisplayMode returned: %lx
\n
"
,
rc
);
rc
=
IDirectDraw_RestoreDisplayMode
(
lpDD
);
ok
(
rc
==
DD_OK
,
"RestoreDisplayMode returned: %lx
\n
"
,
rc
);
}
}
}
static
void
createsurface
()
{
DDSURFACEDESC
ddsd
;
DDSCAPS
ddscaps
;
HRESULT
rc
;
createdirectdraw
();
enumdisplaymodes
();
for
(
i
=
0
;
i
<
modes_cnt
;
++
i
)
ddsd
.
dwSize
=
sizeof
(
ddsd
);
ddsd
.
dwFlags
=
DDSD_CAPS
|
DDSD_BACKBUFFERCOUNT
;
ddsd
.
ddsCaps
.
dwCaps
=
DDSCAPS_PRIMARYSURFACE
|
DDSCAPS_FLIP
|
DDSCAPS_COMPLEX
;
ddsd
.
dwBackBufferCount
=
1
;
rc
=
IDirectDraw_CreateSurface
(
lpDD
,
&
ddsd
,
&
lpDDSPrimary
,
NULL
);
ok
(
rc
==
DD_OK
,
"CreateSurface returned: %lx
\n
"
,
rc
);
ddscaps
.
dwCaps
=
DDSCAPS_BACKBUFFER
;
rc
=
IDirectDrawSurface_GetAttachedSurface
(
lpDDSPrimary
,
&
ddscaps
,
&
lpDDSBack
);
ok
(
rc
==
DD_OK
,
"GetAttachedSurface returned: %lx
\n
"
,
rc
);
}
static
void
destroysurface
()
{
if
(
lpDDSPrimary
!=
NULL
)
{
rc
=
IDirectDraw_SetCooperativeLevel
(
lpDD
,
hwnd
,
DDSCL_ALLOWMODEX
|
DDSCL_EXCLUSIVE
|
DDSCL_FULLSCREEN
);
ok
(
rc
==
DD_OK
,
"SetCooperativeLevel returned: %lx
\n
"
,
rc
);
if
(
modes
[
i
].
dwFlags
&
DDSD_PIXELFORMAT
)
IDirectDrawSurface_Release
(
lpDDSPrimary
);
lpDDSPrimary
=
NULL
;
}
}
static
void
testsurface
()
{
const
char
*
testMsg
=
"ddraw device context test"
;
HDC
hdc
;
HRESULT
rc
;
rc
=
IDirectDrawSurface_GetDC
(
lpDDSBack
,
&
hdc
);
ok
(
rc
==
DD_OK
,
"IDirectDrawSurface_GetDC returned: %lx
\n
"
,
rc
);
SetBkColor
(
hdc
,
RGB
(
0
,
0
,
255
));
SetTextColor
(
hdc
,
RGB
(
255
,
255
,
0
));
TextOut
(
hdc
,
0
,
0
,
testMsg
,
lstrlen
(
testMsg
));
IDirectDrawSurface_ReleaseDC
(
lpDDSBack
,
hdc
);
ok
(
rc
==
DD_OK
,
"IDirectDrawSurface_ReleaseDC returned: %lx
\n
"
,
rc
);
while
(
1
)
{
rc
=
IDirectDrawSurface_Flip
(
lpDDSPrimary
,
NULL
,
DDFLIP_WAIT
);
ok
(
rc
==
DD_OK
||
rc
==
DDERR_SURFACELOST
,
"IDirectDrawSurface_BltFast returned: %lx
\n
"
,
rc
);
if
(
rc
==
DD_OK
)
{
break
;
}
else
if
(
rc
==
DDERR_SURFACELOST
)
{
if
(
modes
[
i
].
ddpfPixelFormat
.
dwFlags
&
DDPF_RGB
)
{
rc
=
IDirectDraw_SetDisplayMode
(
lpDD
,
modes
[
i
].
dwWidth
,
modes
[
i
].
dwHeight
,
modes
[
i
].
ddpfPixelFormat
.
UNION_MEMBER
(
1
,
dwRGBBitCount
));
ok
(
rc
==
DD_OK
,
"SetDisplayMode returned: %lx
\n
"
,
rc
);
rc
=
IDirectDraw_RestoreDisplayMode
(
lpDD
);
ok
(
rc
==
DD_OK
,
"RestoreDisplayMode returned: %lx
\n
"
,
rc
);
}
rc
=
IDirectDrawSurface_Restore
(
lpDDSPrimary
);
ok
(
rc
==
DD_OK
,
"IDirectDrawSurface_Restore returned: %lx
\n
"
,
rc
);
}
}
flush_modes
();
}
static
void
testdisplaymodes
()
{
int
i
;
for
(
i
=
0
;
i
<
modes_cnt
;
++
i
)
{
setdisplaymode
(
i
);
createsurface
();
testsurface
();
destroysurface
();
}
}
START_TEST
(
ddrawmodes
)
{
setdisplaymode_tests
();
createdirectdraw
();
enumdisplaymodes
();
testdisplaymodes
();
flushdisplaymodes
();
releasedirectdraw
();
}
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