[gtk/wip/baedert/for-master] gskpango: Handle fg colors ourselves
- From: Timm Bäder <baedert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/wip/baedert/for-master] gskpango: Handle fg colors ourselves
- Date: Mon, 21 Dec 2020 12:44:14 +0000 (UTC)
commit 1ac37fc566174a110f40a23b722ab91fe3fe8e46
Author: Timm Bäder <mail baedert org>
Date: Mon Dec 21 13:39:00 2020 +0100
gskpango: Handle fg colors ourselves
Instead of going through converting GdkRGBA to PangoColor all the time,
just use the fg_color we already have. This change is only for the
fg_color, which is used most often.
gtk/gskpango.c | 17 ++++++++---------
gtk/gskpango.h | 2 +-
gtk/gtktextlayout.c | 2 +-
3 files changed, 10 insertions(+), 11 deletions(-)
---
diff --git a/gtk/gskpango.c b/gtk/gskpango.c
index 6803f7528a..b700d69bd1 100644
--- a/gtk/gskpango.c
+++ b/gtk/gskpango.c
@@ -61,16 +61,19 @@ get_color (GskPangoRenderer *crenderer,
const PangoColor *color = pango_renderer_get_color ((PangoRenderer *) (crenderer), part);
const guint16 a = pango_renderer_get_alpha ((PangoRenderer *) (crenderer), part);
+ /* We do this ourselves */
+ g_assert (part != PANGO_RENDER_PART_FOREGROUND);
+
if (color)
{
rgba->red = color->red / 65535.;
rgba->green = color->green / 65535.;
rgba->blue = color->blue / 65535.;
- rgba->alpha = a ? a / 65535. : crenderer->fg_color.alpha;
+ rgba->alpha = a ? a / 65535. : crenderer->fg_color->alpha;
}
else
{
- *rgba = crenderer->fg_color;
+ *rgba = *crenderer->fg_color;
if (a)
rgba->alpha = a / 65535.;
}
@@ -95,14 +98,10 @@ gsk_pango_renderer_draw_glyph_item (PangoRenderer *renderer,
int y)
{
GskPangoRenderer *crenderer = (GskPangoRenderer *) (renderer);
- GdkRGBA color;
-
- get_color (crenderer, PANGO_RENDER_PART_FOREGROUND, &color);
-
gtk_snapshot_append_text (crenderer->snapshot,
glyph_item->item->analysis.font,
glyph_item->glyphs,
- &color,
+ crenderer->fg_color,
(float) x / PANGO_SCALE,
(float) y / PANGO_SCALE);
}
@@ -388,7 +387,7 @@ gsk_pango_renderer_prepare_run (PangoRenderer *renderer,
else
fg_rgba = appearance->fg_rgba;
- text_renderer_set_rgba (crenderer, PANGO_RENDER_PART_FOREGROUND, fg_rgba);
+ crenderer->fg_color = fg_rgba;
if (appearance->strikethrough_rgba)
text_renderer_set_rgba (crenderer, PANGO_RENDER_PART_STRIKETHROUGH, appearance->strikethrough_rgba);
@@ -502,7 +501,7 @@ gtk_snapshot_append_layout (GtkSnapshot *snapshot,
crenderer = gsk_pango_renderer_acquire ();
crenderer->snapshot = snapshot;
- crenderer->fg_color = *color;
+ crenderer->fg_color = color;
pango_renderer_draw_layout (PANGO_RENDERER (crenderer), layout, 0, 0);
diff --git a/gtk/gskpango.h b/gtk/gskpango.h
index 37052a1c0e..672128d1c1 100644
--- a/gtk/gskpango.h
+++ b/gtk/gskpango.h
@@ -58,7 +58,7 @@ struct _GskPangoRenderer
GtkWidget *widget;
GtkSnapshot *snapshot;
- GdkRGBA fg_color;
+ const GdkRGBA *fg_color;
/* Error underline color for this widget */
GdkRGBA *error_color;
diff --git a/gtk/gtktextlayout.c b/gtk/gtktextlayout.c
index ecbd2d3a08..9c994137ae 100644
--- a/gtk/gtktextlayout.c
+++ b/gtk/gtktextlayout.c
@@ -4164,7 +4164,7 @@ gtk_text_layout_snapshot (GtkTextLayout *layout,
crenderer->widget = widget;
crenderer->snapshot = snapshot;
- crenderer->fg_color = color;
+ crenderer->fg_color = &color;
gtk_text_layout_wrap_loop_start (layout);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]