From 1ca5809da5de98a14ec6cc61462cf6f04e2d56f5 Mon Sep 17 00:00:00 2001 From: ranma Date: Sat, 10 Mar 2018 20:44:45 +0100 Subject: [PATCH] Improve DrawQuads batching in the font render. (#1654) Currently only identical glyphs are merged into one DrawQuads call. This fixes the comparison so that all glyphs with the same texture can be merged, which greatly improves the font rendering performance. --- src/BitmapText.cpp | 2 +- src/Font.h | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/BitmapText.cpp b/src/BitmapText.cpp index 701a817381..3f5ec8e3b5 100644 --- a/src/BitmapText.cpp +++ b/src/BitmapText.cpp @@ -422,7 +422,7 @@ void BitmapText::DrawChars( bool bUseStrokeTexture ) for( int start = iStartGlyph; start < iEndGlyph; ) { int end = start; - while( end < iEndGlyph && m_vpFontPageTextures[end] == m_vpFontPageTextures[start] ) + while( end < iEndGlyph && *m_vpFontPageTextures[end] == *m_vpFontPageTextures[start] ) end++; bool bHaveATexture = !bUseStrokeTexture || (bUseStrokeTexture && m_vpFontPageTextures[start]->m_pTextureStroke); diff --git a/src/Font.h b/src/Font.h index da06841192..4d8df76b44 100644 --- a/src/Font.h +++ b/src/Font.h @@ -24,6 +24,15 @@ struct FontPageTextures /** @brief Set up the initial textures. */ FontPageTextures(): m_pTextureMain(NULL), m_pTextureStroke(NULL) {} + + bool operator == (const struct FontPageTextures& other) const { + return m_pTextureMain == other.m_pTextureMain && + m_pTextureStroke == other.m_pTextureStroke; + } + + bool operator != (const struct FontPageTextures& other) const { + return !operator==(other); + } }; /** @brief The components of a glyph (not technically a character). */