vcl/headless/SvpGraphicsBackend.cxx | 25 +++++++++++++++++---- vcl/headless/svpgdi.cxx | 37 ++++++-------------------------- vcl/inc/headless/CairoCommon.hxx | 2 + vcl/inc/headless/SvpGraphicsBackend.hxx | 6 ++++- vcl/inc/headless/svpgdi.hxx | 9 ------- 5 files changed, 34 insertions(+), 45 deletions(-)
New commits: commit 49c5ee173bb9085bc56822cdc90786e1477abd5d Author: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> AuthorDate: Thu Nov 11 12:45:17 2021 +0100 Commit: Tomaž Vajngerl <qui...@gmail.com> CommitDate: Thu Dec 30 11:47:24 2021 +0100 vcl: move set and reset clip region tothe SvpGraphicBackend The clip region variable now needs to be in CairoCommon and used in SvpSalGraphic and SvpGraphicBackend. Change-Id: I577ad2c3b6531a26089019ccbdc5e07398f70378 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/127705 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <qui...@gmail.com> diff --git a/vcl/headless/SvpGraphicsBackend.cxx b/vcl/headless/SvpGraphicsBackend.cxx index bac3d949a279..e41cc5449b88 100644 --- a/vcl/headless/SvpGraphicsBackend.cxx +++ b/vcl/headless/SvpGraphicsBackend.cxx @@ -33,9 +33,13 @@ void SvpGraphicsBackend::Init() {} void SvpGraphicsBackend::freeResources() {} -bool SvpGraphicsBackend::setClipRegion(const vcl::Region& /*i_rClip*/) { return false; } +bool SvpGraphicsBackend::setClipRegion(const vcl::Region& i_rClip) +{ + m_rCairoCommon.m_aClipRegion = i_rClip; + return true; +} -void SvpGraphicsBackend::ResetClipRegion() {} +void SvpGraphicsBackend::ResetClipRegion() { m_rCairoCommon.m_aClipRegion.SetNull(); } sal_uInt16 SvpGraphicsBackend::GetBitCount() const { diff --git a/vcl/headless/svpgdi.cxx b/vcl/headless/svpgdi.cxx index d32c65448ce9..e8e4ec764ac0 100644 --- a/vcl/headless/svpgdi.cxx +++ b/vcl/headless/svpgdi.cxx @@ -854,7 +854,7 @@ void SvpSalGraphics::clipRegion(cairo_t* cr, const vcl::Region& rClipRegion) void SvpSalGraphics::clipRegion(cairo_t* cr) { - SvpSalGraphics::clipRegion(cr, m_aClipRegion); + SvpSalGraphics::clipRegion(cr, m_aCairoCommon.m_aClipRegion); } bool SvpSalGraphics::drawAlphaRect(tools::Long nX, tools::Long nY, tools::Long nWidth, tools::Long nHeight, sal_uInt8 nTransparency) @@ -942,17 +942,6 @@ void SvpSalGraphics::GetResolution( sal_Int32& rDPIX, sal_Int32& rDPIY ) rDPIX = rDPIY = 96; } -void SvpSalGraphics::ResetClipRegion() -{ - m_aClipRegion.SetNull(); -} - -bool SvpSalGraphics::setClipRegion( const vcl::Region& i_rClip ) -{ - m_aClipRegion = i_rClip; - return true; -} - void SvpSalGraphics::SetLineColor() { m_aLineColor = SALCOLOR_NONE; diff --git a/vcl/inc/headless/CairoCommon.hxx b/vcl/inc/headless/CairoCommon.hxx index 34bbc57a4d43..ee924edb17e1 100644 --- a/vcl/inc/headless/CairoCommon.hxx +++ b/vcl/inc/headless/CairoCommon.hxx @@ -64,6 +64,7 @@ struct VCL_DLLPUBLIC CairoCommon { cairo_surface_t* m_pSurface; basegfx::B2IVector m_aFrameSize; + vcl::Region m_aClipRegion; CairoCommon() : m_pSurface(nullptr) diff --git a/vcl/inc/headless/svpgdi.hxx b/vcl/inc/headless/svpgdi.hxx index 827dffcb46e8..5a6bcf9b3f91 100644 --- a/vcl/inc/headless/svpgdi.hxx +++ b/vcl/inc/headless/svpgdi.hxx @@ -99,7 +99,6 @@ private: void applyColor(cairo_t *cr, Color rColor, double fTransparency = 0.0); protected: - vcl::Region m_aClipRegion; SvpCairoTextRender m_aTextRenderImpl; std::unique_ptr<SvpGraphicsBackend> m_pBackend; @@ -130,9 +129,6 @@ public: virtual void GetResolution( sal_Int32& rDPIX, sal_Int32& rDPIY ) override; - virtual void ResetClipRegion() override; - virtual bool setClipRegion( const vcl::Region& ) override; - virtual void SetLineColor() override; virtual void SetLineColor( Color nColor ) override; virtual void SetFillColor() override; commit aa4f1be4a9c0161711d3d8a6cdabb7b05f53cf07 Author: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> AuthorDate: Sun Oct 31 11:40:55 2021 +0100 Commit: Tomaž Vajngerl <qui...@gmail.com> CommitDate: Thu Dec 30 11:47:12 2021 +0100 vcl: pass CairoCommon to SvpGraphicBackend, move over some methods SvpGraphicBackend now accepts CairoCommon on construction, as we need it to move over methods. This moves over GetBitCount and GetGraphicsWidth, which also needs the frame size, that is added to CairoCommon. Change-Id: I362c9bed3ef0d85fc51f90a192cc20e06d7a45c0 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/127704 Tested-by: Tomaž Vajngerl <qui...@gmail.com> Reviewed-by: Tomaž Vajngerl <qui...@gmail.com> diff --git a/vcl/headless/SvpGraphicsBackend.cxx b/vcl/headless/SvpGraphicsBackend.cxx index d8688f7cefd5..bac3d949a279 100644 --- a/vcl/headless/SvpGraphicsBackend.cxx +++ b/vcl/headless/SvpGraphicsBackend.cxx @@ -24,7 +24,10 @@ #include <basegfx/polygon/b2dpolygontools.hxx> #include <vcl/BitmapTools.hxx> -SvpGraphicsBackend::SvpGraphicsBackend() {} +SvpGraphicsBackend::SvpGraphicsBackend(CairoCommon& rCairoCommon) + : m_rCairoCommon(rCairoCommon) +{ +} void SvpGraphicsBackend::Init() {} @@ -34,9 +37,17 @@ bool SvpGraphicsBackend::setClipRegion(const vcl::Region& /*i_rClip*/) { return void SvpGraphicsBackend::ResetClipRegion() {} -sal_uInt16 SvpGraphicsBackend::GetBitCount() const { return 0; } +sal_uInt16 SvpGraphicsBackend::GetBitCount() const +{ + if (cairo_surface_get_content(m_rCairoCommon.m_pSurface) != CAIRO_CONTENT_COLOR_ALPHA) + return 1; + return 32; +} -tools::Long SvpGraphicsBackend::GetGraphicsWidth() const { return 0; } +tools::Long SvpGraphicsBackend::GetGraphicsWidth() const +{ + return m_rCairoCommon.m_pSurface ? m_rCairoCommon.m_aFrameSize.getX() : 0; +} void SvpGraphicsBackend::SetLineColor() {} diff --git a/vcl/headless/svpgdi.cxx b/vcl/headless/svpgdi.cxx index 1e6a6edf7100..d32c65448ce9 100644 --- a/vcl/headless/svpgdi.cxx +++ b/vcl/headless/svpgdi.cxx @@ -918,7 +918,7 @@ SvpSalGraphics::SvpSalGraphics() , m_aFillColor(Color(0xFF, 0xFF, 0XFF)) , m_ePaintMode(PaintMode::Over) , m_aTextRenderImpl(*this) - , m_pBackend(new SvpGraphicsBackend()) + , m_pBackend(new SvpGraphicsBackend(m_aCairoCommon)) { bool bLOKActive = comphelper::LibreOfficeKit::isActive(); initWidgetDrawBackends(bLOKActive); @@ -932,7 +932,7 @@ SvpSalGraphics::~SvpSalGraphics() void SvpSalGraphics::setSurface(cairo_surface_t* pSurface, const basegfx::B2IVector& rSize) { m_aCairoCommon.m_pSurface = pSurface; - m_aFrameSize = rSize; + m_aCairoCommon.m_aFrameSize = rSize; dl_cairo_surface_get_device_scale(pSurface, &m_fScale, nullptr); ResetClipRegion(); } @@ -942,18 +942,6 @@ void SvpSalGraphics::GetResolution( sal_Int32& rDPIX, sal_Int32& rDPIY ) rDPIX = rDPIY = 96; } -sal_uInt16 SvpSalGraphics::GetBitCount() const -{ - if (cairo_surface_get_content(m_aCairoCommon.m_pSurface) != CAIRO_CONTENT_COLOR_ALPHA) - return 1; - return 32; -} - -tools::Long SvpSalGraphics::GetGraphicsWidth() const -{ - return m_aCairoCommon.m_pSurface ? m_aFrameSize.getX() : 0; -} - void SvpSalGraphics::ResetClipRegion() { m_aClipRegion.SetNull(); @@ -2487,8 +2475,8 @@ cairo_t* SvpSalGraphics::createTmpCompatibleCairoContext() const cairo_surface_t *target = cairo_image_surface_create( #endif CAIRO_FORMAT_ARGB32, - m_aFrameSize.getX() * m_fScale, - m_aFrameSize.getY() * m_fScale); + m_aCairoCommon.m_aFrameSize.getX() * m_fScale, + m_aCairoCommon.m_aFrameSize.getY() * m_fScale); dl_cairo_surface_set_device_scale(target, m_fScale, m_fScale); @@ -2539,8 +2527,8 @@ void SvpSalGraphics::releaseCairoContext(cairo_t* cr, bool bXorModeAllowed, cons basegfx::B2IRange aIntExtents(basegfx::unotools::b2ISurroundingRangeFromB2DRange(rExtents)); sal_Int32 nExtentsLeft(aIntExtents.getMinX()), nExtentsTop(aIntExtents.getMinY()); sal_Int32 nExtentsRight(aIntExtents.getMaxX()), nExtentsBottom(aIntExtents.getMaxY()); - sal_Int32 nWidth = m_aFrameSize.getX(); - sal_Int32 nHeight = m_aFrameSize.getY(); + sal_Int32 nWidth = m_aCairoCommon.m_aFrameSize.getX(); + sal_Int32 nHeight = m_aCairoCommon.m_aFrameSize.getY(); nExtentsLeft = std::max<sal_Int32>(nExtentsLeft, 0); nExtentsTop = std::max<sal_Int32>(nExtentsTop, 0); nExtentsRight = std::min<sal_Int32>(nExtentsRight, nWidth); diff --git a/vcl/inc/headless/CairoCommon.hxx b/vcl/inc/headless/CairoCommon.hxx index 3e00c0a41cff..34bbc57a4d43 100644 --- a/vcl/inc/headless/CairoCommon.hxx +++ b/vcl/inc/headless/CairoCommon.hxx @@ -63,6 +63,7 @@ typedef struct _cairo_user_data_key cairo_user_data_key_t; struct VCL_DLLPUBLIC CairoCommon { cairo_surface_t* m_pSurface; + basegfx::B2IVector m_aFrameSize; CairoCommon() : m_pSurface(nullptr) diff --git a/vcl/inc/headless/SvpGraphicsBackend.hxx b/vcl/inc/headless/SvpGraphicsBackend.hxx index a21e886abf7f..e927ad9b684b 100644 --- a/vcl/inc/headless/SvpGraphicsBackend.hxx +++ b/vcl/inc/headless/SvpGraphicsBackend.hxx @@ -25,10 +25,14 @@ #include <salgdiimpl.hxx> #include <salgdi.hxx> +#include <headless/CairoCommon.hxx> + class VCL_DLLPUBLIC SvpGraphicsBackend : public SalGraphicsImpl { + CairoCommon& m_rCairoCommon; + public: - SvpGraphicsBackend(); + SvpGraphicsBackend(CairoCommon& rCairoCommon); void Init() override; diff --git a/vcl/inc/headless/svpgdi.hxx b/vcl/inc/headless/svpgdi.hxx index dac0c62ed4dc..827dffcb46e8 100644 --- a/vcl/inc/headless/svpgdi.hxx +++ b/vcl/inc/headless/svpgdi.hxx @@ -60,7 +60,6 @@ struct VCL_DLLPUBLIC DamageHandler class VCL_DLLPUBLIC SvpSalGraphics : public SalGraphicsAutoDelegateToImpl { CairoCommon m_aCairoCommon; - basegfx::B2IVector m_aFrameSize; double m_fScale; Color m_aLineColor; Color m_aFillColor; @@ -130,8 +129,6 @@ public: 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; virtual void ResetClipRegion() override; virtual bool setClipRegion( const vcl::Region& ) override; @@ -241,8 +238,6 @@ public: virtual SystemGraphicsData GetGraphicsData() const override; - virtual OUString getRenderBackendName() const override { return "svp"; } - #if ENABLE_CAIRO_CANVAS virtual bool SupportsCairo() const override; virtual cairo::SurfaceSharedPtr CreateSurface(const cairo::CairoSurfaceSharedPtr& rSurface) const override;