summaryrefslogtreecommitdiffstats
path: root/vcl/inc/headless
diff options
context:
space:
mode:
Diffstat (limited to 'vcl/inc/headless')
-rw-r--r--vcl/inc/headless/BitmapHelper.hxx81
-rw-r--r--vcl/inc/headless/CairoCommon.hxx230
-rw-r--r--vcl/inc/headless/SvpGraphicsBackend.hxx142
-rw-r--r--vcl/inc/headless/svpbmp.hxx89
-rw-r--r--vcl/inc/headless/svpcairotextrender.hxx32
-rw-r--r--vcl/inc/headless/svpdata.hxx25
-rw-r--r--vcl/inc/headless/svpdummies.hxx64
-rw-r--r--vcl/inc/headless/svpframe.hxx145
-rw-r--r--vcl/inc/headless/svpgdi.hxx130
-rw-r--r--vcl/inc/headless/svpinst.hxx192
-rw-r--r--vcl/inc/headless/svpprn.hxx39
-rw-r--r--vcl/inc/headless/svpvd.hxx67
12 files changed, 1236 insertions, 0 deletions
diff --git a/vcl/inc/headless/BitmapHelper.hxx b/vcl/inc/headless/BitmapHelper.hxx
new file mode 100644
index 000000000..cffa0b21d
--- /dev/null
+++ b/vcl/inc/headless/BitmapHelper.hxx
@@ -0,0 +1,81 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#pragma once
+
+#include <headless/CairoCommon.hxx>
+#include <headless/svpbmp.hxx>
+#include <basegfx/utils/systemdependentdata.hxx>
+
+class BitmapHelper : public SurfaceHelper
+{
+private:
+#ifdef HAVE_CAIRO_FORMAT_RGB24_888
+ const bool m_bForceARGB32;
+#endif
+ SvpSalBitmap aTmpBmp;
+
+public:
+ explicit BitmapHelper(const SalBitmap& rSourceBitmap, const bool bForceARGB32 = false);
+ void mark_dirty();
+ unsigned char* getBits(sal_Int32& rStride);
+};
+
+class MaskHelper : public SurfaceHelper
+{
+private:
+ std::unique_ptr<unsigned char[]> pAlphaBits;
+
+public:
+ explicit MaskHelper(const SalBitmap& rAlphaBitmap);
+};
+
+class SystemDependentData_BitmapHelper : public basegfx::SystemDependentData
+{
+private:
+ std::shared_ptr<BitmapHelper> maBitmapHelper;
+
+public:
+ SystemDependentData_BitmapHelper(
+ basegfx::SystemDependentDataManager& rSystemDependentDataManager,
+ const std::shared_ptr<BitmapHelper>& rBitmapHelper);
+
+ const std::shared_ptr<BitmapHelper>& getBitmapHelper() const { return maBitmapHelper; };
+ virtual sal_Int64 estimateUsageInBytes() const override;
+};
+
+class SystemDependentData_MaskHelper : public basegfx::SystemDependentData
+{
+private:
+ std::shared_ptr<MaskHelper> maMaskHelper;
+
+public:
+ SystemDependentData_MaskHelper(basegfx::SystemDependentDataManager& rSystemDependentDataManager,
+ const std::shared_ptr<MaskHelper>& rMaskHelper);
+
+ const std::shared_ptr<MaskHelper>& getMaskHelper() const { return maMaskHelper; };
+ virtual sal_Int64 estimateUsageInBytes() const override;
+};
+
+VCL_DLLPUBLIC void tryToUseSourceBuffer(const SalBitmap& rSourceBitmap,
+ std::shared_ptr<BitmapHelper>& rSurface);
+VCL_DLLPUBLIC void tryToUseMaskBuffer(const SalBitmap& rMaskBitmap,
+ std::shared_ptr<MaskHelper>& rMask);
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/inc/headless/CairoCommon.hxx b/vcl/inc/headless/CairoCommon.hxx
new file mode 100644
index 000000000..e8b1a4927
--- /dev/null
+++ b/vcl/inc/headless/CairoCommon.hxx
@@ -0,0 +1,230 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#pragma once
+
+#include <sal/config.h>
+#include <config_features.h>
+
+#include <cairo.h>
+
+#include <vcl/dllapi.h>
+#include <vcl/region.hxx>
+#include <vcl/salgtype.hxx>
+#include <vcl/BitmapBuffer.hxx>
+
+#include <com/sun/star/drawing/LineCap.hpp>
+
+#include <basegfx/utils/systemdependentdata.hxx>
+#include <basegfx/range/b2drange.hxx>
+#include <basegfx/range/b2irange.hxx>
+#include <basegfx/matrix/b2dhommatrix.hxx>
+#include <basegfx/polygon/b2dpolypolygon.hxx>
+#include <basegfx/polygon/b2dpolygon.hxx>
+
+#include <unordered_map>
+
+//Using formats that match cairo's formats. For android we patch cairo,
+//which is internal in that case, to swap the rgb components so that
+//cairo then matches the OpenGL GL_RGBA format so we can use it there
+//where we don't have GL_BGRA support.
+// SVP_24BIT_FORMAT is used to store 24-bit images in 3-byte pixels to conserve memory.
+#if defined(ANDROID) && !HAVE_FEATURE_ANDROID_LOK
+#define SVP_24BIT_FORMAT (ScanlineFormat::N24BitTcRgb | ScanlineFormat::TopDown)
+#define SVP_CAIRO_FORMAT (ScanlineFormat::N32BitTcRgba | ScanlineFormat::TopDown)
+#define SVP_CAIRO_BLUE 1
+#define SVP_CAIRO_GREEN 2
+#define SVP_CAIRO_RED 0
+#define SVP_CAIRO_ALPHA 3
+#elif defined OSL_BIGENDIAN
+#define SVP_24BIT_FORMAT (ScanlineFormat::N24BitTcRgb | ScanlineFormat::TopDown)
+#define SVP_CAIRO_FORMAT (ScanlineFormat::N32BitTcArgb | ScanlineFormat::TopDown)
+#define SVP_CAIRO_BLUE 3
+#define SVP_CAIRO_GREEN 2
+#define SVP_CAIRO_RED 1
+#define SVP_CAIRO_ALPHA 0
+#else
+#define SVP_24BIT_FORMAT (ScanlineFormat::N24BitTcBgr | ScanlineFormat::TopDown)
+#define SVP_CAIRO_FORMAT (ScanlineFormat::N32BitTcBgra | ScanlineFormat::TopDown)
+#define SVP_CAIRO_BLUE 0
+#define SVP_CAIRO_GREEN 1
+#define SVP_CAIRO_RED 2
+#define SVP_CAIRO_ALPHA 3
+#endif
+
+typedef struct _cairo cairo_t;
+typedef struct _cairo_surface cairo_surface_t;
+typedef struct _cairo_user_data_key cairo_user_data_key_t;
+
+VCL_DLLPUBLIC void dl_cairo_surface_set_device_scale(cairo_surface_t* surface, double x_scale,
+ double y_scale);
+VCL_DLLPUBLIC void dl_cairo_surface_get_device_scale(cairo_surface_t* surface, double* x_scale,
+ double* y_scale);
+
+VCL_DLLPUBLIC basegfx::B2DRange getFillDamage(cairo_t* cr);
+VCL_DLLPUBLIC basegfx::B2DRange getClipBox(cairo_t* cr);
+VCL_DLLPUBLIC basegfx::B2DRange getClippedFillDamage(cairo_t* cr);
+VCL_DLLPUBLIC basegfx::B2DRange getClippedStrokeDamage(cairo_t* cr);
+VCL_DLLPUBLIC basegfx::B2DRange getStrokeDamage(cairo_t* cr);
+
+class SystemDependentData_CairoPath : public basegfx::SystemDependentData
+{
+private:
+ // the path data itself
+ cairo_path_t* mpCairoPath;
+
+ // all other values the path data is based on and
+ // need to be compared with to check for data validity
+ bool mbNoJoin;
+ bool mbAntiAlias;
+ std::vector<double> maStroke;
+
+public:
+ SystemDependentData_CairoPath(basegfx::SystemDependentDataManager& rSystemDependentDataManager,
+ size_t nSizeMeasure, cairo_t* cr, bool bNoJoin, bool bAntiAlias,
+ const std::vector<double>* pStroke); // MM01
+ virtual ~SystemDependentData_CairoPath() override;
+
+ // read access
+ cairo_path_t* getCairoPath() { return mpCairoPath; }
+ bool getNoJoin() const { return mbNoJoin; }
+ bool getAntiAlias() const { return mbAntiAlias; }
+ const std::vector<double>& getStroke() const { return maStroke; }
+
+ virtual sal_Int64 estimateUsageInBytes() const override;
+};
+
+VCL_DLLPUBLIC size_t AddPolygonToPath(cairo_t* cr, const basegfx::B2DPolygon& rPolygon,
+ const basegfx::B2DHomMatrix& rObjectToDevice, bool bPixelSnap,
+ bool bPixelSnapHairline);
+
+VCL_DLLPUBLIC basegfx::B2DPoint impPixelSnap(const basegfx::B2DPolygon& rPolygon,
+ const basegfx::B2DHomMatrix& rObjectToDevice,
+ basegfx::B2DHomMatrix& rObjectToDeviceInv,
+ sal_uInt32 nIndex);
+
+VCL_DLLPUBLIC void add_polygon_path(cairo_t* cr, const basegfx::B2DPolyPolygon& rPolyPolygon,
+ const basegfx::B2DHomMatrix& rObjectToDevice, bool bPixelSnap);
+
+VCL_DLLPUBLIC cairo_format_t getCairoFormat(const BitmapBuffer& rBuffer);
+
+VCL_DLLPUBLIC std::unique_ptr<BitmapBuffer>
+FastConvert24BitRgbTo32BitCairo(const BitmapBuffer* pSrc);
+
+VCL_DLLPUBLIC void Toggle1BitTransparency(const BitmapBuffer& rBuf);
+
+enum class PaintMode
+{
+ Over,
+ Xor
+};
+
+typedef void (*damageHandler)(void* handle, sal_Int32 nExtentsX, sal_Int32 nExtentsY,
+ sal_Int32 nExtentsWidth, sal_Int32 nExtentsHeight);
+
+struct VCL_DLLPUBLIC DamageHandler
+{
+ void* handle;
+ damageHandler damaged;
+};
+
+struct VCL_DLLPUBLIC CairoCommon
+{
+ cairo_surface_t* m_pSurface;
+ basegfx::B2IVector m_aFrameSize;
+ vcl::Region m_aClipRegion;
+ Color m_aLineColor;
+ Color m_aFillColor;
+ PaintMode m_ePaintMode;
+ double m_fScale;
+
+ CairoCommon()
+ : m_pSurface(nullptr)
+ , m_aLineColor(Color(0x00, 0x00, 0x00))
+ , m_aFillColor(Color(0xFF, 0xFF, 0XFF))
+ , m_ePaintMode(PaintMode::Over)
+ , m_fScale(1.0)
+ {
+ }
+
+ static cairo_user_data_key_t* getDamageKey();
+
+ cairo_surface_t* getSurface() const { return m_pSurface; }
+
+ cairo_t* getCairoContext(bool bXorModeAllowed, bool bAntiAlias) const;
+ void releaseCairoContext(cairo_t* cr, bool bXorModeAllowed,
+ const basegfx::B2DRange& rExtents) const;
+ cairo_t* createTmpCompatibleCairoContext() const;
+
+ void applyColor(cairo_t* cr, Color rColor, double fTransparency = 0.0);
+ void clipRegion(cairo_t* cr);
+ static void clipRegion(cairo_t* cr, const vcl::Region& rClipRegion);
+
+ // need this static version of ::drawPolyLine for usage from
+ // vcl/unx/generic/gdi/salgdi.cxx. It gets wrapped by
+ // ::drawPolyLine with some added parameters (see there)
+ static bool drawPolyLine(cairo_t* cr, basegfx::B2DRange* pExtents, const Color& rLineColor,
+ bool bAntiAlias, const basegfx::B2DHomMatrix& rObjectToDevice,
+ const basegfx::B2DPolygon& rPolyLine, double fTransparency,
+ double fLineWidth, const std::vector<double>* pStroke,
+ basegfx::B2DLineJoin eLineJoin, css::drawing::LineCap eLineCap,
+ double fMiterMinimumAngle, bool bPixelSnapHairline);
+
+ void copyWithOperator(const SalTwoRect& rTR, cairo_surface_t* source, cairo_operator_t eOp,
+ bool bAntiAlias);
+
+ void copySource(const SalTwoRect& rTR, cairo_surface_t* source, bool bAntiAlias);
+
+ static basegfx::B2DRange renderSource(cairo_t* cr, const SalTwoRect& rTR,
+ cairo_surface_t* source);
+
+ void copyBitsCairo(const SalTwoRect& rTR, cairo_surface_t* pSourceSurface, bool bAntiAlias);
+
+ void invert(const basegfx::B2DPolygon& rPoly, SalInvert nFlags, bool bAntiAlias);
+
+ static cairo_surface_t* createCairoSurface(const BitmapBuffer* pBuffer);
+};
+
+class SurfaceHelper
+{
+private:
+ cairo_surface_t* pSurface;
+ std::unordered_map<sal_uInt64, cairo_surface_t*> maDownscaled;
+
+ SurfaceHelper(const SurfaceHelper&) = delete;
+ SurfaceHelper& operator=(const SurfaceHelper&) = delete;
+
+ cairo_surface_t* implCreateOrReuseDownscale(unsigned long nTargetWidth,
+ unsigned long nTargetHeight);
+
+protected:
+ cairo_surface_t* implGetSurface() const { return pSurface; }
+ void implSetSurface(cairo_surface_t* pNew) { pSurface = pNew; }
+
+ bool isTrivial() const;
+
+public:
+ explicit SurfaceHelper();
+ ~SurfaceHelper();
+
+ cairo_surface_t* getSurface(unsigned long nTargetWidth = 0,
+ unsigned long nTargetHeight = 0) const;
+};
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/inc/headless/SvpGraphicsBackend.hxx b/vcl/inc/headless/SvpGraphicsBackend.hxx
new file mode 100644
index 000000000..997f1bc84
--- /dev/null
+++ b/vcl/inc/headless/SvpGraphicsBackend.hxx
@@ -0,0 +1,142 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#pragma once
+
+#include <vcl/dllapi.h>
+#include <tools/long.hxx>
+#include <tools/color.hxx>
+#include <salgdiimpl.hxx>
+#include <salgdi.hxx>
+
+#include <headless/CairoCommon.hxx>
+
+class VCL_DLLPUBLIC SvpGraphicsBackend : public SalGraphicsImpl
+{
+ CairoCommon& m_rCairoCommon;
+
+public:
+ SvpGraphicsBackend(CairoCommon& rCairoCommon);
+
+ void Init() override;
+
+ void freeResources() override;
+
+ OUString getRenderBackendName() const override { return "svp"; }
+
+ bool setClipRegion(vcl::Region const& rRegion) override;
+ void ResetClipRegion() override;
+
+ sal_uInt16 GetBitCount() const override;
+
+ tools::Long GetGraphicsWidth() const override;
+
+ void SetLineColor() override;
+ void SetLineColor(Color nColor) override;
+ void SetFillColor() override;
+ void SetFillColor(Color nColor) override;
+ void SetXORMode(bool bSet, bool bInvertOnly) override;
+ void SetROPLineColor(SalROPColor nROPColor) override;
+ void SetROPFillColor(SalROPColor nROPColor) override;
+
+ void drawPixel(tools::Long nX, tools::Long nY) override;
+ void drawPixel(tools::Long nX, tools::Long nY, Color nColor) override;
+
+ void drawLine(tools::Long nX1, tools::Long nY1, tools::Long nX2, tools::Long nY2) override;
+ void drawRect(tools::Long nX, tools::Long nY, tools::Long nWidth, tools::Long nHeight) override;
+ void drawPolyLine(sal_uInt32 nPoints, const Point* pPointArray) override;
+ void drawPolygon(sal_uInt32 nPoints, const Point* pPointArray) override;
+ void drawPolyPolygon(sal_uInt32 nPoly, const sal_uInt32* pPoints,
+ const Point** pPointArray) override;
+
+ bool drawPolyPolygon(const basegfx::B2DHomMatrix& rObjectToDevice,
+ const basegfx::B2DPolyPolygon&, double fTransparency) override;
+
+ bool drawPolyLine(const basegfx::B2DHomMatrix& rObjectToDevice, const basegfx::B2DPolygon&,
+ double fTransparency, double fLineWidth, const std::vector<double>* pStroke,
+ basegfx::B2DLineJoin, css::drawing::LineCap, double fMiterMinimumAngle,
+ bool bPixelSnapHairline) override;
+
+ bool drawPolyLineBezier(sal_uInt32 nPoints, const Point* pPointArray,
+ const PolyFlags* pFlagArray) override;
+
+ bool drawPolygonBezier(sal_uInt32 nPoints, const Point* pPointArray,
+ const PolyFlags* pFlagArray) override;
+
+ bool drawPolyPolygonBezier(sal_uInt32 nPoly, const sal_uInt32* pPoints,
+ const Point* const* pPointArray,
+ const PolyFlags* const* pFlagArray) override;
+
+ void copyArea(tools::Long nDestX, tools::Long nDestY, tools::Long nSrcX, tools::Long nSrcY,
+ tools::Long nSrcWidth, tools::Long nSrcHeight, bool bWindowInvalidate) override;
+
+ void copyBits(const SalTwoRect& rPosAry, SalGraphics* pSrcGraphics) override;
+
+ void drawBitmap(const SalTwoRect& rPosAry, const SalBitmap& rSalBitmap) override;
+
+ void drawBitmap(const SalTwoRect& rPosAry, const SalBitmap& rSalBitmap,
+ const SalBitmap& rMaskBitmap) override;
+
+ void drawMask(const SalTwoRect& rPosAry, const SalBitmap& rSalBitmap,
+ Color nMaskColor) override;
+
+ std::shared_ptr<SalBitmap> getBitmap(tools::Long nX, tools::Long nY, tools::Long nWidth,
+ tools::Long nHeight) override;
+
+ Color getPixel(tools::Long nX, tools::Long nY) override;
+
+ void invert(tools::Long nX, tools::Long nY, tools::Long nWidth, tools::Long nHeight,
+ SalInvert nFlags) override;
+
+ void invert(sal_uInt32 nPoints, const Point* pPtAry, SalInvert nFlags) override;
+
+ bool drawEPS(tools::Long nX, tools::Long nY, tools::Long nWidth, tools::Long nHeight,
+ void* pPtr, sal_uInt32 nSize) override;
+
+ bool blendBitmap(const SalTwoRect&, const SalBitmap& rBitmap) override;
+
+ bool blendAlphaBitmap(const SalTwoRect&, const SalBitmap& rSrcBitmap,
+ const SalBitmap& rMaskBitmap, const SalBitmap& rAlphaBitmap) override;
+
+ bool drawAlphaBitmap(const SalTwoRect&, const SalBitmap& rSourceBitmap,
+ const SalBitmap& rAlphaBitmap) override;
+
+ bool drawTransformedBitmap(const basegfx::B2DPoint& rNull, const basegfx::B2DPoint& rX,
+ const basegfx::B2DPoint& rY, const SalBitmap& rSourceBitmap,
+ const SalBitmap* pAlphaBitmap, double fAlpha) override;
+
+ bool hasFastDrawTransformedBitmap() const override;
+
+ bool drawAlphaRect(tools::Long nX, tools::Long nY, tools::Long nWidth, tools::Long nHeight,
+ sal_uInt8 nTransparency) override;
+
+ bool drawGradient(const tools::PolyPolygon& rPolygon, const Gradient& rGradient) override;
+ bool implDrawGradient(basegfx::B2DPolyPolygon const& rPolyPolygon,
+ SalGradient const& rGradient) override;
+
+ bool supportsOperation(OutDevSupportType eType) const override;
+
+ void drawBitmapBuffer(const SalTwoRect& rPosAry, const BitmapBuffer* pBuffer,
+ cairo_operator_t eOp);
+
+private:
+ void implDrawRect(double nX, double nY, double nWidth, double nHeight);
+};
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/inc/headless/svpbmp.hxx b/vcl/inc/headless/svpbmp.hxx
new file mode 100644
index 000000000..2c347372a
--- /dev/null
+++ b/vcl/inc/headless/svpbmp.hxx
@@ -0,0 +1,89 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef INCLUDED_VCL_INC_HEADLESS_SVPBMP_HXX
+#define INCLUDED_VCL_INC_HEADLESS_SVPBMP_HXX
+
+#include <sal/config.h>
+
+#include <salbmp.hxx>
+#include <basegfx/utils/systemdependentdata.hxx>
+
+class VCL_DLLPUBLIC SvpSalBitmap final : public SalBitmap, public basegfx::SystemDependentDataHolder // MM02
+{
+ std::unique_ptr<BitmapBuffer> mpDIB;
+public:
+ SvpSalBitmap();
+ virtual ~SvpSalBitmap() override;
+
+ // SalBitmap
+ virtual bool Create(const Size& rSize,
+ vcl::PixelFormat ePixelFormat,
+ const BitmapPalette& rPalette) override;
+ virtual bool Create( const SalBitmap& rSalBmp ) override;
+ virtual bool Create( const SalBitmap& rSalBmp,
+ SalGraphics* pGraphics ) override;
+ virtual bool Create(const SalBitmap& rSalBmp,
+ vcl::PixelFormat eNewPixelFormat) override;
+ virtual bool Create( const css::uno::Reference< css::rendering::XBitmapCanvas >& rBitmapCanvas,
+ Size& rSize,
+ bool bMask = false ) override;
+ void Create(std::unique_ptr<BitmapBuffer> pBuf);
+ const BitmapBuffer* GetBuffer() const
+ {
+ return mpDIB.get();
+ }
+ virtual void Destroy() final override;
+ virtual Size GetSize() const override;
+ virtual sal_uInt16 GetBitCount() const override;
+
+ virtual BitmapBuffer* AcquireBuffer( BitmapAccessMode nMode ) override;
+ virtual void ReleaseBuffer( BitmapBuffer* pBuffer, BitmapAccessMode nMode ) override;
+ virtual bool GetSystemData( BitmapSystemData& rData ) override;
+
+ virtual bool ScalingSupported() const override;
+ virtual bool Scale( const double& rScaleX, const double& rScaleY, BmpScaleFlag nScaleFlag ) override;
+ virtual bool Replace( const Color& rSearchColor, const Color& rReplaceColor, sal_uInt8 nTol ) override;
+
+ // MM02 exclusive management op's for SystemDependentData at WinSalBitmap
+ template<class T>
+ std::shared_ptr<T> getSystemDependentData() const
+ {
+ return std::static_pointer_cast<T>(basegfx::SystemDependentDataHolder::getSystemDependentData(typeid(T).hash_code()));
+ }
+
+ template<class T, class... Args>
+ std::shared_ptr<T> addOrReplaceSystemDependentData(basegfx::SystemDependentDataManager& manager, Args&&... args) const
+ {
+ std::shared_ptr<T> r = std::make_shared<T>(manager, std::forward<Args>(args)...);
+
+ // tdf#129845 only add to buffer if a relevant buffer time is estimated
+ if(r->calculateCombinedHoldCyclesInSeconds() > 0)
+ {
+ basegfx::SystemDependentData_SharedPtr r2(r);
+ const_cast< SvpSalBitmap* >(this)->basegfx::SystemDependentDataHolder::addOrReplaceSystemDependentData(r2);
+ }
+
+ return r;
+ }
+};
+
+#endif // INCLUDED_VCL_INC_HEADLESS_SVPBMP_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/inc/headless/svpcairotextrender.hxx b/vcl/inc/headless/svpcairotextrender.hxx
new file mode 100644
index 000000000..35744d5a2
--- /dev/null
+++ b/vcl/inc/headless/svpcairotextrender.hxx
@@ -0,0 +1,32 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#ifndef INCLUDED_VCL_UNX_GTK3_GDI_GTK3CAIROTEXTRENDER_HXX
+#define INCLUDED_VCL_UNX_GTK3_GDI_GTK3CAIROTEXTRENDER_HXX
+
+#include <unx/cairotextrender.hxx>
+
+class SvpSalGraphics;
+
+class SvpCairoTextRender final : public CairoTextRender
+{
+ SvpSalGraphics& mrParent;
+
+public:
+ explicit SvpCairoTextRender(SvpSalGraphics& rParent);
+
+ virtual cairo_t* getCairoContext() override;
+ virtual void getSurfaceOffset(double& nDX, double& nDY) override;
+ virtual void clipRegion(cairo_t* cr) override;
+ virtual void releaseCairoContext(cairo_t* cr) override;
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/inc/headless/svpdata.hxx b/vcl/inc/headless/svpdata.hxx
new file mode 100644
index 000000000..f995d7ef3
--- /dev/null
+++ b/vcl/inc/headless/svpdata.hxx
@@ -0,0 +1,25 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#pragma once
+
+#include <unx/gendata.hxx>
+
+class SvpSalData : public GenericUnixSalData
+{
+public:
+ explicit SvpSalData()
+ : GenericUnixSalData()
+ {
+ }
+ virtual void ErrorTrapPush() override {}
+ virtual bool ErrorTrapPop(bool /*bIgnoreError*/ = true) override { return false; }
+};
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/inc/headless/svpdummies.hxx b/vcl/inc/headless/svpdummies.hxx
new file mode 100644
index 000000000..cdcdcc0b1
--- /dev/null
+++ b/vcl/inc/headless/svpdummies.hxx
@@ -0,0 +1,64 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef INCLUDED_VCL_INC_HEADLESS_SVPDUMMIES_HXX
+#define INCLUDED_VCL_INC_HEADLESS_SVPDUMMIES_HXX
+
+#include <vcl/sysdata.hxx>
+#include <unx/gensys.h>
+#include <salobj.hxx>
+
+class SalGraphics;
+
+class SvpSalObject final : public SalObject
+{
+public:
+ SystemEnvData m_aSystemChildData;
+
+ virtual ~SvpSalObject() override;
+
+ // override all pure virtual methods
+ virtual void ResetClipRegion() override;
+ virtual void BeginSetClipRegion( sal_uInt32 nRects ) override;
+ virtual void UnionClipRegion( tools::Long nX, tools::Long nY, tools::Long nWidth, tools::Long nHeight ) override;
+ virtual void EndSetClipRegion() override;
+
+ virtual void SetPosSize( tools::Long nX, tools::Long nY, tools::Long nWidth, tools::Long nHeight ) override;
+ virtual void Show( bool bVisible ) override;
+
+ virtual const SystemEnvData* GetSystemData() const override;
+};
+
+class SvpSalSystem : public SalGenericSystem
+{
+public:
+ SvpSalSystem() {}
+ virtual ~SvpSalSystem() override;
+ // get info about the display
+ virtual unsigned int GetDisplayScreenCount() override;
+ virtual tools::Rectangle GetDisplayScreenPosSizePixel( unsigned int nScreen ) override;
+
+ virtual int ShowNativeDialog( const OUString& rTitle,
+ const OUString& rMessage,
+ const std::vector< OUString >& rButtons ) override;
+};
+
+#endif // INCLUDED_VCL_INC_HEADLESS_SVPDUMMIES_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/inc/headless/svpframe.hxx b/vcl/inc/headless/svpframe.hxx
new file mode 100644
index 000000000..84dca0c84
--- /dev/null
+++ b/vcl/inc/headless/svpframe.hxx
@@ -0,0 +1,145 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef INCLUDED_VCL_INC_HEADLESS_SVPFRAME_HXX
+#define INCLUDED_VCL_INC_HEADLESS_SVPFRAME_HXX
+
+#include <vcl/sysdata.hxx>
+
+#include <salframe.hxx>
+
+#include <vector>
+
+#ifdef IOS
+#define SvpSalInstance AquaSalInstance
+#define SvpSalGraphics AquaSalGraphics
+#endif
+
+class SvpSalInstance;
+class SvpSalGraphics;
+
+class SvpSalFrame : public SalFrame
+{
+ SvpSalInstance* m_pInstance;
+ SvpSalFrame* m_pParent; // pointer to parent frame
+ std::vector< SvpSalFrame* > m_aChildren; // Vector of child frames
+ SalFrameStyleFlags m_nStyle;
+ bool m_bVisible;
+#ifndef IOS
+ cairo_surface_t* m_pSurface;
+#endif
+ tools::Long m_nMinWidth;
+ tools::Long m_nMinHeight;
+ tools::Long m_nMaxWidth;
+ tools::Long m_nMaxHeight;
+
+ SystemEnvData m_aSystemChildData;
+
+ std::vector< SvpSalGraphics* > m_aGraphics;
+
+ static SvpSalFrame* s_pFocusFrame;
+ OUString m_sTitle;
+
+public:
+ SvpSalFrame( SvpSalInstance* pInstance,
+ SalFrame* pParent,
+ SalFrameStyleFlags nSalFrameStyle );
+ virtual ~SvpSalFrame() override;
+
+ void GetFocus();
+ void LoseFocus();
+ void PostPaint() const;
+
+ const OUString& title() const { return m_sTitle; }
+ SalFrameStyleFlags style() const { return m_nStyle; }
+ bool isVisible() const { return m_bVisible; }
+ bool hasFocus() const { return s_pFocusFrame == this; }
+
+ // SalFrame
+ virtual SalGraphics* AcquireGraphics() override;
+ virtual void ReleaseGraphics( SalGraphics* pGraphics ) override;
+
+ virtual bool PostEvent(std::unique_ptr<ImplSVEvent> pData) override;
+
+ virtual void SetTitle( const OUString& rTitle ) override;
+ virtual void SetIcon( sal_uInt16 nIcon ) override;
+ virtual void SetMenu( SalMenu* pMenu ) override;
+ virtual void DrawMenuBar() override;
+
+ virtual void SetExtendedFrameStyle( SalExtStyle nExtStyle ) override;
+ virtual void Show( bool bVisible, bool bNoActivate = false ) override;
+ virtual void SetMinClientSize( tools::Long nWidth, tools::Long nHeight ) override;
+ virtual void SetMaxClientSize( tools::Long nWidth, tools::Long nHeight ) override;
+ virtual void SetPosSize( tools::Long nX, tools::Long nY, tools::Long nWidth, tools::Long nHeight, sal_uInt16 nFlags ) override;
+ virtual void GetClientSize( tools::Long& rWidth, tools::Long& rHeight ) override;
+ virtual void GetWorkArea( tools::Rectangle& rRect ) override;
+ virtual SalFrame* GetParent() const override;
+ virtual void SetWindowState( const SalFrameState* pState ) override;
+ virtual bool GetWindowState( SalFrameState* pState ) override;
+ virtual void ShowFullScreen( bool bFullScreen, sal_Int32 nDisplay ) override;
+ virtual void StartPresentation( bool bStart ) override;
+ virtual void SetAlwaysOnTop( bool bOnTop ) override;
+ virtual void ToTop( SalFrameToTop nFlags ) override;
+ virtual void SetPointer( PointerStyle ePointerStyle ) override;
+ virtual void CaptureMouse( bool bMouse ) override;
+ virtual void SetPointerPos( tools::Long nX, tools::Long nY ) override;
+ using SalFrame::Flush;
+ virtual void Flush() override;
+ virtual void SetInputContext( SalInputContext* pContext ) override;
+ virtual void EndExtTextInput( EndExtTextInputFlags nFlags ) override;
+ virtual OUString GetKeyName( sal_uInt16 nKeyCode ) override;
+ virtual bool MapUnicodeToKeyCode( sal_Unicode aUnicode, LanguageType aLangType, vcl::KeyCode& rKeyCode ) override;
+ virtual LanguageType GetInputLanguage() override;
+ virtual void UpdateSettings( AllSettings& rSettings ) override;
+ virtual void Beep() override;
+ virtual const SystemEnvData* GetSystemData() const override;
+ virtual SalPointerState GetPointerState() override;
+ virtual KeyIndicatorState GetIndicatorState() override;
+ virtual void SimulateKeyPress( sal_uInt16 nKeyCode ) override;
+ virtual void SetParent( SalFrame* pNewParent ) override;
+ virtual void SetPluginParent( SystemParentData* pNewParent ) override;
+ virtual void ResetClipRegion() override;
+ virtual void BeginSetClipRegion( sal_uInt32 nRects ) override;
+ virtual void UnionClipRegion( tools::Long nX, tools::Long nY, tools::Long nWidth, tools::Long nHeight ) override;
+ virtual void EndSetClipRegion() override;
+
+ /*TODO: functional implementation */
+ virtual void SetScreenNumber( unsigned int ) override {}
+ virtual void SetApplicationID(const OUString &) override {}
+
+private:
+ basegfx::B2IVector GetSurfaceFrameSize() const;
+};
+
+template <typename charT, typename traits>
+inline std::basic_ostream<charT, traits>& operator<<(std::basic_ostream<charT, traits>& stream,
+ const SvpSalFrame& frame)
+{
+ stream << &frame << " (vis " << frame.isVisible() << " focus " << frame.hasFocus();
+ stream << " style " << std::hex << std::setfill('0') << std::setw(8) << static_cast<sal_uInt32>(frame.style());
+ OUString sTitle = frame.title();
+ if (!sTitle.isEmpty())
+ stream << " '" << sTitle << "'";
+ stream << ")";
+ return stream;
+}
+
+#endif // INCLUDED_VCL_INC_HEADLESS_SVPFRAME_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/inc/headless/svpgdi.hxx b/vcl/inc/headless/svpgdi.hxx
new file mode 100644
index 000000000..1abc2b05f
--- /dev/null
+++ b/vcl/inc/headless/svpgdi.hxx
@@ -0,0 +1,130 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#pragma once
+
+#ifdef IOS
+#error This file is not for iOS
+#endif
+
+#include <sal/config.h>
+#include <config_features.h>
+
+#include <osl/endian.h>
+#include <vcl/sysdata.hxx>
+#include <config_cairo_canvas.h>
+
+#include <font/PhysicalFontFace.hxx>
+#include <salgdi.hxx>
+#include <sallayout.hxx>
+#include "svpcairotextrender.hxx"
+#include <impfontmetricdata.hxx>
+
+#include <headless/SvpGraphicsBackend.hxx>
+#include <headless/CairoCommon.hxx>
+
+struct BitmapBuffer;
+class FreetypeFont;
+
+class VCL_DLLPUBLIC SvpSalGraphics : public SalGraphicsAutoDelegateToImpl
+{
+ CairoCommon m_aCairoCommon;
+
+public:
+ void setSurface(cairo_surface_t* pSurface, const basegfx::B2IVector& rSize);
+ cairo_surface_t* getSurface() const { return m_aCairoCommon.m_pSurface; }
+ static cairo_user_data_key_t* getDamageKey()
+ {
+ return CairoCommon::getDamageKey();
+ }
+
+protected:
+ SvpCairoTextRender m_aTextRenderImpl;
+ std::unique_ptr<SvpGraphicsBackend> m_pBackend;
+
+ cairo_t* createTmpCompatibleCairoContext() const;
+
+public:
+ SvpSalGraphics();
+ virtual ~SvpSalGraphics() override;
+
+ virtual SalGraphicsImpl* GetImpl() const override { return m_pBackend.get(); }
+ std::unique_ptr<SvpGraphicsBackend> const& getSvpBackend() { return m_pBackend; }
+
+ virtual void GetResolution( sal_Int32& rDPIX, sal_Int32& rDPIY ) override;
+
+ virtual void SetTextColor( Color nColor ) override;
+ virtual void SetFont(LogicalFontInstance*, int nFallbackLevel) override;
+ virtual void GetFontMetric( ImplFontMetricDataRef&, int nFallbackLevel ) override;
+ virtual FontCharMapRef GetFontCharMap() const override;
+ virtual bool GetFontCapabilities(vcl::FontCapabilities &rFontCapabilities) const override;
+ virtual void GetDevFontList( vcl::font::PhysicalFontCollection* ) override;
+ virtual void ClearDevFontCache() override;
+ virtual bool AddTempDevFont( vcl::font::PhysicalFontCollection*, const OUString& rFileURL, const OUString& rFontName ) override;
+ virtual bool CreateFontSubset( const OUString& rToFile,
+ const vcl::font::PhysicalFontFace*,
+ const sal_GlyphId* pGlyphIds,
+ const sal_uInt8* pEncoding,
+ sal_Int32* pWidths,
+ int nGlyphs,
+ FontSubsetInfo& rInfo
+ ) override;
+ virtual const void* GetEmbedFontData(const vcl::font::PhysicalFontFace*, tools::Long* pDataLen) override;
+ virtual void FreeEmbedFontData( const void* pData, tools::Long nDataLen ) override;
+ virtual void GetGlyphWidths( const vcl::font::PhysicalFontFace*,
+ bool bVertical,
+ std::vector< sal_Int32 >& rWidths,
+ Ucs2UIntMap& rUnicodeEnc ) override;
+ virtual std::unique_ptr<GenericSalLayout>
+ GetTextLayout(int nFallbackLevel) override;
+ virtual void DrawTextLayout( const GenericSalLayout& ) override;
+
+ virtual bool ShouldDownscaleIconsAtSurface(double* pScaleOut) const override;
+
+ virtual SystemGraphicsData GetGraphicsData() const override;
+
+#if ENABLE_CAIRO_CANVAS
+ virtual bool SupportsCairo() const override;
+ virtual cairo::SurfaceSharedPtr CreateSurface(const cairo::CairoSurfaceSharedPtr& rSurface) const override;
+ virtual cairo::SurfaceSharedPtr CreateSurface(const OutputDevice& rRefDevice, int x, int y, int width, int height) const override;
+ virtual cairo::SurfaceSharedPtr CreateBitmapSurface(const OutputDevice& rRefDevice, const BitmapSystemData& rData, const Size& rSize) const override;
+ virtual css::uno::Any GetNativeSurfaceHandle(cairo::SurfaceSharedPtr& rSurface, const basegfx::B2ISize& rSize) const override;
+#endif // ENABLE_CAIRO_CANVAS
+
+ cairo_t* getCairoContext() const
+ {
+ return m_aCairoCommon.getCairoContext(/*bXorModeAllowed*/false, getAntiAlias());
+ }
+
+ void releaseCairoContext(cairo_t* cr, const basegfx::B2DRange& rExtents) const
+ {
+ return m_aCairoCommon.releaseCairoContext(cr, /*bXorModeAllowed*/false, rExtents);
+ }
+
+ void clipRegion(cairo_t* cr)
+ {
+ m_aCairoCommon.clipRegion(cr);
+ }
+ void copySource(const SalTwoRect& rTR, cairo_surface_t* source)
+ {
+ m_aCairoCommon.copySource(rTR, source, getAntiAlias());
+ }
+};
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/inc/headless/svpinst.hxx b/vcl/inc/headless/svpinst.hxx
new file mode 100644
index 000000000..874ce672d
--- /dev/null
+++ b/vcl/inc/headless/svpinst.hxx
@@ -0,0 +1,192 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef INCLUDED_VCL_INC_HEADLESS_SVPINST_HXX
+#define INCLUDED_VCL_INC_HEADLESS_SVPINST_HXX
+
+#include <osl/thread.hxx>
+#include <osl/conditn.hxx>
+#include <salinst.hxx>
+#include <saltimer.hxx>
+#include <salusereventlist.hxx>
+#include <unx/geninst.h>
+#include <unx/genprn.h>
+
+#include <condition_variable>
+
+#include <sys/time.h>
+
+#define VIRTUAL_DESKTOP_WIDTH 1024
+#define VIRTUAL_DESKTOP_HEIGHT 768
+
+#ifdef IOS
+#define SvpSalInstance AquaSalInstance
+#endif
+
+class SvpSalInstance;
+class SvpSalTimer final : public SalTimer
+{
+ SvpSalInstance* m_pInstance;
+public:
+ SvpSalTimer( SvpSalInstance* pInstance ) : m_pInstance( pInstance ) {}
+ virtual ~SvpSalTimer() override;
+
+ // override all pure virtual methods
+ virtual void Start( sal_uInt64 nMS ) override;
+ virtual void Stop() override;
+};
+
+class SvpSalFrame;
+class GenPspGraphics;
+
+enum class SvpRequest
+{
+ NONE,
+ MainThreadDispatchOneEvent,
+ MainThreadDispatchAllEvents,
+};
+
+class SvpSalYieldMutex final : public SalYieldMutex
+{
+private:
+ // note: these members might as well live in SvpSalInstance, but there is
+ // at least one subclass of SvpSalInstance (GTK3) that doesn't use them.
+ friend class SvpSalInstance;
+ // members for communication from main thread to non-main thread
+ int m_FeedbackFDs[2];
+ osl::Condition m_NonMainWaitingYieldCond;
+ // members for communication from non-main thread to main thread
+ bool m_bNoYieldLock = false; // accessed only on main thread
+ std::mutex m_WakeUpMainMutex; // guard m_wakeUpMain & m_Request
+ std::condition_variable m_WakeUpMainCond;
+ bool m_wakeUpMain = false;
+ SvpRequest m_Request = SvpRequest::NONE;
+
+ virtual void doAcquire( sal_uInt32 nLockCount ) override;
+ virtual sal_uInt32 doRelease( bool bUnlockAll ) override;
+
+public:
+ SvpSalYieldMutex();
+ virtual ~SvpSalYieldMutex() override;
+
+ virtual bool IsCurrentThread() const override;
+};
+
+// NOTE: the functions IsMainThread, DoYield and Wakeup *require* the use of
+// SvpSalYieldMutex; if a subclass uses something else it must override these
+// (Wakeup is only called by SvpSalTimer and SvpSalFrame)
+class VCL_DLLPUBLIC SvpSalInstance : public SalGenericInstance, public SalUserEventList
+{
+ timeval m_aTimeout;
+ sal_uLong m_nTimeoutMS;
+ oslThreadIdentifier m_MainThread;
+
+ virtual void TriggerUserEventProcessing() override;
+ virtual void ProcessEvent( SalUserEvent aEvent ) override;
+ bool ImplYield(bool bWait, bool bHandleAllCurrentEvents);
+
+public:
+ static SvpSalInstance* s_pDefaultInstance;
+
+ SvpSalInstance( std::unique_ptr<SalYieldMutex> pMutex );
+ virtual ~SvpSalInstance() override;
+
+ void CloseWakeupPipe(bool log);
+ void CreateWakeupPipe(bool log);
+ void Wakeup(SvpRequest request = SvpRequest::NONE);
+
+ void StartTimer( sal_uInt64 nMS );
+ void StopTimer();
+
+ inline void registerFrame( SalFrame* pFrame );
+ inline void deregisterFrame( SalFrame* pFrame );
+
+ bool CheckTimeout( bool bExecuteTimers = true );
+
+ // Frame
+ virtual SalFrame* CreateChildFrame( SystemParentData* pParent, SalFrameStyleFlags nStyle ) override;
+ virtual SalFrame* CreateFrame( SalFrame* pParent, SalFrameStyleFlags nStyle ) override;
+ virtual void DestroyFrame( SalFrame* pFrame ) override;
+
+ // Object (System Child Window)
+ virtual SalObject* CreateObject( SalFrame* pParent, SystemWindowData* pWindowData, bool bShow ) override;
+ virtual void DestroyObject( SalObject* pObject ) override;
+
+ // VirtualDevice
+ // nDX and nDY in Pixel
+ // nBitCount: 0 == Default(=as window) / 1 == Mono
+ // pData allows for using a system dependent graphics or device context
+ virtual std::unique_ptr<SalVirtualDevice>
+ CreateVirtualDevice( SalGraphics& rGraphics,
+ tools::Long &nDX, tools::Long &nDY,
+ DeviceFormat eFormat, const SystemGraphicsData *pData = nullptr ) override;
+
+ // Printer
+ // pSetupData->mpDriverData can be 0
+ // pSetupData must be updated with the current
+ // JobSetup
+ virtual SalInfoPrinter* CreateInfoPrinter( SalPrinterQueueInfo* pQueueInfo,
+ ImplJobSetup* pSetupData ) override;
+ virtual void DestroyInfoPrinter( SalInfoPrinter* pPrinter ) override;
+ virtual std::unique_ptr<SalPrinter> CreatePrinter( SalInfoPrinter* pInfoPrinter ) override;
+
+ virtual void GetPrinterQueueInfo( ImplPrnQueueList* pList ) override;
+ virtual void GetPrinterQueueState( SalPrinterQueueInfo* pInfo ) override;
+ virtual OUString GetDefaultPrinter() override;
+ virtual void PostPrintersChanged() override;
+
+ // SalTimer
+ virtual SalTimer* CreateSalTimer() override;
+ // SalSystem
+ virtual SalSystem* CreateSalSystem() override;
+ // SalBitmap
+ virtual std::shared_ptr<SalBitmap> CreateSalBitmap() override;
+
+ // wait next event and dispatch
+ // must returned by UserEvent (SalFrame::PostEvent)
+ // and timer
+ virtual bool DoYield(bool bWait, bool bHandleAllCurrentEvents) override;
+ virtual bool AnyInput( VclInputFlags nType ) override;
+ virtual bool IsMainThread() const override;
+ virtual void updateMainThread() override;
+
+ virtual OUString GetConnectionIdentifier() override;
+
+ virtual void AddToRecentDocumentList(const OUString& rFileUrl, const OUString& rMimeType, const OUString& rDocumentService) override;
+
+ virtual std::unique_ptr<GenPspGraphics> CreatePrintGraphics() override;
+
+ virtual const cairo_font_options_t* GetCairoFontOptions() override;
+};
+
+inline void SvpSalInstance::registerFrame( SalFrame* pFrame )
+{
+ insertFrame( pFrame );
+}
+
+inline void SvpSalInstance::deregisterFrame( SalFrame* pFrame )
+{
+ eraseFrame( pFrame );
+}
+
+VCL_DLLPUBLIC cairo_surface_t* get_underlying_cairo_surface(const VirtualDevice& rDevice);
+
+#endif // INCLUDED_VCL_INC_HEADLESS_SVPINST_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/inc/headless/svpprn.hxx b/vcl/inc/headless/svpprn.hxx
new file mode 100644
index 000000000..e1dd1e15f
--- /dev/null
+++ b/vcl/inc/headless/svpprn.hxx
@@ -0,0 +1,39 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef INCLUDED_VCL_INC_HEADLESS_SVPPRN_HXX
+#define INCLUDED_VCL_INC_HEADLESS_SVPPRN_HXX
+
+#include <unx/genprn.h>
+
+class SvpSalInfoPrinter final : public PspSalInfoPrinter
+{
+public:
+ virtual bool Setup(weld::Window* pFrame, ImplJobSetup* pSetupData) override;
+};
+
+class SvpSalPrinter final : public PspSalPrinter
+{
+public:
+ SvpSalPrinter(SalInfoPrinter* pInfoPrinter);
+};
+
+#endif // INCLUDED_VCL_INC_HEADLESS_SVPPRN_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/inc/headless/svpvd.hxx b/vcl/inc/headless/svpvd.hxx
new file mode 100644
index 000000000..ca9e38cee
--- /dev/null
+++ b/vcl/inc/headless/svpvd.hxx
@@ -0,0 +1,67 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef INCLUDED_VCL_INC_HEADLESS_SVPVD_HXX
+#define INCLUDED_VCL_INC_HEADLESS_SVPVD_HXX
+
+#include <salvd.hxx>
+#include <vcl/salgtype.hxx>
+#include <basegfx/vector/b2ivector.hxx>
+
+#include <vector>
+
+class SvpSalGraphics;
+typedef struct _cairo_surface cairo_surface_t;
+
+class VCL_DLLPUBLIC SvpSalVirtualDevice : public SalVirtualDevice
+{
+ cairo_surface_t* m_pRefSurface;
+ cairo_surface_t* m_pSurface;
+ bool m_bOwnsSurface; // nearly always true, except for edge case of tdf#127529
+ basegfx::B2IVector m_aFrameSize;
+ std::vector< SvpSalGraphics* > m_aGraphics;
+
+ void CreateSurface(tools::Long nNewDX, tools::Long nNewDY, sal_uInt8 *const pBuffer);
+
+protected:
+ SvpSalGraphics* AddGraphics(SvpSalGraphics* aGraphics);
+
+public:
+ SvpSalVirtualDevice(cairo_surface_t* pRefSurface, cairo_surface_t* pPreExistingTarget);
+ virtual ~SvpSalVirtualDevice() override;
+
+ // SalVirtualDevice
+ virtual SalGraphics* AcquireGraphics() override;
+ virtual void ReleaseGraphics( SalGraphics* pGraphics ) override;
+
+ virtual bool SetSize( tools::Long nNewDX, tools::Long nNewDY ) override;
+ virtual bool SetSizeUsingBuffer( tools::Long nNewDX, tools::Long nNewDY,
+ sal_uInt8 * pBuffer
+ ) override;
+
+ cairo_surface_t* GetSurface() const { return m_pSurface; }
+
+ // SalGeometryProvider
+ virtual tools::Long GetWidth() const override;
+ virtual tools::Long GetHeight() const override;
+};
+
+#endif // INCLUDED_VCL_INC_HEADLESS_SVPVD_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */