From 4907c5cc952e94e32cb0f95ea6f3be361b55d389 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Sat, 3 Oct 2020 14:46:57 +0200 Subject: Reduce memory usage by cleaning up text not visible on the screen As a text, memory usage decreased from 150mb to 20mb --- src/Text.cpp | 24 ------------------------ 1 file changed, 24 deletions(-) (limited to 'src/Text.cpp') diff --git a/src/Text.cpp b/src/Text.cpp index 2165037..e311f14 100644 --- a/src/Text.cpp +++ b/src/Text.cpp @@ -37,7 +37,6 @@ namespace QuickMedia dirtyText(false), dirtyCaret(false), editable(false), - visible(true), caretMoveDirection(CaretMoveDirection::NONE), lineSpacing(0.0f), characterSpacing(0.0f), @@ -707,32 +706,10 @@ namespace QuickMedia } sf::Vector2f pos = position; - - // TODO: Do not use maxWidth here. Max width might be set to 99999 and actual text width might be 200. Text width should be calculated instead - //sf::FloatRect targetRect(0.0f, 0.0f, maxWidth, target.getSize().y); - //sf::FloatRect textRect(pos.x, pos.y, maxWidth, ) - //colRect.contains() - //if(pos.x + maxWidth <= 0.0f || pos.x >= maxWidth || pos.y + totalHeight <= 0.0f || pos.y >= target.getSize().y) return; - renderTargetSize = target.getSize(); - if(pos.y + getHeight() <= 0.0f || pos.y >= renderTargetSize.y) - { - if(!editable && visible && lastSeenTimer.getElapsedTime().asMilliseconds() > 3000) - { - visible = false; - vertices[0].resize(0); - vertices[1].resize(0); - } - return false; - } const float vspace = font->getLineSpacing(characterSize); pos.y += floor(vspace); // Origin is at bottom left, we want it to be at top left - if(!visible) { - visible = true; - updateGeometry(true); - } - const sf::Font *fonts[] = { font, cjk_font }; for(size_t i = 0; i < 2; ++i) { sf::RenderStates states; @@ -740,7 +717,6 @@ namespace QuickMedia states.texture = &fonts[i]->getTexture(characterSize); target.draw(vertices[i], states); } - lastSeenTimer.restart(); if(!editable) return true; pos.y -= floor(vspace * 2.0f); -- cgit v1.2.3