Encapsulate debug overlayData
Signed-off-by: Neil Guertin <neil.guertin@collabora.com> Change-Id: I768562e7e4a17d65338d0f5a64c4346e2f09f53f
This commit is contained in:
parent
6f749b1055
commit
e54ab27957
3 changed files with 18 additions and 22 deletions
|
@ -140,17 +140,6 @@ L.DebugManager = L.Class.extend({
|
|||
onAdd: function () {
|
||||
self.overlayOn = true;
|
||||
self.overlayData = {};
|
||||
var names = ['canonicalViewId', 'tileCombine', 'fromKeyInputToInvalidate', 'ping', 'loadCount', 'postMessage'];
|
||||
for (var i = 0; i < names.length; i++) {
|
||||
self.overlayData[names[i]] = L.control.attribution({prefix: '', position: 'bottomleft'}).addTo(self._map);
|
||||
self.overlayData[names[i]].addTo(self._map);
|
||||
}
|
||||
names = ['nullUpdateMetric', 'newTileMetric'];
|
||||
for (var i = 0; i < names.length; i++) {
|
||||
self.overlayData[names[i]] = L.control.attribution({prefix: '', position: 'topleft'}).addTo(self._map);
|
||||
self.overlayData[names[i]].addTo(self._map);
|
||||
self.overlayData[names[i]]._container.style.fontSize = '14px';
|
||||
}
|
||||
},
|
||||
onRemove: function () {
|
||||
self.overlayOn = false;
|
||||
|
@ -565,9 +554,15 @@ L.DebugManager = L.Class.extend({
|
|||
}
|
||||
},
|
||||
|
||||
setOverlayPostMessage: function(type,msg) {
|
||||
setOverlayMessage: function(id, message) {
|
||||
if (this.overlayOn) {
|
||||
this.overlayData['postMessage'].setPrefix(type+': '+ msg);
|
||||
if (!this.overlayData[id]) {
|
||||
var topLeftNames = ['nullUpdateMetric', 'newTileMetric'];
|
||||
var position = topLeftNames.includes(id) ? 'topleft' : 'bottomleft';
|
||||
this.overlayData[id] = L.control.attribution({prefix: '', position: position});
|
||||
this.overlayData[id].addTo(this._map);
|
||||
}
|
||||
this.overlayData[id].setPrefix(message);
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -589,16 +584,16 @@ L.DebugManager = L.Class.extend({
|
|||
|
||||
|
||||
_overlayShowTileData: function() {
|
||||
this.overlayData['loadCount'].setPrefix(
|
||||
this.setOverlayMessage('loadCount',
|
||||
'Total of requested tiles: ' + this._debugInvalidateCount + ', ' +
|
||||
'recv-tiles: ' + this._debugLoadTile + ', ' +
|
||||
'recv-delta: ' + this._debugLoadDelta + ', ' +
|
||||
'recv-update: ' + this._debugLoadUpdate);
|
||||
var allDeltas = this._debugLoadDelta + this._debugLoadUpdate;
|
||||
this.overlayData['nullUpdateMetric'].setPrefix(
|
||||
this.setOverlayMessage('nullUpdateMetric',
|
||||
'<b>Tile update waste: ' + Math.round(100.0 * this._debugLoadUpdate / allDeltas) + '%</b>'
|
||||
);
|
||||
this.overlayData['newTileMetric'].setPrefix(
|
||||
this.setOverlayMessage('newTileMetric',
|
||||
'<b>New Tile ratio: ' + Math.round(100.0 * this._debugLoadTile / (allDeltas + this._debugLoadTile)) + '%</b>'
|
||||
);
|
||||
},
|
||||
|
@ -631,7 +626,7 @@ L.DebugManager = L.Class.extend({
|
|||
}
|
||||
}
|
||||
if (this.overlayOn) {
|
||||
this.overlayData['tileCombine'].setPrefix(messages);
|
||||
this.setOverlayMessage('tileCombine',messages);
|
||||
this._overlayShowTileData();
|
||||
}
|
||||
},
|
||||
|
@ -658,7 +653,7 @@ L.DebugManager = L.Class.extend({
|
|||
var oldestKeypress = this._debugKeypressQueue.shift();
|
||||
if (oldestKeypress) {
|
||||
var timeText = this.updateTimeArray(this._debugTimeKeypress, now - oldestKeypress);
|
||||
this.overlayData['fromKeyInputToInvalidate'].setPrefix(
|
||||
this.setOverlayMessage('fromKeyInputToInvalidate',
|
||||
'Elapsed time between key input and next invalidate: ' + timeText
|
||||
);
|
||||
}
|
||||
|
|
|
@ -291,8 +291,9 @@ app.definitions.Socket = L.Class.extend({
|
|||
|
||||
var debugOn = this._map._debug.debugOn;
|
||||
|
||||
if (debugOn)
|
||||
this._map._debug.setOverlayPostMessage(type,msg);
|
||||
if (this._map._debug.overlayOn) {
|
||||
this._map._debug.setOverlayMessage('postMessage',type+': '+msg);
|
||||
}
|
||||
|
||||
if (!debugOn && msg.length > 256) // for reasonable performance.
|
||||
msg = msg.substring(0,256) + '<truncated ' + (msg.length - 256) + 'chars>';
|
||||
|
@ -1074,7 +1075,7 @@ app.definitions.Socket = L.Class.extend({
|
|||
var times = this._map._debug._debugTimePING;
|
||||
var timeText = this._map._debug.updateTimeArray(times, +new Date() - this._map._debug._debugPINGQueue.shift());
|
||||
if (this._map._debug.overlayOn) {
|
||||
this._map._debug.overlayData['ping'].setPrefix(
|
||||
this._map._debug.setOverlayMessage('ping',
|
||||
'Server ping time: ' + timeText + '. ' +
|
||||
'Rendered tiles: ' + command.rendercount + ', ' +
|
||||
'last: ' + (command.rendercount - this._map._debug._debugRenderCount)
|
||||
|
|
|
@ -1776,7 +1776,7 @@ L.CanvasTileLayer = L.Layer.extend({
|
|||
if (this._debug.overlayOn) {
|
||||
var viewId = payload.split('=')[1].split(' ')[0];
|
||||
var canonicalId = payload.split('=')[2].split(' ')[0];
|
||||
this._debug.overlayData['canonicalViewId'].setPrefix(
|
||||
this._debug.setOverlayMessage('canonicalViewId',
|
||||
'Canonical id changed to: ' + canonicalId + ' for view id: ' + viewId + ' with view renderend state: ' + viewRenderedState
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue