diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2023-01-12 16:42:39 +0100 |
---|---|---|
committer | Christian Lohmaier <lohmaier+LibreOffice@googlemail.com> | 2023-01-12 20:24:18 +0000 |
commit | c21cf015dc913713dcd4c343e2562c80b6469303 (patch) | |
tree | ebf814e7d5042fd8731ce9924f5e43edfff21fe3 | |
parent | Curl:CURLOPT_REDIR_PROTOCOLS(_STR): use only "https", not "http" (diff) | |
download | core-c21cf015dc913713dcd4c343e2562c80b6469303.tar.gz core-c21cf015dc913713dcd4c343e2562c80b6469303.zip |
Fix VclTextTest with colorized antialiasing
The Flathub build for
<https://github.com/flathub/org.libreoffice.LibreOffice/commit/d5ac1d2bd680970ba992c8c6836683262f067592>
"Merge pull request #206 from flathub/lo-7.4.4" on 2023-01-12 at
<https://buildbot.flathub.org/#/builders/6/builds/16778> consistently failed for
both aarch64 and x86_64 builds with
> text.cxx:260:Assertion
> Test name: VclTextTest::testSimpleText
> double equality assertion failed
> - Expected: 28
> - Actual : -1
> - Delta : 2
during CppunitTest_vcl_text. The reason (as seen with a temporary build setting
mbExportBitmap = true and looking at the resulting
workdir/CppunitTest/vcl_text.test.core/simple-text-36-50pct.png) is that the
stem of the "L" doesn't contain any COL_BLACK pixels, so
getCharacterLeftSideHeight returns early with -1. The stem is drawn as three
vertical lines of pixels, a yellow (RGB 255/195/111), a black-ish (RGB 23/0/0),
and a blue (RGB 31/155/199) one. In comparison, when running the same test on
Fedora 37, the three vertical lines use gray-scale instead of colors,
RGB 195/195/195, then true black (RGB 0/0/0), and RGB 115/115/115.
An earlier test build of
<https://github.com/flathub/org.libreoffice.LibreOffice/pull/206> "Update to
LibreOffice 7.4.4" for the same libreoffice-7.4.4.2 tag on 2023-01-02 at
<https://buildbot.flathub.org/#/builders/6/builds/14712> succeeded, so I assume
that it must be some change in the meantime to the underlying
org.fedoraproject.sdk//22.08 that started to cause colorized antialiasing here.
Change-Id: I7059268eabcfe8e501d0be4f38746707def7bb35
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145411
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
(cherry picked from commit 933519505aee0e91ca99af0ed860e4a0f148f922)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145313
Reviewed-by: Christian Lohmaier <lohmaier+LibreOffice@googlemail.com>
-rw-r--r-- | vcl/qa/cppunit/text.cxx | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/vcl/qa/cppunit/text.cxx b/vcl/qa/cppunit/text.cxx index 69365f98a00e..833022ee2204 100644 --- a/vcl/qa/cppunit/text.cxx +++ b/vcl/qa/cppunit/text.cxx @@ -99,6 +99,13 @@ public: CPPUNIT_TEST_SUITE_END(); }; +// Avoid issues when colorized antialiasing generates slightly tinted rather than truly black +// pixels: +static bool isBlack(Color col) +{ + return col.GetRed() < 25 && col.GetGreen() < 25 && col.GetBlue() < 25; +} + // Return pixel width of the base of the given character located above // the starting position. // In other words, go up in y direction until a black pixel is found, @@ -109,7 +116,7 @@ static tools::Long getCharacterBaseWidth(VirtualDevice* device, const Point& sta Bitmap bitmap = device->GetBitmap(Point(), device->GetOutputSizePixel()); Bitmap::ScopedReadAccess access(bitmap); tools::Long y = start.Y(); - while (y >= 0 && access->GetColor(y, start.X()) != COL_BLACK) + while (y >= 0 && !isBlack(access->GetColor(y, start.X()))) --y; if (y < 0) return -1; @@ -128,7 +135,7 @@ static tools::Long getCharacterTopWidth(VirtualDevice* device, const Point& star Bitmap bitmap = device->GetBitmap(Point(), device->GetOutputSizePixel()); Bitmap::ScopedReadAccess access(bitmap); tools::Long y = start.Y(); - while (y < bitmap.GetSizePixel().Height() && access->GetColor(y, start.X()) != COL_BLACK) + while (y < bitmap.GetSizePixel().Height() && !isBlack(access->GetColor(y, start.X()))) ++y; if (y >= bitmap.GetSizePixel().Height()) return -1; @@ -149,7 +156,7 @@ static tools::Long getCharacterLeftSideHeight(VirtualDevice* device, const Point Bitmap bitmap = device->GetBitmap(Point(), device->GetOutputSizePixel()); Bitmap::ScopedReadAccess access(bitmap); tools::Long x = start.X(); - while (x < bitmap.GetSizePixel().Width() && access->GetColor(start.Y(), x) != COL_BLACK) + while (x < bitmap.GetSizePixel().Width() && !isBlack(access->GetColor(start.Y(), x))) ++x; if (x >= bitmap.GetSizePixel().Width()) return -1; |