[evince/wip/gpoo/rgba-cherry-picking: 1/2] backends: replace GdkColor with GdkRGBA in dvi




commit a782b05b65941a686c11da8dc5fcdb152dc96ac7
Author: Qiu Wenbo <qiuwenbo kylinos com cn>
Date:   Mon Aug 23 09:54:26 2021 +0800

    backends: replace GdkColor with GdkRGBA in dvi
    
    Signed-off-by: Qiu Wenbo <qiuwenbo kylinos com cn>

 backend/dvi/cairo-device.c | 13 +++++++------
 backend/dvi/dvi-document.c | 12 ++++++------
 2 files changed, 13 insertions(+), 12 deletions(-)
---
diff --git a/backend/dvi/cairo-device.c b/backend/dvi/cairo-device.c
index f46da99c..56e2c72f 100644
--- a/backend/dvi/cairo-device.c
+++ b/backend/dvi/cairo-device.c
@@ -202,26 +202,27 @@ dvi_cairo_alloc_colors (void  *device_data,
                        int    density)
 {
        double  frac;
-       GdkColor color, color_fg;
+       GdkRGBA color, color_fg;
        int     i, n;
        unsigned int alpha;
 
-       color_fg.red = (fg >> 16) & 0xff;
-       color_fg.green = (fg >> 8) & 0xff;
-       color_fg.blue = (fg >> 0) & 0xff;
+       color_fg.red = ((fg >> 16) & 0xff) / 255.;
+       color_fg.green = ((fg >> 8) & 0xff) / 255.;
+       color_fg.blue = ((fg >> 0) & 0xff) / 255.;
 
        n = npixels - 1;
        for (i = 0; i < npixels; i++) {
                frac = (gamma > 0) ?
                        pow ((double)i / n, 1 / gamma) :
                        1 - pow ((double)(n - i) / n, -gamma);
-               
+
                color.red = frac * color_fg.red;
                color.green = frac * color_fg.green;
                color.blue = frac * color_fg.blue;
                alpha = frac * 0xFF;
 
-               pixels[i] = (alpha << 24) + (color.red << 16) + (color.green << 8) + color.blue;
+               pixels[i] = (alpha << 24) + ((uint8_t)(color.red * 255) << 16) +
+                       ((uint8_t)(color.green * 255) << 8) + (uint8_t)(color.blue * 255);
        }
 
        return npixels;
diff --git a/backend/dvi/dvi-document.c b/backend/dvi/dvi-document.c
index 28877700..c1839f20 100644
--- a/backend/dvi/dvi-document.c
+++ b/backend/dvi/dvi-document.c
@@ -479,14 +479,14 @@ dvi_document_do_color_special (DviContext *dvi, const char *prefix, const char *
 
                        mdvi_push_color (dvi, RGB2ULONG (rgb, rgb, rgb), 0xFFFFFFFF);
                 } else {
-                        GdkColor color;
-                       
-                        if (gdk_color_parse (tmp, &color)) {
+                        GdkRGBA rgba;
+
+                        if (gdk_rgba_parse (&rgba, tmp)) {
                                guchar red, green, blue;
 
-                               red = color.red * 255 / 65535.;
-                               green = color.green * 255 / 65535.;
-                               blue = color.blue * 255 / 65535.;
+                               red = rgba.red * 255;
+                               green = rgba.green * 255;
+                               blue = rgba.blue * 255;
 
                                 mdvi_push_color (dvi, RGB2ULONG (red, green, blue), 0xFFFFFFFF);
                        }


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