mirror of
https://github.com/brl/mutter.git
synced 2024-11-26 18:11:05 -05:00
profile: Add profiling points for Text
Add a static timer for the text layout code, and two counters for the layout cache hit and miss conditions.
This commit is contained in:
parent
5608a54708
commit
73e4d49053
@ -53,9 +53,10 @@
|
|||||||
#include "clutter-enum-types.h"
|
#include "clutter-enum-types.h"
|
||||||
#include "clutter-keysyms.h"
|
#include "clutter-keysyms.h"
|
||||||
#include "clutter-main.h"
|
#include "clutter-main.h"
|
||||||
#include "clutter-private.h" /* includes pango/cogl-pango.h */
|
|
||||||
#include "clutter-units.h"
|
|
||||||
#include "clutter-marshal.h"
|
#include "clutter-marshal.h"
|
||||||
|
#include "clutter-private.h" /* includes pango/cogl-pango.h */
|
||||||
|
#include "clutter-profile.h"
|
||||||
|
#include "clutter-units.h"
|
||||||
|
|
||||||
/* cursor width in pixels */
|
/* cursor width in pixels */
|
||||||
#define DEFAULT_CURSOR_SIZE 2
|
#define DEFAULT_CURSOR_SIZE 2
|
||||||
@ -358,6 +359,14 @@ clutter_text_create_layout_no_cache (ClutterText *text,
|
|||||||
gchar *contents;
|
gchar *contents;
|
||||||
gsize contents_len;
|
gsize contents_len;
|
||||||
|
|
||||||
|
CLUTTER_STATIC_TIMER (text_layout_timer,
|
||||||
|
"Mainloop",
|
||||||
|
"Text Layout",
|
||||||
|
"Layout creation",
|
||||||
|
0);
|
||||||
|
|
||||||
|
CLUTTER_TIMER_START (_clutter_uprof_context, text_layout_timer);
|
||||||
|
|
||||||
layout = clutter_actor_create_pango_layout (CLUTTER_ACTOR (text), NULL);
|
layout = clutter_actor_create_pango_layout (CLUTTER_ACTOR (text), NULL);
|
||||||
pango_layout_set_font_description (layout, priv->font_desc);
|
pango_layout_set_font_description (layout, priv->font_desc);
|
||||||
|
|
||||||
@ -476,6 +485,8 @@ clutter_text_create_layout_no_cache (ClutterText *text,
|
|||||||
|
|
||||||
g_free (contents);
|
g_free (contents);
|
||||||
|
|
||||||
|
CLUTTER_TIMER_STOP (_clutter_uprof_context, text_layout_timer);
|
||||||
|
|
||||||
return layout;
|
return layout;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -532,6 +543,15 @@ clutter_text_create_layout (ClutterText *text,
|
|||||||
gboolean found_free_cache = FALSE;
|
gboolean found_free_cache = FALSE;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
CLUTTER_STATIC_COUNTER (text_cache_hit_counter,
|
||||||
|
"Text layout cache hit counter",
|
||||||
|
"Increments for each layout cache hit",
|
||||||
|
0);
|
||||||
|
CLUTTER_STATIC_COUNTER (text_cache_miss_counter,
|
||||||
|
"Text layout cache miss counter",
|
||||||
|
"Increments for each layout cache miss",
|
||||||
|
0);
|
||||||
|
|
||||||
/* Search for a cached layout with the same width and keep
|
/* Search for a cached layout with the same width and keep
|
||||||
* track of the oldest one
|
* track of the oldest one
|
||||||
*/
|
*/
|
||||||
@ -554,6 +574,8 @@ clutter_text_create_layout (ClutterText *text,
|
|||||||
allocation_width,
|
allocation_width,
|
||||||
allocation_height);
|
allocation_height);
|
||||||
|
|
||||||
|
CLUTTER_COUNTER_INC (_clutter_uprof_context, text_cache_hit_counter);
|
||||||
|
|
||||||
return priv->cached_layouts[i].layout;
|
return priv->cached_layouts[i].layout;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -581,27 +603,33 @@ clutter_text_create_layout (ClutterText *text,
|
|||||||
if (allocation_height == -1 &&
|
if (allocation_height == -1 &&
|
||||||
allocation_width == layout_width)
|
allocation_width == layout_width)
|
||||||
{
|
{
|
||||||
/* We've been asked for our height for the width we gave as a result
|
/* We've been asked for our height for the width we gave
|
||||||
* of a _get_preferred_width call
|
* as a result of a _get_preferred_width call
|
||||||
*/
|
*/
|
||||||
CLUTTER_NOTE (ACTOR, "ClutterText: %p: cache hit for size %.2fx%.2f " \
|
CLUTTER_NOTE (ACTOR,
|
||||||
|
"ClutterText: %p: cache hit for size %.2fx%.2f "
|
||||||
"(matches width of extents)",
|
"(matches width of extents)",
|
||||||
text,
|
text,
|
||||||
allocation_width,
|
allocation_width,
|
||||||
allocation_height);
|
allocation_height);
|
||||||
|
|
||||||
|
CLUTTER_COUNTER_INC (_clutter_uprof_context, text_cache_hit_counter);
|
||||||
|
|
||||||
return priv->cached_layouts[i].layout;
|
return priv->cached_layouts[i].layout;
|
||||||
}
|
}
|
||||||
else if (allocation_width == layout_width &&
|
else if (allocation_width == layout_width &&
|
||||||
allocation_height == layout_height)
|
allocation_height == layout_height)
|
||||||
{
|
{
|
||||||
/* We've been asked for width and height we gave before */
|
/* We've been asked for width and height we gave before */
|
||||||
CLUTTER_NOTE (ACTOR, "ClutterText: %p: cache hit for size %.2fx%.2f " \
|
CLUTTER_NOTE (ACTOR,
|
||||||
|
"ClutterText: %p: cache hit for size %.2fx%.2f "
|
||||||
"(matches size of extents)",
|
"(matches size of extents)",
|
||||||
text,
|
text,
|
||||||
allocation_width,
|
allocation_width,
|
||||||
allocation_height);
|
allocation_height);
|
||||||
|
|
||||||
|
CLUTTER_COUNTER_INC (_clutter_uprof_context, text_cache_hit_counter);
|
||||||
|
|
||||||
return priv->cached_layouts[i].layout;
|
return priv->cached_layouts[i].layout;
|
||||||
}
|
}
|
||||||
else if (!found_free_cache &&
|
else if (!found_free_cache &&
|
||||||
@ -617,6 +645,8 @@ clutter_text_create_layout (ClutterText *text,
|
|||||||
allocation_width,
|
allocation_width,
|
||||||
allocation_height);
|
allocation_height);
|
||||||
|
|
||||||
|
CLUTTER_COUNTER_INC (_clutter_uprof_context, text_cache_miss_counter);
|
||||||
|
|
||||||
/* If we make it here then we didn't have a cached version so we
|
/* If we make it here then we didn't have a cached version so we
|
||||||
need to recreate the layout */
|
need to recreate the layout */
|
||||||
if (oldest_cache->layout)
|
if (oldest_cache->layout)
|
||||||
|
Loading…
Reference in New Issue
Block a user