<DIV>Hi Joonas,</DIV>
<DIV>&nbsp;</DIV>
<DIV>Thank you very much for your help.</DIV>
<DIV><BR>And I still have some questions bellow:</DIV>
<DIV>(1) I compare the DDA algorithms in http://en.wikipedia.org/wiki/Digital_Differential_Analyzer_(graphics_algorithm)<BR>with that in cairo , there are a few&nbsp;differences .</DIV>
<DIV>&gt;&gt;&nbsp; #define&nbsp;RENDER_EDGE_STEP_SMALL(edge)<BR>&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp;{&nbsp;&nbsp;edge-&gt;x&nbsp;+=&nbsp;edge-&gt;stepx_small;<BR>&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;edge-&gt;e&nbsp;+=&nbsp;edge-&gt;dx_small;<BR>&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if(edge-&gt;e&nbsp;&gt;&nbsp;0)<BR>&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{&nbsp;&nbsp;edge-&gt;e&nbsp;-=&nbsp;edge-&gt;dy;<BR>&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;edge-&gt;x&nbsp;+=&nbsp;edge-&gt;signdx;<BR>&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<BR>&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp;}<BR>The value of&nbsp;edge-&gt;x is the x&nbsp;&nbsp;coordinate&nbsp;multiply 65536,but the value of edge-&gt;signdx is "-1" or "1" , &nbsp;it makes no difference by edge-&gt;x&nbsp;+=&nbsp;edge-&gt;signdx . I do not&nbsp;understand .<BR></DIV>
<DIV>(2)What's the meaning of "Cairo&nbsp;internally&nbsp;uses&nbsp;<FONT color="#ff0000">24.8</FONT>&nbsp;and&nbsp;pixman&nbsp;uses&nbsp;<FONT color="#ff0000">16.16&nbsp;</FONT>fixed&nbsp;</DIV>
<DIV>point&nbsp;representation"&nbsp; ,&nbsp;"24.8" and "16.16" ?</DIV>
<DIV>&nbsp;</DIV>
<DIV>(3) I use 1.8.10 cairo code and I can not find the 1.9 code at download/releases , is it insecure yet? How could I&nbsp;know&nbsp;the</DIV>
<DIV>differences between 1.8 cairo code and 1.9 cairo code ?</DIV>
<DIV>&nbsp;</DIV>
<DIV>Thanks,</DIV>
<DIV>chen&nbsp;</DIV>
<DIV></DIV><BR><PRE><BR>
&gt;
&gt;Hi&nbsp;Chen,
&gt;
&gt;On&nbsp;Mon,&nbsp;19&nbsp;Jul&nbsp;2010,&nbsp;xigcw&nbsp;wrote:
&gt;
&gt;&gt;&nbsp;I&nbsp;am&nbsp;learning&nbsp;cairo&nbsp;with&nbsp;image&nbsp;backend&nbsp;for&nbsp;several&nbsp;weeks&nbsp;,&nbsp;and&nbsp;
&gt;&gt;&nbsp;I&nbsp;have&nbsp;several&nbsp;questions&nbsp;whitch&nbsp;troubles&nbsp;me&nbsp;a&nbsp;lot.
&gt;
&gt;Your&nbsp;questions&nbsp;indicate&nbsp;to&nbsp;me&nbsp;that&nbsp;you're&nbsp;probably&nbsp;looking&nbsp;at&nbsp;the&nbsp;&lt;=&nbsp;
&gt;1.8&nbsp;cairo&nbsp;code.&nbsp;&nbsp;The&nbsp;1.9&nbsp;code&nbsp;paths&nbsp;for&nbsp;the&nbsp;image&nbsp;backend&nbsp;have&nbsp;changed&nbsp;
&gt;a&nbsp;lot.
&gt;
&gt;&gt;&nbsp;1.&nbsp;There&nbsp;are&nbsp;two&nbsp;data&nbsp;changes&nbsp;in&nbsp;cairo:
&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp;(1)&nbsp;fdx&nbsp;=&nbsp;_cairo_fixed_from_double(dx)
&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp;(2)&nbsp;x_off_fixed&nbsp;=&nbsp;pixman_int_to_fixed(x_off)
&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp;that&nbsp;,&nbsp;fdx&nbsp;=&nbsp;dx&nbsp;*&nbsp;256&nbsp;&nbsp;,&nbsp;x_off_fixed&nbsp;=&nbsp;x_off&nbsp;*&nbsp;256&nbsp;*&nbsp;256,
&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp;What's&nbsp;the&nbsp;meaning&nbsp;about&nbsp;the&nbsp;two&nbsp;changes?
&gt;
&gt;These&nbsp;are&nbsp;conversions&nbsp;from&nbsp;doubles&nbsp;(_cairo_fixed_from_double)&nbsp;or&nbsp;
&gt;integers&nbsp;(pixman_int_to_fixed)&nbsp;into&nbsp;fixed&nbsp;point&nbsp;formats&nbsp;used&nbsp;by&nbsp;cairo&nbsp;
&gt;and&nbsp;pixman.&nbsp;&nbsp;Cairo&nbsp;internally&nbsp;uses&nbsp;24.8&nbsp;and&nbsp;pixman&nbsp;uses&nbsp;16.16&nbsp;fixed&nbsp;
&gt;point&nbsp;representation.
&gt;
&gt;http://en.wikipedia.org/wiki/Fixed-point_arithmetic
&gt;
&gt;&gt;&nbsp;2.&nbsp;I&nbsp;use&nbsp;a&nbsp;debugger&nbsp;to&nbsp;see&nbsp;how&nbsp;the&nbsp;thick&nbsp;stroking&nbsp;works.
&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp;After&nbsp;cairo_traps_add_trap,the&nbsp;polygon&nbsp;will&nbsp;be&nbsp;reduced&nbsp;
&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp;to&nbsp;trapezoid,&nbsp;and&nbsp;then&nbsp;the&nbsp;pixman&nbsp;will&nbsp;compute&nbsp;the&nbsp;right&nbsp;and
&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp;left&nbsp;edge&nbsp;of&nbsp;the&nbsp;trapezoid&nbsp;.is&nbsp;that&nbsp;right?
&gt;
&gt;Yes.
&gt;
&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp;When&nbsp;compute&nbsp;the&nbsp;edge&nbsp;of&nbsp;trapezoid&nbsp;,the&nbsp;algorithms&nbsp;is&nbsp;different
&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp;from&nbsp;Bresenham&nbsp;algorithms,&nbsp;so&nbsp;I&nbsp;would&nbsp;like&nbsp;to&nbsp;know&nbsp;what&nbsp;computer&nbsp;
&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp;graphics&nbsp;algorithms&nbsp;does&nbsp;cairo&nbsp;use?(draw&nbsp;line)
&gt;
&gt;The&nbsp;trapezoid&nbsp;stepper&nbsp;is&nbsp;a&nbsp;fairly&nbsp;straight&nbsp;forward&nbsp;DDA&nbsp;over&nbsp;a&nbsp;17x15&nbsp;
&gt;subpixel&nbsp;grid.
&gt;
&gt;http://en.wikipedia.org/wiki/Digital_Differential_Analyzer_(graphics_algorithm)
&gt;
&gt;&gt;&nbsp;3.&nbsp;&nbsp;#define&nbsp;RENDER_EDGE_STEP_SMALL(edge)
&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp;{&nbsp;&nbsp;edge-&gt;x&nbsp;+=&nbsp;edge-&gt;stepx_small;
&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;edge-&gt;e&nbsp;+=&nbsp;edge-&gt;dx_small;
&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if(edge-&gt;e&nbsp;&gt;&nbsp;0)
&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{&nbsp;&nbsp;edge-&gt;e&nbsp;-=&nbsp;edge-&gt;dy;
&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;edge-&gt;x&nbsp;+=&nbsp;edge-&gt;signdx;
&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp;}
&gt;
&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp;What's&nbsp;the&nbsp;meaning&nbsp;of&nbsp;edge-&gt;e&nbsp;
&gt;
&gt;The&nbsp;edge-&gt;e&nbsp;field&nbsp;is&nbsp;the&nbsp;"excess"&nbsp;of&nbsp;the&nbsp;x&nbsp;coordinate&nbsp;and&nbsp;represents&nbsp;
&gt;the&nbsp;fractional&nbsp;part&nbsp;of&nbsp;the&nbsp;x&nbsp;coordinate&nbsp;along&nbsp;the&nbsp;edge&nbsp;for&nbsp;the&nbsp;current&nbsp;
&gt;y.&nbsp;&nbsp;For&nbsp;an&nbsp;edge&nbsp;which&nbsp;goes&nbsp;dx&nbsp;units&nbsp;to&nbsp;the&nbsp;right&nbsp;and&nbsp;dy&nbsp;units&nbsp;down&nbsp;the&nbsp;
&gt;excess&nbsp;is&nbsp;(dx&nbsp;mod&nbsp;dy)&nbsp;-&nbsp;dy.&nbsp;&nbsp;The&nbsp;bias&nbsp;-dy&nbsp;is&nbsp;added&nbsp;to&nbsp;make&nbsp;checking&nbsp;of&nbsp;
&gt;the&nbsp;overflow&nbsp;condition&nbsp;in&nbsp;the&nbsp;DDA&nbsp;a&nbsp;comparison&nbsp;against&nbsp;zero&nbsp;rather&nbsp;
&gt;than&nbsp;dy.
&gt;
&gt;&gt;&nbsp;or&nbsp;What's&nbsp;the&nbsp;meaning&nbsp;of&nbsp;if(edge-&gt;e&nbsp;&gt;&nbsp;0)?
&gt;
&gt;Without&nbsp;the&nbsp;bias&nbsp;-dy&nbsp;in&nbsp;edge-&gt;e,&nbsp;the&nbsp;test&nbsp;for&nbsp;overflow&nbsp;would&nbsp;require&nbsp;
&gt;fetching&nbsp;dy&nbsp;into&nbsp;a&nbsp;register&nbsp;just&nbsp;for&nbsp;the&nbsp;test,&nbsp;so&nbsp;comparison&nbsp;against&nbsp;
&gt;zero&nbsp;is&nbsp;usually&nbsp;faster.
&gt;
&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp;What's&nbsp;the&nbsp;different&nbsp;between&nbsp;&nbsp;RENDER_EDGE_STEP_SMALL(edge)&nbsp;&nbsp;and
&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp;RENDER_EDGE_STEP_BIG(edge)?
&gt;
&gt;One&nbsp;advances&nbsp;the&nbsp;edge&nbsp;by&nbsp;the&nbsp;amount&nbsp;STEP_Y_SMALL(8)&nbsp;downwards&nbsp;and&nbsp;the&nbsp;
&gt;other&nbsp;by&nbsp;STEP_Y_BIG(8).
&gt;
&gt;For&nbsp;the&nbsp;purposes&nbsp;of&nbsp;rasterization&nbsp;the&nbsp;pixel&nbsp;grid&nbsp;is&nbsp;subdivided&nbsp;into&nbsp;a&nbsp;
&gt;subpixel&nbsp;grid&nbsp;of&nbsp;size&nbsp;17&nbsp;x&nbsp;15.&nbsp;&nbsp;Within&nbsp;each&nbsp;subpixel&nbsp;in&nbsp;the&nbsp;17&nbsp;x&nbsp;15&nbsp;
&gt;grid&nbsp;there&nbsp;is&nbsp;a&nbsp;sample&nbsp;in&nbsp;the&nbsp;middle&nbsp;of&nbsp;the&nbsp;subpixel,&nbsp;and&nbsp;if&nbsp;the&nbsp;
&gt;sample&nbsp;falls&nbsp;within&nbsp;the&nbsp;trapezoid&nbsp;defined&nbsp;by&nbsp;two&nbsp;edges,&nbsp;then&nbsp;it&nbsp;
&gt;contributes&nbsp;to&nbsp;the&nbsp;coverage&nbsp;of&nbsp;its&nbsp;pixel&nbsp;by&nbsp;1/255.
&gt;
&gt;That's&nbsp;the&nbsp;ideal&nbsp;anyway,&nbsp;but&nbsp;remember&nbsp;that&nbsp;pixman&nbsp;uses&nbsp;16.16&nbsp;fixed&nbsp;
&gt;point,&nbsp;so&nbsp;it&nbsp;can't&nbsp;represent&nbsp;the&nbsp;height&nbsp;or&nbsp;width&nbsp;of&nbsp;a&nbsp;subpixel&nbsp;
&gt;_exactly_&nbsp;correctly&nbsp;(65536&nbsp;is&nbsp;not&nbsp;divisible&nbsp;by&nbsp;15&nbsp;or&nbsp;17.)&nbsp;&nbsp;So&nbsp;instead&nbsp;
&gt;of&nbsp;having&nbsp;15&nbsp;rows&nbsp;of&nbsp;subpixels&nbsp;of&nbsp;uniform&nbsp;height&nbsp;(which&nbsp;it&nbsp;can't&nbsp;
&gt;represent),&nbsp;pixman&nbsp;uses&nbsp;14&nbsp;rows&nbsp;of&nbsp;subpixels&nbsp;of&nbsp;the&nbsp;same,&nbsp;nearly&nbsp;
&gt;correct&nbsp;but&nbsp;representable&nbsp;height,&nbsp;and&nbsp;one&nbsp;one&nbsp;slightly&nbsp;larger&nbsp;row&nbsp;
&gt;cover&nbsp;the&nbsp;space&nbsp;between&nbsp;the&nbsp;14th&nbsp;subpixel&nbsp;row&nbsp;and&nbsp;the&nbsp;bottom&nbsp;of&nbsp;the&nbsp;
&gt;full&nbsp;pixel.&nbsp;&nbsp;The&nbsp;height&nbsp;of&nbsp;the&nbsp;smaller&nbsp;subpixels&nbsp;is&nbsp;STEP_Y_SMALL(8)&nbsp;
&gt;and&nbsp;the&nbsp;height&nbsp;of&nbsp;the&nbsp;larger&nbsp;subpixels&nbsp;is&nbsp;STEP_Y_BIG(8).
&gt;
&gt;Hope&nbsp;that&nbsp;helps,
&gt;
&gt;Joonas
</PRE><br><br><span title="neteasefooter"/><hr/>
<a href="http://qiye.163.com/?163" target="_blank">您想拥有和网易免费邮箱一样强大的软件吗?</a>
</span>