After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 608715 - StWidget: Don't redraw gradient when size doesn't change
StWidget: Don't redraw gradient when size doesn't change
Status: RESOLVED FIXED
Product: gnome-shell
Classification: Core
Component: general
unspecified
Other Linux
: Normal normal
: ---
Assigned To: gnome-shell-maint
gnome-shell-maint
Depends on:
Blocks:
 
 
Reported: 2010-02-01 19:23 UTC by Owen Taylor
Modified: 2010-02-01 23:19 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
[StWidget] Limit gradient redraws to size changes (1.99 KB, patch)
2010-02-01 21:31 UTC, Florian Müllner
needs-work Details | Review
[StWidget] Limit gradient redraws to size changes (2.20 KB, patch)
2010-02-01 23:12 UTC, Florian Müllner
committed Details | Review

Description Owen Taylor 2010-02-01 19:23:20 UTC
If we are animating a widget with a gradient moving around the screen, the widget will constantly be reallocated, but with the same size every time. This happens when entering and leaving the overview. In this case, we should avoid recreating and redrawing the gradient. (The biggest expense I'm seeing isn't recreating the gradient but uploading it as a texture, though I'm not quite sure why that is noticeably slow, since copying *into* video ram should be pretty fast.)
Comment 1 Florian Müllner 2010-02-01 21:31:10 UTC
Created attachment 152772 [details] [review]
[StWidget] Limit gradient redraws to size changes

When moving a widget with a gradient, its allocation changes
continuously, resulting in constant redraws.
Checking for actual size changes before the operation avoids
unnecessary redraws.
Comment 2 Owen Taylor 2010-02-01 22:41:02 UTC
Review of attachment 152772 [details] [review]:

Heh, came up with almost exactly the same patch, but then my computer crashed when I went to test it, and I got drawn off into a meeting. Patch looks good, just one comment based on comparison with my patch. If that makes sense to you and works out in testing, you can go ahead and commit with the change.

::: src/st/st-widget.c
@@ +336,3 @@
+
+      if (width > 0 && height > 0 &&
+          (old_width != (guint)width || old_height != (guint)height))

Though this patch doesn't make it worse, and should work, in general, I think the truncating cast from float width/height to integers isn't a great idea. I'd rather see something like:

-      float width, height;
+      guint width, height;

-      frame_box.x2 = width;
-      frame_box.y2 = height;
+      frame_box.x2 = box->x2 - box->x1;
+      frame_box.y2 = box->y2 - box->y1;
+
+      width = (guint)(0.5 + frame_box.x2);
+      height = (guint)(0.5 + frame_box.y2);

Then you can just compare with old_width, old_height directly.
Comment 3 Florian Müllner 2010-02-01 23:12:37 UTC
Created attachment 152783 [details] [review]
[StWidget] Limit gradient redraws to size changes

Updated patch according to Owen's suggestions.

Owen: Yeah, casting float to integer is kinda nasty - originally I
considered something along the lines of (fabs(width - old_width) > 0.1),
but your suggestion seems much more reasonable to me.
Comment 4 Florian Müllner 2010-02-01 23:19:10 UTC
Attachment 152783 [details] pushed as 3e19f41 - [StWidget] Limit gradient redraws to size changes