mirror of
https://gitlab.com/kicad/code/kicad.git
synced 2025-09-14 18:23:15 +02:00
Runtime cache for knockout text.
Fixes https://gitlab.com/kicad/code/kicad/-/issues/20711 (cherry picked from commit 80d24d47200fd37d775c204f3ca85721240b93bb)
This commit is contained in:
parent
8dd10e11b4
commit
fc30a4eb3d
@ -2262,9 +2262,7 @@ void PCB_PAINTER::draw( const PCB_TEXT* aText, int aLayer )
|
||||
|
||||
if( aText->IsKnockout() )
|
||||
{
|
||||
SHAPE_POLY_SET finalPoly;
|
||||
aText->TransformTextToPolySet( finalPoly, 0, m_maxError, ERROR_INSIDE );
|
||||
finalPoly.Fracture();
|
||||
SHAPE_POLY_SET finalPoly = aText->GetKnockoutCache( font, resolvedText, m_maxError );
|
||||
|
||||
m_gal->SetIsStroke( false );
|
||||
m_gal->SetIsFill( true );
|
||||
|
@ -482,6 +482,38 @@ std::shared_ptr<SHAPE> PCB_TEXT::GetEffectiveShape( PCB_LAYER_ID aLayer, FLASHIN
|
||||
}
|
||||
|
||||
|
||||
SHAPE_POLY_SET PCB_TEXT::GetKnockoutCache( const KIFONT::FONT* aFont, const wxString& forResolvedText,
|
||||
int aMaxError ) const
|
||||
{
|
||||
TEXT_ATTRIBUTES attrs = GetAttributes();
|
||||
EDA_ANGLE drawAngle = GetDrawRotation();
|
||||
VECTOR2I drawPos = GetDrawPos();
|
||||
|
||||
if( m_knockout_cache.IsEmpty()
|
||||
|| m_knockout_cache_text_attrs != attrs
|
||||
|| m_knockout_cache_text != forResolvedText
|
||||
|| m_knockout_cache_angle != drawAngle )
|
||||
{
|
||||
m_knockout_cache.RemoveAllContours();
|
||||
|
||||
TransformTextToPolySet( m_knockout_cache, 0, aMaxError, ERROR_INSIDE );
|
||||
m_knockout_cache.Fracture();
|
||||
|
||||
m_knockout_cache_text_attrs = attrs;
|
||||
m_knockout_cache_angle = drawAngle;
|
||||
m_knockout_cache_text = forResolvedText;
|
||||
m_knockout_cache_pos = drawPos;
|
||||
}
|
||||
else if( m_knockout_cache_pos != drawPos )
|
||||
{
|
||||
m_knockout_cache.Move( drawPos - m_knockout_cache_pos );
|
||||
m_knockout_cache_pos = drawPos;
|
||||
}
|
||||
|
||||
return m_knockout_cache;
|
||||
}
|
||||
|
||||
|
||||
void PCB_TEXT::buildBoundingHull( SHAPE_POLY_SET* aBuffer, const SHAPE_POLY_SET& aRenderedText,
|
||||
int aClearance ) const
|
||||
{
|
||||
|
@ -142,6 +142,9 @@ public:
|
||||
GetEffectiveShape( PCB_LAYER_ID aLayer = UNDEFINED_LAYER,
|
||||
FLASHING aFlash = FLASHING::DEFAULT ) const override;
|
||||
|
||||
SHAPE_POLY_SET GetKnockoutCache( const KIFONT::FONT* aFont, const wxString& forResolvedText,
|
||||
int aMaxError ) const;
|
||||
|
||||
virtual wxString GetTextTypeDescription() const;
|
||||
|
||||
wxString GetItemDescription( UNITS_PROVIDER* aUnitsProvider, bool aFull ) const override;
|
||||
@ -188,6 +191,13 @@ protected:
|
||||
int getKnockoutMargin() const;
|
||||
|
||||
const KIFONT::METRICS& getFontMetrics() const override { return GetFontMetrics(); }
|
||||
|
||||
private:
|
||||
mutable wxString m_knockout_cache_text;
|
||||
mutable TEXT_ATTRIBUTES m_knockout_cache_text_attrs;
|
||||
mutable EDA_ANGLE m_knockout_cache_angle;
|
||||
mutable VECTOR2I m_knockout_cache_pos;
|
||||
mutable SHAPE_POLY_SET m_knockout_cache;
|
||||
};
|
||||
|
||||
#endif // #define PCB_TEXT_H
|
||||
|
Loading…
x
Reference in New Issue
Block a user