diff options
author | Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> | 2021-10-22 20:25:31 +0200 |
---|---|---|
committer | Tomaž Vajngerl <quikee@gmail.com> | 2021-12-30 02:55:31 +0100 |
commit | ab6471861ca916eab445e6cc17a2f7f8457cb56e (patch) | |
tree | 391acac032cb9de30495b18c4e787f3d5a0e36d7 /vcl | |
parent | ce54ba96f38b4af3aab1a7064078ee406eb021c6 (diff) |
vcl: Introduce SvpGraphicsBackend
SvpGraphicsBackend contains the implementation of the graphic
drawing backend, which uses cairo for drawing. Currently the
cairo based graphic drawing implementation is on SvpSalGraphics,
but will be steb-by-step moved into SvpGraphicsBackend, just like
with other vcl plugins.
Change-Id: I70c94f08c5bd1d705f2faeacb66373ddf12f494a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/127702
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/Library_vcl.mk | 1 | ||||
-rw-r--r-- | vcl/headless/SvpGraphicsBackend.cxx | 223 | ||||
-rw-r--r-- | vcl/headless/svpgdi.cxx | 1 | ||||
-rw-r--r-- | vcl/inc/headless/SvpGraphicsBackend.hxx | 132 | ||||
-rw-r--r-- | vcl/inc/headless/svpgdi.hxx | 7 |
5 files changed, 362 insertions, 2 deletions
diff --git a/vcl/Library_vcl.mk b/vcl/Library_vcl.mk index cd6826c6dbba..02eadd06805a 100644 --- a/vcl/Library_vcl.mk +++ b/vcl/Library_vcl.mk @@ -526,6 +526,7 @@ vcl_headless_code= \ $(if $(filter-out iOS,$(OS)), \ vcl/headless/svpbmp \ vcl/headless/svpgdi \ + vcl/headless/SvpGraphicsBackend \ $(if $(ENABLE_HEADLESS),vcl/headless/svpdata) \ ) \ vcl/headless/svpdummies \ diff --git a/vcl/headless/SvpGraphicsBackend.cxx b/vcl/headless/SvpGraphicsBackend.cxx new file mode 100644 index 000000000000..d8688f7cefd5 --- /dev/null +++ b/vcl/headless/SvpGraphicsBackend.cxx @@ -0,0 +1,223 @@ +/* -*- 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 . + */ + +#include <headless/SvpGraphicsBackend.hxx> + +#include <sal/log.hxx> +#include <basegfx/matrix/b2dhommatrixtools.hxx> +#include <basegfx/polygon/b2dpolygontools.hxx> +#include <vcl/BitmapTools.hxx> + +SvpGraphicsBackend::SvpGraphicsBackend() {} + +void SvpGraphicsBackend::Init() {} + +void SvpGraphicsBackend::freeResources() {} + +bool SvpGraphicsBackend::setClipRegion(const vcl::Region& /*i_rClip*/) { return false; } + +void SvpGraphicsBackend::ResetClipRegion() {} + +sal_uInt16 SvpGraphicsBackend::GetBitCount() const { return 0; } + +tools::Long SvpGraphicsBackend::GetGraphicsWidth() const { return 0; } + +void SvpGraphicsBackend::SetLineColor() {} + +void SvpGraphicsBackend::SetLineColor(Color /*nColor*/) {} + +void SvpGraphicsBackend::SetFillColor() {} + +void SvpGraphicsBackend::SetFillColor(Color /*nColor*/) {} + +void SvpGraphicsBackend::SetXORMode(bool /*bSet*/, bool /*bInvertOnly*/) {} + +void SvpGraphicsBackend::SetROPLineColor(SalROPColor /*nROPColor*/) {} + +void SvpGraphicsBackend::SetROPFillColor(SalROPColor /*nROPColor*/) {} + +void SvpGraphicsBackend::drawPixel(tools::Long /*nX*/, tools::Long /*nY*/) {} + +void SvpGraphicsBackend::drawPixel(tools::Long /*nX*/, tools::Long /*nY*/, Color /*aColor*/) {} + +void SvpGraphicsBackend::drawLine(tools::Long /*nX1*/, tools::Long /*nY1*/, tools::Long /*nX2*/, + tools::Long /*nY2*/) +{ +} + +void SvpGraphicsBackend::drawRect(tools::Long /*nX*/, tools::Long /*nY*/, tools::Long /*nWidth*/, + tools::Long /*nHeight*/) +{ +} + +void SvpGraphicsBackend::drawPolyLine(sal_uInt32 /*nPoints*/, const Point* /*pPtAry*/) {} + +void SvpGraphicsBackend::drawPolygon(sal_uInt32 /*nPoints*/, const Point* /*pPtAry*/) {} + +void SvpGraphicsBackend::drawPolyPolygon(sal_uInt32 /*nPoly*/, const sal_uInt32* /*pPointCounts*/, + const Point** /*pPtAry*/) +{ +} + +bool SvpGraphicsBackend::drawPolyPolygon(const basegfx::B2DHomMatrix& /*rObjectToDevice*/, + const basegfx::B2DPolyPolygon& /*rPolyPolygon*/, + double /*fTransparency*/) +{ + return false; +} + +bool SvpGraphicsBackend::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*/) +{ + return false; +} + +bool SvpGraphicsBackend::drawPolyLineBezier(sal_uInt32, const Point*, const PolyFlags*) +{ + SAL_INFO("vcl.gdi", "unsupported SvpSalGraphics::drawPolyLineBezier case"); + return false; +} + +bool SvpGraphicsBackend::drawPolygonBezier(sal_uInt32, const Point*, const PolyFlags*) +{ + SAL_INFO("vcl.gdi", "unsupported SvpSalGraphics::drawPolygonBezier case"); + return false; +} + +bool SvpGraphicsBackend::drawPolyPolygonBezier(sal_uInt32, const sal_uInt32*, const Point* const*, + const PolyFlags* const*) +{ + SAL_INFO("vcl.gdi", "unsupported SvpSalGraphics::drawPolyPolygonBezier case"); + return false; +} + +void SvpGraphicsBackend::copyArea(tools::Long /*nDestX*/, tools::Long /*nDestY*/, + tools::Long /*nSrcX*/, tools::Long /*nSrcY*/, + tools::Long /*nSrcWidth*/, tools::Long /*nSrcHeight*/, + bool /*bWindowInvalidate*/) +{ +} + +void SvpGraphicsBackend::copyBits(const SalTwoRect& /*rTR*/, SalGraphics* /*pSrcGraphics*/) {} + +void SvpGraphicsBackend::drawBitmap(const SalTwoRect& /*rPosAry*/, const SalBitmap& /*rSalBitmap*/) +{ +} + +void SvpGraphicsBackend::drawBitmap(const SalTwoRect& /*rPosAry*/, const SalBitmap& /*rSalBitmap*/, + const SalBitmap& /*rMaskBitmap*/) +{ +} + +void SvpGraphicsBackend::drawMask(const SalTwoRect& /*rPosAry*/, const SalBitmap& /*rSalBitmap*/, + Color /*nMaskColor*/) +{ +} + +std::shared_ptr<SalBitmap> SvpGraphicsBackend::getBitmap(tools::Long /*nX*/, tools::Long /*nY*/, + tools::Long /*nWidth*/, + tools::Long /*nHeight*/) +{ + return std::shared_ptr<SalBitmap>(); +} + +Color SvpGraphicsBackend::getPixel(tools::Long /*nX*/, tools::Long /*nY*/) { return Color(); } + +void SvpGraphicsBackend::invert(tools::Long /*nX*/, tools::Long /*nY*/, tools::Long /*nWidth*/, + tools::Long /*nHeight*/, SalInvert /*nFlags*/) +{ +} + +void SvpGraphicsBackend::invert(sal_uInt32 /*nPoints*/, const Point* /*pPtAry*/, + SalInvert /*nFlags*/) +{ +} + +bool SvpGraphicsBackend::drawEPS(tools::Long /*nX*/, tools::Long /*nY*/, tools::Long /*nWidth*/, + tools::Long /*nHeight*/, void* /*pPtr*/, sal_uInt32 /*nSize*/) +{ + return false; +} + +bool SvpGraphicsBackend::blendBitmap(const SalTwoRect& /*rPosAry*/, const SalBitmap& /*rBitmap*/) +{ + return false; +} + +bool SvpGraphicsBackend::blendAlphaBitmap(const SalTwoRect& /*rPosAry*/, + const SalBitmap& /*rSrcBitmap*/, + const SalBitmap& /*rMaskBitmap*/, + const SalBitmap& /*rAlphaBitmap*/) +{ + return false; +} + +bool SvpGraphicsBackend::drawAlphaBitmap(const SalTwoRect&, const SalBitmap& /*rSourceBitmap*/, + const SalBitmap& /*rAlphaBitmap*/) +{ + return false; +} + +bool SvpGraphicsBackend::drawTransformedBitmap(const basegfx::B2DPoint& /*rNull*/, + const basegfx::B2DPoint& /*rX*/, + const basegfx::B2DPoint& /*rY*/, + const SalBitmap& /*rSourceBitmap*/, + const SalBitmap* /*pAlphaBitmap*/, double /*fAlpha*/) +{ + return false; +} + +bool SvpGraphicsBackend::hasFastDrawTransformedBitmap() const { return false; } + +bool SvpGraphicsBackend::drawAlphaRect(tools::Long /*nX*/, tools::Long /*nY*/, + tools::Long /*nWidth*/, tools::Long /*nHeight*/, + sal_uInt8 /*nTransparency*/) +{ + return false; +} + +bool SvpGraphicsBackend::drawGradient(const tools::PolyPolygon& /*rPolyPolygon*/, + const Gradient& /*rGradient*/) +{ + return false; +} + +bool SvpGraphicsBackend::implDrawGradient(basegfx::B2DPolyPolygon const& /*rPolyPolygon*/, + SalGradient const& /*rGradient*/) +{ + return false; +} + +bool SvpGraphicsBackend::supportsOperation(OutDevSupportType eType) const +{ + switch (eType) + { + case OutDevSupportType::TransparentRect: + case OutDevSupportType::B2DDraw: + return true; + } + return false; +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/headless/svpgdi.cxx b/vcl/headless/svpgdi.cxx index ac375c3fadf0..223956076471 100644 --- a/vcl/headless/svpgdi.cxx +++ b/vcl/headless/svpgdi.cxx @@ -919,6 +919,7 @@ SvpSalGraphics::SvpSalGraphics() , m_aFillColor(Color(0xFF, 0xFF, 0XFF)) , m_ePaintMode(PaintMode::Over) , m_aTextRenderImpl(*this) + , m_pBackend(new SvpGraphicsBackend()) { bool bLOKActive = comphelper::LibreOfficeKit::isActive(); initWidgetDrawBackends(bLOKActive); diff --git a/vcl/inc/headless/SvpGraphicsBackend.hxx b/vcl/inc/headless/SvpGraphicsBackend.hxx new file mode 100644 index 000000000000..a21e886abf7f --- /dev/null +++ b/vcl/inc/headless/SvpGraphicsBackend.hxx @@ -0,0 +1,132 @@ +/* -*- 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> + +class VCL_DLLPUBLIC SvpGraphicsBackend : public SalGraphicsImpl +{ +public: + SvpGraphicsBackend(); + + 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; +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/headless/svpgdi.hxx b/vcl/inc/headless/svpgdi.hxx index 32168d87e727..44aba3587276 100644 --- a/vcl/inc/headless/svpgdi.hxx +++ b/vcl/inc/headless/svpgdi.hxx @@ -35,6 +35,7 @@ #include <sallayout.hxx> #include "svpcairotextrender.hxx" #include <impfontmetricdata.hxx> +#include "SvpGraphicsBackend.hxx" #include <cairo.h> @@ -87,7 +88,7 @@ struct VCL_DLLPUBLIC DamageHandler damageHandler damaged; }; -class VCL_DLLPUBLIC SvpSalGraphics : public SalGraphics +class VCL_DLLPUBLIC SvpSalGraphics : public SalGraphicsAutoDelegateToImpl { cairo_surface_t* m_pSurface; basegfx::B2IVector m_aFrameSize; @@ -132,6 +133,7 @@ private: protected: vcl::Region m_aClipRegion; SvpCairoTextRender m_aTextRenderImpl; + std::unique_ptr<SvpGraphicsBackend> m_pBackend; protected: virtual bool blendBitmap( const SalTwoRect&, const SalBitmap& rBitmap ) override; @@ -156,7 +158,8 @@ public: SvpSalGraphics(); virtual ~SvpSalGraphics() override; - virtual SalGraphicsImpl* GetImpl() const override { return nullptr; }; + virtual SalGraphicsImpl* GetImpl() const override { return m_pBackend.get(); } + virtual void GetResolution( sal_Int32& rDPIX, sal_Int32& rDPIY ) override; virtual sal_uInt16 GetBitCount() const override; virtual tools::Long GetGraphicsWidth() const override; |