1
0
Fork 0

cogl/pango: Add argument to supply extra snippet

This will be applied to the pipeline used for drawing, and can be used
to include color state transformation snippets.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3433>
This commit is contained in:
Jonas Ådahl 2024-06-07 23:40:49 +02:00 committed by Sebastian Wick
parent fe63242d60
commit 9a0fbbfa81
6 changed files with 49 additions and 34 deletions

View file

@ -771,7 +771,8 @@ clutter_text_node_draw (ClutterPaintNode *node,
tnode->layout,
op->op.texrect[0],
op->op.texrect[1],
&tnode->color);
&tnode->color,
NULL);
if (clipped)
cogl_framebuffer_pop_clip (fb);

View file

@ -1951,7 +1951,7 @@ paint_selection_rectangle (ClutterText *self,
color->blue / 255.0f,
paint_opacity / 255.0f * color->alpha / 255.0f);
cogl_pango_show_layout (fb, layout, priv->text_x, 0, &cogl_color);
cogl_pango_show_layout (fb, layout, priv->text_x, 0, &cogl_color, NULL);
cogl_framebuffer_pop_clip (fb);
g_object_unref (color_pipeline);
@ -2758,7 +2758,7 @@ clutter_text_paint (ClutterActor *self,
priv->text_color.green / 255.0f,
priv->text_color.blue / 255.0f,
real_opacity / 255.0f);
cogl_pango_show_layout (fb, layout, priv->text_x, priv->text_y, &color);
cogl_pango_show_layout (fb, layout, priv->text_x, priv->text_y, &color, NULL);
selection_paint (text, fb);

View file

@ -391,8 +391,9 @@ _cogl_framebuffer_draw_display_list_texture (CoglFramebuffer *fb,
}
void
_cogl_pango_display_list_render (CoglFramebuffer *fb,
cogl_pango_display_list_render (CoglFramebuffer *fb,
CoglPangoDisplayList *dl,
CoglSnippet *extra_snippet,
const CoglColor *color)
{
GSList *l;
@ -401,6 +402,7 @@ _cogl_pango_display_list_render (CoglFramebuffer *fb,
{
CoglPangoDisplayListNode *node = l->data;
CoglColor draw_color;
g_autoptr (CoglPipeline) pipeline = NULL;
if (node->pipeline == NULL)
{
@ -414,6 +416,8 @@ _cogl_pango_display_list_render (CoglFramebuffer *fb,
NULL);
}
pipeline = cogl_pipeline_copy (node->pipeline);
if (node->color_override)
/* Use the override color but preserve the alpha from the
draw color */
@ -427,17 +431,20 @@ _cogl_pango_display_list_render (CoglFramebuffer *fb,
draw_color = *color;
cogl_color_premultiply (&draw_color);
cogl_pipeline_set_color (node->pipeline, &draw_color);
cogl_pipeline_set_color (pipeline, &draw_color);
if (extra_snippet)
cogl_pipeline_add_snippet (pipeline, extra_snippet);
switch (node->type)
{
case COGL_PANGO_DISPLAY_LIST_TEXTURE:
_cogl_framebuffer_draw_display_list_texture (fb, node->pipeline, node);
_cogl_framebuffer_draw_display_list_texture (fb, pipeline, node);
break;
case COGL_PANGO_DISPLAY_LIST_RECTANGLE:
cogl_framebuffer_draw_rectangle (fb,
node->pipeline,
pipeline,
node->d.rectangle.x_1,
node->d.rectangle.y_1,
node->d.rectangle.x_2,
@ -447,7 +454,7 @@ _cogl_pango_display_list_render (CoglFramebuffer *fb,
case COGL_PANGO_DISPLAY_LIST_TRAPEZOID:
cogl_primitive_draw (node->d.trapezoid.primitive,
fb,
node->pipeline);
pipeline);
break;
}
}

View file

@ -69,8 +69,9 @@ _cogl_pango_display_list_add_trapezoid (CoglPangoDisplayList *dl,
float x_22);
void
_cogl_pango_display_list_render (CoglFramebuffer *framebuffer,
cogl_pango_display_list_render (CoglFramebuffer *framebuffer,
CoglPangoDisplayList *dl,
CoglSnippet *extra_snippet,
const CoglColor *color);
void

View file

@ -361,7 +361,8 @@ cogl_pango_show_layout (CoglFramebuffer *fb,
PangoLayout *layout,
float x,
float y,
const CoglColor *color)
const CoglColor *color,
CoglSnippet *extra_snippet)
{
PangoContext *context;
CoglPangoRenderer *priv;
@ -423,8 +424,9 @@ cogl_pango_show_layout (CoglFramebuffer *fb,
cogl_framebuffer_push_matrix (fb);
cogl_framebuffer_translate (fb, x, y, 0);
_cogl_pango_display_list_render (fb,
cogl_pango_display_list_render (fb,
qdata->display_list,
extra_snippet,
color);
cogl_framebuffer_pop_matrix (fb);
@ -448,7 +450,8 @@ cogl_pango_show_layout_line (CoglFramebuffer *fb,
PangoLayoutLine *line,
float x,
float y,
const CoglColor *color)
const CoglColor *color,
CoglSnippet *extra_snippet)
{
PangoContext *context;
CoglPangoRenderer *priv;
@ -472,8 +475,9 @@ cogl_pango_show_layout_line (CoglFramebuffer *fb,
pango_renderer_draw_layout_line (PANGO_RENDERER (priv), line,
pango_x, pango_y);
_cogl_pango_display_list_render (fb,
cogl_pango_display_list_render (fb,
priv->display_list,
extra_snippet,
color);
_cogl_pango_display_list_free (priv->display_list);

View file

@ -155,7 +155,8 @@ cogl_pango_show_layout (CoglFramebuffer *framebuffer,
PangoLayout *layout,
float x,
float y,
const CoglColor *color);
const CoglColor *color,
CoglSnippet *extra_snippet);
/**
* cogl_pango_show_layout_line: (skip)
@ -173,7 +174,8 @@ cogl_pango_show_layout_line (CoglFramebuffer *framebuffer,
PangoLayoutLine *line,
float x,
float y,
const CoglColor *color);
const CoglColor *color,
CoglSnippet *extra_snippet);
#define COGL_PANGO_TYPE_RENDERER (cogl_pango_renderer_get_type ())