Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-cw
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-cw
Commits
fce9abd0
Commit
fce9abd0
authored
Dec 01, 2007
by
Stefan Dösinger
Committed by
Alexandre Julliard
Dec 04, 2007
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
wined3d: Clear honors the viewport.
parent
bd10d526
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
100 additions
and
21 deletions
+100
-21
visual.c
dlls/d3d9/tests/visual.c
+64
-0
device.c
dlls/wined3d/device.c
+36
-21
No files found.
dlls/d3d9/tests/visual.c
View file @
fce9abd0
...
@@ -276,6 +276,7 @@ static void clear_test(IDirect3DDevice9 *device)
...
@@ -276,6 +276,7 @@ static void clear_test(IDirect3DDevice9 *device)
D3DRECT
rect
[
2
];
D3DRECT
rect
[
2
];
D3DRECT
rect_negneg
;
D3DRECT
rect_negneg
;
DWORD
color
;
DWORD
color
;
D3DVIEWPORT9
old_vp
,
vp
;
hr
=
IDirect3DDevice9_Clear
(
device
,
0
,
NULL
,
D3DCLEAR_TARGET
,
0xffffffff
,
0
.
0
,
0
);
hr
=
IDirect3DDevice9_Clear
(
device
,
0
,
NULL
,
D3DCLEAR_TARGET
,
0xffffffff
,
0
.
0
,
0
);
ok
(
hr
==
D3D_OK
,
"IDirect3DDevice9_Clear failed with %s
\n
"
,
DXGetErrorString9
(
hr
));
ok
(
hr
==
D3D_OK
,
"IDirect3DDevice9_Clear failed with %s
\n
"
,
DXGetErrorString9
(
hr
));
...
@@ -315,6 +316,69 @@ static void clear_test(IDirect3DDevice9 *device)
...
@@ -315,6 +316,69 @@ static void clear_test(IDirect3DDevice9 *device)
ok
(
color
==
0x00ffffff
,
"Clear rectangle 4(NULL) has color %08x
\n
"
,
color
);
ok
(
color
==
0x00ffffff
,
"Clear rectangle 4(NULL) has color %08x
\n
"
,
color
);
color
=
getPixelColor
(
device
,
480
,
120
);
/* upper right quad */
color
=
getPixelColor
(
device
,
480
,
120
);
/* upper right quad */
ok
(
color
==
0x00ffffff
,
"Clear rectangle 4(neg, neg) has color %08x
\n
"
,
color
);
ok
(
color
==
0x00ffffff
,
"Clear rectangle 4(neg, neg) has color %08x
\n
"
,
color
);
/* Test how the viewport affects clears */
hr
=
IDirect3DDevice9_Clear
(
device
,
0
,
NULL
,
D3DCLEAR_TARGET
,
0xffffffff
,
0
.
0
,
0
);
ok
(
hr
==
D3D_OK
,
"IDirect3DDevice9_Clear failed with %s
\n
"
,
DXGetErrorString9
(
hr
));
hr
=
IDirect3DDevice9_GetViewport
(
device
,
&
old_vp
);
ok
(
hr
==
D3D_OK
,
"IDirect3DDevice9_GetViewport failed with %s
\n
"
,
DXGetErrorString9
(
hr
));
vp
.
X
=
160
;
vp
.
Y
=
120
;
vp
.
Width
=
160
;
vp
.
Height
=
120
;
vp
.
MinZ
=
0
.
0
;
vp
.
MaxZ
=
1
.
0
;
hr
=
IDirect3DDevice9_SetViewport
(
device
,
&
vp
);
ok
(
hr
==
D3D_OK
,
"IDirect3DDevice9_SetViewport failed with %s
\n
"
,
DXGetErrorString9
(
hr
));
hr
=
IDirect3DDevice9_Clear
(
device
,
0
,
NULL
,
D3DCLEAR_TARGET
,
0xff0000ff
,
0
.
0
,
0
);
ok
(
hr
==
D3D_OK
,
"IDirect3DDevice9_Clear failed with %s
\n
"
,
DXGetErrorString9
(
hr
));
vp
.
X
=
320
;
vp
.
Y
=
240
;
vp
.
Width
=
320
;
vp
.
Height
=
240
;
vp
.
MinZ
=
0
.
0
;
vp
.
MaxZ
=
1
.
0
;
hr
=
IDirect3DDevice9_SetViewport
(
device
,
&
vp
);
ok
(
hr
==
D3D_OK
,
"IDirect3DDevice9_SetViewport failed with %s
\n
"
,
DXGetErrorString9
(
hr
));
rect
[
0
].
x1
=
160
;
rect
[
0
].
y1
=
120
;
rect
[
0
].
x2
=
480
;
rect
[
0
].
y2
=
360
;
hr
=
IDirect3DDevice9_Clear
(
device
,
1
,
&
rect
[
0
],
D3DCLEAR_TARGET
,
0xff00ff00
,
0
.
0
,
0
);
ok
(
hr
==
D3D_OK
,
"IDirect3DDevice9_Clear failed with %s
\n
"
,
DXGetErrorString9
(
hr
));
hr
=
IDirect3DDevice9_SetViewport
(
device
,
&
old_vp
);
ok
(
hr
==
D3D_OK
,
"IDirect3DDevice9_SetViewport failed with %s
\n
"
,
DXGetErrorString9
(
hr
));
IDirect3DDevice9_Present
(
device
,
NULL
,
NULL
,
NULL
,
NULL
);
color
=
getPixelColor
(
device
,
158
,
118
);
ok
(
color
==
0x00ffffff
,
"(158,118) has color %08x
\n
"
,
color
);
color
=
getPixelColor
(
device
,
162
,
118
);
ok
(
color
==
0x00ffffff
,
"(162,118) has color %08x
\n
"
,
color
);
color
=
getPixelColor
(
device
,
158
,
122
);
ok
(
color
==
0x00ffffff
,
"(158,122) has color %08x
\n
"
,
color
);
color
=
getPixelColor
(
device
,
162
,
122
);
ok
(
color
==
0x000000ff
,
"(162,122) has color %08x
\n
"
,
color
);
color
=
getPixelColor
(
device
,
318
,
238
);
ok
(
color
==
0x000000ff
,
"(318,238) has color %08x
\n
"
,
color
);
color
=
getPixelColor
(
device
,
322
,
238
);
ok
(
color
==
0x00ffffff
,
"(322,328) has color %08x
\n
"
,
color
);
color
=
getPixelColor
(
device
,
318
,
242
);
ok
(
color
==
0x00ffffff
,
"(318,242) has color %08x
\n
"
,
color
);
color
=
getPixelColor
(
device
,
322
,
242
);
ok
(
color
==
0x0000ff00
,
"(322,242) has color %08x
\n
"
,
color
);
color
=
getPixelColor
(
device
,
478
,
358
);
ok
(
color
==
0x0000ff00
,
"(478,358 has color %08x
\n
"
,
color
);
color
=
getPixelColor
(
device
,
482
,
358
);
ok
(
color
==
0x00ffffff
,
"(482,358) has color %08x
\n
"
,
color
);
color
=
getPixelColor
(
device
,
478
,
362
);
ok
(
color
==
0x00ffffff
,
"(478,362) has color %08x
\n
"
,
color
);
color
=
getPixelColor
(
device
,
482
,
362
);
ok
(
color
==
0x00ffffff
,
"(482,362) has color %08x
\n
"
,
color
);
}
}
typedef
struct
{
typedef
struct
{
...
...
dlls/wined3d/device.c
View file @
fce9abd0
...
@@ -4786,7 +4786,9 @@ static HRESULT WINAPI IWineD3DDeviceImpl_Clear(IWineD3DDevice *iface, DWORD Coun
...
@@ -4786,7 +4786,9 @@ static HRESULT WINAPI IWineD3DDeviceImpl_Clear(IWineD3DDevice *iface, DWORD Coun
GLbitfield
glMask
=
0
;
GLbitfield
glMask
=
0
;
unsigned
int
i
;
unsigned
int
i
;
CONST
WINED3DRECT
*
curRect
;
WINED3DRECT
curRect
;
RECT
vp_rect
;
WINED3DVIEWPORT
*
vp
=
&
This
->
stateBlock
->
viewport
;
TRACE
(
"(%p) Count (%d), pRects (%p), Flags (%x), Color (0x%08x), Z (%f), Stencil (%d)
\n
"
,
This
,
TRACE
(
"(%p) Count (%d), pRects (%p), Flags (%x), Color (0x%08x), Z (%f), Stencil (%d)
\n
"
,
This
,
Count
,
pRects
,
Flags
,
Color
,
Z
,
Stencil
);
Count
,
pRects
,
Flags
,
Color
,
Z
,
Stencil
);
...
@@ -4803,19 +4805,25 @@ static HRESULT WINAPI IWineD3DDeviceImpl_Clear(IWineD3DDevice *iface, DWORD Coun
...
@@ -4803,19 +4805,25 @@ static HRESULT WINAPI IWineD3DDeviceImpl_Clear(IWineD3DDevice *iface, DWORD Coun
*
*
* If we're clearing the whole target there is no need to copy it into the drawable, it will be overwritten
* If we're clearing the whole target there is no need to copy it into the drawable, it will be overwritten
* anyway. If we're not clearing the color buffer we don't have to copy either since we're not going to set
* anyway. If we're not clearing the color buffer we don't have to copy either since we're not going to set
* the drawable up to date
* the drawable up to date. We have to check all settings that limit the clear area though. Do not bother
* checking all this if the dest surface is in the drawable anyway.
*/
*/
if
(
Count
>
0
&&
pRects
)
{
if
((
Flags
&
WINED3DCLEAR_TARGET
)
&&
!
(
target
->
Flags
&
SFLAG_INDRAWABLE
))
{
if
(
Flags
&
WINED3DCLEAR_TARGET
)
{
while
(
1
)
{
if
(
pRects
[
0
].
x1
>
0
||
pRects
[
0
].
y1
>
0
||
if
(
vp
->
X
!=
0
||
vp
->
Y
!=
0
||
vp
->
Width
<
target
->
currentDesc
.
Width
||
vp
->
Height
<
target
->
currentDesc
.
Height
)
{
IWineD3DSurface_LoadLocation
((
IWineD3DSurface
*
)
target
,
SFLAG_INDRAWABLE
,
NULL
);
break
;
}
if
(
Count
>
0
&&
pRects
&&
(
pRects
[
0
].
x1
>
0
||
pRects
[
0
].
y1
>
0
||
pRects
[
0
].
x2
<
target
->
currentDesc
.
Width
||
pRects
[
0
].
x2
<
target
->
currentDesc
.
Width
||
pRects
[
0
].
y2
<
target
->
currentDesc
.
Height
)
{
pRects
[
0
].
y2
<
target
->
currentDesc
.
Height
)
)
{
IWineD3DSurface_LoadLocation
((
IWineD3DSurface
*
)
target
,
SFLAG_INDRAWABLE
,
NULL
);
IWineD3DSurface_LoadLocation
((
IWineD3DSurface
*
)
target
,
SFLAG_INDRAWABLE
,
NULL
);
break
;
}
}
break
;
}
}
curRect
=
pRects
;
}
else
{
curRect
=
NULL
;
}
}
/* This is for offscreen rendering as well as for multithreading, thus activate the set render target
/* This is for offscreen rendering as well as for multithreading, thus activate the set render target
...
@@ -4857,9 +4865,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_Clear(IWineD3DDevice *iface, DWORD Coun
...
@@ -4857,9 +4865,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_Clear(IWineD3DDevice *iface, DWORD Coun
glMask
=
glMask
|
GL_COLOR_BUFFER_BIT
;
glMask
=
glMask
|
GL_COLOR_BUFFER_BIT
;
}
}
if
(
!
curRect
)
{
if
(
!
(
Count
>
0
&&
pRects
))
{
/* In drawable flag is set below */
if
(
This
->
render_offscreen
)
{
if
(
This
->
render_offscreen
)
{
glScissor
(
This
->
stateBlock
->
viewport
.
X
,
glScissor
(
This
->
stateBlock
->
viewport
.
X
,
This
->
stateBlock
->
viewport
.
Y
,
This
->
stateBlock
->
viewport
.
Y
,
...
@@ -4876,29 +4882,38 @@ static HRESULT WINAPI IWineD3DDeviceImpl_Clear(IWineD3DDevice *iface, DWORD Coun
...
@@ -4876,29 +4882,38 @@ static HRESULT WINAPI IWineD3DDeviceImpl_Clear(IWineD3DDevice *iface, DWORD Coun
glClear
(
glMask
);
glClear
(
glMask
);
checkGLcall
(
"glClear"
);
checkGLcall
(
"glClear"
);
}
else
{
}
else
{
/* The viewport cap still applies, we have to intersect each clear rect with the viewport
* range because glClear ignores the viewport(and the viewport isn't even applied in this state)
*/
vp_rect
.
left
=
vp
->
X
;
vp_rect
.
top
=
vp
->
Y
;
vp_rect
.
right
=
vp
->
X
+
vp
->
Width
;
vp_rect
.
bottom
=
vp
->
Y
+
vp
->
Height
;
/* Now process each rect in turn */
/* Now process each rect in turn */
for
(
i
=
0
;
i
<
Count
;
i
++
)
{
for
(
i
=
0
;
i
<
Count
;
i
++
)
{
/* Note gl uses lower left, width/height */
/* Note gl uses lower left, width/height */
TRACE
(
"(%p) %p Rect=(%d,%d)->(%d,%d) glRect=(%d,%d), len=%d, hei=%d
\n
"
,
This
,
curRect
,
IntersectRect
((
RECT
*
)
&
curRect
,
&
vp_rect
,
(
RECT
*
)
&
pRects
[
i
]);
curRect
[
i
].
x1
,
curRect
[
i
].
y1
,
curRect
[
i
].
x2
,
curRect
[
i
].
y2
,
TRACE
(
"(%p) Rect=(%d,%d)->(%d,%d) glRect=(%d,%d), len=%d, hei=%d
\n
"
,
This
,
curRect
[
i
].
x1
,
(
target
->
currentDesc
.
Height
-
curRect
[
i
].
y2
),
pRects
[
i
].
x1
,
pRects
[
i
].
y1
,
pRects
[
i
].
x2
,
pRects
[
i
].
y2
,
curRect
[
i
].
x2
-
curRect
[
i
].
x1
,
curRect
[
i
].
y2
-
curRect
[
i
].
y1
);
curRect
.
x1
,
(
target
->
currentDesc
.
Height
-
curRect
.
y2
),
curRect
.
x2
-
curRect
.
x1
,
curRect
.
y2
-
curRect
.
y1
);
/* Tests show that rectangles where x1 > x2 or y1 > y2 are ignored silently.
/* Tests show that rectangles where x1 > x2 or y1 > y2 are ignored silently.
* The rectangle is not cleared, no error is returned, but further rectanlges are
* The rectangle is not cleared, no error is returned, but further rectanlges are
* still cleared if they are valid
* still cleared if they are valid
*/
*/
if
(
curRect
[
i
].
x1
>
curRect
[
i
].
x2
||
curRect
[
i
].
y1
>
curRect
[
i
]
.
y2
)
{
if
(
curRect
.
x1
>
curRect
.
x2
||
curRect
.
y1
>
curRect
.
y2
)
{
TRACE
(
"Rectangle with negative dimensions, ignoring
\n
"
);
TRACE
(
"Rectangle with negative dimensions, ignoring
\n
"
);
continue
;
continue
;
}
}
if
(
This
->
render_offscreen
)
{
if
(
This
->
render_offscreen
)
{
glScissor
(
curRect
[
i
].
x1
,
curRect
[
i
]
.
y1
,
glScissor
(
curRect
.
x1
,
curRect
.
y1
,
curRect
[
i
].
x2
-
curRect
[
i
].
x1
,
curRect
[
i
].
y2
-
curRect
[
i
]
.
y1
);
curRect
.
x2
-
curRect
.
x1
,
curRect
.
y2
-
curRect
.
y1
);
}
else
{
}
else
{
glScissor
(
curRect
[
i
].
x1
,
target
->
currentDesc
.
Height
-
curRect
[
i
]
.
y2
,
glScissor
(
curRect
.
x1
,
target
->
currentDesc
.
Height
-
curRect
.
y2
,
curRect
[
i
].
x2
-
curRect
[
i
].
x1
,
curRect
[
i
].
y2
-
curRect
[
i
]
.
y1
);
curRect
.
x2
-
curRect
.
x1
,
curRect
.
y2
-
curRect
.
y1
);
}
}
checkGLcall
(
"glScissor"
);
checkGLcall
(
"glScissor"
);
...
...
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