Skip to content

Commit

Permalink
Added project cache debug
Browse files Browse the repository at this point in the history
  • Loading branch information
deepnight committed Jan 15, 2024
1 parent 12e0455 commit 9f34fd0
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 32 deletions.
1 change: 1 addition & 0 deletions src/electron.renderer/EditorTypes.hx
Original file line number Diff line number Diff line change
Expand Up @@ -308,4 +308,5 @@ enum AppCommand {
enum DebugFlag {
F_MainDebug;
F_IntGridUseCounts;
F_ProjectImgCache;
}
79 changes: 47 additions & 32 deletions src/electron.renderer/page/Editor.hx
Original file line number Diff line number Diff line change
Expand Up @@ -2898,6 +2898,52 @@ class Editor extends Page {
}


function updateDebug() {
// IntGrid use counts debugging
if( App.ME.hasDebugFlag(F_IntGridUseCounts) ) {
App.ME.clearDebug();
@:privateAccess
for(li in curLevel.layerInstances) {
if( li.def.type==IntGrid ) {
// Show cached area counts
App.ME.debugPre(li.toString());
for(iv in li.def.intGridValues) {
var n = 0;
if( li.areaIntGridUseCount.exists(iv.value) )
for(areaCount in li.areaIntGridUseCount.get(iv.value))
n++;
var nLayer = li.layerIntGridUseCount.get(iv.value);
if( n>0 )
App.ME.debugPre(' #${iv.value} => $n area (layer count=$nLayer)', n<=0 ? dn.Col.midGray() : dn.Col.white());
}
}
if( li.def.isAutoLayer() ) {
// Count relevant rules
for(rg in li.def.autoRuleGroups) {
var n = 0;
for(r in rg.rules)
if( r.isRelevantInLayer(li) )
n++;

if( n>0 )
App.ME.debugPre(" Group "+rg.toString()+": "+n+" rule(s)", "#56b0ff");
}
}
}
}

// Project images cache
if( App.ME.hasDebugFlag(F_ProjectImgCache) ) {
App.ME.clearDebug();
@:privateAccess
for(c in project.imageCache.keyValueIterator()) {
var cache = project.imageCache.get(c.key);
App.ME.debugPre('${c.key}: (${cache.pixels.width}x${cache.pixels.height})');
}
}
}


override function postUpdate() {
super.postUpdate();
ge.onEndOfFrame();
Expand Down Expand Up @@ -2940,37 +2986,6 @@ class Editor extends Page {
if( settings.v.zenMode && cd.has("pendingZenModeReHide") && !cd.has("zenModeReHideLock") )
setZenModeReveal(false);

// IntGrid use counts debugging
if( App.ME.hasDebugFlag(F_IntGridUseCounts) ) {
App.ME.clearDebug();
@:privateAccess
for(li in curLevel.layerInstances) {
if( li.def.type==IntGrid ) {
// Show cached area counts
App.ME.debugPre(li.toString());
for(iv in li.def.intGridValues) {
var n = 0;
if( li.areaIntGridUseCount.exists(iv.value) )
for(areaCount in li.areaIntGridUseCount.get(iv.value))
n++;
var nLayer = li.layerIntGridUseCount.get(iv.value);
if( n>0 )
App.ME.debugPre(' #${iv.value} => $n area (layer count=$nLayer)', n<=0 ? dn.Col.midGray() : dn.Col.white());
}
}
if( li.def.isAutoLayer() ) {
// Count relevant rules
for(rg in li.def.autoRuleGroups) {
var n = 0;
for(r in rg.rules)
if( r.isRelevantInLayer(li) )
n++;

if( n>0 )
App.ME.debugPre(" Group "+rg.toString()+": "+n+" rule(s)", "#56b0ff");
}
}
}
}
updateDebug();
}
}

0 comments on commit 9f34fd0

Please sign in to comment.