check scrollable elements for "clean" sides for CSR rendering.

This commit is contained in:
Christopher Jeffrey 2013-07-14 11:23:05 -05:00
parent 95848bafa3
commit fd5bd89d56

View File

@ -651,6 +651,53 @@ Screen.prototype.deleteTop = function(top, bottom) {
return this.deleteLine(1, top, top, bottom);
};
// Not exactly sure how worthwile this is.
// This will cause a performance/cpu-usage hit,
// but will it be less or greater than the
// performance hit of slow-rendering scrollable
// boxes with clean sides?
Screen.prototype.cleanSides = function(el) {
if (!el._lastPos) {
return false;
}
var pos = el._lastPos
, yi = pos.yi + (el.border ? 1 : 0) + el.padding
, yl = pos.yl - (el.border ? 1 : 0) - el.padding
, first = this.olines[yi][pos.xi - 1]
, ch
, x
, y;
if (pos._cleanSides != null) {
return pos._cleanSides;
}
if (pos.xi === 0 && pos.xl === this.width) {
return pos._cleanSides = true;
}
for (; y < yl; y++) {
for (x = pos.xi - 1; x >= 0; x--) {
ch = this.olines[y][x];
if (ch[0] !== first[0] || ch[1] !== first[1]) {
return pos._cleanSides = false;
}
}
}
for (; y < yl; y++) {
for (x = pos.xl; x < this.width; x++) {
ch = this.olines[y][x];
if (ch[0] !== first[0] || ch[1] !== first[1]) {
return pos._cleanSides = false;
}
}
}
return pos._cleanSides = true;
};
Screen.prototype.draw = function(start, end) {
var x
, y
@ -1960,6 +2007,7 @@ outer:
Box.prototype.insertLine = function(i, line) {
//if (typeof line === 'string') line = [line];
// if (this.screen.cleanSides(this)) {
if (this._lastPos && this._lastPos.xi === 0 && this._lastPos.xl === this.screen.width) {
i = Math.max(i, 0);
i = Math.min(i, this._lastPos.yl - this._lastPos.yi - (this.border ? 2 : 0) - this.padding * 2);
@ -1980,6 +2028,7 @@ Box.prototype.insertLine = function(i, line) {
Box.prototype.deleteLine = function(i) {
//if (typeof line === 'string') line = [line];
var reset = true;
// if (this.screen.cleanSides(this)) {
if (this._lastPos && this._lastPos.xi === 0 && this._lastPos.xl === this.screen.width) {
i = Math.max(i, 0);
i = Math.min(i, this._lastPos.yl - this._lastPos.yi - (this.border ? 2 : 0) - this.padding * 2);
@ -2156,6 +2205,7 @@ ScrollableBox.prototype.scroll = function(offset) {
// Optimize scrolling with CSR + IL/DL.
p = this._lastPos;
// if (this.childBase !== base && this.screen.cleanSides(this)) {
if (this.childBase !== base && p && (p.xl - p.xi) === this.screen.width) {
t = p.yi + (this.border ? 1 : 0) + this.padding;
b = p.yl - (this.border ? 1 : 0) - this.padding - 1;