diff options
author | Herbert Duerr <hdu@openoffice.org> | 2003-07-22 11:05:31 +0000 |
---|---|---|
committer | Herbert Duerr <hdu@openoffice.org> | 2003-07-22 11:05:31 +0000 |
commit | 40bddf58a3082785cf7692256dfb365d49d18f89 (patch) | |
tree | d0eeb69a27799104197834e6eb42ab295d1f9434 /vcl | |
parent | fec1779cbee6d08c82469366d22e3b82ec7c975a (diff) |
#110987# unify textlayout caches
Diffstat (limited to 'vcl')
-rwxr-xr-x | vcl/win/source/gdi/winlayout.cxx | 129 |
1 files changed, 61 insertions, 68 deletions
diff --git a/vcl/win/source/gdi/winlayout.cxx b/vcl/win/source/gdi/winlayout.cxx index 5b0cef06f168..85e8f91035aa 100755 --- a/vcl/win/source/gdi/winlayout.cxx +++ b/vcl/win/source/gdi/winlayout.cxx @@ -2,9 +2,9 @@ * * $RCSfile: winlayout.cxx,v $ * - * $Revision: 1.70 $ + * $Revision: 1.71 $ * - * last change: $Author: vg $ $Date: 2003-07-21 11:22:25 $ + * last change: $Author: hdu $ $Date: 2003-07-22 12:05:31 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -1109,30 +1109,6 @@ void SimpleWinLayout::Simplify( bool bIsBase ) // ======================================================================= -#ifdef GNG_VERT_HACK - -class GNGVertLayoutCache : public ImplTextLayoutCache -{ -public: - GNGVertLayoutCache() {} - virtual ~GNGVertLayoutCache() { flush( 0 ); } - virtual void flush( int nMinLevel ); - - GSUBList maGSUBLists[ MAX_FALLBACK ]; -}; - -// ----------------------------------------------------------------------- - -void GNGVertLayoutCache::flush( int nMinLevel ) -{ - for( int i = nMinLevel; i < MAX_FALLBACK; ++i ) - maGSUBLists[i].clear(); -} - -#endif // GNG_VERT_HACK - -// ======================================================================= - #ifdef USE_UNISCRIBE #include <Usp10.h> @@ -1152,17 +1128,6 @@ public: bool IsEmpty() const { return (mnEndGlyphPos <= 0); } }; -class UniscribeLayoutCache : public ImplTextLayoutCache -{ -public: - UniscribeLayoutCache(); - virtual ~UniscribeLayoutCache() { flush( 0 ); } - - virtual void flush( int nMinLevel ); - - SCRIPT_CACHE maScriptCache[ MAX_FALLBACK ]; -}; - class UniscribeLayout : public WinLayout { public: @@ -1312,26 +1277,6 @@ static bool InitUSP() // ----------------------------------------------------------------------- -UniscribeLayoutCache::UniscribeLayoutCache() -{ - for( int i = 0; i < MAX_FALLBACK; ++i ) - maScriptCache[ i ] = NULL; -} - -// ----------------------------------------------------------------------- - -void UniscribeLayoutCache::flush( int nMinLevel ) -{ - for( int i = nMinLevel; i < MAX_FALLBACK; ++i ) - { - if( maScriptCache[ i ] != NULL ) - (*pScriptFreeCache)( &maScriptCache[ i ] ); - maScriptCache[ i ] = NULL; - } -} - -// ----------------------------------------------------------------------- - UniscribeLayout::UniscribeLayout( HDC hDC, SCRIPT_CACHE& rScriptCache ) : WinLayout( hDC ), mnItemCount(0), @@ -2370,21 +2315,73 @@ void UniscribeLayout::Justify( long nNewWidth ) // ======================================================================= +// for performance reasons the informations in the +// class below are so expensive to get that getting +// them should be avoided if possible. Only when new +// fonts get involved they get invalidated +// TODO: move to upper layers font list management +class WinTextLayoutCache : public ImplTextLayoutCache +{ +public: + WinTextLayoutCache(); + virtual ~WinTextLayoutCache() { flush( 0 ); } + virtual void flush( int nMinLevel ); + +// public access only visible to SalGraphics::GetTextLayout() +#ifdef GNG_VERT_HACK + GSUBList maGSUBLists[ MAX_FALLBACK ]; +#endif // GNG_VERT_HACK +#ifdef USE_UNISCRIBE + SCRIPT_CACHE maScriptCache[ MAX_FALLBACK ]; +#endif // USE_UNISCRIBE +}; + +// ----------------------------------------------------------------------- + +WinTextLayoutCache::WinTextLayoutCache() +{ +#ifdef USE_UNISCRIBE + for( int i = 0; i < MAX_FALLBACK; ++i ) + maScriptCache[ i ] = NULL; +#endif // USE_UNISCRIBE +} + +// ----------------------------------------------------------------------- + +void WinTextLayoutCache::flush( int nMinLevel ) +{ + for( int i = nMinLevel; i < MAX_FALLBACK; ++i ) + { +#ifdef GNG_VERT_HACK + maGSUBLists[i].clear(); +#endif // GNG_VERT_HACK +#ifdef USE_UNISCRIBE + if( maScriptCache[ i ] != NULL ) + (*pScriptFreeCache)( &maScriptCache[ i ] ); + maScriptCache[ i ] = NULL; +#endif // USE_UNISCRIBE + } +} + +// ======================================================================= + SalLayout* SalGraphics::GetTextLayout( ImplLayoutArgs& rArgs, int nFallbackLevel ) { WinLayout* pWinLayout = NULL; + WinTextLayoutCache* pCache = (WinTextLayoutCache*)maGraphicsData.mxTextLayoutCache.get(); + if( !pCache ) + { + pCache = new WinTextLayoutCache; + maGraphicsData.mxTextLayoutCache.reset( pCache ); + } + #ifdef USE_UNISCRIBE if( !(rArgs.mnFlags & SAL_LAYOUT_COMPLEX_DISABLED) // complex text && (aUspModule || (bUspEnabled && InitUSP())) ) // CTL layout engine { - if( maGraphicsData.mxTextLayoutCache.get() == 0 ) - maGraphicsData.mxTextLayoutCache.reset(new UniscribeLayoutCache); - // script complexity is determined in upper layers - SCRIPT_CACHE& rScriptCache = - static_cast<UniscribeLayoutCache*>( maGraphicsData.mxTextLayoutCache.get() ) - ->maScriptCache[ nFallbackLevel ]; + SCRIPT_CACHE& rScriptCache = pCache->maScriptCache[ nFallbackLevel ]; pWinLayout = new UniscribeLayout( maGraphicsData.mhDC, rScriptCache ); // NOTE: it must be guaranteed that the SalGraphics lives longer than // the created UniscribeLayout, otherwise the data passed into the @@ -2399,11 +2396,7 @@ SalLayout* SalGraphics::GetTextLayout( ImplLayoutArgs& rArgs, int nFallbackLevel #endif // GCP_KERN_HACK #ifdef GNG_VERT_HACK - if( maGraphicsData.mxTextLayoutCache.get() == 0 ) - maGraphicsData.mxTextLayoutCache.reset( new GNGVertLayoutCache ); - GSUBList& rGSUBList = - static_cast<GNGVertLayoutCache*>( maGraphicsData.mxTextLayoutCache.get() ) - ->maGSUBLists[ nFallbackLevel ]; + GSUBList& rGSUBList = pCache->maGSUBLists[ nFallbackLevel ]; #endif // GNG_VERT_HACK BYTE eCharSet = ANSI_CHARSET; |