include/vcl/vcllayout.hxx | 2 - vcl/source/gdi/pdfwriter_impl.cxx | 2 - vcl/source/gdi/sallayout.cxx | 59 ++------------------------------ vcl/source/outdev/text.cxx | 70 ++++---------------------------------- vcl/source/outdev/textline.cxx | 4 +- 5 files changed, 16 insertions(+), 121 deletions(-)
New commits: commit e231cf313d8b3be672d32b9201b37fb20e646758 Author: Caolán McNamara <caol...@redhat.com> AuthorDate: Tue Nov 29 10:18:38 2022 +0000 Commit: Caolán McNamara <caol...@redhat.com> CommitDate: Tue Nov 29 12:37:39 2022 +0100 SalLayout::mnUnitsPerPixel is always 1 since commit 368de904974b18dc5a8d237e046c0ed005f7c85d Date: Thu Nov 24 09:21:56 2016 +0200 Kill PspFontLayout removed the last SetUnitsPerPixel Change-Id: I60db3d9eb4c42f3f0372b5f063a912b7addfde90 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143456 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caol...@redhat.com> diff --git a/include/vcl/vcllayout.hxx b/include/vcl/vcllayout.hxx index b76c789fb16b..4705a44d9b92 100644 --- a/include/vcl/vcllayout.hxx +++ b/include/vcl/vcllayout.hxx @@ -80,7 +80,6 @@ public: virtual void InitFont() const {} virtual void DrawText( SalGraphics& ) const = 0; - int GetUnitsPerPixel() const { return mnUnitsPerPixel; } Degree10 GetOrientation() const { return mnOrientation; } void SetTextRenderModeForResolutionIndependentLayout(bool bTextRenderModeForResolutionIndependentLayout) @@ -121,7 +120,6 @@ protected: int mnEndCharPos; LanguageTag maLanguageTag; - int mnUnitsPerPixel; Degree10 mnOrientation; mutable Point maDrawOffset; diff --git a/vcl/source/gdi/pdfwriter_impl.cxx b/vcl/source/gdi/pdfwriter_impl.cxx index 34785e2da3f7..18f9032529c9 100644 --- a/vcl/source/gdi/pdfwriter_impl.cxx +++ b/vcl/source/gdi/pdfwriter_impl.cxx @@ -6834,7 +6834,7 @@ void PDFWriterImpl::drawLayout( SalLayout& rLayout, const OUString& rText, bool else { DevicePoint aStartPt = rLayout.GetDrawPosition(); - int nWidth = rLayout.GetTextWidth() / rLayout.GetUnitsPerPixel(); + int nWidth = rLayout.GetTextWidth(); drawTextLine( SubPixelToLogic(aStartPt), ImplDevicePixelToLogicWidth( nWidth ), eStrikeout, eUnderline, eOverline, bUnderlineAbove ); diff --git a/vcl/source/gdi/sallayout.cxx b/vcl/source/gdi/sallayout.cxx index cd27a2cb8a0c..521cbb3d6007 100644 --- a/vcl/source/gdi/sallayout.cxx +++ b/vcl/source/gdi/sallayout.cxx @@ -125,7 +125,6 @@ SalLayout::SalLayout() : mnMinCharPos( -1 ), mnEndCharPos( -1 ), maLanguageTag( LANGUAGE_DONTKNOW ), - mnUnitsPerPixel( 1 ), mnOrientation( 0 ), maDrawOffset( 0, 0 ), mbTextRenderModeForResolutionIndependentLayout(false) @@ -288,7 +287,6 @@ DeviceCoordinate GenericSalLayout::GetTextWidth() const void GenericSalLayout::Justify( DeviceCoordinate nNewWidth ) { - nNewWidth *= mnUnitsPerPixel; DeviceCoordinate nOldWidth = GetTextWidth(); if( !nOldWidth || nNewWidth==nOldWidth ) return; @@ -536,8 +534,6 @@ bool GenericSalLayout::GetNextGlyph(const GlyphItem** pGlyph, // calculate absolute position in pixel units DevicePoint aRelativePos = pGlyphIter->linearPos(); - aRelativePos.setX( aRelativePos.getX() / mnUnitsPerPixel ); - aRelativePos.setY( aRelativePos.getY() / mnUnitsPerPixel ); rPos = GetDrawPosition( aRelativePos ); return true; @@ -605,7 +601,6 @@ MultiSalLayout::MultiSalLayout( std::unique_ptr<SalLayout> pBaseLayout ) assert(dynamic_cast<GenericSalLayout*>(pBaseLayout.get())); mpLayouts[ 0 ].reset(static_cast<GenericSalLayout*>(pBaseLayout.release())); - mnUnitsPerPixel = mpLayouts[ 0 ]->GetUnitsPerPixel(); } std::unique_ptr<SalLayout> MultiSalLayout::ReleaseBaseLayout() @@ -656,7 +651,6 @@ void MultiSalLayout::AdjustLayout( vcl::text::ImplLayoutArgs& rArgs ) // for stretched text in a MultiSalLayout the target width needs to be // distributed by individually adjusting its virtual character widths DeviceCoordinate nTargetWidth = aMultiArgs.mnLayoutWidth; - nTargetWidth *= mnUnitsPerPixel; // convert target width to base font units aMultiArgs.mnLayoutWidth = 0; // we need to get the original unmodified layouts ready @@ -699,18 +693,6 @@ void MultiSalLayout::AdjustLayout( vcl::text::ImplLayoutArgs& rArgs ) if( nWidthSum != nTargetWidth ) aJustificationArray[ nCharCount-1 ] = nTargetWidth; - // the justification array is still in base level units - // => convert it to pixel units - if( mnUnitsPerPixel > 1 ) - { - for( int i = 0; i < nCharCount; ++i ) - { - DeviceCoordinate nVal = aJustificationArray[ i ]; - nVal += (mnUnitsPerPixel + 1) / 2; - aJustificationArray[ i ] = nVal / mnUnitsPerPixel; - } - } - aNaturalJustificationArray.reserve(aJustificationArray.size()); for (DeviceCoordinate a : aJustificationArray) aNaturalJustificationArray.push_back(a); @@ -790,7 +772,6 @@ void MultiSalLayout::ImplAdjustMultiLayout(vcl::text::ImplLayoutArgs& rArgs, // prepare merge the fallback levels tools::Long nXPos = 0; - double fUnitMul = 1.0; for( n = 0; n < nLevel; ++n ) maFallbackRuns[n].ResetPos(); @@ -825,15 +806,11 @@ void MultiSalLayout::ImplAdjustMultiLayout(vcl::text::ImplLayoutArgs& rArgs, if( n < nLevel ) { // use base(n==0) or fallback(n>=1) level - fUnitMul = mnUnitsPerPixel; - fUnitMul /= mpLayouts[n]->GetUnitsPerPixel(); - tools::Long nNewPos = static_cast<tools::Long>(nXPos/fUnitMul + 0.5); - mpLayouts[n]->MoveGlyph( nStartOld[n], nNewPos ); + mpLayouts[n]->MoveGlyph( nStartOld[n], nXPos ); } else { n = 0; // keep NotDef in base level - fUnitMul = 1.0; } if( n > 0 ) @@ -956,19 +933,9 @@ void MultiSalLayout::ImplAdjustMultiLayout(vcl::text::ImplLayoutArgs& rArgs, } nLastRunEndChar = nRunVisibleEndChar; nRunVisibleEndChar = pGlyphs[nFirstValid]->charPos(); - // the requested width is still in pixel units - // => convert it to base level font units - nRunAdvance *= mnUnitsPerPixel; - } - else - { - // the measured width is still in fallback font units - // => convert it to base level font units - if( n > 0 ) // optimization: because (fUnitMul==1.0) for (n==0) - nRunAdvance = nRunAdvance * fUnitMul; } - // calculate new x position (in base level units) + // calculate new x position nXPos += nRunAdvance; // prepare for next fallback run @@ -1034,17 +1001,9 @@ sal_Int32 MultiSalLayout::GetTextBreak( DeviceCoordinate nMaxWidth, DeviceCoordi { SalLayout& rLayout = *mpLayouts[ n ]; rLayout.FillDXArray( &aFallbackCharWidths, {} ); - double fUnitMul = mnUnitsPerPixel; - fUnitMul /= rLayout.GetUnitsPerPixel(); for( int i = 0; i < nCharCount; ++i ) - { if( aCharWidths[ i ] == 0 ) - { - DeviceCoordinate w = aFallbackCharWidths[i]; - w = static_cast<DeviceCoordinate>(w * fUnitMul + 0.5); - aCharWidths[ i ] = w; - } - } + aCharWidths[i] = aFallbackCharWidths[i]; } DeviceCoordinate nWidth = 0; @@ -1079,9 +1038,6 @@ DeviceCoordinate MultiSalLayout::FillDXArray( std::vector<DeviceCoordinate>* pCh if( !nTextWidth ) continue; // merge results from current level - double fUnitMul = mnUnitsPerPixel; - fUnitMul /= mpLayouts[n]->GetUnitsPerPixel(); - nTextWidth = static_cast<DeviceCoordinate>(nTextWidth * fUnitMul + 0.5); if( nMaxWidth < nTextWidth ) nMaxWidth = nTextWidth; if( !pCharWidths ) @@ -1096,7 +1052,6 @@ DeviceCoordinate MultiSalLayout::FillDXArray( std::vector<DeviceCoordinate>* pCh DeviceCoordinate nCharWidth = aTempWidths[i]; if( !nCharWidth ) continue; - nCharWidth = static_cast<DeviceCoordinate>(nCharWidth * fUnitMul + 0.5); (*pCharWidths)[i] = nCharWidth; } } @@ -1116,15 +1071,9 @@ void MultiSalLayout::GetCaretPositions( int nMaxIndex, sal_Int32* pCaretXArray ) for( int n = 1; n < mnLevel; ++n ) { mpLayouts[ n ]->GetCaretPositions( nMaxIndex, pTempPos.get() ); - double fUnitMul = mnUnitsPerPixel; - fUnitMul /= mpLayouts[n]->GetUnitsPerPixel(); for( int i = 0; i < nMaxIndex; ++i ) if( pTempPos[i] >= 0 ) - { - sal_Int32 w = pTempPos[i]; - w = static_cast<sal_Int32>(w*fUnitMul + 0.5); - pCaretXArray[i] = w; - } + pCaretXArray[i] = pTempPos[i]; } } diff --git a/vcl/source/outdev/text.cxx b/vcl/source/outdev/text.cxx index 7b9dde2a94a8..c3cdc2d6b8fd 100644 --- a/vcl/source/outdev/text.cxx +++ b/vcl/source/outdev/text.cxx @@ -169,7 +169,7 @@ void OutputDevice::ImplDrawTextRect( tools::Long nBaseX, tools::Long nBaseY, void OutputDevice::ImplDrawTextBackground( const SalLayout& rSalLayout ) { - const tools::Long nWidth = rSalLayout.GetTextWidth() / rSalLayout.GetUnitsPerPixel(); + const tools::Long nWidth = rSalLayout.GetTextWidth(); const DevicePoint aBase = rSalLayout.DrawBase(); const tools::Long nX = aBase.getX(); const tools::Long nY = aBase.getY(); @@ -995,7 +995,6 @@ tools::Long OutputDevice::GetTextArray( const OUString& rStr, std::vector<sal_In } std::vector<DeviceCoordinate>* pDXPixelArray = xDXPixelArray.get(); DeviceCoordinate nWidth = pSalLayout->FillDXArray(pDXPixelArray, bCaret ? rStr : OUString()); - int nWidthFactor = pSalLayout->GetUnitsPerPixel(); // convert virtual char widths to virtual absolute positions if( pDXPixelArray ) @@ -1016,17 +1015,6 @@ tools::Long OutputDevice::GetTextArray( const OUString& rStr, std::vector<sal_In } nWidth = ImplDevicePixelToLogicWidth( nWidth ); } - if( nWidthFactor > 1 ) - { - if( pDXPixelArray ) - { - for( int i = 0; i < nLen; ++i ) - { - (*pDXPixelArray)[i] /= nWidthFactor; - } - } - nWidth /= nWidthFactor; - } if(pDXAry) { pDXAry->resize(nLen); @@ -1040,7 +1028,6 @@ tools::Long OutputDevice::GetTextArray( const OUString& rStr, std::vector<sal_In #else /* ! VCL_FLOAT_DEVICE_PIXEL */ tools::Long nWidth = pSalLayout->FillDXArray( pDXAry, bCaret ? rStr : OUString() ); - int nWidthFactor = pSalLayout->GetUnitsPerPixel(); // convert virtual char widths to virtual absolute positions if( pDXAry ) @@ -1056,13 +1043,6 @@ tools::Long OutputDevice::GetTextArray( const OUString& rStr, std::vector<sal_In nWidth = ImplDevicePixelToLogicWidth( nWidth ); } - if( nWidthFactor > 1 ) - { - if( pDXAry ) - for( int i = 0; i < nLen; ++i ) - (*pDXAry)[i] /= nWidthFactor; - nWidth /= nWidthFactor; - } return nWidth; #endif /* VCL_FLOAT_DEVICE_PIXEL */ } @@ -1086,7 +1066,6 @@ void OutputDevice::GetCaretPositions( const OUString& rStr, sal_Int32* pCaretXAr return; } - int nWidthFactor = pSalLayout->GetUnitsPerPixel(); pSalLayout->GetCaretPositions( 2*nLen, pCaretXArray ); tools::Long nWidth = pSalLayout->GetTextWidth(); @@ -1117,12 +1096,6 @@ void OutputDevice::GetCaretPositions( const OUString& rStr, sal_Int32* pCaretXAr for( i = 0; i < 2*nLen; ++i ) pCaretXArray[i] = ImplDevicePixelToLogicWidth( pCaretXArray[i] ); } - - if( nWidthFactor != 1 ) - { - for( i = 0; i < 2*nLen; ++i ) - pCaretXArray[i] /= nWidthFactor; - } } void OutputDevice::DrawStretchText( const Point& rStartPt, sal_uLong nWidth, @@ -1449,7 +1422,7 @@ std::unique_ptr<SalLayout> OutputDevice::ImplLayout(const OUString& rOrigStr, else if( nPixelWidth ) nRTLOffset = nPixelWidth; else - nRTLOffset = pSalLayout->GetTextWidth() / pSalLayout->GetUnitsPerPixel(); + nRTLOffset = pSalLayout->GetTextWidth(); pSalLayout->DrawOffset().setX( 1 - nRTLOffset ); } @@ -1491,14 +1464,13 @@ sal_Int32 OutputDevice::GetTextBreak( const OUString& rStr, tools::Long nTextWid // NOTE: be very careful to avoid rounding errors for nCharExtra case // problem with rounding errors especially for small nCharExtras // TODO: remove when layout units have subpixel granularity - tools::Long nWidthFactor = pSalLayout->GetUnitsPerPixel(); - tools::Long nSubPixelFactor = (nWidthFactor < 64 ) ? 64 : 1; - nTextWidth *= nWidthFactor * nSubPixelFactor; + tools::Long nSubPixelFactor = 64; + nTextWidth *= nSubPixelFactor; DeviceCoordinate nTextPixelWidth = LogicWidthToDeviceCoordinate( nTextWidth ); DeviceCoordinate nExtraPixelWidth = 0; if( nCharExtra != 0 ) { - nCharExtra *= nWidthFactor * nSubPixelFactor; + nCharExtra *= nSubPixelFactor; nExtraPixelWidth = LogicWidthToDeviceCoordinate( nCharExtra ); } nRetVal = pSalLayout->GetTextBreak( nTextPixelWidth, nExtraPixelWidth, nSubPixelFactor ); @@ -1525,15 +1497,14 @@ sal_Int32 OutputDevice::GetTextBreak( const OUString& rStr, tools::Long nTextWid // NOTE: be very careful to avoid rounding errors for nCharExtra case // problem with rounding errors especially for small nCharExtras // TODO: remove when layout units have subpixel granularity - tools::Long nWidthFactor = pSalLayout->GetUnitsPerPixel(); - tools::Long nSubPixelFactor = (nWidthFactor < 64 ) ? 64 : 1; + tools::Long nSubPixelFactor = 64; - nTextWidth *= nWidthFactor * nSubPixelFactor; + nTextWidth *= nSubPixelFactor; DeviceCoordinate nTextPixelWidth = LogicWidthToDeviceCoordinate( nTextWidth ); DeviceCoordinate nExtraPixelWidth = 0; if( nCharExtra != 0 ) { - nCharExtra *= nWidthFactor * nSubPixelFactor; + nCharExtra *= nSubPixelFactor; nExtraPixelWidth = LogicWidthToDeviceCoordinate( nCharExtra ); } @@ -2358,7 +2329,6 @@ bool OutputDevice::GetTextBoundRect( tools::Rectangle& rRect, if( pSalLayout ) { nXOffset = pSalLayout->GetTextWidth(); - nXOffset /= pSalLayout->GetUnitsPerPixel(); // TODO: fix offset calculation for Bidi case if( nBase < nIndex) nXOffset = -nXOffset; @@ -2374,21 +2344,6 @@ bool OutputDevice::GetTextBoundRect( tools::Rectangle& rRect, if( bRet ) { - int nWidthFactor = pSalLayout->GetUnitsPerPixel(); - - if( nWidthFactor > 1 ) - { - double fFactor = 1.0 / nWidthFactor; - aPixelRect.SetLeft( - static_cast< tools::Long >(aPixelRect.Left() * fFactor) ); - aPixelRect.SetRight( - static_cast< tools::Long >(aPixelRect.Right() * fFactor) ); - aPixelRect.SetTop( - static_cast< tools::Long >(aPixelRect.Top() * fFactor) ); - aPixelRect.SetBottom( - static_cast< tools::Long >(aPixelRect.Bottom() * fFactor) ); - } - Point aRotatedOfs( mnTextOffX, mnTextOffY ); DevicePoint aPos = pSalLayout->GetDrawPosition(DevicePoint(nXOffset, 0)); aRotatedOfs -= Point(aPos.getX(), aPos.getY()); @@ -2457,20 +2412,13 @@ bool OutputDevice::GetTextOutlines( basegfx::B2DPolyPolygonVector& rVector, // transform polygon to pixel units basegfx::B2DHomMatrix aMatrix; - int nWidthFactor = pSalLayout->GetUnitsPerPixel(); if( nXOffset | mnTextOffX | mnTextOffY ) { - DevicePoint aRotatedOfs( mnTextOffX*nWidthFactor, mnTextOffY*nWidthFactor ); + DevicePoint aRotatedOfs(mnTextOffX, mnTextOffY); aRotatedOfs -= pSalLayout->GetDrawPosition(DevicePoint(nXOffset, 0)); aMatrix.translate( aRotatedOfs.getX(), aRotatedOfs.getY() ); } - if( nWidthFactor > 1 ) - { - double fFactor = 1.0 / nWidthFactor; - aMatrix.scale( fFactor, fFactor ); - } - if( !aMatrix.isIdentity() ) { for (auto & elem : rVector) diff --git a/vcl/source/outdev/textline.cxx b/vcl/source/outdev/textline.cxx index a4591707b971..4feb65fda1a2 100644 --- a/vcl/source/outdev/textline.cxx +++ b/vcl/source/outdev/textline.cxx @@ -672,7 +672,7 @@ void OutputDevice::ImplDrawStrikeoutChar( tools::Long nBaseX, tools::Long nBaseY std::unique_ptr<SalLayout> pLayout = ImplLayout( aStrikeoutTest, 0, nTestStrLen ); if( pLayout ) { - nStrikeoutWidth = pLayout->GetTextWidth() / (nTestStrLen * pLayout->GetUnitsPerPixel()); + nStrikeoutWidth = pLayout->GetTextWidth() / nTestStrLen; } if( nStrikeoutWidth <= 0 ) // sanity check return; @@ -861,7 +861,7 @@ void OutputDevice::ImplDrawTextLines( SalLayout& rSalLayout, FontStrikeout eStri { DevicePoint aStartPt = rSalLayout.GetDrawPosition(); ImplDrawTextLine( aStartPt.getX(), aStartPt.getY(), 0, - rSalLayout.GetTextWidth() / rSalLayout.GetUnitsPerPixel(), + rSalLayout.GetTextWidth(), eStrikeout, eUnderline, eOverline, bUnderlineAbove ); } }