summaryrefslogtreecommitdiff
path: root/vcl/headless
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2021-10-31 11:40:55 +0100
committerTomaž Vajngerl <quikee@gmail.com>2021-12-30 11:47:12 +0100
commitaa4f1be4a9c0161711d3d8a6cdabb7b05f53cf07 (patch)
tree7a8c8bc8b090612f182c2b5c7afd4704fdc40c68 /vcl/headless
parent70a1f26a5ebb839279f1c7d58ffd9f085bfb1f0b (diff)
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 <quikee@gmail.com> Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'vcl/headless')
-rw-r--r--vcl/headless/SvpGraphicsBackend.cxx17
-rw-r--r--vcl/headless/svpgdi.cxx24
2 files changed, 20 insertions, 21 deletions
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);