compilerplugins/clang/constantparam.constructors.results |    2 -
 desktop/source/lib/init.cxx                              |    6 +--
 include/vcl/virdev.hxx                                   |    8 ++---
 sc/qa/unit/tiledrendering/tiledrendering.cxx             |    6 +--
 sw/qa/extras/tiledrendering/tiledrendering.cxx           |   22 ++++++-------
 vcl/headless/svpvd.cxx                                   |   24 ++++++---------
 vcl/source/gdi/virdev.cxx                                |   19 ++++++-----
 7 files changed, 43 insertions(+), 44 deletions(-)

New commits:
commit ffe7e9bb1f099b1d517ab6a082793fa58330eccd
Author:     Luboš Luňák <l.lu...@collabora.com>
AuthorDate: Fri Jun 10 12:33:53 2022 +0200
Commit:     Luboš Luňák <l.lu...@collabora.com>
CommitDate: Fri Jun 17 14:29:32 2022 +0200

    make VirtualDevice::SetOutputSizePixelScaleOffsetAndBuffer() LOK-only
    
    Because it's used only for LOK, and SvpSalVirtualDevice::CreateSurface()
    otherwise wouldn't know whether to apply LOK DPI settings or not
    (since this might be called for LOK tiled painting, when it should,
    or it might be called from somewhere else while LOK is active, in which
    case this should be handled normally). Getting that mismatched can cause
    things like https://github.com/CollaboraOnline/online/issues/4834 .
    
    Change-Id: I1df7b8a169c8ef2e799731a6695a032948536582
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135546
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com>
    Reviewed-by: Luboš Luňák <l.lu...@collabora.com>

diff --git a/compilerplugins/clang/constantparam.constructors.results 
b/compilerplugins/clang/constantparam.constructors.results
index bbb7f36f287a..c8348bc45827 100644
--- a/compilerplugins/clang/constantparam.constructors.results
+++ b/compilerplugins/clang/constantparam.constructors.results
@@ -527,7 +527,7 @@ include/vcl/transfer.hxx:358
     const class rtl::OUString & rDestDoc
     ""
 include/vcl/virdev.hxx:164
