Use pitch instead of trying to calculate it (#308)

This commit is contained in:
Anders Jenbo 2025-06-14 19:42:50 +02:00 committed by GitHub
parent 975764dc17
commit 43a261b945
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 10 additions and 12 deletions

View File

@ -388,12 +388,11 @@ void MxTransitionManager::WipeDownTransition()
// For each of the 240 animation ticks, blank out two scanlines
// starting at the top of the screen.
// (dwRGBBitCount / 8) will tell how many bytes are used per pixel.
MxU8* line = (MxU8*) ddsd.lpSurface + 2 * ddsd.lPitch * m_animationTimer;
memset(line, 0, 640 * ddsd.ddpfPixelFormat.dwRGBBitCount / 8);
memset(line, 0, ddsd.lPitch);
line += ddsd.lPitch;
memset(line, 0, 640 * ddsd.ddpfPixelFormat.dwRGBBitCount / 8);
memset(line, 0, ddsd.lPitch);
SetupCopyRect(&ddsd);
m_ddSurface->Unlock(ddsd.lpSurface);
@ -427,9 +426,8 @@ void MxTransitionManager::WindowsTransition()
MxU8* line = (MxU8*) ddsd.lpSurface + m_animationTimer * ddsd.lPitch;
MxS32 bytesPerPixel = ddsd.ddpfPixelFormat.dwRGBBitCount / 8;
MxS32 bytesPerLine = bytesPerPixel * 640;
memset(line, 0, bytesPerLine);
memset(line, 0, ddsd.lPitch);
for (MxS32 i = m_animationTimer + 1; i < 480 - m_animationTimer; i++) {
line += ddsd.lPitch;
@ -439,7 +437,7 @@ void MxTransitionManager::WindowsTransition()
}
line += ddsd.lPitch;
memset(line, 0, bytesPerLine);
memset(line, 0, ddsd.lPitch);
SetupCopyRect(&ddsd);
m_ddSurface->Unlock(ddsd.lpSurface);

View File

@ -459,7 +459,7 @@ void LegoVideoManager::DrawFPS()
char* ptr = (char*) surfaceDesc.lpSurface;
for (i = 0; i < surfaceDesc.dwHeight; i++) {
memset(ptr, 0, surfaceDesc.dwWidth * surfaceDesc.ddpfPixelFormat.dwRGBBitCount / 8);
memset(ptr, 0, surfaceDesc.lPitch);
ptr += surfaceDesc.lPitch;
}
@ -485,7 +485,7 @@ void LegoVideoManager::DrawFPS()
char* ptr = (char*) surfaceDesc.lpSurface;
for (i = 0; i < surfaceDesc.dwHeight; i++) {
memset(ptr, 0, surfaceDesc.dwWidth * surfaceDesc.ddpfPixelFormat.dwRGBBitCount / 8);
memset(ptr, 0, surfaceDesc.lPitch);
ptr += surfaceDesc.lPitch;
}

View File

@ -178,7 +178,7 @@ BOOL MxDirect3D::D3DSetMode()
unsigned char* surface = (unsigned char*) desc.lpSurface;
for (int i = 0; i < mode.height; i++) {
memset(surface, 0, mode.width * desc.ddpfPixelFormat.dwRGBBitCount / 8);
memset(surface, 0, desc.lPitch);
surface += desc.lPitch;
}
@ -196,7 +196,7 @@ BOOL MxDirect3D::D3DSetMode()
unsigned char* surface = (unsigned char*) desc.lpSurface;
for (int i = 0; i < mode.height; i++) {
memset(surface, 0, mode.width * desc.ddpfPixelFormat.dwRGBBitCount / 8);
memset(surface, 0, desc.lPitch);
surface += desc.lPitch;
}

View File

@ -78,7 +78,7 @@ void MxDisplaySurface::ClearScreen()
MxS32 height = m_videoParam.GetRect().GetHeight();
while (height--) {
memset(surface, 0, m_videoParam.GetRect().GetWidth() * desc.ddpfPixelFormat.dwRGBBitCount / 8);
memset(surface, 0, desc.lPitch);
surface += desc.lPitch;
}
@ -854,7 +854,7 @@ void MxDisplaySurface::Display(MxS32 p_left, MxS32 p_top, MxS32 p_left2, MxS32 p
MxS32 height = m_videoParam.GetRect().GetHeight();
for (MxU32 i = 0; i < ddsd.dwHeight; i++) {
memset(surface, 0, ddsd.dwWidth * ddsd.ddpfPixelFormat.dwRGBBitCount / 8);
memset(surface, 0, ddsd.lPitch);
surface += ddsd.lPitch;
}