[Libreoffice-commits] core.git: vcl/CppunitTest_vcl_gen.mk vcl/opengl vcl/qa

Miklos Vajna (via logerrit) logerrit at kemper.freedesktop.org
Fri Mar 29 14:21:16 UTC 2019


 vcl/CppunitTest_vcl_gen.mk |    1 +
 vcl/opengl/gdiimpl.cxx     |    5 +++++
 vcl/qa/cppunit/gen/gen.cxx |   36 +++++++++++++++++++++++++++++++++++-
 3 files changed, 41 insertions(+), 1 deletion(-)

New commits:
commit 75e152a7e8f384921d4417d0fb5d2db6a6f357cb
Author:     Miklos Vajna <vmiklos at collabora.com>
AuthorDate: Fri Mar 29 13:40:21 2019 +0100
Commit:     Miklos Vajna <vmiklos at collabora.com>
CommitDate: Fri Mar 29 15:20:49 2019 +0100

    tdf#107966 vcl opengl: fix not drawn 1px wide polypolygons
    
    Visible at e.g. in Calc: Format Cells/Borders/Line Styles.
    
    The problem was that first commit
    2e99e4e11d33679aed674eea0d6054d16d39d6df (opengl: use MVP matrix in
    vertex shaders, pixel offsets, 2015-07-08) introduced the concept of
    pixel offsets, setting the value (implicitly) to 0 in
    OpenGLSalGraphicsImpl::DrawTrapezoid(), but using 0.5 in
    OpenGLSalGraphicsImpl::FlushLinesOrTriangles().
    
    This is fine, but then later commit
    2003076c4318511a3d621558d3b44b4e8e6c6529 (opengl: batch draw
    polypolygons, 2016-05-29) changed
    OpenGLSalGraphicsImpl::drawPolyPolygon() to use deferred drawing instead
    of DrawTrapezoid(), without doing any translation of the input
    polypolygon. This resulted in loss of those polygons when used in the
    above mentioned dialog, which has a listbox of bitmaps, where each line
    style preview is drawn on a virtual device with a height of 1px. So at
    the end the 1px offset meant the previews were simply missing.
    
    ('make CppunitTest_vcl_gen SAL_USE_VCLPLUGIN=gen SAL_FORCEGL=1' is
    needed on Linux to see the test failing without the fix.)
    
    Change-Id: Ia9f3d6e7cb38a43fe2f8a41746b538af68add43c
    Reviewed-on: https://gerrit.libreoffice.org/69920
    Reviewed-by: Miklos Vajna <vmiklos at collabora.com>
    Tested-by: Jenkins

