<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">2015-04-15 23:31 GMT+02:00 karl ramberg <span dir="ltr">&lt;<a href="mailto:karlramberg@gmail.com" target="_blank">karlramberg@gmail.com</a>&gt;</span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">You also get weird artifacts when the gradient orientation and normal is very small.</div></blockquote><div><br></div><div>looks funny:)<br></div><div><br> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><br></div><div>In attached image, orientation is 0@-1 and normal is 1@1</div><span class="HOEnZb"><font color="#888888"><div><br></div><div>Karl</div></font></span></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Apr 15, 2015 at 10:34 PM, Nicolai Hess <span dir="ltr">&lt;<a href="mailto:nicolaihess@web.de" target="_blank">nicolaihess@web.de</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote"><span>2015-04-08 20:02 GMT+02:00 karl ramberg <span dir="ltr">&lt;<a href="mailto:karlramberg@gmail.com" target="_blank">karlramberg@gmail.com</a>&gt;</span>:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Confirmed.<span><font color="#888888"><div><br></div><div>Karl</div></font></span></div><div><div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Apr 8, 2015 at 5:33 PM, Nicolai Hess <span dir="ltr">&lt;<a href="mailto:nicolaihess@web.de" target="_blank">nicolaihess@web.de</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div><div><div>In order to reproduce it, draw a rectangle with radial gradient fill, with direction<br></div><div>and normal, both of length 1.<br></div></div></div></div></blockquote></div></div></div></div></blockquote><div><br></div></span><div>This is not the reason why it crashes. It happens for other values as well:<span><br><br>|form canvas fill direction normal|<br></span>direction := 4@0.<br>normal := 0@2.<span><br>form := Form extent:300@300 depth:32.<br>canvas := form getCanvas.<br></span>fill := GradientFillStyle new colorRamp:{0 -&gt; Color white . 0.5 -&gt; Color green . 1 -&gt; Color blue};origin:400@400;direction:direction;normal:normal;radial:true;yourself.<br>canvas fillRectangle: (0@0 extent:800@800) fillStyle: fill.<span><br>Display getCanvas drawImage: form at: 300@300<br><br></span></div><div>This uses a different value for direction and normal and the fill is defined for a larger area (800x800) -&gt; CRASH<br></div><div><br><div>Maybe, this is a rare bug, because, normally you don&#39;t create a small gradient t o<br></div><div>fill a large area. But a vm crash is not nice, I would like to get this<br></div>fixed.<br><br>I am not sure what is the exact cause, but it may come from a signed integer overflwo,<br></div><div>It looks like Balloon uses fixed point arithmetik (binary scaling).<br></div><div>This fixed point representation (16.16 bit fixed point represented in a 32 integer) tend<br></div><div>to overflow, especially for operations like computing the squared length of a vector<br></div><div>x*x+y*y -&gt; overflow -&gt; result is a negative number.<br><br></div><div>Possible solutions:<br></div><div>downscale prior to the multiplication -&gt; lost of precision<br></div><div>use a larger datatype for intermediate results.<br><br></div><div>It looks like B2D uses the first option (look at senders of<br>accurateLengthOfwith<br></div><div>and<br></div><div>squaredLenghtOfwith<br></div><div>Maybe there is something wrong with the other code that<br></div><div>multiplies the values, or the 16.16 bit fixed point is just not<br></div><div>large enough for some fills?<br><br></div><br><div>Any ideas?<span><font color="#888888"><br><br></font></span></div><span><font color="#888888"><div>Nicolai<br></div></font></span><div><div><div><br><br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div><div><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div><div><div></div><div><br>This one works (no vm crash):<br>|form canvas fill direction normal|<br>direction := 1@0.<br>normal := 0@0.<br>form := Form extent:300@300 depth:32.<br>canvas := form getCanvas.<br>fill := GradientFillStyle new colorRamp:{0 -&gt; Color white . 0.5 -&gt; Color green . 1 -&gt; Color blue};origin:150@150;direction:direction;normal:normal;radial:true;yourself.<br>canvas fillRectangle: (50@50 extent:200@200) fillStyle: fill.<br>Display getCanvas drawImage: form at: 300@300.<br><br><br>direction := 1@0.<br>normal := 0@0.<br></div>-&gt; OK<br><br>direction := 0@0.<br>normal := 0@1.<br></div>-&gt; OK<br><br>direction := 1@0.<br>normal := 0@1.<br></div>-&gt; VM-Crash (Pharo and Squeak)<br><br>Pharo:<br>VM Version: Cog VM 4.0.0 (release) from Feb 16 2015<br>Compiler: gcc 4.6.2<br>Interpreter Build: NBCoInterpreter NativeBoost-CogPlugin-EstebanLorenzano.21 uuid: 4d9b9bdf-2dfa-4c0b-99eb-5b110dadc697 Feb 16 2015<br>Cogit Build: NBCogit NativeBoost-CogPlugin-EstebanLorenzano.21 uuid: 4d9b9bdf-2dfa-4c0b-99eb-5b110dadc697 Feb 16 2015<br>Source Version: <a href="https://github.com/pharo-project/pharo-vm.git" target="_blank">https://github.com/pharo-project/pharo-vm.git</a> Commit: 55fbd0b0279998a4a33852f5afb3d213986cc3ae Date: 2015-02-16 17:54:00 +0100 By: Esteban Lorenzano &lt;<a href="mailto:estebanlm@gmail.com" target="_blank">estebanlm@gmail.com</a>&gt; Jenkins build #14895<br><br>Current byte code: -1<br>Primitive index: 117<br>Smalltalk stack dump:<br>  0x24c830 M BalloonEngine&gt;copyLoopFaster 0x6b09b80: a(n) BalloonEngine<br>  0x24c848 M BalloonEngine&gt;copyBits 0x6b09b80: a(n) BalloonEngine<br>  0x24c860 M BalloonEngine&gt;postFlushIfNeeded 0x6b09b80: a(n) BalloonEngine<br>  0x24c884 I BalloonEngine&gt;drawRectangle:fill:borderWidth:borderColor:transform: 0x6b09b80: a(n) BalloonEngine<br>  0x24c8b8 I BalloonCanvas&gt;drawRectangle:color:borderWidth:borderColor: 0x6b099c0: a(n) BalloonCanvas<br>  0x24c8e8 I BalloonCanvas&gt;fillRectangle:basicFillStyle: 0x6b099c0: a(n) BalloonCanvas<br><br><br>Squeak:<br><div><div><div>VM Version: Cog VM 4.0.0 (release) from Aug 22 2013<br>Compiler: gcc 3.4.4 (cygming special, gdc 0.12, using dmd 0.125)<br>Interpreter Build: CoInterpreter VMMaker.oscog-eem.331 uuid: 37d2e4b0-2f37-4e2d-8313-c63637785e59 Aug 22 2013<br>Cogit Build: StackToRegisterMappingCogit VMMaker.oscog-eem.333 uuid: 84da9cb8-7f30-4cb7-b4fb-239a11f63b54 Aug 22 2013<br>Source Version: VM: r2776 <a href="http://www.squeakvm.org/svn/squeak/branches/Cog" target="_blank">http://www.squeakvm.org/svn/squeak/branches/Cog</a><br>Plugins: r2545 <a href="http://squeakvm.org/svn/squeak/trunk/platforms/Cross/plugins" target="_blank">http://squeakvm.org/svn/squeak/trunk/platforms/Cross/plugins</a><br><br>Current byte code: -1<br>Primitive index: 117<span><font color="#888888"><br><br><br></font></span></div><span><font color="#888888"><div>nicolai<br></div></font></span></div></div></div>
<br><br>
<br></blockquote></div><br></div>
</div></div></blockquote></div></div></div><br></div></div>
<br><br>
<br></blockquote></div><br></div>
</div></div></blockquote></div><br></div></div>