laya-coreui-es
Version:
laya核心库、ui库es版本,剔除了媒体、TTF等功能。基于 LayaAir-release_2.12.0 修改
101 lines (100 loc) • 4.24 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.QuickTestTool = void 0;
const Sprite_1 = require("../display/Sprite");
const SpriteConst_1 = require("../display/SpriteConst");
const Stage_1 = require("../display/Stage");
const RenderSprite_1 = require("../renders/RenderSprite");
const ILaya_1 = require("../../ILaya");
class QuickTestTool {
static getMCDName(type) {
return QuickTestTool._typeToNameDic[type];
}
static showRenderTypeInfo(type, force = false) {
if (!force && QuickTestTool.showedDic[type])
return;
QuickTestTool.showedDic[type] = true;
if (!QuickTestTool._rendertypeToStrDic[type]) {
var arr = [];
var tType;
tType = 1;
while (tType <= type) {
if (tType & type) {
arr.push(QuickTestTool.getMCDName(tType & type));
}
tType = tType << 1;
}
QuickTestTool._rendertypeToStrDic[type] = arr.join(",");
}
console.log("cmd:", QuickTestTool._rendertypeToStrDic[type]);
}
static __init__() {
QuickTestTool._typeToNameDic[SpriteConst_1.SpriteConst.ALPHA] = "ALPHA";
QuickTestTool._typeToNameDic[SpriteConst_1.SpriteConst.TRANSFORM] = "TRANSFORM";
QuickTestTool._typeToNameDic[SpriteConst_1.SpriteConst.TEXTURE] = "TEXTURE";
QuickTestTool._typeToNameDic[SpriteConst_1.SpriteConst.GRAPHICS] = "GRAPHICS";
QuickTestTool._typeToNameDic[SpriteConst_1.SpriteConst.ONECHILD] = "ONECHILD";
QuickTestTool._typeToNameDic[SpriteConst_1.SpriteConst.CHILDS] = "CHILDS";
QuickTestTool._typeToNameDic[SpriteConst_1.SpriteConst.TRANSFORM | SpriteConst_1.SpriteConst.ALPHA] = "TRANSFORM|ALPHA";
QuickTestTool._typeToNameDic[SpriteConst_1.SpriteConst.CANVAS] = "CANVAS";
QuickTestTool._typeToNameDic[SpriteConst_1.SpriteConst.BLEND] = "BLEND";
QuickTestTool._typeToNameDic[SpriteConst_1.SpriteConst.FILTERS] = "FILTERS";
QuickTestTool._typeToNameDic[SpriteConst_1.SpriteConst.MASK] = "MASK";
QuickTestTool._typeToNameDic[SpriteConst_1.SpriteConst.CLIP] = "CLIP";
QuickTestTool._typeToNameDic[SpriteConst_1.SpriteConst.LAYAGL3D] = "LAYAGL3D";
}
constructor() {
}
render(context, x, y) {
QuickTestTool._addType(this._renderType);
QuickTestTool.showRenderTypeInfo(this._renderType);
RenderSprite_1.RenderSprite.renders[this._renderType]._fun(this, context, x + this._x, y + this._y);
this._repaint = 0;
}
_stageRender(context, x, y) {
QuickTestTool._countStart();
QuickTestTool._PreStageRender.call(ILaya_1.ILaya.stage, context, x, y);
QuickTestTool._countEnd();
}
static _countStart() {
var key;
for (key in QuickTestTool._countDic) {
QuickTestTool._countDic[key] = 0;
}
}
static _countEnd() {
QuickTestTool._i++;
if (QuickTestTool._i > 60) {
QuickTestTool.showCountInfo();
QuickTestTool._i = 0;
}
}
static _addType(type) {
if (!QuickTestTool._countDic[type]) {
QuickTestTool._countDic[type] = 1;
}
else {
QuickTestTool._countDic[type] += 1;
}
}
static showCountInfo() {
console.log("===================");
var key;
for (key in QuickTestTool._countDic) {
console.log("count:" + QuickTestTool._countDic[key]);
QuickTestTool.showRenderTypeInfo(key, true);
}
}
static enableQuickTest() {
QuickTestTool.__init__();
Sprite_1.Sprite["prototype"]["render"] = QuickTestTool["prototype"]["render"];
QuickTestTool._PreStageRender = Stage_1.Stage["prototype"]["render"];
Stage_1.Stage["prototype"]["render"] = QuickTestTool["prototype"]["_stageRender"];
}
}
exports.QuickTestTool = QuickTestTool;
QuickTestTool.showedDic = {};
QuickTestTool._rendertypeToStrDic = {};
QuickTestTool._typeToNameDic = {};
QuickTestTool._countDic = {};
QuickTestTool._i = 0;