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
8b17b0f5
Commit
8b17b0f5
authored
May 04, 2012
by
Józef Kucia
Committed by
Alexandre Julliard
May 07, 2012
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
d3dx9/tests: Add tests for D3DXSaveSurfaceToFile.
parent
f0bb4255
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
84 additions
and
0 deletions
+84
-0
surface.c
dlls/d3dx9_36/tests/surface.c
+84
-0
No files found.
dlls/d3dx9_36/tests/surface.c
View file @
8b17b0f5
...
...
@@ -917,6 +917,89 @@ static void test_D3DXCreateVolumeTexture(IDirect3DDevice9 *device)
}
}
static
void
test_D3DXSaveSurfaceToFile
(
IDirect3DDevice9
*
device
)
{
HRESULT
hr
;
IDirect3DSurface9
*
surface
;
RECT
rect
;
D3DLOCKED_RECT
lock_rect
;
D3DXIMAGE_INFO
image_info
;
const
BYTE
pixels
[]
=
{
0xff
,
0x00
,
0x00
,
0x00
,
0xff
,
0x00
,
0x00
,
0x00
,
0xff
,
0x00
,
0x00
,
0xff
};
DWORD
pitch
=
sizeof
(
pixels
)
/
2
;
hr
=
IDirect3DDevice9_CreateOffscreenPlainSurface
(
device
,
2
,
2
,
D3DFMT_R8G8B8
,
D3DPOOL_SCRATCH
,
&
surface
,
NULL
);
if
(
FAILED
(
hr
))
{
skip
(
"Couldn't create surface
\n
"
);
return
;
}
SetRect
(
&
rect
,
0
,
0
,
2
,
2
);
hr
=
D3DXLoadSurfaceFromMemory
(
surface
,
NULL
,
NULL
,
pixels
,
D3DFMT_R8G8B8
,
pitch
,
NULL
,
&
rect
,
D3DX_FILTER_NONE
,
0
);
if
(
SUCCEEDED
(
hr
))
{
hr
=
D3DXSaveSurfaceToFileA
(
"saved_surface.bmp"
,
D3DXIFF_BMP
,
surface
,
NULL
,
NULL
);
ok
(
hr
==
D3D_OK
,
"D3DXSaveSurfaceToFileA returned %#x, expected %#x
\n
"
,
hr
,
D3D_OK
);
hr
=
D3DXLoadSurfaceFromFileA
(
surface
,
NULL
,
NULL
,
"saved_surface.bmp"
,
NULL
,
D3DX_FILTER_NONE
,
0
,
&
image_info
);
ok
(
hr
==
D3D_OK
,
"Couldn't load saved surface %#x
\n
"
,
hr
);
if
(
FAILED
(
hr
))
goto
next_tests
;
ok
(
image_info
.
Width
==
2
,
"Wrong width %u
\n
"
,
image_info
.
Width
);
ok
(
image_info
.
Height
==
2
,
"Wrong height %u
\n
"
,
image_info
.
Height
);
ok
(
image_info
.
Format
==
D3DFMT_R8G8B8
,
"Wrong format %#x
\n
"
,
image_info
.
Format
);
ok
(
image_info
.
ImageFileFormat
==
D3DXIFF_BMP
,
"Wrong file format %u
\n
"
,
image_info
.
ImageFileFormat
);
hr
=
IDirect3DSurface9_LockRect
(
surface
,
&
lock_rect
,
NULL
,
D3DLOCK_READONLY
);
ok
(
hr
==
D3D_OK
,
"Couldn't lock surface %#x
\n
"
,
hr
);
if
(
FAILED
(
hr
))
goto
next_tests
;
ok
(
!
memcmp
(
lock_rect
.
pBits
,
pixels
,
pitch
),
"Pixel data mismatch in first row
\n
"
);
ok
(
!
memcmp
((
BYTE
*
)
lock_rect
.
pBits
+
lock_rect
.
Pitch
,
pixels
+
pitch
,
pitch
),
"Pixel data mismatch in second row
\n
"
);
IDirect3DSurface9_UnlockRect
(
surface
);
}
else
skip
(
"Couldn't fill surface
\n
"
);
next_tests:
hr
=
D3DXSaveSurfaceToFileA
(
NULL
,
D3DXIFF_BMP
,
surface
,
NULL
,
NULL
);
ok
(
hr
==
D3DERR_INVALIDCALL
,
"D3DXSaveSurfaceToFileA returned %#x, expected %#x
\n
"
,
hr
,
D3DERR_INVALIDCALL
);
/* PPM and TGA are supported, even though MSDN claims they aren't */
todo_wine
{
hr
=
D3DXSaveSurfaceToFileA
(
"saved_surface.ppm"
,
D3DXIFF_PPM
,
surface
,
NULL
,
NULL
);
ok
(
hr
==
D3D_OK
,
"D3DXSaveSurfaceToFileA returned %#x, expected %#x
\n
"
,
hr
,
D3D_OK
);
hr
=
D3DXSaveSurfaceToFileA
(
"saved_surface.tga"
,
D3DXIFF_TGA
,
surface
,
NULL
,
NULL
);
ok
(
hr
==
D3D_OK
,
"D3DXSaveSurfaceToFileA returned %#x, expected %#x
\n
"
,
hr
,
D3D_OK
);
hr
=
D3DXSaveSurfaceToFileA
(
"saved_surface.dds"
,
D3DXIFF_DDS
,
surface
,
NULL
,
NULL
);
ok
(
hr
==
D3D_OK
,
"D3DXSaveSurfaceToFileA returned %#x, expected %#x
\n
"
,
hr
,
D3D_OK
);
}
hr
=
D3DXSaveSurfaceToFileA
(
"saved_surface"
,
D3DXIFF_PFM
+
1
,
surface
,
NULL
,
NULL
);
ok
(
hr
==
D3DERR_INVALIDCALL
,
"D3DXSaveSurfaceToFileA returned %#x, expected %#x
\n
"
,
hr
,
D3DERR_INVALIDCALL
);
SetRect
(
&
rect
,
0
,
0
,
4
,
4
);
hr
=
D3DXSaveSurfaceToFileA
(
"saved_surface.bmp"
,
D3DXIFF_BMP
,
surface
,
NULL
,
&
rect
);
ok
(
hr
==
D3DERR_INVALIDCALL
,
"D3DXSaveSurfaceToFileA returned %#x, expected %#x
\n
"
,
hr
,
D3DERR_INVALIDCALL
);
SetRect
(
&
rect
,
2
,
0
,
1
,
4
);
hr
=
D3DXSaveSurfaceToFileA
(
"saved_surface.bmp"
,
D3DXIFF_BMP
,
surface
,
NULL
,
&
rect
);
ok
(
hr
==
D3DERR_INVALIDCALL
,
"D3DXSaveSurfaceToFileA returned %#x, expected %#x
\n
"
,
hr
,
D3DERR_INVALIDCALL
);
SetRect
(
&
rect
,
0
,
2
,
4
,
1
);
hr
=
D3DXSaveSurfaceToFileA
(
"saved_surface.bmp"
,
D3DXIFF_BMP
,
surface
,
NULL
,
&
rect
);
ok
(
hr
==
D3DERR_INVALIDCALL
,
"D3DXSaveSurfaceToFileA returned %#x, expected %#x
\n
"
,
hr
,
D3DERR_INVALIDCALL
);
SetRect
(
&
rect
,
-
1
,
-
1
,
2
,
2
);
hr
=
D3DXSaveSurfaceToFileA
(
"saved_surface.bmp"
,
D3DXIFF_BMP
,
surface
,
NULL
,
&
rect
);
ok
(
hr
==
D3DERR_INVALIDCALL
,
"D3DXSaveSurfaceToFileA returned %#x, expected %#x
\n
"
,
hr
,
D3DERR_INVALIDCALL
);
SetRect
(
&
rect
,
0
,
0
,
0
,
0
);
hr
=
D3DXSaveSurfaceToFileA
(
"saved_surface.bmp"
,
D3DXIFF_BMP
,
surface
,
NULL
,
&
rect
);
ok
(
hr
==
D3D_OK
,
"D3DXSaveSurfaceToFileA returned %#x, expected %#x
\n
"
,
hr
,
D3D_OK
);
DeleteFileA
(
"saved_surface.bmp"
);
DeleteFileA
(
"saved_surface.ppm"
);
DeleteFileA
(
"saved_surface.tga"
);
DeleteFileA
(
"saved_surface.dds"
);
IDirect3DSurface9_Release
(
surface
);
}
START_TEST
(
surface
)
{
HWND
wnd
;
...
...
@@ -952,6 +1035,7 @@ START_TEST(surface)
test_D3DXLoadSurface
(
device
);
test_D3DXCreateCubeTexture
(
device
);
test_D3DXCreateVolumeTexture
(
device
);
test_D3DXSaveSurfaceToFile
(
device
);
check_release
((
IUnknown
*
)
device
,
0
);
check_release
((
IUnknown
*
)
d3d
,
0
);
...
...
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