Files
palemoon27/devtools/server/primitive.js
roytam1 d6c5650b54 import changes from `dev' branch of rmottola/Arctic-Fox:
- Bug 1189759 - Part 1: Implement <xul:menuitem endimage> as a way to display an image at the end of a menu item; r=jaws (eb66e2b142)
- bits of Bug 880164 - Australis toolbar buttons contextual menu in toolbar, palette and customize mode (601529fa02)
- complete allTabs removal  initiate accidentally in  1228627 (11526f9be2)
- Bug 1189759 - Part 2: Add sound playing and muted icons to the all tabs menu; r=jaws (b3780a4080)
- Bug 1204845 - Remove the menuitem-iconic-both binding. r=enndeakin (1a6b49137f)
- Bug 897751 - Tab close button's DoubleClick protection handler leaks. r=mano (598ffd6ea0)
- Bug 1059600 - Set the URI as the initial tab label for javascript links opened in new tabs. r=gijs (a888e89683)
- Bug 1247920 - Remove tabs' visibleLabel property and TabLabelModified event, backing out bug 943820. r=gijs (f2a8c6c5b6)
- Bug 1196762 - Part 2: PrefsProvider and PlacesProvider messaging integration in RemoteAboutNewTab r=Mardak (40f298de12)
- Bug 1210478 - Add Meta URL resolution in RemoteNewTabLocation r=mconley (a9a7b774b2)
- Bug 1218996 - Fuse aboutNewTabService and RemoteNewTabLocation and return resource URLS r=marcosc (42f6909cc8)
- Bug 1218996 - Remove now redundant messaging code for remote newtab r=marcosc (50de90e6c9)
- Bug 1214287 - 2-4% linux64/win7/8 ts_paint regression on inbound (v.44) seen on Oct 12, 2015 from rev 3012b7a2c97c r=mconley (f7d4224141)
- assorted fixes to make newtab work (d5b208fc72)
- Bug 1169179 - Run mozscreenshots as a mochitest-browser-chrome test. r=felipe,glandium (6a9c3c896d)
- Bug 1216979 - Add ACCEL+ALT+R key binding to reload WebIDE. r=jryans (c7afde0f46)
- Bug 1204127 - Clean up paths added after migration. r=ochameau (9e35211636)
- Bug 1029371 - Make style editor media sidebar interact with media sidebar. r=bgrins r=paul r=mgoodwin (c166b888cb)
- Bug 1055333 - Enable last styleeditor e10s tests;r=ejpbruel (768bc3948b)
- Bug 1192486 - make completion work in any selected style editor; r=mratcliffe (fde809a65e)
- Bug 1206463 - Eslint cleanup for source editor r=mratcliffe (b8a2b7f0e7)
- Bug 1232786 - Convert JS tests to use open2 within devtools/ (r=sicking) (3c76f148d8)
- Bug 1235953 - Refactor responsive mode tests to use add_task to not use CPOWs and make sure they all wait for the off event. r=ochameau (ad4374ca81)
- Bug 1240183 - make styleeditor eslint-clean; r=pbro (37f17595ca)
- Bug 1162848 - Make console 'clear' shortcut ctrl+shift+l on Windows / Linux;r=jryans (1870519951)
- Bug 1245462 - Replace usages of gDevTools.jsm by module imports. r=jryans (7f967d5410)
- Bug 1244514 - webconsole.js eslint: fix spacing and line length; r=linclark (c98e3aeb07)
- Bug 1246188 - Make webconsole.js ESLint-clean. r=lclark (7dec42e75f)
- Bug 1249714 - Use jsterm.focus instead of inputNode.focus;r=linclark (60238ce0bd)
- Bug 1249715 - Split jsterm into different file than webconsole.js;r=linclark (b4560b21b4)
- Bug 1249714 - Use jsterm.focus instead of inputNode.focus;r=linclark (a01b4348f4)
- Bug 1248301 - Do not cause a horizontal scrollbar to appear in the console when it overflows vertically;r=vporof (2c86ffacbe)
- Bug 1228032 - restore chrome://global/skin/ where chrome://browser/skin/ was removed, r=jryans (5609017a31)
- Bug 1239437 - Delegate to empty, new responsive UI tool if enabled. r=pbrosset (e131d71fa6)
- Bug 1239437 - Add a basic viewport frame. r=pbrosset (82759cdcc3)
- Bug 1239437 - Hide iframe border. r=pbrosset (5668bd6171)
- Bug 1239437 - Stir in React and Redux. r=pbrosset,jlongster (c6ef09a7f7)
- Bug 1246733 - Remove stylesheet references of 'devtools/skin/common.css' and instead import it in theme files;r=ntim,r=ochameau (dd5c660185)
- Bug 1204429 - Part 1: Collect primitive counts information. r=vporof (bdaaad5c20)
- Bug 1204429 - Part 2: Add tests for counting number of primitives in WebGL draw functions. r=vporof (1a093ad855)
- Bug 1226245 - Make CallWatcher generic, r=jsantell (5771c8a173)
2024-01-25 12:03:08 +08:00

165 lines
4.2 KiB
JavaScript

/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict";
const { on, once, off, emit } = require("sdk/event/core");
const { Class } = require("sdk/core/heritage");
const WebGLPrimitivesType = {
"POINTS": 0,
"LINES": 1,
"LINE_LOOP": 2,
"LINE_STRIP": 3,
"TRIANGLES": 4,
"TRIANGLE_STRIP": 5,
"TRIANGLE_FAN": 6
};
/**
* A utility for monitoring WebGL primitive draws. Takes a `tabActor`
* and monitors primitive draws over time.
*/
const WebGLDrawArrays = "drawArrays";
const WebGLDrawElements = "drawElements";
var WebGLPrimitiveCounter = exports.WebGLPrimitiveCounter = Class({
initialize: function(tabActor) {
this.tabActor = tabActor;
},
destroy: function() {
this.stopRecording();
},
/**
* Starts monitoring primitive draws, storing the primitives count per tick.
*/
resetCounts: function() {
this._tris = 0;
this._vertices = 0;
this._points = 0;
this._lines = 0;
this._startTime = this.tabActor.docShell.now();
},
/**
* Stops monitoring primitive draws, returning the recorded values.
*/
getCounts: function() {
var result = {
tris: this._tris,
vertices: this._vertices,
points: this._points,
lines: this._lines
};
this._tris = 0;
this._vertices = 0;
this._points = 0;
this._lines = 0;
return result;
},
/**
* Handles WebGL draw primitive functions to catch primitive info.
*/
handleDrawPrimitive: function(functionCall) {
let { name, args } = functionCall.details;
if (name === WebGLDrawArrays) {
this._processDrawArrays(args);
} else if (name === WebGLDrawElements) {
this._processDrawElements(args);
}
},
/**
* Processes WebGL drawArrays method to count primitve numbers
*/
_processDrawArrays: function(args) {
let mode = args[0];
let count = args[2];
switch ( mode ) {
case WebGLPrimitivesType.POINTS:
this._vertices += count;
this._points += count;
break;
case WebGLPrimitivesType.LINES:
this._vertices += count;
this._lines += (count / 2);
break;
case WebGLPrimitivesType.LINE_LOOP:
this._vertices += count;
this._lines += count;
break;
case WebGLPrimitivesType.LINE_STRIP:
this._vertices += count;
this._lines += (count - 1);
break;
case WebGLPrimitivesType.TRIANGLES:
this._tris += (count / 3);
this._vertices += count;
break;
case WebGLPrimitivesType.TRIANGLE_STRIP:
this._tris += (count - 2);
this._vertices += count;
break;
case WebGLPrimitivesType.TRIANGLE_FAN:
this._tris += (count - 2);
this._vertices += count;
break;
default:
console.error("_processDrawArrays doesn't define this type.");
break;
}
},
/**
* Processes WebGL drawElements method to count primitve numbers
*/
_processDrawElements: function(args) {
let mode = args[0];
let count = args[1];
switch ( mode ) {
case WebGLPrimitivesType.POINTS:
this._vertices += count;
this._points += count;
break;
case WebGLPrimitivesType.LINES:
this._vertices += count;
this._lines += (count / 2);
break;
case WebGLPrimitivesType.LINE_LOOP:
this._vertices += count;
this._lines += count;
break;
case WebGLPrimitivesType.LINE_STRIP:
this._vertices += count;
this._lines += (count - 1);
break;
case WebGLPrimitivesType.TRIANGLES:
let tris = count / 3;
let vertex = tris * 3;
if (tris > 1) {
vertex = tris * 2;
}
this._tris += tris;
this._vertices += vertex;
break;
case WebGLPrimitivesType.TRIANGLE_STRIP:
this._tris += (count - 2);
this._vertices += count;
break;
case WebGLPrimitivesType.TRIANGLE_FAN:
this._tris += (count - 2);
this._vertices += count;
default:
console.error("_processDrawElements doesn't define this type.");
break;
}
}
});