Module: wine Branch: master Commit: d4b63bbd87a221c725aff56b300224e55aa1f0a6 URL: http://source.winehq.org/git/wine.git/?a=commit;h=d4b63bbd87a221c725aff56b30...
Author: Stefan Dösinger stefan@codeweavers.com Date: Wed Jan 10 11:28:42 2007 +0100
wined3d: Store the scissor rect in the stateblock.
---
dlls/wined3d/device.c | 19 ++++++++++--------- dlls/wined3d/stateblock.c | 14 ++++++++++++++ dlls/wined3d/wined3d_private.h | 4 ++++ 3 files changed, 28 insertions(+), 9 deletions(-)
diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c index 3300cdd..7b81f0e 100644 --- a/dlls/wined3d/device.c +++ b/dlls/wined3d/device.c @@ -3180,6 +3180,15 @@ static HRESULT WINAPI IWineD3DDeviceImpl RECT windowRect; UINT winHeight;
+ This->updateStateBlock->set.scissorRect = TRUE; + This->updateStateBlock->changed.scissorRect = TRUE; + memcpy(&This->updateStateBlock->scissorRect, pRect, sizeof(*pRect)); + + if(This->isRecordingState) { + TRACE("Recording... not performing anything\n"); + return WINED3D_OK; + } + GetClientRect(((IWineD3DSwapChainImpl *)This->swapchains[0])->win_handle, &windowRect); /* Warning: glScissor uses window coordinates, not viewport coordinates, so our viewport correction does not apply * Warning2: Even in windowed mode the coords are relative to the window, not the screen @@ -3197,17 +3206,9 @@ static HRESULT WINAPI IWineD3DDeviceImpl
static HRESULT WINAPI IWineD3DDeviceImpl_GetScissorRect(IWineD3DDevice *iface, RECT* pRect) { IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface; - GLint scissorBox[4];
- ENTER_GL(); - /** FIXME: Windows uses a top,left origin openGL uses a bottom Right? **/ - glGetIntegerv(GL_SCISSOR_BOX, scissorBox); - pRect->left = scissorBox[0]; - pRect->top = scissorBox[1]; - pRect->right = scissorBox[0] + scissorBox[2]; - pRect->bottom = scissorBox[1] + scissorBox[3]; + memcpy(pRect, &This->updateStateBlock->scissorRect, sizeof(pRect)); TRACE("(%p)Returning a Scissor Rect of %d:%d-%d:%d\n", This, pRect->left, pRect->top, pRect->right, pRect->bottom); - LEAVE_GL(); return WINED3D_OK; }
diff --git a/dlls/wined3d/stateblock.c b/dlls/wined3d/stateblock.c index dba9e8a..093c83d 100644 --- a/dlls/wined3d/stateblock.c +++ b/dlls/wined3d/stateblock.c @@ -78,6 +78,7 @@ void stateblock_savedstates_copy( dest->vertexDecl = source->vertexDecl; dest->pixelShader = source->pixelShader; dest->vertexShader = source->vertexShader; + dest->scissorRect = dest->scissorRect;
/* Fixed size arrays */ memcpy(dest->streamSource, source->streamSource, bsize * MAX_STREAMS); @@ -115,6 +116,7 @@ void stateblock_savedstates_set( states->vertexDecl = value; states->pixelShader = value; states->vertexShader = value; + states->scissorRect = value;
/* Fixed size arrays */ memset(states->streamSource, value, bsize * MAX_STREAMS); @@ -168,6 +170,7 @@ void stateblock_copy( Dest->material = This->material; Dest->pixelShader = This->pixelShader; Dest->glsl_program = This->glsl_program; + memcpy(&Dest->scissorRect, &This->scissorRect, sizeof(Dest->scissorRect));
/* Fixed size arrays */ memcpy(Dest->vertexShaderConstantB, This->vertexShaderConstantB, sizeof(BOOL) * MAX_CONST_B); @@ -484,6 +487,14 @@ static HRESULT WINAPI IWineD3DStateBloc memcpy(&This->viewport, &targetStateBlock->viewport, sizeof(WINED3DVIEWPORT)); }
+ if(This->set.scissorRect && memcmp(&targetStateBlock->scissorRect, + &This->scissorRect, + sizeof(targetStateBlock->scissorRect))) + { + TRACE("Updating scissor rect\n"); + memcpy(&targetStateBlock->scissorRect, &This->scissorRect, sizeof(targetStateBlock->scissorRect)); + } + for (i = 0; i < MAX_STREAMS; i++) { if (This->set.streamSource[i] && ((This->streamStride[i] != targetStateBlock->streamStride[i]) || @@ -656,6 +667,9 @@ should really perform a delta so that on if (This->set.viewport && This->changed.viewport) IWineD3DDevice_SetViewport(pDevice, &This->viewport);
+ if (This->set.scissorRect && This->changed.scissorRect) + IWineD3DDevice_SetScissorRect(pDevice, &This->scissorRect); + /* TODO: Proper implementation using SetStreamSource offset (set to 0 for the moment)\n") */ for (i=0; i<MAX_STREAMS; i++) { if (This->set.streamSource[i] && This->changed.streamSource[i]) diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index 323fa38..0166637 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -1155,6 +1155,7 @@ typedef struct SAVEDSTATES { BOOL vertexShaderConstantsB[MAX_CONST_B]; BOOL vertexShaderConstantsI[MAX_CONST_I]; BOOL *vertexShaderConstantsF; + BOOL scissorRect; } SAVEDSTATES;
typedef struct { @@ -1243,6 +1244,9 @@ struct IWineD3DStateBlockImpl
/* Current GLSL Shader Program */ struct glsl_shader_prog_link *glsl_program; + + /* Scissor test rectangle */ + RECT scissorRect; };
extern void stateblock_savedstates_set(