plan9fox/sys/include
cinap_lenrek 71dbddef16 draw: fix drawing of replicated source image on memlayer with a clip rectangle
when a replicated source image with a clipr with clipr.min > Pt(0, 0),
drawclip() would properly translate the src->clipr on the dstr
but then clamp the source rectangle back on src->r.

while traversing down multiple layers, this would cause the translation to
be applied multiple times to the dst rectangle giving the wrong image result.

this change adds a new drawclipnorepl() function that avoids the clamping
of source and mask rectangles to src->r and mask->r. this is then used in
libmemlayer.

the final memimagedraw() call will call drawclip() which will do the final
claming.

a testcase is provided:

#include <u.h>
#include <libc.h>
#include <draw.h>

Image *blue;
Image *red;

void
main(int, char *argv[])
{
	Image *i;

	if(initdraw(nil, nil, argv[0]) < 0)
		sysfatal("initdraw: %r");
	i = allocimage(display, screen->r, screen->chan, 1, DWhite);

	red = allocimage(display, Rect(0,0,1,1), screen->chan, 1, DRed);
	blue = allocimage(display, Rect(0,0,1,1), screen->chan, 1, DPaleblue);
	replclipr(red, 1, Rect(10, 10, 110, 110));
	replclipr(blue, 1, Rect(11, 11, 111, 111));

	/* draw on non-layer, works correctly */
	draw(i, i->r, red, nil, ZP);
	draw(i, i->r, blue, nil, ZP);
	draw(screen, screen->r, i, nil, i->r.min);
	flushimage(display, 1);

	/* draw on (screen) layer is too far to the right */
	draw(screen, screen->r, red, nil, ZP);
	draw(screen, screen->r, blue, nil, ZP);
	flushimage(display, 1);

	for(;;){
		sleep(1000);
	}
}
2013-12-09 03:35:01 +01:00
..
ape change Rune from ushort to uint for to 21 bit runes (thanks mischief!) 2013-10-17 12:02:45 +02:00
9p.h lib9p: defer closing down srv until the last request has been responded, Tversion message size 2013-01-30 06:26:03 +01:00
a.out.h libmach: add arm64 constants (import from sources) 2012-08-02 22:23:58 +02:00
aml.h libaml: amldelay(), _OSI(), fix bug in Load() (from plhk's acpi patch) 2013-09-07 14:40:24 +02:00
ar.h
auth.h libauth: fix authrpc buffer overflow (import from sources) 2012-08-02 22:22:05 +02:00
authsrv.h
avl.h
bin.h
bio.h bio: use UTFmax for Bungetsize and fix libmach to include <libc.h> before <bio.h> (from sources) 2013-05-04 18:30:49 +02:00
bootexec.h
complete.h
control.h
ctype.h
cursor.h
disk.h Add alignment hints for e512 ATA drives. 2012-09-09 17:22:12 +12:00
draw.h draw: add badrect() function to reject zero, negative size or orverly huge rectangles 2013-06-16 19:01:46 +02:00
event.h
fcall.h
fis.h Add alignment hints for e512 ATA drives. 2012-09-09 17:22:12 +12:00
flate.h
frame.h
geometry.h
html.h libhtml: fix potential linked list corruption 2013-09-05 00:55:58 +02:00
httpd.h
ip.h
json.h make libjson from /sys/src/cmd/btc/json.c 2013-10-27 15:44:33 -04:00
keyboard.h rio: add ^B control sequence to move cursor to output point 2013-08-04 06:45:58 +02:00
libc.h change Rune from ushort to uint for to 21 bit runes (thanks mischief!) 2013-10-17 12:02:45 +02:00
libsec.h added ecdsa to factotum 2012-06-06 16:43:15 +02:00
mach.h libmach: add arm64 constants (import from sources) 2012-08-02 22:23:58 +02:00
memdraw.h draw: fix drawing of replicated source image on memlayer with a clip rectangle 2013-12-09 03:35:01 +01:00
memlayer.h
mouse.h
mp.h mp.h: fix typo 2013-02-10 20:46:56 +01:00
ndb.h
nfs3.h
oventi.h
plumb.h
pool.h
rdbg.h
regexp.h
scribble.h
stdio.h
String.h
sunrpc.h
thread.h
tos.h
trace.h
venti.h