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.kaganski@collabora.com>
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
This commit is contained in:
Christopher Sherlock 2025-01-15 17:53:50 +11:00 committed by Michael Weghorn
parent 94d851b27f
commit f7af54d39a

View File

@ -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));
}
Scanline pScanContent = pContent->GetScanline(0);
Scanline pScanAlpha = pContent->GetScanline(0);
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);
// 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);
tools::Long x(0);
const tools::Long nW(rSize.Width());
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
// 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);
}