vcl/source/bitmap/BlendFrameCache.cxx | 133 ++++++++++++++++------------------ 1 file changed, 66 insertions(+), 67 deletions(-)
New commits: commit f7af54d39a402b24f55bcfd9c1d906b9c8b3dac8 Author: Christopher Sherlock <chris.sherloc...@gmail.com> AuthorDate: Wed Jan 15 17:53:50 2025 +1100 Commit: Michael Weghorn <m.wegh...@posteo.de> CommitDate: Fri Jan 17 23:08:28 2025 +0100 vcl: followup to remove unnecessary resets Followup for 44dfcebde64b9edfa9f50eace34e5e1497ab9314 Just enclose it in the correct scope. Change-Id: I3bb3bfa0fa8bc5996d728f175aad16b64da52166 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/180260 Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com> Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.wegh...@posteo.de> diff --git a/vcl/source/bitmap/BlendFrameCache.cxx b/vcl/source/bitmap/BlendFrameCache.cxx index fc883710c988..56738369fbb2 100644 --- a/vcl/source/bitmap/BlendFrameCache.cxx +++ b/vcl/source/bitmap/BlendFrameCache.cxx @@ -43,93 +43,92 @@ BlendFrameCache::BlendFrameCache(Size const& rSize, sal_uInt8 nAlpha, Color cons aContent.Erase(COL_BLACK); - BitmapScopedWriteAccess pContent(aContent); - BitmapScopedWriteAccess pAlpha(aAlpha); - - if (!pContent || !pAlpha) - return; - - Scanline pScanContent = pContent->GetScanline(0); - Scanline pScanAlpha = pContent->GetScanline(0); - - // x == 0, y == 0, top-left corner - pContent->SetPixelOnData(pScanContent, 0, rColorTopLeft); - pAlpha->SetPixelOnData(pScanAlpha, 0, BitmapColor(nAlpha)); - - tools::Long x(0); - const tools::Long nW(rSize.Width()); - - // y == 0, top line left to right - for (x = 1; x < nW - 1; x++) { - Color aMix(rColorTopLeft); + BitmapScopedWriteAccess pContent(aContent); + BitmapScopedWriteAccess pAlpha(aAlpha); - aMix.Merge(rColorTopRight, 255 - sal_uInt8((x * 255) / nW)); - pContent->SetPixelOnData(pScanContent, x, aMix); - pAlpha->SetPixelOnData(pScanAlpha, x, BitmapColor(nAlpha)); - } + if (!pContent || !pAlpha) + return; - // x == nW - 1, y == 0, top-right corner - // #i123690# Caution! When nW is 1, x == nW is possible (!) - if (x < nW) - { - pContent->SetPixelOnData(pScanContent, x, rColorTopRight); - pAlpha->SetPixelOnData(pScanAlpha, x, BitmapColor(nAlpha)); - } - - tools::Long y(0); - const tools::Long nH(rSize.Height()); - - // x == 0 and nW - 1, left and right line top-down - for (y = 1; y < nH - 1; y++) - { - pScanContent = pContent->GetScanline(y); - pScanAlpha = pContent->GetScanline(y); - Color aMixA(rColorTopLeft); + Scanline pScanContent = pContent->GetScanline(0); + Scanline pScanAlpha = pContent->GetScanline(0); - aMixA.Merge(rColorBottomLeft, 255 - sal_uInt8((y * 255) / nH)); - pContent->SetPixelOnData(pScanContent, 0, aMixA); + // x == 0, y == 0, top-left corner + pContent->SetPixelOnData(pScanContent, 0, rColorTopLeft); pAlpha->SetPixelOnData(pScanAlpha, 0, BitmapColor(nAlpha)); - // #i123690# Caution! When nW is 1, x == nW is possible (!) - if (x < nW) - { - Color aMixB(rColorTopRight); - - aMixB.Merge(rColorBottomRight, 255 - sal_uInt8((y * 255) / nH)); - pContent->SetPixelOnData(pScanContent, x, aMixB); - pAlpha->SetPixelOnData(pScanAlpha, x, BitmapColor(nAlpha)); - } - } - - // #i123690# Caution! When nH is 1, y == nH is possible (!) - if (y < nH) - { - // x == 0, y == nH - 1, bottom-left corner - pContent->SetPixelOnData(pScanContent, 0, rColorBottomLeft); - pAlpha->SetPixelOnData(pScanAlpha, 0, BitmapColor(nAlpha)); + tools::Long x(0); + const tools::Long nW(rSize.Width()); - // y == nH - 1, bottom line left to right + // y == 0, top line left to right for (x = 1; x < nW - 1; x++) { - Color aMix(rColorBottomLeft); + Color aMix(rColorTopLeft); - aMix.Merge(rColorBottomRight, 255 - sal_uInt8(((x - 0) * 255) / nW)); + aMix.Merge(rColorTopRight, 255 - sal_uInt8((x * 255) / nW)); pContent->SetPixelOnData(pScanContent, x, aMix); pAlpha->SetPixelOnData(pScanAlpha, x, BitmapColor(nAlpha)); } - // x == nW - 1, y == nH - 1, bottom-right corner + // x == nW - 1, y == 0, top-right corner // #i123690# Caution! When nW is 1, x == nW is possible (!) if (x < nW) { - pContent->SetPixelOnData(pScanContent, x, rColorBottomRight); + pContent->SetPixelOnData(pScanContent, x, rColorTopRight); pAlpha->SetPixelOnData(pScanAlpha, x, BitmapColor(nAlpha)); } - } - pContent.reset(); - pAlpha.reset(); + tools::Long y(0); + const tools::Long nH(rSize.Height()); + + // x == 0 and nW - 1, left and right line top-down + for (y = 1; y < nH - 1; y++) + { + pScanContent = pContent->GetScanline(y); + pScanAlpha = pContent->GetScanline(y); + Color aMixA(rColorTopLeft); + + aMixA.Merge(rColorBottomLeft, 255 - sal_uInt8((y * 255) / nH)); + pContent->SetPixelOnData(pScanContent, 0, aMixA); + pAlpha->SetPixelOnData(pScanAlpha, 0, BitmapColor(nAlpha)); + + // #i123690# Caution! When nW is 1, x == nW is possible (!) + if (x < nW) + { + Color aMixB(rColorTopRight); + + aMixB.Merge(rColorBottomRight, 255 - sal_uInt8((y * 255) / nH)); + pContent->SetPixelOnData(pScanContent, x, aMixB); + pAlpha->SetPixelOnData(pScanAlpha, x, BitmapColor(nAlpha)); + } + } + + // #i123690# Caution! When nH is 1, y == nH is possible (!) + if (y < nH) + { + // x == 0, y == nH - 1, bottom-left corner + pContent->SetPixelOnData(pScanContent, 0, rColorBottomLeft); + pAlpha->SetPixelOnData(pScanAlpha, 0, BitmapColor(nAlpha)); + + // y == nH - 1, bottom line left to right + for (x = 1; x < nW - 1; x++) + { + Color aMix(rColorBottomLeft); + + aMix.Merge(rColorBottomRight, 255 - sal_uInt8(((x - 0) * 255) / nW)); + pContent->SetPixelOnData(pScanContent, x, aMix); + pAlpha->SetPixelOnData(pScanAlpha, x, BitmapColor(nAlpha)); + } + + // x == nW - 1, y == nH - 1, bottom-right corner + // #i123690# Caution! When nW is 1, x == nW is possible (!) + if (x < nW) + { + pContent->SetPixelOnData(pScanContent, x, rColorBottomRight); + pAlpha->SetPixelOnData(pScanAlpha, x, BitmapColor(nAlpha)); + } + } + } m_aLastResult = BitmapEx(aContent, aAlpha); }