1
0
Fork 0

tweaks to reduce layout memory usage

master
Gordon Williams 2021-09-29 14:22:36 +01:00
parent 602b1533e1
commit dd49e1f631
1 changed files with 3 additions and 5 deletions

View File

@ -162,10 +162,8 @@ function prepareLazyRender(l, rectsToClear, drawList, rects, parentBg) {
if (c) l.c = c;
if (!delete rectsToClear[hash]) {
rects[hash] = {
bg: parentBg == null ? g.theme.bg : parentBg,
r: [l.x,l.y,l.x+l.w-1,l.y+l.h-1]
};
var r = rects[hash] = [l.x,l.y,l.x+l.w-1,l.y+l.h-1];
r.bg = parentBg == null ? g.theme.bg : parentBg;
if (drawList) {
drawList.push(l);
drawList = null; // Prevent children from being redundantly added to the drawList
@ -225,7 +223,7 @@ Layout.prototype.render = function (l) {
prepareLazyRender(l, rectsToClear, drawList, this.rects, null);
for (var h in rectsToClear) delete this.rects[h];
var clearList = Object.keys(rectsToClear).map(k=>rectsToClear[k]).reverse(); // Rects are cleared in reverse order so that the original bg color is restored
for (var r of clearList) g.setBgColor(r.bg).clearRect.apply(g, r.r);
for (var r of clearList) g.setBgColor(r.bg).clearRect.apply(g, r);
drawList.forEach(render);
} else { // non-lazy
render(l);