Skip to content

Commit 882401a

Browse files
committed
Build 3.33.2-sm
1 parent c4a500c commit 882401a

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

src/extensions/renderer/canvas/layered-texture-cache.mjs

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -186,17 +186,19 @@ LTCp.getLayers = function( eles, pxRatio, lvl ){
186186
// SM customization: use self.bb (persistent across calls) instead of a local bb variable.
187187
// Also adds early-exit if the accumulated layer area exceeds maxLayerArea during incremental
188188
// bounding box computation, preventing massive texture allocation for very large graphs.
189+
// The loop only runs when self.bb is null (first call or after invalidation).
189190
function getBb() {
190191
if( !self.bb ){
191192
self.bb = math.makeBoundingBox();
192-
}
193193

194-
for( var i = 0; i < eles.length; i++ ){
195-
var area = self.bb.w * scale * (self.bb.h * scale);
196-
if (area > maxLayerArea) {
197-
return null;
194+
for( var i = 0; i < eles.length; i++ ){
195+
var area = self.bb.w * scale * (self.bb.h * scale);
196+
if (area > maxLayerArea) {
197+
self.bb = null;
198+
return null;
199+
}
200+
math.updateBoundingBox(self.bb, eles[i].boundingBox() );
198201
}
199-
math.updateBoundingBox(self.bb, eles[i].boundingBox() );
200202
}
201203

202204
return self.bb;
@@ -471,6 +473,9 @@ LTCp.invalidateLayer = function( layer ){
471473

472474
if( layer.invalid ){ return; } // save cycles
473475

476+
// SM customization: clear persistent BB so it's recomputed on next getLayers() call
477+
this.bb = null;
478+
474479
var lvl = layer.level;
475480
var eles = layer.eles;
476481
var layers = this.layersByLevel[ lvl ];

0 commit comments

Comments
 (0)