summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorLuboš Luňák <l.lunak@collabora.com>2022-06-10 12:33:53 +0200
committerLuboš Luňák <l.lunak@collabora.com>2022-06-17 14:34:25 +0200
commit7727c61b1c7c52b211c0f9ac0cd59fab680be679 (patch)
tree9357625fb409ed1707c1a51bf071cfa7c607e41e /vcl
parentcdf48e57da6b8a6a5eb4131340fa2c14be135714 (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> (cherry picked from commit 91b98efc2a5cf41d9442f90d7cb37075721519e0) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135710
Diffstat (limited to 'vcl')
-rw-r--r--vcl/headless/svpvd.cxx24
-rw-r--r--vcl/source/gdi/virdev.cxx19
2 files changed, 21 insertions, 22 deletions
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);
}