From 3d656ffb9d242ba42f87cd2ef7ac13b06c7a2043 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Mon, 5 Aug 2019 21:34:37 +0200 Subject: Only redraw image preview when needed, less cpu usage --- src/QuickMedia.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/QuickMedia.cpp') diff --git a/src/QuickMedia.cpp b/src/QuickMedia.cpp index 5ea2c43..2e7647e 100644 --- a/src/QuickMedia.cpp +++ b/src/QuickMedia.cpp @@ -424,6 +424,8 @@ namespace QuickMedia { image_size.y *= image_scale.y; image.setPosition(std::floor(window_size.x * 0.5f - image_size.x * 0.5f), std::floor(window_size.y * 0.5f - image_size.y * 0.5f)); } + } else { + continue; } window.clear(back_color); @@ -437,11 +439,11 @@ namespace QuickMedia { float background_height = font_height + 20.0f; chapter_text_background.setSize(sf::Vector2f(window_size.x, background_height)); - chapter_text_background.setPosition(0.0f, window_size.y - background_height); + chapter_text_background.setPosition(0.0f, std::floor(window_size.y - background_height)); window.draw(chapter_text_background); auto text_bounds = chapter_text.getLocalBounds(); - chapter_text.setPosition(window_size.x * 0.5f - text_bounds.width * 0.5f, window_size.y - background_height * 0.5f - text_bounds.height * 0.5f); + chapter_text.setPosition(std::floor(window_size.x * 0.5f - text_bounds.width * 0.5f), std::floor(window_size.y - background_height * 0.5f - font_height * 0.5f)); window.draw(chapter_text); } window.display(); -- cgit v1.2.3