Module Name:    xsrc
Committed By:   macallan
Date:           Wed Jul  3 15:29:34 UTC 2013

Modified Files:
        xsrc/external/mit/xf86-video-suncg14/dist/src: cg14.h cg14_accel.c
            cg14_render.c

Log Message:
- fetch fill colour for text drawing in CheckComposite, swap red and blue
  channels as needed
- support solid sources without a drawable
now gtk2 apps no longer crash the Xserver and text is drawn in the correct
colour
next step: 32bit PictOpOver with 32bit mask, gtk2 seems to use those a lot


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 xsrc/external/mit/xf86-video-suncg14/dist/src/cg14.h
cvs rdiff -u -r1.4 -r1.5 \
    xsrc/external/mit/xf86-video-suncg14/dist/src/cg14_accel.c
cvs rdiff -u -r1.3 -r1.4 \
    xsrc/external/mit/xf86-video-suncg14/dist/src/cg14_render.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: xsrc/external/mit/xf86-video-suncg14/dist/src/cg14.h
diff -u xsrc/external/mit/xf86-video-suncg14/dist/src/cg14.h:1.8 xsrc/external/mit/xf86-video-suncg14/dist/src/cg14.h:1.9
--- xsrc/external/mit/xf86-video-suncg14/dist/src/cg14.h:1.8	Wed Jul  3 02:05:52 2013
+++ xsrc/external/mit/xf86-video-suncg14/dist/src/cg14.h	Wed Jul  3 15:29:34 2013
@@ -99,7 +99,7 @@ typedef struct {
 	uint32_t	srcformat, dstformat, mskformat;
 	uint32_t	fillcolour;
 	int		op;
-	Bool		source_is_solid;
+	Bool		source_is_solid, no_source_pixmap;
 	int		xdir, ydir;	
 	ExaDriverPtr 	pExa;
 } Cg14Rec, *Cg14Ptr;

