diff options
author | Luboš Luňák <l.lunak@collabora.com> | 2022-04-08 17:54:26 +0200 |
---|---|---|
committer | Luboš Luňák <l.lunak@collabora.com> | 2022-04-09 15:01:23 +0200 |
commit | 136d9b34459edb444fb5154fa8b5c74d877099d5 (patch) | |
tree | 5d86ce9aba6c4a5dfe3e32c5ba6efdf5a4bfde81 /vcl | |
parent | 0c852a14d61d2c06322b8a0e51960604fd212e2b (diff) |
no public data members in GlyphItem
Change-Id: Ib5911a8ad33aefffa972f583c2b5fc7d42a2b9bf
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132746
Tested-by: Jenkins
Reviewed-by: Luboš Luňák <l.lunak@collabora.com>
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/inc/impglyphitem.hxx | 18 | ||||
-rw-r--r-- | vcl/source/gdi/CommonSalLayout.cxx | 18 | ||||
-rw-r--r-- | vcl/source/gdi/pdfwriter_impl.cxx | 4 | ||||
-rw-r--r-- | vcl/source/gdi/sallayout.cxx | 32 | ||||
-rw-r--r-- | vcl/source/outdev/textline.cxx | 2 | ||||
-rw-r--r-- | vcl/win/gdi/DWriteTextRenderer.cxx | 2 |
6 files changed, 41 insertions, 35 deletions
diff --git a/vcl/inc/impglyphitem.hxx b/vcl/inc/impglyphitem.hxx index 57efcd827ccb..7228911a3ed7 100644 --- a/vcl/inc/impglyphitem.hxx +++ b/vcl/inc/impglyphitem.hxx @@ -50,27 +50,26 @@ template <> struct typed_flags<GlyphItemFlags> : is_typed_flags<GlyphItemFlags, class VCL_DLLPUBLIC GlyphItem { + DevicePoint m_aLinearPos; // absolute position of non rotated string sal_Int32 m_nOrigWidth; // original glyph width sal_Int32 m_nCharPos; // index in string sal_Int32 m_nXOffset; + sal_Int32 m_nNewWidth; // width after adjustments sal_GlyphId m_aGlyphId; sal_Int8 m_nCharCount; // number of characters making up this glyph GlyphItemFlags m_nFlags; public: - DevicePoint m_aLinearPos; // absolute position of non rotated string - sal_Int32 m_nNewWidth; // width after adjustments - GlyphItem(int nCharPos, int nCharCount, sal_GlyphId aGlyphId, const DevicePoint& rLinearPos, GlyphItemFlags nFlags, int nOrigWidth, int nXOffset) - : m_nOrigWidth(nOrigWidth) + : m_aLinearPos(rLinearPos) + , m_nOrigWidth(nOrigWidth) , m_nCharPos(nCharPos) , m_nXOffset(nXOffset) + , m_nNewWidth(nOrigWidth) , m_aGlyphId(aGlyphId) , m_nCharCount(nCharCount) , m_nFlags(nFlags) - , m_aLinearPos(rLinearPos) - , m_nNewWidth(nOrigWidth) { } @@ -92,6 +91,13 @@ public: int origWidth() const { return m_nOrigWidth; } int charPos() const { return m_nCharPos; } int xOffset() const { return m_nXOffset; } + sal_Int32 newWidth() const { return m_nNewWidth; } + const DevicePoint& linearPos() const { return m_aLinearPos; } + + void setNewWidth(sal_Int32 width) { m_nNewWidth = width; } + void addNewWidth(sal_Int32 width) { m_nNewWidth += width; } + void setLinearPosX(double x) { m_aLinearPos.setX(x); } + void adjustLinearPosX(double diff) { m_aLinearPos.adjustX(diff); } }; bool GlyphItem::GetGlyphBoundRect(const LogicalFontInstance* pFontInstance, diff --git a/vcl/source/gdi/CommonSalLayout.cxx b/vcl/source/gdi/CommonSalLayout.cxx index 2c8a4db8398f..edf5538e49e0 100644 --- a/vcl/source/gdi/CommonSalLayout.cxx +++ b/vcl/source/gdi/CommonSalLayout.cxx @@ -649,7 +649,7 @@ void GenericSalLayout::GetCharWidths(std::vector<DeviceCoordinate>& rCharWidths) const int nIndex = aGlyphItem.charPos() - mnMinCharPos; if (nIndex >= nCharCount) continue; - rCharWidths[nIndex] += aGlyphItem.m_nNewWidth; + rCharWidths[nIndex] += aGlyphItem.newWidth(); } } @@ -722,15 +722,15 @@ void GenericSalLayout::ApplyDXArray(const DC* pDXArray, SalLayoutFlags nLayoutFl { // Adjust the width and position of the first (leftmost) glyph in // the cluster. - m_GlyphItems[i].m_nNewWidth += nDiff; - m_GlyphItems[i].m_aLinearPos.adjustX(nDelta); + m_GlyphItems[i].addNewWidth(nDiff); + m_GlyphItems[i].adjustLinearPosX(nDelta); // Adjust the position of the rest of the glyphs in the cluster. while (++i < m_GlyphItems.size()) { if (!m_GlyphItems[i].IsInCluster()) break; - m_GlyphItems[i].m_aLinearPos.adjustX(nDelta); + m_GlyphItems[i].adjustLinearPosX(nDelta); } } else if (m_GlyphItems[i].IsInCluster()) @@ -744,8 +744,8 @@ void GenericSalLayout::ApplyDXArray(const DC* pDXArray, SalLayoutFlags nLayoutFl // Adjust the width and position of the first (rightmost) glyph in // the cluster. // For RTL, we put all the adjustment to the left of the glyph. - m_GlyphItems[i].m_nNewWidth += nDiff; - m_GlyphItems[i].m_aLinearPos.adjustX(nDelta + nDiff); + m_GlyphItems[i].addNewWidth(nDiff); + m_GlyphItems[i].adjustLinearPosX(nDelta + nDiff); // Adjust the X position of all glyphs in the cluster. size_t j = i; @@ -754,7 +754,7 @@ void GenericSalLayout::ApplyDXArray(const DC* pDXArray, SalLayoutFlags nLayoutFl --j; if (!m_GlyphItems[j].IsInCluster()) break; - m_GlyphItems[j].m_aLinearPos.adjustX(nDelta + nDiff); + m_GlyphItems[j].adjustLinearPosX(nDelta + nDiff); } // If this glyph is Kashida-justifiable, then mark this as a @@ -771,7 +771,7 @@ void GenericSalLayout::ApplyDXArray(const DC* pDXArray, SalLayoutFlags nLayoutFl { if (!m_GlyphItems[j].IsDiacritic()) break; - m_GlyphItems[j--].m_aLinearPos.adjustX(nDiff); + m_GlyphItems[j--].adjustLinearPosX(nDiff); } } i++; @@ -813,7 +813,7 @@ void GenericSalLayout::ApplyDXArray(const DC* pDXArray, SalLayoutFlags nLayoutFl nOverlap = nExcess / (nCopies - 1); } - DevicePoint aPos(pGlyphIter->m_aLinearPos.getX() - nTotalWidth, 0); + DevicePoint aPos(pGlyphIter->linearPos().getX() - nTotalWidth, 0); int nCharPos = pGlyphIter->charPos(); GlyphItemFlags const nFlags = GlyphItemFlags::IS_IN_CLUSTER | GlyphItemFlags::IS_RTL_GLYPH; while (nCopies--) diff --git a/vcl/source/gdi/pdfwriter_impl.cxx b/vcl/source/gdi/pdfwriter_impl.cxx index 7e01ed70dc58..8f9792acf54a 100644 --- a/vcl/source/gdi/pdfwriter_impl.cxx +++ b/vcl/source/gdi/pdfwriter_impl.cxx @@ -6341,7 +6341,7 @@ void PDFWriterImpl::drawLayout( SalLayout& rLayout, const OUString& rText, bool if( !nWidth ) aStartPt = Point(aPos.getX(), aPos.getY()); - nWidth += pGlyph->m_nNewWidth; + nWidth += pGlyph->newWidth(); } else if( nWidth > 0 ) { @@ -6434,7 +6434,7 @@ void PDFWriterImpl::drawLayout( SalLayout& rLayout, const OUString& rText, bool if (pGlyph->IsSpacing()) { Point aAdjOffset = aOffset; - aAdjOffset.AdjustX((pGlyph->m_nNewWidth - nEmphWidth) / 2 ); + aAdjOffset.AdjustX((pGlyph->newWidth() - nEmphWidth) / 2 ); aAdjOffset = aRotScale.transform( aAdjOffset ); aAdjOffset -= Point( nEmphWidth2, nEmphHeight2 ); diff --git a/vcl/source/gdi/sallayout.cxx b/vcl/source/gdi/sallayout.cxx index abad66427491..17d5bfbb6c20 100644 --- a/vcl/source/gdi/sallayout.cxx +++ b/vcl/source/gdi/sallayout.cxx @@ -277,10 +277,10 @@ DeviceCoordinate GenericSalLayout::GetTextWidth() const for (auto const& aGlyphItem : m_GlyphItems) { // update the text extent with the glyph extent - DeviceCoordinate nXPos = aGlyphItem.m_aLinearPos.getX(); + DeviceCoordinate nXPos = aGlyphItem.linearPos().getX(); if( nMinPos > nXPos ) nMinPos = nXPos; - nXPos += aGlyphItem.m_nNewWidth - aGlyphItem.xOffset(); + nXPos += aGlyphItem.newWidth() - aGlyphItem.xOffset(); if( nMaxPos < nXPos ) nMaxPos = nXPos; } @@ -322,7 +322,7 @@ void GenericSalLayout::Justify( DeviceCoordinate nNewWidth ) if( nNewWidth < nMaxGlyphWidth) nNewWidth = nMaxGlyphWidth; nNewWidth -= pGlyphIterRight->origWidth(); - pGlyphIterRight->m_aLinearPos.setX( nNewWidth ); + pGlyphIterRight->setLinearPosX( nNewWidth ); // justify glyph widths and positions int nDiffWidth = nNewWidth - nOldWidth; @@ -333,7 +333,7 @@ void GenericSalLayout::Justify( DeviceCoordinate nNewWidth ) for( pGlyphIter = m_GlyphItems.begin(); pGlyphIter != pGlyphIterRight; ++pGlyphIter ) { // move glyph to justified position - pGlyphIter->m_aLinearPos.adjustX(nDeltaSum); + pGlyphIter->adjustLinearPosX(nDeltaSum); // do not stretch non-stretchable glyphs if( pGlyphIter->IsDiacritic() || (nStretchable <= 0) ) @@ -342,7 +342,7 @@ void GenericSalLayout::Justify( DeviceCoordinate nNewWidth ) // distribute extra space equally to stretchable glyphs int nDeltaWidth = nDiffWidth / nStretchable--; nDiffWidth -= nDeltaWidth; - pGlyphIter->m_nNewWidth += nDeltaWidth; + pGlyphIter->addNewWidth(nDeltaWidth); nDeltaSum += nDeltaWidth; } } @@ -354,14 +354,14 @@ void GenericSalLayout::Justify( DeviceCoordinate nNewWidth ) { for( pGlyphIter = m_GlyphItems.begin(); ++pGlyphIter != pGlyphIterRight;) { - int nX = pGlyphIter->m_aLinearPos.getX(); + int nX = pGlyphIter->linearPos().getX(); nX = static_cast<int>(nX * fSqueeze); - pGlyphIter->m_aLinearPos.setX( nX ); + pGlyphIter->setLinearPosX( nX ); } } // adjust glyph widths to new positions for( pGlyphIter = m_GlyphItems.begin(); pGlyphIter != pGlyphIterRight; ++pGlyphIter ) - pGlyphIter->m_nNewWidth = pGlyphIter[1].m_aLinearPos.getX() - pGlyphIter[0].m_aLinearPos.getX(); + pGlyphIter->setNewWidth( pGlyphIter[1].linearPos().getX() - pGlyphIter[0].linearPos().getX()); } } @@ -442,14 +442,14 @@ void GenericSalLayout::ApplyAsianKerning(const OUString& rStr) { nDelta = (nDelta * pGlyphIter->origWidth() + 2) / 4; if( pGlyphIter+1 == pGlyphIterEnd ) - pGlyphIter->m_nNewWidth += nDelta; + pGlyphIter->addNewWidth( nDelta ); nOffset += nDelta; } } // adjust the glyph positions to the new glyph widths if( pGlyphIter+1 != pGlyphIterEnd ) - pGlyphIter->m_aLinearPos.adjustX(nOffset); + pGlyphIter->adjustLinearPosX(nOffset); } } @@ -462,7 +462,7 @@ void GenericSalLayout::GetCaretPositions( int nMaxIndex, sal_Int32* pCaretXArray // calculate caret positions using glyph array for (auto const& aGlyphItem : m_GlyphItems) { - tools::Long nXPos = aGlyphItem.m_aLinearPos.getX(); + tools::Long nXPos = aGlyphItem.linearPos().getX(); tools::Long nXRight = nXPos + aGlyphItem.origWidth(); int n = aGlyphItem.charPos(); int nCurrIdx = 2 * (n - mnMinCharPos); @@ -532,7 +532,7 @@ bool GenericSalLayout::GetNextGlyph(const GlyphItem** pGlyph, *ppGlyphFont = m_GlyphItems.GetFont().get(); // calculate absolute position in pixel units - DevicePoint aRelativePos = pGlyphIter->m_aLinearPos; + DevicePoint aRelativePos = pGlyphIter->linearPos(); aRelativePos.setX( aRelativePos.getX() / mnUnitsPerPixel ); aRelativePos.setY( aRelativePos.getY() / mnUnitsPerPixel ); @@ -553,15 +553,15 @@ void GenericSalLayout::MoveGlyph( int nStart, tools::Long nNewXPos ) // as RTL-glyphs are right justified in their cell // the cell position needs to be adjusted to the glyph position if( pGlyphIter->IsRTLGlyph() ) - nNewXPos += pGlyphIter->m_nNewWidth - pGlyphIter->origWidth(); + nNewXPos += pGlyphIter->newWidth() - pGlyphIter->origWidth(); // calculate the x-offset to the old position - tools::Long nXDelta = nNewXPos - pGlyphIter->m_aLinearPos.getX() + pGlyphIter->xOffset(); + tools::Long nXDelta = nNewXPos - pGlyphIter->linearPos().getX() + pGlyphIter->xOffset(); // adjust all following glyph positions if needed if( nXDelta != 0 ) { for( std::vector<GlyphItem>::iterator pGlyphIterEnd = m_GlyphItems.end(); pGlyphIter != pGlyphIterEnd; ++pGlyphIter ) { - pGlyphIter->m_aLinearPos.adjustX(nXDelta); + pGlyphIter->adjustLinearPosX(nXDelta); } } } @@ -856,7 +856,7 @@ void MultiSalLayout::ImplAdjustMultiLayout(vcl::text::ImplLayoutArgs& rArgs, bool bKeepNotDef = (nFBLevel >= nLevel); for(;;) { - nRunAdvance += pGlyphs[n]->m_nNewWidth; + nRunAdvance += pGlyphs[n]->newWidth(); // proceed to next glyph nStartOld[n] = nStartNew[n]; diff --git a/vcl/source/outdev/textline.cxx b/vcl/source/outdev/textline.cxx index 7c8af3db9220..4ea677b0bbfe 100644 --- a/vcl/source/outdev/textline.cxx +++ b/vcl/source/outdev/textline.cxx @@ -837,7 +837,7 @@ void OutputDevice::ImplDrawTextLines( SalLayout& rSalLayout, FontStrikeout eStri } // update the length of the textline - nWidth += pGlyph->m_nNewWidth; + nWidth += pGlyph->newWidth(); } else if( nWidth > 0 ) { diff --git a/vcl/win/gdi/DWriteTextRenderer.cxx b/vcl/win/gdi/DWriteTextRenderer.cxx index 1ec441b00592..835e09e7eed9 100644 --- a/vcl/win/gdi/DWriteTextRenderer.cxx +++ b/vcl/win/gdi/DWriteTextRenderer.cxx @@ -262,7 +262,7 @@ bool D2DWriteTextOutRenderer::performRender(GenericSalLayout const & rLayout, Sa while (rLayout.GetNextGlyph(&pGlyph, aPos, nStart)) { UINT16 glyphIndices[] = { pGlyph->glyphId() }; - FLOAT glyphAdvances[] = { static_cast<FLOAT>(pGlyph->m_nNewWidth) / fHScale }; + FLOAT glyphAdvances[] = { static_cast<FLOAT>(pGlyph->newWidth()) / fHScale }; DWRITE_GLYPH_OFFSET glyphOffsets[] = { { 0.0f, 0.0f }, }; D2D1_POINT_2F baseline = { static_cast<FLOAT>(aPos.getX() - bounds.Left()) / fHScale, static_cast<FLOAT>(aPos.getY() - bounds.Top()) }; |