clutter/pango: Avoid going through global context
As we have access to the actor context in most of the cases except for render nodes. Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4077>
This commit is contained in:
parent
93a05a0631
commit
40e7998669
@ -746,6 +746,7 @@ clutter_text_node_draw (ClutterPaintNode *node,
|
||||
clutter_paint_context_get_color_state (paint_context);
|
||||
ClutterColorState *target_color_state =
|
||||
clutter_paint_context_get_target_color_state (paint_context);
|
||||
ClutterContext *context = _clutter_context_get_default ();
|
||||
PangoRectangle extents;
|
||||
CoglFramebuffer *fb;
|
||||
guint i;
|
||||
@ -786,7 +787,8 @@ clutter_text_node_draw (ClutterPaintNode *node,
|
||||
clipped = TRUE;
|
||||
}
|
||||
|
||||
clutter_show_layout (fb,
|
||||
clutter_show_layout (context,
|
||||
fb,
|
||||
tnode->layout,
|
||||
op->op.texrect[0],
|
||||
op->op.texrect[1],
|
||||
|
@ -917,6 +917,7 @@ clutter_text_create_layout (ClutterText *text,
|
||||
gfloat allocation_height)
|
||||
{
|
||||
ClutterTextPrivate *priv = clutter_text_get_instance_private (text);
|
||||
ClutterContext *context = clutter_actor_get_context (CLUTTER_ACTOR (text));
|
||||
LayoutCache *oldest_cache = priv->cached_layouts;
|
||||
gboolean found_free_cache = FALSE;
|
||||
gint width = -1;
|
||||
@ -1074,7 +1075,7 @@ clutter_text_create_layout (ClutterText *text,
|
||||
oldest_cache->layout =
|
||||
clutter_text_create_layout_no_cache (text, width, height, ellipsize);
|
||||
|
||||
clutter_ensure_glyph_cache_for_layout (oldest_cache->layout);
|
||||
clutter_ensure_glyph_cache_for_layout (context, oldest_cache->layout);
|
||||
|
||||
/* Mark the 'time' this cache was created and advance the time */
|
||||
oldest_cache->age = priv->cache_age++;
|
||||
@ -2005,7 +2006,7 @@ paint_selection_rectangle (ClutterText *self,
|
||||
color->blue / 255.0f,
|
||||
paint_opacity / 255.0f * color->alpha / 255.0f);
|
||||
|
||||
clutter_show_layout (fb, layout, priv->text_x, 0, &cogl_color,
|
||||
clutter_show_layout (context, fb, layout, priv->text_x, 0, &cogl_color,
|
||||
color_state, target_color_state);
|
||||
|
||||
cogl_framebuffer_pop_clip (fb);
|
||||
@ -2663,6 +2664,7 @@ clutter_text_paint (ClutterActor *self,
|
||||
{
|
||||
ClutterText *text = CLUTTER_TEXT (self);
|
||||
ClutterTextPrivate *priv = clutter_text_get_instance_private (text);
|
||||
ClutterContext *context = clutter_actor_get_context(self);
|
||||
ClutterColorState *color_state =
|
||||
clutter_paint_context_get_color_state (paint_context);
|
||||
ClutterColorState *target_color_state =
|
||||
@ -2832,7 +2834,7 @@ clutter_text_paint (ClutterActor *self,
|
||||
priv->text_color.blue / 255.0f,
|
||||
real_opacity / 255.0f);
|
||||
|
||||
clutter_show_layout (fb, layout, priv->text_x, priv->text_y, &color,
|
||||
clutter_show_layout (context, fb, layout, priv->text_x, priv->text_y, &color,
|
||||
color_state, target_color_state);
|
||||
|
||||
selection_paint (text, fb, paint_context);
|
||||
|
@ -46,6 +46,7 @@ PangoRenderer * clutter_pango_renderer_new (CoglContext *context);
|
||||
|
||||
/**
|
||||
* clutter_ensure_glyph_cache_for_layout:
|
||||
* @context: A #ClutterContext
|
||||
* @layout: A #PangoLayout
|
||||
*
|
||||
* This updates any internal glyph cache textures as necessary to be
|
||||
@ -54,10 +55,12 @@ PangoRenderer * clutter_pango_renderer_new (CoglContext *context);
|
||||
* This api should be used to avoid mid-scene modifications of
|
||||
* glyph-cache textures which can lead to undefined rendering results.
|
||||
*/
|
||||
void clutter_ensure_glyph_cache_for_layout (PangoLayout *layout);
|
||||
void clutter_ensure_glyph_cache_for_layout (ClutterContext *context,
|
||||
PangoLayout *layout);
|
||||
|
||||
/**
|
||||
* clutter_show_layout: (skip)
|
||||
* @context: A #ClutterContext
|
||||
* @framebuffer: A #CoglFramebuffer to draw too.
|
||||
* @layout: a #PangoLayout
|
||||
* @x: X coordinate to render the layout at
|
||||
@ -67,7 +70,8 @@ void clutter_ensure_glyph_cache_for_layout (PangoLayout *layout);
|
||||
* Draws a solidly coloured @layout on the given @framebuffer at (@x,
|
||||
* @y) within the `framebuffer`'s current model-view coordinate space.
|
||||
*/
|
||||
void clutter_show_layout (CoglFramebuffer *framebuffer,
|
||||
void clutter_show_layout (ClutterContext *context,
|
||||
CoglFramebuffer *framebuffer,
|
||||
PangoLayout *layout,
|
||||
float x,
|
||||
float y,
|
||||
|
@ -257,7 +257,8 @@ clutter_pango_render_qdata_destroy (PangoLayoutQdata *qdata)
|
||||
}
|
||||
|
||||
void
|
||||
clutter_show_layout (CoglFramebuffer *fb,
|
||||
clutter_show_layout (ClutterContext *context,
|
||||
CoglFramebuffer *fb,
|
||||
PangoLayout *layout,
|
||||
float x,
|
||||
float y,
|
||||
@ -267,9 +268,7 @@ clutter_show_layout (CoglFramebuffer *fb,
|
||||
{
|
||||
ClutterPangoRenderer *renderer;
|
||||
PangoLayoutQdata *qdata;
|
||||
ClutterContext *context;
|
||||
|
||||
context = _clutter_context_get_default ();
|
||||
renderer = CLUTTER_PANGO_RENDERER (clutter_context_get_font_renderer (context));
|
||||
if (G_UNLIKELY (!renderer))
|
||||
return;
|
||||
@ -298,7 +297,7 @@ clutter_show_layout (CoglFramebuffer *fb,
|
||||
|
||||
if (qdata->display_list == NULL)
|
||||
{
|
||||
clutter_ensure_glyph_cache_for_layout (layout);
|
||||
clutter_ensure_glyph_cache_for_layout (context, layout);
|
||||
|
||||
qdata->display_list =
|
||||
clutter_pango_display_list_new (renderer->pipeline_cache);
|
||||
@ -353,15 +352,11 @@ clutter_pango_renderer_get_cached_glyph (PangoRenderer *renderer,
|
||||
}
|
||||
|
||||
static void
|
||||
clutter_pango_ensure_glyph_cache_for_layout_line_internal (PangoLayoutLine *line)
|
||||
clutter_pango_ensure_glyph_cache_for_layout_line_internal (PangoRenderer *renderer,
|
||||
PangoLayoutLine *line)
|
||||
{
|
||||
ClutterContext *context;
|
||||
PangoRenderer *renderer;
|
||||
GSList *l;
|
||||
|
||||
context = _clutter_context_get_default ();
|
||||
renderer = clutter_context_get_font_renderer (context);
|
||||
|
||||
for (l = line->runs; l; l = l->next)
|
||||
{
|
||||
PangoLayoutRun *run = l->data;
|
||||
@ -386,14 +381,13 @@ clutter_pango_ensure_glyph_cache_for_layout_line_internal (PangoLayoutLine *line
|
||||
}
|
||||
|
||||
void
|
||||
clutter_ensure_glyph_cache_for_layout (PangoLayout *layout)
|
||||
clutter_ensure_glyph_cache_for_layout (ClutterContext *context,
|
||||
PangoLayout *layout)
|
||||
{
|
||||
ClutterContext *context;
|
||||
ClutterPangoRenderer *renderer;
|
||||
PangoRenderer *renderer;
|
||||
PangoLayoutIter *iter;
|
||||
|
||||
context = _clutter_context_get_default ();
|
||||
renderer = CLUTTER_PANGO_RENDERER (clutter_context_get_font_renderer (context));
|
||||
renderer = clutter_context_get_font_renderer (context);
|
||||
|
||||
g_return_if_fail (PANGO_IS_LAYOUT (layout));
|
||||
|
||||
@ -406,7 +400,7 @@ clutter_ensure_glyph_cache_for_layout (PangoLayout *layout)
|
||||
|
||||
line = pango_layout_iter_get_line_readonly (iter);
|
||||
|
||||
clutter_pango_ensure_glyph_cache_for_layout_line_internal (line);
|
||||
clutter_pango_ensure_glyph_cache_for_layout_line_internal (renderer, line);
|
||||
}
|
||||
while (pango_layout_iter_next_line (iter));
|
||||
|
||||
@ -414,7 +408,7 @@ clutter_ensure_glyph_cache_for_layout (PangoLayout *layout)
|
||||
|
||||
/* Now that we know all of the positions are settled we'll fill in
|
||||
any dirty glyphs */
|
||||
clutter_pango_glyph_cache_set_dirty_glyphs (renderer->glyph_cache);
|
||||
clutter_pango_glyph_cache_set_dirty_glyphs (CLUTTER_PANGO_RENDERER (renderer)->glyph_cache);
|
||||
}
|
||||
|
||||
static void
|
||||
|
Loading…
x
Reference in New Issue
Block a user