clutter-text: Fix selection color drawing

Commit cabcad185 removed the call to cogl_set_source_color4ub() before
cogl_fill_path(), so instead of the previously assigned selection color,
the background is drawn with the last set source.

In order to honour the newly added framebuffer parameter and still apply
the correct color, switch from cogl_fill_path() to the (deprecated!)
cogl_framebuffer_fill_path() method.

https://gitlab.gnome.org/GNOME/mutter/issues/494
This commit is contained in:
Florian Müllner 2019-05-27 17:48:41 +00:00
parent 18e44bb64c
commit 30d6e3abe2

View File

@ -1975,6 +1975,7 @@ selection_paint (ClutterText *self,
else else
{ {
/* Paint selection background first */ /* Paint selection background first */
CoglPipeline *color_pipeline = cogl_pipeline_copy (default_color_pipeline);
PangoLayout *layout = clutter_text_get_layout (self); PangoLayout *layout = clutter_text_get_layout (self);
CoglPath *selection_path = cogl_path_new (); CoglPath *selection_path = cogl_path_new ();
CoglColor cogl_color = { 0, }; CoglColor cogl_color = { 0, };
@ -1987,11 +1988,19 @@ selection_paint (ClutterText *self,
else else
color = &priv->text_color; color = &priv->text_color;
cogl_color_init_from_4ub (&cogl_color,
color->red,
color->green,
color->blue,
paint_opacity * color->alpha / 255);
cogl_color_premultiply (&cogl_color);
cogl_pipeline_set_color (color_pipeline, &cogl_color);
clutter_text_foreach_selection_rectangle_prescaled (self, clutter_text_foreach_selection_rectangle_prescaled (self,
add_selection_rectangle_to_path, add_selection_rectangle_to_path,
selection_path); selection_path);
cogl_path_fill (selection_path); cogl_framebuffer_fill_path (fb, color_pipeline, selection_path);
/* Paint selected text */ /* Paint selected text */
cogl_framebuffer_push_path_clip (fb, selection_path); cogl_framebuffer_push_path_clip (fb, selection_path);