Index: xsrc/external/mit/xf86-video-suncg14/dist/src/cg14_accel.c
diff -u xsrc/external/mit/xf86-video-suncg14/dist/src/cg14_accel.c:1.4 xsrc/external/mit/xf86-video-suncg14/dist/src/cg14_accel.c:1.5
--- xsrc/external/mit/xf86-video-suncg14/dist/src/cg14_accel.c:1.4	Wed Jul  3 02:05:52 2013
+++ xsrc/external/mit/xf86-video-suncg14/dist/src/cg14_accel.c	Wed Jul  3 15:29:34 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: cg14_accel.c,v 1.4 2013/07/03 02:05:52 macallan Exp $ */
+/* $NetBSD: cg14_accel.c,v 1.5 2013/07/03 15:29:34 macallan Exp $ */
 /*
  * Copyright (c) 2013 Michael Lorenz
  * All rights reserved.
@@ -583,19 +583,24 @@ CG14PrepareComposite(int op, PicturePtr 
 
 	ENTER;
 
+	p->no_source_pixmap = FALSE;
+	p->source_is_solid = FALSE;
+
 	if (pSrcPicture->format == PICT_a1) {
 		xf86Msg(X_ERROR, "src mono, dst %x, op %d\n",
 		    pDstPicture->format, op);
 		if (pMaskPicture != NULL) {
 			xf86Msg(X_ERROR, "msk %x\n", pMaskPicture->format);
 		}
-	} 
+	}
 	if (pSrcPicture->pSourcePict != NULL) {
 		if (pSrcPicture->pSourcePict->type == SourcePictTypeSolidFill) {
 			p->fillcolour =
 			    pSrcPicture->pSourcePict->solidFill.color;
-			xf86Msg(X_ERROR, "%s: solid src %08x\n",
+			DPRINTF(X_ERROR, "%s: solid src %08x\n",
 			    __func__, p->fillcolour);
+			p->no_source_pixmap = TRUE;
+			p->source_is_solid = TRUE;
 		}
 	}
 	if ((pMaskPicture != NULL) && (pMaskPicture->pSourcePict != NULL)) {
@@ -616,12 +621,43 @@ CG14PrepareComposite(int op, PicturePtr 
 		p->mskpitch = 0;
 		p->mskformat = 0;
 	}
-	p->source_is_solid = 
-	   ((pSrc->drawable.width == 1) && (pSrc->drawable.height == 1));
-	p->srcoff = exaGetPixmapOffset(pSrc);		
-	p->srcpitch = exaGetPixmapPitch(pSrc);		
+	if (pSrc != NULL) {
+		p->source_is_solid = 
+		   ((pSrc->drawable.width == 1) && (pSrc->drawable.height == 1));
+		p->srcoff = exaGetPixmapOffset(pSrc);
+		p->srcpitch = exaGetPixmapPitch(pSrc);
+		if (p->source_is_solid) {
+			p->fillcolour = *(uint32_t *)(p->fb + p->srcoff);
+		}
+	}
 	p->srcformat = pSrcPicture->format;
 	p->dstformat = pDstPicture->format;
+	
+	if (p->source_is_solid) {
+		uint32_t temp;
+
+		/* stuff source colour into SX registers, swap as needed */
+		temp = p->fillcolour;
+		switch (p->srcformat) {
+			case PICT_a8r8g8b8:
+			case PICT_x8r8g8b8:
+				write_sx_reg(p, SX_QUEUED(9), temp & 0xff);
+				temp = temp >> 8;
+				write_sx_reg(p, SX_QUEUED(10), temp & 0xff);
+				temp = temp >> 8;
+				write_sx_reg(p, SX_QUEUED(11), temp & 0xff);
+				break;
+			case PICT_a8b8g8r8:
+			case PICT_x8b8g8r8:
+				write_sx_reg(p, SX_QUEUED(11), temp & 0xff);
+				temp = temp >> 8;
+				write_sx_reg(p, SX_QUEUED(10), temp & 0xff);
+				temp = temp >> 8;
+				write_sx_reg(p, SX_QUEUED(9), temp & 0xff);
+				break;
+		}
+		write_sx_reg(p, SX_QUEUED(8), 0xff);
+	}
 	p->op = op;
 	if (op == PictOpSrc) {
 		CG14PrepareCopy(pSrc, pDst, 1, 1, GXcopy, 0xffffffff);

Index: xsrc/external/mit/xf86-video-suncg14/dist/src/cg14_render.c
diff -u xsrc/external/mit/xf86-video-suncg14/dist/src/cg14_render.c:1.3 xsrc/external/mit/xf86-video-suncg14/dist/src/cg14_render.c:1.4
--- xsrc/external/mit/xf86-video-suncg14/dist/src/cg14_render.c:1.3	Wed Jul  3 02:05:52 2013
+++ xsrc/external/mit/xf86-video-suncg14/dist/src/cg14_render.c	Wed Jul  3 15:29:34 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: cg14_render.c,v 1.3 2013/07/03 02:05:52 macallan Exp $ */
+/* $NetBSD: cg14_render.c,v 1.4 2013/07/03 15:29:34 macallan Exp $ */
 /*
  * Copyright (c) 2013 Michael Lorenz
  * All rights reserved.
@@ -63,9 +63,7 @@ void CG14Comp_Over32Solid(Cg14Ptr p,
 	int line, x, i;
 
 	ENTER;
-	/* first get the source colour */
-	write_sx_io(p, p->srcoff, SX_LDUQ0(8, 0, p->srcoff & 7));
-	write_sx_reg(p, SX_QUEUED(8), 0xff);
+
 	for (line = 0; line < height; line++) {
 		mskx = msk;
 		dstx = dst;
@@ -164,9 +162,6 @@ void CG14Comp_Over8Solid(Cg14Ptr p,
 #endif
 	ENTER;
 
-	/* first get the source colour */
-	write_sx_io(p, p->srcoff, SX_LDUQ0(8, 0, p->srcoff & 7));
-	write_sx_reg(p, SX_QUEUED(8), 0xff);
 	DPRINTF(X_ERROR, "src: %d %d %d, %08x\n", read_sx_reg(p, SX_QUEUED(9)),
 	    read_sx_reg(p, SX_QUEUED(10)), read_sx_reg(p, SX_QUEUED(11)),
 	    *(uint32_t *)(p->fb + p->srcoff));
@@ -447,10 +442,13 @@ void CG14Comp_Over32Mask(Cg14Ptr p,
 			write_sx_io(p, mskx & (~7), SX_LDB(9, 0, mskx & 7));
 			/* fetch dst pixel */
 			write_sx_io(p, dstx, SX_LDUQ0(20, 0, dstx & 7));
-			/* apply mask */
+			/* stick mask alpha into SCAM */
 			write_sx_reg(p, SX_INSTRUCTIONS,
-			    SX_ANDS(12, 9, 16, 3));
+			    SX_ORS(9, 0, R_SCAM, 0));
+			/* apply mask */
 			/* src is premultiplied with alpha */
+			write_sx_reg(p, SX_INSTRUCTIONS,
+			    SX_SAXP16X16SR8(12, 0, 16, 3));
 			/* write inverted alpha into SCAM */
 			write_sx_reg(p, SX_INSTRUCTIONS,
 			    SX_XORV(16, 8, R_SCAM, 0));

Reply via email to