Signed-off-by: Adam Jackson <a...@redhat.com>
---
 exa/exa_render.c        |  4 +++-
 fb/fbpict.c             | 16 +++-------------
 glamor/glamor_program.c |  7 ++++---
 glamor/glamor_render.c  | 14 ++++----------
 glamor/glamor_utils.h   |  9 +++++++++
 render/picture.c        | 10 +---------
 render/picturestr.h     |  2 +-
 7 files changed, 25 insertions(+), 37 deletions(-)

diff --git a/exa/exa_render.c b/exa/exa_render.c
index b24bec052..2dad795f2 100644
--- a/exa/exa_render.c
+++ b/exa/exa_render.c
@@ -291,7 +291,9 @@ exaTryDriverSolidFill(PicturePtr pSrc,
         pixel = exaGetPixmapFirstPixel(pSrcPix);
     }
     else
-        pixel = pSrc->pSourcePict->solidFill.color;
+        miRenderColorToPixel(pSrc->pFormat,
+                             &pSrc->pSourcePict->solidFill.color,
+                             &pixel);
 
     if (!exaGetRGBAFromPixel(pixel, &red, &green, &blue, &alpha,
                              pSrc->pFormat, pSrc->format) ||
diff --git a/fb/fbpict.c b/fb/fbpict.c
index 7ea0b668f..759f0d5db 100644
--- a/fb/fbpict.c
+++ b/fb/fbpict.c
@@ -220,20 +220,10 @@ static pixman_image_t *
 create_solid_fill_image(PicturePtr pict)
 {
     PictSolidFill *solid = &pict->pSourcePict->solidFill;
-    pixman_color_t color;
-    CARD32 a, r, g, b;
+    /* pixman_color_t and xRenderColor have the same layout */
+    pixman_color_t *color = (pixman_color_t *)&solid->color;
 
-    a = (solid->color & 0xff000000) >> 24;
-    r = (solid->color & 0x00ff0000) >> 16;
-    g = (solid->color & 0x0000ff00) >> 8;
-    b = (solid->color & 0x000000ff) >> 0;
-
-    color.alpha = (a << 8) | a;
-    color.red = (r << 8) | r;
-    color.green = (g << 8) | g;
-    color.blue = (b << 8) | b;
-
-    return pixman_image_create_solid_fill(&color);
+    return pixman_image_create_solid_fill(color);
 }
 
 static pixman_image_t *
diff --git a/glamor/glamor_program.c b/glamor/glamor_program.c
index 23c102bc3..29ffed05c 100644
--- a/glamor/glamor_program.c
+++ b/glamor/glamor_program.c
@@ -508,12 +508,13 @@ glamor_set_blend(CARD8 op, glamor_program_alpha alpha, 
PicturePtr dst)
 static Bool
 use_source_solid(CARD8 op, PicturePtr src, PicturePtr dst, glamor_program 
*prog)
 {
+    PictSolidFill *solid = &src->pSourcePict->solidFill;
+    float color[4];
 
+    glamor_get_rgba_from_color(&solid->color, color);
     glamor_set_blend(op, prog->alpha, dst);
+    glUniform4fv(prog->fg_uniform, 1, color);
 
-    glamor_set_color_depth(dst->pDrawable->pScreen, 32,
-                           src->pSourcePict->solidFill.color,
-                           prog->fg_uniform);
     return TRUE;
 }
 
diff --git a/glamor/glamor_render.c b/glamor/glamor_render.c
index 7a96c82dd..75f4258d8 100644
--- a/glamor/glamor_render.c
+++ b/glamor/glamor_render.c
@@ -830,11 +830,8 @@ glamor_composite_choose_shader(CARD8 op,
     else if (!source->pDrawable) {
         if (source->pSourcePict->type == SourcePictTypeSolidFill) {
             key.source = SHADER_SOURCE_SOLID;
-            glamor_get_rgba_from_pixel(source->pSourcePict->solidFill.color,
-                                       &source_solid_color[0],
-                                       &source_solid_color[1],
-                                       &source_solid_color[2],
-                                       &source_solid_color[3], PICT_a8r8g8b8);
+            glamor_get_rgba_from_color(&source->pSourcePict->solidFill.color,
+                                       source_solid_color);
         }
         else
             goto fail;
@@ -850,11 +847,8 @@ glamor_composite_choose_shader(CARD8 op,
         if (!mask->pDrawable) {
             if (mask->pSourcePict->type == SourcePictTypeSolidFill) {
                 key.mask = SHADER_MASK_SOLID;
-                glamor_get_rgba_from_pixel
-                    (mask->pSourcePict->solidFill.color,
-                     &mask_solid_color[0],
-                     &mask_solid_color[1],
-                     &mask_solid_color[2], &mask_solid_color[3], 
PICT_a8r8g8b8);
+                glamor_get_rgba_from_color(&mask->pSourcePict->solidFill.color,
+                                           mask_solid_color);
             }
             else
                 goto fail;
diff --git a/glamor/glamor_utils.h b/glamor/glamor_utils.h
index 7597b92dc..d4f995ab9 100644
--- a/glamor/glamor_utils.h
+++ b/glamor/glamor_utils.h
@@ -710,6 +710,15 @@ glamor_get_rgba_from_pixel(CARD32 pixel,
     return TRUE;
 }
 
+static inline void
+glamor_get_rgba_from_color(const xRenderColor *color, float rgba[4])
+{
+    rgba[0] = color->red   / (float)UINT16_MAX;
+    rgba[1] = color->green / (float)UINT16_MAX;
+    rgba[2] = color->blue  / (float)UINT16_MAX;
+    rgba[3] = color->alpha / (float)UINT16_MAX;
+}
+
 inline static Bool
 glamor_is_large_pixmap(PixmapPtr pixmap)
 {
diff --git a/render/picture.c b/render/picture.c
index 9e4036e7d..9907e15d6 100644
--- a/render/picture.c
+++ b/render/picture.c
@@ -817,14 +817,6 @@ CreatePicture(Picture pid,
     return pPicture;
 }
 
-static CARD32
-xRenderColorToCard32(xRenderColor c)
-{
-    return
-        (c.alpha >> 8 << 24) |
-        (c.red >> 8 << 16) | (c.green & 0xff00) | (c.blue >> 8);
-}
-
 static void
 initGradient(SourcePictPtr pGradient, int stopCount,
              xFixed * stopPoints, xRenderColor * stopColors, int *error)
@@ -898,7 +890,7 @@ CreateSolidPicture(Picture pid, xRenderColor * color, int 
*error)
         return 0;
     }
     pPicture->pSourcePict->type = SourcePictTypeSolidFill;
-    pPicture->pSourcePict->solidFill.color = xRenderColorToCard32(*color);
+    memcpy(&pPicture->pSourcePict->solidFill.color, color, sizeof(*color));
     return pPicture;
 }
 
diff --git a/render/picturestr.h b/render/picturestr.h
index 33baef9bf..5d479f18e 100644
--- a/render/picturestr.h
+++ b/render/picturestr.h
@@ -67,7 +67,7 @@ typedef struct pixman_transform PictTransform, 
*PictTransformPtr;
 
 typedef struct _PictSolidFill {
     unsigned int type;
-    CARD32 color;
+    xRenderColor color;
 } PictSolidFill, *PictSolidFillPtr;
 
 typedef struct _PictGradientStop {
-- 
2.14.3

_______________________________________________
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: https://lists.x.org/mailman/listinfo/xorg-devel

Reply via email to