wined3d: Assign to structs instead of using memcpy.

This commit is contained in:
Andrew Talbot 2008-03-20 22:25:13 +00:00 committed by Alexandre Julliard
parent d4c6992131
commit 19c105c79c
3 changed files with 21 additions and 22 deletions

View file

@ -1709,7 +1709,7 @@ static unsigned int ConvertFvfToDeclaration(IWineD3DDeviceImpl *This, /* For the
if (!elements)
return 0;
memcpy(&elements[size-1], &end_element, sizeof(WINED3DVERTEXELEMENT));
elements[size-1] = end_element;
idx = 0;
if (has_pos) {
if (!has_blend && (fvf & WINED3DFVF_XYZRHW)) {
@ -2549,7 +2549,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_SetTransform(IWineD3DDevice *iface, W
if (This->isRecordingState) {
TRACE("Recording... not performing anything\n");
This->updateStateBlock->changed.transform[d3dts] = TRUE;
memcpy(&This->updateStateBlock->transforms[d3dts], lpmatrix, sizeof(WINED3DMATRIX));
This->updateStateBlock->transforms[d3dts] = *lpmatrix;
return WINED3D_OK;
}
@ -2589,7 +2589,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_SetTransform(IWineD3DDevice *iface, W
static HRESULT WINAPI IWineD3DDeviceImpl_GetTransform(IWineD3DDevice *iface, WINED3DTRANSFORMSTATETYPE State, WINED3DMATRIX* pMatrix) {
IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
TRACE("(%p) : for Transform State %s\n", This, debug_d3dtstype(State));
memcpy(pMatrix, &This->stateBlock->transforms[State], sizeof(WINED3DMATRIX));
*pMatrix = This->stateBlock->transforms[State];
return WINED3D_OK;
}
@ -2696,7 +2696,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_SetLight(IWineD3DDevice *iface, DWORD I
TRACE("... Range(%f), Falloff(%f), Theta(%f), Phi(%f)\n", pLight->Range, pLight->Falloff, pLight->Theta, pLight->Phi);
/* Save away the information */
memcpy(&object->OriginalParms, pLight, sizeof(WINED3DLIGHT));
object->OriginalParms = *pLight;
switch (pLight->Type) {
case WINED3DLIGHT_POINT:
@ -2788,7 +2788,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_GetLight(IWineD3DDevice *iface, DWORD I
return WINED3DERR_INVALIDCALL;
}
memcpy(pLight, &lightInfo->OriginalParms, sizeof(WINED3DLIGHT));
*pLight = lightInfo->OriginalParms;
return WINED3D_OK;
}
@ -2993,7 +2993,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_SetMaterial(IWineD3DDevice *iface, CONS
IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
This->updateStateBlock->changed.material = TRUE;
memcpy(&This->updateStateBlock->material, pMaterial, sizeof(WINED3DMATERIAL));
This->updateStateBlock->material = *pMaterial;
/* Handle recording of state blocks */
if (This->isRecordingState) {
@ -3007,7 +3007,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_SetMaterial(IWineD3DDevice *iface, CONS
static HRESULT WINAPI IWineD3DDeviceImpl_GetMaterial(IWineD3DDevice *iface, WINED3DMATERIAL* pMaterial) {
IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
memcpy(pMaterial, &This->updateStateBlock->material, sizeof (WINED3DMATERIAL));
*pMaterial = This->updateStateBlock->material;
TRACE("(%p) : Diffuse (%f,%f,%f,%f)\n", This, pMaterial->Diffuse.r, pMaterial->Diffuse.g,
pMaterial->Diffuse.b, pMaterial->Diffuse.a);
TRACE("(%p) : Ambient (%f,%f,%f,%f)\n", This, pMaterial->Ambient.r, pMaterial->Ambient.g,
@ -3107,7 +3107,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_SetViewport(IWineD3DDevice *iface, CONS
TRACE("(%p)\n", This);
This->updateStateBlock->changed.viewport = TRUE;
memcpy(&This->updateStateBlock->viewport, pViewport, sizeof(WINED3DVIEWPORT));
This->updateStateBlock->viewport = *pViewport;
/* Handle recording of state blocks */
if (This->isRecordingState) {
@ -3126,7 +3126,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_SetViewport(IWineD3DDevice *iface, CONS
static HRESULT WINAPI IWineD3DDeviceImpl_GetViewport(IWineD3DDevice *iface, WINED3DVIEWPORT* pViewport) {
IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
TRACE("(%p)\n", This);
memcpy(pViewport, &This->stateBlock->viewport, sizeof(WINED3DVIEWPORT));
*pViewport = This->stateBlock->viewport;
return WINED3D_OK;
}
@ -5806,7 +5806,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_DrawRectPatch(IWineD3DDevice *iface, UI
TRACE("Tesselation density or patch info changed, retesselating\n");
if(pRectPatchInfo) {
memcpy(&patch->RectPatchInfo, pRectPatchInfo, sizeof(*pRectPatchInfo));
patch->RectPatchInfo = *pRectPatchInfo;
}
patch->numSegs[0] = pNumSegs[0];
patch->numSegs[1] = pNumSegs[1];

View file

@ -170,7 +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));
Dest->scissorRect = This->scissorRect;
/* Lights */
memset(This->activeLights, 0, sizeof(This->activeLights));
@ -185,7 +185,7 @@ void stateblock_copy(
LIST_FOR_EACH(e1, &This->lightMap[l]) {
PLIGHTINFOEL *light = LIST_ENTRY(e1, PLIGHTINFOEL, entry), *light2;
light2 = HeapAlloc(GetProcessHeap(), 0, sizeof(*light));
memcpy(light2, light, sizeof(*light));
*light2 = *light;
list_add_tail(&Dest->lightMap[l], &light2->entry);
if(light2->glIndex != -1) Dest->activeLights[light2->glIndex] = light2;
}
@ -342,7 +342,7 @@ static inline void record_lights(IWineD3DStateBlockImpl *This, IWineD3DStateBloc
realLight = LIST_ENTRY(f, PLIGHTINFOEL, entry);
if(realLight->OriginalIndex == src->OriginalIndex) {
if(src->changed) {
memcpy(&src->OriginalParms, &realLight->OriginalParms, sizeof(src->OriginalParms));
src->OriginalParms = realLight->OriginalParms;
}
if(src->enabledChanged) {
/* Need to double check because enabledChanged does not catch enabled -> disabled -> enabled
@ -367,7 +367,7 @@ static inline void record_lights(IWineD3DStateBlockImpl *This, IWineD3DStateBloc
continue;
} else if(src->changed) {
/* Otherwise assign defaul params */
memcpy(&src->OriginalParms, &WINED3D_default_light, sizeof(src->OriginalParms));
src->OriginalParms = WINED3D_default_light;
} else {
/* Not enabled by default */
src->glIndex = -1;
@ -477,9 +477,8 @@ static HRESULT WINAPI IWineD3DStateBlockImpl_Capture(IWineD3DStateBlock *iface)
/* Others + Render & Texture */
for (i = 0; i < This->num_contained_transform_states; i++) {
TRACE("Updating transform %d\n", i);
memcpy(&This->transforms[This->contained_transform_states[i]],
&targetStateBlock->transforms[This->contained_transform_states[i]],
sizeof(WINED3DMATRIX));
This->transforms[This->contained_transform_states[i]] =
targetStateBlock->transforms[This->contained_transform_states[i]];
}
if (This->changed.indices && ((This->pIndexData != targetStateBlock->pIndexData)
@ -506,14 +505,14 @@ static HRESULT WINAPI IWineD3DStateBlockImpl_Capture(IWineD3DStateBlock *iface)
&This->material,
sizeof(WINED3DMATERIAL)) != 0) {
TRACE("Updating material\n");
memcpy(&This->material, &targetStateBlock->material, sizeof(WINED3DMATERIAL));
This->material = targetStateBlock->material;
}
if (This->changed.viewport && memcmp(&targetStateBlock->viewport,
&This->viewport,
sizeof(WINED3DVIEWPORT)) != 0) {
TRACE("Updating viewport\n");
memcpy(&This->viewport, &targetStateBlock->viewport, sizeof(WINED3DVIEWPORT));
This->viewport = targetStateBlock->viewport;
}
if(This->changed.scissorRect && memcmp(&targetStateBlock->scissorRect,
@ -521,7 +520,7 @@ static HRESULT WINAPI IWineD3DStateBlockImpl_Capture(IWineD3DStateBlock *iface)
sizeof(targetStateBlock->scissorRect)))
{
TRACE("Updating scissor rect\n");
memcpy(&targetStateBlock->scissorRect, &This->scissorRect, sizeof(targetStateBlock->scissorRect));
targetStateBlock->scissorRect = This->scissorRect;
}
for (i = 0; i < MAX_STREAMS; i++) {

View file

@ -849,7 +849,7 @@ IWineD3DBaseSurfaceImpl_Blt(IWineD3DSurface *iface,
if (DestRect)
{
memcpy(&xdst,DestRect,sizeof(xdst));
xdst = *DestRect;
}
else
{
@ -861,7 +861,7 @@ IWineD3DBaseSurfaceImpl_Blt(IWineD3DSurface *iface,
if (SrcRect)
{
memcpy(&xsrc,SrcRect,sizeof(xsrc));
xsrc = *SrcRect;
}
else
{