/***************************************************************************** * IDirect3DViewport3::SetViewport2 * * Sets the viewport from a D3DVIEWPORT2 structure * * Params: * lpData: Viewport to set * * Returns: * D3D_OK on success * *****************************************************************************/ static HRESULT WINAPI IDirect3DViewportImpl_SetViewport2(IDirect3DViewport3 *iface, D3DVIEWPORT2 *lpData) { IDirect3DViewportImpl *This = (IDirect3DViewportImpl *)iface; LPDIRECT3DVIEWPORT3 current_viewport; TRACE("iface %p, data %p.\n", iface, lpData); if (TRACE_ON(ddraw)) { TRACE(" getting D3DVIEWPORT2 :\n"); _dump_D3DVIEWPORT2(lpData); } EnterCriticalSection(&ddraw_cs); This->use_vp2 = 1; memset(&(This->viewports.vp2), 0, sizeof(This->viewports.vp2)); memcpy(&(This->viewports.vp2), lpData, lpData->dwSize); if (This->active_device) { IDirect3DDevice3 *d3d_device3 = (IDirect3DDevice3 *)&This->active_device->IDirect3DDevice3_vtbl; IDirect3DDevice3_GetCurrentViewport(d3d_device3, ¤t_viewport); if (current_viewport) { if ((IDirect3DViewportImpl *)current_viewport == This) viewport_activate(This, FALSE); IDirect3DViewport3_Release(current_viewport); } } LeaveCriticalSection(&ddraw_cs); return D3D_OK; }
/***************************************************************************** * IDirect3DViewport3::SetViewport2 * * Sets the viewport from a D3DVIEWPORT2 structure * * Params: * lpData: Viewport to set * * Returns: * D3D_OK on success * *****************************************************************************/ static HRESULT WINAPI IDirect3DViewportImpl_SetViewport2(IDirect3DViewport3 *iface, D3DVIEWPORT2 *lpData) { ICOM_THIS_FROM(IDirect3DViewportImpl, IDirect3DViewport3, iface); LPDIRECT3DVIEWPORT3 current_viewport; TRACE("(%p/%p)->(%p)\n", This, iface, lpData); if (TRACE_ON(d3d7)) { TRACE(" getting D3DVIEWPORT2 :\n"); _dump_D3DVIEWPORT2(lpData); } EnterCriticalSection(&ddraw_cs); This->use_vp2 = 1; memset(&(This->viewports.vp2), 0, sizeof(This->viewports.vp2)); memcpy(&(This->viewports.vp2), lpData, lpData->dwSize); if (This->active_device) { IDirect3DDevice3_GetCurrentViewport(ICOM_INTERFACE(This->active_device, IDirect3DDevice3), ¤t_viewport); if (current_viewport) { if (ICOM_OBJECT(IDirect3DViewportImpl, IDirect3DViewport3, current_viewport) == This) This->activate(This, FALSE); IDirect3DViewport3_Release(current_viewport); } } LeaveCriticalSection(&ddraw_cs); return D3D_OK; }
/***************************************************************************** * IDirect3DViewport3::GetViewport2 * * Returns the currently set viewport in a D3DVIEWPORT2 structure. * Similar to IDirect3DViewport3::GetViewport * * Params: * lpData: Pointer to the structure to fill * * Returns: * D3D_OK on success * DDERR_INVALIDPARAMS if the viewport was set with * IDirect3DViewport3::SetViewport * DDERR_INVALIDPARAMS if Data is NULL * *****************************************************************************/ static HRESULT WINAPI IDirect3DViewportImpl_GetViewport2(IDirect3DViewport3 *iface, D3DVIEWPORT2 *lpData) { ICOM_THIS_FROM(IDirect3DViewportImpl, IDirect3DViewport3, iface); DWORD dwSize; TRACE("(%p)->(%p)\n", This, lpData); EnterCriticalSection(&ddraw_cs); if (This->use_vp2 != 1) { ERR(" Requesting to get a D3DVIEWPORT2 struct where a D3DVIEWPORT was set !\n"); LeaveCriticalSection(&ddraw_cs); return DDERR_INVALIDPARAMS; } dwSize = lpData->dwSize; memset(lpData, 0, dwSize); memcpy(lpData, &(This->viewports.vp2), dwSize); if (TRACE_ON(d3d7)) { TRACE(" returning D3DVIEWPORT2 :\n"); _dump_D3DVIEWPORT2(lpData); } LeaveCriticalSection(&ddraw_cs); return D3D_OK; }
/***************************************************************************** * IDirect3DViewport3::GetViewport2 * * Returns the currently set viewport in a D3DVIEWPORT2 structure. * Similar to IDirect3DViewport3::GetViewport * * Params: * lpData: Pointer to the structure to fill * * Returns: * D3D_OK on success * DDERR_INVALIDPARAMS if the viewport was set with * IDirect3DViewport3::SetViewport * DDERR_INVALIDPARAMS if Data is NULL * *****************************************************************************/ static HRESULT WINAPI IDirect3DViewportImpl_GetViewport2(IDirect3DViewport3 *iface, D3DVIEWPORT2 *lpData) { IDirect3DViewportImpl *This = (IDirect3DViewportImpl *)iface; DWORD dwSize; TRACE("iface %p, data %p.\n", iface, lpData); EnterCriticalSection(&ddraw_cs); dwSize = lpData->dwSize; memset(lpData, 0, dwSize); if (This->use_vp2) memcpy(lpData, &(This->viewports.vp2), dwSize); else { D3DVIEWPORT2 vp2; vp2.dwSize = sizeof(vp2); vp2.dwX = This->viewports.vp1.dwX; vp2.dwY = This->viewports.vp1.dwY; vp2.dwWidth = This->viewports.vp1.dwWidth; vp2.dwHeight = This->viewports.vp1.dwHeight; vp2.dvClipX = 0.0; vp2.dvClipY = 0.0; vp2.dvClipWidth = 0.0; vp2.dvClipHeight = 0.0; vp2.dvMinZ = This->viewports.vp1.dvMinZ; vp2.dvMaxZ = This->viewports.vp1.dvMaxZ; memcpy(lpData, &vp2, dwSize); } if (TRACE_ON(ddraw)) { TRACE(" returning D3DVIEWPORT2 :\n"); _dump_D3DVIEWPORT2(lpData); } LeaveCriticalSection(&ddraw_cs); return D3D_OK; }