Don't try to move bounding box caches.

This commit is contained in:
Jeff Young 2022-02-01 21:37:05 +00:00
parent 6fcc6f7c9d
commit 0634cf261a
2 changed files with 12 additions and 10 deletions

View File

@ -389,7 +389,7 @@ void EDA_TEXT::Offset( const VECTOR2I& aOffset )
for( std::unique_ptr<KIFONT::GLYPH>& glyph : m_render_cache ) for( std::unique_ptr<KIFONT::GLYPH>& glyph : m_render_cache )
static_cast<KIFONT::OUTLINE_GLYPH*>( glyph.get() )->Move( aOffset ); static_cast<KIFONT::OUTLINE_GLYPH*>( glyph.get() )->Move( aOffset );
m_bounding_box_cache.Move( aOffset ); m_bounding_box_cache_valid = false;
} }
@ -512,10 +512,11 @@ EDA_RECT EDA_TEXT::GetTextBox( int aLine, bool aInvertY ) const
{ {
VECTOR2I drawPos = GetDrawPos(); VECTOR2I drawPos = GetDrawPos();
if( m_bounding_box_cache_valid && aLine < 0 && !aInvertY ) if( m_bounding_box_cache_valid
&& m_bounding_box_cache_pos == drawPos
&& m_bounding_box_cache_line == aLine
&& m_bounding_box_cache_inverted == aInvertY )
{ {
m_bounding_box_cache.Offset( drawPos - m_bounding_box_cache_pos );
m_bounding_box_cache_pos = drawPos;
return m_bounding_box_cache; return m_bounding_box_cache;
} }
@ -605,12 +606,11 @@ EDA_RECT EDA_TEXT::GetTextBox( int aLine, bool aInvertY ) const
rect.Normalize(); // Make h and v sizes always >= 0 rect.Normalize(); // Make h and v sizes always >= 0
if( aLine < 0 && !aInvertY ) m_bounding_box_cache_valid = true;
{ m_bounding_box_cache_pos = drawPos;
m_bounding_box_cache_valid = true; m_bounding_box_cache_line = aLine;
m_bounding_box_cache_pos = drawPos; m_bounding_box_cache_inverted = aInvertY;
m_bounding_box_cache = rect; m_bounding_box_cache = rect;
}
return rect; return rect;
} }

View File

@ -343,6 +343,8 @@ private:
mutable bool m_bounding_box_cache_valid; mutable bool m_bounding_box_cache_valid;
mutable VECTOR2I m_bounding_box_cache_pos; mutable VECTOR2I m_bounding_box_cache_pos;
mutable int m_bounding_box_cache_line;
mutable bool m_bounding_box_cache_inverted;
mutable EDA_RECT m_bounding_box_cache; mutable EDA_RECT m_bounding_box_cache;
TEXT_ATTRIBUTES m_attributes; TEXT_ATTRIBUTES m_attributes;