MCPcopy
hub / github.com/apache/echarts / printSingleCanvasLayer

Function printSingleCanvasLayer

test/lib/testHelper.js:2273–2334  ·  view source on GitHub ↗
(layerId, layer, frameNumber)

Source from the content-addressed store, hash-verified

2271 }
2272
2273 function printSingleCanvasLayer(layerId, layer, frameNumber) {
2274 var layerInfo = _drawOpCtx.layersInfoMap[layerId];
2275 if (!layerInfo) {
2276 layerInfo = _drawOpCtx.layersInfoMap[layerId] = {
2277 recordLineCellCount: 0,
2278 recordLineTitle: document.createElement('span'),
2279 recordLineAvg: document.createElement('span'),
2280 recordLineContainer: document.createElement('div')
2281 };
2282 layerInfo.stackLengthRecord = [];
2283 layerInfo.stackLengthSumInWindow = 0;
2284 layerInfo.stackLengthMax = 0;
2285 layerInfo.recordLineTitle.innerHTML = 'layer ' + layerId + ': ';
2286 layerInfo.recordLineTitle.className = 'print-canvas-layer-draw-operations-on-frame-record-line-title';
2287 layerInfo.recordLineAvg.className = 'print-canvas-layer-draw-operations-on-frame-record-line-title';
2288 layerInfo.recordLineContainer.className = 'print-canvas-layer-draw-operations-on-frame-record-line';
2289 var titleLineDom = document.createElement('div');
2290 titleLineDom.appendChild(layerInfo.recordLineTitle);
2291 titleLineDom.appendChild(layerInfo.recordLineAvg);
2292 _drawOpCtx.recordContainer.appendChild(titleLineDom);
2293 _drawOpCtx.recordContainer.appendChild(layerInfo.recordLineContainer);
2294 }
2295
2296 var canvas = layer.dom;
2297 var ctx = canvas.getContext('2d');
2298 var stackLength = getStackLength(ctx);
2299 var thisStackLength = stackLength;
2300
2301 if (thisStackLength > layerInfo.stackLengthMax) {
2302 layerInfo.stackLengthMax = thisStackLength;
2303 }
2304
2305 layerInfo.stackLengthRecord.push(thisStackLength);
2306 layerInfo.stackLengthSumInWindow += thisStackLength;
2307 if (layerInfo.stackLengthRecord.length > _drawOpCtx.CELL_MAX) {
2308 layerInfo.stackLengthSumInWindow -= layerInfo.stackLengthRecord[0];
2309 layerInfo.stackLengthRecord.shift();
2310 }
2311 var avgStackLength = (layerInfo.stackLengthSumInWindow / layerInfo.stackLengthRecord.length).toFixed(2);
2312 layerInfo.recordLineAvg.innerHTML =
2313 '  (avg: ' + avgStackLength
2314 + ' = ' + layerInfo.stackLengthSumInWindow + ' / ' + layerInfo.stackLengthRecord.length
2315 + '    max: ' + layerInfo.stackLengthMax + ')';
2316
2317 var cell;
2318 if (layerInfo.recordLineCellCount > _drawOpCtx.CELL_MAX) {
2319 cell = layerInfo.recordLineContainer.firstChild;
2320 }
2321 else {
2322 cell = document.createElement('span');
2323 layerInfo.recordLineCellCount++;
2324 }
2325 cell.innerHTML = frameNumber + ':<span class="print-canvas-layer-draw-operations-on-frame-cmd-count">' + thisStackLength + '</span> ';
2326 layerInfo.recordLineContainer.appendChild(cell);
2327
2328 if (ctx.stack) {
2329 _lastOps[layerId] = ctx.stack().slice();
2330 }

Callers 1

doPrintFunction · 0.85

Calls 4

getStackLengthFunction · 0.85
getContextMethod · 0.80
toFixedMethod · 0.80
clearMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…