<div dir="ltr"><div class="gmail_extra"><br><div class="gmail_quote">2013/12/20 David T. Lewis <span dir="ltr">&lt;<a href="mailto:lewis@mail.msen.com" target="_blank">lewis@mail.msen.com</a>&gt;</span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
Moving this to vm-dev for discussion of the BitBlt primitive.<br>
<br>
On Fri, Dec 20, 2013 at 02:13:29AM +0100, Nicolas Cellier wrote:<br>
&gt; 2013/12/20 Bert Freudenberg &lt;<a href="mailto:bert@freudenbergs.de">bert@freudenbergs.de</a>&gt;<br>
&gt;<br>
&gt; &gt;<br>
&gt; &gt; On 20.12.2013, at 00:55, Nicolas Cellier &lt;<br>
&gt; &gt; <a href="mailto:nicolas.cellier.aka.nice@gmail.com">nicolas.cellier.aka.nice@gmail.com</a>&gt; wrote:<br>
&gt; &gt;<br>
&gt; &gt; 2013/12/13 Nicolas Cellier &lt;<a href="mailto:nicolas.cellier.aka.nice@gmail.com">nicolas.cellier.aka.nice@gmail.com</a>&gt;<br>
&gt; &gt;<br>
&gt; &gt;&gt; I feel like it would be better to change pixelValueAt: so as to always<br>
&gt; &gt;&gt; unhibernate, but I did not dare if ever someone had the idea of sending it<br>
&gt; &gt;&gt; in tight loops (one shouldn&#39;t, there is BitBlt for that purpose, but who<br>
&gt; &gt;&gt; knows...).<br>
&gt; &gt;&gt;<br>
&gt; &gt;&gt; Maybe we could fail primitivePixelValueAt if receiver is Byte like, and<br>
&gt; &gt;&gt; unhibernate in fallback code.<br>
&gt; &gt;&gt; We would let every other BitBlt primitives accept a ByteArray to allow<br>
&gt; &gt;&gt; BitBlt tricks.<br>
&gt; &gt;&gt;<br>
&gt; &gt;&gt; Thoughts?<br>
&gt; &gt;&gt;<br>
&gt; &gt;&gt;<br>
&gt; &gt; No one raised a comment so far.<br>
&gt; &gt; Isn&#39;t it a good idea to fail the primitive?<br>
&gt; &gt;<br>
&gt; &gt;<br>
&gt; &gt; The primitive must fail, yes. That is simply a bug. Before that primitive<br>
&gt; &gt; existed, pixelValueAt: used BitBlt which did the unhibernate.<br>
&gt; &gt;<br>
&gt; &gt; If yes, then it&#39;s very simple to implement, just add:<br>
&gt; &gt;<br>
&gt; &gt;     (interpreterProxy isWords: bitmap)    ifFalse:[interpreterProxy<br>
&gt; &gt; primitiveFail].<br>
&gt; &gt;<br>
&gt; &gt;<br>
&gt; &gt; IMHO the primitive should do the same check as BitBlt: verify that the<br>
&gt; &gt; size of the bits is exactly right given width, height, and depth.<br>
&gt; &gt;<br>
&gt; &gt; - Bert -<br>
&gt; &gt;<br>
&gt;<br>
&gt; I opened <a href="http://bugs.squeak.org/view.php?id=7799" target="_blank">http://bugs.squeak.org/view.php?id=7799</a> just in case.<br>
&gt;<br>
<br>
Thanks for opening the <a href="http://bugs.squeak.org" target="_blank">bugs.squeak.org</a> issue. Your patch adds this:<br>
<br>
        bitsSize := interpreterProxy byteSizeOf: bitmap.<br>
        ((interpreterProxy isWordsOrBytes: bitmap)<br>
                and: [bitsSize = (stride * height * 4 &quot;bytes per word&quot;)])<br>
                        ifFalse: [^interpreterProxy primitiveFail].<br>
<br>
Which translates as:<br>
<br>
        bitsSize = interpreterProxy-&gt;byteSizeOf(bitmap);<br>
        if (!((interpreterProxy-&gt;isWordsOrBytes(bitmap)) &amp;&amp; (bitsSize == ((stride * height) * 4)))) {<br>
                interpreterProxy-&gt;primitiveFail();<br>
                return null;<br>
        }<br>
<br>
This looks like exactly what Bert was suggesting.<br>
<br>
I think there are two things we should test:<br>
<br>
1) Check if the extra computation has an effect on performance.<br></blockquote><div><br></div><div>I don&#39;t think the difference will be measurable, that&#39;s very few ops overhead...<br></div><div>Even if it was, it must be compared to in-image protection alternative.<br>
So I don&#39;t think that this is relevant in this case.<br></div><div> <br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
2) Check to make sure the logic works on the 64 bit image, to make sure<br>
that the 4 bytes per word does the right thing (I think that it will work,<br>
and I can follow up on this later to be sure).<br>
<br>
Dave<br>
<br></blockquote><div> </div><div>The 4 bytes per word is also hardcoded in other BitBlt primitive because that&#39;s really what the bit blt expect, 32bit words.<br></div><div>I&#39;m a bit puzzled by 64bits image terminology, is variableWordSubclass: composed of 32bits words or 64 bits words (like pointers)?<br>
</div></div><br><br></div></div>