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
208d3868
Commit
208d3868
authored
Jun 08, 2007
by
Stefan Dösinger
Committed by
Alexandre Julliard
Jun 22, 2007
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ddraw: Check for incorrect rectangles to DDrawSurface::Blt.
parent
e019cebd
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
73 additions
and
0 deletions
+73
-0
surface.c
dlls/ddraw/surface.c
+24
-0
dsurface.c
dlls/ddraw/tests/dsurface.c
+49
-0
No files found.
dlls/ddraw/surface.c
View file @
208d3868
...
...
@@ -753,7 +753,31 @@ IDirectDrawSurfaceImpl_Blt(IDirectDrawSurface7 *iface,
return
DDERR_INVALIDPARAMS
;
}
/* Sizes can change, therefore hold the lock when testing the rectangles */
EnterCriticalSection
(
&
ddraw_cs
);
if
(
DestRect
)
{
if
(
DestRect
->
top
>=
DestRect
->
bottom
||
DestRect
->
left
>=
DestRect
->
right
||
DestRect
->
right
>
This
->
surface_desc
.
dwWidth
||
DestRect
->
bottom
>
This
->
surface_desc
.
dwHeight
)
{
WARN
(
"Source rectangle is invalid, returning DDERR_INVALIDRECT
\n
"
);
LeaveCriticalSection
(
&
ddraw_cs
);
return
DDERR_INVALIDRECT
;
}
}
if
(
Src
&&
SrcRect
)
{
if
(
SrcRect
->
top
>=
SrcRect
->
bottom
||
SrcRect
->
left
>=
SrcRect
->
right
||
SrcRect
->
right
>
Src
->
surface_desc
.
dwWidth
||
SrcRect
->
bottom
>
Src
->
surface_desc
.
dwHeight
)
{
WARN
(
"Source rectangle is invalid, returning DDERR_INVALIDRECT
\n
"
);
LeaveCriticalSection
(
&
ddraw_cs
);
return
DDERR_INVALIDRECT
;
}
}
if
(
Flags
&
DDBLT_KEYSRC
&&
(
!
Src
||
!
(
Src
->
surface_desc
.
dwFlags
&
DDSD_CKSRCBLT
)))
{
WARN
(
"DDBLT_KEYDEST blit without color key in surface, returning DDERR_INVALIDPARAMS
\n
"
);
LeaveCriticalSection
(
&
ddraw_cs
);
...
...
dlls/ddraw/tests/dsurface.c
View file @
208d3868
...
...
@@ -2208,6 +2208,7 @@ static void BltParamTest(void)
IDirectDrawSurface
*
surface1
=
NULL
,
*
surface2
=
NULL
;
DDSURFACEDESC
desc
;
HRESULT
hr
;
DDBLTFX
BltFx
;
RECT
valid
=
{
10
,
10
,
20
,
20
};
RECT
invalid1
=
{
20
,
10
,
10
,
20
};
RECT
invalid2
=
{
20
,
20
,
20
,
20
};
...
...
@@ -2255,6 +2256,54 @@ static void BltParamTest(void)
hr
=
IDirectDrawSurface_BltFast
(
surface1
,
0
,
0
,
surface1
,
NULL
,
0
);
ok
(
hr
==
DD_OK
,
"BltFast blitting a surface onto itself returned %08x
\n
"
,
hr
);
/* Blt(non-fast) tests */
memset
(
&
BltFx
,
0
,
sizeof
(
BltFx
));
BltFx
.
dwSize
=
sizeof
(
BltFx
);
BltFx
.
dwFillColor
=
0xaabbccdd
;
hr
=
IDirectDrawSurface_Blt
(
surface1
,
&
valid
,
NULL
,
NULL
,
DDBLT_COLORFILL
,
&
BltFx
);
ok
(
hr
==
DD_OK
,
"IDirectDrawSurface_Blt with a valid rectangle for color fill returned %08x
\n
"
,
hr
);
hr
=
IDirectDrawSurface_Blt
(
surface1
,
&
valid
,
NULL
,
&
invalid3
,
DDBLT_COLORFILL
,
&
BltFx
);
ok
(
hr
==
DD_OK
,
"IDirectDrawSurface_Blt with a invalid, unused rectangle returned %08x
\n
"
,
hr
);
hr
=
IDirectDrawSurface_Blt
(
surface2
,
&
invalid1
,
NULL
,
NULL
,
DDBLT_COLORFILL
,
&
BltFx
);
ok
(
hr
==
DDERR_INVALIDRECT
,
"IDirectDrawSurface_Blt with a with invalid rectangle 1 returned %08x
\n
"
,
hr
);
hr
=
IDirectDrawSurface_Blt
(
surface2
,
&
invalid2
,
NULL
,
NULL
,
DDBLT_COLORFILL
,
&
BltFx
);
ok
(
hr
==
DDERR_INVALIDRECT
,
"IDirectDrawSurface_Blt with a with invalid rectangle 2 returned %08x
\n
"
,
hr
);
hr
=
IDirectDrawSurface_Blt
(
surface2
,
&
invalid3
,
NULL
,
NULL
,
DDBLT_COLORFILL
,
&
BltFx
);
ok
(
hr
==
DDERR_INVALIDRECT
,
"IDirectDrawSurface_Blt with a with invalid rectangle 3 returned %08x
\n
"
,
hr
);
hr
=
IDirectDrawSurface_Blt
(
surface2
,
&
invalid4
,
NULL
,
NULL
,
DDBLT_COLORFILL
,
&
BltFx
);
ok
(
hr
==
DDERR_INVALIDRECT
,
"IDirectDrawSurface_Blt with a with invalid rectangle 4 returned %08x
\n
"
,
hr
);
/* Valid on surface 1 */
hr
=
IDirectDrawSurface_Blt
(
surface1
,
&
invalid4
,
NULL
,
NULL
,
DDBLT_COLORFILL
,
&
BltFx
);
ok
(
hr
==
DD_OK
,
"IDirectDrawSurface_Blt with a subrectangle fill returned %08x
\n
"
,
hr
);
/* Works - stretched blit */
hr
=
IDirectDrawSurface_Blt
(
surface1
,
NULL
,
surface2
,
NULL
,
0
,
NULL
);
ok
(
hr
==
DD_OK
,
"IDirectDrawSurface_Blt from a smaller to a bigger surface returned %08x
\n
"
,
hr
);
hr
=
IDirectDrawSurface_Blt
(
surface2
,
NULL
,
surface1
,
NULL
,
0
,
NULL
);
ok
(
hr
==
DD_OK
,
"IDirectDrawSurface_Blt from a bigger to a smaller surface %08x
\n
"
,
hr
);
/* Invalid dest rects in sourced blits */
hr
=
IDirectDrawSurface_Blt
(
surface2
,
&
invalid1
,
surface1
,
NULL
,
0
,
NULL
);
ok
(
hr
==
DDERR_INVALIDRECT
,
"IDirectDrawSurface_Blt with a with invalid rectangle 1 returned %08x
\n
"
,
hr
);
hr
=
IDirectDrawSurface_Blt
(
surface2
,
&
invalid2
,
surface1
,
NULL
,
0
,
NULL
);
ok
(
hr
==
DDERR_INVALIDRECT
,
"IDirectDrawSurface_Blt with a with invalid rectangle 2 returned %08x
\n
"
,
hr
);
hr
=
IDirectDrawSurface_Blt
(
surface2
,
&
invalid3
,
surface1
,
NULL
,
0
,
NULL
);
ok
(
hr
==
DDERR_INVALIDRECT
,
"IDirectDrawSurface_Blt with a with invalid rectangle 3 returned %08x
\n
"
,
hr
);
hr
=
IDirectDrawSurface_Blt
(
surface2
,
&
invalid4
,
surface1
,
NULL
,
0
,
NULL
);
ok
(
hr
==
DDERR_INVALIDRECT
,
"IDirectDrawSurface_Blt with a with invalid rectangle 4 returned %08x
\n
"
,
hr
);
/* Invalid src rects */
hr
=
IDirectDrawSurface_Blt
(
surface2
,
NULL
,
surface1
,
&
invalid1
,
0
,
NULL
);
ok
(
hr
==
DDERR_INVALIDRECT
,
"IDirectDrawSurface_Blt with a with invalid rectangle 1 returned %08x
\n
"
,
hr
);
hr
=
IDirectDrawSurface_Blt
(
surface2
,
NULL
,
surface1
,
&
invalid2
,
0
,
NULL
);
ok
(
hr
==
DDERR_INVALIDRECT
,
"IDirectDrawSurface_Blt with a with invalid rectangle 2 returned %08x
\n
"
,
hr
);
hr
=
IDirectDrawSurface_Blt
(
surface2
,
NULL
,
surface1
,
&
invalid3
,
0
,
NULL
);
ok
(
hr
==
DDERR_INVALIDRECT
,
"IDirectDrawSurface_Blt with a with invalid rectangle 3 returned %08x
\n
"
,
hr
);
hr
=
IDirectDrawSurface_Blt
(
surface1
,
NULL
,
surface2
,
&
invalid4
,
0
,
NULL
);
ok
(
hr
==
DDERR_INVALIDRECT
,
"IDirectDrawSurface_Blt with a with invalid rectangle 4 returned %08x
\n
"
,
hr
);
IDirectDrawSurface_Release
(
surface1
);
IDirectDrawSurface_Release
(
surface2
);
}
...
...
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