diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-15 05:54:39 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-15 05:54:39 +0000 |
commit | 267c6f2ac71f92999e969232431ba04678e7437e (patch) | |
tree | 358c9467650e1d0a1d7227a21dac2e3d08b622b2 /vcl/inc/headless | |
parent | Initial commit. (diff) | |
download | libreoffice-267c6f2ac71f92999e969232431ba04678e7437e.tar.xz libreoffice-267c6f2ac71f92999e969232431ba04678e7437e.zip |
Adding upstream version 4:24.2.0.upstream/4%24.2.0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vcl/inc/headless')
-rw-r--r-- | vcl/inc/headless/BitmapHelper.hxx | 75 | ||||
-rw-r--r-- | vcl/inc/headless/CairoCommon.hxx | 269 | ||||
-rw-r--r-- | vcl/inc/headless/SvpGraphicsBackend.hxx | 139 | ||||
-rw-r--r-- | vcl/inc/headless/svpbmp.hxx | 75 | ||||
-rw-r--r-- | vcl/inc/headless/svpdata.hxx | 25 | ||||
-rw-r--r-- | vcl/inc/headless/svpdummies.hxx | 64 | ||||
-rw-r--r-- | vcl/inc/headless/svpframe.hxx | 145 | ||||
-rw-r--r-- | vcl/inc/headless/svpgdi.hxx | 110 | ||||
-rw-r--r-- | vcl/inc/headless/svpinst.hxx | 192 | ||||
-rw-r--r-- | vcl/inc/headless/svpprn.hxx | 39 | ||||
-rw-r--r-- | vcl/inc/headless/svpvd.hxx | 66 |
11 files changed, 1199 insertions, 0 deletions
diff --git a/vcl/inc/headless/BitmapHelper.hxx b/vcl/inc/headless/BitmapHelper.hxx new file mode 100644 index 0000000000..2b65984647 --- /dev/null +++ b/vcl/inc/headless/BitmapHelper.hxx @@ -0,0 +1,75 @@ +/* -*- 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 VCL_DLLPUBLIC 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 VCL_DLLPUBLIC MaskHelper : public SurfaceHelper +{ +public: + explicit MaskHelper(const SalBitmap& rAlphaBitmap); +}; + +class SystemDependentData_BitmapHelper : public basegfx::SystemDependentData +{ +private: + std::shared_ptr<BitmapHelper> maBitmapHelper; + +public: + SystemDependentData_BitmapHelper(std::shared_ptr<BitmapHelper> xBitmapHelper); + + 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(std::shared_ptr<MaskHelper> xMaskHelper); + + 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 0000000000..13e0398dd6 --- /dev/null +++ b/vcl/inc/headless/CairoCommon.hxx @@ -0,0 +1,269 @@ +/* -*- 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 <cairo.h> + +#include <vcl/dllapi.h> +#include <vcl/region.hxx> +#include <vcl/salgtype.hxx> +#include <vcl/vclenum.hxx> +#include <vcl/BitmapBuffer.hxx> + +#include <com/sun/star/drawing/LineCap.hpp> + +#include <basegfx/utils/systemdependentdata.hxx> +#include <basegfx/range/b2drange.hxx> +#include <basegfx/matrix/b2dhommatrix.hxx> +#include <basegfx/polygon/b2dpolypolygon.hxx> +#include <basegfx/polygon/b2dpolygon.hxx> + +#include <optional> +#include <unordered_map> + +typedef struct _cairo cairo_t; +typedef struct _cairo_surface cairo_surface_t; +typedef struct _cairo_user_data_key cairo_user_data_key_t; + +class Gradient; +class SalBitmap; +struct SalGradient; + +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 final : 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(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); + +class VCL_DLLPUBLIC PixelSnapper +{ +public: + basegfx::B2DPoint snap(const basegfx::B2DPolygon& rPolygon, + const basegfx::B2DHomMatrix& rObjectToDevice, + basegfx::B2DHomMatrix& rObjectToDeviceInv, sal_uInt32 nIndex); + +private: + basegfx::B2DPoint maPrevPoint, maCurrPoint, maNextPoint; + basegfx::B2ITuple maPrevTuple, maCurrTuple, maNextTuple; +}; + +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::optional<BitmapBuffer> FastConvert24BitRgbTo32BitCairo(const BitmapBuffer* pSrc); + +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; + std::optional<Color> m_oLineColor; + std::optional<Color> m_oFillColor; + PaintMode m_ePaintMode; + double m_fScale; + + CairoCommon() + : m_pSurface(nullptr) + , m_oLineColor(Color(0x00, 0x00, 0x00)) + , m_oFillColor(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; } + + sal_uInt16 GetBitCount() const; + + cairo_t* getCairoContext(bool bXorModeAllowed, bool bAntiAlias) const; + void releaseCairoContext(cairo_t* cr, bool bXorModeAllowed, + const basegfx::B2DRange& rExtents) const; + + cairo_t* createTmpCompatibleCairoContext() const; + + static 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); + + void SetXORMode(bool bSet, bool bInvertOnly); + void SetROPLineColor(SalROPColor nROPColor); + void SetROPFillColor(SalROPColor nROPColor); + + void drawPixel(const std::optional<Color>& rLineColor, tools::Long nX, tools::Long nY, + bool bAntiAlias); + + static Color getPixel(cairo_surface_t* pSurface, tools::Long nX, tools::Long nY); + + void drawLine(tools::Long nX1, tools::Long nY1, tools::Long nX2, tools::Long nY2, + bool bAntiAlias); + + void drawRect(double nX, double nY, double nWidth, double nHeight, bool bAntiAlias); + + void drawPolygon(sal_uInt32 nPoints, const Point* pPtAry, bool bAntiAlias); + + void drawPolyPolygon(sal_uInt32 nPoly, const sal_uInt32* pPoints, const Point** pPtAry, + bool bAntiAlias); + + void drawPolyPolygon(const basegfx::B2DHomMatrix& rObjectToDevice, + const basegfx::B2DPolyPolygon&, double fTransparency, bool bAntiAlias); + + void drawPolyLine(sal_uInt32 nPoints, const Point* pPtAry, bool bAntiAlias); + + bool drawPolyLine(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, bool bAntiAlias); + + bool drawAlphaRect(tools::Long nX, tools::Long nY, tools::Long nWidth, tools::Long nHeight, + sal_uInt8 nTransparency, bool bAntiAlias); + + bool drawGradient(const tools::PolyPolygon& rPolyPolygon, const Gradient& rGradient, + bool bAntiAlias); + + bool implDrawGradient(basegfx::B2DPolyPolygon const& rPolyPolygon, SalGradient const& rGradient, + bool bAntiAlias); + + 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); + + void invert(tools::Long nX, tools::Long nY, tools::Long nWidth, tools::Long nHeight, + SalInvert nFlags, bool bAntiAlias); + + void invert(sal_uInt32 nPoints, const Point* pPtAry, SalInvert nFlags, bool bAntiAlias); + + void drawBitmap(const SalTwoRect& rPosAry, const SalBitmap& rSalBitmap, bool bAntiAlias); + + bool drawAlphaBitmap(const SalTwoRect& rTR, const SalBitmap& rSourceBitmap, + const SalBitmap& rAlphaBitmap, bool bAntiAlias); + + bool drawTransformedBitmap(const basegfx::B2DPoint& rNull, const basegfx::B2DPoint& rX, + const basegfx::B2DPoint& rY, const SalBitmap& rSourceBitmap, + const SalBitmap* pAlphaBitmap, double fAlpha, bool bAntiAlias); + + void drawMask(const SalTwoRect& rTR, const SalBitmap& rSalBitmap, Color nMaskColor, + bool bAntiAlias); + + std::shared_ptr<SalBitmap> getBitmap(tools::Long nX, tools::Long nY, tools::Long nWidth, + tools::Long nHeight); + + static cairo_surface_t* createCairoSurface(const BitmapBuffer* pBuffer); + + static bool supportsOperation(OutDevSupportType eType); + static bool hasFastDrawTransformedBitmap(); + +private: + void doXorOnRelease(sal_Int32 nExtentsLeft, sal_Int32 nExtentsTop, sal_Int32 nExtentsRight, + sal_Int32 nExtentsBottom, cairo_surface_t* const surface, + sal_Int32 nWidth) const; +}; + +class VCL_DLLPUBLIC 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 0000000000..6a68899c8a --- /dev/null +++ b/vcl/inc/headless/SvpGraphicsBackend.hxx @@ -0,0 +1,139 @@ +/* -*- 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 final : public SalGraphicsImpl +{ + CairoCommon& m_rCairoCommon; + +public: + SvpGraphicsBackend(CairoCommon& rCairoCommon); + + void Init() override; + + void freeResources() override; + + OUString getRenderBackendName() const override { return "svp"; } + + void 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; + + void 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); +}; + +/* 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 0000000000..b7fdb230f9 --- /dev/null +++ b/vcl/inc/headless/svpbmp.hxx @@ -0,0 +1,75 @@ +/* -*- 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> +#include <optional> + +class VCL_DLLPUBLIC SvpSalBitmap final : public SalBitmap, public basegfx::SystemDependentDataHolder // MM02 +{ + std::optional<BitmapBuffer> moDIB; +public: + SvpSalBitmap(); + virtual ~SvpSalBitmap() override; + + bool ImplCreate(const Size& rSize, + vcl::PixelFormat ePixelFormat, + const BitmapPalette& rPalette, + bool bClear); + + // 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(const std::optional<BitmapBuffer> & pBuf); + const BitmapBuffer* GetBuffer() const + { + return moDIB ? &*moDIB : nullptr; + } + 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; + + virtual const basegfx::SystemDependentDataHolder* accessSystemDependentDataHolder() const override; +}; + +#endif // INCLUDED_VCL_INC_HEADLESS_SVPBMP_HXX + +/* 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 0000000000..f995d7ef39 --- /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 0000000000..92958f8d55 --- /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 +{ + SystemEnvData m_aSystemChildData; + +public: + 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 AbsoluteScreenPixelRectangle 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 0000000000..3789e44745 --- /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 +#include <quartz/salgdi.h> +#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 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( AbsoluteScreenPixelRectangle& rRect ) override; + virtual SalFrame* GetParent() const override; + virtual void SetWindowState(const vcl::WindowData*) override; + virtual bool GetWindowState(vcl::WindowData*) 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 0000000000..a68c1b974c --- /dev/null +++ b/vcl/inc/headless/svpgdi.hxx @@ -0,0 +1,110 @@ +/* -*- 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 <osl/endian.h> +#include <vcl/sysdata.hxx> +#include <config_cairo_canvas.h> + +#include <salgdi.hxx> +#include <sallayout.hxx> +#include <unx/cairotextrender.hxx> +#include <font/FontMetricData.hxx> + +#include <headless/SvpGraphicsBackend.hxx> +#include <headless/CairoCommon.hxx> + +struct BitmapBuffer; +class FreetypeFont; + +class VCL_DLLPUBLIC SvpSalGraphics : public SalGraphicsAutoDelegateToImpl +{ + CairoCommon m_aCairoCommon; + CairoTextRender m_aTextRenderImpl; + std::unique_ptr<SvpGraphicsBackend> m_pBackend; + +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: + + 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( FontMetricDataRef&, 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 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 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 0000000000..efe32761f5 --- /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 <mutex> +#include <queue> + +#include <sys/time.h> + +#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 + std::mutex m_FeedbackMutex; + std::queue<bool> m_FeedbackPipe; + std::condition_variable m_FeedbackCV; + 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(); + 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 0000000000..e1dd1e15f9 --- /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 0000000000..f1666b689a --- /dev/null +++ b/vcl/inc/headless/svpvd.hxx @@ -0,0 +1,66 @@ +/* -*- 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 <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; + + bool 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: */ |