From d06ad43dca38913168f8dccc98d85813dc094023 Mon Sep 17 00:00:00 2001 From: ocornut Date: Tue, 16 Jun 2015 17:50:55 -0600 Subject: [PATCH] ImFont::RenderText() additional early out (typically performed at TextUnformatted() level for large chunks but this is also useful) (#200) --- imgui.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/imgui.cpp b/imgui.cpp index e4c102ed..b0eaa6b0 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -10092,8 +10092,10 @@ void ImFont::RenderText(float size, ImVec2 pos, ImU32 col, const ImVec4& clip_re { // Clipping on Y is more likely float y1 = (float)(y + glyph->YOffset * scale); + if (y1 > clip_rect.w) + break; float y2 = (float)(y1 + glyph->Height * scale); - if (y1 <= clip_rect.w && y2 >= clip_rect.y) // FIMXE-OPT: could fast-forward until next line + if (y2 >= clip_rect.y) // FIMXE-OPT: could fast-forward until next line (without breaking word-wrapping) { float x1 = (float)(x + glyph->XOffset * scale); float x2 = (float)(x1 + glyph->Width * scale);