workspace: Use set_origin/set_size instead of properties when allocating

Setting four properties is more expensive than calling two C functions,
so move to set_origin()/set_size() calls for our ClutterActorBox
handling.

This gets us down to an average time of 2.1 ms spent in vfunc_allocate()
with 20 windows

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1743>
This commit is contained in:
Jonas Dreßler 2021-02-25 11:54:39 +01:00 committed by Marge Bot
parent e75f3a8aed
commit 3e9a08a2e1

View File

@ -635,10 +635,12 @@ var WorkspaceLayout = GObject.registerClass({
const windowInfo = this._windows.get(child); const windowInfo = this._windows.get(child);
if (windowInfo.metaWindow.showing_on_its_workspace()) { if (windowInfo.metaWindow.showing_on_its_workspace()) {
workspaceBox.x1 = child.boundingBox.x - this._workarea.x; workspaceBox.set_origin(
workspaceBox.x2 = workspaceBox.x1 + child.boundingBox.width; child.boundingBox.x - this._workarea.x,
workspaceBox.y1 = child.boundingBox.y - this._workarea.y; child.boundingBox.y - this._workarea.y);
workspaceBox.y2 = workspaceBox.y1 + child.boundingBox.height; workspaceBox.set_size(
child.boundingBox.width,
child.boundingBox.height);
} else { } else {
workspaceBox.set_origin(this._workarea.x, this._workarea.y); workspaceBox.set_origin(this._workarea.x, this._workarea.y);
workspaceBox.set_size(0, 0); workspaceBox.set_size(0, 0);
@ -659,10 +661,8 @@ var WorkspaceLayout = GObject.registerClass({
Math.max(workspaceBox.get_height(), height)); Math.max(workspaceBox.get_height(), height));
} }
layoutBox.x1 = x; layoutBox.set_origin(x, y);
layoutBox.x2 = layoutBox.x1 + width; layoutBox.set_size(width, height);
layoutBox.y1 = y;
layoutBox.y2 = layoutBox.y1 + height;
childBox = workspaceBox.interpolate(layoutBox, childBox = workspaceBox.interpolate(layoutBox,
this._stateAdjustment.value); this._stateAdjustment.value);