Commit Graph

11 Commits

Author SHA1 Message Date
Timm Bäder
0a6ed12d56 builtinicon: remove unused struct member 2016-10-18 00:29:17 +02:00
Timm Bäder
601839c825 Remove various sizing related style properties 2016-10-16 18:17:21 +02:00
Christian Hergert
f165bbda57 builtinicon: avoid calculating font-metrics in vast majority of cases
We perform lots of gadget allocations that require allocating a
GtkBuiltinIcon. One notable example is the scrollbar for a scrolled
window.

In the process of doing this, we often calculate baseline information that
isn't necessary. With how much this code path gets exercised, its worth
catching the result for the common case, which is that the font-description
has not changed and we are using the default language the application
was started with.

This simply caches the previous result and verifies that we can reuse it
with pango_font_description_hash() and a simple language check.

Numbers below are scrolling through a textview with GDK_KEY_Down.

Before:
      SELF CUMULATIVE    FUNCTION
[   0.08%] [   9.26%]    gtk_builtin_icon_get_preferred_size
[   0.01%] [   8.82%]      pango_context_get_metrics
[   0.02%] [   0.16%]      gtk_widget_get_pango_context
[   0.06%] [   0.06%]      pango_context_get_language
[   0.01%] [   0.02%]      g_type_check_instance_cast
[   0.02%] [   0.02%]      strlen
[   0.02%] [   0.02%]      pango_context_get_font_description
[   0.02%] [   0.02%]      g_list_foreach
[   0.01%] [   0.01%]      gtk_css_style_get_value
[   0.01%] [   0.01%]      itemize_with_font
[   0.01%] [   0.01%]      pango_context_get_type
[   0.01%] [   0.01%]      get_base_metrics
[   0.00%] [   0.01%]      pango_font_metrics_unref
[   0.01%] [   0.01%]      g_list_free
[   0.01%] [   0.01%]      gtk_builtin_icon_get_type

After:
      SELF CUMULATIVE    FUNCTION
[   0.08%] [   0.18%]    gtk_builtin_icon_get_preferred_size
[   0.02%] [   0.02%]      pango_font_description_hash
[   0.00%] [   0.02%]      gtk_widget_get_pango_context
[   0.00%] [   0.02%]        g_object_get_qdata
[   0.00%] [   0.02%]          g_datalist_id_get_data
[   0.02%] [   0.02%]      gtk_builtin_icon_get_type
[   0.01%] [   0.01%]      pango_context_get_font_description
[   0.00%] [   0.01%]      - - kernel - -
[   0.01%] [   0.01%]      pango_context_get_language
[   0.00%] [   0.01%]      gtk_css_style_get_value
[   0.00%] [   0.01%]      gtk_css_gadget_get_style

https://bugzilla.gnome.org/show_bug.cgi?id=765486
2016-04-25 16:13:06 -04:00
Matthias Clasen
da30858ee4 builtin icon: set a baseline
Most uses of builtin icons (check and radio buttons,
expanders, etc) are placed next to labels, so they should
be properly positioned wrt to the baseline. Lacking anything
better, give the builtin icons a baseline that places the
center of the icon at the strikethrough position.
2016-01-17 21:02:18 -05:00
Matthias Clasen
64b499be66 builtin icon: Don't save/restore cairo state
The reason why this was introduced is now handled in
gtk_css_stylke_render_icon since commit
0138af9f96.
2016-01-13 00:01:14 -05:00
Matthias Clasen
5f330418ae Add some docs to GtkBuiltinIcon 2015-12-22 15:03:15 -05:00
Chun-wei Fan
7a05432843 gtk/gtkbuiltinicon.c: Fix build
The gtk_builtin_icon_get_default_size_property returns a const char *,
in a way such that some compilers insist that something that is of a
pointer value be returned, so fix that by replacing 0 with NULL.
2015-12-22 16:35:58 +08:00
Cosimo Cecchi
aadc13c4ec builtinicon: save/restore cairo context when rendering 2015-12-19 21:22:37 -08:00
Benjamin Otte
36653bea41 checkbutton: Use a builtin icon
Also, add support to uiltin icons to look up the default size from a
style property.
2015-12-16 19:55:50 +01:00
Benjamin Otte
fab181fcfa builtinicon: Change the way size is handled
Make min-width/height have preference over the set default size. This
allows shrinking the widget. The default size is only used if min-width
is not set (or explicitly set to 0.
2015-12-16 04:46:23 +01:00
Benjamin Otte
9d56a076cc gadget: Add builtin icon gadget
This is to be used in all the places where we now call
gtk_render_activity()/option()/check() etc that in turn call the icon
render function.
2015-12-16 04:46:23 +01:00