-    _Bool VirtualDevice::SetOutputSizePixelScaleOffsetAndBuffer(const class 
Size &,const class Fraction &,const class Point &,unsigned char *)
+    _Bool VirtualDevice::SetOutputSizePixelScaleOffsetAndLOKBuffer(const class 
Size &,const class Fraction &,const class Point &,unsigned char *)
     const class Point & rNewOffset
     Point()
 include/vcl/weld.hxx:635
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 51167cf7871b..5b4434b75e22 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -3489,7 +3489,7 @@ static void doc_paintTile(LibreOfficeKitDocument* pThis,
     // Set background to transparent by default.
     pDevice->SetBackground(Wallpaper(COL_TRANSPARENT));
 
-    pDevice->SetOutputSizePixelScaleOffsetAndBuffer(
+    pDevice->SetOutputSizePixelScaleOffsetAndLOKBuffer(
                 Size(nCanvasWidth, nCanvasHeight), Fraction(1.0), Point(),
                 pBuffer);
 
@@ -5734,7 +5734,7 @@ unsigned char* 
doc_renderFontOrientation(SAL_UNUSED_PARAMETER LibreOfficeKitDocu
 
     memset(pBuffer, 0, nFontWidth * nFontHeight * 4);
     aDevice->SetBackground(Wallpaper(COL_TRANSPARENT));
-    aDevice->SetOutputSizePixelScaleOffsetAndBuffer(
+    aDevice->SetOutputSizePixelScaleOffsetAndLOKBuffer(
                 Size(nFontWidth, nFontHeight), Fraction(1.0), Point(),
                 pBuffer);
 
@@ -5834,7 +5834,7 @@ static void 
doc_paintWindowForView(LibreOfficeKitDocument* pThis, unsigned nLOKW
     ScopedVclPtrInstance<VirtualDevice> pDevice(DeviceFormat::DEFAULT);
     pDevice->SetBackground(Wallpaper(COL_TRANSPARENT));
 
-    pDevice->SetOutputSizePixelScaleOffsetAndBuffer(Size(nWidth, nHeight), 
Fraction(1.0), Point(), pBuffer);
+    pDevice->SetOutputSizePixelScaleOffsetAndLOKBuffer(Size(nWidth, nHeight), 
Fraction(1.0), Point(), pBuffer);
 
     MapMode aMapMode(pDevice->GetMapMode());
     aMapMode.SetOrigin(Point(-(nX / fDPIScale), -(nY / fDPIScale)));
diff --git a/include/vcl/virdev.hxx b/include/vcl/virdev.hxx
index 459660eb71cd..b611e7f8aecd 100644
--- a/include/vcl/virdev.hxx
+++ b/include/vcl/virdev.hxx
@@ -154,10 +154,10 @@ public:
     virtual void        EnableRTL( bool bEnable = true ) override;
 
     bool                SetOutputSizePixel( const Size& rNewSize, bool bErase 
= true );
-    bool                SetOutputSizePixelScaleOffsetAndBuffer( const Size& 
rNewSize,
-                                                                const 
Fraction& rScale,
-                                                                const Point& 
rNewOffset,
-                                                                sal_uInt8* 
pBuffer);
+    bool                SetOutputSizePixelScaleOffsetAndLOKBuffer( const Size& 
rNewSize,
+                                                                   const 
Fraction& rScale,
+                                                                   const 
Point& rNewOffset,
+                                                                   sal_uInt8* 
pBuffer);
 
     bool                SetOutputSize( const Size& rNewSize )
                             { return SetOutputSizePixel( LogicToPixel( 
rNewSize ) ); }
diff --git a/sc/qa/unit/tiledrendering/tiledrendering.cxx 
b/sc/qa/unit/tiledrendering/tiledrendering.cxx
index 4d947cb4f600..38f1affe2ebc 100644
--- a/sc/qa/unit/tiledrendering/tiledrendering.cxx
+++ b/sc/qa/unit/tiledrendering/tiledrendering.cxx
@@ -1505,7 +1505,7 @@ void 
ScTiledRenderingTest::testInsertGraphicInvalidations()
     int nCanvasHeight = 256;
     std::vector<unsigned char> aBuffer(nCanvasWidth * nCanvasHeight * 4);
     ScopedVclPtrInstance<VirtualDevice> pDevice(DeviceFormat::DEFAULT);
-    pDevice->SetOutputSizePixelScaleOffsetAndBuffer(Size(nCanvasWidth, 
nCanvasHeight), Fraction(1.0), Point(), aBuffer.data());
+    pDevice->SetOutputSizePixelScaleOffsetAndLOKBuffer(Size(nCanvasWidth, 
nCanvasHeight), Fraction(1.0), Point(), aBuffer.data());
     pModelObj->paintTile(*pDevice, nCanvasWidth, nCanvasHeight, 
/*nTilePosX=*/0, /*nTilePosY=*/0, /*nTileWidth=*/3840, /*nTileHeight=*/3840);
     Scheduler::ProcessEventsToIdle();
 
@@ -1543,7 +1543,7 @@ void ScTiledRenderingTest::testDocumentSizeWithTwoViews()
     int nCanvasHeight = 256;
     std::vector<unsigned char> aBuffer1(nCanvasWidth * nCanvasHeight * 4);
     ScopedVclPtrInstance<VirtualDevice> pDevice1(DeviceFormat::DEFAULT);
-    pDevice1->SetOutputSizePixelScaleOffsetAndBuffer(Size(nCanvasWidth, 
nCanvasHeight), Fraction(1.0), Point(), aBuffer1.data());
+    pDevice1->SetOutputSizePixelScaleOffsetAndLOKBuffer(Size(nCanvasWidth, 
nCanvasHeight), Fraction(1.0), Point(), aBuffer1.data());
     pModelObj->paintTile(*pDevice1, nCanvasWidth, nCanvasHeight, 
/*nTilePosX=*/0, /*nTilePosY=*/291840, /*nTileWidth=*/3840, 
/*nTileHeight=*/3840);
     Scheduler::ProcessEventsToIdle();
 
@@ -1553,7 +1553,7 @@ void ScTiledRenderingTest::testDocumentSizeWithTwoViews()
 
     std::vector<unsigned char> aBuffer2(nCanvasWidth * nCanvasHeight * 4);
     ScopedVclPtrInstance<VirtualDevice> pDevice2(DeviceFormat::DEFAULT);
-    pDevice2->SetOutputSizePixelScaleOffsetAndBuffer(Size(nCanvasWidth, 
nCanvasHeight), Fraction(1.0), Point(), aBuffer2.data());
+    pDevice2->SetOutputSizePixelScaleOffsetAndLOKBuffer(Size(nCanvasWidth, 
nCanvasHeight), Fraction(1.0), Point(), aBuffer2.data());
     pModelObj->paintTile(*pDevice2, nCanvasWidth, nCanvasHeight, 
/*nTilePosX=*/0, /*nTilePosY=*/291840, /*nTileWidth=*/3840, 
/*nTileHeight=*/3840);
     Scheduler::ProcessEventsToIdle();
 
diff --git a/sw/qa/extras/tiledrendering/tiledrendering.cxx 
b/sw/qa/extras/tiledrendering/tiledrendering.cxx
index 80125d1c31d5..6db7cd57dfdd 100644
--- a/sw/qa/extras/tiledrendering/tiledrendering.cxx
+++ b/sw/qa/extras/tiledrendering/tiledrendering.cxx
@@ -1838,7 +1838,7 @@ CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, 
testPaintCallbacks)
     int nCanvasHeight = 256;
     std::vector<unsigned char> aBuffer(nCanvasWidth * nCanvasHeight * 4);
     ScopedVclPtrInstance<VirtualDevice> pDevice(DeviceFormat::DEFAULT);
-    pDevice->SetOutputSizePixelScaleOffsetAndBuffer(Size(nCanvasWidth, 
nCanvasHeight), Fraction(1.0), Point(), aBuffer.data());
+    pDevice->SetOutputSizePixelScaleOffsetAndLOKBuffer(Size(nCanvasWidth, 
nCanvasHeight), Fraction(1.0), Point(), aBuffer.data());
     // Make sure that painting a tile in the second view doesn't invoke
     // callbacks on the first view.
     aView1.m_bCalled = false;
@@ -2682,7 +2682,7 @@ CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, 
testSemiTransparent)
     std::vector<unsigned char> aPixmap(nCanvasWidth * nCanvasHeight * 4, 0);
     ScopedVclPtrInstance<VirtualDevice> pDevice(DeviceFormat::DEFAULT);
     pDevice->SetBackground(Wallpaper(COL_TRANSPARENT));
-    pDevice->SetOutputSizePixelScaleOffsetAndBuffer(Size(nCanvasWidth, 
nCanvasHeight),
+    pDevice->SetOutputSizePixelScaleOffsetAndLOKBuffer(Size(nCanvasWidth, 
nCanvasHeight),
             Fraction(1.0), Point(), aPixmap.data());
     pXTextDocument->paintTile(*pDevice, nCanvasWidth, nCanvasHeight, 
/*nTilePosX=*/0,
             /*nTilePosY=*/0, /*nTileWidth=*/15360, /*nTileHeight=*/7680);
@@ -2711,7 +2711,7 @@ CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, 
testHighlightNumbering)
     std::vector<unsigned char> aPixmap(nCanvasWidth * nCanvasHeight * 4, 0);
     ScopedVclPtrInstance<VirtualDevice> pDevice(DeviceFormat::DEFAULT);
     pDevice->SetBackground(Wallpaper(COL_TRANSPARENT));
-    pDevice->SetOutputSizePixelScaleOffsetAndBuffer(Size(nCanvasWidth, 
nCanvasHeight),
+    pDevice->SetOutputSizePixelScaleOffsetAndLOKBuffer(Size(nCanvasWidth, 
nCanvasHeight),
             Fraction(1.0), Point(), aPixmap.data());
     pXTextDocument->paintTile(*pDevice, nCanvasWidth, nCanvasHeight, 
/*nTilePosX=*/0,
             /*nTilePosY=*/0, /*nTileWidth=*/15360, /*nTileHeight=*/7680);
@@ -2736,7 +2736,7 @@ CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, 
testHighlightNumbering_shd)
     std::vector<unsigned char> aPixmap(nCanvasWidth * nCanvasHeight * 4, 0);
     ScopedVclPtrInstance<VirtualDevice> pDevice(DeviceFormat::DEFAULT);
     pDevice->SetBackground(Wallpaper(COL_TRANSPARENT));
-    pDevice->SetOutputSizePixelScaleOffsetAndBuffer(Size(nCanvasWidth, 
nCanvasHeight),
+    pDevice->SetOutputSizePixelScaleOffsetAndLOKBuffer(Size(nCanvasWidth, 
nCanvasHeight),
             Fraction(1.0), Point(), aPixmap.data());
     pXTextDocument->paintTile(*pDevice, nCanvasWidth, nCanvasHeight, 
/*nTilePosX=*/0,
             /*nTilePosY=*/0, /*nTileWidth=*/15360, /*nTileHeight=*/7680);
@@ -2766,7 +2766,7 @@ CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, 
testPilcrowRedlining)
     std::vector<unsigned char> aPixmap(nCanvasWidth * nCanvasHeight * 4, 0);
     ScopedVclPtrInstance<VirtualDevice> pDevice(DeviceFormat::DEFAULT);
     pDevice->SetBackground(Wallpaper(COL_TRANSPARENT));
-    pDevice->SetOutputSizePixelScaleOffsetAndBuffer(Size(nCanvasWidth, 
nCanvasHeight),
+    pDevice->SetOutputSizePixelScaleOffsetAndLOKBuffer(Size(nCanvasWidth, 
nCanvasHeight),
             Fraction(1.0), Point(), aPixmap.data());
     pXTextDocument->paintTile(*pDevice, nCanvasWidth, nCanvasHeight, 
/*nTilePosX=*/0,
             /*nTilePosY=*/0, /*nTileWidth=*/15360, /*nTileHeight=*/7680);
@@ -2830,7 +2830,7 @@ CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, testClipText)
     std::vector<unsigned char> aPixmap(nCanvasWidth * nCanvasHeight * 4, 0);
     ScopedVclPtrInstance<VirtualDevice> pDevice(DeviceFormat::DEFAULT);
     pDevice->SetBackground(Wallpaper(COL_TRANSPARENT));
-    pDevice->SetOutputSizePixelScaleOffsetAndBuffer(Size(nCanvasWidth, 
nCanvasHeight),
+    pDevice->SetOutputSizePixelScaleOffsetAndLOKBuffer(Size(nCanvasWidth, 
nCanvasHeight),
             Fraction(1.0), Point(), aPixmap.data());
     pXTextDocument->paintTile(*pDevice, nCanvasWidth, nCanvasHeight, 
/*nTilePosX=*/0,
             /*nTilePosY=*/0, /*nTileWidth=*/15360, /*nTileHeight=*/7680);
@@ -2959,7 +2959,7 @@ CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, 
testDropDownFormFieldButton)
     std::vector<unsigned char> aPixmap(nCanvasWidth * nCanvasHeight * 4, 0);
     ScopedVclPtrInstance<VirtualDevice> pDevice(DeviceFormat::DEFAULT);
     pDevice->SetBackground(Wallpaper(COL_TRANSPARENT));
-    pDevice->SetOutputSizePixelScaleOffsetAndBuffer(Size(nCanvasWidth, 
nCanvasHeight),
+    pDevice->SetOutputSizePixelScaleOffsetAndLOKBuffer(Size(nCanvasWidth, 
nCanvasHeight),
             Fraction(1.0), Point(), aPixmap.data());
     pXTextDocument->paintTile(*pDevice, nCanvasWidth, nCanvasHeight, 
/*nTilePosX=*/0,
             /*nTilePosY=*/0, /*nTileWidth=*/10000, /*nTileHeight=*/4000);
@@ -3032,7 +3032,7 @@ CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, 
testDropDownFormFieldButtonEditing)
     std::vector<unsigned char> aPixmap(nCanvasWidth * nCanvasHeight * 4, 0);
     ScopedVclPtrInstance<VirtualDevice> pDevice(DeviceFormat::DEFAULT);
     pDevice->SetBackground(Wallpaper(COL_TRANSPARENT));
-    pDevice->SetOutputSizePixelScaleOffsetAndBuffer(Size(nCanvasWidth, 
nCanvasHeight),
+    pDevice->SetOutputSizePixelScaleOffsetAndLOKBuffer(Size(nCanvasWidth, 
nCanvasHeight),
             Fraction(1.0), Point(), aPixmap.data());
     pXTextDocument->paintTile(*pDevice, nCanvasWidth, nCanvasHeight, 
/*nTilePosX=*/0,
             /*nTilePosY=*/0, /*nTileWidth=*/10000, /*nTileHeight=*/4000);
@@ -3089,7 +3089,7 @@ CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, 
testDropDownFormFieldButtonNoSelectio
     std::vector<unsigned char> aPixmap(nCanvasWidth * nCanvasHeight * 4, 0);
     ScopedVclPtrInstance<VirtualDevice> pDevice(DeviceFormat::DEFAULT);
     pDevice->SetBackground(Wallpaper(COL_TRANSPARENT));
-    pDevice->SetOutputSizePixelScaleOffsetAndBuffer(Size(nCanvasWidth, 
nCanvasHeight),
+    pDevice->SetOutputSizePixelScaleOffsetAndLOKBuffer(Size(nCanvasWidth, 
nCanvasHeight),
             Fraction(1.0), Point(), aPixmap.data());
     pXTextDocument->paintTile(*pDevice, nCanvasWidth, nCanvasHeight, 
/*nTilePosX=*/0,
             /*nTilePosY=*/0, /*nTileWidth=*/10000, /*nTileHeight=*/4000);
@@ -3175,7 +3175,7 @@ CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, 
testDropDownFormFieldButtonNoItem)
     std::vector<unsigned char> aPixmap(nCanvasWidth * nCanvasHeight * 4, 0);
     ScopedVclPtrInstance<VirtualDevice> pDevice(DeviceFormat::DEFAULT);
     pDevice->SetBackground(Wallpaper(COL_TRANSPARENT));
-    pDevice->SetOutputSizePixelScaleOffsetAndBuffer(Size(nCanvasWidth, 
nCanvasHeight),
+    pDevice->SetOutputSizePixelScaleOffsetAndLOKBuffer(Size(nCanvasWidth, 
nCanvasHeight),
                                                     Fraction(1.0), Point(), 
aPixmap.data());
     pXTextDocument->paintTile(*pDevice, nCanvasWidth, nCanvasHeight, 
/*nTilePosX=*/0,
                               /*nTilePosY=*/0, /*nTileWidth=*/10000, 
/*nTileHeight=*/4000);
@@ -3212,7 +3212,7 @@ CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, 
testTablePaintInvalidate)
     std::vector<unsigned char> aPixmap(nCanvasWidth * nCanvasHeight * 4, 0);
     ScopedVclPtrInstance<VirtualDevice> pDevice(DeviceFormat::DEFAULT);
     pDevice->SetBackground(Wallpaper(COL_TRANSPARENT));
-    pDevice->SetOutputSizePixelScaleOffsetAndBuffer(Size(nCanvasWidth, 
nCanvasHeight),
+    pDevice->SetOutputSizePixelScaleOffsetAndLOKBuffer(Size(nCanvasWidth, 
nCanvasHeight),
                                                     Fraction(1.0), Point(), 
aPixmap.data());
     pXTextDocument->paintTile(*pDevice, nCanvasWidth, nCanvasHeight, 
m_aInvalidation.Left(),
                               m_aInvalidation.Top(), /*nTileWidth=*/1000,
diff --git a/vcl/headless/svpvd.cxx b/vcl/headless/svpvd.cxx
index 21d231b229e9..ff02ca6770e5 100644
--- a/vcl/headless/svpvd.cxx
+++ b/vcl/headless/svpvd.cxx
@@ -76,28 +76,24 @@ void SvpSalVirtualDevice::CreateSurface(tools::Long nNewDX, 
tools::Long nNewDY,
         cairo_surface_destroy(m_pSurface);
     }
 
-    double fXScale, fYScale;
-    if (comphelper::LibreOfficeKit::isActive())
-    {
-        // Force scaling of the painting
-        fXScale = fYScale = comphelper::LibreOfficeKit::getDPIScale();
-    }
-    else
-    {
-        dl_cairo_surface_get_device_scale(m_pRefSurface, &fXScale, &fYScale);
-    }
-
     if (pBuffer)
     {
-        nNewDX *= fXScale;
-        nNewDY *= fYScale;
+        // The buffer should only be set by 
VirtualDevice::SetOutputSizePixelScaleOffsetAndLOKBuffer()
+        // when used to draw a tile for LOK. It cannot be used for something 
else, because otherwise
+        // this would need a way to detect whether this is a tiled paint that 
needs LOK handling
+        // or whether it's that something else that just might happen to be 
called with LOK active.
+        assert(comphelper::LibreOfficeKit::isActive());
+        // Force scaling of the painting
+        double fScale = comphelper::LibreOfficeKit::getDPIScale();
 
         m_pSurface = cairo_image_surface_create_for_data(pBuffer, 
CAIRO_FORMAT_ARGB32,
                             nNewDX, nNewDY, 
cairo_format_stride_for_width(CAIRO_FORMAT_ARGB32, nNewDX));
-        dl_cairo_surface_set_device_scale(m_pSurface, fXScale, fYScale);
+        dl_cairo_surface_set_device_scale(m_pSurface, fScale, fScale);
     }
     else if(nNewDX <= 32 && nNewDY <= 32)
     {
+        double fXScale, fYScale;
+        dl_cairo_surface_get_device_scale(m_pRefSurface, &fXScale, &fYScale);
         nNewDX *= fXScale;
         nNewDY *= fYScale;
 
diff --git a/vcl/source/gdi/virdev.cxx b/vcl/source/gdi/virdev.cxx
index 87721c683d77..52052844bae9 100644
--- a/vcl/source/gdi/virdev.cxx
+++ b/vcl/source/gdi/virdev.cxx
@@ -19,6 +19,7 @@
 
 #include <sal/config.h>
 
+#include <comphelper/lok.hxx>
 #include <sal/log.hxx>
 #include <tools/debug.hxx>
 
@@ -406,17 +407,19 @@ bool VirtualDevice::SetOutputSizePixel( const Size& 
rNewSize, bool bErase )
     return ImplSetOutputSizePixel(rNewSize, bErase, nullptr);
 }
 
-bool VirtualDevice::SetOutputSizePixelScaleOffsetAndBuffer(
+bool VirtualDevice::SetOutputSizePixelScaleOffsetAndLOKBuffer(
     const Size& rNewSize, const Fraction& rScale, const Point& rNewOffset,
     sal_uInt8 *const pBuffer)
 {
-    if (pBuffer) {
-        MapMode mm = GetMapMode();
-        mm.SetOrigin( rNewOffset );
-        mm.SetScaleX( rScale );
-        mm.SetScaleY( rScale );
-        SetMapMode( mm );
-    }
+    // If this is ever needed for something else than LOK, changes will
+    // be needed in SvpSalVirtualDevice::CreateSurface() .
+    assert(comphelper::LibreOfficeKit::isActive());
+    assert(pBuffer);
+    MapMode mm = GetMapMode();
+    mm.SetOrigin( rNewOffset );
+    mm.SetScaleX( rScale );
+    mm.SetScaleY( rScale );
+    SetMapMode( mm );
     return ImplSetOutputSizePixel(rNewSize, true, pBuffer);
 }
 

Reply via email to