iconGrid: Eliminate JavaScript for painting/picking
The only reason for `vfunc_paint` and `vfunc_pick` existing was to implement a culling optimization. Although that optimization actually made performance worse than none at all because it forced the painting and picking cycles to spend more time calling into JavaScript. Turns out we don't have to choose between native code and culling though. Just reimplement the culling using native ClutterActor functions and we get the benefits of both. Performance on an i7-7700: Moving the cursor over the icon grid: Before: 70% CPU, 5.5ms per frame After : 60% CPU, 4.5ms per frame Scrolling the icon grid: Before: 60% CPU, 4.4ms per frame After : 50% CPU, 3.3ms per frame Helps with https://gitlab.gnome.org/GNOME/gnome-shell/issues/174
This commit is contained in:
parent
4c11d15a07
commit
0e0574a0b4
@ -344,10 +344,10 @@ var IconGrid = new Lang.Class({
|
||||
|
||||
if (this._rowLimit && rowIndex >= this._rowLimit ||
|
||||
this._fillParent && childBox.y2 > availHeight - this.bottomPadding) {
|
||||
children[i]._skipPaint = true;
|
||||
children[i].hide();
|
||||
} else {
|
||||
children[i].allocate(childBox, flags);
|
||||
children[i]._skipPaint = false;
|
||||
children[i].show();
|
||||
}
|
||||
|
||||
columnIndex++;
|
||||
@ -365,24 +365,6 @@ var IconGrid = new Lang.Class({
|
||||
}
|
||||
},
|
||||
|
||||
vfunc_paint() {
|
||||
this.paint_background();
|
||||
|
||||
this.get_children().forEach(c => {
|
||||
if (!c._skipPaint)
|
||||
c.paint();
|
||||
});
|
||||
},
|
||||
|
||||
vfunc_pick(color) {
|
||||
this.parent(color);
|
||||
|
||||
this.get_children().forEach(c => {
|
||||
if (!c._skipPaint)
|
||||
c.paint();
|
||||
});
|
||||
},
|
||||
|
||||
vfunc_get_paint_volume(paintVolume) {
|
||||
// Setting the paint volume does not make sense when we don't have
|
||||
// any allocation
|
||||
@ -412,9 +394,6 @@ var IconGrid = new Lang.Class({
|
||||
if (!child.visible)
|
||||
continue;
|
||||
|
||||
if (child._skipPaint)
|
||||
continue;
|
||||
|
||||
let childVolume = child.get_transformed_paint_volume(this);
|
||||
if (!childVolume)
|
||||
return false
|
||||
@ -714,7 +693,7 @@ var IconGrid = new Lang.Class({
|
||||
},
|
||||
|
||||
visibleItemsCount() {
|
||||
return this.get_children().filter(c => !c._skipPaint).length;
|
||||
return this.get_children().filter(c => c.is_visible()).length;
|
||||
},
|
||||
|
||||
setSpacing(spacing) {
|
||||
@ -859,7 +838,7 @@ var PaginatedIconGrid = new Lang.Class({
|
||||
for (let i = 0; i < children.length; i++) {
|
||||
let childBox = this._calculateChildBox(children[i], x, y, box);
|
||||
children[i].allocate(childBox, flags);
|
||||
children[i]._skipPaint = false;
|
||||
children[i].show();
|
||||
|
||||
columnIndex++;
|
||||
if (columnIndex == nColumns) {
|
||||
|
Loading…
Reference in New Issue
Block a user