Skip to content

Commit

Permalink
Slightly change where present code is located
Browse files Browse the repository at this point in the history
  • Loading branch information
elishacloud committed Sep 8, 2023
1 parent e1c6f45 commit 54a7988
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 50 deletions.
2 changes: 1 addition & 1 deletion Dllmain/BuildNo.rc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
#define BUILD_NUMBER 6802
#define BUILD_NUMBER 6803
89 changes: 40 additions & 49 deletions ddraw/IDirectDrawSurfaceX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -595,6 +595,12 @@ HRESULT m_IDirectDrawSurfaceX::Blt(LPRECT lpDestRect, LPDIRECTDRAWSURFACE7 lpDDS
{
ddrawParent->SetVsync();
}

// Present surface
if (!DontPresentBlt)
{
EndWritePresent(IsSkipScene);
}
}

} while (false);
Expand All @@ -605,12 +611,6 @@ HRESULT m_IDirectDrawSurfaceX::Blt(LPRECT lpDestRect, LPDIRECTDRAWSURFACE7 lpDDS
hr = D3DERR_WASSTILLDRAWING;
}

// Present surface
if (!DontPresentBlt && SUCCEEDED(hr))
{
EndWritePresent(IsSkipScene);
}

// Release critical section
lpDDSrcSurfaceX->ReleaseLockCriticalSection();
ReleaseLockCriticalSection();
Expand Down Expand Up @@ -1309,30 +1309,27 @@ HRESULT m_IDirectDrawSurfaceX::Flip(LPDIRECTDRAWSURFACE7 lpDDSurfaceTargetOverri
ddrawParent->SetVsync();
}

} while (false);

// Preset surface to window
if (!IsDirect3DEnabled)
{
RECT Rect = { 0, 0, (LONG)surfaceDesc2.dwWidth, (LONG)surfaceDesc2.dwHeight };

// Blt surface directly to GDI
if (Config.DdrawWriteToGDI)
{
CopyEmulatedSurfaceToGDI(Rect);
}
// Handle windowed mode
else if (surface.IsUsingWindowedMode)
// Preset surface to window
if (!IsDirect3DEnabled)
{
PresentSurfaceToWindow(Rect);
RECT Rect = { 0, 0, (LONG)surfaceDesc2.dwWidth, (LONG)surfaceDesc2.dwHeight };

// Blt surface directly to GDI
if (Config.DdrawWriteToGDI)
{
CopyEmulatedSurfaceToGDI(Rect);
}
// Handle windowed mode
else if (surface.IsUsingWindowedMode)
{
PresentSurfaceToWindow(Rect);
}
}
}

// Present surface
if (SUCCEEDED(hr))
{
// Present surface
EndWritePresent(false);
}

} while (false);

// Release critical section for each surface
for (m_IDirectDrawSurfaceX*& pSurfaceX : FlipList)
Expand Down Expand Up @@ -2394,13 +2391,6 @@ HRESULT m_IDirectDrawSurfaceX::ReleaseDC(HDC hDC)
break;
}

// Preset surface to window
if (surface.IsUsingWindowedMode && IsPrimarySurface() && !Config.DdrawWriteToGDI && !IsDirect3DEnabled)
{
RECT Rect = { 0, 0, (LONG)surfaceDesc2.dwWidth, (LONG)surfaceDesc2.dwHeight };
PresentSurfaceToWindow(Rect);
}

// Reset DC flag
IsInDC = false;

Expand All @@ -2410,13 +2400,17 @@ HRESULT m_IDirectDrawSurfaceX::ReleaseDC(HDC hDC)
// Set dirty flag
SetDirtyFlag();

} while (false);
// Preset surface to window
if (surface.IsUsingWindowedMode && IsPrimarySurface() && !Config.DdrawWriteToGDI && !IsDirect3DEnabled)
{
RECT Rect = { 0, 0, (LONG)surfaceDesc2.dwWidth, (LONG)surfaceDesc2.dwHeight };
PresentSurfaceToWindow(Rect);
}

// Present surface
if (SUCCEEDED(hr))
{
// Present surface
EndWritePresent(false);
}

} while (false);

ReleaseSurfaceCriticalSection();

Expand Down Expand Up @@ -2792,12 +2786,6 @@ HRESULT m_IDirectDrawSurfaceX::Unlock(LPRECT lpRect)
break;
}

// Preset surface to window
if (surface.IsUsingWindowedMode && IsPrimarySurface() && !Config.DdrawWriteToGDI && !IsDirect3DEnabled)
{
PresentSurfaceToWindow(LastLock.Rect);
}

// Clear memory pointer
LastLock.LockedRect.pBits = nullptr;

Expand All @@ -2819,13 +2807,16 @@ HRESULT m_IDirectDrawSurfaceX::Unlock(LPRECT lpRect)
SetDirtyFlag();
}

} while (false);
// Preset surface to window
if (surface.IsUsingWindowedMode && IsPrimarySurface() && !Config.DdrawWriteToGDI && !IsDirect3DEnabled)
{
PresentSurfaceToWindow(LastLock.Rect);
}

// Present surface
if (SUCCEEDED(hr))
{
// Present surface
EndWritePresent(LastLock.IsSkipScene);
}

} while (false);

ReleaseSurfaceCriticalSection();

Expand Down

0 comments on commit 54a7988

Please sign in to comment.