Skip to content

Commit 5594390

Browse files
committed
Optimized grid and overall rendering: skip lines at low zoom, use fillRect instead of vertical/horizontal drawLine
Also now using getNoteBounds() for checking if need to draw note in paint(). Optimized drawing of very short notes (<=1 pixel, as rectangles). Optimized drawing of bent and rounded notes.
1 parent ab88887 commit 5594390

6 files changed

Lines changed: 326 additions & 194 deletions

File tree

plugin/include/XenRoll/data/Parameters.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@ class Parameters {
5252
static constexpr float max_bar_width_px = 4000.0f;
5353
static constexpr float max_octave_height_px = 5000.0f;
5454
static constexpr float max_note_height_scale = 2.0f;
55+
static constexpr float min_subdiv_width_px = 4.0f; // for drawing subdiv lines
56+
static constexpr float min_beat_width_px = 6.0f; // for drawing beat lines
57+
static constexpr float min_bar_width_px = 30.0f; // for drawing bar lines
5558
// ===== Vocal to melody =====
5659
static constexpr float minVocalVolume_dB = -60.0f;
5760
static constexpr float maxVocalVolume_dB = 0.0f;

plugin/include/XenRoll/editor/panels/MainPanel.h

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ class MainPanel : public juce::Component, public juce::KeyListener {
205205
std::mutex mptcMtx;
206206

207207
juce::Font bendFont;
208-
std::unordered_map<juce::String, juce::Path> outlinedTextPathCache;
208+
std::unordered_map<size_t, juce::Path> outlinedTextPathCache;
209209
static constexpr int OUTLINED_TEXT_CACHE_MAX_SIZE = 150;
210210

211211
PitchMemoryResults pitchMemoryResults = {{}, {}};
@@ -293,6 +293,11 @@ class MainPanel : public juce::Component, public juce::KeyListener {
293293
*/
294294
void updateLayout();
295295

296+
float getNotesHeight(); ///< in pixels
297+
298+
///< For fast check if we need to draw note in paint()
299+
juce::Rectangle<float> getNoteBounds(const Note &note);
300+
296301
/**
297302
* @brief Get the path for drawing a note
298303
* @param note Note to get path for
@@ -344,7 +349,7 @@ class MainPanel : public juce::Component, public juce::KeyListener {
344349
void pitchCorrectRatioMarksBasedOnSelNotes();
345350
void timeCorrectRatioMarksBasedOnSelNotes(float dtime);
346351

347-
int totalCentsToY(int totalCents);
352+
float totalCentsToY(int totalCents);
348353

349354
void restoreState();
350355

plugin/include/XenRoll/editor/panels/NotePathManager.h

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,13 @@ class NotePathManager {
1919
private:
2020
const int numOctaves;
2121

22-
///< Is used to scale duration in CacheKey & to round corner radius in path (tol)
22+
///< Is used to scale duration in CacheKey
2323
static constexpr float MAX_PX_SCALE = 4.0f;
24+
///< Minimum rounding radius
25+
static constexpr float TOL_RADIUS = 1.8f;
26+
///< If arc has angle < 90° and sagitta less than this, then just draw a line instead
27+
static constexpr float MAX_VISUAL_DEVIATION = 0.4f;
28+
2429
static constexpr size_t MAX_CACHE_SIZE = 1000; // 1000 elements = ~0.5 Mb total
2530

2631
///< Cache key, contains only params that affect the shape of note
@@ -55,6 +60,10 @@ class NotePathManager {
5560
* @return juce::Path Canonical path
5661
*/
5762
juce::Path buildCanonicalPath(float w, float dy, float h, float noteRoundCoef) const;
63+
64+
void addConditionalArc(juce::Path &path, float centreX, float centreY, float radius,
65+
float fromRadians, float toRadians,
66+
bool startAsNewSubPath = false) const;
5867
};
5968

6069
} // namespace audio_plugin

0 commit comments

Comments
 (0)