diff options
author | Luboš Luňák <l.lunak@collabora.com> | 2022-06-10 12:33:53 +0200 |
---|---|---|
committer | Luboš Luňák <l.lunak@collabora.com> | 2022-06-13 10:36:35 +0200 |
commit | 91b98efc2a5cf41d9442f90d7cb37075721519e0 (patch) | |
tree | 581d27a0636057115ab2c15bbeb4f86c83fd4e6e | |
parent | b7b06f28d5728c2c33c073df35ac0c3bcc51e583 (diff) |
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/+/135588
Tested-by: Jenkins
Reviewed-by: Luboš Luňák <l.lunak@collabora.com>
-rw-r--r-- | compilerplugins/clang/constantparam.constructors.results | 2 | ||||
-rw-r--r-- | desktop/source/lib/init.cxx | 6 | ||||
-rw-r--r-- | include/vcl/virdev.hxx | 8 | ||||
-rw-r--r-- | sc/qa/unit/tiledrendering/tiledrendering.cxx | 6 | ||||
-rw-r--r-- | sw/qa/extras/tiledrendering/tiledrendering.cxx | 24 | ||||
-rw-r--r-- | vcl/headless/svpvd.cxx | 24 | ||||
-rw-r--r-- | vcl/source/gdi/virdev.cxx | 19 |
7 files changed, 44 insertions, 45 deletions
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 edc206cb4122..52fd35a23104 100644 --- a/desktop/source/lib/init.cxx +++ b/desktop/source/lib/init.cxx @@ -3481,7 +3481,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); @@ -5726,7 +5726,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); @@ -5826,7 +5826,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 3fa368d423b1..73288fd565bc 100644 --- a/sc/qa/unit/tiledrendering/tiledrendering.cxx +++ b/sc/qa/unit/tiledrendering/tiledrendering.cxx @@ -1464,7 +1464,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(); @@ -1500,7 +1500,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(); @@ -1510,7 +1510,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 7354782563c4..a4a9d7b318b3 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; @@ -2675,7 +2675,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); @@ -2704,7 +2704,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); @@ -2729,7 +2729,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); @@ -2759,7 +2759,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); @@ -2826,7 +2826,7 @@ CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, testTdf43244_SpacesOnMargin) 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); @@ -2869,7 +2869,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); @@ -2998,7 +2998,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); @@ -3071,7 +3071,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); @@ -3128,7 +3128,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); @@ -3214,7 +3214,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); @@ -3251,7 +3251,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 76cb53fc1745..162bd78ec75a 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 1aec06239913..e082e4b21e72 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> @@ -409,17 +410,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); } |