On Fri, Dec 11, 2009 at 12:49 AM, Jonas Sicking <span dir="ltr"><jonas@sicking.cc></span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div class="im">On Thu, Dec 10, 2009 at 1:36 PM, Oliver Hunt <<a href="mailto:oliver@apple.com">oliver@apple.com</a>> wrote:<br>
> Ideally if we were to have a graphics context in a worker we'd want it to be<br>
> the standard CanvasRenderingContext2D, the only real problem is that<br>
> CanvasRenderingContext2D references the parent canvas element which clearly<br>
> won't fly in a worker.<br>
> I've been thinking of creating something like a WorkerCanvas which is<br>
> basically a DOM-less CanvasRenderingContext2D, so you can do<br>
> var canvas = new WorkerCanvas(width, height);<br>
> canvas.putImageData(myData);<br>
<br>
</div>Do you really need all of CanvasRenderingContext2D? I.e. do you really<br>
need things like spline drawing, pattern filling, and text?<br>
<br>
My concern weather the libraries backing CanvasRenderingContext2D are<br>
generally threadsafe?<br></blockquote><div><br></div><div>CanvasRenderingContext2Ds would never need to be shared between threads because they're "cloned" when passed...so is your concern that the libraries are only meant to ever be used from one thread? Maybe I'm being naive, but it would surprise me if that turned out to be an issue.</div>
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
The use case brought up at the beginning of this thread was about<br>
scaling. It would be dramatically easier to implement just a few<br>
things like transformations, cropping and encoding/decoding, than to<br>
implement all of CanvasRenderingContext2D off the main thread.<br></blockquote><div><br></div><div>Resizing images was just one use. I could easily imagine apps wanting to generate more complex images on background threads without needing to implement things like spline drawing, pattern filling, and text themselves.</div>
</div>