From 1d8e74d4aa26c7a85393f2f5676b7641ac4241e6 Mon Sep 17 00:00:00 2001 From: Joachim Henze Date: Mon, 11 Jan 2021 16:42:01 +0100 Subject: [PATCH] [0.4.14][WIN32SS][COMCTL32] Commit Flip_Fix_9.patch flip_fix_9.patch fixes: CORE-16984 " 'SPINA Thrulg' / 'SPINA Thyr' / 'Sim Thyr' have images flipped" CORE-17194 "StretchDIBits test" isn't work correctly" "Output of 'Project 3 Test'" CORE-14701 "DVDStyler 3.0.4 transparent toolbars" CORE-14701 "DVDStyler 3.0.4 erroneously black around icons of welcome-dlg" CORE-14671 "'Peazip' shows icons in buttons and menubar vertically flipped" "Double Commander shoes icons flipped in buttons, menubar, listview and the treeview" CORE-13273 "Welcome to Lazarus" icon shows flipped CORE-13026 "'CudaText app' icon shows flipped" Not all of those are duplicates, although they appear to be at first glance. It affects different controls and some of those tickets do have different 'guilty revs' than others. The patch does consist of 3 parts: 1.) win32ss/gdi/ntgdi/dibobj.c This one is the most clean part of it, that addresses most of the flipping issues now. 2.) The hack in comctl32.h redefining the version: We used that in the past to appease some, but not all of the issues listed above. But it does hide additional issues, e.g. in DvDStyler, therefore we seem to still need that appeasement even today. Most likely it would make sense to aim to avoid this part in the future. part 2.) was committed as first appeasement on its own already into 0.4.14-RC-24-g 198b61e 0.4.13-RC-7-g 67211fa 0.4.12-RC-5-g 8449527 0.4.11-RC-16-g b906163 0.4.10-RC-7-g f1e80fe 0.4.9-RC-34-g 9d758ae 3.) toolbar.c change That part fixes at least the toolbar case for DvDStyler without relying on the comctl32.h hack any longer, but it was still not enough to completely get rid of part 2.) yet. Many thanks to all contributors: 'I_kill_Bugs', Doug Lyons and also 'Julenuri' for testing. The patch gave nice testbot results: KVM: https://reactos.org/testman/compare.php?ids=75704,75714 VBox: https://reactos.org/testman/compare.php?ids=75705,75715 and we also created a summary of manual test-results: https://jira.reactos.org/browse/CORE-17415?focusedCommentId=126668&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-126668 If you read this comment via git blame and your goal is to get rid of the hack in comctl32.h, I would highly recommend to redo the tests of that testing table, and if that is asked too much, then please test at least the following cases: CORE-14701 "DVDStyler 3.0.4 transparent toolbars" CORE-14701 "DVDStyler 3.0.4 erroneously black around icons of welcome-dlg" "DVDStyler 3.0.4 erroneously black/transparent within comboboxes of properties of VMGM menu" and try to add what might be needed to fix them, and double-check again: "DoubleCommander optionsDlg the most complex testcase, contains flip-prone icons in treeview, listview, menubar, buttons, statics". Only some of its flipped icons were impacted by the comctl32.h change before. fix picked from 0.4.15-dev-1603-g 232c45fcd71b12a0d726b47f4a72e9a16f87432a --- dll/win32/comctl32/toolbar.c | 4 +++ win32ss/gdi/ntgdi/dibobj.c | 55 ++++++++++++++++++++++-------------- 2 files changed, 38 insertions(+), 21 deletions(-) diff --git a/dll/win32/comctl32/toolbar.c b/dll/win32/comctl32/toolbar.c index e2b6193b663..b725f3c5121 100644 --- a/dll/win32/comctl32/toolbar.c +++ b/dll/win32/comctl32/toolbar.c @@ -6603,6 +6603,10 @@ TOOLBAR_Paint (TOOLBAR_INFO *infoPtr, WPARAM wParam) TRACE("psrect=(%s)\n", wine_dbgstr_rect(&ps.rcPaint)); +#ifdef __REACTOS__ + TOOLBAR_EraseBackground(infoPtr, (WPARAM)hdc, (LPARAM) 0); +#endif + TOOLBAR_Refresh (infoPtr, hdc, &ps); if (!wParam) EndPaint (infoPtr->hwndSelf, &ps); diff --git a/win32ss/gdi/ntgdi/dibobj.c b/win32ss/gdi/ntgdi/dibobj.c index 93208665b39..7b8cc330c73 100644 --- a/win32ss/gdi/ntgdi/dibobj.c +++ b/win32ss/gdi/ntgdi/dibobj.c @@ -951,25 +951,28 @@ GreGetDIBitsInternal( RECT rcDest; POINTL srcPoint; BOOL ret ; + int newLines = -1; - if (StartScan > (ULONG)psurf->SurfObj.sizlBitmap.cy) + if (StartScan >= abs(Info->bmiHeader.biHeight)) { - ScanLines = 0; + ScanLines = 1; goto done; } else { - ScanLines = min(ScanLines, psurf->SurfObj.sizlBitmap.cy - StartScan); + ScanLines = min(ScanLines, abs(Info->bmiHeader.biHeight) - StartScan); } + if (abs(Info->bmiHeader.biHeight) < psurf->SurfObj.sizlBitmap.cy) + { + StartScan += psurf->SurfObj.sizlBitmap.cy - abs(Info->bmiHeader.biHeight); + } /* Fixup values */ - Info->bmiHeader.biWidth = psurf->SurfObj.sizlBitmap.cx; Info->bmiHeader.biHeight = (height < 0) ? -(LONG)ScanLines : ScanLines; /* Create the DIB */ hBmpDest = DIB_CreateDIBSection(pDC, Info, Usage, &pDIBits, NULL, 0, 0); /* Restore them */ - Info->bmiHeader.biWidth = width; Info->bmiHeader.biHeight = height; if(!hBmpDest) @@ -982,27 +985,33 @@ GreGetDIBitsInternal( psurfDest = SURFACE_ShareLockSurface(hBmpDest); - RECTL_vSetRect(&rcDest, 0, 0, psurf->SurfObj.sizlBitmap.cx, ScanLines); - + RECTL_vSetRect(&rcDest, 0, 0, Info->bmiHeader.biWidth, ScanLines); + Info->bmiHeader.biWidth = width; srcPoint.x = 0; - if(height < 0) + if (abs(Info->bmiHeader.biHeight) <= psurf->SurfObj.sizlBitmap.cy) { - srcPoint.y = 0; - - if(ScanLines <= StartScan) - { - ScanLines = 1; - SURFACE_ShareUnlockSurface(psurfDest); - GreDeleteObject(hBmpDest); - goto done; - } - - ScanLines -= StartScan; + srcPoint.y = psurf->SurfObj.sizlBitmap.cy - StartScan - ScanLines; } else { - srcPoint.y = StartScan; + /* Determine the actual number of lines copied from the */ + /* original bitmap. It might be different from ScanLines. */ + newLines = abs(Info->bmiHeader.biHeight) - psurf->SurfObj.sizlBitmap.cy; + newLines = min((int)(StartScan + ScanLines - newLines), psurf->SurfObj.sizlBitmap.cy); + if (newLines > 0) + { + srcPoint.y = psurf->SurfObj.sizlBitmap.cy - newLines; + if (StartScan > psurf->SurfObj.sizlBitmap.cy) + { + newLines -= (StartScan - psurf->SurfObj.sizlBitmap.cy); + } + } + else + { + newLines = 0; + srcPoint.y = psurf->SurfObj.sizlBitmap.cy; + } } EXLATEOBJ_vInitialize(&exlo, psurf->ppal, psurfDest->ppal, 0xffffff, 0xffffff, 0); @@ -1022,7 +1031,11 @@ GreGetDIBitsInternal( { RtlCopyMemory(Bits, pDIBits, DIB_GetDIBImageBytes (width, ScanLines, bpp)); } - + /* Update if line count has changed */ + if (newLines != -1) + { + ScanLines = (UINT)newLines; + } GreDeleteObject(hBmpDest); EXLATEOBJ_vCleanup(&exlo); }