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 Import sources from 2011-03-30 iso image - lib 2011-03-30 19:35:09 +03:00
auth.h libauth: fix authrpc buffer overflow (import from sources) 2012-08-02 22:22:05 +02:00
authsrv.h Import sources from 2011-03-30 iso image - lib 2011-03-30 19:35:09 +03:00
avl.h Import sources from 2011-03-30 iso image - lib 2011-03-30 19:35:09 +03:00
bin.h Import sources from 2011-03-30 iso image - lib 2011-03-30 19:35:09 +03:00
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 Import sources from 2011-03-30 iso image - lib 2011-03-30 19:35:09 +03:00
complete.h Import sources from 2011-03-30 iso image - lib 2011-03-30 19:35:09 +03:00
control.h Import sources from 2011-03-30 iso image - lib 2011-03-30 19:35:09 +03:00
ctype.h Import sources from 2011-03-30 iso image - lib 2011-03-30 19:35:09 +03:00
cursor.h Import sources from 2011-03-30 iso image - lib 2011-03-30 19:35:09 +03:00
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 libdraw: added enter() and eenter() functions 2011-10-31 19:41:48 +01:00
fcall.h Import sources from 2011-03-30 iso image - lib 2011-03-30 19:35:09 +03:00
fis.h Add alignment hints for e512 ATA drives. 2012-09-09 17:22:12 +12:00
flate.h Import sources from 2011-03-30 iso image - lib 2011-03-30 19:35:09 +03:00
frame.h Import sources from 2011-03-30 iso image - lib 2011-03-30 19:35:09 +03:00
geometry.h Import sources from 2011-03-30 iso image - lib 2011-03-30 19:35:09 +03:00
html.h libhtml: fix potential linked list corruption 2013-09-05 00:55:58 +02:00
httpd.h Import sources from 2011-03-30 iso image - lib 2011-03-30 19:35:09 +03:00
ip.h Import sources from 2011-03-30 iso image - lib 2011-03-30 19:35:09 +03:00
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 Import sources from 2011-03-30 iso image - lib 2011-03-30 19:35:09 +03:00
mouse.h libdraw: added enter() and eenter() functions 2011-10-31 19:41:48 +01:00
mp.h mp.h: fix typo 2013-02-10 20:46:56 +01:00
ndb.h ndb/cs: fix use after free caused by flush/clunk happening before dns lookup finishes 2012-03-23 04:02:34 +01:00
nfs3.h Import sources from 2011-03-30 iso image - lib 2011-03-30 19:35:09 +03:00
oventi.h Import sources from 2011-03-30 iso image - lib 2011-03-30 19:35:09 +03:00
plumb.h Import sources from 2011-03-30 iso image - lib 2011-03-30 19:35:09 +03:00
pool.h Import sources from 2011-03-30 iso image - lib 2011-03-30 19:35:09 +03:00
rdbg.h Import sources from 2011-03-30 iso image - lib 2011-03-30 19:35:09 +03:00
regexp.h Import sources from 2011-03-30 iso image - lib 2011-03-30 19:35:09 +03:00
scribble.h Import sources from 2011-03-30 iso image - lib 2011-03-30 19:35:09 +03:00
stdio.h Import sources from 2011-03-30 iso image - lib 2011-03-30 19:35:09 +03:00
String.h Import sources from 2011-03-30 iso image - lib 2011-03-30 19:35:09 +03:00
sunrpc.h Import sources from 2011-03-30 iso image - lib 2011-03-30 19:35:09 +03:00
thread.h libthread: reimplemented i/o procs using new interrupt ctl message 2011-08-22 03:04:01 +02:00
tos.h Import sources from 2011-03-30 iso image - lib 2011-03-30 19:35:09 +03:00
trace.h Import sources from 2011-03-30 iso image - lib 2011-03-30 19:35:09 +03:00
venti.h Import sources from 2011-03-30 iso image - lib 2011-03-30 19:35:09 +03:00