27.01.2015 Views

A Methodology for Fine- Grained Parallelism in JavaScript ...

A Methodology for Fine- Grained Parallelism in JavaScript ...

A Methodology for Fine- Grained Parallelism in JavaScript ...

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Pixastic Benchmarks<br />

Ported 4 image process<strong>in</strong>g rout<strong>in</strong>es: <strong>in</strong>vert, sepia, sharpen,<br />

and edge detection<br />

Orig<strong>in</strong>al Invert Code<br />

function <strong>in</strong>vert_ref(params)<br />

{<br />

var data = Pixastic.prepareData(params);<br />

var <strong>in</strong>vertAlpha =<br />

!!params.options.<strong>in</strong>vertAlpha;<br />

}<br />

var rect = params.options.rect;<br />

var p = rect.width * rect.height;<br />

var pix = p*4, pix1 = pix + 1,<br />

var pix2 = pix + 2, pix3 = pix + 3;<br />

while (p--) {<br />

data[pix-=4] = 255 - data[pix];<br />

data[pix1-=4] = 255 - data[pix1];<br />

data[pix2-=4] = 255 - data[pix2];<br />

if (<strong>in</strong>vertAlpha)<br />

data[pix3-=4] = 255 - data[pix3];<br />

}<br />

return true;<br />

Sluice Invert Code<br />

function <strong>in</strong>vert_sluice(data, <strong>in</strong>vert_alpha)<br />

{<br />

this.<strong>in</strong>vertAlpha = <strong>in</strong>vert_alpha;<br />

this.data = data;<br />

}<br />

this.work = function () {<br />

var w = this.pop();<br />

var h = this.pop();<br />

var p = w * h;<br />

};<br />

var pix = p*4, pix1 = pix + 1;<br />

var pix2 = pix + 2, pix3 = pix + 3;<br />

while (p--) {<br />

this.data[pix-=4] = 255 - this.data[pix];<br />

this.data[pix1-=4] = 255 - this.data[pix1];<br />

this.data[pix2-=4] = 255 - this.data[pix2];<br />

if (this.<strong>in</strong>vertAlpha)<br />

this.data[pix3-=4] = 255 - this.data[pix3];<br />

}<br />

this.push(w);<br />

this.push(h);<br />

return false;

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!