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 5416a8e3d5373517aa90c3cf4c25d105a3768a59 Author: Caolán McNamara <caol...@redhat.com> AuthorDate: Tue Nov 29 10:18:38 2022 +0000 Commit: Xisco Fauli <xiscofa...@libreoffice.org> CommitDate: Mon Dec 5 09:58:09 2022 +0000 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> (cherry picked from commit e231cf313d8b3be672d32b9201b37fb20e646758) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143625 Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org> diff --git a/include/vcl/vcllayout.hxx b/include/vcl/vcllayout.hxx index 87d9345f4b9b..0fa25116ec85 100644 --- a/include/vcl/vcllayout.hxx +++ b/include/vcl/vcllayout.hxx @@ -79,7 +79,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) @@ -115,7 +114,6 @@ protected: int mnMinCharPos; int mnEndCharPos; - int mnUnitsPerPixel; Degree10 mnOrientation; mutable Point maDrawOffset; diff --git a/vcl/source/gdi/pdfwriter_impl.cxx b/vcl/source/gdi/pdfwriter_impl.cxx index 501fee55f933..3455c3a0d353 100644 --- a/vcl/source/gdi/pdfwriter_impl.cxx +++ b/vcl/source/gdi/pdfwriter_impl.cxx @@ -6495,7 +6495,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( PixelToLogic(Point(aStartPt.getX(), aStartPt.getY()) ), ImplDevicePixelToLogicWidth( nWidth ), eStrikeout, eUnderline, eOverline, bUnderlineAbove ); diff --git a/vcl/source/gdi/sallayout.cxx b/vcl/source/gdi/sallayout.cxx index 0e582015adc8..51e1d9ad5e20 100644 --- a/vcl/source/gdi/sallayout.cxx +++ b/vcl/source/gdi/sallayout.cxx @@ -133,7 +133,6 @@ sal_UCS4 GetLocalizedChar( sal_UCS4 nChar, LanguageType eLang ) SalLayout::SalLayout() : mnMinCharPos( -1 ), mnEndCharPos( -1 ), - mnUnitsPerPixel( 1 ), mnOrientation( 0 ), maDrawOffset( 0, 0 ), mbTextRenderModeForResolutionIndependentLayout(false) @@ -298,7 +297,6 @@ DeviceCoordinate GenericSalLayout::GetTextWidth() const void GenericSalLayout::Justify( DeviceCoordinate nNewWidth ) { - nNewWidth *= mnUnitsPerPixel; DeviceCoordinate nOldWidth = GetTextWidth(); if( !nOldWidth || nNewWidth==nOldWidth ) return; @@ -547,8 +545,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; @@ -616,7 +612,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() @@ -666,7 +661,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 @@ -709,18 +703,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; - } - } - // change the mpDXArray temporarily (just for the justification) aMultiArgs.mpDXArray = aJustificationArray.data(); } @@ -801,7 +783,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(); @@ -836,15 +817,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 ) @@ -967,19 +944,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 = static_cast<tools::Long>(nRunAdvance*fUnitMul + 0.5); } - // calculate new x position (in base level units) + // calculate new x position nXPos += nRunAdvance; // prepare for next fallback run @@ -1045,17 +1012,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; @@ -1090,9 +1049,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 ) @@ -1107,7 +1063,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; } } @@ -1127,15 +1082,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 d1d50f79572b..5d8595abe770 100644 --- a/vcl/source/outdev/text.cxx +++ b/vcl/source/outdev/text.cxx @@ -167,7 +167,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(); @@ -989,7 +989,6 @@ tools::Long OutputDevice::GetTextArray( const OUString& rStr, std::vector<sal_In } std::vector<DeviceCoordinate>* pDXPixelArray = xDXPixelArray.get(); DeviceCoordinate nWidth = pSalLayout->FillDXArray(pDXPixelArray); - int nWidthFactor = pSalLayout->GetUnitsPerPixel(); // convert virtual char widths to virtual absolute positions if( pDXPixelArray ) @@ -1010,17 +1009,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); @@ -1034,7 +1022,6 @@ tools::Long OutputDevice::GetTextArray( const OUString& rStr, std::vector<sal_In #else /* ! VCL_FLOAT_DEVICE_PIXEL */ tools::Long nWidth = pSalLayout->FillDXArray( pDXAry ); - int nWidthFactor = pSalLayout->GetUnitsPerPixel(); // convert virtual char widths to virtual absolute positions if( pDXAry ) @@ -1050,13 +1037,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 */ } @@ -1080,7 +1060,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(); @@ -1111,12 +1090,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, @@ -1467,7 +1440,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 ); } @@ -1509,14 +1482,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 ); @@ -1543,15 +1515,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 ); } @@ -2395,7 +2366,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; @@ -2411,21 +2381,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()); @@ -2492,20 +2447,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 b652ce34408c..bfe5120f9c15 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 ); } }