diff --git a/vcl/CppunitTest_vcl_gen.mk b/vcl/CppunitTest_vcl_gen.mk
index 84dd0ca25bb0..d4f701782ee8 100644
--- a/vcl/CppunitTest_vcl_gen.mk
+++ b/vcl/CppunitTest_vcl_gen.mk
@@ -16,6 +16,7 @@ $(eval $(call gb_CppunitTest_add_exception_objects,vcl_gen, \
 ))
 
 $(eval $(call gb_CppunitTest_use_libraries,vcl_gen, \
+	basegfx \
 	comphelper \
 	cppu \
 	cppuhelper \
diff --git a/vcl/opengl/gdiimpl.cxx b/vcl/opengl/gdiimpl.cxx
index 3a15755eb7a9..1c0d3ecc91e2 100644
--- a/vcl/opengl/gdiimpl.cxx
+++ b/vcl/opengl/gdiimpl.cxx
@@ -1606,6 +1606,11 @@ bool OpenGLSalGraphicsImpl::drawPolyPolygon(
     basegfx::B2DPolyPolygon aPolyPolygon(rPolyPolygon);
     aPolyPolygon.transform(rObjectToDevice);
 
+    // FlushLinesOrTriangles() works with a 0.5 pixel offset, compensate for that here.
+    basegfx::B2DHomMatrix aMatrix;
+    aMatrix.translate(-0.5f, -0.5f);
+    aPolyPolygon.transform(aMatrix);
+
     mpRenderList->addDrawPolyPolygon(
         aPolyPolygon,
         fTransparency,
diff --git a/vcl/qa/cppunit/gen/gen.cxx b/vcl/qa/cppunit/gen/gen.cxx
index f5d1c1c6769c..37692a65d5a9 100644
--- a/vcl/qa/cppunit/gen/gen.cxx
+++ b/vcl/qa/cppunit/gen/gen.cxx
@@ -17,6 +17,7 @@
 #include <vcl/bitmapaccess.hxx>
 #include <vcl/pngwrite.hxx>
 #include <vcl/gdimtf.hxx>
+#include <vcl/virdev.hxx>
 #include <tools/stream.hxx>
 
 using namespace com::sun::star;
@@ -72,13 +73,46 @@ CPPUNIT_TEST_FIXTURE(GenTest, testTdf121120)
     const Size& rSize = aBitmap.GetPrefSize();
     Color aColor(pAccess->GetPixel(rSize.getWidth() / 2, rSize.getHeight() / 2).GetColor());
     // Without the accompanying fix in place, this test would have failed with 'Expected: 255;
-    // Actual  : 1'. I.e. center if the preview (which has the background color) was ~black, not
+    // Actual  : 1'. I.e. center of the preview (which has the background color) was ~black, not
     // white.
     CPPUNIT_ASSERT_EQUAL(0xff, int(aColor.GetRed()));
     CPPUNIT_ASSERT_EQUAL(0xff, int(aColor.GetBlue()));
     CPPUNIT_ASSERT_EQUAL(0xff, int(aColor.GetGreen()));
 }
 
+/// Test that drawing a line preview to a bitmap is not lost.
+CPPUNIT_TEST_FIXTURE(GenTest, testTdf107966)
+{
+    // Set up the virtual device: white background.
+    ScopedVclPtr<VirtualDevice> pVirtualDevice(VclPtr<VirtualDevice>::Create());
+    pVirtualDevice->SetLineColor();
+    MapMode aMapMode;
+    aMapMode.SetMapUnit(MapUnit::MapTwip);
+    pVirtualDevice->SetMapMode(aMapMode);
+    pVirtualDevice->SetOutputSizePixel(Size(90, 15));
+    pVirtualDevice->SetFillColor(Color(255, 255, 255));
+    pVirtualDevice->DrawRect(tools::Rectangle(Point(), Size(1350, 225)));
+    pVirtualDevice->SetFillColor(Color(0, 0, 0));
+    AntialiasingFlags nOldAA = pVirtualDevice->GetAntialiasing();
+    pVirtualDevice->SetAntialiasing(nOldAA & ~AntialiasingFlags::EnableB2dDraw);
+
+    // Paint a black polygon on it.
+    basegfx::B2DPolygon aPolygon;
+    aPolygon.append(basegfx::B2DPoint(0, 15));
+    aPolygon.append(basegfx::B2DPoint(1350, 15));
+    aPolygon.append(basegfx::B2DPoint(1350, 0));
+    aPolygon.append(basegfx::B2DPoint(0, 0));
+    pVirtualDevice->DrawPolygon(aPolygon);
+
+    // Make sure that the polygon is visible.
+    Bitmap aBitmap = pVirtualDevice->GetBitmap(Point(), Size(1350, 15));
+    Bitmap::ScopedReadAccess pAccess(aBitmap);
+    Color aPixel(pAccess->GetPixel(0, 0).GetColor());
+    // Without the accompanying fix in place, this test would have failed with 'Expected: 000000;
+    // Actual: ffffff', i.e. the top left pixel was white, not black.
+    CPPUNIT_ASSERT_EQUAL(OUString("000000"), aPixel.AsRGBHexString());
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */


More information about the Libreoffice-commits mailing list