This patch combines a number of fixes and improvements to the
layout caching logic in ClutterText.
* Fix: The width must always be set on the PangoLayout when painting.
This is necessary because the layout aligns in the width, and
even when we think we are left-aligned, the auto-dir feature
of PangoLayout may result in right-alignment.
* Fix: We should only ever try to reuse a cached layout based
on its logical width if layout.width was -1 when computing
that logical width. If the layout was already ellipsized,
then comparing the logical width to the new width we are
trying to wrap to doesn't make sense. (If "abc" ellipsizes
to a 15-pixel wide "..." for a width of 1 pixel, that doesn't
mean that we should use "..." for a width of 15 pixels. Maybe
"abc" itself is 15 pixels wide.)
* Improvement: rather than looking up cached layouts based on the
input allocation_width/allocation_height, look them up based
on the actual width/height/ellipsize that we pass to create
a layout. This is simpler and improves the chance we'll get
a cache hit when appropriate even if there are small floating
point differences.
Note because of the first fix this is less aggressive than dd40732
in caching layouts; get_preferred_width() and painting can't share
a layout since get_preferred_width() needs to pass a width of -1
to Pango and painting needs to pass the real width.
The patch has been updated from the clutter-1.2 branch to current
master; using the profiling instrumentation it is possible to verify
with test-text-field that the hit/miss counters go from:
Name Total Per Frame
---- ----- ---------
Text layout cache hit counter 13 6
Text layout cache miss counter 11 5
before applying the patch, to:
Name Total Per Frame
---- ----- ---------
Text layout cache miss counter 4 2
Text layout cache hit counter 3 1
after applying the patch.
https://bugzilla.gnome.org/show_bug.cgi?id=618104http://bugzilla.openedhand.com/show_bug.cgi?id=2109
Signed-off-by: Emmanuele Bassi <ebassi@linux.intel.com>