diff options
author | Caolán McNamara <caolanm@redhat.com> | 2015-10-07 10:09:56 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2015-10-07 13:24:01 +0000 |
commit | ae625675a88db46d378cc29f6513bbb4fa6e62a7 (patch) | |
tree | 0c91981c8e7726a79b3f911b86e30ca7475e1974 /vcl | |
parent | 9bb6863fcf0784c70a95510b488f0162fe6deb37 (diff) |
afl-eventtesting: creating OUString from super long sal_Unicode* is slow
the mpStr and mnLength arguments are always created from an OUString
and the OUString aRun(rArgs.mpStr); creates a duplicate of the original
string. Its way faster to pass the original OUString around instead.
Change-Id: I3de0cc31654eb215362548b6aee435f9c0c3c9db
Reviewed-on: https://gerrit.libreoffice.org/19221
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/generic/glyphs/gcach_layout.cxx | 18 | ||||
-rw-r--r-- | vcl/generic/glyphs/graphite_serverfont.cxx | 1 | ||||
-rw-r--r-- | vcl/generic/print/genpspgraphics.cxx | 10 | ||||
-rw-r--r-- | vcl/inc/graphite_serverfont.hxx | 2 | ||||
-rw-r--r-- | vcl/inc/sallayout.hxx | 7 | ||||
-rw-r--r-- | vcl/quartz/ctlayout.cxx | 9 | ||||
-rw-r--r-- | vcl/source/gdi/sallayout.cxx | 57 | ||||
-rw-r--r-- | vcl/source/glyphs/graphite_layout.cxx | 18 | ||||
-rw-r--r-- | vcl/source/outdev/font.cxx | 4 | ||||
-rw-r--r-- | vcl/source/outdev/text.cxx | 2 | ||||
-rw-r--r-- | vcl/win/source/gdi/winlayout.cxx | 23 |
11 files changed, 80 insertions, 71 deletions
diff --git a/vcl/generic/glyphs/gcach_layout.cxx b/vcl/generic/glyphs/gcach_layout.cxx index 4a8c14445718..3d841449c434 100644 --- a/vcl/generic/glyphs/gcach_layout.cxx +++ b/vcl/generic/glyphs/gcach_layout.cxx @@ -58,7 +58,7 @@ void ServerFontLayout::AdjustLayout( ImplLayoutArgs& rArgs ) if( (rArgs.mnFlags & SalLayoutFlags::KerningAsian) && !(rArgs.mnFlags & SalLayoutFlags::Vertical) ) if( (rArgs.mpDXArray != NULL) || (rArgs.mnLayoutWidth != 0) ) - ApplyAsianKerning( rArgs.mpStr, rArgs.mnLength ); + ApplyAsianKerning(rArgs.mrStr); // insert kashidas where requested by the formatting array if( (rArgs.mnFlags & SalLayoutFlags::KashidaJustification) && rArgs.mpDXArray ) @@ -89,13 +89,12 @@ void ServerFontLayout::SetNeedFallback(ImplLayoutArgs& rArgs, sal_Int32 nCharPos //if position nCharPos is missing in the font, grab the entire grapheme and //mark all glyphs as missing so the whole thing is rendered with the same //font - OUString aRun(rArgs.mpStr); sal_Int32 nDone; sal_Int32 nGraphemeStartPos = - mxBreak->previousCharacters(aRun, nCharPos+1, aLocale, + mxBreak->previousCharacters(rArgs.mrStr, nCharPos+1, aLocale, i18n::CharacterIteratorMode::SKIPCELL, 1, nDone); sal_Int32 nGraphemeEndPos = - mxBreak->nextCharacters(aRun, nCharPos, aLocale, + mxBreak->nextCharacters(rArgs.mrStr, nCharPos, aLocale, i18n::CharacterIteratorMode::SKIPCELL, 1, nDone); rArgs.NeedFallback(nGraphemeStartPos, nGraphemeEndPos, bRightToLeft); @@ -409,6 +408,9 @@ bool HbLayoutEngine::Layout(ServerFontLayout& rLayout, ImplLayoutArgs& rArgs) rLayout.Reserve(nGlyphCapacity); + const int nLength = rArgs.mrStr.getLength(); + const sal_Unicode *pStr = rArgs.mrStr.getStr(); + std::unique_ptr<vcl::TextLayoutCache> pNewScriptRun; vcl::TextLayoutCache const* pTextLayout; if (rArgs.m_pTextLayoutCache) @@ -417,7 +419,7 @@ bool HbLayoutEngine::Layout(ServerFontLayout& rLayout, ImplLayoutArgs& rArgs) } else { - pNewScriptRun.reset(new vcl::TextLayoutCache(rArgs.mpStr, rArgs.mnEndCharPos)); + pNewScriptRun.reset(new vcl::TextLayoutCache(pStr, rArgs.mnEndCharPos)); pTextLayout = pNewScriptRun.get(); } @@ -472,7 +474,7 @@ bool HbLayoutEngine::Layout(ServerFontLayout& rLayout, ImplLayoutArgs& rArgs) int nHbFlags = HB_BUFFER_FLAGS_DEFAULT; if (nMinRunPos == 0) nHbFlags |= HB_BUFFER_FLAG_BOT; /* Beginning-of-text */ - if (nEndRunPos == rArgs.mnLength) + if (nEndRunPos == nLength) nHbFlags |= HB_BUFFER_FLAG_EOT; /* End-of-text */ hb_buffer_t *pHbBuffer = hb_buffer_create(); @@ -481,7 +483,7 @@ bool HbLayoutEngine::Layout(ServerFontLayout& rLayout, ImplLayoutArgs& rArgs) hb_buffer_set_script(pHbBuffer, maHbScript); hb_buffer_set_language(pHbBuffer, hb_language_from_string(sLanguage.getStr(), -1)); hb_buffer_set_flags(pHbBuffer, (hb_buffer_flags_t) nHbFlags); - hb_buffer_add_utf16(pHbBuffer, rArgs.mpStr, rArgs.mnLength, nMinRunPos, nRunLen); + hb_buffer_add_utf16(pHbBuffer, pStr, nLength, nMinRunPos, nRunLen); hb_shape(pHbFont, pHbBuffer, NULL, 0); int nRunGlyphCount = hb_buffer_get_length(pHbBuffer); @@ -505,7 +507,7 @@ bool HbLayoutEngine::Layout(ServerFontLayout& rLayout, ImplLayoutArgs& rArgs) // FixupGlyphIndex() is doing, minus the GSUB part. if (nCharPos >= 0) { - sal_UCS4 aChar = rArgs.mpStr[nCharPos]; + sal_UCS4 aChar = rArgs.mrStr[nCharPos]; nGlyphIndex = rFont.FixupGlyphIndex(nGlyphIndex, aChar); } diff --git a/vcl/generic/glyphs/graphite_serverfont.cxx b/vcl/generic/glyphs/graphite_serverfont.cxx index 84cdcf8ce044..d92195e2f194 100644 --- a/vcl/generic/glyphs/graphite_serverfont.cxx +++ b/vcl/generic/glyphs/graphite_serverfont.cxx @@ -46,7 +46,6 @@ GraphiteServerFontLayout::GraphiteServerFontLayout(ServerFont& rServerFont) thro : ServerFontLayout(rServerFont), maImpl(rServerFont.GetGraphiteFace()->face(), rServerFont) , mpFeatures(NULL) - , mpStr(NULL) { gr_font * pFont = rServerFont.GetGraphiteFace()->font(rServerFont.GetFontSelData().mnHeight, rServerFont.NeedsArtificialBold(), rServerFont.NeedsArtificialItalic()); if (!pFont) diff --git a/vcl/generic/print/genpspgraphics.cxx b/vcl/generic/print/genpspgraphics.cxx index dca1fb3dba5a..86f9ccb70fca 100644 --- a/vcl/generic/print/genpspgraphics.cxx +++ b/vcl/generic/print/genpspgraphics.cxx @@ -602,8 +602,9 @@ bool PspFontLayout::LayoutText( ImplLayoutArgs& rArgs ) Point aNewPos( 0, 0 ); GlyphItem aPrevItem; rtl_TextEncoding aFontEnc = mrPrinterGfx.GetFontMgr().getFontEncoding( mnFontID ); - - Reserve(rArgs.mnLength); + const int nLength = rArgs.mrStr.getLength(); + const sal_Unicode *pStr = rArgs.mrStr.getStr(); + Reserve(nLength); for(;;) { @@ -611,7 +612,7 @@ bool PspFontLayout::LayoutText( ImplLayoutArgs& rArgs ) if( !rArgs.GetNextPos( &nCharPos, &bRightToLeft ) ) break; - sal_Unicode cChar = rArgs.mpStr[ nCharPos ]; + sal_Unicode cChar = pStr[ nCharPos ]; if( bRightToLeft ) cChar = GetMirroredChar( cChar ); // symbol font aliasing: 0x0020-0x00ff -> 0xf020 -> 0xf0ff @@ -680,7 +681,8 @@ PspServerFontLayout::PspServerFontLayout( ::psp::PrinterGfx& rGfx, ServerFont& r mbVertical = mrPrinterGfx.GetFontVertical(); mbArtItalic = mrPrinterGfx.GetArtificialItalic(); mbArtBold = mrPrinterGfx.GetArtificialBold(); - maText = OUString( rArgs.mpStr + rArgs.mnMinCharPos, rArgs.mnEndCharPos - rArgs.mnMinCharPos+1 ); + const sal_Unicode *pStr = rArgs.mrStr.getStr(); + maText = OUString( pStr + rArgs.mnMinCharPos, rArgs.mnEndCharPos - rArgs.mnMinCharPos+1 ); mnMinCharPos = rArgs.mnMinCharPos; } diff --git a/vcl/inc/graphite_serverfont.hxx b/vcl/inc/graphite_serverfont.hxx index ec002a55b771..63dc900d1024 100644 --- a/vcl/inc/graphite_serverfont.hxx +++ b/vcl/inc/graphite_serverfont.hxx @@ -53,13 +53,11 @@ private: // mutable so that the DrawOffset/DrawBase can be set mutable GraphiteLayoutImpl maImpl; grutils::GrFeatureParser * mpFeatures; - const sal_Unicode * mpStr; public: GraphiteServerFontLayout(ServerFont& pServerFont) throw(); virtual bool LayoutText( ImplLayoutArgs& rArgs) SAL_OVERRIDE { - mpStr = rArgs.mpStr; SalLayout::AdjustLayout(rArgs); return maImpl.LayoutText(rArgs); }; // first step of layout diff --git a/vcl/inc/sallayout.hxx b/vcl/inc/sallayout.hxx index 9a33c12430b2..46a3a9e521ad 100644 --- a/vcl/inc/sallayout.hxx +++ b/vcl/inc/sallayout.hxx @@ -75,10 +75,9 @@ public: // string related inputs LanguageTag maLanguageTag; SalLayoutFlags mnFlags; - int mnLength; + const OUString& mrStr; int mnMinCharPos; int mnEndCharPos; - const sal_Unicode* mpStr; // performance hack vcl::TextLayoutCache const* m_pTextLayoutCache; @@ -93,7 +92,7 @@ public: ImplLayoutRuns maFallbackRuns; public: - ImplLayoutArgs( const sal_Unicode* pStr, int nLength, + ImplLayoutArgs( const OUString& rStr, int nMinCharPos, int nEndCharPos, SalLayoutFlags nFlags, const LanguageTag& rLanguageTag, vcl::TextLayoutCache const* pLayoutCache); @@ -339,7 +338,7 @@ public: void ApplyDXArray( ImplLayoutArgs& ); void Justify( DeviceCoordinate nNewWidth ); void KashidaJustify( long nIndex, int nWidth ); - void ApplyAsianKerning( const sal_Unicode*, int nLength ); + void ApplyAsianKerning(const OUString& rStr); void SortGlyphItems(); // used by upper layers diff --git a/vcl/quartz/ctlayout.cxx b/vcl/quartz/ctlayout.cxx index f1acd1727191..8e8f27572d3c 100644 --- a/vcl/quartz/ctlayout.cxx +++ b/vcl/quartz/ctlayout.cxx @@ -131,9 +131,11 @@ bool CTLayout::LayoutText( ImplLayoutArgs& rArgs ) if( mnCharCount <= 0 ) return false; + const sal_Unicode *pStr = rArgs.mrStr.getStr(); + // create the CoreText line layout CFStringRef aCFText = CFStringCreateWithCharactersNoCopy( NULL, - rArgs.mpStr + mnMinCharPos, + pStr + mnMinCharPos, mnCharCount, kCFAllocatorNull ); // CFAttributedStringCreate copies the attribues parameter @@ -146,7 +148,7 @@ bool CTLayout::LayoutText( ImplLayoutArgs& rArgs ) // reverse search for first 'non-space'... for( int i = mnEndCharPos - 1; i >= mnMinCharPos; i--) { - sal_Unicode nChar = rArgs.mpStr[i]; + sal_Unicode nChar = pStr[i]; if ((nChar <= 0x0020) || // blank (nChar == 0x00A0) || // non breaking space (nChar >= 0x2000 && nChar <= 0x200F) || // whitespace @@ -209,8 +211,9 @@ void CTLayout::AdjustLayout( ImplLayoutArgs& rArgs ) // recreate the CoreText line layout without trailing spaces SAL_INFO( "vcl.ct", "CFRelease(" << mpCTLine << ")" ); CFRelease( mpCTLine ); + const sal_Unicode *pStr = rArgs.mrStr.getStr(); CFStringRef aCFText = CFStringCreateWithCharactersNoCopy( NULL, - rArgs.mpStr + mnMinCharPos, + pStr + mnMinCharPos, mnCharCount - mnTrailingSpaceCount, kCFAllocatorNull ); CFAttributedStringRef pAttrStr = CFAttributedStringCreate( NULL, diff --git a/vcl/source/gdi/sallayout.cxx b/vcl/source/gdi/sallayout.cxx index eefcd57e23af..6becfe772b6c 100644 --- a/vcl/source/gdi/sallayout.cxx +++ b/vcl/source/gdi/sallayout.cxx @@ -102,25 +102,27 @@ std::ostream &operator <<(std::ostream& s, ImplLayoutArgs &rArgs) s << "}"; } - s << ",Length=" << rArgs.mnLength; + const int nLength = rArgs.mrStr.getLength(); + + s << ",Length=" << nLength; s << ",MinCharPos=" << rArgs.mnMinCharPos; s << ",EndCharPos=" << rArgs.mnEndCharPos; s << ",Str=\""; - int lim = rArgs.mnLength; + int lim = nLength; if (lim > 10) lim = 7; for (int i = 0; i < lim; i++) { - if (rArgs.mpStr[i] == '\n') + if (rArgs.mrStr[i] == '\n') s << "\\n"; - else if (rArgs.mpStr[i] < ' ' || (rArgs.mpStr[i] >= 0x7F && rArgs.mpStr[i] <= 0xFF)) - s << "\\0x" << std::hex << std::setw(2) << std::setfill('0') << (int) rArgs.mpStr[i] << std::setfill(' ') << std::setw(1) << std::dec; - else if (rArgs.mpStr[i] < 0x7F) - s << (char) rArgs.mpStr[i]; + else if (rArgs.mrStr[i] < ' ' || (rArgs.mrStr[i] >= 0x7F && rArgs.mrStr[i] <= 0xFF)) + s << "\\0x" << std::hex << std::setw(2) << std::setfill('0') << (int) rArgs.mrStr[i] << std::setfill(' ') << std::setw(1) << std::dec; + else if (rArgs.mrStr[i] < 0x7F) + s << (char) rArgs.mrStr[i]; else - s << "\\u" << std::hex << std::setw(4) << std::setfill('0') << (int) rArgs.mpStr[i] << std::setfill(' ') << std::setw(1) << std::dec; + s << "\\u" << std::hex << std::setw(4) << std::setfill('0') << (int) rArgs.mrStr[i] << std::setfill(' ') << std::setw(1) << std::dec; } - if (rArgs.mnLength > lim) + if (nLength > lim) s << "..."; s << "\""; @@ -452,16 +454,15 @@ bool ImplLayoutRuns::GetRun( int* nMinRunPos, int* nEndRunPos, bool* bRightToLef return true; } -ImplLayoutArgs::ImplLayoutArgs( const sal_Unicode* pStr, int nLen, +ImplLayoutArgs::ImplLayoutArgs(const OUString& rStr, int nMinCharPos, int nEndCharPos, SalLayoutFlags nFlags, const LanguageTag& rLanguageTag, vcl::TextLayoutCache const*const pLayoutCache) : maLanguageTag( rLanguageTag ), mnFlags( nFlags ), - mnLength( nLen ), + mrStr( rStr ), mnMinCharPos( nMinCharPos ), mnEndCharPos( nEndCharPos ), - mpStr( pStr ), m_pTextLayoutCache(pLayoutCache), mpDXArray( NULL ), mnLayoutWidth( 0 ), @@ -488,14 +489,15 @@ ImplLayoutArgs::ImplLayoutArgs( const sal_Unicode* pStr, int nLen, // prepare substring for BiDi analysis // TODO: reuse allocated pParaBidi UErrorCode rcI18n = U_ZERO_ERROR; - UBiDi* pParaBidi = ubidi_openSized( mnLength, 0, &rcI18n ); + const int nLength = mrStr.getLength(); + UBiDi* pParaBidi = ubidi_openSized(nLength, 0, &rcI18n); if( !pParaBidi ) return; - ubidi_setPara( pParaBidi, reinterpret_cast<const UChar *>(mpStr), mnLength, nLevel, NULL, &rcI18n ); // UChar != sal_Unicode in MinGW + ubidi_setPara(pParaBidi, reinterpret_cast<const UChar *>(mrStr.getStr()), nLength, nLevel, NULL, &rcI18n); // UChar != sal_Unicode in MinGW UBiDi* pLineBidi = pParaBidi; int nSubLength = mnEndCharPos - mnMinCharPos; - if( nSubLength != mnLength ) + if (nSubLength != nLength) { pLineBidi = ubidi_openSized( nSubLength, 0, &rcI18n ); ubidi_setLine( pParaBidi, mnMinCharPos, mnEndCharPos, pLineBidi, &rcI18n ); @@ -506,10 +508,10 @@ ImplLayoutArgs::ImplLayoutArgs( const sal_Unicode* pStr, int nLen, //maRuns.resize( 2 * nRunCount ); for( int i = 0; i < nRunCount; ++i ) { - int32_t nMinPos, nLength; - const UBiDiDirection nDir = ubidi_getVisualRun( pLineBidi, i, &nMinPos, &nLength ); + int32_t nMinPos, nRunLength; + const UBiDiDirection nDir = ubidi_getVisualRun( pLineBidi, i, &nMinPos, &nRunLength ); const int nPos0 = nMinPos + mnMinCharPos; - const int nPos1 = nPos0 + nLength; + const int nPos1 = nPos0 + nRunLength; const bool bRTL = (nDir == UBIDI_RTL); AddRun( nPos0, nPos1, bRTL ); @@ -534,7 +536,7 @@ void ImplLayoutArgs::AddRun( int nCharPos0, int nCharPos1, bool bRTL ) if( !bRTL ) { for( int i = nCharPos0; i < nCharPos1; ++i ) - if( IsControlChar( mpStr[i] ) ) + if( IsControlChar( mrStr[i] ) ) { // add run until control char maRuns.AddRun( nCharPos0, i, bRTL ); @@ -544,7 +546,7 @@ void ImplLayoutArgs::AddRun( int nCharPos0, int nCharPos1, bool bRTL ) else { for( int i = nCharPos1; --i >= nCharPos0; ) - if( IsControlChar( mpStr[i] ) ) + if( IsControlChar( mrStr[i] ) ) { // add run until control char maRuns.AddRun( i+1, nCharPos1, bRTL ); @@ -572,7 +574,7 @@ bool ImplLayoutArgs::PrepareFallback() // get the individual fallback requests typedef std::vector<int> IntVector; IntVector aPosVector; - aPosVector.reserve( mnLength ); + aPosVector.reserve(mrStr.getLength()); maFallbackRuns.ResetPos(); for(; maFallbackRuns.GetRun( &nMin, &nEnd, &bRTL ); maFallbackRuns.NextRun() ) for( int i = nMin; i < nEnd; ++i ) @@ -1136,8 +1138,9 @@ void GenericSalLayout::Justify( DeviceCoordinate nNewWidth ) } } -void GenericSalLayout::ApplyAsianKerning( const sal_Unicode* pStr, int nLength ) +void GenericSalLayout::ApplyAsianKerning(const OUString& rStr) { + const int nLength = rStr.getLength(); long nOffset = 0; for( GlyphVector::iterator pGlyphIter = m_GlyphItems.begin(), pGlyphIterEnd = m_GlyphItems.end(); pGlyphIter != pGlyphIterEnd; ++pGlyphIter ) @@ -1146,10 +1149,10 @@ void GenericSalLayout::ApplyAsianKerning( const sal_Unicode* pStr, int nLength ) if( n < nLength - 1) { // ignore code ranges that are not affected by asian punctuation compression - const sal_Unicode cHere = pStr[n]; + const sal_Unicode cHere = rStr[n]; if( ((0x3000 != (cHere & 0xFF00)) && (0x2010 != (cHere & 0xFFF0))) || (0xFF00 != (cHere & 0xFF00)) ) continue; - const sal_Unicode cNext = pStr[n+1]; + const sal_Unicode cNext = rStr[n+1]; if( ((0x3000 != (cNext & 0xFF00)) && (0x2010 != (cNext & 0xFFF0))) || (0xFF00 != (cNext & 0xFF00)) ) continue; @@ -1622,7 +1625,7 @@ void MultiSalLayout::AdjustLayout( ImplLayoutArgs& rArgs ) nStartNew[ nLevel ], &nGlyphAdv[ nLevel ], &nCharPos[ nLevel ] ); #ifdef MULTI_SL_DEBUG if (nValid[nLevel]) fprintf(mslLog(), "layout[%d]->GetNextGlyphs %d,%d x%d a%d c%d %x\n", n, nStartOld[nLevel], nStartNew[nLevel], aPos.X(), (long)nGlyphAdv[nLevel], nCharPos[nLevel], - rArgs.mpStr[nCharPos[nLevel]]); + rArgs.mrStr[nCharPos[nLevel]]); #endif if( (n > 0) && !nValid[ nLevel ] ) { @@ -1692,7 +1695,7 @@ void MultiSalLayout::AdjustLayout( ImplLayoutArgs& rArgs ) nValid[0] = mpLayouts[0]->GetNextGlyphs( 1, &nDummy, aPos, nStartNew[0], &nGlyphAdv[0], &nCharPos[0] ); #ifdef MULTI_SL_DEBUG - if (nValid[0]) fprintf(mslLog(), "layout[0]->GetNextGlyphs %d,%d x%d a%d c%d %x\n", nStartOld[0], nStartNew[0], aPos.X(), (long)nGlyphAdv[0], nCharPos[0], rArgs.mpStr[nCharPos[0]]); + if (nValid[0]) fprintf(mslLog(), "layout[0]->GetNextGlyphs %d,%d x%d a%d c%d %x\n", nStartOld[0], nStartNew[0], aPos.X(), (long)nGlyphAdv[0], nCharPos[0], rArgs.mrStr[nCharPos[0]]); #endif if( !nValid[0] ) break; @@ -1712,7 +1715,7 @@ void MultiSalLayout::AdjustLayout( ImplLayoutArgs& rArgs ) nValid[n] = mpLayouts[n]->GetNextGlyphs( 1, &nDummy, aPos, nStartNew[n], &nGlyphAdv[n], &nCharPos[n] ); #ifdef MULTI_SL_DEBUG - if (nValid[n]) fprintf(mslLog(), "layout[%d]->GetNextGlyphs %d,%d a%d c%d %x\n", n, nStartOld[n], nStartNew[n], (long)nGlyphAdv[n], nCharPos[n], rArgs.mpStr[nCharPos[n]]); + if (nValid[n]) fprintf(mslLog(), "layout[%d]->GetNextGlyphs %d,%d a%d c%d %x\n", n, nStartOld[n], nStartNew[n], (long)nGlyphAdv[n], nCharPos[n], rArgs.mrStr[nCharPos[n]]); #endif // break after last glyph of active layout if( !nValid[n] ) diff --git a/vcl/source/glyphs/graphite_layout.cxx b/vcl/source/glyphs/graphite_layout.cxx index 1ba80bb64928..876d52da118c 100644 --- a/vcl/source/glyphs/graphite_layout.cxx +++ b/vcl/source/glyphs/graphite_layout.cxx @@ -308,7 +308,7 @@ GraphiteLayout::append(gr_segment *pSeg, ImplLayoutArgs &rArgs, else if(rArgs.mnFlags & SalLayoutFlags::ForFallback) { #ifdef GRLAYOUT_DEBUG - fprintf(grLog(),"fallback c%d %x in run %d\n", firstChar, rArgs.mpStr[firstChar], + fprintf(grLog(),"fallback c%d %x in run %d\n", firstChar, rArgs.mrStr[firstChar], rArgs.maRuns.PosIsInAnyRun(firstChar)); #endif // glyphs that aren't requested for fallback will be taken from base @@ -405,6 +405,7 @@ bool GraphiteLayout::LayoutText(ImplLayoutArgs & rArgs) fprintf(grLog(), "New Graphite LayoutText\n"); #endif success = false; + const int nLength = rArgs.mrStr.getLength(); while (true) { int nBidiMinRunPos, nBidiEndRunPos; @@ -418,11 +419,12 @@ bool GraphiteLayout::LayoutText(ImplLayoutArgs & rArgs) if (nBidiMinRunPos == mnMinCharPos) nBidiMinRunPos = maximum<int>(0, nBidiMinRunPos - EXTRA_CONTEXT_LENGTH); if (nBidiEndRunPos == mnEndCharPos) - nBidiEndRunPos = minimum<int>(rArgs.mnLength, nBidiEndRunPos + EXTRA_CONTEXT_LENGTH); - size_t numchars = gr_count_unicode_characters(gr_utf16, rArgs.mpStr + nBidiMinRunPos, - rArgs.mpStr + nBidiEndRunPos, NULL); + nBidiEndRunPos = minimum<int>(nLength, nBidiEndRunPos + EXTRA_CONTEXT_LENGTH); + const sal_Unicode *pStr = rArgs.mrStr.getStr(); + size_t numchars = gr_count_unicode_characters(gr_utf16, pStr + nBidiMinRunPos, + pStr + nBidiEndRunPos, NULL); gr_segment * pSegment = gr_make_seg(mpFont, mpFace, 0, mpFeatures ? mpFeatures->values() : NULL, - gr_utf16, rArgs.mpStr + nBidiMinRunPos, numchars, 2 | int(bRightToLeft)); + gr_utf16, pStr + nBidiMinRunPos, numchars, 2 | int(bRightToLeft)); if (pSegment != NULL) { @@ -432,9 +434,9 @@ bool GraphiteLayout::LayoutText(ImplLayoutArgs & rArgs) fprintf(grLog(),"Gr::LayoutText %d-%d, context %d-%d, len %d, numchars %" SAL_PRI_SIZET "u, rtl %d scaling %f:", rArgs.mnMinCharPos, rArgs.mnEndCharPos, nBidiMinRunPos, nBidiEndRunPos, - rArgs.mnLength, numchars, bRightToLeft, mfScaling); + mnLength, numchars, bRightToLeft, mfScaling); for (int i = mnSegCharOffset; i < nBidiEndRunPos; ++i) - fprintf(grLog(), " %04X", rArgs.mpStr[i]); + fprintf(grLog(), " %04X", rArgs.mrStr[i]); fprintf(grLog(), "\n"); #endif fillFrom(pSegment, rArgs, mfScaling, bRightToLeft, nBidiEndRunPos); @@ -546,7 +548,7 @@ void GraphiteLayout::AdjustLayout(ImplLayoutArgs& rArgs) for (int i = rArgs.mnMinCharPos; i < rArgs.mnEndCharPos; i++) { UErrorCode aStatus = U_ZERO_ERROR; - UScriptCode scriptCode = uscript_getScript(rArgs.mpStr[i], &aStatus); + UScriptCode scriptCode = uscript_getScript(rArgs.mrStr[i], &aStatus); if (scriptCode == USCRIPT_ARABIC || scriptCode == USCRIPT_SYRIAC) { bKashidaScript = true; diff --git a/vcl/source/outdev/font.cxx b/vcl/source/outdev/font.cxx index dcd2af30be0d..fd7b818ac871 100644 --- a/vcl/source/outdev/font.cxx +++ b/vcl/source/outdev/font.cxx @@ -2101,8 +2101,8 @@ SalLayout* OutputDevice::ImplGlyphFallbackLayout( SalLayout* pSalLayout, ImplLay int nCharPos = -1; bool bRTL = false; OUStringBuffer aMissingCodeBuf; - while( rLayoutArgs.GetNextPos( &nCharPos, &bRTL) ) - aMissingCodeBuf.append( rLayoutArgs.mpStr[ nCharPos ] ); + while (rLayoutArgs.GetNextPos( &nCharPos, &bRTL)) + aMissingCodeBuf.append(rLayoutArgs.mrStr[nCharPos]); rLayoutArgs.ResetPos(); OUString aMissingCodes = aMissingCodeBuf.makeStringAndClear(); diff --git a/vcl/source/outdev/text.cxx b/vcl/source/outdev/text.cxx index c81e6f305892..d8757e057dd3 100644 --- a/vcl/source/outdev/text.cxx +++ b/vcl/source/outdev/text.cxx @@ -1298,7 +1298,7 @@ ImplLayoutArgs OutputDevice::ImplPrepareLayoutArgs( OUString& rStr, nLayoutFlags |= SalLayoutFlags::RightAlign; // set layout options - ImplLayoutArgs aLayoutArgs( rStr.getStr(), rStr.getLength(), nMinIndex, nEndIndex, nLayoutFlags, maFont.GetLanguageTag(), pLayoutCache ); + ImplLayoutArgs aLayoutArgs(rStr, nMinIndex, nEndIndex, nLayoutFlags, maFont.GetLanguageTag(), pLayoutCache); int nOrientation = mpFontEntry ? mpFontEntry->mnOrientation : 0; aLayoutArgs.SetOrientation( nOrientation ); diff --git a/vcl/win/source/gdi/winlayout.cxx b/vcl/win/source/gdi/winlayout.cxx index 8dace9ee5f6b..0a6d806f418d 100644 --- a/vcl/win/source/gdi/winlayout.cxx +++ b/vcl/win/source/gdi/winlayout.cxx @@ -710,8 +710,8 @@ bool UniscribeLayout::LayoutText( ImplLayoutArgs& rArgs ) if( rArgs.mnFlags & SalLayoutFlags::ForFallback ) { // calculate superfluous context char positions - aDropChars.push_back( 0 ); - aDropChars.push_back( rArgs.mnLength ); + aDropChars.push_back(0); + aDropChars.push_back(rArgs.mrStr.getLength()); int nMin, nEnd; bool bRTL; for( rArgs.ResetPos(); rArgs.GetNextRun( &nMin, &nEnd, &bRTL ); ) @@ -748,7 +748,9 @@ bool UniscribeLayout::LayoutText( ImplLayoutArgs& rArgs ) // determine relevant substring and work only on it // when Bidi status is unknown we need to look at the whole string though mnSubStringMin = 0; - int nSubStringEnd = rArgs.mnLength; + const int nLength = rArgs.mrStr.getLength(); + const sal_Unicode *pStr = rArgs.mrStr.getStr(); + int nSubStringEnd = nLength; if( aScriptState.fOverrideDirection ) { // TODO: limit substring to portion limits @@ -756,17 +758,16 @@ bool UniscribeLayout::LayoutText( ImplLayoutArgs& rArgs ) if( mnSubStringMin < 0 ) mnSubStringMin = 0; nSubStringEnd = rArgs.mnEndCharPos + 8; - if( nSubStringEnd > rArgs.mnLength ) - nSubStringEnd = rArgs.mnLength; + if( nSubStringEnd > nLength ) + nSubStringEnd = nLength; } - // now itemize the substring with its context for( int nItemCapacity = 16;; nItemCapacity *= 8 ) { mpScriptItems = new SCRIPT_ITEM[ nItemCapacity ]; HRESULT nRC = ScriptItemize( - reinterpret_cast<LPCWSTR>(rArgs.mpStr + mnSubStringMin), nSubStringEnd - mnSubStringMin, + reinterpret_cast<LPCWSTR>(pStr + mnSubStringMin), nSubStringEnd - mnSubStringMin, nItemCapacity - 1, &aScriptControl, &aScriptState, mpScriptItems, &mnItemCount ); if( !nRC ) // break loop when everything is correctly itemized @@ -909,7 +910,7 @@ bool UniscribeLayout::LayoutText( ImplLayoutArgs& rArgs ) int nGlyphCount = 0; int nCharCount = rVisualItem.mnEndCharPos - rVisualItem.mnMinCharPos; HRESULT nRC = ScriptShape( mhDC, &rScriptCache, - reinterpret_cast<LPCWSTR>(rArgs.mpStr + rVisualItem.mnMinCharPos), + reinterpret_cast<LPCWSTR>(pStr + rVisualItem.mnMinCharPos), nCharCount, mnGlyphCapacity - rVisualItem.mnMinGlyphPos, // problem when >0xFFFF &rVisualItem.mpScriptItem->a, @@ -934,7 +935,7 @@ bool UniscribeLayout::LayoutText( ImplLayoutArgs& rArgs ) // the primitive layout engine is good enough for the default layout rVisualItem.mpScriptItem->a.eScript = SCRIPT_UNDEFINED; nRC = ScriptShape( mhDC, &rScriptCache, - reinterpret_cast<LPCWSTR>(rArgs.mpStr + rVisualItem.mnMinCharPos), + reinterpret_cast<LPCWSTR>(pStr + rVisualItem.mnMinCharPos), nCharCount, mnGlyphCapacity - rVisualItem.mnMinGlyphPos, &rVisualItem.mpScriptItem->a, @@ -983,7 +984,7 @@ bool UniscribeLayout::LayoutText( ImplLayoutArgs& rArgs ) if( mpLogClusters[ c ] == i ) { // #i55716# skip WORDJOINER - if( rArgs.mpStr[ c ] == 0x2060 ) + if( pStr[ c ] == 0x2060 ) mpOutGlyphs[ i + rVisualItem.mnMinGlyphPos ] = 1; else rArgs.NeedFallback( c, false ); @@ -998,7 +999,7 @@ bool UniscribeLayout::LayoutText( ImplLayoutArgs& rArgs ) if( mpLogClusters[ c ] == i ) { // #i55716# skip WORDJOINER - if( rArgs.mpStr[ c ] == 0x2060 ) + if( pStr[ c ] == 0x2060 ) mpOutGlyphs[ i + rVisualItem.mnMinGlyphPos ] = 1; else rArgs.NeedFallback( c, true ); |