linedisplay: Save paragraph bg color inline

No need to allocate this separately.
This commit is contained in:
Timm Bäder 2019-07-21 09:47:09 +02:00
parent f6d7967e96
commit 2ca56d4c4c
3 changed files with 12 additions and 9 deletions

View File

@ -642,13 +642,13 @@ render_para (GtkTextRenderer *text_renderer,
} }
else else
{ {
if (line_display->pg_bg_rgba) if (line_display->pg_bg_rgba_set)
{ {
cairo_t *cr = text_renderer->cr; cairo_t *cr = text_renderer->cr;
cairo_save (cr); cairo_save (cr);
gdk_cairo_set_source_rgba (text_renderer->cr, line_display->pg_bg_rgba); gdk_cairo_set_source_rgba (text_renderer->cr, &line_display->pg_bg_rgba);
cairo_rectangle (cr, cairo_rectangle (cr,
line_display->left_margin, selection_y, line_display->left_margin, selection_y,
screen_width, selection_height); screen_width, selection_height);

View File

@ -1431,11 +1431,16 @@ set_para_values (GtkTextLayout *layout,
pango_layout_set_wrap (display->layout, pango_wrap); pango_layout_set_wrap (display->layout, pango_wrap);
} }
display->total_width = MAX (layout->screen_width, layout->width) - h_margin - h_padding; display->total_width = MAX (layout->screen_width, layout->width) - h_margin - h_padding;
if (style->pg_bg_rgba) if (style->pg_bg_rgba)
display->pg_bg_rgba = gdk_rgba_copy (style->pg_bg_rgba); {
display->pg_bg_rgba = *style->pg_bg_rgba;
display->pg_bg_rgba_set = TRUE;
}
else else
display->pg_bg_rgba = NULL; {
display->pg_bg_rgba_set = FALSE;
}
} }
static PangoAttribute * static PangoAttribute *
@ -2630,9 +2635,6 @@ gtk_text_layout_free_line_display (GtkTextLayout *layout,
if (display->cursors) if (display->cursors)
g_array_free (display->cursors, TRUE); g_array_free (display->cursors, TRUE);
if (display->pg_bg_rgba)
gdk_rgba_free (display->pg_bg_rgba);
g_slice_free (GtkTextLineDisplay, display); g_slice_free (GtkTextLineDisplay, display);
} }
} }

View File

@ -246,7 +246,8 @@ struct _GtkTextLineDisplay
guint cursor_at_line_end : 1; guint cursor_at_line_end : 1;
guint size_only : 1; guint size_only : 1;
GdkRGBA *pg_bg_rgba; GdkRGBA pg_bg_rgba;
guint pg_bg_rgba_set : 1;
}; };
#ifdef GTK_COMPILATION #ifdef GTK_COMPILATION