shithub: rd

Download patch

ref: 5296a39c42a2801fc3e88d36b9b709eea44b5b0e
parent: d64f31c9862f2ab9b779dd9bd5c3363d6764c650
author: Yaroslav Kolomiiets <yarikos@gmail.com>
date: Mon Aug 8 11:40:21 EDT 2016

add scroll() func

--- a/draw.c
+++ b/draw.c
@@ -56,3 +56,14 @@
 	if(display->locking)
 		unlockdisplay(display);
 }
+
+void
+scroll(Display* d, Rectangle r, Rectangle sr)
+{
+	if(d && d->locking)
+		lockdisplay(d);
+	if(d)
+		draw(d->screenimage, r, d->screenimage, nil, sr.min);
+	if(d && d->locking)
+		unlockdisplay(d);
+}
--- a/egdi.c
+++ b/egdi.c
@@ -295,33 +295,26 @@
 static uchar*
 scrblt(Rdp*, uchar* p, uchar* ep, int ctl, int fmask)
 {
-	static Rectangle r;
-	static Point pt;
-	static int rop3;
-	Rectangle rs;
-	Point ps;
+	static	Rectangle wr;
+	static	Point wp;
+	static	int rop3;
+	Rectangle r, sr;
 
-	p = getoffrect(&r, p, ep, ctl, fmask);
+	p = getoffrect(&wr, p, ep, ctl, fmask);
 	if(fmask&1<<4)
 		rop3 = *p++;
-	p = getpt(&pt, p, ep, ctl, fmask>>5);
+	p = getpt(&wp, p, ep, ctl, fmask>>5);
+	if(ctl&Clipped)
+		rectclip(&wr, gc.clipr);
 
 	if(rop3 != ROP2_COPY){
 		fprint(2, "scrblt: rop3 %#hhux is not supported\n", rop3);
 		return p;
 	}
-	rs = r;
-	if(ctl&Clipped)
-		rectclip(&rs, gc.clipr);	// not replclipr: need to clip dst only
-	rs = rectaddpt(rs, screen->r.min);
-	ps = addpt(pt, screen->r.min);
 
-	if(display->locking)
-		lockdisplay(display);
-	draw(screen, rs, screen, nil, ps);
-	if(display->locking)
-		unlockdisplay(display);
-
+	r = rectaddpt(wr, screen->r.min);
+	sr = rectaddpt(Rpt(wp, Pt(Dx(r), Dy(r))), screen->r.min);
+	scroll(display, r, sr);
 	return p;
 }
 
--- a/fns.h
+++ b/fns.h
@@ -53,3 +53,5 @@
 void		pbshort(uchar*,int);
 
 uchar*	putsdh(uchar*,uchar*,int,int,int,int);
+
+void		scroll(Display*, Rectangle, Rectangle);