From mboxrd@z Thu Jan 1 00:00:00 1970 MIME-Version: 1.0 In-Reply-To: <55dbceb34c7d3f45100fd9cbf396b510@felloff.net> References: <55dbceb34c7d3f45100fd9cbf396b510@felloff.net> Date: Mon, 9 Dec 2013 04:43:20 +0000 Message-ID: From: Conor Williams To: Fans of the OS Plan 9 from Bell Labs <9fans@9fans.net> Content-Type: multipart/alternative; boundary=001a11c36742a1ee6b04ed12a294 Subject: Re: [9fans] libmemlayer bug Topicbox-Message-UUID: 939221aa-ead8-11e9-9d60-3106f5b1d025 --001a11c36742a1ee6b04ed12a294 Content-Type: text/plain; charset=ISO-8859-1 have you a screen shot? can you do attachments on this group?? On Mon, Dec 9, 2013 at 4:09 AM, wrote: > when drawing a replicated source image with a clipr with > clipr.min > Pt(0, 0), drawclip() would translate the > src->clipr on the dstr but then clamp the source rectangle > back on src->r. > > this causes problems in libmemlayer when it drawclips() at each iteration > when traversing down the layers. the clamping of sr back to src->r (which > is 1x1 > in the example below) it will shift the destination rectangle to the right > as it is reapplied at each loop iteration. > > #include > #include > #include > > 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); > } > } > > in 9front, i added drawclipnorepl() function that is like drawclip() but > does not clamp > the source and mask rectangles to be in src->r and mask->r and use it in > libmemlayer. > > > http://code.google.com/p/plan9front/source/detail?r=c18ae5b7ea0ee138080824c4f164628f899b7770 > > -- > cinap > > --001a11c36742a1ee6b04ed12a294 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable
have you a screen shot? can you do attachments on this gro= up??


On = Mon, Dec 9, 2013 at 4:09 AM, <cinap_lenrek@felloff.net> wrote:
when drawing a replicated source image with = a clipr with
clipr.min > Pt(0, 0), drawclip() would translate the
src->clipr on the dstr but then clamp the source rectangle
back on src->r.

this causes problems in libmemlayer when it drawclips() at each iteration when traversing down the layers. the clamping of sr back to src->r (whic= h is 1x1
in the example below) it will shift the destination rectangle to the right<= br> as it is reapplied at each loop iteration.

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

Image *blue;
Image *red;

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

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

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

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

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

=A0 =A0 =A0 =A0 for(;;){
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 sleep(1000);
=A0 =A0 =A0 =A0 }
}

in 9front, i added drawclipnorepl() function that is like drawclip() but do= es not clamp
the source and mask rectangles to be in src->r and mask->r and use it= in libmemlayer.

http://code.google.com/p/= plan9front/source/detail?r=3Dc18ae5b7ea0ee138080824c4f164628f899b7770
--
cinap


--001a11c36742a1ee6b04ed12a294--