Commit 7f53bb8f authored by Jason Edmeades's avatar Jason Edmeades Committed by Alexandre Julliard

Avoid setting and resetting the same values when there are many

rectangles.
parent f644c787
...@@ -2184,6 +2184,35 @@ HRESULT WINAPI IDirect3DDevice8Impl_Clear(LPDIRECT3DDEVICE8 iface, DWORD Count ...@@ -2184,6 +2184,35 @@ HRESULT WINAPI IDirect3DDevice8Impl_Clear(LPDIRECT3DDEVICE8 iface, DWORD Count
curRect = NULL; curRect = NULL;
} }
/* Only set the values up once, as they are not changing */
if (Flags & D3DCLEAR_STENCIL) {
glGetIntegerv(GL_STENCIL_CLEAR_VALUE, &old_stencil_clear_value);
glClearStencil(Stencil);
checkGLcall("glClearStencil");
glMask = glMask | GL_STENCIL_BUFFER_BIT;
}
if (Flags & D3DCLEAR_ZBUFFER) {
glGetBooleanv(GL_DEPTH_WRITEMASK, &old_ztest);
glDepthMask(GL_TRUE);
glGetFloatv(GL_DEPTH_CLEAR_VALUE, &old_z_clear_value);
glClearDepth(Z);
checkGLcall("glClearDepth");
glMask = glMask | GL_DEPTH_BUFFER_BIT;
}
if (Flags & D3DCLEAR_TARGET) {
TRACE("Clearing screen with glClear to color %lx\n", Color);
glGetFloatv(GL_COLOR_CLEAR_VALUE, old_color_clear_value);
glClearColor(((Color >> 16) & 0xFF) / 255.0,
((Color >> 8) & 0xFF) / 255.0,
((Color >> 0) & 0xFF) / 255.0,
((Color >> 24) & 0xFF) / 255.0);
checkGLcall("glClearColor");
glMask = glMask | GL_COLOR_BUFFER_BIT;
}
/* Now process each rect in turn */
for (i = 0; i < Count || i == 0; i++) { for (i = 0; i < Count || i == 0; i++) {
if (curRect) { if (curRect) {
...@@ -2197,54 +2226,29 @@ HRESULT WINAPI IDirect3DDevice8Impl_Clear(LPDIRECT3DDEVICE8 iface, DWORD Count ...@@ -2197,54 +2226,29 @@ HRESULT WINAPI IDirect3DDevice8Impl_Clear(LPDIRECT3DDEVICE8 iface, DWORD Count
checkGLcall("glScissor"); checkGLcall("glScissor");
} }
/* Clear the whole screen */ /* Clear the selected rectangle (or full screen) */
if (Flags & D3DCLEAR_STENCIL) {
glGetIntegerv(GL_STENCIL_CLEAR_VALUE, &old_stencil_clear_value);
glClearStencil(Stencil);
checkGLcall("glClearStencil");
glMask = glMask | GL_STENCIL_BUFFER_BIT;
}
if (Flags & D3DCLEAR_ZBUFFER) {
glGetBooleanv(GL_DEPTH_WRITEMASK, &old_ztest);
glDepthMask(GL_TRUE);
glGetFloatv(GL_DEPTH_CLEAR_VALUE, &old_z_clear_value);
glClearDepth(Z);
checkGLcall("glClearDepth");
glMask = glMask | GL_DEPTH_BUFFER_BIT;
}
if (Flags & D3DCLEAR_TARGET) {
TRACE("Clearing screen with glClear to color %lx\n", Color);
glGetFloatv(GL_COLOR_CLEAR_VALUE, old_color_clear_value);
glClearColor(((Color >> 16) & 0xFF) / 255.0,
((Color >> 8) & 0xFF) / 255.0,
((Color >> 0) & 0xFF) / 255.0,
((Color >> 24) & 0xFF) / 255.0);
checkGLcall("glClearColor");
glMask = glMask | GL_COLOR_BUFFER_BIT;
}
glClear(glMask); glClear(glMask);
checkGLcall("glClear"); checkGLcall("glClear");
if (Flags & D3DCLEAR_STENCIL) { /* Step to the next rectangle */
glClearStencil(old_stencil_clear_value);
}
if (Flags & D3DCLEAR_ZBUFFER) {
glDepthMask(old_ztest);
glClearDepth(old_z_clear_value);
}
if (Flags & D3DCLEAR_TARGET) {
glClearColor(old_color_clear_value[0],
old_color_clear_value[1],
old_color_clear_value[2],
old_color_clear_value[3]);
}
if (curRect) curRect = curRect + sizeof(D3DRECT); if (curRect) curRect = curRect + sizeof(D3DRECT);
} }
/* Restore the old values (why..?) */
if (Flags & D3DCLEAR_STENCIL) {
glClearStencil(old_stencil_clear_value);
}
if (Flags & D3DCLEAR_ZBUFFER) {
glDepthMask(old_ztest);
glClearDepth(old_z_clear_value);
}
if (Flags & D3DCLEAR_TARGET) {
glClearColor(old_color_clear_value[0],
old_color_clear_value[1],
old_color_clear_value[2],
old_color_clear_value[3]);
}
if (Count > 0 && pRects) { if (Count > 0 && pRects) {
glDisable(GL_SCISSOR_TEST); glDisable(GL_SCISSOR_TEST);
checkGLcall("glDisable"); checkGLcall("glDisable");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment