From bce954c2bc34b88c46fe4503af9eb8b824fb6ffd Mon Sep 17 00:00:00 2001 From: Mike Kucera Date: Tue, 17 Sep 2024 13:17:52 -0400 Subject: [PATCH] maximum width/height for offscreen canvas used by LayeredTextureCache Refs #3258 --- .../renderer/canvas/layered-texture-cache.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/extensions/renderer/canvas/layered-texture-cache.js b/src/extensions/renderer/canvas/layered-texture-cache.js index 0a2b04b8ef..88b88e4582 100644 --- a/src/extensions/renderer/canvas/layered-texture-cache.js +++ b/src/extensions/renderer/canvas/layered-texture-cache.js @@ -18,6 +18,7 @@ var deqFastCost = 0.9; // % of frame time to be used when >60fps var maxDeqSize = 1; // number of eles to dequeue and render at higher texture in each batch var invalidThreshold = 250; // time threshold for disabling b/c of invalidations var maxLayerArea = 4000 * 4000; // layers can't be bigger than this +var maxLayerDim = 32767; // maximum size for the width/height of layer canvases var alwaysQueue = true; // never draw all the layers in a level on a frame; draw directly until all dequeued var useHighQualityEleTxrReqs = true; // whether to use high quality ele txr requests (generally faster and cheaper in the longterm) @@ -195,7 +196,14 @@ LTCp.getLayers = function( eles, pxRatio, lvl ){ getBb(); - var area = ( bb.w * scale ) * ( bb.h * scale ); + var w = Math.ceil( bb.w * scale ); + var h = Math.ceil( bb.h * scale ); + + if( w > maxLayerDim || h > maxLayerDim ){ + return null; + } + + var area = w * h; if( area > maxLayerArea ){ return null;