Skip to content

Commit

Permalink
Always update objects in render list. DO NOT try to optimize.
Browse files Browse the repository at this point in the history
  • Loading branch information
pissang committed Dec 6, 2017
1 parent c814016 commit ab37300
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 17 deletions.
7 changes: 5 additions & 2 deletions src/Painter.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import Layer from './Layer';
import requestAnimationFrame from './animation/requestAnimationFrame';
import Image from './graphic/Image';

var HOVER_LAYER_ZLEVEL = 1e5;

function parseInt10(val) {
return parseInt(val, 10);
}
Expand Down Expand Up @@ -302,7 +304,7 @@ Painter.prototype = {
// Use a extream large zlevel
// FIXME?
if (!hoverLayer) {
hoverLayer = this._hoverlayer = this.getLayer(1e5);
hoverLayer = this._hoverlayer = this.getLayer(HOVER_LAYER_ZLEVEL);
}

var scope = {};
Expand Down Expand Up @@ -334,7 +336,7 @@ Painter.prototype = {
},

getHoverLayer: function () {
return this._hoverlayer;
return this.getLayer(HOVER_LAYER_ZLEVEL);
},

_paintList: function (list, paintAll) {
Expand Down Expand Up @@ -455,6 +457,7 @@ Painter.prototype = {
if (!layer) {
// Create a new layer
layer = new Layer('zr_' + zlevel, this, this.dpr);
layer.zlevel = zlevel;
layer.__builtin__ = true;

if (this._layerConfig[zlevel]) {
Expand Down
18 changes: 3 additions & 15 deletions src/Storage.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@ Storage.prototype = {

constructor: Storage,

_needsUpdateList: true,

/**
* @param {Function} cb
*
Expand Down Expand Up @@ -73,23 +71,17 @@ Storage.prototype = {
* @param {boolean} [includeIgnore=false] 是否包含 ignore 的数组
*/
updateDisplayList: function (includeIgnore) {
if (this._needsUpdateList) {
this._displayListLen = 0;
}
this._displayListLen = 0;

var roots = this._roots;
var displayList = this._displayList;
for (var i = 0, len = roots.length; i < len; i++) {
this._updateAndAddDisplayable(roots[i], null, includeIgnore);
}

if (this._needsUpdateList) {
displayList.length = this._displayListLen;
}
displayList.length = this._displayListLen;

env.canvasSupported && timsort(displayList, shapeCompareFunc);

this._needsUpdateList = false;
},

_updateAndAddDisplayable: function (el, clipPaths, includeIgnore) {
Expand Down Expand Up @@ -156,9 +148,7 @@ Storage.prototype = {
else {
el.__clipPaths = clipPaths;

if (this._needsUpdateList) {
this._displayList[this._displayListLen++] = el;
}
this._displayList[this._displayListLen++] = el;
}
},

Expand Down Expand Up @@ -222,15 +212,13 @@ Storage.prototype = {
if (el) {
el.__storage = this;
el.dirty(false);
this._needsUpdateList = true;
}
return this;
},

delFromStorage: function (el) {
if (el) {
el.__storage = null;
this._needsUpdateList = true;
}

return this;
Expand Down

0 comments on commit ab37300

Please sign in to comment.