1
0
mirror of https://github.com/narzoul/DDrawCompat synced 2024-12-30 08:55:36 +01:00

Fixed GDI updates interrupted by presentation sync

This commit is contained in:
narzoul 2019-08-25 12:09:35 +02:00
parent 77bdff3f1c
commit 66e0d20897
5 changed files with 35 additions and 16 deletions

View File

@ -188,6 +188,18 @@ namespace D3dDdi
{
}
void Resource::beginGdiAccess(bool isReadOnly)
{
if (m_lockResource)
{
if (!m_lockData[0].isSysMemUpToDate)
{
copyToSysMem(0);
}
m_lockData[0].isVidMemUpToDate &= isReadOnly;
}
}
HRESULT Resource::blt(D3DDDIARG_BLT data)
{
if (!isValidRect(data.DstSubResourceIndex, data.DstRect))
@ -455,6 +467,14 @@ namespace D3dDdi
LOG_RESULT(m_lockResource.get());
}
void Resource::endGdiAccess(bool isReadOnly)
{
if (m_lockResource && !isReadOnly && m_lockData[0].isSysMemUpToDate)
{
m_lockData[0].isVidMemUpToDate = false;
}
}
void Resource::fixVertexData(UINT offset, UINT count, UINT stride)
{
if (!m_fixedData.Flags.MightDrawFromLocked ||

View File

@ -26,8 +26,10 @@ namespace D3dDdi
operator HANDLE() const { return m_handle; }
void beginGdiAccess(bool isReadOnly);
HRESULT blt(D3DDDIARG_BLT data);
HRESULT colorFill(D3DDDIARG_COLORFILL data);
void endGdiAccess(bool isReadOnly);
void fixVertexData(UINT offset, UINT count, UINT stride);
void* getLockPtr(UINT subResourceIndex);
HRESULT lock(D3DDDIARG_LOCK& data);

View File

@ -16,25 +16,23 @@ namespace Gdi
auto gdiResource = D3dDdi::Device::getGdiResource();
if (gdiResource)
{
D3DDDIARG_LOCK lockData = {};
lockData.hResource = gdiResource;
lockData.Flags.ReadOnly = ACCESS_READ == access;
gdiResource->lock(lockData);
D3DDDIARG_UNLOCK unlockData = {};
unlockData.hResource = gdiResource;
gdiResource->unlock(unlockData);
gdiResource->beginGdiAccess(ACCESS_READ == m_access);
}
}
}
AccessGuard::~AccessGuard()
{
if (m_condition && ACCESS_WRITE == m_access)
if (m_condition)
{
D3dDdi::ScopedCriticalSection lock;
auto gdiResource = D3dDdi::Device::getGdiResource();
if (!gdiResource || DDraw::PrimarySurface::getFrontResource() == *gdiResource)
if (gdiResource)
{
gdiResource->endGdiAccess(ACCESS_READ == m_access);
}
if (ACCESS_WRITE == m_access &&
(!gdiResource || DDraw::PrimarySurface::getFrontResource() == *gdiResource))
{
DDraw::RealPrimarySurface::gdiUpdate();
}

View File

@ -1,10 +1,5 @@
#pragma once
namespace D3dDdi
{
class Resource;
}
namespace Gdi
{
enum Access

View File

@ -217,7 +217,10 @@ namespace
return onNcPaint(hwnd, wParam, origWndProc);
case WM_PAINT:
{
D3dDdi::ScopedCriticalSection lock;
return onPaint(hwnd, origWndProc);
}
case WM_PRINTCLIENT:
{
@ -238,7 +241,8 @@ namespace
case 0x1e5:
if (-1 == wParam)
{
RedrawWindow(hwnd, nullptr, nullptr, RDW_INVALIDATE | RDW_ERASE);
D3dDdi::ScopedCriticalSection lock;
RedrawWindow(hwnd, nullptr, nullptr, RDW_INVALIDATE | RDW_ERASE | RDW_UPDATENOW);
}
return CallWindowProc(origWndProc, hwnd, msg, wParam, lParam);