diff options
author | cinap_lenrek <cinap_lenrek@felloff.net> | 2013-12-09 03:35:01 +0100 |
---|---|---|
committer | cinap_lenrek <cinap_lenrek@felloff.net> | 2013-12-09 03:35:01 +0100 |
commit | 71dbddef166f855e28dfae1989ddbd663d38176a (patch) | |
tree | ad74b330dc2aed585e5eab98298bd766d559835e /sys/man | |
parent | 193e55b88cec346a4c3f301057aef692a859b642 (diff) |
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);
}
}
Diffstat (limited to 'sys/man')
-rw-r--r-- | sys/man/2/memdraw | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/sys/man/2/memdraw b/sys/man/2/memdraw index df68b699d..733ae0e78 100644 --- a/sys/man/2/memdraw +++ b/sys/man/2/memdraw @@ -25,6 +25,7 @@ memfillpoly, memimageline, memimagedraw, drawclip, +drawclipnorepl, memlinebbox, memlineendsize, allocmemsubfont, @@ -139,6 +140,9 @@ void memimagedraw(Memimage *dst, Rectangle r, Memimage *src, int drawclip(Memimage *dst, Rectangle *dr, Memimage *src, Point *sp, Memimage *mask, Point *mp, Rectangle *sr, Rectangle *mr) +int drawclipnorepl(Memimage *dst, Rectangle *dr, Memimage *src, + Point *sp, Memimage *mask, Point *mp, + Rectangle *sr, Rectangle *mr) Rectangle memlinebbox(Point p0, Point p1, int end0, int end1, int radius) int memlineendsize(int end) @@ -396,8 +400,18 @@ but translated so the upper left corners are the returned .B sp and .BR mp . +.I Drawclipnorepl +does the same as +.B drawclip +but avoids clamping +.B sp +and +.B mr +within the image rectangle of source and mask when replicated. .I Drawclip -returns zero when the clipped rectangle is empty. +and +.I drawclipnorepl +return zero when the clipped rectangle is empty. .I Memlinebbox returns a conservative bounding box containing a line between two points |