[gtk/wip/baedert/for-master: 75/82] gskpango: Make get_color a bit shorter
- From: Timm Bäder <baedert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/wip/baedert/for-master: 75/82] gskpango: Make get_color a bit shorter
- Date: Mon, 20 Apr 2020 18:04:12 +0000 (UTC)
commit b0d9e7ae17b8da64b7b3845add5dbe27f41f703a
Author: Timm Bäder <mail baedert org>
Date: Fri Apr 17 17:16:05 2020 +0200
gskpango: Make get_color a bit shorter
Don't copy from crenderer->fg_color just to override from the local
color again.
gtk/gskpango.c | 32 ++++++++++++--------------------
1 file changed, 12 insertions(+), 20 deletions(-)
---
diff --git a/gtk/gskpango.c b/gtk/gskpango.c
index 5d2eb3c527..8f54c9cc94 100644
--- a/gtk/gskpango.c
+++ b/gtk/gskpango.c
@@ -59,30 +59,22 @@ get_color (GskPangoRenderer *crenderer,
PangoRenderPart part,
GdkRGBA *rgba)
{
- PangoColor *color = pango_renderer_get_color ((PangoRenderer *) (crenderer), part);
- guint16 a = pango_renderer_get_alpha ((PangoRenderer *) (crenderer), part);
- gdouble red, green, blue, alpha;
-
- red = crenderer->fg_color.red;
- green = crenderer->fg_color.green;
- blue = crenderer->fg_color.blue;
- alpha = crenderer->fg_color.alpha;
+ const PangoColor *color = pango_renderer_get_color ((PangoRenderer *) (crenderer), part);
+ const guint16 a = pango_renderer_get_alpha ((PangoRenderer *) (crenderer), part);
if (color)
{
- red = color->red / 65535.;
- green = color->green / 65535.;
- blue = color->blue / 65535.;
- alpha = 1.;
+ rgba->red = color->red / 65535.;
+ rgba->green = color->green / 65535.;
+ rgba->blue = color->blue / 65535.;
+ rgba->alpha = a ? a / 65535. : crenderer->fg_color.alpha;
+ }
+ else
+ {
+ *rgba = crenderer->fg_color;
+ if (a)
+ rgba->alpha = a / 65535.;
}
-
- if (a)
- alpha = a / 65535.;
-
- rgba->red = red;
- rgba->green = green;
- rgba->blue = blue;
- rgba->alpha = alpha;
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]