diff --git a/DDrawCompat/D3dDdi/Resource.cpp b/DDrawCompat/D3dDdi/Resource.cpp index ab171de..1381c98 100644 --- a/DDrawCompat/D3dDdi/Resource.cpp +++ b/DDrawCompat/D3dDdi/Resource.cpp @@ -417,6 +417,37 @@ namespace D3dDdi return result; } + void Resource::clearRectExterior(UINT subResourceIndex, const RECT& rect) + { + const LONG width = m_fixedData.pSurfList[subResourceIndex].Width; + const LONG height = m_fixedData.pSurfList[subResourceIndex].Height; + if (rect.left > 0) + { + clearRectInterior(subResourceIndex, { 0, 0, rect.left, height }); + } + if (rect.right < width) + { + clearRectInterior(subResourceIndex, { rect.right, 0, width, height }); + } + if (rect.top > 0) + { + clearRectInterior(subResourceIndex, { rect.left, 0, rect.right, rect.top }); + } + if (rect.bottom < height) + { + clearRectInterior(subResourceIndex, { rect.left, rect.bottom, rect.right, height }); + } + } + + void Resource::clearRectInterior(UINT subResourceIndex, const RECT& rect) + { + D3DDDIARG_COLORFILL data = {}; + data.hResource = m_handle; + data.SubResourceIndex = subResourceIndex; + data.DstRect = rect; + m_device.getOrigVtable().pfnColorFill(m_device, &data); + } + void Resource::clearUpToDateFlags(UINT subResourceIndex) { m_lockData[subResourceIndex].isMsaaUpToDate = false; @@ -1110,6 +1141,8 @@ namespace D3dDdi { m_device.getShaderBlitter().gammaBlt(*this, data.DstSubResourceIndex, data.DstRect, rtNext, rtNextRect); } + + clearRectExterior(data.DstSubResourceIndex, data.DstRect); return S_OK; } diff --git a/DDrawCompat/D3dDdi/Resource.h b/DDrawCompat/D3dDdi/Resource.h index 91d360e..56d0159 100644 --- a/DDrawCompat/D3dDdi/Resource.h +++ b/DDrawCompat/D3dDdi/Resource.h @@ -81,6 +81,8 @@ namespace D3dDdi HRESULT bltLock(D3DDDIARG_LOCK& data); HRESULT bltViaCpu(D3DDDIARG_BLT data, Resource& srcResource); HRESULT bltViaGpu(D3DDDIARG_BLT data, Resource& srcResource); + void clearRectExterior(UINT subResourceIndex, const RECT& rect); + void clearRectInterior(UINT subResourceIndex, const RECT& rect); void clearUpToDateFlags(UINT subResourceIndex); void clipRect(UINT subResourceIndex, RECT& rect); HRESULT copySubResource(Resource& dstResource, Resource& srcResource, UINT subResourceIndex);