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>
This commit is contained in:
Caolán McNamara 2023-01-11 09:22:40 +00:00
parent 4160be791d
commit 4557bd79fe
15 changed files with 34 additions and 216 deletions

View file

@ -220,9 +220,7 @@ bool ReservedId::VisitNamedDecl(NamedDecl const * decl) {
&& s != "_SurfaceCellRenderer" // vcl/unx/gtk4/surfacecellrenderer.cxx
&& s != "_SurfaceCellRendererClass" // vcl/unx/gtk4/surfacecellrenderer.cxx
&& s != "_TransferableContent" // vcl/unx/gtk4/transferableprovider.cxx
&& s != "_TransferableContentClass" // vcl/unx/gtk4/transferableprovider.cxx
&& s != "_XRegion" // vcl/unx/generic/gdi/x11cairotextrender.cxx
&& s != "_XTrap") // vcl/unx/generic/gdi/xrender_peer.hxx
&& s != "_TransferableContentClass") // vcl/unx/gtk4/transferableprovider.cxx
{
report(
DiagnosticsEngine::Warning,

View file

@ -98,7 +98,6 @@
BEA20D652166596F0032F67B /* svpvd.cxx */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = svpvd.cxx; path = ../../vcl/headless/svpvd.cxx; sourceTree = "<group>"; };
BEA20D662166596F0032F67B /* svpframe.cxx */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = svpframe.cxx; path = ../../vcl/headless/svpframe.cxx; sourceTree = "<group>"; };
BEA20D672166596F0032F67B /* svpbmp.cxx */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = svpbmp.cxx; path = ../../vcl/headless/svpbmp.cxx; sourceTree = "<group>"; };
BEA20D682166596F0032F67B /* svpcairotextrender.cxx */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = svpcairotextrender.cxx; path = ../../vcl/headless/svpcairotextrender.cxx; sourceTree = "<group>"; };
BEA20D692166596F0032F67B /* svpgdi.cxx */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = svpgdi.cxx; path = ../../vcl/headless/svpgdi.cxx; sourceTree = "<group>"; };
BEA20D6A2166596F0032F67B /* svpglyphcache.cxx */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = svpglyphcache.cxx; path = ../../vcl/headless/svpglyphcache.cxx; sourceTree = "<group>"; };
BEA20D6B2166596F0032F67B /* svpinst.cxx */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = svpinst.cxx; path = ../../vcl/headless/svpinst.cxx; sourceTree = "<group>"; };
@ -355,7 +354,6 @@
children = (
BEA20D6D2166596F0032F67B /* headlessinst.cxx */,
BEA20D672166596F0032F67B /* svpbmp.cxx */,
BEA20D682166596F0032F67B /* svpcairotextrender.cxx */,
BEA20D6E2166596F0032F67B /* svpdata.cxx */,
BEA20D6F2166596F0032F67B /* svpdummies.cxx */,
BEA20D662166596F0032F67B /* svpframe.cxx */,

View file

@ -14380,7 +14380,6 @@ vcl/inc/unx/sm.hxx
vcl/inc/unx/wmadaptor.hxx
vcl/inc/unx/x11/x11sys.hxx
vcl/inc/unx/x11/xlimits.hxx
vcl/inc/unx/x11/xrender_peer.hxx
vcl/inc/unx/x11_cursors/ase_curs.h
vcl/inc/unx/x11_cursors/ase_mask.h
vcl/inc/unx/x11_cursors/asn_curs.h
@ -14981,8 +14980,6 @@ vcl/unx/generic/gdi/salbmp.cxx
vcl/unx/generic/gdi/salgdi.cxx
vcl/unx/generic/gdi/salgdi2.cxx
vcl/unx/generic/gdi/salvd.cxx
vcl/unx/generic/gdi/x11cairotextrender.cxx
vcl/unx/generic/gdi/xrender_peer.cxx
vcl/unx/generic/glyphs/freetype_glyphcache.cxx
vcl/unx/generic/glyphs/glyphcache.cxx
vcl/unx/generic/print/bitmap_gfx.cxx

View file

@ -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 \

View file

@ -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 \

View file

@ -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: */

View file

@ -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();

View file

@ -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: */

View file

@ -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());

View file

@ -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;
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();
CairoTextRender(CairoCommon& rCairoCommon);
virtual ~CairoTextRender();
};

View file

@ -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;

View file

@ -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: */

View file

@ -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();

View file

@ -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));
}
}

View file

@ -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: */