@@ -1906,14 +1906,6 @@ clutter_text_foreach_selection_rectangle (ClutterText *self,
19061906 g_free (utf8 );
19071907}
19081908
1909- static void
1910- add_selection_rectangle_to_path (ClutterText * text ,
1911- const ClutterActorBox * box ,
1912- gpointer user_data )
1913- {
1914- cogl_path_rectangle (user_data , box -> x1 , box -> y1 , box -> x2 , box -> y2 );
1915- }
1916-
19171909static void
19181910clutter_text_foreach_selection_rectangle_prescaled (ClutterText * self ,
19191911 ClutterTextSelectionFunc func ,
@@ -1922,6 +1914,60 @@ clutter_text_foreach_selection_rectangle_prescaled (ClutterText *se
19221914 clutter_text_foreach_selection_rectangle (self , 1.0f , func , user_data );
19231915}
19241916
1917+ static void
1918+ paint_selection_rectangle (ClutterText * self ,
1919+ const ClutterActorBox * box ,
1920+ gpointer user_data )
1921+ {
1922+ CoglFramebuffer * fb = user_data ;
1923+ ClutterTextPrivate * priv = self -> priv ;
1924+ ClutterActor * actor = CLUTTER_ACTOR (self );
1925+ guint8 paint_opacity = clutter_actor_get_paint_opacity (actor );
1926+ CoglPipeline * color_pipeline = cogl_pipeline_copy (default_color_pipeline );
1927+ PangoLayout * layout = clutter_text_get_layout (self );
1928+ CoglColor cogl_color = { 0 , };
1929+ const ClutterColor * color ;
1930+
1931+ /* Paint selection background */
1932+ if (priv -> selection_color_set )
1933+ color = & priv -> selection_color ;
1934+ else if (priv -> cursor_color_set )
1935+ color = & priv -> cursor_color ;
1936+ else
1937+ color = & priv -> text_color ;
1938+
1939+ cogl_color_init_from_4ub (& cogl_color ,
1940+ color -> red ,
1941+ color -> green ,
1942+ color -> blue ,
1943+ paint_opacity * color -> alpha / 255 );
1944+ cogl_color_premultiply (& cogl_color );
1945+ cogl_pipeline_set_color (color_pipeline , & cogl_color );
1946+
1947+ cogl_framebuffer_push_rectangle_clip (fb ,
1948+ box -> x1 , box -> y1 ,
1949+ box -> x2 , box -> y2 );
1950+ cogl_framebuffer_draw_rectangle (fb , color_pipeline ,
1951+ box -> x1 , box -> y1 ,
1952+ box -> x2 , box -> y2 );
1953+
1954+ if (priv -> selected_text_color_set )
1955+ color = & priv -> selected_text_color ;
1956+ else
1957+ color = & priv -> text_color ;
1958+
1959+ cogl_color_init_from_4ub (& cogl_color ,
1960+ color -> red ,
1961+ color -> green ,
1962+ color -> blue ,
1963+ paint_opacity * color -> alpha / 255 );
1964+
1965+ cogl_pango_show_layout (fb , layout , priv -> text_x , 0 , & cogl_color );
1966+
1967+ cogl_framebuffer_pop_clip (fb );
1968+ cogl_object_unref (color_pipeline );
1969+ }
1970+
19251971/* Draws the selected text, its background, and the cursor */
19261972static void
19271973selection_paint (ClutterText * self ,
@@ -1964,52 +2010,9 @@ selection_paint (ClutterText *self,
19642010 }
19652011 else
19662012 {
1967- /* Paint selection background first */
1968- CoglPipeline * color_pipeline = cogl_pipeline_copy (default_color_pipeline );
1969- PangoLayout * layout = clutter_text_get_layout (self );
1970- CoglPath * selection_path = cogl_path_new ();
1971- CoglColor cogl_color = { 0 , };
1972-
1973- /* Paint selection background */
1974- if (priv -> selection_color_set )
1975- color = & priv -> selection_color ;
1976- else if (priv -> cursor_color_set )
1977- color = & priv -> cursor_color ;
1978- else
1979- color = & priv -> text_color ;
1980-
1981- cogl_color_init_from_4ub (& cogl_color ,
1982- color -> red ,
1983- color -> green ,
1984- color -> blue ,
1985- paint_opacity * color -> alpha / 255 );
1986- cogl_color_premultiply (& cogl_color );
1987- cogl_pipeline_set_color (color_pipeline , & cogl_color );
1988-
19892013 clutter_text_foreach_selection_rectangle_prescaled (self ,
1990- add_selection_rectangle_to_path ,
1991- selection_path );
1992-
1993- cogl_framebuffer_fill_path (fb , color_pipeline , selection_path );
1994-
1995- /* Paint selected text */
1996- cogl_framebuffer_push_path_clip (fb , selection_path );
1997- cogl_object_unref (selection_path );
1998-
1999- if (priv -> selected_text_color_set )
2000- color = & priv -> selected_text_color ;
2001- else
2002- color = & priv -> text_color ;
2003-
2004- cogl_color_init_from_4ub (& cogl_color ,
2005- color -> red ,
2006- color -> green ,
2007- color -> blue ,
2008- paint_opacity * color -> alpha / 255 );
2009-
2010- cogl_pango_show_layout (fb , layout , priv -> text_x , 0 , & cogl_color );
2011-
2012- cogl_framebuffer_pop_clip (fb );
2014+ paint_selection_rectangle ,
2015+ fb );
20132016 }
20142017}
20152018
0 commit comments