>From 63fb26b8e1609d4296c8a28cc3a0ad57f810f51a Mon Sep 17 00:00:00 2001
From: Damien Leone <[email protected]>
Date: Wed, 5 Mar 2014 16:51:46 -0800
Subject: [PATCH] render: Add support for RENDER RGBA formats

Signed-off-by: Damien Leone <[email protected]>
---
 exa/exa_render.c |  6 ++++++
 render/picture.c | 42 ++++++++++++++++++++++++++++++++++++++++--
 render/picture.h |  3 +++
 3 files changed, 49 insertions(+), 2 deletions(-)

diff --git a/exa/exa_render.c b/exa/exa_render.c
index c4edf40..aed6154 100644
--- a/exa/exa_render.c
+++ b/exa/exa_render.c
@@ -59,6 +59,12 @@ exaCompositeFallbackPictDesc(PicturePtr pict, char *string, int n)
     case PICT_b8g8r8x8:
         snprintf(format, 20, "BGRX8888");
         break;
+    case PICT_r8g8b8a8:
+        snprintf(format, 20, "RGBA8888");
+        break;
+    case PICT_r8g8b8x8:
+        snprintf(format, 20, "RGBX8888");
+        break;
     case PICT_r5g6b5:
         snprintf(format, 20, "RGB565  ");
         break;
diff --git a/render/picture.c b/render/picture.c
index 58535d4..d060bc2 100644
--- a/render/picture.c
+++ b/render/picture.c
@@ -201,6 +201,12 @@ PictureCreateDefaultFormats(ScreenPtr pScreen, int *nformatp)
     formats[nformats].format = PICT_b8g8r8x8;
     formats[nformats].depth = 32;
     nformats++;
+    formats[nformats].format = PICT_r8g8b8a8;
+    formats[nformats].depth = 32;
+    nformats++;
+    formats[nformats].format = PICT_r8g8b8x8;
+    formats[nformats].depth = 32;
+    nformats++;
 
     /* now look through the depths and visuals adding other formats */
     for (v = 0; v < pScreen->numVisuals; v++) {
@@ -234,6 +240,11 @@ PictureCreateDefaultFormats(ScreenPtr pScreen, int *nformatp)
                      pVisual->offsetBlue == bpp - b) {
                 type = PICT_TYPE_BGRA;
             }
+            else if (pVisual->offsetRed == bpp - r &&
+                     pVisual->offsetGreen == pVisual->offsetRed - g &&
+                     pVisual->offsetBlue == pVisual->offsetGreen - b) {
+                type = PICT_TYPE_RGBA;
+            }
             if (type != PICT_TYPE_OTHER) {
                 format = PICT_FORMAT(bpp, type, 0, r, g, b);
                 nformats = addFormat(formats, nformats, format, depth);
@@ -401,6 +412,31 @@ PictureCreateDefaultFormats(ScreenPtr pScreen, int *nformatp)
             pFormats[f].direct.alpha = 0;
             break;
 
+        case PICT_TYPE_RGBA:
+            pFormats[f].type = PictTypeDirect;
+
+            pFormats[f].direct.redMask = Mask (PICT_FORMAT_R(format));
+
+            pFormats[f].direct.red =
+                (PICT_FORMAT_BPP(format) - PICT_FORMAT_R(format));
+
+            pFormats[f].direct.greenMask = Mask (PICT_FORMAT_G(format));
+
+            pFormats[f].direct.green =
+                (PICT_FORMAT_BPP(format) - PICT_FORMAT_R(format) -
+                 PICT_FORMAT_G(format));
+
+            pFormats[f].direct.blueMask = Mask (PICT_FORMAT_B(format));
+
+            pFormats[f].direct.blue =
+                (PICT_FORMAT_BPP(format) - PICT_FORMAT_R(format) -
+                 PICT_FORMAT_G(format) - PICT_FORMAT_B(format));
+
+            pFormats[f].direct.alphaMask = Mask (PICT_FORMAT_A(format));
+
+            pFormats[f].direct.alpha = 0;
+            break;
+
         case PICT_TYPE_A:
             pFormats[f].type = PictTypeDirect;
 
@@ -672,12 +708,14 @@ PictureInit(ScreenPtr pScreen, PictFormatPtr formats, int nformats)
             if ((formats[n].direct.redMask |
                  formats[n].direct.blueMask | formats[n].direct.greenMask) == 0)
                 type = PICT_TYPE_A;
-            else if (formats[n].direct.red > formats[n].direct.blue)
+            else if (formats[n].direct.blue == 0)
                 type = PICT_TYPE_ARGB;
             else if (formats[n].direct.red == 0)
                 type = PICT_TYPE_ABGR;
-            else
+            else if (formats[n].direct.blue > formats[n].direct.red)
                 type = PICT_TYPE_BGRA;
+            else
+                type = PICT_TYPE_RGBA;
             a = Ones(formats[n].direct.alphaMask);
             r = Ones(formats[n].direct.redMask);
             g = Ones(formats[n].direct.greenMask);
diff --git a/render/picture.h b/render/picture.h
index c85353a..b0885b0 100644
--- a/render/picture.h
+++ b/render/picture.h
@@ -63,6 +63,7 @@ typedef struct _Picture *PicturePtr;
 #define PICT_TYPE_COLOR		PIXMAN_TYPE_COLOR
 #define PICT_TYPE_GRAY		PIXMAN_TYPE_GRAY
 #define PICT_TYPE_BGRA		PIXMAN_TYPE_BGRA
+#define PICT_TYPE_RGBA		PIXMAN_TYPE_RGBA
 
 #define PICT_FORMAT_COLOR(f)	PIXMAN_FORMAT_COLOR(f)
 
@@ -79,6 +80,8 @@ typedef enum _PictFormatShort {
     PICT_x8b8g8r8 = PIXMAN_x8b8g8r8,
     PICT_b8g8r8a8 = PIXMAN_b8g8r8a8,
     PICT_b8g8r8x8 = PIXMAN_b8g8r8x8,
+    PICT_r8g8b8a8 = PIXMAN_r8g8b8a8,
+    PICT_r8g8b8x8 = PIXMAN_r8g8b8x8,
 
 /* 24bpp formats */
     PICT_r8g8b8 = PIXMAN_r8g8b8,
-- 
2.1.0.rc1

_______________________________________________
[email protected]: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel

Reply via email to