mirror of
https://github.com/cocos/cocos4.git
synced 2026-12-01 15:52:40 +08:00
fix conflict
This commit is contained in:
+66
-41
@@ -59,6 +59,14 @@ var _quat_temp = math.quat.create();
|
||||
var _parents = [];
|
||||
var _globalOrderOfArrival = 1;
|
||||
|
||||
const POSITION_DIRTY_FLAG = 1 << 0;
|
||||
const SCALE_DIRTY_FLAG = 1 << 1;
|
||||
const ROTATION_DIRTY_FLAG = 1 << 2;
|
||||
const SKEW_DIRTY_FLAG = 1 << 3;
|
||||
// rotation transform dirty
|
||||
const RT_DIRTY_FLAG = SCALE_DIRTY_FLAG | ROTATION_DIRTY_FLAG | SKEW_DIRTY_FLAG;
|
||||
const ALL_DIRTY_FLAG = 0xffff;
|
||||
|
||||
/**
|
||||
* !#en The event type supported by Node
|
||||
* !#zh Node 支持的事件类型
|
||||
@@ -433,7 +441,7 @@ var Node = cc.Class({
|
||||
}
|
||||
|
||||
localPosition.x = value;
|
||||
this.setLocalDirty();
|
||||
this.setLocalDirty(POSITION_DIRTY_FLAG);
|
||||
|
||||
// fast check event
|
||||
var cache = this._hasListenerCache;
|
||||
@@ -476,7 +484,7 @@ var Node = cc.Class({
|
||||
}
|
||||
|
||||
localPosition.y = value;
|
||||
this.setLocalDirty();
|
||||
this.setLocalDirty(POSITION_DIRTY_FLAG);
|
||||
|
||||
// fast check event
|
||||
var cache = this._hasListenerCache;
|
||||
@@ -506,7 +514,7 @@ var Node = cc.Class({
|
||||
if (value !== localPosition.z) {
|
||||
if (!CC_EDITOR || isFinite(value)) {
|
||||
localPosition.z = value;
|
||||
this.setLocalDirty();
|
||||
this.setLocalDirty(POSITION_DIRTY_FLAG);
|
||||
}
|
||||
else {
|
||||
cc.error(ERR_INVALID_NUMBER, 'new z');
|
||||
@@ -536,7 +544,7 @@ var Node = cc.Class({
|
||||
this._rotationX = this._rotationY = value;
|
||||
// Update quaternion from rotation
|
||||
math.quat.fromEuler(this._quat, 0, 0, -value);
|
||||
this.setLocalDirty();
|
||||
this.setLocalDirty(ROTATION_DIRTY_FLAG);
|
||||
|
||||
var cache = this._hasListenerCache;
|
||||
if (cache && cache[ROTATION_CHANGED]) {
|
||||
@@ -569,7 +577,7 @@ var Node = cc.Class({
|
||||
else {
|
||||
math.quat.fromEuler(this._quat, value, this._rotationY, 0);
|
||||
}
|
||||
this.setLocalDirty();
|
||||
this.setLocalDirty(ROTATION_DIRTY_FLAG);
|
||||
|
||||
var cache = this._hasListenerCache;
|
||||
if (cache && cache[ROTATION_CHANGED]) {
|
||||
@@ -602,7 +610,7 @@ var Node = cc.Class({
|
||||
else {
|
||||
math.quat.fromEuler(this._quat, this._rotationX, value, 0);
|
||||
}
|
||||
this.setLocalDirty();
|
||||
this.setLocalDirty(ROTATION_DIRTY_FLAG);
|
||||
|
||||
var cache = this._hasListenerCache;
|
||||
if (cache && cache[ROTATION_CHANGED]) {
|
||||
@@ -637,7 +645,7 @@ var Node = cc.Class({
|
||||
set (value) {
|
||||
if (this._scale.x !== value) {
|
||||
this._scale.x = value;
|
||||
this.setLocalDirty();
|
||||
this.setLocalDirty(SCALE_DIRTY_FLAG);
|
||||
|
||||
var cache = this._hasListenerCache;
|
||||
if (cache && cache[SCALE_CHANGED]) {
|
||||
@@ -663,7 +671,7 @@ var Node = cc.Class({
|
||||
set (value) {
|
||||
if (this._scale.y !== value) {
|
||||
this._scale.y = value;
|
||||
this.setLocalDirty();
|
||||
this.setLocalDirty(SCALE_DIRTY_FLAG);
|
||||
|
||||
var cache = this._hasListenerCache;
|
||||
if (cache && cache[SCALE_CHANGED]) {
|
||||
@@ -688,7 +696,7 @@ var Node = cc.Class({
|
||||
},
|
||||
set (value) {
|
||||
this._skewX = value;
|
||||
this.setLocalDirty();
|
||||
this.setLocalDirty(SKEW_DIRTY_FLAG);
|
||||
}
|
||||
},
|
||||
|
||||
@@ -707,7 +715,7 @@ var Node = cc.Class({
|
||||
},
|
||||
set (value) {
|
||||
this._skewY = value;
|
||||
this.setLocalDirty();
|
||||
this.setLocalDirty(SKEW_DIRTY_FLAG);
|
||||
}
|
||||
},
|
||||
|
||||
@@ -920,10 +928,9 @@ var Node = cc.Class({
|
||||
|
||||
this._matrix = mathPools.mat4.get();
|
||||
this._worldMatrix = mathPools.mat4.get();
|
||||
this._= new Float32Array(16);
|
||||
this._localMatDirty = false;
|
||||
this._localMatDirty = 0;
|
||||
this._worldMatDirty = false;
|
||||
this.setLocalDirty();
|
||||
this.setLocalDirty(ALL_DIRTY_FLAG);
|
||||
|
||||
this._cullingMask = 1 << this.groupIndex;
|
||||
},
|
||||
@@ -1523,7 +1530,7 @@ var Node = cc.Class({
|
||||
*/
|
||||
setPosition (newPosOrX, y) {
|
||||
var x;
|
||||
if (typeof y === 'undefined') {
|
||||
if (y === undefined) {
|
||||
x = newPosOrX.x;
|
||||
y = newPosOrX.y;
|
||||
}
|
||||
@@ -1552,7 +1559,7 @@ var Node = cc.Class({
|
||||
else {
|
||||
return cc.error(ERR_INVALID_NUMBER, 'y of new position');
|
||||
}
|
||||
this.setLocalDirty();
|
||||
this.setLocalDirty(POSITION_DIRTY_FLAG);
|
||||
|
||||
// fast check event
|
||||
var cache = this._hasListenerCache;
|
||||
@@ -1594,7 +1601,7 @@ var Node = cc.Class({
|
||||
* node.setScale(1, 1);
|
||||
*/
|
||||
setScale (scaleX, scaleY) {
|
||||
if (typeof scaleX === 'object') {
|
||||
if (scaleX && typeof scaleX !== 'number') {
|
||||
scaleY = scaleX.y;
|
||||
scaleX = scaleX.x;
|
||||
}
|
||||
@@ -1604,7 +1611,7 @@ var Node = cc.Class({
|
||||
if (this._scale.x !== scaleX || this._scale.y !== scaleY) {
|
||||
this._scale.x = scaleX;
|
||||
this._scale.y = scaleY;
|
||||
this.setLocalDirty();
|
||||
this.setLocalDirty(SCALE_DIRTY_FLAG);
|
||||
|
||||
var cache = this._hasListenerCache;
|
||||
if (cache && cache[SCALE_CHANGED]) {
|
||||
@@ -1742,7 +1749,7 @@ var Node = cc.Class({
|
||||
locAnchorPoint.x = point;
|
||||
locAnchorPoint.y = y;
|
||||
}
|
||||
this.setLocalDirty();
|
||||
this.setLocalDirty(POSITION_DIRTY_FLAG);
|
||||
this.emit(ANCHOR_CHANGED);
|
||||
},
|
||||
|
||||
@@ -1809,7 +1816,7 @@ var Node = cc.Class({
|
||||
else {
|
||||
math.vec3.copy(this._position, pos);
|
||||
}
|
||||
this.setLocalDirty();
|
||||
this.setLocalDirty(POSITION_DIRTY_FLAG);
|
||||
|
||||
// fast check event
|
||||
var cache = this._hasListenerCache;
|
||||
@@ -1921,10 +1928,14 @@ var Node = cc.Class({
|
||||
},
|
||||
|
||||
_updateLocalMatrix () {
|
||||
if (this._localMatDirty) {
|
||||
// Update transform
|
||||
let t = this._matrix;
|
||||
//math.mat4.fromRTS(t, this._quat, this._position, this._scale);
|
||||
let dirtyFlag = this._localMatDirty;
|
||||
if (!dirtyFlag) return;
|
||||
|
||||
// Update transform
|
||||
let t = this._matrix;
|
||||
//math.mat4.fromRTS(t, this._quat, this._position, this._scale);
|
||||
|
||||
if (dirtyFlag & RT_DIRTY_FLAG) {
|
||||
let hasRotation = this._rotationX || this._rotationY;
|
||||
let hasSkew = this._skewX || this._skewY;
|
||||
let sx = this._scale.x, sy = this._scale.y;
|
||||
@@ -1972,14 +1983,15 @@ var Node = cc.Class({
|
||||
t.m04 = 0;
|
||||
t.m05 = sy;
|
||||
}
|
||||
// position
|
||||
t.m12 = this._position.x;
|
||||
t.m13 = this._position.y;
|
||||
|
||||
this._localMatDirty = false;
|
||||
// Register dirty status of world matrix so that it can be recalculated
|
||||
this._worldMatDirty = true;
|
||||
}
|
||||
|
||||
// position
|
||||
t.m12 = this._position.x;
|
||||
t.m13 = this._position.y;
|
||||
|
||||
this._localMatDirty = 0;
|
||||
// Register dirty status of world matrix so that it can be recalculated
|
||||
this._worldMatDirty = true;
|
||||
},
|
||||
|
||||
_calculWorldMatrix () {
|
||||
@@ -1989,16 +2001,29 @@ var Node = cc.Class({
|
||||
}
|
||||
|
||||
// Assume parent world matrix is correct
|
||||
if (this._parent) {
|
||||
let pt = this._parent._worldMatrix;
|
||||
let wt = this._worldMatrix;
|
||||
let parent = this._parent;
|
||||
if (parent) {
|
||||
let pt = parent._worldMatrix;
|
||||
let t = this._matrix;
|
||||
wt.m00 = t.m00 * pt.m00 + t.m01 * pt.m04;
|
||||
wt.m01 = t.m00 * pt.m01 + t.m01 * pt.m05;
|
||||
wt.m04 = t.m04 * pt.m00 + t.m05 * pt.m04;
|
||||
wt.m05 = t.m04 * pt.m01 + t.m05 * pt.m05;
|
||||
wt.m12 = t.m12 * pt.m00 + t.m13 * pt.m04 + pt.m12;
|
||||
wt.m13 = t.m12 * pt.m01 + t.m13 * pt.m05 + pt.m13;
|
||||
let wt = this._worldMatrix;
|
||||
let aa=t.m00, ab=t.m01, ac=t.m04, ad=t.m05, atx=t.m12, aty=t.m13;
|
||||
let ba=pt.m00, bb=pt.m01, bc=pt.m04, bd=pt.m05, btx=pt.m12, bty=pt.m13;
|
||||
if (bb !== 0 || bc !== 0) {
|
||||
wt.m00 = aa * ba + ab * bc;
|
||||
wt.m01 = aa * bb + ab * bd;
|
||||
wt.m04 = ac * ba + ad * bc;
|
||||
wt.m05 = ac * bb + ad * bd;
|
||||
wt.m12 = ba * atx + bc * aty + btx;
|
||||
wt.m13 = bb * atx + bd * aty + bty;
|
||||
}
|
||||
else {
|
||||
wt.m00 = aa * ba;
|
||||
wt.m01 = ab * bd;
|
||||
wt.m04 = ac * ba;
|
||||
wt.m05 = ad * bd;
|
||||
wt.m12 = ba * atx + btx;
|
||||
wt.m13 = bd * aty + bty;
|
||||
}
|
||||
}
|
||||
else {
|
||||
math.mat4.copy(this._worldMatrix, this._matrix);
|
||||
@@ -2020,11 +2045,11 @@ var Node = cc.Class({
|
||||
}
|
||||
},
|
||||
|
||||
setLocalDirty () {
|
||||
setLocalDirty (flag) {
|
||||
if (!this._localMatDirty) {
|
||||
this._localMatDirty = true;
|
||||
this.setWorldDirty();
|
||||
}
|
||||
this._localMatDirty = this._localMatDirty | flag;
|
||||
},
|
||||
|
||||
setWorldDirty () {
|
||||
|
||||
@@ -56,6 +56,26 @@ let RenderTexture = cc.Class({
|
||||
this.emit("load");
|
||||
},
|
||||
|
||||
/**
|
||||
* !#en Draw a texture to the specified position
|
||||
* !#zh 将指定的图片渲染到指定的位置上
|
||||
* @param {Texture2D} texture
|
||||
* @param {Number} x
|
||||
* @param {Number} y
|
||||
*/
|
||||
drawTextureAt (texture, x, y) {
|
||||
if (!texture._image) return;
|
||||
|
||||
this._texture.updateSubImage({
|
||||
x, y,
|
||||
image: texture._image,
|
||||
width: texture.width,
|
||||
height: texture.height,
|
||||
level: 0,
|
||||
flipY: false
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* !#en
|
||||
* Get pixels from render texture, the pixels data stores in a RGBA Uint8Array.
|
||||
|
||||
@@ -158,6 +158,9 @@ var SpriteFrame = cc.Class(/** @lends cc.SpriteFrame# */{
|
||||
this._texture = null;
|
||||
this._textureFilename = '';
|
||||
|
||||
// store original info before packed to dynamic atlas
|
||||
this._original = null;
|
||||
|
||||
if (CC_EDITOR) {
|
||||
// Atlas asset uuid
|
||||
this._atlasUuid = '';
|
||||
|
||||
@@ -464,9 +464,9 @@ var Sprite = cc.Class({
|
||||
* @param state {Sprite.State} NORMAL or GRAY State.
|
||||
*/
|
||||
setState: function (state) {
|
||||
if (this._state === state) return;
|
||||
this._state = state;
|
||||
this._material = null;
|
||||
this._activateMaterial();
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -483,8 +483,6 @@ var Sprite = cc.Class({
|
||||
|
||||
this._updateAssembler();
|
||||
|
||||
this._activateMaterial();
|
||||
|
||||
this.node.on('size-changed', this._onNodeSizeDirty, this);
|
||||
this.node.on('anchor-changed', this._onNodeSizeDirty, this);
|
||||
},
|
||||
@@ -517,40 +515,45 @@ var Sprite = cc.Class({
|
||||
},
|
||||
|
||||
_activateMaterial: function () {
|
||||
if (this._material) return;
|
||||
|
||||
let spriteFrame = this._spriteFrame;
|
||||
// cannot be activated if texture not loaded yet
|
||||
if (!this._spriteFrame || !this._spriteFrame.textureLoaded()) {
|
||||
if (!spriteFrame || !spriteFrame.textureLoaded()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Get material
|
||||
if (!this._material) {
|
||||
let texture = this._spriteFrame.getTexture();
|
||||
let url = texture.url;
|
||||
let key = url;
|
||||
if (this._state === State.GRAY) {
|
||||
key = url + ':gray';
|
||||
}
|
||||
if (this._state === State.GRAY) {
|
||||
this._material = new GraySpriteMaterial();
|
||||
}
|
||||
else {
|
||||
this._material = new SpriteMaterial();
|
||||
}
|
||||
// TODO: old texture in material have been released by loader
|
||||
this._material.texture = texture;
|
||||
let texture = spriteFrame.getTexture();
|
||||
let url = texture.url;
|
||||
let key = url;
|
||||
if (this._state === State.GRAY) {
|
||||
key = url + ':gray';
|
||||
}
|
||||
|
||||
let material;
|
||||
if (this._state === State.GRAY) {
|
||||
material = new GraySpriteMaterial();
|
||||
}
|
||||
else {
|
||||
material = new SpriteMaterial();
|
||||
}
|
||||
// TODO: old texture in material have been released by loader
|
||||
material.texture = texture;
|
||||
|
||||
if (this.srcBlendFactor !== gfx.BLEND_SRC_ALPHA || this.dstBlendFactor !== gfx.BLEND_ONE_MINUS_SRC_ALPHA) {
|
||||
// Update hash inside
|
||||
this._updateBlendFunc();
|
||||
}
|
||||
else {
|
||||
this._material.updateHash();
|
||||
material.updateHash();
|
||||
}
|
||||
|
||||
if (this._renderData) {
|
||||
this._renderData.material = this._material;
|
||||
this._renderData.material = material;
|
||||
}
|
||||
|
||||
this._material = material;
|
||||
},
|
||||
|
||||
_updateBlendFunc: function () {
|
||||
@@ -632,10 +635,7 @@ var Sprite = cc.Class({
|
||||
if (!this.isValid) {
|
||||
return;
|
||||
}
|
||||
// Reactivate material
|
||||
if (this.enabledInHierarchy) {
|
||||
this._activateMaterial();
|
||||
}
|
||||
|
||||
this._applySpriteSize();
|
||||
},
|
||||
|
||||
|
||||
@@ -250,7 +250,7 @@ var NodeActivator = cc.Class({
|
||||
if (cc.engine._isPlaying || comp.constructor._executeInEditMode) {
|
||||
if (!(comp._objFlags & IsPreloadStarted)) {
|
||||
comp._objFlags |= IsPreloadStarted;
|
||||
if (typeof comp.__preload === 'function') {
|
||||
if (comp.__preload) {
|
||||
if (preloadInvoker) {
|
||||
preloadInvoker.add(comp);
|
||||
}
|
||||
@@ -285,7 +285,7 @@ var NodeActivator = cc.Class({
|
||||
} : function (comp, preloadInvoker, onLoadInvoker, onEnableInvoker) {
|
||||
if (!(comp._objFlags & IsPreloadStarted)) {
|
||||
comp._objFlags |= IsPreloadStarted;
|
||||
if (typeof comp.__preload === 'function') {
|
||||
if (comp.__preload) {
|
||||
if (preloadInvoker) {
|
||||
preloadInvoker.add(comp);
|
||||
}
|
||||
@@ -337,7 +337,7 @@ var NodeActivator = cc.Class({
|
||||
},
|
||||
|
||||
resetComp: CC_EDITOR && function (comp) {
|
||||
if (typeof comp.resetInEditor === 'function') {
|
||||
if (comp.resetInEditor) {
|
||||
callResetInTryCatch(comp);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -232,7 +232,7 @@ var inputManager = {
|
||||
var docElem = document.documentElement;
|
||||
var leftOffset = window.pageXOffset - docElem.clientLeft;
|
||||
var topOffset = window.pageYOffset - docElem.clientTop;
|
||||
if (typeof element.getBoundingClientRect === 'function') {
|
||||
if (element.getBoundingClientRect) {
|
||||
var box = element.getBoundingClientRect();
|
||||
return {
|
||||
left: box.left + leftOffset,
|
||||
|
||||
@@ -92,7 +92,7 @@ cc.screen = /** @lends cc.screen# */{
|
||||
}
|
||||
}
|
||||
|
||||
this._supportsFullScreen = (typeof this._fn.requestFullscreen !== 'undefined');
|
||||
this._supportsFullScreen = (this._fn.requestFullscreen !== undefined);
|
||||
this._touchEvent = ('ontouchstart' in window) ? 'touchstart' : 'mousedown';
|
||||
},
|
||||
|
||||
|
||||
@@ -296,7 +296,7 @@ var _Deserializer = (function () {
|
||||
// 和 _deserializeObject 不同的地方在于会判断 id 和 uuid
|
||||
prototype._deserializeObjField = function (obj, jsonObj, propName, target, _stillUseUrl) {
|
||||
var id = jsonObj.__id__;
|
||||
if (typeof id === 'undefined') {
|
||||
if (id === undefined) {
|
||||
var uuid = jsonObj.__uuid__;
|
||||
if (uuid) {
|
||||
//if (ENABLE_TARGET) {
|
||||
@@ -413,7 +413,7 @@ var _Deserializer = (function () {
|
||||
for (var i = 0; i < fastDefinedProps.length; i++) {
|
||||
var propName = fastDefinedProps[i];
|
||||
var prop = serialized[propName];
|
||||
if (typeof prop !== 'undefined' && serialized.hasOwnProperty(propName)) {
|
||||
if (prop !== undefined && serialized.hasOwnProperty(propName)) {
|
||||
if (typeof prop !== 'object') {
|
||||
instance[propName] = prop;
|
||||
}
|
||||
@@ -612,7 +612,7 @@ var _Deserializer = (function () {
|
||||
|
||||
prop = d[propNameToRead];
|
||||
|
||||
if (typeof prop !== 'undefined') {
|
||||
if (prop !== undefined) {
|
||||
var stillUseUrl = attrs[propName + SAVE_URL_AS_ASSET];
|
||||
// function undefined object(null) string boolean number
|
||||
var defaultValue = CCClass.getDefault(attrs[propName + DEFAULT]);
|
||||
|
||||
@@ -269,7 +269,7 @@ var tmpGetSetDesc = {
|
||||
* @param {Object} obj
|
||||
* @param {String} prop
|
||||
* @param {Function} getter
|
||||
* @param {Function} setter
|
||||
* @param {Function} [setter=null]
|
||||
* @param {Boolean} [enumerable=false]
|
||||
*/
|
||||
js.getset = function (obj, prop, getter, setter, enumerable) {
|
||||
@@ -897,7 +897,7 @@ js.array = {
|
||||
* constructor(size: number)
|
||||
*/
|
||||
function Pool (cleanupFunc, size) {
|
||||
if (typeof cleanupFunc === 'number') {
|
||||
if (size === undefined) {
|
||||
size = cleanupFunc;
|
||||
cleanupFunc = null;
|
||||
}
|
||||
|
||||
@@ -27,12 +27,24 @@ const Sprite = require('../../../components/CCSprite');
|
||||
const FillType = Sprite.FillType;
|
||||
|
||||
const simpleRenderUtil = require('./simple');
|
||||
const dynamicAtlasManager = require('../../utils/dynamic-atlas/manager');
|
||||
|
||||
module.exports = {
|
||||
useModel: false,
|
||||
updateRenderData (sprite) {
|
||||
let frame = sprite.spriteFrame;
|
||||
|
||||
// 避免用户使用自定义 material 的情况下覆盖用户设置,不过这里还应该加一个 TODO,未来设计 material 的序列化和用户接口时,应该会有改动
|
||||
if (!sprite._material && frame) {
|
||||
// 尽可能避免函数调用的开销
|
||||
if (!frame._original) {
|
||||
dynamicAtlasManager.insertSpriteFrame(frame);
|
||||
}
|
||||
sprite._activateMaterial();
|
||||
}
|
||||
|
||||
let renderData = sprite._renderData;
|
||||
if (renderData && sprite._material) {
|
||||
if (renderData && frame) {
|
||||
let uvDirty = renderData.uvDirty,
|
||||
vertDirty = renderData.vertDirty;
|
||||
|
||||
|
||||
@@ -24,6 +24,8 @@
|
||||
****************************************************************************/
|
||||
|
||||
const Sprite = require('../../../components/CCSprite');
|
||||
const dynamicAtlasManager = require('../../utils/dynamic-atlas/manager');
|
||||
|
||||
const SpriteType = Sprite.Type;
|
||||
const FillType = Sprite.FillType;
|
||||
|
||||
@@ -35,6 +37,7 @@ const barFilledRenderUtil = require('./bar-filled');
|
||||
const meshRenderUtil = require('./mesh');
|
||||
|
||||
// Inline all type switch to avoid jit deoptimization during inlined function change
|
||||
|
||||
let spriteAssembler = {
|
||||
getAssembler (sprite) {
|
||||
let util = simpleRenderUtil;
|
||||
|
||||
@@ -23,7 +23,9 @@
|
||||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
|
||||
module.exports = {
|
||||
const dynamicAtlasManager = require('../../utils/dynamic-atlas/manager');
|
||||
|
||||
module.exports = {
|
||||
useModel: false,
|
||||
|
||||
createData (sprite) {
|
||||
@@ -31,9 +33,19 @@ module.exports = {
|
||||
},
|
||||
|
||||
updateRenderData (sprite) {
|
||||
let renderData = sprite._renderData;
|
||||
let frame = sprite.spriteFrame;
|
||||
if (renderData && frame && sprite._material) {
|
||||
|
||||
// 避免用户使用自定义 material 的情况下覆盖用户设置,不过这里还应该加一个 TODO,未来设计 material 的序列化和用户接口时,应该会有改动
|
||||
if (!sprite._material && frame) {
|
||||
// 尽可能避免函数调用的开销
|
||||
if (!frame._original) {
|
||||
dynamicAtlasManager.insertSpriteFrame(frame);
|
||||
}
|
||||
sprite._activateMaterial();
|
||||
}
|
||||
|
||||
let renderData = sprite._renderData;
|
||||
if (renderData && frame) {
|
||||
let vertices = frame.vertices;
|
||||
if (vertices) {
|
||||
if (renderData.vertexCount !== vertices.x.length) {
|
||||
@@ -168,5 +180,5 @@ module.exports = {
|
||||
for (let i = 0, l = triangles.length; i < l; i++) {
|
||||
ibuf[indiceOffset++] = vertexId + triangles[i];
|
||||
}
|
||||
}
|
||||
},
|
||||
};
|
||||
@@ -23,7 +23,7 @@
|
||||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
|
||||
const simpleRenderUtil = require('./simple');
|
||||
const dynamicAtlasManager = require('../../utils/dynamic-atlas/manager');
|
||||
|
||||
const PI_2 = Math.PI * 2;
|
||||
|
||||
@@ -43,9 +43,19 @@ module.exports = {
|
||||
},
|
||||
|
||||
updateRenderData (sprite) {
|
||||
let frame = sprite.spriteFrame;
|
||||
|
||||
// 避免用户使用自定义 material 的情况下覆盖用户设置,不过这里还应该加一个 TODO,未来设计 material 的序列化和用户接口时,应该会有改动
|
||||
if (!sprite._material && frame) {
|
||||
// 尽可能避免函数调用的开销
|
||||
if (!frame._original) {
|
||||
dynamicAtlasManager.insertSpriteFrame(frame);
|
||||
}
|
||||
sprite._activateMaterial();
|
||||
}
|
||||
|
||||
let renderData = sprite._renderData;
|
||||
let spriteFrame = sprite._spriteFrame;
|
||||
if (renderData && frame && sprite._material) {
|
||||
if (renderData && frame) {
|
||||
if (renderData.vertDirty || renderData.uvDirty) {
|
||||
let data = renderData._data;
|
||||
|
||||
@@ -344,5 +354,5 @@ module.exports = {
|
||||
for (let i = 0; i < count; i++) {
|
||||
ibuf[indiceOffset+i] = vertexId+i;
|
||||
}
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
@@ -24,13 +24,25 @@
|
||||
****************************************************************************/
|
||||
|
||||
const js = require('../../../platform/js');
|
||||
const dynamicAtlasManager = require('../../utils/dynamic-atlas/manager');
|
||||
|
||||
module.exports = {
|
||||
useModel: false,
|
||||
|
||||
|
||||
updateRenderData (sprite) {
|
||||
let frame = sprite.spriteFrame;
|
||||
|
||||
// 避免用户使用自定义 material 的情况下覆盖用户设置,不过这里还应该加一个 TODO,未来设计 material 的序列化和用户接口时,应该会有改动
|
||||
if (!sprite._material && frame) {
|
||||
// 尽可能避免函数调用的开销
|
||||
if (!frame._original) {
|
||||
dynamicAtlasManager.insertSpriteFrame(frame);
|
||||
}
|
||||
sprite._activateMaterial();
|
||||
}
|
||||
|
||||
let renderData = sprite._renderData;
|
||||
if (renderData && sprite._material) {
|
||||
if (renderData && frame) {
|
||||
if (renderData.uvDirty) {
|
||||
this.updateUVs(sprite);
|
||||
}
|
||||
|
||||
@@ -24,10 +24,9 @@
|
||||
****************************************************************************/
|
||||
|
||||
const Sprite = require('../../../components/CCSprite');
|
||||
const dynamicAtlasManager = require('../../utils/dynamic-atlas/manager');
|
||||
const FillType = Sprite.FillType;
|
||||
|
||||
const simpleRenderUtil = require('./simple');
|
||||
|
||||
module.exports = {
|
||||
useModel: false,
|
||||
|
||||
@@ -42,9 +41,20 @@ module.exports = {
|
||||
return renderData;
|
||||
},
|
||||
|
||||
updateRenderData (sprite) {
|
||||
updateRenderData (sprite, batchData) {
|
||||
let frame = sprite.spriteFrame;
|
||||
|
||||
// 避免用户使用自定义 material 的情况下覆盖用户设置,不过这里还应该加一个 TODO,未来设计 material 的序列化和用户接口时,应该会有改动
|
||||
if (!sprite._material && frame) {
|
||||
// 尽可能避免函数调用的开销
|
||||
if (!frame._original) {
|
||||
dynamicAtlasManager.insertSpriteFrame(frame);
|
||||
}
|
||||
sprite._activateMaterial();
|
||||
}
|
||||
|
||||
let renderData = sprite._renderData;
|
||||
if (renderData && sprite._material) {
|
||||
if (renderData) {
|
||||
if (renderData.uvDirty) {
|
||||
this.updateUVs(sprite);
|
||||
}
|
||||
|
||||
@@ -23,6 +23,8 @@
|
||||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
|
||||
const dynamicAtlasManager = require('../../utils/dynamic-atlas/manager');
|
||||
|
||||
module.exports = {
|
||||
useModel: false,
|
||||
|
||||
@@ -31,11 +33,21 @@ module.exports = {
|
||||
},
|
||||
|
||||
updateRenderData (sprite) {
|
||||
let frame = sprite.spriteFrame;
|
||||
|
||||
// 避免用户使用自定义 material 的情况下覆盖用户设置,不过这里还应该加一个 TODO,未来设计 material 的序列化和用户接口时,应该会有改动
|
||||
if (!sprite._material && frame) {
|
||||
// 尽可能避免函数调用的开销
|
||||
if (!frame._original) {
|
||||
dynamicAtlasManager.insertSpriteFrame(frame);
|
||||
}
|
||||
sprite._activateMaterial();
|
||||
}
|
||||
|
||||
let renderData = sprite._renderData;
|
||||
let material = sprite.getMaterial();
|
||||
if (renderData && material) {
|
||||
if (renderData) {
|
||||
if (renderData.uvDirty || renderData.vertDirty) {
|
||||
let texture = material.effect.getProperty('texture');
|
||||
let texture = frame._texture;
|
||||
let texw = texture._width,
|
||||
texh = texture._height;
|
||||
let frame = sprite.spriteFrame;
|
||||
@@ -206,5 +218,5 @@ module.exports = {
|
||||
ibuf[indiceOffset++] = vertexId+2;
|
||||
vertexId += 4;
|
||||
}
|
||||
}
|
||||
},
|
||||
};
|
||||
@@ -28,6 +28,8 @@ const renderEngine = require('./render-engine');
|
||||
const defaultVertexFormat = require('./vertex-format');
|
||||
const StencilManager = require('./stencil-manager');
|
||||
const hierarchyChain = require('./utils/hierarchy-chain');
|
||||
const atlasManager = require('./utils/dynamic-atlas/manager');
|
||||
|
||||
const gfx = renderEngine.gfx;
|
||||
const RecyclePool = renderEngine.RecyclePool;
|
||||
const InputAssembler = renderEngine.InputAssembler;
|
||||
@@ -365,6 +367,7 @@ RenderComponentWalker.prototype = {
|
||||
this._batchData.worldMatUpdated = false;
|
||||
}
|
||||
|
||||
atlasManager.update();
|
||||
this._flush();
|
||||
this._uploadData();
|
||||
}
|
||||
|
||||
@@ -15056,7 +15056,13 @@ var Model$2 = renderer.Model;
|
||||
var InputAssembler$2 = renderer.InputAssembler;
|
||||
|
||||
// Add stage to renderer
|
||||
renderer.addStage('transparent');
|
||||
if (renderer.config) {
|
||||
// JSB adaptation
|
||||
renderer.config.addStage('transparent');
|
||||
}
|
||||
else {
|
||||
renderer.addStage('transparent');
|
||||
}
|
||||
|
||||
var renderEngine = {
|
||||
// core classes
|
||||
|
||||
@@ -10045,7 +10045,13 @@ var Model = renderer.Model;
|
||||
var InputAssembler = renderer.InputAssembler;
|
||||
|
||||
// Add stage to renderer
|
||||
renderer.addStage('transparent');
|
||||
if (renderer.config) {
|
||||
// JSB adaptation
|
||||
renderer.config.addStage('transparent');
|
||||
}
|
||||
else {
|
||||
renderer.addStage('transparent');
|
||||
}
|
||||
|
||||
var renderEngine = {
|
||||
// core classes
|
||||
|
||||
@@ -0,0 +1,108 @@
|
||||
const space = 1;
|
||||
|
||||
class Atlas {
|
||||
constructor (width, height) {
|
||||
let texture = new cc.RenderTexture();
|
||||
texture.initWithSize(width, height);
|
||||
texture.update();
|
||||
|
||||
this._texture = texture;
|
||||
|
||||
this._x = space;
|
||||
this._y = space;
|
||||
this._nexty = space;
|
||||
|
||||
this._width = width;
|
||||
this._height = height;
|
||||
|
||||
this._innerTextureInfos = {};
|
||||
this._innerSpriteFrames = [];
|
||||
}
|
||||
|
||||
insertSpriteFrame (spriteFrame) {
|
||||
let rect = spriteFrame._rect,
|
||||
texture = spriteFrame._texture,
|
||||
info = this._innerTextureInfos[texture.__instanceId];
|
||||
|
||||
let sx = rect.x, sy = rect.y;
|
||||
|
||||
if (info) {
|
||||
rect.x += info.x;
|
||||
rect.y += info.y;
|
||||
}
|
||||
else {
|
||||
let width = texture.width, height = texture.height;
|
||||
|
||||
if ((this._x + width) > this._width) {
|
||||
this._x = space;
|
||||
this._y = this._nexty;
|
||||
}
|
||||
|
||||
if ((this._y + height) > this._nexty) {
|
||||
this._nexty = this._y + height;
|
||||
}
|
||||
|
||||
if (this._nexty > this._height) {
|
||||
return false;
|
||||
}
|
||||
|
||||
this._texture.drawTextureAt(texture, this._x, this._y);
|
||||
|
||||
this._innerTextureInfos[texture.__instanceId] = {
|
||||
x: this._x,
|
||||
y: this._y,
|
||||
texture: texture
|
||||
};
|
||||
|
||||
rect.x += this._x;
|
||||
rect.y += this._y;
|
||||
|
||||
this._x += width;
|
||||
|
||||
this._dirty = true;
|
||||
}
|
||||
|
||||
spriteFrame._original = {
|
||||
x: sx,
|
||||
y: sy,
|
||||
texture: spriteFrame._texture
|
||||
}
|
||||
|
||||
spriteFrame._texture = this._texture;
|
||||
|
||||
this._innerSpriteFrames.push(spriteFrame);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
update () {
|
||||
if (!this._dirty) return;
|
||||
this._texture.update();
|
||||
this._dirty = false;
|
||||
}
|
||||
|
||||
reset () {
|
||||
this._x = space;
|
||||
this._y = space;
|
||||
this._nexty = space;
|
||||
|
||||
let frames = this._innerSpriteFrames;
|
||||
for (let i = 0, l = frames.length; i < l; i++) {
|
||||
let frame = frames[i];
|
||||
let oriInfo = frame._original;
|
||||
frame._rect.x = oriInfo.x;
|
||||
frame._rect.y = oriInfo.y;
|
||||
frame._texture = oriInfo.texture;
|
||||
frame._original = null;
|
||||
}
|
||||
this._innerSpriteFrames.length = 0;
|
||||
this._innerTextureInfos = {};
|
||||
}
|
||||
|
||||
destroy () {
|
||||
this.reset();
|
||||
this._texture.destroy();
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Atlas;
|
||||
@@ -0,0 +1,211 @@
|
||||
const Atlas = require('./atlas');
|
||||
|
||||
let _atlases = [];
|
||||
let _atlasIndex = -1;
|
||||
|
||||
let _maxAtlasCount = 5;
|
||||
let _textureSize = 2048;
|
||||
let _maxFrameSize = 256;
|
||||
|
||||
let _enabled = false;
|
||||
|
||||
let _debugNode = null;
|
||||
|
||||
function newAtlas () {
|
||||
let atlas = new Atlas(_textureSize, _textureSize);
|
||||
_atlases.push(atlas);
|
||||
_atlasIndex++;
|
||||
return atlas;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* !#en Manager the dynamic atlas.
|
||||
* !#zh 管理动态图集。
|
||||
* @class DynamicAtlasManager
|
||||
*/
|
||||
let dynamicAtlasManager = {
|
||||
|
||||
/**
|
||||
* !#en Enabled or Disabled dynamic atlas.
|
||||
* !#zh 开启或者关闭动态图集。
|
||||
* @property enabled
|
||||
* @type {Boolean}
|
||||
*/
|
||||
get enabled () {
|
||||
return _enabled;
|
||||
},
|
||||
set enabled (value) {
|
||||
if (_enabled === value) return;
|
||||
|
||||
if (value) {
|
||||
this.reset();
|
||||
}
|
||||
_enabled = value;
|
||||
},
|
||||
|
||||
/**
|
||||
* !#en The maximum number of atlas that can be created.
|
||||
* !#zh 可以创建的最大图集数量。
|
||||
* @property maxAtlasCount
|
||||
* @type {Number}
|
||||
*/
|
||||
get maxAtlasCount () {
|
||||
return _maxAtlasCount;
|
||||
},
|
||||
set maxAtlasCount (value) {
|
||||
_maxAtlasCount = value;
|
||||
},
|
||||
|
||||
/**
|
||||
* !#en The size of the atlas that was created
|
||||
* !#zh 创建的图集的宽高
|
||||
* @property textureSize
|
||||
* @type {Number}
|
||||
*/
|
||||
get textureSize () {
|
||||
return _textureSize;
|
||||
},
|
||||
set textureSize (value) {
|
||||
_textureSize = value;
|
||||
},
|
||||
|
||||
/**
|
||||
* !#en The maximum size of the picture that can be added to the atlas.
|
||||
* !#zh 可以添加进图集的图片的最大尺寸。
|
||||
* @property maxFrameSize
|
||||
* @type {Number}
|
||||
*/
|
||||
get maxFrameSize () {
|
||||
return _maxFrameSize;
|
||||
},
|
||||
set maxFrameSize (value) {
|
||||
_maxFrameSize = value;
|
||||
},
|
||||
|
||||
/**
|
||||
* !#en Append a sprite frame into the dynamic atlas.
|
||||
* !#zh 添加碎图进入动态图集。
|
||||
* @method insertSpriteFrame
|
||||
* @param {SpriteFrame} spriteFrame
|
||||
*/
|
||||
insertSpriteFrame (spriteFrame) {
|
||||
if (CC_EDITOR) return;
|
||||
if (!this.enabled || _atlasIndex === _maxAtlasCount ||
|
||||
!spriteFrame || spriteFrame._original) return;
|
||||
|
||||
let texture = spriteFrame._texture;
|
||||
if (texture.width > _maxFrameSize || texture.height > _maxFrameSize) {
|
||||
return;
|
||||
}
|
||||
|
||||
let atlas = _atlases[_atlasIndex];
|
||||
if (!atlas) {
|
||||
atlas = newAtlas();
|
||||
}
|
||||
|
||||
if (!atlas.insertSpriteFrame(spriteFrame) && _atlasIndex !== _maxAtlasCount) {
|
||||
atlas = newAtlas();
|
||||
atlas.insertSpriteFrame(spriteFrame);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* !#en Resets all dynamic atlas, and the existing ones are not destroyed, but are reused.
|
||||
* !#zh 重置所有动态图集,已有的动态图集并不会被销毁,而是会被复用。
|
||||
* @method reset
|
||||
*/
|
||||
reset () {
|
||||
for (let i = 0; i <= _atlasIndex; i++) {
|
||||
_atlases[i].reset();
|
||||
}
|
||||
_atlasIndex = -1;
|
||||
},
|
||||
|
||||
/**
|
||||
* !#en Releases all dynamic atlas, which are destroyed.
|
||||
* !#zh 释放所有动态图集,这些图集会被销毁掉。
|
||||
* @method releaseAll
|
||||
*/
|
||||
releaseAll () {
|
||||
for (let i = 0, l = _atlases.length; i < l; i++) {
|
||||
_atlases[i].destroy();
|
||||
}
|
||||
_atlases.length = 0;
|
||||
_atlasIndex = -1;
|
||||
},
|
||||
|
||||
/**
|
||||
* !#en Displays all the dynamic atlas in the current scene, which you can use to view the current atlas state.
|
||||
* !#zh 在当前场景中显示所有动态图集,可以用来查看当前的合图状态。
|
||||
* @method showDebug
|
||||
* @param {Boolean} show
|
||||
*/
|
||||
showDebug: CC_DEV && function (show) {
|
||||
if (show) {
|
||||
if (!_debugNode) {
|
||||
let width = cc.visibleRect.width;
|
||||
let height = cc.visibleRect.height;
|
||||
|
||||
_debugNode = new cc.Node('DYNAMIC_ATLAS_DEBUG_NODE');
|
||||
_debugNode.width = width;
|
||||
_debugNode.height = height;
|
||||
_debugNode.x = width/2;
|
||||
_debugNode.y = height/2;
|
||||
_debugNode._zIndex = cc.macro.MAX_ZINDEX;
|
||||
_debugNode.parent = cc.director.getScene();
|
||||
|
||||
let scroll = _debugNode.addComponent(cc.ScrollView);
|
||||
|
||||
let content = new cc.Node('CONTENT');
|
||||
let layout = content.addComponent(cc.Layout);
|
||||
layout.type = cc.Layout.Type.VERTICAL;
|
||||
layout.resizeMode = cc.Layout.ResizeMode.CONTAINER;
|
||||
content.parent = _debugNode;
|
||||
|
||||
scroll.content = content;
|
||||
|
||||
for (let i = 0; i <= _atlasIndex; i++) {
|
||||
let node = new cc.Node('ATLAS');
|
||||
|
||||
let texture = _atlases[i]._texture;
|
||||
let spriteFrame = new cc.SpriteFrame();
|
||||
spriteFrame.setTexture(_atlases[i]._texture);
|
||||
|
||||
let sprite = node.addComponent(cc.Sprite)
|
||||
sprite.spriteFrame = spriteFrame;
|
||||
sprite.sizeMode = cc.Sprite.SizeMode.CUSTOM;
|
||||
|
||||
node.width = height;
|
||||
node.height = height;
|
||||
|
||||
node.parent = content;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (_debugNode) {
|
||||
_debugNode.parent = null;
|
||||
_debugNode = null;
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
update () {
|
||||
if (!this.enabled) return;
|
||||
|
||||
for (let i = 0; i <= _atlasIndex; i++) {
|
||||
_atlases[i].update();
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
/**
|
||||
* @module cc
|
||||
*/
|
||||
|
||||
/**
|
||||
* @property dynamicAtlasManager
|
||||
* @type DynamicAtlasManager
|
||||
*/
|
||||
module.exports = cc.dynamicAtlasManager = dynamicAtlasManager;
|
||||
@@ -311,7 +311,7 @@ var BaseNode = cc.Class({
|
||||
* @param {String} [name]
|
||||
*/
|
||||
ctor (name) {
|
||||
this._name = typeof name !== 'undefined' ? name : 'New Node';
|
||||
this._name = name !== undefined ? name : 'New Node';
|
||||
|
||||
this._activeInHierarchy = false;
|
||||
// Support for ActionManager and EventManager
|
||||
|
||||
@@ -121,8 +121,9 @@ function generateStats () {
|
||||
mode: { desc: cc.game.renderType === cc.game.RENDER_TYPE_WEBGL ? 'WebGL' : 'Canvas', min: 1 }
|
||||
};
|
||||
|
||||
let now = performance.now();
|
||||
for (let id in _stats) {
|
||||
_stats[id]._counter = new PerfCounter(id, _stats[id]);
|
||||
_stats[id]._counter = new PerfCounter(id, _stats[id], now);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -163,18 +164,20 @@ function generateNode () {
|
||||
function beforeUpdate () {
|
||||
generateNode();
|
||||
|
||||
_stats['frame']._counter.start();
|
||||
_stats['logic']._counter.start();
|
||||
let now = cc.director._lastUpdate;
|
||||
_stats['frame']._counter.start(now);
|
||||
_stats['logic']._counter.start(now);
|
||||
}
|
||||
|
||||
function afterUpdate () {
|
||||
let now = performance.now();
|
||||
if (cc.director.isPaused()) {
|
||||
_stats['frame']._counter.start();
|
||||
_stats['frame']._counter.start(now);
|
||||
}
|
||||
else {
|
||||
_stats['logic']._counter.end();
|
||||
_stats['logic']._counter.end(now);
|
||||
}
|
||||
_stats['render']._counter.start();
|
||||
_stats['render']._counter.start(now);
|
||||
}
|
||||
|
||||
function updateLabel (stat) {
|
||||
@@ -185,16 +188,17 @@ function updateLabel (stat) {
|
||||
}
|
||||
|
||||
function afterDraw () {
|
||||
_stats['render']._counter.end();
|
||||
let now = performance.now();
|
||||
_stats['render']._counter.end(now);
|
||||
_stats['draws']._counter.value = cc.renderer.drawCalls;
|
||||
_stats['frame']._counter.end();
|
||||
_stats['fps']._counter.frame();
|
||||
_stats['frame']._counter.end(now);
|
||||
_stats['fps']._counter.frame(now);
|
||||
|
||||
let left = '';
|
||||
let right = '';
|
||||
for (let id in _stats) {
|
||||
let stat = _stats[id];
|
||||
stat._counter.sample();
|
||||
stat._counter.sample(now);
|
||||
|
||||
left += stat.desc + '\n';
|
||||
right += stat._counter.human() + '\n';
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
class Counter {
|
||||
constructor(id, opts) {
|
||||
constructor(id, opts, now) {
|
||||
this._id = id;
|
||||
this._opts = opts || {};
|
||||
|
||||
@@ -8,15 +8,15 @@ class Counter {
|
||||
this._averageValue = 0;
|
||||
this._accumValue = 0;
|
||||
this._accumSamples = 0;
|
||||
this._accumStart = window.performance.now();
|
||||
this._accumStart = now;
|
||||
}
|
||||
|
||||
_average(v) {
|
||||
_average(v, now) {
|
||||
if (this._opts.average) {
|
||||
this._accumValue += v;
|
||||
++this._accumSamples;
|
||||
|
||||
let t = performance.now();
|
||||
let t = now;
|
||||
if (t - this._accumStart >= this._opts.average) {
|
||||
this._averageValue = this._accumValue / this._accumSamples;
|
||||
this._accumValue = 0;
|
||||
@@ -31,8 +31,8 @@ class Counter {
|
||||
this._value = v;
|
||||
}
|
||||
|
||||
sample() {
|
||||
this._average(this._value);
|
||||
sample(now) {
|
||||
this._average(this._value, now);
|
||||
}
|
||||
|
||||
human() {
|
||||
|
||||
@@ -1,25 +1,25 @@
|
||||
const Counter = require('./counter');
|
||||
|
||||
class PerfCounter extends Counter {
|
||||
constructor(id, opts) {
|
||||
super(id, opts);
|
||||
constructor(id, opts, now) {
|
||||
super(id, opts, now);
|
||||
|
||||
// DISABLE
|
||||
// this._idstart = `${id}_start`;
|
||||
// this._idend = `${id}_end`;
|
||||
|
||||
this._time = window.performance.now();
|
||||
this._time = now;
|
||||
}
|
||||
|
||||
start() {
|
||||
this._time = window.performance.now();
|
||||
start(now) {
|
||||
this._time = now;
|
||||
|
||||
// DISABLE: long time running will cause performance drop down
|
||||
// window.performance.mark(this._idstart);
|
||||
}
|
||||
|
||||
end() {
|
||||
this._value = window.performance.now() - this._time;
|
||||
end(now) {
|
||||
this._value = now - this._time;
|
||||
|
||||
// DISABLE: long time running will cause performance drop down
|
||||
// window.performance.mark(this._idend);
|
||||
@@ -33,8 +33,8 @@ class PerfCounter extends Counter {
|
||||
this.start();
|
||||
}
|
||||
|
||||
frame() {
|
||||
let t = window.performance.now();
|
||||
frame(now) {
|
||||
let t = now;
|
||||
let e = t - this._time;
|
||||
this._total++;
|
||||
let avg = this._opts.average || 1000;
|
||||
|
||||
Reference in New Issue
Block a user