[vte] draw: Use double for alpha



commit fa8b20f8ffe1280a97d4202fc4a6275b346bca53
Author: Christian Persch <chpe gnome org>
Date:   Sat Nov 28 22:58:31 2015 +0100

    draw: Use double for alpha

 src/vtedraw.cc |   22 +++++++++++-----------
 src/vtedraw.h  |   10 +++++-----
 2 files changed, 16 insertions(+), 16 deletions(-)
---
diff --git a/src/vtedraw.cc b/src/vtedraw.cc
index 5113a9b..8857b04 100644
--- a/src/vtedraw.cc
+++ b/src/vtedraw.cc
@@ -926,14 +926,14 @@ _vte_draw_has_bold (struct _vte_draw *draw, guint style)
 static void
 _vte_draw_set_source_color_alpha (struct _vte_draw *draw,
                                   vte::color::rgb const* color,
-                                  guchar            alpha)
+                                  double alpha)
 {
         g_assert(draw->cr);
        cairo_set_source_rgba (draw->cr,
                              color->red / 65535.,
                              color->green / 65535.,
                              color->blue / 65535.,
-                             alpha / 255.);
+                             alpha);
 }
 
 /* Check if a unicode character is actually a graphic character we draw
@@ -1410,7 +1410,7 @@ _vte_draw_terminal_draw_graphic(struct _vte_draw *draw, vteunistr c, vte::color:
 static void
 _vte_draw_text_internal (struct _vte_draw *draw,
                         struct _vte_draw_text_request *requests, gsize n_requests,
-                        vte::color::rgb const* color, guchar alpha, guint style)
+                        vte::color::rgb const* color, double alpha, guint style)
 {
        gsize i;
        cairo_scaled_font_t *last_scaled_font = NULL;
@@ -1484,7 +1484,7 @@ _vte_draw_text_internal (struct _vte_draw *draw,
 void
 _vte_draw_text (struct _vte_draw *draw,
               struct _vte_draw_text_request *requests, gsize n_requests,
-              vte::color::rgb const* color, guchar alpha, guint style)
+              vte::color::rgb const* color, double alpha, guint style)
 {
         g_assert(draw->cr);
 
@@ -1496,7 +1496,7 @@ _vte_draw_text (struct _vte_draw *draw,
                        g_string_append_unichar (string, requests[n].c);
                }
                str = g_string_free (string, FALSE);
-               g_printerr ("draw_text (\"%s\", len=%" G_GSIZE_FORMAT ", color=(%d,%d,%d,%d), %s - %s)\n",
+               g_printerr ("draw_text (\"%s\", len=%" G_GSIZE_FORMAT ", color=(%d,%d,%d,%.3f), %s - %s)\n",
                                str, n_requests, color->red, color->green, color->blue, alpha,
                                (style & VTE_DRAW_BOLD)   ? "bold"   : "normal",
                                (style & VTE_DRAW_ITALIC) ? "italic" : "regular");
@@ -1543,12 +1543,12 @@ _vte_draw_has_char (struct _vte_draw *draw, vteunistr c, guint style)
 gboolean
 _vte_draw_char (struct _vte_draw *draw,
               struct _vte_draw_text_request *request,
-              vte::color::rgb const* color, guchar alpha, guint style)
+              vte::color::rgb const* color, double alpha, guint style)
 {
        gboolean has_char;
 
        _vte_debug_print (VTE_DEBUG_DRAW,
-                       "draw_char ('%c', color=(%d,%d,%d,%d), %s, %s)\n",
+                       "draw_char ('%c', color=(%d,%d,%d,%.3f), %s, %s)\n",
                        request->c,
                        color->red, color->green, color->blue,
                        alpha,
@@ -1565,12 +1565,12 @@ _vte_draw_char (struct _vte_draw *draw,
 void
 _vte_draw_draw_rectangle (struct _vte_draw *draw,
                         gint x, gint y, gint width, gint height,
-                        vte::color::rgb const* color, guchar alpha)
+                        vte::color::rgb const* color, double alpha)
 {
         g_assert(draw->cr);
 
        _vte_debug_print (VTE_DEBUG_DRAW,
-                       "draw_rectangle (%d, %d, %d, %d, color=(%d,%d,%d,%d))\n",
+                       "draw_rectangle (%d, %d, %d, %d, color=(%d,%d,%d,%.3f))\n",
                        x,y,width,height,
                        color->red, color->green, color->blue,
                        alpha);
@@ -1585,12 +1585,12 @@ _vte_draw_draw_rectangle (struct _vte_draw *draw,
 void
 _vte_draw_fill_rectangle (struct _vte_draw *draw,
                         gint x, gint y, gint width, gint height,
-                        vte::color::rgb const* color, guchar alpha)
+                        vte::color::rgb const* color, double alpha)
 {
         g_assert(draw->cr);
 
        _vte_debug_print (VTE_DEBUG_DRAW,
-                       "draw_fill_rectangle (%d, %d, %d, %d, color=(%d,%d,%d,%d))\n",
+                       "draw_fill_rectangle (%d, %d, %d, %d, color=(%d,%d,%d,%.3f))\n",
                        x,y,width,height,
                        color->red, color->green, color->blue,
                        alpha);
diff --git a/src/vtedraw.h b/src/vtedraw.h
index 7a6a4fc..4bfa088 100644
--- a/src/vtedraw.h
+++ b/src/vtedraw.h
@@ -44,7 +44,7 @@ G_BEGIN_DECLS
    returned by pango_layout would be screwed up for Chinese and Japanese
    fonts without Hangul */
 #define VTE_DRAW_DOUBLE_WIDE_IDEOGRAPHS 0x4e00, 0x4e8c, 0x4e09, 0x56db, 0x4e94
-#define VTE_DRAW_OPAQUE 0xff
+#define VTE_DRAW_OPAQUE (1.0)
 #define VTE_DRAW_MAX_LENGTH 1024
 
 #define VTE_DRAW_NORMAL 0
@@ -90,18 +90,18 @@ gboolean _vte_draw_has_bold (struct _vte_draw *draw, guint style);
 
 void _vte_draw_text(struct _vte_draw *draw,
                    struct _vte_draw_text_request *requests, gsize n_requests,
-                   vte::color::rgb const* color, guchar alpha, guint style);
+                   vte::color::rgb const* color, double alpha, guint style);
 gboolean _vte_draw_char(struct _vte_draw *draw,
                        struct _vte_draw_text_request *request,
-                       vte::color::rgb const* color, guchar alpha, guint style);
+                       vte::color::rgb const* color, double alpha, guint style);
 gboolean _vte_draw_has_char(struct _vte_draw *draw, vteunistr c, guint style);
 
 void _vte_draw_fill_rectangle(struct _vte_draw *draw,
                              gint x, gint y, gint width, gint height,
-                             vte::color::rgb const* color, guchar alpha);
+                             vte::color::rgb const* color, double alpha);
 void _vte_draw_draw_rectangle(struct _vte_draw *draw,
                              gint x, gint y, gint width, gint height,
-                             vte::color::rgb const* color, guchar alpha);
+                             vte::color::rgb const* color, double alpha);
 
 G_END_DECLS
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]