include/vcl/vcllayout.hxx | 2 ++ vcl/inc/impglyphitem.hxx | 22 ++++++++++------------ vcl/inc/sallayout.hxx | 2 ++ vcl/source/gdi/CommonSalLayout.cxx | 4 ++-- vcl/source/gdi/pdfwriter_impl.cxx | 5 ++--- vcl/source/gdi/sallayout.cxx | 16 +++++++++++----- vcl/source/outdev/font.cxx | 5 +++-- 7 files changed, 32 insertions(+), 24 deletions(-)
New commits: commit 1bfcb00aeb23efddf500e6623d36c0f816f4d2e1 Author: Noel Grandin <noel.gran...@collabora.co.uk> AuthorDate: Fri Sep 3 14:44:22 2021 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Fri Sep 3 21:44:11 2021 +0200 pull duplicate field out of GlyphItem we already store it in SalLayoutGlyphsImpl Change-Id: I772c08966572e42789bcede1a148b2b7710f29d1 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/121602 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/include/vcl/vcllayout.hxx b/include/vcl/vcllayout.hxx index e09e54f59d65..b6744ce8a118 100644 --- a/include/vcl/vcllayout.hxx +++ b/include/vcl/vcllayout.hxx @@ -27,6 +27,7 @@ #include <vcl/glyphitem.hxx> #include <vcl/dllapi.h> +class LogicalFontInstance; class ImplLayoutArgs; class PhysicalFontFace; class SalGraphics; @@ -90,6 +91,7 @@ public: // methods using glyph indexing virtual bool GetNextGlyph(const GlyphItem** pGlyph, Point& rPos, int& nStart, + const LogicalFontInstance** ppGlyphFont = nullptr, const PhysicalFontFace** pFallbackFont = nullptr) const = 0; virtual bool GetOutline(basegfx::B2DPolyPolygonVector&) const; bool GetBoundRect(tools::Rectangle&) const; diff --git a/vcl/inc/impglyphitem.hxx b/vcl/inc/impglyphitem.hxx index 913a33c1f421..1942b9d159d5 100644 --- a/vcl/inc/impglyphitem.hxx +++ b/vcl/inc/impglyphitem.hxx @@ -50,7 +50,6 @@ template <> struct typed_flags<GlyphItemFlags> : is_typed_flags<GlyphItemFlags, class VCL_DLLPUBLIC GlyphItem { - LogicalFontInstance* m_pFontInstance; sal_Int32 m_nOrigWidth; // original glyph width sal_Int32 m_nCharPos; // index in string sal_Int32 m_nXOffset; @@ -63,10 +62,8 @@ public: sal_Int32 m_nNewWidth; // width after adjustments GlyphItem(int nCharPos, int nCharCount, sal_GlyphId aGlyphId, const Point& rLinearPos, - GlyphItemFlags nFlags, int nOrigWidth, int nXOffset, - LogicalFontInstance* pFontInstance) - : m_pFontInstance(pFontInstance) - , m_nOrigWidth(nOrigWidth) + GlyphItemFlags nFlags, int nOrigWidth, int nXOffset) + : m_nOrigWidth(nOrigWidth) , m_nCharPos(nCharPos) , m_nXOffset(nXOffset) , m_aGlyphId(aGlyphId) @@ -75,7 +72,6 @@ public: , m_aLinearPos(rLinearPos) , m_nNewWidth(nOrigWidth) { - assert(m_pFontInstance); } bool IsInCluster() const { return bool(m_nFlags & GlyphItemFlags::IS_IN_CLUSTER); } @@ -87,8 +83,8 @@ public: bool IsDropped() const { return bool(m_nFlags & GlyphItemFlags::IS_DROPPED); } bool IsClusterStart() const { return bool(m_nFlags & GlyphItemFlags::IS_CLUSTER_START); } - inline bool GetGlyphBoundRect(tools::Rectangle&) const; - inline bool GetGlyphOutline(basegfx::B2DPolyPolygon&) const; + inline bool GetGlyphBoundRect(const LogicalFontInstance*, tools::Rectangle&) const; + inline bool GetGlyphOutline(const LogicalFontInstance*, basegfx::B2DPolyPolygon&) const; inline void dropGlyph(); sal_GlyphId glyphId() const { return m_aGlyphId; } @@ -98,14 +94,16 @@ public: int xOffset() const { return m_nXOffset; } }; -VCL_DLLPUBLIC bool GlyphItem::GetGlyphBoundRect(tools::Rectangle& rRect) const +VCL_DLLPUBLIC bool GlyphItem::GetGlyphBoundRect(const LogicalFontInstance* pFontInstance, + tools::Rectangle& rRect) const { - return m_pFontInstance->GetGlyphBoundRect(m_aGlyphId, rRect, IsVertical()); + return pFontInstance->GetGlyphBoundRect(m_aGlyphId, rRect, IsVertical()); } -VCL_DLLPUBLIC bool GlyphItem::GetGlyphOutline(basegfx::B2DPolyPolygon& rPoly) const +VCL_DLLPUBLIC bool GlyphItem::GetGlyphOutline(const LogicalFontInstance* pFontInstance, + basegfx::B2DPolyPolygon& rPoly) const { - return m_pFontInstance->GetGlyphOutline(m_aGlyphId, rPoly, IsVertical()); + return pFontInstance->GetGlyphOutline(m_aGlyphId, rPoly, IsVertical()); } void GlyphItem::dropGlyph() diff --git a/vcl/inc/sallayout.hxx b/vcl/inc/sallayout.hxx index 2608044d592f..9d37b71d1a3e 100644 --- a/vcl/inc/sallayout.hxx +++ b/vcl/inc/sallayout.hxx @@ -131,6 +131,7 @@ public: DeviceCoordinate FillDXArray(DeviceCoordinate* pDXArray) const override; void GetCaretPositions(int nArraySize, tools::Long* pCaretXArray) const override; bool GetNextGlyph(const GlyphItem** pGlyph, Point& rPos, int& nStart, + const LogicalFontInstance** ppGlyphFont = nullptr, const PhysicalFontFace** pFallbackFont = nullptr) const override; bool GetOutline(basegfx::B2DPolyPolygonVector&) const override; bool IsKashidaPosValid(int nCharPos) const override; @@ -187,6 +188,7 @@ public: { return *m_GlyphItems.GetFont(); } bool GetNextGlyph(const GlyphItem** pGlyph, Point& rPos, int& nStart, + const LogicalFontInstance** ppGlyphFont = nullptr, const PhysicalFontFace** pFallbackFont = nullptr) const override; const SalLayoutGlyphsImpl& GlyphsImpl() const { return m_GlyphItems; } diff --git a/vcl/source/gdi/CommonSalLayout.cxx b/vcl/source/gdi/CommonSalLayout.cxx index 5f0c9637a7d2..4aa527c91d39 100644 --- a/vcl/source/gdi/CommonSalLayout.cxx +++ b/vcl/source/gdi/CommonSalLayout.cxx @@ -583,7 +583,7 @@ bool GenericSalLayout::LayoutText(ImplLayoutArgs& rArgs, const SalLayoutGlyphsIm Point aNewPos(aCurrPos.X() + nXOffset, aCurrPos.Y() + nYOffset); const GlyphItem aGI(nCharPos, nCharCount, nGlyphIndex, aNewPos, nGlyphFlags, - nAdvance, nXOffset, &GetFont()); + nAdvance, nXOffset); m_GlyphItems.push_back(aGI); aCurrPos.AdjustX(nAdvance ); @@ -781,7 +781,7 @@ void GenericSalLayout::ApplyDXArray(const DeviceCoordinate* pDXArray, SalLayoutF GlyphItemFlags const nFlags = GlyphItemFlags::IS_IN_CLUSTER | GlyphItemFlags::IS_RTL_GLYPH; while (nCopies--) { - GlyphItem aKashida(nCharPos, 0, nKashidaIndex, aPos, nFlags, nKashidaWidth, 0, &GetFont()); + GlyphItem aKashida(nCharPos, 0, nKashidaIndex, aPos, nFlags, nKashidaWidth, 0); pGlyphIter = m_GlyphItems.insert(pGlyphIter, aKashida); aPos.AdjustX(nKashidaWidth ); aPos.AdjustX( -nOverlap ); diff --git a/vcl/source/gdi/pdfwriter_impl.cxx b/vcl/source/gdi/pdfwriter_impl.cxx index ec9712291026..31aea83a9685 100644 --- a/vcl/source/gdi/pdfwriter_impl.cxx +++ b/vcl/source/gdi/pdfwriter_impl.cxx @@ -3894,8 +3894,7 @@ void PDFWriterImpl::createDefaultCheckBoxAppearance( PDFWidget& rBox, const PDFW // make sure OpenSymbol is embedded, and includes our checkmark const sal_Unicode cMark=0x2713; const GlyphItem aItem(0, 0, pMap->GetGlyphIndex(cMark), - Point(), GlyphItemFlags::NONE, 0, 0, - const_cast<LogicalFontInstance*>(pFontInstance)); + Point(), GlyphItemFlags::NONE, 0, 0); const std::vector<sal_Ucs> aCodeUnits={ cMark }; sal_uInt8 nMappedGlyph; sal_Int32 nMappedFontObject; @@ -6132,7 +6131,7 @@ void PDFWriterImpl::drawLayout( SalLayout& rLayout, const OUString& rText, bool aGlyphs.reserve( nMaxGlyphs ); // first get all the glyphs and register them; coordinates still in Pixel Point aPos; - while (rLayout.GetNextGlyph(&pGlyph, aPos, nIndex, &pFallbackFont)) + while (rLayout.GetNextGlyph(&pGlyph, aPos, nIndex, nullptr, &pFallbackFont)) { const auto* pFont = pFallbackFont ? pFallbackFont : pDevFont; diff --git a/vcl/source/gdi/sallayout.cxx b/vcl/source/gdi/sallayout.cxx index a993b8131ca4..2370e59bfa36 100644 --- a/vcl/source/gdi/sallayout.cxx +++ b/vcl/source/gdi/sallayout.cxx @@ -612,10 +612,11 @@ bool SalLayout::GetOutline(basegfx::B2DPolyPolygonVector& rVector) const Point aPos; const GlyphItem* pGlyph; int nStart = 0; - while (GetNextGlyph(&pGlyph, aPos, nStart)) + const LogicalFontInstance* pGlyphFont; + while (GetNextGlyph(&pGlyph, aPos, nStart, &pGlyphFont)) { // get outline of individual glyph, ignoring "empty" glyphs - bool bSuccess = pGlyph->GetGlyphOutline(aGlyphOutline); + bool bSuccess = pGlyph->GetGlyphOutline(pGlyphFont, aGlyphOutline); bAllOk &= bSuccess; bOneOk |= bSuccess; // only add non-empty outlines @@ -644,10 +645,11 @@ bool SalLayout::GetBoundRect(tools::Rectangle& rRect) const Point aPos; const GlyphItem* pGlyph; int nStart = 0; - while (GetNextGlyph(&pGlyph, aPos, nStart)) + const LogicalFontInstance* pGlyphFont; + while (GetNextGlyph(&pGlyph, aPos, nStart, &pGlyphFont)) { // get bounding rectangle of individual glyph - if (pGlyph->GetGlyphBoundRect(aRectangle)) + if (pGlyph->GetGlyphBoundRect(pGlyphFont, aRectangle)) { // merge rectangle aRectangle += aPos; @@ -915,6 +917,7 @@ sal_Int32 GenericSalLayout::GetTextBreak( DeviceCoordinate nMaxWidth, DeviceCoor bool GenericSalLayout::GetNextGlyph(const GlyphItem** pGlyph, Point& rPos, int& nStart, + const LogicalFontInstance** ppGlyphFont, const PhysicalFontFace**) const { std::vector<GlyphItem>::const_iterator pGlyphIter = m_GlyphItems.begin(); @@ -939,6 +942,8 @@ bool GenericSalLayout::GetNextGlyph(const GlyphItem** pGlyph, // update return data with glyph info *pGlyph = &(*pGlyphIter); ++nStart; + if (ppGlyphFont) + *ppGlyphFont = m_GlyphItems.GetFont().get(); // calculate absolute position in pixel units Point aRelativePos = pGlyphIter->m_aLinearPos; @@ -1529,6 +1534,7 @@ void MultiSalLayout::GetCaretPositions( int nMaxIndex, tools::Long* pCaretXArray bool MultiSalLayout::GetNextGlyph(const GlyphItem** pGlyph, Point& rPos, int& nStart, + const LogicalFontInstance** ppGlyphFont, const PhysicalFontFace** pFallbackFont) const { // NOTE: nStart is tagged with current font index @@ -1539,7 +1545,7 @@ bool MultiSalLayout::GetNextGlyph(const GlyphItem** pGlyph, GenericSalLayout& rLayout = *mpLayouts[ nLevel ]; rLayout.InitFont(); const PhysicalFontFace* pFontFace = rLayout.GetFont().GetFontFace(); - if (rLayout.GetNextGlyph(pGlyph, rPos, nStart)) + if (rLayout.GetNextGlyph(pGlyph, rPos, nStart, ppGlyphFont)) { int nFontTag = nLevel << GF_FONTSHIFT; nStart |= nFontTag; diff --git a/vcl/source/outdev/font.cxx b/vcl/source/outdev/font.cxx index 3f84afb2c3bf..1875394eaf93 100644 --- a/vcl/source/outdev/font.cxx +++ b/vcl/source/outdev/font.cxx @@ -1221,10 +1221,11 @@ void OutputDevice::ImplDrawEmphasisMarks( SalLayout& rSalLayout ) Point aOutPoint; tools::Rectangle aRectangle; const GlyphItem* pGlyph; + const LogicalFontInstance* pGlyphFont; int nStart = 0; - while (rSalLayout.GetNextGlyph(&pGlyph, aOutPoint, nStart)) + while (rSalLayout.GetNextGlyph(&pGlyph, aOutPoint, nStart, &pGlyphFont)) { - if (!pGlyph->GetGlyphBoundRect(aRectangle)) + if (!pGlyph->GetGlyphBoundRect(pGlyphFont, aRectangle)) continue; if (!pGlyph->IsSpacing())