1
0
mirror of https://github.com/OpenTTD/OpenTTD synced 2026-01-21 11:22:45 +01:00

Codechange: Remove initial colour from layouter cache. (#12728)

Initial colour is now always TC_INVALID, which is substituted with the desired colour when drawing the layout line.

This allows strings which differ only by initial colour to use the same layout cache entry, increasing the efficacy of the cache.
This commit is contained in:
Peter Nelson
2024-05-28 19:33:44 +01:00
committed by GitHub
parent 605dff4920
commit 3d4b98845a
4 changed files with 16 additions and 15 deletions

View File

@@ -125,12 +125,11 @@ static inline void GetLayouter(Layouter::LineCacheItem &line, std::string_view s
* Create a new layouter.
* @param str The string to create the layout for.
* @param maxw The maximum width.
* @param colour The colour of the font.
* @param fontsize The size of font to use.
*/
Layouter::Layouter(std::string_view str, int maxw, TextColour colour, FontSize fontsize) : string(str)
Layouter::Layouter(std::string_view str, int maxw, FontSize fontsize) : string(str)
{
FontState state(colour, fontsize);
FontState state(TC_INVALID, fontsize);
while (true) {
auto line_length = str.find_first_of('\n');