[Libreoffice-commits] core.git: vcl/headless vcl/inc
Caolán McNamara (via logerrit)
logerrit at kemper.freedesktop.org
Thu Oct 3 18:59:49 UTC 2019
vcl/headless/svpvd.cxx | 77 ++++++++++++++++++++++++---------------------
vcl/inc/headless/svpvd.hxx | 2 +
2 files changed, 44 insertions(+), 35 deletions(-)
New commits:
commit 730f50a86d9521c8d3793b40ce14c484d3e3c2f7
Author: Caolán McNamara <caolanm at redhat.com>
AuthorDate: Thu Oct 3 17:04:10 2019 +0100
Commit: Caolán McNamara <caolanm at redhat.com>
CommitDate: Thu Oct 3 20:58:21 2019 +0200
factor out the actual surface creation
Change-Id: I77520b67b988f583dfd277e69d8181b9acdbd904
Reviewed-on: https://gerrit.libreoffice.org/80153
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm at redhat.com>
Tested-by: Caolán McNamara <caolanm at redhat.com>
diff --git a/vcl/headless/svpvd.cxx b/vcl/headless/svpvd.cxx
index a1e415739d6b..686587f9deab 100644
--- a/vcl/headless/svpvd.cxx
+++ b/vcl/headless/svpvd.cxx
@@ -68,6 +68,46 @@ bool SvpSalVirtualDevice::SetSize( long nNewDX, long nNewDY )
return SetSizeUsingBuffer(nNewDX, nNewDY, nullptr);
}
+void SvpSalVirtualDevice::CreateSurface(long nNewDX, long nNewDY, sal_uInt8 *const pBuffer)
+{
+ m_aFrameSize = basegfx::B2IVector(nNewDX, nNewDY);
+
+ if (m_pSurface)
+ {
+ cairo_surface_destroy(m_pSurface);
+ }
+
+ if (m_eFormat == DeviceFormat::BITMASK)
+ {
+ m_pSurface = cairo_surface_create_similar(m_pRefSurface, CAIRO_CONTENT_ALPHA,
+ nNewDX, nNewDY);
+ }
+ else if (pBuffer)
+ {
+ 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);
+ nNewDX *= fXScale;
+ nNewDY *= fYScale;
+ }
+
+ 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);
+ }
+ else
+ {
+ m_pSurface = cairo_surface_create_similar(m_pRefSurface, CAIRO_CONTENT_COLOR_ALPHA, nNewDX, nNewDY);
+ }
+}
+
bool SvpSalVirtualDevice::SetSizeUsingBuffer( long nNewDX, long nNewDY,
sal_uInt8 *const pBuffer)
{
@@ -77,44 +117,11 @@ bool SvpSalVirtualDevice::SetSizeUsingBuffer( long nNewDX, long nNewDY,
nNewDY = 1;
if (!m_pSurface || m_aFrameSize.getX() != nNewDX ||
- m_aFrameSize.getY() != nNewDY )
+ m_aFrameSize.getY() != nNewDY)
{
m_aFrameSize = basegfx::B2IVector(nNewDX, nNewDY);
- if (m_pSurface)
- {
- cairo_surface_destroy(m_pSurface);
- }
-
- if (m_eFormat == DeviceFormat::BITMASK)
- {
- m_pSurface = cairo_surface_create_similar(m_pRefSurface, CAIRO_CONTENT_ALPHA,
- nNewDX, nNewDY);
- }
- else if (pBuffer)
- {
- 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);
- nNewDX *= fXScale;
- nNewDY *= fYScale;
- }
-
- 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);
- }
- else
- {
- m_pSurface = cairo_surface_create_similar(m_pRefSurface, CAIRO_CONTENT_COLOR_ALPHA, nNewDX, nNewDY);
- }
+ CreateSurface(nNewDX, nNewDY, pBuffer);
// update device in existing graphics
for (auto const& graphic : m_aGraphics)
diff --git a/vcl/inc/headless/svpvd.hxx b/vcl/inc/headless/svpvd.hxx
index 3da74b5e1ba8..b069c63286d1 100644
--- a/vcl/inc/headless/svpvd.hxx
+++ b/vcl/inc/headless/svpvd.hxx
@@ -37,6 +37,8 @@ class VCL_DLLPUBLIC SvpSalVirtualDevice : public SalVirtualDevice
basegfx::B2IVector m_aFrameSize;
std::vector< SvpSalGraphics* > m_aGraphics;
+ void CreateSurface(long nNewDX, long nNewDY, sal_uInt8 *const pBuffer);
+
protected:
SvpSalGraphics* AddGraphics(SvpSalGraphics* aGraphics);
More information about the Libreoffice-commits
mailing list