summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2023-01-11 09:22:40 +0000
committerCaolán McNamara <caolanm@redhat.com>2023-01-12 11:33:24 +0000
commit4557bd79fe323af6b192e40ba6a035fe06d6adcf (patch)
treed8a7d00c25c8c87a267e4aade050adbcf5b2f42a /vcl
parent4160be791daaef1a0c059a248f678cbad6408a69 (diff)
merge duplicate CairoTextRender impls
drop getSurfaceOffset because both impls just set these to 0, so its a no opt Change-Id: Ie4f28d57fb8a170c7a46d3cafceef3e049c26e2f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145325 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'vcl')
-rw-r--r--vcl/Library_vcl.mk1
-rw-r--r--vcl/Library_vclplug_gen.mk1
-rw-r--r--vcl/headless/svpcairotextrender.cxx34
-rw-r--r--vcl/headless/svpgdi.cxx2
-rw-r--r--vcl/inc/headless/svpcairotextrender.hxx32
-rw-r--r--vcl/inc/headless/svpgdi.hxx10
-rw-r--r--vcl/inc/unx/cairotextrender.hxx16
-rw-r--r--vcl/inc/unx/salgdi.h10
-rw-r--r--vcl/inc/unx/x11/x11cairotextrender.hxx41
-rw-r--r--vcl/unx/generic/gdi/cairotextrender.cxx24
-rw-r--r--vcl/unx/generic/gdi/salgdi.cxx4
-rw-r--r--vcl/unx/generic/gdi/x11cairotextrender.cxx66
12 files changed, 33 insertions, 208 deletions
diff --git a/vcl/Library_vcl.mk b/vcl/Library_vcl.mk
index ca32ff803ebe..f66bfc53db9e 100644
--- a/vcl/Library_vcl.mk
+++ b/vcl/Library_vcl.mk
@@ -557,7 +557,6 @@ vcl_headless_freetype_code=\
vcl/unx/generic/fontmanager/fontconfig \
vcl/unx/generic/fontmanager/fontmanager \
vcl/unx/generic/fontmanager/helper \
- vcl/headless/svpcairotextrender \
vcl/unx/generic/print/bitmap_gfx \
vcl/unx/generic/print/common_gfx \
vcl/unx/generic/print/glyphset \
diff --git a/vcl/Library_vclplug_gen.mk b/vcl/Library_vclplug_gen.mk
index 4c6a5c7b0ef3..c117fb3bbee4 100644
--- a/vcl/Library_vclplug_gen.mk
+++ b/vcl/Library_vclplug_gen.mk
@@ -98,7 +98,6 @@ $(eval $(call gb_Library_add_exception_objects,vclplug_gen,\
vcl/unx/generic/dtrans/X11_service \
vcl/unx/generic/dtrans/X11_transferable \
vcl/unx/generic/gdi/cairo_xlib_cairo \
- vcl/unx/generic/gdi/x11cairotextrender \
vcl/unx/generic/gdi/X11CairoSalGraphicsImpl \
vcl/unx/generic/gdi/gdiimpl \
vcl/unx/generic/gdi/salgdi2 \
diff --git a/vcl/headless/svpcairotextrender.cxx b/vcl/headless/svpcairotextrender.cxx
deleted file mode 100644
index c64bafae0969..000000000000
--- a/vcl/headless/svpcairotextrender.cxx
+++ /dev/null
@@ -1,34 +0,0 @@
-/* -*- 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/.
- */
-
-#include <headless/svpcairotextrender.hxx>
-#include <headless/svpgdi.hxx>
-#include <cairo.h>
-
-SvpCairoTextRender::SvpCairoTextRender(SvpSalGraphics& rParent)
- : mrParent(rParent)
-{
-}
-
-cairo_t* SvpCairoTextRender::getCairoContext() { return mrParent.getCairoContext(); }
-
-void SvpCairoTextRender::getSurfaceOffset(double& nDX, double& nDY)
-{
- nDX = 0;
- nDY = 0;
-}
-
-void SvpCairoTextRender::clipRegion(cairo_t* cr) { mrParent.clipRegion(cr); }
-
-void SvpCairoTextRender::releaseCairoContext(cairo_t* cr)
-{
- mrParent.releaseCairoContext(cr, basegfx::B2DRange());
-}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/headless/svpgdi.cxx b/vcl/headless/svpgdi.cxx
index a7ce0e3c769e..c9edd7e9a19c 100644
--- a/vcl/headless/svpgdi.cxx
+++ b/vcl/headless/svpgdi.cxx
@@ -26,7 +26,7 @@
#include <comphelper/lok.hxx>
SvpSalGraphics::SvpSalGraphics()
- : m_aTextRenderImpl(*this)
+ : m_aTextRenderImpl(m_aCairoCommon)
, m_pBackend(new SvpGraphicsBackend(m_aCairoCommon))
{
bool bLOKActive = comphelper::LibreOfficeKit::isActive();
diff --git a/vcl/inc/headless/svpcairotextrender.hxx b/vcl/inc/headless/svpcairotextrender.hxx
deleted file mode 100644
index 35744d5a2e3e..000000000000
--- a/vcl/inc/headless/svpcairotextrender.hxx
+++ /dev/null
@@ -1,32 +0,0 @@
-/* -*- 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/svpgdi.hxx b/vcl/inc/headless/svpgdi.hxx
index 740edd93f149..29b7dd53c7c2 100644
--- a/vcl/inc/headless/svpgdi.hxx
+++ b/vcl/inc/headless/svpgdi.hxx
@@ -33,7 +33,7 @@
#include <font/PhysicalFontFace.hxx>
#include <salgdi.hxx>
#include <sallayout.hxx>
-#include "svpcairotextrender.hxx"
+#include <unx/cairotextrender.hxx>
#include <impfontmetricdata.hxx>
#include <headless/SvpGraphicsBackend.hxx>
@@ -45,7 +45,7 @@ class FreetypeFont;
class VCL_DLLPUBLIC SvpSalGraphics : public SalGraphicsAutoDelegateToImpl
{
CairoCommon m_aCairoCommon;
- SvpCairoTextRender m_aTextRenderImpl;
+ CairoTextRender m_aTextRenderImpl;
std::unique_ptr<SvpGraphicsBackend> m_pBackend;
public:
@@ -98,15 +98,11 @@ public:
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());
diff --git a/vcl/inc/unx/cairotextrender.hxx b/vcl/inc/unx/cairotextrender.hxx
index e9a85739827b..05f15d14ee27 100644
--- a/vcl/inc/unx/cairotextrender.hxx
+++ b/vcl/inc/unx/cairotextrender.hxx
@@ -24,26 +24,26 @@
class GenericSalLayout;
class SalGraphics;
+struct CairoCommon;
typedef struct _cairo cairo_t;
typedef struct _cairo_font_options cairo_font_options_t;
class VCL_DLLPUBLIC CairoTextRender : public FreeTypeTextRenderImpl
{
private:
+ CairoCommon& mrCairoCommon;
// https://gitlab.freedesktop.org/cairo/cairo/-/merge_requests/235
// I don't want to have CAIRO_ROUND_GLYPH_POS_ON set in the cairo
// surfaces font_options, but that's private, so tricky to achieve
- cairo_font_options_t* mpRoundGlyphPosOffOptions;
+ cairo_font_options_t* mpRoundGlyphPosOffOptions;
protected:
- virtual cairo_t* getCairoContext() = 0;
- virtual void getSurfaceOffset(double& nDX, double& nDY) = 0;
- virtual void releaseCairoContext(cairo_t* cr) = 0;
-
- virtual void clipRegion(cairo_t* cr) = 0;
+ cairo_t* getCairoContext();
+ void releaseCairoContext(cairo_t* cr);
+ void clipRegion(cairo_t* cr);
public:
- virtual void DrawTextLayout(const GenericSalLayout&, const SalGraphics&) override;
- CairoTextRender();
+ virtual void DrawTextLayout(const GenericSalLayout&, const SalGraphics&) override;
+ CairoTextRender(CairoCommon& rCairoCommon);
virtual ~CairoTextRender();
};
diff --git a/vcl/inc/unx/salgdi.h b/vcl/inc/unx/salgdi.h
index 9fa31a2295a2..99a1a3e91af6 100644
--- a/vcl/inc/unx/salgdi.h
+++ b/vcl/inc/unx/salgdi.h
@@ -141,16 +141,6 @@ public:
*/
void YieldGraphicsExpose();
- cairo_t* getCairoContext() const
- {
- return maCairoCommon.getCairoContext(/*bXorModeAllowed*/false, getAntiAlias());
- }
-
- void releaseCairoContext(cairo_t* cr, const basegfx::B2DRange& rExtents) const
- {
- return maCairoCommon.releaseCairoContext(cr, /*bXorModeAllowed*/false, rExtents);
- }
-
private:
using SalGraphics::GetPixel;
void SetClipRegion( GC pGC, Region pXReg = nullptr ) const;
diff --git a/vcl/inc/unx/x11/x11cairotextrender.hxx b/vcl/inc/unx/x11/x11cairotextrender.hxx
deleted file mode 100644
index 1da78384d0bd..000000000000
--- a/vcl/inc/unx/x11/x11cairotextrender.hxx
+++ /dev/null
@@ -1,41 +0,0 @@
-/* -*- 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_UNX_GENERIC_GDI_X11CAIROTEXTRENDER_HXX
-#define INCLUDED_VCL_UNX_GENERIC_GDI_X11CAIROTEXTRENDER_HXX
-
-#include <unx/cairotextrender.hxx>
-#include <unx/salgdi.h>
-
-class X11CairoTextRender final : public CairoTextRender
-{
- X11SalGraphics& mrParent;
-
-public:
- explicit X11CairoTextRender(X11SalGraphics& 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/unx/generic/gdi/cairotextrender.cxx b/vcl/unx/generic/gdi/cairotextrender.cxx
index 878eb3e1ac99..edc06f1bf3fa 100644
--- a/vcl/unx/generic/gdi/cairotextrender.cxx
+++ b/vcl/unx/generic/gdi/cairotextrender.cxx
@@ -131,7 +131,8 @@ extern "C"
}
#endif
-CairoTextRender::CairoTextRender()
+CairoTextRender::CairoTextRender(CairoCommon& rCairoCommon)
+ : mrCairoCommon(rCairoCommon)
{
// https://gitlab.freedesktop.org/cairo/cairo/-/merge_requests/235
// I don't want to have CAIRO_ROUND_GLYPH_POS_ON set in the cairo surfaces
@@ -309,10 +310,6 @@ void CairoTextRender::DrawTextLayout(const GenericSalLayout& rLayout, const SalG
cairo_set_font_options(cr, pFontOptions);
}
- double nDX, nDY;
- getSurfaceOffset(nDX, nDY);
- cairo_translate(cr, nDX, nDY);
-
clipRegion(cr);
cairo_set_source_rgb(cr,
@@ -412,6 +409,23 @@ void CairoTextRender::DrawTextLayout(const GenericSalLayout& rLayout, const SalG
#endif
}
+cairo_t* CairoTextRender::getCairoContext()
+{
+ // Note that cairo_set_antialias (bAntiAlias property) doesn't affect cairo
+ // text rendering. That's affected by cairo_font_options_set_antialias instead.
+ return mrCairoCommon.getCairoContext(/*bXorModeAllowed*/false, /*bAntiAlias*/true);
+}
+
+void CairoTextRender::clipRegion(cairo_t* cr)
+{
+ mrCairoCommon.clipRegion(cr);
+}
+
+void CairoTextRender::releaseCairoContext(cairo_t* cr)
+{
+ mrCairoCommon.releaseCairoContext(cr, /*bXorModeAllowed*/false, basegfx::B2DRange());
+}
+
void FontConfigFontOptions::cairo_font_options_substitute(FcPattern* pPattern)
{
const cairo_font_options_t* pFontOptions = GetSalInstance()->GetCairoFontOptions();
diff --git a/vcl/unx/generic/gdi/salgdi.cxx b/vcl/unx/generic/gdi/salgdi.cxx
index 76f31e02d5cf..89e6217c0645 100644
--- a/vcl/unx/generic/gdi/salgdi.cxx
+++ b/vcl/unx/generic/gdi/salgdi.cxx
@@ -53,7 +53,7 @@
#include "gdiimpl.hxx"
#include <unx/salframe.h>
-#include <unx/x11/x11cairotextrender.hxx>
+#include <unx/cairotextrender.hxx>
#include "cairo_xlib_cairo.hxx"
#include <cairo-xlib.h>
@@ -96,8 +96,8 @@ X11SalGraphics::X11SalGraphics():
else
#endif
{
- mxTextRenderImpl.reset(new X11CairoTextRender(*this));
mxImpl.reset(new X11CairoSalGraphicsImpl(*this, maCairoCommon));
+ mxTextRenderImpl.reset(new CairoTextRender(maCairoCommon));
}
}
diff --git a/vcl/unx/generic/gdi/x11cairotextrender.cxx b/vcl/unx/generic/gdi/x11cairotextrender.cxx
deleted file mode 100644
index bdd522a17928..000000000000
--- a/vcl/unx/generic/gdi/x11cairotextrender.cxx
+++ /dev/null
@@ -1,66 +0,0 @@
-/* -*- 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 <unx/x11/x11cairotextrender.hxx>
-
-#include <unx/glyphcache.hxx>
-#include <X11/Xregion.h>
-#include <cairo.h>
-#include <salframe.hxx>
-#include <salvd.hxx>
-
-X11CairoTextRender::X11CairoTextRender(X11SalGraphics& rParent)
- : mrParent(rParent)
-{
-}
-
-cairo_t* X11CairoTextRender::getCairoContext()
-{
- return mrParent.getCairoContext();
-}
-
-void X11CairoTextRender::getSurfaceOffset( double& nDX, double& nDY )
-{
- nDX = 0;
- nDY = 0;
-}
-
-void X11CairoTextRender::clipRegion(cairo_t* cr)
-{
- Region pClipRegion = mrParent.mpClipRegion;
- if( pClipRegion && !XEmptyRegion( pClipRegion ) )
- {
- for (tools::Long i = 0; i < pClipRegion->numRects; ++i)
- {
- cairo_rectangle(cr,
- pClipRegion->rects[i].x1,
- pClipRegion->rects[i].y1,
- pClipRegion->rects[i].x2 - pClipRegion->rects[i].x1,
- pClipRegion->rects[i].y2 - pClipRegion->rects[i].y1);
- }
- cairo_clip(cr);
- }
-}
-
-void X11CairoTextRender::releaseCairoContext(cairo_t* cr)
-{
- mrParent.releaseCairoContext(cr, basegfx::B2DRange());
-}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */