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 608847 - st_widget_recompute_style triggers reallocation on map
st_widget_recompute_style triggers reallocation on map
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-03 00:20 UTC by Owen Taylor
Modified: 2010-02-03 22:35 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Improve handling of gradients (7.54 KB, patch)
2010-02-03 19:22 UTC, Florian Müllner
needs-work Details | Review
Improve handling of gradients (1.69 KB, patch)
2010-02-03 20:52 UTC, Florian Müllner
committed Details | Review

Description Owen Taylor 2010-02-03 00:20:13 UTC
Seen when debugging:

====
  • #26 clutter_stage_allocate
    at ./clutter-stage.c line 191
  • #27 clutter_actor_allocate
    at ./clutter-actor.c line 4809
  • #28 _clutter_stage_maybe_relayout
    at ./clutter-main.c line 203
  • #29 clutter_actor_get_allocation_box
    at ./clutter-actor.c line 4700
  • #30 st_widget_recompute_style
    at st/st-widget.c line 1528
  • #31 st_widget_map
    at st/st-widget.c line 577
  • #32 clutter_actor_set_mapped
    at ./clutter-actor.c line 644
  • #33 clutter_actor_update_map_state
    at ./clutter-actor.c line 864
  • #34 clutter_actor_update_map_state
    at ./clutter-actor.c line 839

This can cause effects like adding N items to a box triggering N complete reallocations of the stage. Calling clutter_actor_get_allocation_box() looks innocuous but ends up triggering some bad stuff.

What I'd like to see is the gradient be demands-redrawn just before painting, though this is a bit hard because ClutterCairoTexture queues a redraw every time it is drawn on. What I'd probably suggest is skipping the ClutterCairoTexture and drawing directly to an cairo_image_surface and creating the CoglTexture from that. 

This interacts with some of the stuff discussed in bug 607500 about moving painting of the background and border into StThemeNode.
Comment 1 Florian Müllner 2010-02-03 19:22:18 UTC
Created attachment 152956 [details] [review]
Improve handling of gradients

By calling clutter_actor_get_allocation() in st_widget_recompute_style()
to determine whether to redraw gradients, we triggered a complete
reallocation of the stage for each gradient.

As gradients are processed in st_widget_real_style_changed() anyway, the
additional checks in st_widget_recompute_style() are redundant and can
be removed altogether.

Also, in preparation to moving the actual drawing code to StThemeNode,
replace ClutterCairoTexture with plain cairo for the gradient drawing.
Comment 2 Florian Müllner 2010-02-03 19:38:55 UTC
(In reply to comment #1)
> Created an attachment (id=152956) [details] [review]
> Improve handling of gradients

The patch leaves the gradient drawing in st_widget_allocate() instead of moving it to st_widget_paint(), but otherwise follows the suggestions above.

As the changes to st_widget_recompute_style() should be enough for this bug, it might be a good idea to split the patch and attach the ClutterCairoTexture stuff to bug 607500 though ...
Comment 3 Owen Taylor 2010-02-03 19:40:08 UTC
Review of attachment 152956 [details] [review]:

Hmm, I'd really like to see this with only the fix, since there is a simple fix, and not pull in the conversion too.

One side-note about the conversion below for reference.

Also, my intent wasn't to move from ClutterCairoTexture to ClutterTexture, but to CoglTexture - if we manage a CoglTexture ourselves, we can just use it in paint() and not have to worry about allocating extra actors.

::: src/st/st-widget.c
@@ +734,3 @@
+  /* cogl doesn't seem to support the conversion, do it manually */
+  /* borrowed from clutter-cairo, conversion from ARGB pre-multiplied
+   * to RGBA */

This is supported in COGL now

@@ +779,3 @@
+  texture = cogl_texture_new_from_data (width, height,
+                                        COGL_TEXTURE_NONE,
+                                        COGL_PIXEL_FORMAT_RGBA_8888,

You'd just use COGL_PIXEL_FORMAT_ARGB_8888_PRE
Comment 4 Florian Müllner 2010-02-03 20:52:49 UTC
Created attachment 152966 [details] [review]
Improve handling of gradients

Stripped the conversion code.
Comment 5 Colin Walters 2010-02-03 22:19:14 UTC
Review of attachment 152966 [details] [review]:

Looks simple and correct.

But do you have any plans to update the gradient code to use a CoglHandle?  If so we should coordinate since I'd like to pick back up my borders work and there is a lot of overlap there.
Comment 6 Florian Müllner 2010-02-03 22:35:27 UTC
Attachment 152966 [details] pushed as fd1ce40 - Improve handling of gradients

(In reply to comment #5)
> But do you have any plans to update the gradient code to use a CoglHandle?  If
> so we should coordinate since I'd like to pick back up my borders work and
> there is a lot of overlap there.

Well, yes ... how about me updating the patch and attaching it to the other bug so you can pick it up there? Shouldn't take too much time ...