aboutsummaryrefslogtreecommitdiff
path: root/src/Text.cpp
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2020-10-03 14:46:57 +0200
committerdec05eba <dec05eba@protonmail.com>2020-10-03 14:47:03 +0200
commit4907c5cc952e94e32cb0f95ea6f3be361b55d389 (patch)
tree305331f272dd3d93bb20bffdf154eeb1f798d565 /src/Text.cpp
parent8ce51433c8a73b76e57f124bb62e5aa39867238a (diff)
Reduce memory usage by cleaning up text not visible on the screen
As a text, memory usage decreased from 150mb to 20mb
Diffstat (limited to 'src/Text.cpp')
-rw-r--r--src/Text.cpp24
1 files changed, 0 insertions, 24 deletions
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);