From e67b02da8ba629b58b95e86c316822313dbc50fc Mon Sep 17 00:00:00 2001 From: Ingo Weyrich Date: Sat, 15 Aug 2020 22:36:10 +0200 Subject: [PATCH] further cleanups --- rtengine/array2D.h | 1 + rtengine/improccoordinator.cc | 25 +++++++++---------------- rtengine/rtengine.h | 6 +++--- rtgui/editorpanel.cc | 6 +++--- rtgui/editorpanel.h | 6 +++--- 5 files changed, 19 insertions(+), 25 deletions(-) diff --git a/rtengine/array2D.h b/rtengine/array2D.h index 512f7bcc1..e55326ef4 100644 --- a/rtengine/array2D.h +++ b/rtengine/array2D.h @@ -140,6 +140,7 @@ public: { buffer.clear(); rows.clear(); + width = 0; } // use with indices diff --git a/rtengine/improccoordinator.cc b/rtengine/improccoordinator.cc index 0a752784a..a7f73a19a 100644 --- a/rtengine/improccoordinator.cc +++ b/rtengine/improccoordinator.cc @@ -1864,17 +1864,6 @@ BENCHFUN memset((int*)vectorscope, 0, size * size * sizeof(vectorscope[0][0])); vectorscopeScale = (x2 - x1) * (y2 - y1); - const int lab_img_size = (hListener->vectorscopeType() == 1) ? vectorscopeScale : 0; - - std::unique_ptr a; - std::unique_ptr b; - if (lab_img_size) { - a.reset(new float[lab_img_size]); - b.reset(new float[lab_img_size]); - std::unique_ptr L(new float[lab_img_size]); - ipf.rgb2lab(*workimg, x1, y1, x2 - x1, y2 - y1, L.get(), a.get(), b.get(), params->icm); - } - if (hListener->vectorscopeType() == 0) { // HS for (int i = y1; i < y2; ++i) { int ofs = (i * pW + x1) * 3; @@ -1893,6 +1882,10 @@ BENCHFUN } } } else if (hListener->vectorscopeType() == 1) { // CH + const std::unique_ptr a(new float[vectorscopeScale]); + const std::unique_ptr b(new float[vectorscopeScale]); + const std::unique_ptr L(new float[vectorscopeScale]); + ipf.rgb2lab(*workimg, x1, y1, x2 - x1, y2 - y1, L.get(), a.get(), b.get(), params->icm); for (int i = y1; i < y2; ++i) { for (int j = x1, ofs_lab = (i - y1) * (x2 - x1); j < x2; ++j, ++ofs_lab) { const int col = (size / 96000.f) * a[ofs_lab] + size / 2; @@ -1908,11 +1901,11 @@ BENCHFUN void ImProcCoordinator::updateWaveforms() { if (!workimg) { - // Resize to zero. - waveformRed(0, 0); - waveformGreen(0, 0); - waveformBlue(0, 0); - waveformLuma(0, 0); + // free memory + waveformRed.free(); + waveformGreen.free(); + waveformBlue.free(); + waveformLuma.free(); return; } diff --git a/rtengine/rtengine.h b/rtengine/rtengine.h index be33ea41e..e6749a9f0 100644 --- a/rtengine/rtengine.h +++ b/rtengine/rtengine.h @@ -344,11 +344,11 @@ public: /** Tells which observable is notifying the listener. */ virtual void setObservable(HistogramObservable* observable) = 0; /** Returns if the listener wants the histogram to be updated. */ - virtual bool updateHistogram(void) = 0; + virtual bool updateHistogram(void) const = 0; /** Returns if the listener wants the vectorscope to be updated. */ - virtual bool updateVectorscope(void) = 0; + virtual bool updateVectorscope(void) const = 0; /** Returns if the listener wants the waveform to be updated. */ - virtual bool updateWaveform(void) = 0; + virtual bool updateWaveform(void) const = 0; /** Returns the vectorscope type: 0 for H-S and 1 for H-C. */ virtual int vectorscopeType(void) const = 0; }; diff --git a/rtgui/editorpanel.cc b/rtgui/editorpanel.cc index d80da8ef2..594965ee6 100644 --- a/rtgui/editorpanel.cc +++ b/rtgui/editorpanel.cc @@ -2269,13 +2269,13 @@ void EditorPanel::setObservable(rtengine::HistogramObservable* observable) histogram_observable = observable; } -bool EditorPanel::updateHistogram(void) +bool EditorPanel::updateHistogram(void) const { return histogram_scope_type == HistogramPanelListener::HISTOGRAM || histogram_scope_type == HistogramPanelListener::NONE; } -bool EditorPanel::updateVectorscope(void) +bool EditorPanel::updateVectorscope(void) const { return histogram_scope_type == HistogramPanelListener::VECTORSCOPE_HS @@ -2283,7 +2283,7 @@ bool EditorPanel::updateVectorscope(void) || histogram_scope_type == HistogramPanelListener::NONE; } -bool EditorPanel::updateWaveform(void) +bool EditorPanel::updateWaveform(void) const { return histogram_scope_type == HistogramPanelListener::WAVEFORM || histogram_scope_type == HistogramPanelListener::NONE; diff --git a/rtgui/editorpanel.h b/rtgui/editorpanel.h index 93e373924..9f0ebf8cb 100644 --- a/rtgui/editorpanel.h +++ b/rtgui/editorpanel.h @@ -143,9 +143,9 @@ public: const array2D& waveformLuma ) override; void setObservable(rtengine::HistogramObservable* observable) override; - bool updateHistogram(void) override; - bool updateVectorscope(void) override; - bool updateWaveform(void) override; + bool updateHistogram(void) const override; + bool updateVectorscope(void) const override; + bool updateWaveform(void) const override; int vectorscopeType(void) const override; // HistogramPanelListener