PixelPaint: Calculate histogram and vectorscope data only when needed

With this patch the histogram and vectorscope data for the image is
only computed when the widgets are visible to the user and therefore
saves some processing time when this information is not required
to be computed.
This commit is contained in:
Torstennator 2023-08-16 14:30:00 +02:00 committed by Sam Atkins
commit 60b72b8033
Notes: sideshowbarker 2024-07-18 05:01:22 +09:00
7 changed files with 40 additions and 14 deletions

View file

@ -6,6 +6,7 @@
#include "ScopeWidget.h"
#include "Layer.h"
#include <LibConfig/Client.h>
namespace PixelPaint {
@ -38,4 +39,26 @@ void ScopeWidget::set_color_at_mouseposition(Color color)
update();
}
void ScopeWidget::set_scope_visibility(bool visible)
{
if (visible != read_visibility_from_configuration())
Config::write_bool("PixelPaint"sv, "Scopes"sv, widget_config_name(), visible);
// since we are housed within a other widget we need to set the visibility on our parent widget
if (parent_widget())
parent_widget()->set_visible(visible);
if (visible)
image_changed();
}
bool ScopeWidget::read_visibility_from_configuration()
{
return Config::read_bool("PixelPaint"sv, "Scopes"sv, widget_config_name(), false);
}
bool ScopeWidget::should_process_data()
{
return m_image && read_visibility_from_configuration();
}
}