[Spice-devel] [PATCH spice-html5]Handling non top-down lz_rgb
Jeremy White
jwhite at codeweavers.com
Mon Jan 21 12:02:22 PST 2013
Hi Vincent,
> +function flip_image_data(img)
> +{
> + var w = img.width;
> + var h = img.height;
> + var temp_w = w;
> + var temp_h = h;
> + var buff = new Uint8Array(img.width * img.height * 4);
> + while (temp_h--)
> + {
> + while (temp_w--)
> + {
> + buff[(temp_h * w + temp_w) * 4] = img.data[((h - temp_h -
> 1) * w + temp_w) * 4];
> + buff[(temp_h * w + temp_w) * 4 + 1] = img.data[((h - temp_h
> - 1) * w + temp_w) * 4 + 1];
> + buff[(temp_h * w + temp_w) * 4 + 2] = img.data[((h - temp_h
> - 1) * w + temp_w) * 4 + 2];
> + buff[(temp_h * w + temp_w) * 4 + 3] = img.data[((h - temp_h
> - 1) * w + temp_w) * 4 + 3];
> + }
> + temp_w = w;
> + }
> + img.data.set(buff);
Couldn't this be done more simply by swapping line by line, rather than
pixel by pixel? If I'm not mistaken, the Uint8Array set() method will
take an array and offset as a parameter, and you can get a subarray
fairly easily. I have no idea if that will provide a performance boost,
but it will least enable the Javascript engines to try.
Either way, if you could resubmit this as a discrete git-format-patch
entry (probably with signed-off-by while you're at it), I'd appreciate it.
Cheers,
Jeremy
More information about the Spice-devel
mailing list