From 070d510578c7aa7d5681ecc71a7b79dd002bfd6d Mon Sep 17 00:00:00 2001 From: SmallMain Date: Fri, 20 Dec 2024 14:49:56 +0800 Subject: [PATCH] =?UTF-8?q?[engine]=20=E4=BF=AE=E5=A4=8D=E9=AB=98=E7=BA=A7?= =?UTF-8?q?=E6=80=A7=E8=83=BD=E6=8C=87=E7=A4=BA=E5=99=A8=20Char=20Atlas=20?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E7=BB=9F=E8=AE=A1=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cocos2d/core/utils/profiler/CCProfiler.js | 23 ++++++++----------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/engine/cocos2d/core/utils/profiler/CCProfiler.js b/engine/cocos2d/core/utils/profiler/CCProfiler.js index 53311eb0..fe1c6324 100644 --- a/engine/cocos2d/core/utils/profiler/CCProfiler.js +++ b/engine/cocos2d/core/utils/profiler/CCProfiler.js @@ -82,24 +82,19 @@ function generateStats () { }, human() { const atlases = cc.Label._shareAtlas.atlases; + const chars = cc.Label._shareAtlas._fontDefDictionary._letterDefinitions; + const oneOfMax = atlases.reduce((a, b) => a + b._width * b._height, 0) / atlases.length; let used = 0; let usedLess = 0; - for (const atlas of atlases) { - const max = atlas._width * atlas._height; - let _used = atlas._width * atlas._nexty; - for (const area of atlas.frees) { - _used -= area._width * area._height; + for (const key in chars) { + const char = chars[key]; + const size = char._height * char._width; + usedLess += size; + if (char.ref > 0) { + used += size; } - let _usedLess = _used; - for (const area of atlas.waitCleans) { - if (area.ref === 0) { - _usedLess -= area._width * area._height; - } - } - used += _used / max; - usedLess += _usedLess / max; } - return `${(usedLess / atlases.length).toFixed(2)} / ${(used / atlases.length).toFixed(2)} / ${atlases.length}`; + return `${(used / oneOfMax).toFixed(2)} / ${(usedLess / oneOfMax).toFixed(2)} / ${atlases.length}`; } }, };