Mesa (master): st/xorg: setup solid fills

Zack Rusin zack at kemper.freedesktop.org
Tue Sep 1 21:44:57 UTC 2009


Module: Mesa
Branch: master
Commit: a8cbb1563213086f58d3b82b6d0755a59eb43c79
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=a8cbb1563213086f58d3b82b6d0755a59eb43c79

Author: Zack Rusin <zackr at vmware.com>
Date:   Tue Sep  1 17:49:32 2009 -0400

st/xorg: setup solid fills

---

 src/gallium/state_trackers/xorg/xorg_composite.c |   34 ++++++++++++++++++++-
 1 files changed, 32 insertions(+), 2 deletions(-)

diff --git a/src/gallium/state_trackers/xorg/xorg_composite.c b/src/gallium/state_trackers/xorg/xorg_composite.c
index 132c05e..fafd77f 100644
--- a/src/gallium/state_trackers/xorg/xorg_composite.c
+++ b/src/gallium/state_trackers/xorg/xorg_composite.c
@@ -40,6 +40,24 @@ static const struct xorg_composite_blend xorg_blends[] = {
      PIPE_BLENDFACTOR_INV_SRC_ALPHA, PIPE_BLENDFACTOR_INV_SRC_ALPHA },
 };
 
+static INLINE void
+pixel_to_float4(PictFormatPtr format,
+                CARD32 pixel, float *color)
+{
+   CARD32	    r, g, b, a;
+
+   debug_assert(format->type == PictTypeDirect);
+
+   r = (pixel >> format->direct.red) & format->direct.redMask;
+   g = (pixel >> format->direct.green) & format->direct.greenMask;
+   b = (pixel >> format->direct.blue) & format->direct.blueMask;
+   a = (pixel >> format->direct.alpha) & format->direct.alphaMask;
+   color[0] = ((float)r) / ((float)format->direct.redMask);
+   color[1] = ((float)g) / ((float)format->direct.greenMask);
+   color[2] = ((float)b) / ((float)format->direct.blueMask);
+   color[3] = ((float)a) / ((float)format->direct.alphaMask);
+}
+
 struct acceleration_info {
    int op : 16;
    int with_mask : 1;
@@ -355,8 +373,20 @@ bind_shaders(struct exa_context *exa, int op,
    struct xorg_shader shader;
 
    if (pSrcPicture) {
-      vs_traits |= VS_COMPOSITE;
-      fs_traits |= FS_COMPOSITE;
+      if (pSrcPicture->pSourcePict) {
+         if (pSrcPicture->pSourcePict->type == SourcePictTypeSolidFill) {
+            fs_traits |= FS_FILL;
+            vs_traits |= VS_FILL;
+            pixel_to_float4(pSrcPicture->pFormat,
+                            pSrcPicture->pSourcePict->solidFill.color,
+                            exa->solid_color);
+         } else {
+            debug_assert("!gradients not supported");
+         }
+      } else {
+         fs_traits |= FS_COMPOSITE;
+         vs_traits |= VS_COMPOSITE;
+      }
    }
 
    if (pMaskPicture) {




More information about the mesa-commit mailing list