[gnome-shell] iconGrid: Only animate items when we actually need it
- From: Marge Bot <marge-bot src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell] iconGrid: Only animate items when we actually need it
- Date: Wed, 3 Mar 2021 18:03:31 +0000 (UTC)
commit 7f996550673ea417a1f0618a883d9275ae0e93cf
Author: Jonas Dreßler <verdre v0yd nl>
Date: Wed Feb 24 11:29:46 2021 +0100
iconGrid: Only animate items when we actually need it
Animating items of the iconGrid involves calling a few more C functions,
which is quite slow. Especially calling ClutterActor.set_easing_delay()
is slow because we override that function in JS to adjust for the
animation slow-down factor. So add a small class variable to make sure
we only animate the icons of the grid when we actually need it.
This makes the average time spent in vfunc_allocate() of the iconGrid go
down to about 0.7 ms.
Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1713>
js/ui/iconGrid.js | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
---
diff --git a/js/ui/iconGrid.js b/js/ui/iconGrid.js
index 0fc37a49c5..0272c0e233 100644
--- a/js/ui/iconGrid.js
+++ b/js/ui/iconGrid.js
@@ -790,6 +790,7 @@ var IconGridLayout = GObject.registerClass({
const pageHeight = this._pageHeight;
const pageSizeChanged = this._pageSizeChanged;
const lastRowAlign = this.lastRowAlign;
+ const shouldEaseItems = this._shouldEaseItems;
this._pages.forEach((page, pageIndex) => {
if (isRtl && orientation === Clutter.Orientation.HORIZONTAL)
@@ -826,8 +827,7 @@ var IconGridLayout = GObject.registerClass({
Math.max(childSize, naturalWidth),
Math.max(childSize, naturalHeight));
- // Only ease icons when the page size didn't change
- if (pageSizeChanged)
+ if (!shouldEaseItems || pageSizeChanged)
item.allocate(childBox);
else if (animateIconPosition(item, childBox, nChangedIcons))
nChangedIcons++;
@@ -835,6 +835,7 @@ var IconGridLayout = GObject.registerClass({
});
this._pageSizeChanged = false;
+ this._shouldEaseItems = false;
this._runPostAllocation();
}
@@ -863,6 +864,8 @@ var IconGridLayout = GObject.registerClass({
if (!this._container)
return;
+ this._shouldEaseItems = true;
+
this._container.add_child(item);
this._addItemToPage(item, page, index);
}
@@ -889,6 +892,8 @@ var IconGridLayout = GObject.registerClass({
if (!this._items.has(item))
throw new Error(`Item ${item} is not part of the IconGridLayout`);
+ this._shouldEaseItems = true;
+
this._removeItemData(item);
this._addItemToPage(item, newPage, newPosition);
}
@@ -906,6 +911,8 @@ var IconGridLayout = GObject.registerClass({
if (!this._container)
return;
+ this._shouldEaseItems = true;
+
this._container.remove_child(item);
this._removeItemData(item);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]