aboutsummaryrefslogtreecommitdiff
path: root/include
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 /include
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 'include')
-rw-r--r--include/Body.hpp4
-rw-r--r--include/Text.hpp2
2 files changed, 4 insertions, 2 deletions
diff --git a/include/Body.hpp b/include/Body.hpp
index 47de784..bf5f6aa 100644
--- a/include/Body.hpp
+++ b/include/Body.hpp
@@ -78,6 +78,7 @@ namespace QuickMedia {
sf::Color title_color;
sf::Color author_color;
void *userdata; // Not managed, should be deallocated by whoever sets this
+ sf::Int32 last_drawn_time;
private:
std::string title;
std::string description;
@@ -157,6 +158,8 @@ namespace QuickMedia {
sf::Color line_seperator_color;
private:
void draw_item(sf::RenderWindow &window, BodyItem *item, const sf::Vector2f &pos, const sf::Vector2f &size, const float item_height, const int item_index, const Json::Value &content_progress);
+ void update_dirty_state(BodyItem *body_item, sf::Vector2f size);
+ void clear_body_item_cache(BodyItem *body_item);
private:
Program *program;
std::unordered_map<std::string, std::shared_ptr<ThumbnailData>> item_thumbnail_textures;
@@ -173,5 +176,6 @@ namespace QuickMedia {
int num_visible_items;
bool last_item_fully_visible;
int last_fully_visible_item;
+ sf::Clock draw_timer;
};
} \ No newline at end of file
diff --git a/include/Text.hpp b/include/Text.hpp
index 6a4ed9c..7e9dda2 100644
--- a/include/Text.hpp
+++ b/include/Text.hpp
@@ -139,7 +139,6 @@ namespace QuickMedia
bool dirtyText;
bool dirtyCaret;
bool editable;
- bool visible;
CaretMoveDirection caretMoveDirection;
sf::FloatRect boundingBox;
float lineSpacing;
@@ -149,7 +148,6 @@ namespace QuickMedia
int caretIndex;
float caret_offset_x;
sf::Vector2f caretPosition;
- sf::Clock lastSeenTimer;
sf::Vector2u renderTargetSize;
std::vector<VertexRef> vertices_linear; // TODO: Use textElements instead