Cached sf::Text attributes
Two optimizations: - If a value remains the same, nothing happens - Recompute geometry only before drawing and bound access, not after each set Closes #413
This commit is contained in:
parent
59e920cf10
commit
666da801a1
2 changed files with 58 additions and 32 deletions
|
@ -275,21 +275,25 @@ private :
|
|||
virtual void draw(RenderTarget& target, RenderStates states) const;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Update the text's geometry
|
||||
/// \brief Make sure the text's geometry is updated
|
||||
///
|
||||
/// All the attributes related to rendering are cached, such
|
||||
/// that the geometry is only updated when necessary.
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void updateGeometry();
|
||||
void ensureGeometryUpdate() const;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
// Member data
|
||||
////////////////////////////////////////////////////////////
|
||||
String m_string; ///< String to display
|
||||
const Font* m_font; ///< Font used to display the string
|
||||
unsigned int m_characterSize; ///< Base size of characters, in pixels
|
||||
Uint32 m_style; ///< Text style (see Style enum)
|
||||
Color m_color; ///< Text color
|
||||
VertexArray m_vertices; ///< Vertex array containing the text's geometry
|
||||
FloatRect m_bounds; ///< Bounding rectangle of the text (in local coordinates)
|
||||
String m_string; ///< String to display
|
||||
const Font* m_font; ///< Font used to display the string
|
||||
unsigned int m_characterSize; ///< Base size of characters, in pixels
|
||||
Uint32 m_style; ///< Text style (see Style enum)
|
||||
Color m_color; ///< Text color
|
||||
mutable VertexArray m_vertices; ///< Vertex array containing the text's geometry
|
||||
mutable FloatRect m_bounds; ///< Bounding rectangle of the text (in local coordinates)
|
||||
mutable bool m_geometryNeedUpdate; ///< Does the geometry need to be recomputed?
|
||||
};
|
||||
|
||||
} // namespace sf
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue