[gtk/wip/baedert/for-master: 3/12] gskpango: Make get_color a bit shorter



commit cde4ab0d92f0533d939fe325dfc25476c35dd5c0
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]