Renderer_outline_aa::line3 () Infinite loop

Source: Internet
Author: User

situation One:

The function appears in an infinite loop in the following two-sentence code:

while (ABS (SX-LP.X1) + ABS (SY-LP.Y1) > Lp2.len)
{
SX = (lp.x1 + sx) >> 1;
Sy = (lp.y1 + sy) >> 1;
}

When debugging a breakpoint, the result of an infinite loop is that the value appears as follows:

Sx=0x3d00
Lp.x1=0x3d01
Sy=0x7a00
Lp.y1=0x7a01
Lp2.len=1

in this case, SX and the Sy value is never changed, and the condition of the loop is always set ( While (2>1).

Try modifying the following:

SX = lp.x1 + ((sx-lp.x1) >> 1);
SY = lp.y1 + ((sy-lp.y1) >> 1);

The purpose of the modification is to eventually jump out of the loop. Does not understand the logic of the code.

situation Two:

There is also an infinite loop for the following code:

while (ABS (EX-LP.X2) + ABS (EY-LP.Y2) >
Lp2.len)
{
/* Original
ex = (lp.x2 + ex) >> 1;
EY = (lp.y2 + ey) >> 1;
*/
ex = Lp.x2 + ((ex-lp.x2) >> 1);
EY = Lp.y2 + ((ey-lp.y2) >> 1);

}

situation Three:

Agg_renderer_outline_aa file 1801 Line (Clipbox enabled):

while (ABS (SX-LP.X1) + ABS (SY-LP.Y1) >lp2.len)

{

SX = (lp.x1 + sx) >> 1;

Sy = (lp.y1 + sy) >> 1;

}

SX = 365433

SY =-512

Lp.x1 = 365434

Lp.y1 =-511

Sx/sy always keep the same value: ( -511 + -512) >> 1 =-512;

Modify the following:

while (ABS (SX-LP.X1) + ABS (SY-LP.Y1) > (Lp2.len + 1))
{
...
}

Lp2.len Plus 1 .

It's very pleasure to offer me point

From

Http://vector-agg-general.narkive.com/Zl9USSxj/renderer-outline-aa-line3-infinite-loop-and-fix

Http://vector-agg-general.narkive.com/pJq7asry/infinite-loop-in-renderer-outline-aa


Renderer_outline_aa::line3 () Infinite loop

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.