I added a new debugging function to my Georgia theme, and I'm sharing it here because I thought some other people might find it useful. What it does is highlights the areas which are marked for repainting through RepaintRect. I kind of did it as a whim when doing some performance testing in my draw code, but it's helped me track down several other bugs that I wasn't aware I even had.
let repaintRects = [];
let drawRepaintRects = true;
window.oldRepaintRect = window.RepaintRect;
window.RepaintRect = (x, y, w, h, force = undefined) => {
if (drawRepaintRects) {
repaintRects.push({ x, y, w, h });
window.Repaint(); // must do a full repaint otherwise old outlines won't clear
} else {
window.oldRepaintRect(x, y, w, h, force);
}
}
// then in your on_paint
on_paint(gr) {
// ... all your other draw code first...
if (repaintRects.length) {
repaintRects.forEach(rect => gr.DrawRect(rect.x, rect.y, rect.w, rect.h, 1, rgba(255,0,0,175)));
repaintRects = [];
}
}
I added it to a menu option so I can toggle it on and off as needed.