9front - general discussion about 9front
 help / color / mirror / Atom feed
* "libmemdraw: fix byte ordering in memfillcolor()"
@ 2016-06-05 14:17 Dave MacFarlane
  2016-06-05 15:10 ` [9front] " cinap_lenrek
  0 siblings, 1 reply; 2+ messages in thread
From: Dave MacFarlane @ 2016-06-05 14:17 UTC (permalink / raw)
  To: 9front

[-- Attachment #1: Type: text/plain, Size: 353 bytes --]

Can someone point me to the patch that fixes "libmemdraw: fix byte ordering
in memfillcolor()" from the release notes of the 2014-11-06 9front release?

I'm having an issue under Plan9 where some of my colour channels are
getting swapped with libmemdraw which doesn't happen under 9front or
drawterm, and that note seems suspiciously relevant..

- Dave

[-- Attachment #2: Type: text/html, Size: 986 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [9front] "libmemdraw: fix byte ordering in memfillcolor()"
  2016-06-05 14:17 "libmemdraw: fix byte ordering in memfillcolor()" Dave MacFarlane
@ 2016-06-05 15:10 ` cinap_lenrek
  0 siblings, 0 replies; 2+ messages in thread
From: cinap_lenrek @ 2016-06-05 15:10 UTC (permalink / raw)
  To: 9front

changeset:   3879:3042d2acd1a6
user:        cinap_lenrek@felloff.net
date:        Fri Sep 19 17:49:48 2014 +0200
summary:     libmemdraw: fix byte ordering in memfillcolor()

diff -r 60b6bf7cd078 -r 3042d2acd1a6 sys/src/libmemdraw/draw.c
--- a/sys/src/libmemdraw/draw.c	Fri Sep 19 05:22:26 2014 +0200
+++ b/sys/src/libmemdraw/draw.c	Fri Sep 19 17:49:48 2014 +0200
@@ -2051,6 +2051,12 @@
 memsets(void *vp, ushort val, int n)
 {
 	ushort *p, *ep;
+	uchar b[2];
+
+	/* make little endian */
+	b[0] = val;
+	b[1] = val>>8;
+	val = *(ushort*)b;
 
 	p = vp;
 	ep = p+n;
@@ -2062,6 +2068,14 @@
 memsetl(void *vp, ulong val, int n)
 {
 	ulong *p, *ep;
+	uchar b[4];
+
+	/* make little endian */
+	b[0] = val;
+	b[1] = val>>8;
+	b[2] = val>>16;
+	b[3] = val>>24;
+	val = *(ulong*)b;
 
 	p = vp;
 	ep = p+n;
@@ -2075,15 +2089,17 @@
 	uchar *p, *ep;
 	uchar a,b,c;
 
-	p = vp;
-	ep = p+3*n;
 	a = val;
 	b = val>>8;
 	c = val>>16;
+
+	p = vp;
+	ep = p+3*n;
 	while(p<ep){
-		*p++ = a;
-		*p++ = b;
-		*p++ = c;
+		p[0] = a;
+		p[1] = b;
+		p[2] = c;
+		p += 3;
 	}
 }
 
@@ -2126,9 +2142,9 @@
 			break;
 		case CMap:
 			p = img->cmap->cmap2rgb+3*ov;
-			r = *p++;
-			g = *p++;	
-			b = *p;
+			r = p[0];
+			g = p[1];
+			b = p[2];
 			break;
 		}
 	}
@@ -2202,9 +2218,8 @@
 	 */
 	m = Simplesrc|Simplemask|Fullmask;
 	if((par->state&m)==m && (par->srgba&0xFF) == 0xFF && (op ==S || op == SoverD)){
-		uchar *dp, p[4];
 		int d, dwid, ppb, np, nb;
-		uchar lm, rm;
+		uchar *dp, lm, rm;
 
 DBG print("memopt, dst %p, dst->data->bdata %p\n", dst, dst->data->bdata);
 		dwid = dst->width*sizeof(ulong);
@@ -2273,11 +2288,6 @@
 				memset(dp, v, dx);
 			return 1;
 		case 16:
-			p[0] = v;		/* make little endian */
-			p[1] = v>>8;
-			v = *(ushort*)p;
-DBG print("dp=%p; dx=%d; for(y=0; y<%d; y++, dp+=%d)\nmemsets(dp, v, dx);\n",
-	dp, dx, dy, dwid);
 			for(y=0; y<dy; y++, dp+=dwid)
 				memsets(dp, v, dx);
 			return 1;
@@ -2286,11 +2296,6 @@
 				memset24(dp, v, dx);
 			return 1;
 		case 32:
-			p[0] = v;		/* make little endian */
-			p[1] = v>>8;
-			p[2] = v>>16;
-			p[3] = v>>24;
-			v = *(ulong*)p;
 			for(y=0; y<dy; y++, dp+=dwid)
 				memsetl(dp, v, dx);
 			return 1;
@@ -2439,9 +2444,8 @@
 static int
 chardraw(Memdrawparam *par)
 {
-	ulong bits;
 	int i, ddepth, dy, dx, x, bx, ex, y, npack, bsh, depth, op;
-	ulong v, maskwid, dstwid;
+	ulong bits, v, maskwid, dstwid;
 	uchar *wp, *rp, *q, *wc;
 	ushort *ws;
 	ulong *wl;

--
cinap


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2016-06-05 15:10 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-06-05 14:17 "libmemdraw: fix byte ordering in memfillcolor()" Dave MacFarlane
2016-06-05 15:10 ` [9front] " cinap_lenrek

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).